Пример #1
0
        public static void WebStart(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime)
        {
            SignumServer.Start(app, env, typeof(Startup).Assembly);

            AuthServer.Start(app, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM AtTest. CHANGE THIS STRING!!!");
            CacheServer.Start(app);
            FilesServer.Start(app);
            UserQueryServer.Start(app);
            DashboardServer.Start(app);
            WordServer.Start(app);
            ExcelServer.Start(app);
            ChartServer.Start(app);
            MapServer.Start(app);
            ToolbarServer.Start(app);
            TranslationServer.Start(app, new AlreadyTranslatedTranslator(new AzureTranslator("Your API Key for Azure Translate")));
            SchedulerServer.Start(app, lifetime);
            ProcessServer.Start(app);
            MailingServer.Start(app);
            ProfilerServer.Start(app);
            DiffLogServer.Start(app);
            PredictorServer.Start(app);
            OmniboxServer.Start(app,
                                new EntityOmniboxResultGenenerator(),
                                new DynamicQueryOmniboxResultGenerator(),
                                new ChartOmniboxResultGenerator(),
                                new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete),
                                new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete),
                                new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete),
                                new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()),
                                new ReactSpecialOmniboxGenerator()
                                   //new HelpModuleOmniboxResultGenerator(),
                                ); //Omnibox

            SignumCultureSelectorFilter.GetCurrentCulture = (ctx) => GetCulture(ctx);
        }
Пример #2
0
        public static void WebStart(HttpConfiguration config)
        {
            SignumServer.Start(config, typeof(Global).Assembly);
            AuthServer.Start(config, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM Southwind. CHANGE THIS STRING!!!");
            CacheServer.Start(config);
            FilesServer.Start(config);
            UserQueryServer.Start(config);
            DashboardServer.Start(config);
            WordServer.Start(config);
            ExcelServer.Start(config);
            ChartServer.Start(config);
            MapServer.Start(config);
            TranslationServer.Start(config, new AlreadyTranslatedTranslator(new BingTranslator()));
            SchedulerServer.Start(config);
            ProcessServer.Start(config);
            DisconnectedServer.Start(config);
            MailingServer.Start(config);
            ProfilerServer.Start(config);
            DiffLogServer.Start(config);

            OmniboxServer.Start(config,
                                new EntityOmniboxResultGenenerator(),
                                new DynamicQueryOmniboxResultGenerator(),
                                new ChartOmniboxResultGenerator(),
                                new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete),
                                new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete),
                                new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete),
                                new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()),
                                new ReactSpecialOmniboxGenerator()
                                   //new HelpModuleOmniboxResultGenerator(),
                                ); //Omnibox
        }
Пример #3
0
        static SqlPreCommand?SynchronizeTypes(Replacements replacements, SyncData data)
        {
            var dic = Database.Query <TypeHelpEntity>().ToList();

            if (dic.IsEmpty())
            {
                return(null);
            }

            var typesByTableName = Schema.Current.Tables.ToDictionary(kvp => kvp.Value.Name.Name, kvp => kvp.Key);

            var replace = replacements.TryGetC(Replacements.KeyTables);

            var table = Schema.Current.Table <TypeHelpEntity>();

            using (replacements.WithReplacedDatabaseName())
                return(dic.Select(eh =>
                {
                    Type?type = typesByTableName.TryGetC(replace?.TryGetC(eh.Type.TableName) ?? eh.Type.TableName);
                    if (type == null)
                    {
                        return null; //PreDeleteSqlSync
                    }
                    var repProperties = replacements.TryGetC(PropertyRouteLogic.PropertiesFor.FormatWith(eh.Type.CleanName));
                    var routes = PropertyRoute.GenerateRoutes(type).ToDictionary(pr => { var ps = pr.PropertyString(); return repProperties?.TryGetC(ps) ?? ps; });
                    eh.Properties.RemoveAll(p => !routes.ContainsKey(p.Property.Path));
                    foreach (var prop in eh.Properties)
                    {
                        prop.Description = SynchronizeContent(prop.Description, replacements, data);
                    }

                    var resOperations = replacements.TryGetC(typeof(OperationSymbol).Name);
                    var operations = OperationLogic.TypeOperations(type).ToDictionary(o => { var key = o.OperationSymbol.Key; return resOperations?.TryGetC(key) ?? key; });
                    eh.Operations.RemoveAll(p => !operations.ContainsKey(p.Operation.Key));
                    foreach (var op in eh.Operations)
                    {
                        op.Description = SynchronizeContent(op.Description, replacements, data);
                    }

                    eh.Description = SynchronizeContent(eh.Description, replacements, data);

                    return table.UpdateSqlSync(eh, e => e.Type.CleanName == eh.Type.CleanName);
                }).Combine(Spacing.Simple));
        }
Пример #4
0
    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;
    }
Пример #5
0
        public static ImportAction Load(XDocument document, Dictionary <string, Type> typesByFullName)
        {
            XElement element  = document.Element(_Entity) !;
            var      ci       = CultureInfoLogic.CultureInfoToEntity.Value.GetOrThrow(element.Attribute(_Culture) !.Value);
            var      fullName = element.Attribute(_FullName) !.Value;
            var      type     = SelectInteractive(fullName, typesByFullName, "types");

            if (type == null)
            {
                return(ImportAction.Skipped);
            }

            var typeEntity = type.ToTypeEntity();

            var entity = Database.Query <TypeHelpEntity>().SingleOrDefaultEx(a => a.Culture.Is(ci) && a.Type.Is(typeEntity)) ??
                         new TypeHelpEntity
            {
                Culture = ci,
                Type    = typeEntity,
            };

            element.Element(_Description)?.Do(d => entity.Description = d.Value);

            var props = element.Element(_Properties);

            if (props != null)
            {
                var properties = PropertyRouteLogic.RetrieveOrGenerateProperties(typeEntity).ToDictionary(a => a.Path);

                foreach (var item in props.Elements(_Property))
                {
                    string name = item.Attribute(_Name) !.Value;

                    var property = SelectInteractive(name, properties, "properties for {0}".FormatWith(type.Name));
                    if (property == null)
                    {
                        continue;
                    }

                    var col = property.IsNew ? null : entity.Properties.SingleOrDefaultEx(c => c.Property.Is(property));
                    if (col != null)
                    {
                        col.Description = item.Value;
                    }
                    else
                    {
                        entity.Properties.Add(new PropertyRouteHelpEmbedded
                        {
                            Property    = property,
                            Description = item.Value
                        });
                    }
                }
            }

            var opers = element.Element(_Operations);

            if (opers != null)
            {
                var operations = OperationLogic.TypeOperations(typeEntity.ToType()).ToDictionary(a => a.OperationSymbol.Key, a => a.OperationSymbol);

                foreach (var item in opers.Elements(_Operation))
                {
                    string name      = item.Attribute(_Name) !.Value;
                    var    operation = SelectInteractive(name, operations, "operations for {0}".FormatWith(type.Name));

                    if (operation == null)
                    {
                        continue;
                    }

                    var col = entity.Operations.SingleOrDefaultEx(c => c.Operation.Is(operation));
                    if (col != null)
                    {
                        col.Description = item.Value;
                    }
                    else
                    {
                        entity.Operations.Add(new OperationHelpEmbedded
                        {
                            Operation   = operation,
                            Description = item.Value
                        });
                    }
                }
            }


            return(Save(entity));
        }
Пример #6
0
 public override OmniboxResultGenerator <MapOmniboxResult> CreateGenerator()
 {
     return(new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()));
 }
Пример #7
0
        public EntityHelp(Type type, CultureInfo culture, EntityHelpEntity?entity)
        {
            Type    = type;
            Culture = culture;
            Info    = HelpGenerator.GetEntityHelp(type);

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

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


            var allQueries = HelpLogic.CachedQueriesHelp();

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

            if (entity != null)
            {
                HasEntity = true;

                Description = entity.Description;

                foreach (var tranProp in entity.Properties)
                {
                    Properties.GetOrThrow(tranProp.Property.ToPropertyRoute()).UserDescription = tranProp.Description;
                }

                foreach (var transOper in entity.Operations)
                {
                    Operations.GetOrThrow(transOper.Operation).UserDescription = transOper.Description;
                }
            }

            Entity = new Lazy <EntityHelpEntity>(() => HelpLogic.GlobalContext(() =>
            {
                if (entity == null)
                {
                    entity = new EntityHelpEntity
                    {
                        Culture = this.Culture.ToCultureInfoEntity(),
                        Type    = this.Type.ToTypeEntity(),
                    }
                }
                ;

                entity.Properties.AddRange(
                    PropertyRouteLogic.RetrieveOrGenerateProperties(this.Type.ToTypeEntity())
                    .Except(entity.Properties.Select(a => a.Property))
                    .Select(pr => new PropertyRouteHelpEmbedded
                {
                    Property    = pr,
                    Description = null,
                }));

                entity.Operations.AddRange(
                    OperationLogic.TypeOperations(this.Type).Select(a => a.OperationSymbol)
                    .Except(entity.Operations.Select(a => a.Operation))
                    .Select(pr => new OperationHelpEmbedded
                {
                    Operation   = pr,
                    Description = null,
                }));

                entity.Queries.AddRange(this.Queries.Values.Select(a => a.Entity.Value).ToList());

                return(entity);
            }));
        }