Example #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;
        }
Example #2
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;
        }
Example #3
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);
            }
        }
Example #4
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")
                    });
                };
            }