Ejemplo n.º 1
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                TypeClient.Start();
                QueryClient.Start();

                Navigator.AddSettings(new List <EntitySettings>()
                {
                    new EntitySettings <UserChartEntity> {
                        View = e => new UserChart(), Icon = ExtensionsImageLoader.GetImageSortName("chartIcon.png")
                    },
                    new EntitySettings <ChartScriptEntity> {
                        View = e => new ChartScript(), Icon = ExtensionsImageLoader.GetImageSortName("chartScript.png")
                    },
                });

                UserAssetsClient.Start();
                UserAssetsClient.RegisterExportAssertLink <UserChartEntity>();

                SearchControl.GetMenuItems += SearchControl_GetCustomMenuItems;

                UserChartEntity.SetConverters(query => QueryClient.GetQueryName(query.Key), queryname => QueryClient.GetQuery(queryname));

                string processName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

                var main = Registry.CurrentUser
                           .CreateSubKey("Software")
                           .CreateSubKey("Microsoft")
                           .CreateSubKey("Internet Explorer")
                           .CreateSubKey("Main")
                           .CreateSubKey("FeatureControl")
                           .CreateSubKey("FEATURE_BROWSER_EMULATION");

                main.SetValue(processName, 9999, RegistryValueKind.DWord);

                Constructor.Register <UserChartEntity>(ctx =>
                {
                    MessageBox.Show(Window.GetWindow(ctx.Element),
                                    ChartMessage._0CanOnlyBeCreatedFromTheChartWindow.NiceToString().FormatWith(typeof(UserChartEntity).NicePluralName()),
                                    ChartMessage.CreateNew.NiceToString(),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    return(null);
                });

                LinksClient.RegisterEntityLinks <Entity>((entity, ctrl) =>
                                                         Server.Return((IChartServer us) => us.GetUserChartsEntity(entity.EntityType))
                                                         .Select(cp => new UserChartQuickLink(cp, entity)).ToArray());
            }
        }
Ejemplo n.º 2
0
        public static void Start(IApplicationBuilder app)
        {
            UserAssetServer.Start(app);

            SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod());

            CustomizeChartRequest();

            SignumServer.WebEntityJsonConverterFactory.AfterDeserilization.Register((ChartRequestModel cr) =>
            {
                if (cr.ChartScript != null)
                {
                    cr.GetChartScript().SynchronizeColumns(cr, null);
                }

                if (cr.QueryName != null)
                {
                    var qd = QueryLogic.Queries.QueryDescription(cr.QueryName);

                    if (cr.Columns != null)
                    {
                        foreach (var c in cr.Columns)
                        {
                            c.ParseData(cr, qd, SubTokensOptions.CanElement | SubTokensOptions.CanAggregate);
                        }
                    }
                }
            });

            SignumServer.WebEntityJsonConverterFactory.AfterDeserilization.Register((UserChartEntity uc) =>
            {
                if (uc.ChartScript != null)
                {
                    uc.GetChartScript().SynchronizeColumns(uc, null);
                }

                if (uc.Query != null)
                {
                    var qd = QueryLogic.Queries.QueryDescription(uc.Query.ToQueryName());
                    uc.ParseData(qd);
                }
            });

            UserChartEntity.SetConverters(
                query => QueryLogic.ToQueryName(query.Key),
                queryName => QueryLogic.GetQueryEntity(queryName));

            EntityPackTS.AddExtension += ep =>
            {
                if (ep.entity.IsNew || !ChartPermission.ViewCharting.IsAuthorized() || TypeAuthLogic.GetAllowed(typeof(UserChartEntity)).MaxDB() == TypeAllowedBasic.None)
                {
                    return;
                }

                var userCharts = UserChartLogic.GetUserChartsEntity(ep.entity.GetType());
                if (userCharts.Any())
                {
                    ep.extension.Add("userCharts", userCharts);
                }
            };
        }
Ejemplo n.º 3
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                QueryClient.Start();

                UserAssetsClient.Start();
                UserAssetsClient.RegisterExportAssertLink <UserChartEntity>();

                LinksClient.RegisterEntityLinks <UserChartEntity>((lite, ctx) => new[]
                {
                    new QuickLinkAction(ChartMessage.Preview, RouteHelper.New().Action <ChartController>(cc => cc.ViewUserChart(lite, null)))
                    {
                        IsVisible = ChartPermission.ViewCharting.IsAuthorized()
                    }
                });

                Func <SubTokensOptions, Mapping <QueryTokenEmbedded> > qtMapping = ops => ctx =>
                {
                    string tokenStr = UserAssetsHelper.GetTokenString(ctx);

                    string queryKey  = ctx.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", "Key")];
                    object queryName = QueryLogic.ToQueryName(queryKey);

                    var chart = ((UserChartEntity)ctx.Parent.Parent.Parent.UntypedValue);

                    QueryDescription qd = DynamicQueryManager.Current.QueryDescription(queryName);
                    return(new QueryTokenEmbedded(QueryUtils.Parse(tokenStr, qd, ops | (chart.GroupResults ? SubTokensOptions.CanAggregate : 0))));
                };

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <UserChartEntity> {
                        PartialViewName = _ => ChartClient.ViewPrefix.FormatWith("UserChart"), IsCreable = EntityWhen.Never
                    }
                });

                Navigator.EntitySettings <UserChartEntity>().MappingMain = Navigator.EntitySettings <UserChartEntity>().MappingLine =
                    new EntityMapping <UserChartEntity>(true)
                    .SetProperty(cb => cb.Columns, new ChartClient.MListCorrelatedOrDefaultMapping <ChartColumnEmbedded>(ChartClient.MappingChartColumn))
                    .SetProperty(cr => cr.Filters, new MListMapping <QueryFilterEmbedded>
                {
                    ElementMapping = new EntityMapping <QueryFilterEmbedded>(false)
                                     .CreateProperty(a => a.Operation)
                                     .CreateProperty(a => a.ValueString)
                                     .SetProperty(a => a.Token, qtMapping(SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement))
                })
                    .SetProperty(cr => cr.Orders, new MListMapping <QueryOrderEmbedded>
                {
                    ElementMapping = new EntityMapping <QueryOrderEmbedded>(false)
                                     .CreateProperty(a => a.OrderType)
                                     .SetProperty(a => a.Token, qtMapping(SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement))
                })
                    .SetProperty(cb => cb.Parameters, new MListDictionaryMapping <ChartParameterEmbedded, string>(p => p.Name)
                {
                    OnlyIfPossible = true
                });

                RouteTable.Routes.MapRoute(null, "UC/{webQueryName}/{lite}",
                                           new { controller = "Chart", action = "ViewUserChart" });

                UserChartEntity.SetConverters(query => QueryLogic.ToQueryName(query.Key), queryName =>
                                              QueryLogic.GetQueryEntity(queryName));

                OperationClient.AddSetting(new EntityOperationSettings <UserChartEntity>(UserChartOperation.Delete)
                {
                    Click = ctx => ChartClient.Module["deleteUserChart"](ctx.Options(), Finder.FindRoute(((UserChartEntity)ctx.Entity).Query.ToQueryName())),
                });

                LinksClient.RegisterEntityLinks <Entity>((entity, ctrl) =>
                {
                    if (!ChartPermission.ViewCharting.IsAuthorized())
                    {
                        return(null);
                    }

                    return(UserChartLogic.GetUserChartsEntity(entity.EntityType)
                           .Select(cp => new UserChartQuickLink(cp, entity)).ToArray());
                });
            }
        }
Ejemplo n.º 4
0
        public static void Start(HttpConfiguration config)
        {
            UserAssetServer.Start(config);

            SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod());

            CustomizeChartRequest();

            PropertyConverter.GetPropertyConverters(typeof(ChartScriptParameterEmbedded)).Add("enumValues", new PropertyConverter()
            {
                CustomWriteJsonProperty = ctx =>
                {
                    var csp = (ChartScriptParameterEmbedded)ctx.Entity;

                    if (csp.Type == ChartParameterType.Enum)
                    {
                        ctx.JsonWriter.WritePropertyName(ctx.LowerCaseName);
                        ctx.JsonSerializer.Serialize(ctx.JsonWriter, csp.GetEnumValues().Select(a => new { name = a.Name, typeFilter = a.TypeFilter }).ToList());
                    }
                },
                AvoidValidate          = true,
                CustomReadJsonProperty = ctx =>
                {
                    var list = ctx.JsonSerializer.Deserialize(ctx.JsonReader);
                    //Discard
                }
            });

            EntityJsonConverter.AfterDeserilization.Register((ChartRequest cr) =>
            {
                if (cr.ChartScript != null)
                {
                    cr.ChartScript.SynchronizeColumns(cr);
                }

                if (cr.QueryName != null)
                {
                    var qd = DynamicQueryManager.Current.QueryDescription(cr.QueryName);

                    if (cr.Columns != null)
                    {
                        foreach (var c in cr.Columns)
                        {
                            c.ParseData(cr, qd, SubTokensOptions.CanElement | (c.IsGroupKey == false ? SubTokensOptions.CanAggregate : 0));
                        }
                    }
                }
            });

            EntityJsonConverter.AfterDeserilization.Register((UserChartEntity uc) =>
            {
                if (uc.ChartScript != null)
                {
                    uc.ChartScript.SynchronizeColumns(uc);
                }

                if (uc.Query != null)
                {
                    var qd = DynamicQueryManager.Current.QueryDescription(uc.Query.ToQueryName());
                    uc.ParseData(qd);
                }
            });

            UserChartEntity.SetConverters(
                query => QueryLogic.ToQueryName(query.Key),
                queryName => QueryLogic.GetQueryEntity(queryName));

            EntityPackTS.AddExtension += ep =>
            {
                if (ep.entity.IsNew || !ChartPermission.ViewCharting.IsAuthorized())
                {
                    return;
                }

                var userCharts = UserChartLogic.GetUserChartsEntity(ep.entity.GetType());
                if (userCharts.Any())
                {
                    ep.Extension.Add("userCharts", userCharts);
                }
            };
        }