Beispiel #1
0
        private static void OnUserQueryChanged(DependencyObject s, UserQueryEntity uc)
        {
            UserQueryPermission.ViewUserQuery.Authorize();

            var currentEntity = UserAssetsClient.GetCurrentEntity(s);

            if (s is CountSearchControl csc)
            {
                csc.QueryName = QueryClient.GetQueryName(uc.Query.Key);
                using (currentEntity == null ? null : CurrentEntityConverter.SetCurrentEntity(currentEntity))
                    UserQueryClient.ToCountSearchControl(uc, csc);
                csc.Search();
                return;
            }

            if (s is SearchControl sc && sc.ShowHeader == false)
            {
                sc.QueryName = QueryClient.GetQueryName(uc.Query.Key);
                using (currentEntity == null ? null : CurrentEntityConverter.SetCurrentEntity(currentEntity))
                    UserQueryClient.ToSearchControl(uc, sc);
                sc.Search();
                return;
            }

            return;
        }
Beispiel #2
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                TypeClient.Start();
                QueryClient.Start();
                Navigator.AddSetting(new EntitySettings <UserQueryEntity> {
                    View = _ => new UserQuery(), Icon = ExtensionsImageLoader.GetImageSortName("userQuery.png")
                });
                SearchControl.GetMenuItems += SearchControl_GetCustomMenuItems;
                UserAssetsClient.Start();
                UserAssetsClient.RegisterExportAssertLink <UserQueryEntity>();

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

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

                    return(Server.Return((IUserQueryServer us) => us.GetUserQueriesEntity(entity.EntityType))
                           .Select(cp => new UserQueryQuickLink(cp, entity)).ToArray());
                });
            }
        }
Beispiel #3
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());
            }
        }
Beispiel #4
0
        void UserChartPartView_Loaded(object sender, RoutedEventArgs e)
        {
            var dc = (UserChartPartEntity)DataContext;

            chartRenderer.FilterOptions = new FreezableCollection <FilterOption>();
            var currentEntity = UserAssetsClient.GetCurrentEntity(this);

            using (currentEntity == null ? null : CurrentEntityConverter.SetCurrentEntity(currentEntity))
                chartRenderer.DataContext = dc.UserChart.ToRequest();

            if (dc.ShowData)
            {
                chartRenderer.ShowData();
            }

            chartRenderer.UpdateFiltersOrdersUserInterface();
            chartRenderer.GenerateOnLoad = true;
        }
Beispiel #5
0
        void UserChartMenuItem_Loaded(object sender, RoutedEventArgs e)
        {
            var currentEntity = UserAssetsClient.GetCurrentEntity(this);

            if (currentEntity != null)
            {
                this.Visibility = System.Windows.Visibility.Hidden;
            }
            else
            {
                Initialize();
            }

            var autoSet = ChartClient.GetUserChart(ChartWindow);

            if (autoSet != null)
            {
                using (currentEntity == null ? null : CurrentEntityConverter.SetCurrentEntity(currentEntity))
                    SetCurrent(autoSet);
            }
        }
Beispiel #6
0
        internal static void OpenChartRequest(ChartRequest chartRequest, UserChartEntity uc, Entity currentEntity)
        {
            Navigator.OpenIndependentWindow(() =>
            {
                var crw = new ChartRequestWindow()
                {
                    DataContext = chartRequest,
                    Title       = ChartMessage.ChartOf0.NiceToString().FormatWith(QueryUtils.GetNiceName(chartRequest.QueryName)),
                    Icon        = Finder.Manager.GetFindIcon(chartRequest.QueryName, false) ?? ExtensionsImageLoader.GetImageSortName("chartIcon.png")
                };

                if (uc != null)
                {
                    SetUserChart(crw, uc);
                }

                if (currentEntity != null)
                {
                    UserAssetsClient.SetCurrentEntity(crw, currentEntity);
                }

                return(crw);
            });
        }
Beispiel #7
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                QueryClient.Start();

                Navigator.RegisterArea(typeof(UserQueriesClient));

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

                LinksClient.RegisterEntityLinks <UserQueryEntity>((lite, ctx) => new[]
                {
                    new QuickLinkAction(UserQueryMessage.Preview, RouteHelper.New().Action <UserQueriesController>(cc => cc.View(lite, null, null)))
                    {
                        IsVisible = UserQueryPermission.ViewUserQuery.IsAuthorized()
                    }
                });

                RouteTable.Routes.MapRoute(null, "UQ/{webQueryName}/{lite}",
                                           new { controller = "UserQueries", action = "View" });

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <UserQueryEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("UserQuery"), IsCreable = EntityWhen.Never
                    },

                    new EmbeddedEntitySettings <QueryFilterEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("QueryFilter"),
                        MappingDefault  = new EntityMapping <QueryFilterEmbedded>(false)
                                          .SetProperty(a => a.Token, QueryTokenMapping(SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement))
                                          .CreateProperty(a => a.Operation)
                                          .CreateProperty(a => a.ValueString)
                    },

                    new EmbeddedEntitySettings <QueryColumnEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("QueryColumn"),
                        MappingDefault  = new EntityMapping <QueryColumnEmbedded>(false)
                                          .SetProperty(a => a.Token, QueryTokenMapping(SubTokensOptions.CanElement))
                                          .CreateProperty(a => a.DisplayName)
                    },

                    new EmbeddedEntitySettings <QueryOrderEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("QueryOrder"),
                        MappingDefault  = new EntityMapping <QueryOrderEmbedded>(false)
                                          .SetProperty(a => a.Token, QueryTokenMapping(SubTokensOptions.CanElement))
                                          .CreateProperty(a => a.OrderType)
                    },
                });

                ButtonBarQueryHelper.RegisterGlobalButtons(ButtonBarQueryHelper_GetButtonBarForQueryName);

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <UserQueryEntity>(UserQueryOperation.Delete)
                    {
                        Click = ctx => Module["deleteUserQuery"](ctx.Options(), Finder.FindRoute(((UserQueryEntity)ctx.Entity).Query.ToQueryName())),
                    }
                });

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

                    return(UserQueryLogic.GetUserQueriesEntity(entity.EntityType)
                           .Select(cp => new UserQueryQuickLink(cp, entity)).ToArray());
                });
            }
        }
Beispiel #8
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());
                });
            }
        }
Beispiel #9
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                TypeClient.Start();

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

                Navigator.AddSettings(new List <EntitySettings>()
                {
                    new EntitySettings <DashboardEntity>()
                    {
                        View = e => new DashboardEdit(), Icon = ExtensionsImageLoader.GetImageSortName("dashboard.png")
                    },

                    new EntitySettings <ValueUserQueryListPartEntity>()
                    {
                        View = e => new ValueUserQueryListPartEntityEdit()
                    },
                    new EntitySettings <LinkListPartEntity>()
                    {
                        View = e => new LinkListPartEdit()
                    },
                    new EntitySettings <UserQueryPartEntity>()
                    {
                        View = e => new UserQueryPartEdit()
                    },
                    new EntitySettings <UserChartPartEntity>()
                    {
                        View = e => new UserChartPartEdit()
                    }
                });

                PartViews.Add(typeof(UserQueryPartEntity), new PartView
                {
                    ViewControl    = () => new UserQueryPartView(),
                    IsTitleEnabled = () => Navigator.IsNavigable(typeof(UserQueryEntity), true),
                    OnTitleClick   = part =>
                    {
                        Navigator.Navigate(((UserQueryPartEntity)part).UserQuery);
                    },
                    FullScreen = (elem, part) =>
                    {
                        UserQueryClient.Explore(((UserQueryPartEntity)part).UserQuery, UserAssetsClient.GetCurrentEntity(elem));
                    }
                });

                PartViews.Add(typeof(UserChartPartEntity), new PartView
                {
                    ViewControl    = () => new UserChartPartView(),
                    IsTitleEnabled = () => Navigator.IsNavigable(typeof(UserChartEntity), true),
                    OnTitleClick   = part =>
                    {
                        Navigator.Navigate(((UserChartPartEntity)part).UserChart);
                    },
                    FullScreen = (elem, part) =>
                    {
                        ChartClient.View(((UserChartPartEntity)part).UserChart, UserAssetsClient.GetCurrentEntity(elem));
                    }
                });

                PartViews.Add(typeof(ValueUserQueryListPartEntity), new PartView
                {
                    ViewControl = () => new CountSearchControlPartView()
                });

                PartViews.Add(typeof(LinkListPartEntity), new PartView
                {
                    ViewControl = () => new LinkListPartView()
                });

                LinksClient.RegisterEntityLinks <DashboardEntity>((cp, ctrl) => new[]
                {
                    new QuickLinkAction(DashboardMessage.Preview, () => Navigate(cp, null))
                    {
                        IsVisible = DashboardPermission.ViewDashboard.IsAuthorized()
                    }
                });

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

                    return(Server.Return((IDashboardServer us) => us.GetDashboardsEntity(entity.EntityType))
                           .Select(cp => new DashboardQuickLink(cp, entity)).ToArray());
                });

                Navigator.Manager.OnGetEmbeddedWigets += (e, ctx) =>
                {
                    if (!DashboardPermission.ViewDashboard.IsAuthorized() || !(e is Entity))
                    {
                        return(null);
                    }

                    var dashboard = Server.Return((IDashboardServer s) => s.GetEmbeddedDashboard(e.GetType()));
                    if (dashboard == null)
                    {
                        return(null);
                    }

                    var control = new DashboardView {
                        DataContext = dashboard
                    }.Set(UserAssetsClient.CurrentEntityProperty, e);

                    return(new EmbeddedWidget
                    {
                        Control = control,
                        Position = dashboard.EmbeddedInEntity.Value == DashboardEmbedededInEntity.Top ? EmbeddedWidgetPostion.Top:
                                   dashboard.EmbeddedInEntity.Value == DashboardEmbedededInEntity.Bottom ? EmbeddedWidgetPostion.Bottom:
                                   throw new InvalidOperationException("Unexpected")
                    });
                };
            }
Beispiel #10
0
        public static void Start(bool navBar)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(DashboardClient));

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

                Navigator.AddSettings(new List<EntitySettings>
                {
                    new EntitySettings<DashboardEntity> { PartialViewName = e => AdminViewPrefix.FormatWith("DashboardAdmin") },
                    new EmbeddedEntitySettings<PanelPartEmbedded>(),
                    
                    new EntitySettings<UserChartPartEntity>(),

                    new EntitySettings<UserQueryPartEntity>(),

                    //new EntitySettings<CountSearchControlPartEntity>(),
                    //new EmbeddedEntitySettings<CountUserQueryElementEmbedded> { PartialViewName = e => AdminViewPrefix.FormatWith("CountUserQueryElement") },
                    
                    new EntitySettings<LinkListPartEntity>(),
                    //new EntitySettings<LinkPartEntity>(),
                    new EmbeddedEntitySettings<LinkElementEmbedded> { PartialViewName = e => AdminViewPrefix.FormatWith("LinkElement") },
                });


                //if(navBar)
                //{

                //    Navigator.AddSettings(new List<EntitySettings>
                //    {
                //        new EntitySettings<OmniboxPanelPartEmbedded> {  },
                //        new EntitySettings<UserQueryCountPartEntity> { PartialViewName = e => AdminViewPrefix.FormatWith("UserQueryCountPartAdmin") },
                //    });
                    

                //    DashboardClient.PanelPartViews.Add(
                //       typeof(OmniboxPanelPartEmbedded),
                //       new DashboardClient.PartViews(ViewPrefixOmnibox.FormatWith("OmniboxPanelPart"), ViewPrefixOmnibox.FormatWith("OmniboxPanelPart")));

                //    DashboardClient.PanelPartViews.Add(
                //     typeof(UserQueryCountPartEntity),
                //     new DashboardClient.PartViews(ViewPrefix.FormatWith("UserQueryCountPart"), AdminViewPrefix.FormatWith("UserQueryCountPartAdmin")));
                //}


                Constructor.Register(ctx => new DashboardEntity { Owner = UserQueryUtils.DefaultOwner() });

                LinksClient.RegisterEntityLinks<DashboardEntity>((cp, ctx) => new[]
                {
                    !DashboardPermission.ViewDashboard.IsAuthorized() ? null:
                     new QuickLinkAction(DashboardMessage.Preview, RouteHelper.New().Action<DashboardController>(cpc => cpc.View(cp, null)))
                });

                LinksClient.RegisterEntityLinks<Entity>((entity, ctrl) =>
                {
                    if (!DashboardPermission.ViewDashboard.IsAuthorized())
                        return null;

                    return DashboardLogic.GetDashboardsEntity(entity.EntityType)
                        .Select(cp => new DashboardQuickLink(cp, entity)).ToArray();
                });

                WidgetsHelper.GetEmbeddedWidget += ctx =>
                {
                    if (!DashboardPermission.ViewDashboard.IsAuthorized() || !(ctx.Entity is Entity) || ((Entity)ctx.Entity).IsNew)
                        return null;

                    var dashboard = DashboardLogic.GetEmbeddedDashboard(ctx.Entity.GetType());
                    if (dashboard == null)
                        return null;

                    return new DashboardEmbeddedWidget { Dashboard = dashboard, Entity = (Entity)ctx.Entity };
                };
            }
        }