コード例 #1
0
            public MvcHtmlString ToHtml(HtmlHelper helper)
            {
                HtmlStringBuilder sb = new HtmlStringBuilder();

                using (sb.SurroundLine("li"))
                {
                    sb.Add(helper.ScriptCss("~/Help/Content/helpWidget.css"));

                    var id = TypeContextUtilities.Compose(Prefix, "helpButton");

                    sb.Add(new HtmlTag("button").Id(id)
                           .Class("btn btn-xs btn-help btn-help-widget")
                           .Class(HelpLogic.GetEntityHelp(RootType).HasEntity ? "hasItems" : null)
                           .Attr("type", "button")
                           .SetInnerText("?"));

                    var type = HelpLogic.GetEntityHelpService(this.RootType);

                    var jsType = new
                    {
                        Type       = TypeLogic.GetCleanName(type.Type),
                        Info       = type.Info,
                        Operations = type.Operations.ToDictionary(a => a.Key.Key, a => a.Value),
                        Properties = type.Properties.ToDictionary(a => a.Key.ToString(), a => a.Value),
                    };

                    sb.Add(MvcHtmlString.Create("<script>$('#" + id + "').on('mouseup', function(event){ if(event.which == 3) return; " +
                                                HelpClient.WidgetModule["entityClick"](JsFunction.This, this.Prefix, jsType, helper.UrlHelper().Action((HelpController c) => c.PropertyRoutes())).ToString() +
                                                " })</script>"));
                }

                return(sb.ToHtml());
            }
コード例 #2
0
    public NamespaceHelp Namespace(string @namespace)
    {
        var help = HelpLogic.GetNamespaceHelp(@namespace.Replace("_", "."));

        help.AssertAllowed();
        return(help);
    }
コード例 #3
0
    public TypeHelpEntity Type(string cleanName)
    {
        var help = HelpLogic.GetTypeHelp(TypeLogic.GetType(cleanName));

        help.AssertAllowed();
        return(help.GetEntity());
    }
コード例 #4
0
            public override MvcHtmlString ToHtml(HtmlHelper helper)
            {
                var a = new HtmlTag("button").Id(this.Id)
                        .Class("btn btn-default btn-help")
                        .Class(HelpLogic.GetQueryHelp(QueryName).HasEntity ? "hasItems" : null)
                        .Attr("type", "button")
                        .SetInnerText("?");

                var query = HelpLogic.GetQueryHelpService(this.QueryName);

                var jsType = new
                {
                    QueryName = QueryUtils.GetKey(query.QueryName),
                    Info      = query.Info,
                    Columns   = query.Columns,
                };

                var result = new HtmlTag("div").Class("btn-group").InnerHtml(a).ToHtml();

                result = result.Concat(helper.ScriptCss("~/Help/Content/helpWidget.css"));
                result = result.Concat(MvcHtmlString.Create("<script>$('#" + this.Id + "').on('mouseup', function(event){ if(event.which == 3) return; " +
                                                            HelpClient.WidgetModule["searchClick"](JsFunction.This, this.Prefix, jsType, helper.UrlHelper().Action((HelpController c) => c.ComplexColumns())).ToString() +
                                                            " })</script>"));

                return(result);
            }
コード例 #5
0
    public static void ImportAll(string directoryName)
    {
        var namespaces = HelpLogic.AllTypes().Select(a => a.Namespace !).Distinct().ToDictionary(a => a);

        var types = HelpLogic.AllTypes().ToDictionary(a => a.FullName !);

        foreach (var path in Directory.GetFiles(directoryName, "*.help", SearchOption.AllDirectories))
        {
            try
            {
                XDocument doc = XDocument.Load(path);

                ImportAction action =
                    doc.Root !.Name == AppendixXml._Appendix ? AppendixXml.Load(doc):
                    doc.Root !.Name == NamespaceXml._Namespace ? NamespaceXml.Load(doc, namespaces):
                    doc.Root !.Name == EntityXml._Entity ? EntityXml.Load(doc, types):
                    doc.Root !.Name == QueryXml._Query ? QueryXml.Load(doc) :
                    throw new InvalidOperationException("Unknown Xml root: " + doc.Root.Name);

                ConsoleColor color =
                    action == ImportAction.Inserted ? ConsoleColor.Green :
                    action == ImportAction.Updated ? ConsoleColor.DarkGreen :
                    action == ImportAction.Skipped ? ConsoleColor.Yellow :
                    action == ImportAction.NoChanges ? ConsoleColor.DarkGray :
                    throw new InvalidOperationException("Unexpected action");

                SafeConsole.WriteLineColor(color, " {0} {1}".FormatWith(action, path));
            }
            catch (Exception e)
            {
                SafeConsole.WriteLineColor(ConsoleColor.Red, " Error {0}:\r\n\t".FormatWith(path) + e.Message);
            }
        }
    }
コード例 #6
0
        public ActionResult PropertyRoutes()
        {
            string[] routes = JsonConvert.DeserializeObject <string[]>(this.Request["routes"]);

            var parsed = routes.Select(r => PropertyRoute.Parse(r)).Distinct().ToList();

            return(this.JsonNet(HelpLogic.GetPropertyRoutesService(parsed).ToDictionary(a => a.Key.ToString(), a => a.Value)));
        }
コード例 #7
0
        public ActionResult ViewNamespace(string @namespace)
        {
            HelpPermissions.ViewHelp.AssertAuthorized();

            NamespaceHelp model = HelpLogic.GetNamespaceHelp(@namespace);

            return(View(HelpClient.ViewNamespaceUrl, model));
        }
コード例 #8
0
        public ActionResult ViewAppendix(string appendix)
        {
            HelpPermissions.ViewHelp.AssertAuthorized();

            AppendixHelp model = HelpLogic.GetAppendixHelp(appendix);

            return(View(HelpClient.ViewAppendixUrl, model));
        }
コード例 #9
0
        public ActionResult ViewEntity(string entity)
        {
            HelpPermissions.ViewHelp.AssertAuthorized();

            Type type = TypeLogic.GetType(entity);

            EntityHelp eh = HelpLogic.GetEntityHelp(type);

            return(View(HelpClient.ViewEntityUrl, eh));
        }
コード例 #10
0
        public ActionResult NewAppendix()
        {
            HelpPermissions.ViewHelp.AssertAuthorized();

            var          culture = HelpLogic.GetCulture();
            AppendixHelp model   = new AppendixHelp(culture, new AppendixHelpEntity {
                Culture = culture.ToCultureInfoEntity()
            });

            return(View(HelpClient.ViewAppendixUrl, model));
        }
コード例 #11
0
    public AppendixHelpEntity Appendix(string?uniqueName)
    {
        if (!uniqueName.HasText())
        {
            return new AppendixHelpEntity
                   {
                       Culture = CultureInfo.CurrentCulture.ToCultureInfoEntity()
                   }
        }
        ;

        var help = HelpLogic.GetAppendixHelp(uniqueName);

        return(help);
    }
コード例 #12
0
        public ActionResult ComplexColumns()
        {
            object queryName = QueryLogic.ToQueryName(this.Request["queryName"]);

            string[] columns = JsonConvert.DeserializeObject <string[]>(this.Request["columns"]);

            var description = DynamicQueryManager.Current.QueryDescription(queryName);

            var parsed = columns.Select(r => QueryUtils.Parse(r, description, SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement)).Distinct().ToList();

            var routes = parsed.Select(a => a.GetPropertyRoute()).NotNull().Distinct().ToList();

            var help = HelpLogic.GetPropertyRoutesService(routes);

            return(this.JsonNet(parsed.ToDictionary(a => a.FullKey(), a => { var pr = a.GetPropertyRoute(); return pr == null ? null : help.TryGetC(pr); })));
        }
コード例 #13
0
ファイル: BaseHelp.cs プロジェクト: goldenauge/framework
    public TypeHelpEntity GetEntity()
    {
        var result = new TypeHelpEntity
        {
            Culture     = this.Culture.ToCultureInfoEntity(),
            Type        = this.Type.ToTypeEntity(),
            Description = DBEntity?.Description,
            Info        = Info
        };

        result.Properties.AddRange(
            from pre in PropertyRouteLogic.RetrieveOrGenerateProperties(this.Type.ToTypeEntity())
            let pr = pre.ToPropertyRoute()
                     where !(pr.PropertyInfo != null && pr.PropertyInfo.SetMethod == null && ExpressionCleaner.HasExpansions(pr.PropertyInfo.DeclaringType !, pr.PropertyInfo))
                     let ph = Properties.GetOrThrow(pre.ToPropertyRoute())
                              where ph.IsAllowed() == null
                              select new PropertyRouteHelpEmbedded
        {
            Property    = pre,
            Info        = ph.Info,
            Description = ph.UserDescription,
        });

        result.Operations.AddRange(
            from oh in Operations.Values
            where oh.IsAllowed() == null
            select new OperationHelpEmbedded
        {
            Operation   = oh.OperationSymbol,
            Info        = oh.Info,
            Description = oh.UserDescription,
        });

        result.Queries.AddRange(
            from qn in QueryLogic.Queries.GetTypeQueries(this.Type).Keys
            let qh = HelpLogic.GetQueryHelp(qn)
                     where qh.IsAllowed() == null
                     select qh.GetEntity());

        if (DBEntity != null)
        {
            result.SetId(DBEntity.Id);
            result.SetIsNew(DBEntity.IsNew);
            result.Ticks = DBEntity.Ticks;
        }
        return(result);
    }
コード例 #14
0
    public HelpIndexTS Index()
    {
        return(new HelpIndexTS
        {
            Namespaces = HelpLogic.GetNamespaceHelps().Select(s => new NamespaceItemTS
            {
                Namespace = s.Namespace,
                Before = s.Before,
                Title = s.Title,
                AllowedTypes = s.AllowedTypes
            }).ToList(),

            Appendices = HelpLogic.GetAppendixHelps().Select(s => new AppendiceItemTS
            {
                UniqueName = s.UniqueName,
                Title = s.Title,
            }).ToList(),
        });
    }
コード例 #15
0
ファイル: BaseHelp.cs プロジェクト: goldenauge/framework
    public TypeHelp(Type type, CultureInfo culture, TypeHelpEntity?entity)
    {
        Type    = type;
        Culture = culture;
        Info    = HelpGenerator.GetEntityHelp(type);

        var props = DBEntity?.Properties.ToDictionaryEx(a => a.Property.ToPropertyRoute(), a => a.Info);
        var opers = DBEntity?.Operations.ToDictionaryEx(a => a.Operation, a => a.Info);

        Properties = PropertyRoute.GenerateRoutes(type)
                     .ToDictionary(pp => pp, pp => new PropertyHelp(pp, props?.TryGetC(pp)));

        Operations = OperationLogic.TypeOperations(type)
                     .ToDictionary(op => op.OperationSymbol, op => new OperationHelp(op.OperationSymbol, type, opers?.TryGetC(op.OperationSymbol)));


        var allQueries = HelpLogic.CachedQueriesHelp();

        Queries = HelpLogic.TypeToQuery.Value.TryGetC(this.Type).EmptyIfNull().Select(a => allQueries.GetOrThrow(a)).ToDictionary(qh => qh.QueryName);

        DBEntity = entity;
    }
コード例 #16
0
        public ActionResult Search(string q)
        {
            HelpPermissions.ViewHelp.AssertAuthorized();

            Stopwatch sp = new Stopwatch();

            sp.Start();
            Regex regex = new Regex(Regex.Escape(q.RemoveDiacritics()), RegexOptions.IgnoreCase);
            List <List <SearchResult> > results = new List <List <SearchResult> >();

            results.AddRange(from eh in HelpLogic.GetEntityHelps()
                             select eh.Search(regex).ToList() into l
                             where l.Any()
                             select l);

            //We add the appendices
            results.AddRange(from a in HelpLogic.GetAppendixHelps()
                             let result = a.Search(regex)
                                          where result != null
                                          select new List <SearchResult> {
                result
            });

            //We add the namespaces
            results.AddRange(from a in HelpLogic.GetNamespaceHelps()
                             let result = a.Search(regex)
                                          where result != null
                                          select new List <SearchResult> {
                result
            });

            results = results.OrderBy(a => a.First().IsDescription).ThenBy(a => a.First().MatchType).ThenBy(a => a.First().TypeSearchResult).ToList();

            sp.Stop();
            ViewData["time"]             = sp.ElapsedMilliseconds;
            ViewData[ViewDataKeys.Title] = q + " - " + HelpMessage.Buscador.NiceToString();
            return(View(HelpClient.SearchResults, results));
        }
コード例 #17
0
ファイル: BaseHelp.cs プロジェクト: goldenauge/framework
 public EntityItem(Type t)
 {
     CleanName      = TypeLogic.GetCleanName(t);
     HasDescription = HelpLogic.GetTypeHelp(t).HasEntity;
 }
コード例 #18
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();
                }
        }
コード例 #19
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
                }
        }
コード例 #20
0
        public override void Execute()
        {
            #line 6 "..\..\Help\Views\Index.cshtml"

            ViewBag.Title = HelpMessage.Help.NiceToString();
            var namespaces = HelpLogic.GetNamespaceHelps().OrderBy(a => a.Namespace);
            var appendices = HelpLogic.GetAppendixHelps();

            Schema schema = Schema.Current;


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n");

            DefineSection("head", () => {
                WriteLiteral("\r\n");

                WriteLiteral("    ");


            #line 16 "..\..\Help\Views\Index.cshtml"
                Write(Html.ScriptCss("~/help/Content/help.css"));


            #line default
            #line hidden
                WriteLiteral("\r\n");
            });

            WriteLiteral("<div");

            WriteLiteral(" id=\"entityContent\"");

            WriteLiteral(">\r\n    <h1");

            WriteLiteral(" class=\"centered\"");

            WriteLiteral(">");


            #line 19 "..\..\Help\Views\Index.cshtml"
            Write(HelpMessage.Help.NiceToString());


            #line default
            #line hidden
            WriteLiteral("</h1>\r\n");


            #line 20 "..\..\Help\Views\Index.cshtml"


            #line default
            #line hidden

            #line 20 "..\..\Help\Views\Index.cshtml"
            using (Html.BeginForm("Search", "Help", FormMethod.Get, new { id = "form-search-big" }))
            {
            #line default
            #line hidden
                WriteLiteral("        <div");

                WriteLiteral(" class=\"input-group\"");

                WriteLiteral(">\r\n            <input");

                WriteLiteral(" type=\"text\"");

                WriteLiteral(" class=\"form-control\"");

                WriteAttribute("placeholder", Tuple.Create(" placeholder=\"", 719), Tuple.Create("\"", 773)

            #line 23 "..\..\Help\Views\Index.cshtml"
                               , Tuple.Create(Tuple.Create("", 733), Tuple.Create <System.Object, System.Int32>(HelpSearchMessage.Search.NiceToString()

            #line default
            #line hidden
                                                                                                                , 733), false)
                               );

                WriteLiteral(" name=\"q\"");

                WriteLiteral(" />\r\n            <div");

                WriteLiteral(" class=\"input-group-btn\"");

                WriteLiteral(">\r\n                <button");

                WriteLiteral(" class=\"btn btn-default\"");

                WriteLiteral(" type=\"submit\"");

                WriteLiteral("><i");

                WriteLiteral(" class=\"glyphicon glyphicon-search\"");

                WriteLiteral("></i></button>\r\n            </div>\r\n        </div>\r\n");


            #line 28 "..\..\Help\Views\Index.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("    <ol");

            WriteLiteral(" class=\"responsive-columns\"");

            WriteLiteral(">\r\n");


            #line 30 "..\..\Help\Views\Index.cshtml"


            #line default
            #line hidden

            #line 30 "..\..\Help\Views\Index.cshtml"
            foreach (var nh in namespaces)
            {
            #line default
            #line hidden
                WriteLiteral("            <li>\r\n                <h3>\r\n                    <a");

                WriteAttribute("href", Tuple.Create(" href=\"", 1143), Tuple.Create("\"", 1214)

            #line 34 "..\..\Help\Views\Index.cshtml"
                               , Tuple.Create(Tuple.Create("", 1150), Tuple.Create <System.Object, System.Int32>(Url.Action((HelpController c) => c.ViewNamespace(nh.Namespace))

            #line default
            #line hidden
                                                                                                                 , 1150), false)
                               );

                WriteLiteral(">");


            #line 34 "..\..\Help\Views\Index.cshtml"
                Write(nh.Title);


            #line default
            #line hidden
                WriteLiteral("</a>\r\n");


            #line 35 "..\..\Help\Views\Index.cshtml"


            #line default
            #line hidden

            #line 35 "..\..\Help\Views\Index.cshtml"
                if (nh.Before != null)
                {
            #line default
            #line hidden
                    WriteLiteral("                        <small>");


            #line 37 "..\..\Help\Views\Index.cshtml"
                    Write(HelpMessage.In0.NiceToString(nh.Before));


            #line default
            #line hidden
                    WriteLiteral("</small>\r\n");


            #line 38 "..\..\Help\Views\Index.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("                </h3>\r\n                <ul>\r\n");


            #line 41 "..\..\Help\Views\Index.cshtml"


            #line default
            #line hidden

            #line 41 "..\..\Help\Views\Index.cshtml"
                foreach (var t in nh.Types.Where(t => schema.IsAllowed(t, inUserInterface: true) == null))
                {
            #line default
            #line hidden
                    WriteLiteral("                        <li><a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 1616), Tuple.Create("\"", 1645)

            #line 43 "..\..\Help\Views\Index.cshtml"
                                   , Tuple.Create(Tuple.Create("", 1623), Tuple.Create <System.Object, System.Int32>(HelpUrls.EntityUrl(t)

            #line default
            #line hidden
                                                                                                                     , 1623), false)
                                   );

                    WriteLiteral(">");


            #line 43 "..\..\Help\Views\Index.cshtml"
                    Write(t.NiceName());


            #line default
            #line hidden
                    WriteLiteral("</a> </li>\r\n");


            #line 44 "..\..\Help\Views\Index.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("                </ul>\r\n            </li>\r\n");


            #line 47 "..\..\Help\Views\Index.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("    </ol>\r\n</div>\r\n\r\n<h3");

            WriteLiteral(" class=\"centered\"");

            WriteLiteral(">");


            #line 51 "..\..\Help\Views\Index.cshtml"
            Write(HelpMessage.Appendices.NiceToString());


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 52 "..\..\Help\Views\Index.cshtml"


            #line default
            #line hidden

            #line 52 "..\..\Help\Views\Index.cshtml"
            if (Navigator.IsCreable(typeof(AppendixHelpEntity), isSearch: true))
            {
            #line default
            #line hidden
                WriteLiteral("        <a");

                WriteAttribute("href", Tuple.Create(" href=\"", 1922), Tuple.Create("\"", 1979)

            #line 54 "..\..\Help\Views\Index.cshtml"
                               , Tuple.Create(Tuple.Create("", 1929), Tuple.Create <System.Object, System.Int32>(Url.Action((HelpController c) => c.NewAppendix())

            #line default
            #line hidden
                                                                                                                 , 1929), false)
                               );

                WriteLiteral(">+</a> \r\n");


            #line 55 "..\..\Help\Views\Index.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("</h3>\r\n<ol");

            WriteLiteral(" class=\"responsive-columns\"");

            WriteLiteral(">\r\n");


            #line 58 "..\..\Help\Views\Index.cshtml"


            #line default
            #line hidden

            #line 58 "..\..\Help\Views\Index.cshtml"
            foreach (var a in appendices)
            {
            #line default
            #line hidden
                WriteLiteral("        <li>\r\n");

                WriteLiteral("            ");


            #line 61 "..\..\Help\Views\Index.cshtml"
                Write(Html.ActionLink(a.Title, (HelpController c) => c.ViewAppendix(a.UniqueName)));


            #line default
            #line hidden
                WriteLiteral("\r\n        </li>\r\n");


            #line 63 "..\..\Help\Views\Index.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("</ol>\r\n");
        }
コード例 #21
0
        //获取数据
        public JsonResult GetHelplist(HelpParam param)
        {
            var result = new HelpLogic().GetHelpList(param);

            return(Json(result));
        }
コード例 #22
0
        public override void Execute()
        {
            #line 5 "..\..\Help\Views\MiniMenu.cshtml"

            var ns       = (string)ViewData["namespace"];
            var type     = (Type)ViewData["type"];
            var appendix = (string)ViewData["appendix"];

            var namespaces = HelpLogic.GetNamespaceHelps();
            var appendices = HelpLogic.GetAppendixHelps();


            Schema schema = Schema.Current;


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n");


            #line 17 "..\..\Help\Views\MiniMenu.cshtml"
            using (Html.BeginForm("Search", "Help", FormMethod.Get, new { id = "form-search" }))
            {
            #line default
            #line hidden
                WriteLiteral("    <div");

                WriteLiteral(" class=\"input-group\"");

                WriteLiteral(">\r\n        <input");

                WriteLiteral(" type=\"text\"");

                WriteLiteral(" class=\"form-control\"");

                WriteAttribute("placeholder", Tuple.Create(" placeholder=\"", 567), Tuple.Create("\"", 621)

            #line 20 "..\..\Help\Views\MiniMenu.cshtml"
                               , Tuple.Create(Tuple.Create("", 581), Tuple.Create <System.Object, System.Int32>(HelpSearchMessage.Search.NiceToString()

            #line default
            #line hidden
                                                                                                                , 581), false)
                               );

                WriteLiteral(" name=\"q\"");

                WriteLiteral(">\r\n        <div");

                WriteLiteral(" class=\"input-group-btn\"");

                WriteLiteral(">\r\n            <button");

                WriteLiteral(" class=\"btn btn-default\"");

                WriteLiteral(" type=\"submit\"");

                WriteLiteral("><i");

                WriteLiteral(" class=\"glyphicon glyphicon-search\"");

                WriteLiteral("></i></button>\r\n        </div>\r\n    </div>\r\n");


            #line 25 "..\..\Help\Views\MiniMenu.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("\r\n<h3><a");

            WriteAttribute("href", Tuple.Create(" href=\"", 823), Tuple.Create("\"", 874)

            #line 27 "..\..\Help\Views\MiniMenu.cshtml"
                           , Tuple.Create(Tuple.Create("", 830), Tuple.Create <System.Object, System.Int32>(Url.Action((HelpController h) => h.Index())

            #line default
            #line hidden
                                                                                                            , 830), false)
                           );

            WriteLiteral(">");


            #line 27 "..\..\Help\Views\MiniMenu.cshtml"
            Write(HelpMessage.Help.NiceToString());


            #line default
            #line hidden
            WriteLiteral("</a></h3>\r\n<h4>");


            #line 28 "..\..\Help\Views\MiniMenu.cshtml"
            Write(HelpMessage.Entities.NiceToString());


            #line default
            #line hidden
            WriteLiteral("</h4>\r\n<ul>\r\n");


            #line 30 "..\..\Help\Views\MiniMenu.cshtml"


            #line default
            #line hidden

            #line 30 "..\..\Help\Views\MiniMenu.cshtml"
            foreach (var item in namespaces.OrderBy(a => a.Namespace))
            {
            #line default
            #line hidden
                WriteLiteral("        <li>\r\n");


            #line 33 "..\..\Help\Views\MiniMenu.cshtml"


            #line default
            #line hidden

            #line 33 "..\..\Help\Views\MiniMenu.cshtml"
                if (item.Namespace != ns)
                {
            #line default
            #line hidden
                    WriteLiteral("                <a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 1131), Tuple.Create("\"", 1204)

            #line 35 "..\..\Help\Views\MiniMenu.cshtml"
                                   , Tuple.Create(Tuple.Create("", 1138), Tuple.Create <System.Object, System.Int32>(Url.Action((HelpController h) => h.ViewNamespace(item.Namespace))

            #line default
            #line hidden
                                                                                                                     , 1138), false)
                                   );

                    WriteLiteral(">\r\n");

                    WriteLiteral("                    ");


            #line 36 "..\..\Help\Views\MiniMenu.cshtml"
                    Write(item.Title);


            #line default
            #line hidden
                    WriteLiteral("</a>\r\n");


            #line 37 "..\..\Help\Views\MiniMenu.cshtml"
                    if (item.Before != null)
                    {
            #line default
            #line hidden
                        WriteLiteral("                <small>");


            #line 39 "..\..\Help\Views\MiniMenu.cshtml"
                        Write(HelpMessage.In0.NiceToString(item.Before));


            #line default
            #line hidden
                        WriteLiteral("</small>\r\n");


            #line 40 "..\..\Help\Views\MiniMenu.cshtml"
                    }
                }
                else
                {
            #line default
            #line hidden

            #line 44 "..\..\Help\Views\MiniMenu.cshtml"
                    Write(item.Title);


            #line default
            #line hidden

            #line 44 "..\..\Help\Views\MiniMenu.cshtml"

                    if (item.Before != null)
                    {
            #line default
            #line hidden
                        WriteLiteral("                <small>");


            #line 47 "..\..\Help\Views\MiniMenu.cshtml"
                        Write(HelpMessage.In0.NiceToString(item.Before));


            #line default
            #line hidden
                        WriteLiteral("</small>\r\n");


            #line 48 "..\..\Help\Views\MiniMenu.cshtml"
                    }
                }


            #line default
            #line hidden
                WriteLiteral("\r\n");


            #line 51 "..\..\Help\Views\MiniMenu.cshtml"


            #line default
            #line hidden

            #line 51 "..\..\Help\Views\MiniMenu.cshtml"
                if (item.Namespace == ns || type != null && item.Namespace == type.Namespace)
                {
            #line default
            #line hidden
                    WriteLiteral("                <ul>\r\n");


            #line 54 "..\..\Help\Views\MiniMenu.cshtml"


            #line default
            #line hidden

            #line 54 "..\..\Help\Views\MiniMenu.cshtml"
                    foreach (var t in item.Types.Where(t => schema.IsAllowed(t, inUserInterface: true) == null))
                    {
                        if (t != type)
                        {
            #line default
            #line hidden
                            WriteLiteral("                        <li><a");

                            WriteAttribute("href", Tuple.Create(" href=\"", 2016), Tuple.Create("\"", 2045)

            #line 58 "..\..\Help\Views\MiniMenu.cshtml"
                                           , Tuple.Create(Tuple.Create("", 2023), Tuple.Create <System.Object, System.Int32>(HelpUrls.EntityUrl(t)

            #line default
            #line hidden
                                                                                                                             , 2023), false)
                                           );

                            WriteLiteral(">");


            #line 58 "..\..\Help\Views\MiniMenu.cshtml"
                            Write(t.NiceName());


            #line default
            #line hidden
                            WriteLiteral("</a></li>\r\n");


            #line 59 "..\..\Help\Views\MiniMenu.cshtml"
                        }
                        else
                        {
            #line default
            #line hidden
                            WriteLiteral("                        <li>");


            #line 62 "..\..\Help\Views\MiniMenu.cshtml"
                            Write(t.NiceName());


            #line default
            #line hidden
                            WriteLiteral("</li>\r\n");


            #line 63 "..\..\Help\Views\MiniMenu.cshtml"
                        }
                    }


            #line default
            #line hidden
                    WriteLiteral("                </ul>\r\n");


            #line 66 "..\..\Help\Views\MiniMenu.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("        </li>\r\n");


            #line 68 "..\..\Help\Views\MiniMenu.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("</ul>\r\n<h4>");


            #line 70 "..\..\Help\Views\MiniMenu.cshtml"
            Write(HelpMessage.Appendices.NiceToString());


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 71 "..\..\Help\Views\MiniMenu.cshtml"


            #line default
            #line hidden

            #line 71 "..\..\Help\Views\MiniMenu.cshtml"
            if (Navigator.IsCreable(typeof(AppendixHelpEntity), isSearch: true))
            {
            #line default
            #line hidden
                WriteLiteral("        <a");

                WriteAttribute("href", Tuple.Create(" href=\"", 2456), Tuple.Create("\"", 2513)

            #line 73 "..\..\Help\Views\MiniMenu.cshtml"
                               , Tuple.Create(Tuple.Create("", 2463), Tuple.Create <System.Object, System.Int32>(Url.Action((HelpController c) => c.NewAppendix())

            #line default
            #line hidden
                                                                                                                 , 2463), false)
                               );

                WriteLiteral(">+</a> \r\n");


            #line 74 "..\..\Help\Views\MiniMenu.cshtml"
            }

            #line default
            #line hidden
            WriteLiteral("</h4>\r\n<ul>\r\n");


            #line 76 "..\..\Help\Views\MiniMenu.cshtml"


            #line default
            #line hidden

            #line 76 "..\..\Help\Views\MiniMenu.cshtml"
            foreach (var item in appendices)
            {
                if (item.UniqueName != appendix)
                {
            #line default
            #line hidden
                    WriteLiteral("        <li><a");

                    WriteAttribute("href", Tuple.Create(" href=\"", 2654), Tuple.Create("\"", 2727)

            #line 80 "..\..\Help\Views\MiniMenu.cshtml"
                                   , Tuple.Create(Tuple.Create("", 2661), Tuple.Create <System.Object, System.Int32>(Url.Action((HelpController h) => h.ViewAppendix(item.UniqueName))

            #line default
            #line hidden
                                                                                                                     , 2661), false)
                                   );

                    WriteLiteral(">\r\n");

                    WriteLiteral("            ");


            #line 81 "..\..\Help\Views\MiniMenu.cshtml"
                    Write(item.Title);


            #line default
            #line hidden
                    WriteLiteral("</a>\r\n        </li>\r\n");


            #line 83 "..\..\Help\Views\MiniMenu.cshtml"
                }
                else
                {
            #line default
            #line hidden
                    WriteLiteral("        <li>\r\n");

                    WriteLiteral("            ");


            #line 87 "..\..\Help\Views\MiniMenu.cshtml"
                    Write(item.Title);


            #line default
            #line hidden
                    WriteLiteral("\r\n        </li>\r\n");


            #line 89 "..\..\Help\Views\MiniMenu.cshtml"
                }
            }


            #line default
            #line hidden
            WriteLiteral("</ul>\r\n\r\n\r\n\r\n");
        }
コード例 #23
0
 //获取数据
 public JsonResult GetHelplist(HelpParam param)
 {
     var result = new HelpLogic().GetHelpList(param);
     return Json(result);
 }
コード例 #24
0
        public static void Start(string connectionString)
        {
            string logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log");

            SchemaBuilder sb = new SchemaBuilder();

            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);

            SetupDisconnectedStrategies(sb);

            DynamicQueryManager dqm = new DynamicQueryManager();

            Connector.Default = new SqlConnector(connectionString, sb.Schema, dqm, SqlServerVersion.SqlServer2012);

            CacheLogic.Start(sb);

            TypeLogic.Start(sb, dqm);

            OperationLogic.Start(sb, dqm);

            MigrationLogic.Start(sb, dqm);

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

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

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

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

            MapLogic.Start(sb, dqm);
            SchedulerLogic.Start(sb, dqm);

            QueryLogic.Start(sb);
            UserQueryLogic.Start(sb, dqm);
            UserQueryLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities);
            UserQueryLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities);
            ChartLogic.Start(sb, dqm);
            UserChartLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities);
            UserChartLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities);
            DashboardLogic.Start(sb, dqm);
            DashboardLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities);
            DashboardLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities);
            ViewLogLogic.Start(sb, dqm, new HashSet <Type> {
                typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity)
            });
            DiffLogLogic.Start(sb, dqm);

            ExceptionLogic.Start(sb, dqm);

            SMSLogic.Start(sb, dqm, 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, dqm, typeof(UserEntity), /*Note*/ typeof(OrderEntity));
            AlertLogic.Start(sb, dqm, typeof(UserEntity), /*Alert*/ typeof(OrderEntity));
            FileLogic.Start(sb, dqm);

            TranslationLogic.Start(sb, dqm);
            TranslatedInstanceLogic.Start(sb, dqm, () => CultureInfo.GetCultureInfo("en"));

            HelpLogic.Start(sb, dqm);
            WordTemplateLogic.Start(sb, dqm);

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

            StartSouthwindConfiguration(sb, dqm);

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

            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);

            DisconnectedLogic.Start(sb, dqm);
            DisconnectedLogic.BackupFolder        = @"D:\SouthwindTemp\Backups";
            DisconnectedLogic.BackupNetworkFolder = @"D:\SouthwindTemp\Backups";
            DisconnectedLogic.DatabaseFolder      = @"D:\SouthwindTemp\Database";

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

            SetupCache(sb);

            SetSchemaNames(Schema.Current);

            if (logDatabase.HasText())
            {
                SetLogDatabase(sb.Schema, new DatabaseName(null, logDatabase));
            }

            Schema.Current.OnSchemaCompleted();
        }
コード例 #25
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
            }
    }