示例#1
0
            public static void Register()
            {
                new Construct(DashboardOperation.Create)
                {
                    Construct = (_) => new DashboardEntity {
                        Owner = UserQueryUtils.DefaultOwner()
                    }
                }.Register();

                new Execute(DashboardOperation.Save)
                {
                    AllowsNew = true,
                    Lite      = false,
                    Execute   = (cp, _) => { }
                }.Register();

                new Delete(DashboardOperation.Delete)
                {
                    Delete = (cp, _) =>
                    {
                        var parts = cp.Parts.Select(a => a.Content).ToList();
                        cp.Delete();
                        Database.DeleteList(parts);
                    }
                }.Register();

                new ConstructFrom <DashboardEntity>(DashboardOperation.Clone)
                {
                    Construct = (cp, _) => cp.Clone()
                }.Register();
            }
示例#2
0
        public ActionResult Create(QueryRequest request)
        {
            if (!Finder.IsFindable(request.QueryName))
            {
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(request.QueryName));
            }

            var userQuery = ToUserQuery(request);

            userQuery.Owner = UserQueryUtils.DefaultOwner();

            return(Navigator.NormalPage(this, userQuery));
        }
示例#3
0
        public ActionResult CreateUserChart()
        {
            var request = ExtractChartRequestCtx(null).Value;

            if (!Finder.IsFindable(request.QueryName))
            {
                throw new UnauthorizedAccessException(ChartMessage.Chart_Query0IsNotAllowed.NiceToString().FormatWith(request.QueryName));
            }

            var userChart = request.ToUserChart();

            userChart.Owner = UserQueryUtils.DefaultOwner();

            ViewData[ViewDataKeys.QueryDescription] = DynamicQueryManager.Current.QueryDescription(request.QueryName);

            return(Navigator.NormalPage(this, userChart));
        }
示例#4
0
        public static UserChartEntity ToUserChart(this ChartRequest request)
        {
            var result = new UserChartEntity
            {
                Owner = UserQueryUtils.DefaultOwner(),

                QueryName = request.QueryName,

                GroupResults = request.GroupResults,
                ChartScript  = request.ChartScript,

                Filters = request.Filters.Select(f => new QueryFilterEmbedded
                {
                    Token       = new QueryTokenEmbedded(f.Token),
                    Operation   = f.Operation,
                    ValueString = FilterValueConverter.ToString(f.Value, f.Token.Type),
                }).ToMList(),

                Orders = request.Orders.Select(o => new QueryOrderEmbedded
                {
                    Token     = new QueryTokenEmbedded(o.Token),
                    OrderType = o.OrderType
                }).ToMList()
            };

            result.Columns.ZipForeach(request.Columns, (u, r) =>
            {
                u.Token       = r.Token;
                u.DisplayName = r.DisplayName;
            });

            result.Parameters.ForEach(u =>
            {
                u.Value = request.Parameters.FirstOrDefault(r => r.Name == u.Name).Value;
            });

            return(result);
        }
示例#5
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 };
                };
            }
        }