Пример #1
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")
                    });
                };
            }
Пример #2
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<CountSearchControlPartEntity>() { View = e => new CountSearchControlPartEdit() },
                    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(CountSearchControlPartEntity), 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:
                                    new InvalidOperationException("Unexpected").Throw<EmbeddedWidgetPostion>()
                    }; 

                };
            }
        }