Base solution for your next web application

Activities of "jonas452"

Hi,

FYI, the passwords aren't encrypted. They are hashed. Its completly different. It is also mathematicly impossible to unhash a hash.

The passwords are being generated and managed through aspnet identity core i think.

Hey,

It's not that easy it seems. How do i handle the JobByteDbContextConfigurer?

As you can see i changed the references in the project but i feel like that cant be enough.

Any tips would be much appreciated.

Yeah, i don't know why i said TPH but i mean TPT. Anyway Thx for the tip. I'll try your suggestion.

Hi,

I've tried to upgrade to 4.1 with mixed succes. After digging around i discovered that the latest version of EFCore does not support TPH(Table per heneritance). Wich is a problem for me cause i use that quite often in my database design.

So I'm thinking why not just roll back to EF6. But how do i best tackle that? Let's say i download a blank ASPNet Zero solution V4.1.

How would you guys change the EntityFrameworkCore project to EF6?

Thx for you advice.

Thx for figuring out a solution for me! Any idea why just adding css/js wasn't okay for the datepicker but it was for the datetimepicker? You never know when i run against this problem again ;)

Anyway, many thanks for your help!

Thx, email with a wetransfer link has been sent. I've only recently started on the front end. So the angular project is almost exactly the same as the template project.

Sure. Here you go. Thx

import { Component, ViewChild, Injector, ElementRef, Output, EventEmitter } from '@angular/core';
import { ModalDirective } from 'ng2-bootstrap';
import { PersonServiceProxy, EmployeeFullDto } from '@shared/service-proxies/service-proxies';
import { AppComponentBase } from '@shared/common/app-component-base';

@Component({
    selector: 'createEmployeeModal',
    templateUrl: './create-Employee-modal.component.html'
})
export class CreateEmployeeModalComponent extends AppComponentBase {

    @Output() modalSave: EventEmitter<any> = new EventEmitter<any>();

    @ViewChild('modal') modal: ModalDirective;
    @ViewChild('nameInput') nameInput: ElementRef;
    @ViewChild('dateInput') dateInput: ElementRef;


    employee: EmployeeFullDto;

    active: boolean = false;
    saving: boolean = false;

    constructor(
        injector: Injector,
        private _personService: PersonServiceProxy
    ) {
        super(injector);
    }

    show(): void {
        this.active = true;
        this.employee = new EmployeeFullDto();        
        this.modal.show();
    }

    onShown(): void {
        $(this.dateInput.nativeElement).datepicker({});
        $(this.nameInput.nativeElement).focus();
    }

    save(): void {
        this.saving = true;
        this._personService.createEmployee(this.employee[0])
            .finally(() => this.saving = false)
            .subscribe(() => {
                this.notify.info(this.l('SavedSuccessfully'));
                this.close();
                this.modalSave.emit(this.employee);
            });
    }

    close(): void {
        this.modal.hide();
        this.active = false;
    }
}
<div bsModal #modal="bs-modal" (onShown)="onShown()" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true" [config]="{backdrop: 'static'}">
    <div class="modal-dialog">
        <div class="modal-content">
            <form *ngIf="active" #employeeForm="ngForm" novalidate (ngSubmit)="save()">
                <div class="modal-header">
                    <button type="button" class="close" (click)="close()" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">
                        <span>{{l("CreateNewEmployee")}}</span>
                    </h4>
                </div>
                <div class="modal-body">
                    
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input #nameInput class="form-control" type="text" name="name" [(ngModel)]="employee.name" required maxlength="32">
                        <label>{{l("Name")}}</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="text" name="firstName" [(ngModel)]="employee.firstName" required maxlength="32">
                        <label>{{l("Surname")}}</label>
                    </div>                    

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="email" name="email" [(ngModel)]="employee.email" required maxlength="255" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$">
                        <label>{{l("EmailAddress")}}</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="text" name="phoneNr" [(ngModel)]="employee.phoneNr" >
                        <label>{{l("PhoneNr")}}</label>
                    </div> 

                    

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input #dateInput class="form-control" type="text" name="dateInput" [(ngModel)]="employee.dateOfBirth" >
                        <label>{{l("DateOfBirth")}}</label>
                    </div>


                    

                </div>
                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-default" (click)="close()">{{l("Cancel")}}</button>
                    <button type="submit" class="btn btn-primary blue" [disabled]="!employeeForm.form.valid" [buttonBusy]="saving" [busyText]="l('SavingWithThreeDot')"><i class="fa fa-save"></i> 
                    <span>{{l("Save")}}</span></button>
                </div>
            </form>
        </div>
    </div>
</div>

Yeah No Prob.

regular class : src / SixByte.JobByte.Core / Scheduler /

namespace SixByte.JobByte.Scheduler
{
    public abstract class Day : FullAuditedEntity,IMustHaveTenant
    {        
        public virtual int TenantId { get; set; }
        [Required]
        public virtual DateTime OnDate { get; set; }
        public virtual string Description { get; set; }
        [Required]
        public virtual bool Locked { get; set; }
        //public virtual WorkSchedule WorkSchedule { get; set; }

        //Foreign key
        public virtual int WorkScheduleId { get; set; }
    }
}

And then in your dbcontext : src / SixByte.JobByte.EntityFramework / EntityFramework / JobByteDbContext.cs Do note: I made an extra addition for switching to mariaDB/mysql. Was needed because mysql doesn't support schemas and i always will group my tables. As you can see i changed the schema's of aspnetzero and aspnetboilerplate. = no dbo schema

namespace SixByte.JobByte.EntityFramework
{
    /* Constructors of this DbContext is important and each one has it's own use case.
     * - Default constructor is used by EF tooling on development time.
     * - constructor(nameOrConnectionString) is used by ABP on runtime.
     * - constructor(existingConnection) is used by unit tests.
     * - constructor(existingConnection,contextOwnsConnection) can be used by ABP if DbContextEfTransactionStrategy is used.
     * See http://www.aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration for more.
     */

    [DbConfigurationType(typeof(JobByteDbConfiguration))]
    public class JobByteDbContext : AbpZeroDbContext<Tenant, Role, User>
    {
        private const DbSysType _DBTYPE = DbSysType.MSSQL;

        /* Define an IDbSet for each entity of the application */
        private const string SCHEMA_ABP = "ABP";
        private const string SCHEMA_ASPZERO = "AZF";
        private const string DBSCHEMA_SCHEDULAR = "SCHED";
        private const string DBSCHEMA_COMPANY = "COMP";


        public virtual IDbSet<BinaryObject> BinaryObjects { get; set; }

        public virtual IDbSet<Friendship> Friendships { get; set; }

        public virtual IDbSet<ChatMessage> ChatMessages { get; set; }

        public virtual IDbSet<TenantCompany> TenantCompanies { get; set; }
        public virtual IDbSet<Person> Persons { get; set; }
        public virtual IDbSet<Employee> Employees { get; set; }
        public virtual IDbSet<WorkActivity> WorkActivities { get; set; }
        public virtual IDbSet<WorkSchedule> WorkSchedules { get; set; }
        public virtual IDbSet<Day> Days { get; set; }
        public virtual IDbSet<SickDay> SickDays { get; set; }
        public virtual IDbSet<WorkDay> WorkDay { get; set; }
        public virtual IDbSet<VacationDay> VacationDay { get; set; }
        public virtual IDbSet<WorkTimePeriod> WorkTimePeriod { get; set; }
        public virtual IDbSet<VacationTimePeriod> VacationTimePeriod { get; set; }
        public virtual IDbSet<TimePeriod> TimePeriods { get; set; }
        public virtual IDbSet<Holiday> Holidays { get; set; }
        public virtual IDbSet<EmployeeWorkActivity> EmployeeWorkActivities { get; set; }
        public virtual IDbSet<WorkEvent> WorkEvents { get; set; }
        public virtual IDbSet<EventType> EventTypes { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            //Basic Application Settings
            CreateBaseTables(modelBuilder);

            //Application Settings    
            CreateApplicationTables(modelBuilder);

        }

        protected void CreateBaseTables(DbModelBuilder modelBuilder)
        {
            TableCreationBasedOnDbType<AuditLog>(_DBTYPE, modelBuilder, SCHEMA_ABP, "AuditLogs");
            TableCreationBasedOnDbType<BackgroundJobInfo>(_DBTYPE, modelBuilder, SCHEMA_ABP, "BackgroundJobs");
            TableCreationBasedOnDbType<Edition>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Editions");
            TableCreationBasedOnDbType<ApplicationLanguage>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Languages");
            TableCreationBasedOnDbType<ApplicationLanguageText>(_DBTYPE, modelBuilder, SCHEMA_ABP, "LanguageTexts");
            TableCreationBasedOnDbType<NotificationInfo>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Notifications");
            TableCreationBasedOnDbType<NotificationSubscriptionInfo>(_DBTYPE, modelBuilder, SCHEMA_ABP, "NotificationSubscriptions");
            TableCreationBasedOnDbType<OrganizationUnit>(_DBTYPE, modelBuilder, SCHEMA_ABP, "OrganizationUnits");
            TableCreationBasedOnDbType<Role>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Roles");
            TableCreationBasedOnDbType<Setting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Settings");
            TableCreationBasedOnDbType<TenantNotificationInfo>(_DBTYPE, modelBuilder, SCHEMA_ABP, "TenantNotifications");
            TableCreationBasedOnDbType<Tenant>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Tenants");
            TableCreationBasedOnDbType<UserAccount>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserAccounts");
            TableCreationBasedOnDbType<UserClaim>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserClaims");
            TableCreationBasedOnDbType<UserLoginAttempt>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserLoginAttempts");
            TableCreationBasedOnDbType<UserNotificationInfo>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserNotifications");
            TableCreationBasedOnDbType<UserOrganizationUnit>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserOrganizationUnits");
            TableCreationBasedOnDbType<UserRole>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserRoles");
            TableCreationBasedOnDbType<User>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Users");
            TableCreationBasedOnDbType<UserLogin>(_DBTYPE, modelBuilder, SCHEMA_ABP, "UserLogins");
            TableCreationBasedOnDbType<EditionFeatureSetting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Features");
            TableCreationBasedOnDbType<FeatureSetting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Features");
            TableCreationBasedOnDbType<TenantFeatureSetting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Features");
            TableCreationBasedOnDbType<UserPermissionSetting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Permissions");
            TableCreationBasedOnDbType<PermissionSetting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Permissions");
            TableCreationBasedOnDbType<RolePermissionSetting>(_DBTYPE, modelBuilder, SCHEMA_ABP, "Permissions");

            TableCreationBasedOnDbType<BinaryObject>(_DBTYPE, modelBuilder, SCHEMA_ASPZERO, "BinaryObjects");
            TableCreationBasedOnDbType<ChatMessage>(_DBTYPE, modelBuilder, SCHEMA_ASPZERO, "ChatMessages");
            TableCreationBasedOnDbType<Friendship>(_DBTYPE, modelBuilder, SCHEMA_ASPZERO, "Friendships");
        }

        protected void CreateApplicationTables(DbModelBuilder modelBuilder)
        {
            TableCreationBasedOnDbType<TenantCompany>(_DBTYPE, modelBuilder, DBSCHEMA_COMPANY, "TenantCompanies");
            TableCreationBasedOnDbType<Person>(_DBTYPE, modelBuilder, DBSCHEMA_COMPANY, "Persons");
            TableCreationBasedOnDbType<Employee>(_DBTYPE, modelBuilder, DBSCHEMA_COMPANY, "Employees");
            TableCreationBasedOnDbType<EmployeeWorkActivity>(_DBTYPE, modelBuilder, DBSCHEMA_COMPANY, "EmployeeActivities");

            TableCreationBasedOnDbType<Day>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "Days");
            TableCreationBasedOnDbType<VacationTimePeriod>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "VacationTimePeriods");
            TableCreationBasedOnDbType<WorkTimePeriod>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkTimePeriods");
            TableCreationBasedOnDbType<VacationDay>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "VacationDays");
            TableCreationBasedOnDbType<WorkDay>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkDays");
            TableCreationBasedOnDbType<Holiday>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "Holidays");
            TableCreationBasedOnDbType<SickDay>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "SickDays");
            TableCreationBasedOnDbType<WorkEmployeeEvent>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkEmployeeEvents");
            TableCreationBasedOnDbType<WorkOwnCarTransportionEvent>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkOwnCarTransportionEvents");
            TableCreationBasedOnDbType<WorkSchedule>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkSchedules");
            TableCreationBasedOnDbType<WorkEvent>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkEvents");
            TableCreationBasedOnDbType<TimePeriod>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "TimePeriods");
            TableCreationBasedOnDbType<ExpenseType>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "ExpenseTypes");
            TableCreationBasedOnDbType<ExpenseNota>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "ExpenseNotas");
            TableCreationBasedOnDbType<ExpenseImage>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "ExpenseImages");
            TableCreationBasedOnDbType<EventType>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "EventTypes");
            TableCreationBasedOnDbType<WorkActivity>(_DBTYPE, modelBuilder, DBSCHEMA_SCHEDULAR, "WorkActivities");
        }

        public JobByteDbContext()
            : base(GetConnectionString())
        {

        }

        private static string GetConnectionString()
        {
            //Notice that; this logic only works on development time.
            //It is used to get connection string from appsettings.json in the Web project.

            var configuration = AppConfigurations.Get(
                WebContentDirectoryFinder.CalculateContentRootFolder()
                );

            return configuration.GetConnectionString(
                JobByteConsts.ConnectionStringName
                );
        }

        public JobByteDbContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {

        }

        public JobByteDbContext(DbConnection existingConnection)
            : base(existingConnection, false)
        {

        }

        public JobByteDbContext(DbConnection existingConnection, bool contextOwnsConnection)
            : base(existingConnection, contextOwnsConnection)
        {

        }

        private enum DbSysType
        {
            MSSQL,
            MYSQL
        }

        private void TableCreationBasedOnDbType<TEntityType>(DbSysType type, DbModelBuilder mB, string schema, string table)
            where TEntityType : class
        {
            switch (type)
            {
                case DbSysType.MSSQL:
                    {
                        mB.Entity<TEntityType>().ToTable(table, schema);
                        break;
                    }
                case DbSysType.MYSQL:
                    {
                        mB.Entity<TEntityType>().ToTable(schema + "_" + table);
                        break;
                    }
            }
        }
    }

    public class JobByteDbConfiguration : DbConfiguration
    {
        public JobByteDbConfiguration()
        {
            SetProviderServices(
                "System.Data.SqlClient",
                System.Data.Entity.SqlServer.SqlProviderServices.Instance
            );
        }
    }

Okay, I got the datetimepicker working. No issue. However. the datepicker is an issue.

<a href="https://ibb.co/ih00WQ">Klembord_afbeelding_2017_04_27_23_54_55<a target='_blank' href='https://nl.imgbb.com/'>upload picture</a><br />

As you can see. the datepicker isn't showing. here is my angular-cli.json file for clarity sake. everything linked to the datetimepicker has been removed.

{
  "project": {
    "version": "1.0.0-beta.30",
    "name": "abp-zero-template"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        {
          "glob": "abp.signalr.js",
          "input": "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/",
          "output": "./assets/abp/"
        },
        {
          "glob": "**.*",
          "input": "../node_modules/jtable/lib/localization/",
          "output": "./assets/localization/jtable/"
        },
        {
          "glob": "**.*",
          "input": "../node_modules/bootstrap-select/dist/js/i18n/",
          "output": "./assets/localization/bootstrap-select/"
        },
        {
          "glob": "**.*",
          "input": "../node_modules/timeago/locales/",
          "output": "./assets/localization/jquery-timeago/"
        }
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "../node_modules/simple-line-icons/css/simple-line-icons.css",
        "../node_modules/font-awesome/css/font-awesome.css",
        "../node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",

        "../node_modules/bootstrap-select/dist/css/bootstrap-select.css",
        "../node_modules/jquery.uniform/dist/css/default.css",
        "../node_modules/toastr/build/toastr.css",
        "../node_modules/sweetalert/dist/sweetalert.css",
        "../node_modules/jstree/dist/themes/default/style.min.css",
        "../node_modules/jtable/lib/themes/metro/blue/jtable.min.css",
        "../node_modules/morris.js/morris.css",

        "../external_libs/Jcrop/css/Jcrop.css",
        "../node_modules/bootstrap-daterangepicker/daterangepicker.css",
        "../node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css",                      

        "../src/app/shared/core.less",
        "../src/app/shared/layout/layout.less",

        "../src/assets/metronic/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.standalone.css",  

        "styles.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.min.js",
        "../node_modules/jquery-migrate/dist/jquery-migrate.min.js",
        "../node_modules/jqueryui/jquery-ui.min.js",
        "../node_modules/js-cookie/src/js.cookie.js",
        "../node_modules/jstree/dist/jstree.min.js",

        "../node_modules/bootstrap/dist/js/bootstrap.js",
        "../node_modules/bootstrap-select/dist/js/bootstrap-select.js",
        "../node_modules/tether/dist/js/tether.min.js",

        "../node_modules/lodash/lodash.min.js",
        "../node_modules/moment/min/moment.min.js",

        "../node_modules/signalr/jquery.signalR.js",

        "../node_modules/jtable/lib/jquery.jtable.min.js",
        "../node_modules/jtable/lib/extensions/jquery.jtable.record-actions.js",
        "../external_libs/Jcrop/js/Jcrop.js",
        "../node_modules/morris.js/morris.min.js",
        "../node_modules/raphael/raphael.min.js",
        "../node_modules/jquery-sparkline/jquery.sparkline.min.js",

        "../node_modules/toastr/toastr.js",
        "../node_modules/sweetalert/dist/sweetalert-dev.js",
        "../node_modules/block-ui/jquery.blockUI.js",
        "../node_modules/spin.js/spin.min.js",
        "../node_modules/spin.js/jquery.spin.js",

        "../node_modules/bootstrap-daterangepicker/daterangepicker.js",
        "../node_modules/jquery-slimscroll/jquery.slimscroll.min.js",
        "../node_modules/timeago/jquery.timeago.js",
        "../node_modules/localforage/dist/localforage.min.js",
        "../node_modules/bootstrap-switch/dist/js/bootstrap-switch.min.js",
        "../node_modules/push.js/push.min.js",

        "../node_modules/abp-web-resources/Abp/Framework/scripts/abp.js",
        "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js",
        "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js",
        "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js",
        "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js",
        "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js",
        "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js",

        "../src/assets/metronic/global/scripts/app.js",

        "../src/assets/metronic/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js",

        "../src/assets/metronic/admin/layout4/scripts/layout.js",
        "../src/assets/metronic/layouts/global/scripts/quick-sidebar.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "hmr": "environments/environment.hmr.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.json"
    },
    {
      "files": "e2e/**/*.ts",
      "project": "e2e/tsconfig.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    }
  }
}

I have tried every datepicker css. don't get why it doesnt show up correctly.

Thx for your help.

Finaly got around to trying it. Been building this project on my own time ;) It works. thx!

Showing 1 to 10 of 28 entries