public static void Start(SchemaBuilder sb)
        {
            DynamicLogic.Start(sb);
            DynamicSqlMigrationLogic.Start(sb);
            DynamicValidationLogic.Start(sb);
            DynamicViewLogic.Start(sb);
            DynamicTypeLogic.Start(sb);
            DynamicTypeConditionLogic.Start(sb);
            DynamicExpressionLogic.Start(sb);
            DynamicMixinConnectionLogic.Start(sb);

            DynamicCode.Namespaces.AddRange(new HashSet <string>
            {
                "Southwind.Entities",
                "Southwind.Logic",
            });

            DynamicCode.AssemblyTypes.AddRange(new HashSet <Type>
            {
                typeof(Database),
            });

            DynamicCode.AddFullAssembly(typeof(Entity));
            DynamicCode.AddFullAssembly(typeof(Database));
            DynamicCode.AddFullAssembly(typeof(AuthLogic));
            DynamicCode.AddFullAssembly(typeof(UserEntity));
            DynamicCode.AddFullAssembly(typeof(ApplicationConfigurationEntity));
            DynamicCode.AddFullAssembly(typeof(Starter));
        }
Exemple #2
0
        public List <CompilationErrorTS> Compile(bool inMemory)
        {
            SystemEventLogLogic.Log("DynamicController.Compile");
            var compileResult = new List <DynamicLogic.CompilationResult>();

            if (!inMemory)
            {
                DynamicLogic.CleanCodeGenFolder();
            }

            Dictionary <string, CodeFile> codeFiles = DynamicLogic.GetCodeFilesDictionary();

            compileResult.Add(DynamicLogic.Compile(codeFiles, inMemory: inMemory, assemblyName: DynamicCode.CodeGenAssembly, needsCodeGenAssembly: false));

            if (DynamicApiLogic.IsStarted)
            {
                Dictionary <string, CodeFile> apiFiles = DynamicApiLogic.GetCodeFiles().ToDictionaryEx(a => a.FileName, "CodeGenController C# code file");
                compileResult.Add(DynamicLogic.Compile(apiFiles, inMemory: inMemory, assemblyName: DynamicCode.CodeGenControllerAssembly, needsCodeGenAssembly: true));
                codeFiles.AddRange(apiFiles);
            }

            return((from cr in compileResult
                    from ce in cr.Errors
                    let fileName = Path.GetFileName(ce.FileName)
                                   select(new CompilationErrorTS
            {
                fileName = fileName,
                column = ce.Column,
                line = ce.Line,
                errorNumber = ce.ErrorNumber,
                errorText = ce.ErrorText,
                fileContent = codeFiles.GetOrThrow(fileName).FileContent
            })).ToList());
        }
Exemple #3
0
    public static void CompileDynamicCode()
    {
        DynamicLogic.BindCodeGenAssemblies();
        Directory.CreateDirectory(DynamicCode.CodeGenDirectory);

        var errors = new List <string>();

        try
        {
            CompilationResult?cr = null;

            bool cleaned = false;
            if (DynamicCode.CodeGenAssemblyPath.IsNullOrEmpty())
            {
                CleanCodeGenFolder();
                cleaned = true;

                {
                    Dictionary <string, CodeFile> codeFiles = GetCodeFilesDictionary();

                    cr = Compile(codeFiles, inMemory: false, assemblyName: DynamicCode.CodeGenAssembly, needsCodeGenAssembly: false);

                    if (cr.Errors.Count == 0)
                    {
                        DynamicCode.CodeGenAssemblyPath = cr.OutputAssembly;
                    }
                    else
                    {
                        errors.Add("Errors compiling  dynamic assembly:\r\n" + cr.Errors.ToString("\r\n").Indent(4));
                    }
                }
            }

            if (DynamicApiLogic.IsStarted && (DynamicCode.CodeGenControllerAssemblyPath.IsNullOrEmpty() || cleaned))
            {
                Dictionary <string, CodeFile> codeFiles = DynamicApiLogic.GetCodeFiles().ToDictionary(a => a.FileContent);
                cr = Compile(codeFiles, inMemory: false, assemblyName: DynamicCode.CodeGenControllerAssembly, needsCodeGenAssembly: true);

                if (cr.Errors.Count == 0)
                {
                    DynamicCode.CodeGenControllerAssemblyPath = cr.OutputAssembly;
                }
                else
                {
                    errors.Add("Errors compiling  dynamic api controller assembly:\r\n" + cr.Errors.ToString("\r\n").Indent(4));
                }
            }

            if (errors.Any())
            {
                throw new InvalidOperationException(errors.ToString("\r\n"));
            }
        }
        catch (Exception e)
        {
            CodeGenError = e;
        }
    }
Exemple #4
0
 public DynamicPanelInformation GetPanelInformation()
 {
     return(new DynamicPanelInformation
     {
         lastDynamicCompilationDateTime = DynamicLogic.GetLastCodeGenAssemblyFileInfo()?.CreationTime,
         loadedCodeGenAssemblyDateTime = DynamicLogic.GetLoadedCodeGenAssemblyFileInfo()?.CreationTime,
         loadedCodeGenControllerAssemblyDateTime = DynamicLogic.GetLoadedCodeGenControllerAssemblyFileInfo()?.CreationTime,
         lastDynamicChangeDateTime = Database.Query <OperationLogEntity>()
                                     .Where(a => DynamicCode.RegisteredDynamicTypes.Contains(a.Target !.EntityType))
                                     .Max(a => a.End),
     });
        public List <CompilationErrorTS> Compile()
        {
            SystemEventLogLogic.Log("DynamicController.Compile");
            Dictionary <string, CodeFile> codeFiles = DynamicLogic.GetCodeFilesDictionary();
            var result = DynamicLogic.Compile(codeFiles, inMemory: true);

            return((from ce in result.Errors.Cast <CompilerError>()
                    let fileName = Path.GetFileName(ce.FileName)
                                   select(new CompilationErrorTS
            {
                fileName = fileName,
                column = ce.Column,
                line = ce.Line,
                errorNumber = ce.ErrorNumber,
                errorText = ce.ErrorText,
                fileContent = codeFiles.GetOrThrow(fileName).FileContent
            })).ToList());
        }
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            DynamicLogic.Start(sb, dqm);
            DynamicSqlMigrationLogic.Start(sb, dqm);
            DynamicValidationLogic.Start(sb, dqm);
            DynamicViewLogic.Start(sb, dqm);
            DynamicTypeLogic.Start(sb, dqm);
            DynamicTypeConditionLogic.Start(sb, dqm);
            DynamicExpressionLogic.Start(sb, dqm);
            DynamicMixinConnectionLogic.Start(sb, dqm);

            DynamicCode.Namespaces.AddRange(new HashSet <string>
            {
                "Southwind.Entities",
                "Southwind.Logic",
            });

            DynamicCode.Assemblies.AddRange(new HashSet <string>
            {
                "Southwind.Entities.dll",
                "Southwind.Logic.dll",
            });
        }
Exemple #7
0
        public static void Start(string connectionString)
        {
            using (HeavyProfiler.Log("Start"))
                using (var initial = HeavyProfiler.Log("Initial"))
                {
                    StartParameters.IgnoredDatabaseMismatches = new List <Exception>();
                    StartParameters.IgnoredCodeErrors         = new List <Exception>();

                    string?logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log");

                    SchemaBuilder sb = new CustomSchemaBuilder {
                        LogDatabaseName = logDatabase, Tracer = initial
                    };
                    sb.Schema.Version          = typeof(Starter).Assembly.GetName().Version;
                    sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US");

                    MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>();
                    MixinDeclarations.Register <UserEntity, UserEmployeeMixin>();

                    OverrideAttributes(sb);

                    var detector = SqlServerVersionDetector.Detect(connectionString);
                    Connector.Default = new SqlConnector(connectionString, sb.Schema, detector !.Value);

                    CacheLogic.Start(sb);

                    DynamicLogicStarter.Start(sb);
                    DynamicLogic.CompileDynamicCode();

                    DynamicLogic.RegisterMixins();
                    DynamicLogic.BeforeSchema(sb);

                    TypeLogic.Start(sb);

                    OperationLogic.Start(sb);
                    ExceptionLogic.Start(sb);

                    MigrationLogic.Start(sb);

                    CultureInfoLogic.Start(sb);
                    FilePathEmbeddedLogic.Start(sb);
                    SmtpConfigurationLogic.Start(sb);
                    EmailLogic.Start(sb, () => Configuration.Value.Email, (et, target) => Configuration.Value.SmtpConfiguration);

                    AuthLogic.Start(sb, "System", null);

                    AuthLogic.StartAllModules(sb);
                    ResetPasswordRequestLogic.Start(sb);
                    UserTicketLogic.Start(sb);
                    SessionLogLogic.Start(sb);

                    ProcessLogic.Start(sb);
                    PackageLogic.Start(sb, packages: true, packageOperations: true);

                    SchedulerLogic.Start(sb);

                    QueryLogic.Start(sb);
                    UserQueryLogic.Start(sb);
                    UserQueryLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities);
                    UserQueryLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities);
                    ChartLogic.Start(sb);


                    UserChartLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities);
                    UserChartLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities);
                    DashboardLogic.Start(sb);
                    DashboardLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities);
                    DashboardLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities);
                    ViewLogLogic.Start(sb, new HashSet <Type> {
                        typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity)
                    });
                    DiffLogLogic.Start(sb, registerAll: true);
                    ExcelLogic.Start(sb, excelReport: true);
                    ToolbarLogic.Start(sb);

                    SMSLogic.Start(sb, null, () => Configuration.Value.Sms);
                    SMSLogic.RegisterPhoneNumberProvider <PersonEntity>(p => p.Phone, p => null);
                    SMSLogic.RegisterDataObjectProvider((PersonEntity p) => new { p.FirstName, p.LastName, p.Title, p.DateOfBirth });
                    SMSLogic.RegisterPhoneNumberProvider <CompanyEntity>(p => p.Phone, p => null);

                    NoteLogic.Start(sb, typeof(UserEntity), /*Note*/ typeof(OrderEntity));
                    AlertLogic.Start(sb, typeof(UserEntity), /*Alert*/ typeof(OrderEntity));
                    FileLogic.Start(sb);

                    TranslationLogic.Start(sb, countLocalizationHits: false);
                    TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en"));

                    HelpLogic.Start(sb);
                    WordTemplateLogic.Start(sb);
                    MapLogic.Start(sb);
                    PredictorLogic.Start(sb, () => new FileTypeAlgorithm(f => new PrefixPair(Starter.Configuration.Value.Folders.PredictorModelFolder)));
                    PredictorLogic.RegisterAlgorithm(CNTKPredictorAlgorithm.NeuralNetwork, new CNTKNeuralNetworkPredictorAlgorithm());
                    PredictorLogic.RegisterPublication(ProductPredictorPublication.MonthlySales, new PublicationSettings(typeof(OrderEntity)));

                    RestLogLogic.Start(sb);
                    RestApiKeyLogic.Start(sb);

                    WorkflowLogicStarter.Start(sb, () => Starter.Configuration.Value.Workflow);

                    EmployeeLogic.Start(sb);
                    ProductLogic.Start(sb);
                    CustomerLogic.Start(sb);
                    OrderLogic.Start(sb);
                    ShipperLogic.Start(sb);

                    StartSouthwindConfiguration(sb);

                    TypeConditionLogic.Register <OrderEntity>(SouthwindGroup.UserEntities, o => o.Employee == EmployeeEntity.Current);
                    TypeConditionLogic.Register <EmployeeEntity>(SouthwindGroup.UserEntities, e => EmployeeEntity.Current.Is(e));

                    TypeConditionLogic.Register <OrderEntity>(SouthwindGroup.CurrentCustomer, o => o.Customer == CustomerEntity.Current);
                    TypeConditionLogic.Register <PersonEntity>(SouthwindGroup.CurrentCustomer, o => o == CustomerEntity.Current);
                    TypeConditionLogic.Register <CompanyEntity>(SouthwindGroup.CurrentCustomer, o => o == CustomerEntity.Current);

                    ProfilerLogic.Start(sb,
                                        timeTracker: true,
                                        heavyProfiler: true,
                                        overrideSessionTimeout: true);

                    DynamicLogic.StartDynamicModules(sb);
                    DynamicLogic.RegisterExceptionIfAny();

                    SetupCache(sb);

                    Schema.Current.OnSchemaCompleted();
                }
        }
Exemple #8
0
        public static void Start(string connectionString, bool isPostgres, bool includeDynamic = true, bool detectSqlVersion = true)
        {
            using (HeavyProfiler.Log("Start"))
                using (var initial = HeavyProfiler.Log("Initial"))
                {
                    StartParameters.IgnoredDatabaseMismatches = new List <Exception>();
                    StartParameters.IgnoredCodeErrors         = new List <Exception>();

                    string?logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log");

                    SchemaBuilder sb = new CustomSchemaBuilder {
                        LogDatabaseName = logDatabase, Tracer = initial
                    };
                    sb.Schema.Version          = typeof(Starter).Assembly.GetName().Version !;
                    sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US");

                    MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>();
                    MixinDeclarations.Register <UserEntity, UserEmployeeMixin>();
                    MixinDeclarations.Register <OrderDetailEmbedded, OrderDetailMixin>();
                    MixinDeclarations.Register <BigStringEmbedded, BigStringMixin>();

                    ConfigureBigString(sb);
                    OverrideAttributes(sb);

                    if (!isPostgres)
                    {
                        var sqlVersion = detectSqlVersion ? SqlServerVersionDetector.Detect(connectionString) : SqlServerVersion.AzureSQL;
                        Connector.Default = new SqlServerConnector(connectionString, sb.Schema, sqlVersion !.Value);
                    }
                    else
                    {
                        var postgreeVersion = detectSqlVersion ? PostgresVersionDetector.Detect(connectionString) : null;
                        Connector.Default = new PostgreSqlConnector(connectionString, sb.Schema, postgreeVersion);
                    }

                    CacheLogic.Start(sb, cacheInvalidator: sb.Settings.IsPostgres ? new PostgresCacheInvalidation() : null);

                    DynamicLogicStarter.Start(sb);
                    if (includeDynamic)//Dynamic
                    {
                        DynamicLogic.CompileDynamicCode();

                        DynamicLogic.RegisterMixins();
                        DynamicLogic.BeforeSchema(sb);
                    }//Dynamic

                    // Framework modules

                    TypeLogic.Start(sb);

                    OperationLogic.Start(sb);
                    ExceptionLogic.Start(sb);
                    QueryLogic.Start(sb);

                    // Extensions modules

                    MigrationLogic.Start(sb);

                    CultureInfoLogic.Start(sb);
                    FilePathEmbeddedLogic.Start(sb);
                    BigStringLogic.Start(sb);
                    EmailLogic.Start(sb, () => Configuration.Value.Email, (template, target, message) => Configuration.Value.EmailSender);

                    AuthLogic.Start(sb, "System", "Anonymous"); /* null); anonymous*/

                    AuthLogic.StartAllModules(sb);
                    ResetPasswordRequestLogic.Start(sb);
                    UserTicketLogic.Start(sb);
                    SessionLogLogic.Start(sb);
                    WebAuthnLogic.Start(sb, () => Configuration.Value.WebAuthn);

                    ProcessLogic.Start(sb);
                    PackageLogic.Start(sb, packages: true, packageOperations: true);

                    SchedulerLogic.Start(sb);
                    OmniboxLogic.Start(sb);

                    UserQueryLogic.Start(sb);
                    UserQueryLogic.RegisterUserTypeCondition(sb, RG2Group.UserEntities);
                    UserQueryLogic.RegisterRoleTypeCondition(sb, RG2Group.RoleEntities);
                    UserQueryLogic.RegisterTranslatableRoutes();

                    ChartLogic.Start(sb, googleMapsChartScripts: false /*requires Google Maps API key in ChartClient */);
                    UserChartLogic.RegisterUserTypeCondition(sb, RG2Group.UserEntities);
                    UserChartLogic.RegisterRoleTypeCondition(sb, RG2Group.RoleEntities);
                    UserChartLogic.RegisterTranslatableRoutes();

                    DashboardLogic.Start(sb);
                    DashboardLogic.RegisterUserTypeCondition(sb, RG2Group.UserEntities);
                    DashboardLogic.RegisterRoleTypeCondition(sb, RG2Group.RoleEntities);
                    DashboardLogic.RegisterTranslatableRoutes();
                    ViewLogLogic.Start(sb, new HashSet <Type> {
                        typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity)
                    });
                    DiffLogLogic.Start(sb, registerAll: true);
                    ExcelLogic.Start(sb, excelReport: true);
                    ToolbarLogic.Start(sb);
                    ToolbarLogic.RegisterTranslatableRoutes();
                    FileLogic.Start(sb);

                    TranslationLogic.Start(sb, countLocalizationHits: false);
                    TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en"));

                    HelpLogic.Start(sb);
                    WordTemplateLogic.Start(sb);
                    MapLogic.Start(sb);
                    RestLogLogic.Start(sb);
                    RestApiKeyLogic.Start(sb);

                    WorkflowLogicStarter.Start(sb, () => Starter.Configuration.Value.Workflow);

                    ProfilerLogic.Start(sb,
                                        timeTracker: true,
                                        heavyProfiler: true,
                                        overrideSessionTimeout: true);

                    // RG2 modules

                    EmployeeLogic.Start(sb);
                    ProductLogic.Start(sb);
                    CustomerLogic.Start(sb);
                    OrderLogic.Start(sb);
                    ShipperLogic.Start(sb);
                    ItemLogic.Start(sb);
                    ItemCategoryLogic.Start(sb);

                    StartRG2Configuration(sb);

                    TypeConditionLogic.Register <OrderEntity>(RG2Group.UserEntities, o => o.Employee == EmployeeEntity.Current);
                    TypeConditionLogic.Register <EmployeeEntity>(RG2Group.UserEntities, e => EmployeeEntity.Current.Is(e));

                    TypeConditionLogic.Register <OrderEntity>(RG2Group.CurrentCustomer, o => o.Customer == CustomerEntity.Current);
                    TypeConditionLogic.Register <PersonEntity>(RG2Group.CurrentCustomer, o => o == CustomerEntity.Current);
                    TypeConditionLogic.Register <CompanyEntity>(RG2Group.CurrentCustomer, o => o == CustomerEntity.Current);

                    if (includeDynamic)//2
                    {
                        DynamicLogic.StartDynamicModules(sb);
                    }//2

                    SetupCache(sb);

                    Schema.Current.OnSchemaCompleted();

                    if (includeDynamic)//3
                    {
                        DynamicLogic.RegisterExceptionIfAny();
                    }//3
                }
        }
Exemple #9
0
    public static void Start(string connectionString, bool isPostgres, string?azureStorageConnectionString, string?broadcastSecret, string?broadcastUrls, bool includeDynamic = true, bool detectSqlVersion = true)
    {
        AzureStorageConnectionString = azureStorageConnectionString;

        using (HeavyProfiler.Log("Start"))
            using (var initial = HeavyProfiler.Log("Initial"))
            {
                StartParameters.IgnoredDatabaseMismatches = new List <Exception>();
                StartParameters.IgnoredCodeErrors         = new List <Exception>();

                string?logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log");

                SchemaBuilder sb = new CustomSchemaBuilder {
                    LogDatabaseName = logDatabase, Tracer = initial
                };
                sb.Schema.Version          = typeof(Starter).Assembly.GetName().Version !;
                sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US");

                MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>();
                MixinDeclarations.Register <UserEntity, UserEmployeeMixin>();
                MixinDeclarations.Register <OrderDetailEmbedded, OrderDetailMixin>();
                MixinDeclarations.Register <BigStringEmbedded, BigStringMixin>();

                ConfigureBigString(sb);
                OverrideAttributes(sb);

                if (!isPostgres)
                {
                    var sqlVersion = detectSqlVersion ? SqlServerVersionDetector.Detect(connectionString) : SqlServerVersion.AzureSQL;
                    Connector.Default = new SqlServerConnector(connectionString, sb.Schema, sqlVersion !.Value);
                }
                else
                {
                    var postgreeVersion = detectSqlVersion ? PostgresVersionDetector.Detect(connectionString) : null;
                    Connector.Default = new PostgreSqlConnector(connectionString, sb.Schema, postgreeVersion);
                }

                CacheLogic.Start(sb, serverBroadcast:
                                 sb.Settings.IsPostgres ? new PostgresBroadcast() :
                                 broadcastSecret != null && broadcastUrls != null ? new SimpleHttpBroadcast(broadcastSecret, broadcastUrls) :
                                 null);/*Cache*/

                /* LightDynamic
                *  DynamicLogic.Start(sb, withCodeGen: false);
                *  LightDynamic */
                DynamicLogicStarter.Start(sb);
                if (includeDynamic)//Dynamic
                {
                    DynamicLogic.CompileDynamicCode();

                    DynamicLogic.RegisterMixins();
                    DynamicLogic.BeforeSchema(sb);
                }//Dynamic

                // Framework modules

                TypeLogic.Start(sb);

                OperationLogic.Start(sb);
                ExceptionLogic.Start(sb);
                QueryLogic.Start(sb);

                // Extensions modules

                MigrationLogic.Start(sb);

                CultureInfoLogic.Start(sb);
                FilePathEmbeddedLogic.Start(sb);
                BigStringLogic.Start(sb);
                EmailLogic.Start(sb, () => Configuration.Value.Email, (template, target, message) => Configuration.Value.EmailSender);

                AuthLogic.Start(sb, "System", "Anonymous"); /* null); anonymous*/
                AuthLogic.Authorizer = new SouthwindAuthorizer(() => Configuration.Value.ActiveDirectory);
                AuthLogic.StartAllModules(sb, activeDirectoryIntegration: true);
                AzureADLogic.Start(sb, adGroups: true, deactivateUsersTask: true);
                ResetPasswordRequestLogic.Start(sb);
                UserTicketLogic.Start(sb);
                SessionLogLogic.Start(sb);
                TypeConditionLogic.RegisterCompile <UserEntity>(SouthwindTypeCondition.UserEntities, u => u.Is(UserEntity.Current));

                ProcessLogic.Start(sb);
                PackageLogic.Start(sb, packages: true, packageOperations: true);

                SchedulerLogic.Start(sb);
                OmniboxLogic.Start(sb);

                UserQueryLogic.Start(sb);
                UserQueryLogic.RegisterUserTypeCondition(sb, SouthwindTypeCondition.UserEntities);
                UserQueryLogic.RegisterRoleTypeCondition(sb, SouthwindTypeCondition.RoleEntities);
                UserQueryLogic.RegisterTranslatableRoutes();

                ChartLogic.Start(sb, googleMapsChartScripts: false /*requires Google Maps API key in ChartClient */);
                UserChartLogic.RegisterUserTypeCondition(sb, SouthwindTypeCondition.UserEntities);
                UserChartLogic.RegisterRoleTypeCondition(sb, SouthwindTypeCondition.RoleEntities);
                UserChartLogic.RegisterTranslatableRoutes();

                DashboardLogic.Start(sb, GetFileTypeAlgorithm(p => p.CachedQueryFolder));
                DashboardLogic.RegisterUserTypeCondition(sb, SouthwindTypeCondition.UserEntities);
                DashboardLogic.RegisterRoleTypeCondition(sb, SouthwindTypeCondition.RoleEntities);
                DashboardLogic.RegisterTranslatableRoutes();
                ViewLogLogic.Start(sb, new HashSet <Type> {
                    typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity)
                });
                SystemEventLogLogic.Start(sb);
                DiffLogLogic.Start(sb, registerAll: true);
                ExcelLogic.Start(sb, excelReport: true);
                ToolbarLogic.Start(sb);
                ToolbarLogic.RegisterTranslatableRoutes();

                SMSLogic.Start(sb, null, () => Configuration.Value.Sms);

                NoteLogic.Start(sb, typeof(UserEntity), /*Note*/ typeof(OrderEntity));
                AlertLogic.Start(sb, typeof(UserEntity), /*Alert*/ typeof(OrderEntity));
                FileLogic.Start(sb);

                TranslationLogic.Start(sb, countLocalizationHits: false);
                TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en"));

                HelpLogic.Start(sb);
                WordTemplateLogic.Start(sb);
                MapLogic.Start(sb);
                PredictorLogic.Start(sb, GetFileTypeAlgorithm(p => p.PredictorModelFolder));
                PredictorLogic.RegisterAlgorithm(TensorFlowPredictorAlgorithm.NeuralNetworkGraph, new TensorFlowNeuralNetworkPredictor());
                PredictorLogic.RegisterPublication(ProductPredictorPublication.MonthlySales, new PublicationSettings(typeof(OrderEntity)));

                RestLogLogic.Start(sb);
                RestApiKeyLogic.Start(sb);

                WorkflowLogicStarter.Start(sb, () => Starter.Configuration.Value.Workflow);

                ProfilerLogic.Start(sb,
                                    timeTracker: true,
                                    heavyProfiler: true,
                                    overrideSessionTimeout: true);

                // Southwind modules

                EmployeeLogic.Start(sb);
                ProductLogic.Start(sb);
                CustomerLogic.Start(sb);
                OrderLogic.Start(sb);
                ShipperLogic.Start(sb);

                StartSouthwindConfiguration(sb);

                TypeConditionLogic.Register <OrderEntity>(SouthwindTypeCondition.CurrentEmployee, o => o.Employee.Is(EmployeeEntity.Current));

                if (includeDynamic)//2
                {
                    DynamicLogic.StartDynamicModules(sb);
                }//2

                SetupCache(sb);

                Schema.Current.OnSchemaCompleted();

                if (includeDynamic)//3
                {
                    DynamicLogic.RegisterExceptionIfAny();
                }//3
            }
    }