Exemple #1
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(WordClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <WordTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("WordTemplate")
                    },
                    new EntitySettings <SystemWordTemplateEntity> {
                    },
                    new EntitySettings <WordTransformerSymbol> {
                    },
                    new EntitySettings <WordConverterSymbol> {
                    },
                });
                OperationClient.AddSetting(new EntityOperationSettings <WordTemplateEntity>(WordTemplateOperation.CreateWordReport)
                {
                    Group = EntityOperationGroup.None,
                    Click = ctx => Module["createWordReportFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                          new FindOptions(ctx.Entity.Query.ToQueryName()).ToJS(ctx.Prefix, "New"),
                                                                          ctx.Url.Action((WordController mc) => mc.CreateWordReport()))
                });
            }
        }
Exemple #2
0
        public static void Start(params Type[] types)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                if (types == null)
                {
                    throw new ArgumentNullException("types");
                }

                Navigator.RegisterArea(typeof(NoteClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <NoteTypeEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("NoteType")
                    },
                    new EntitySettings <NoteEntity>
                    {
                        PartialViewName = _ => ViewPrefix.FormatWith("Note"),
                        IsCreable       = EntityWhen.Never
                    },
                });

                Types = types;

                WidgetsHelper.GetWidget += WidgetsHelper_GetWidget;
                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <Entity>(NoteOperation.CreateNoteFromEntity)
                    {
                        IsVisible = _ => false
                    }
                });
            }
        }
Exemple #3
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(SMSClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <SMSConfigurationEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSConfiguration")
                    },

                    new EntitySettings <SMSMessageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSMessage")
                    },
                    new EntitySettings <SMSTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSTemplate")
                    },
                    new EmbeddedEntitySettings <SMSTemplateMessageEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSTemplateMessage")
                    },

                    new EntitySettings <SMSSendPackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSSendPackage")
                    },
                    new EntitySettings <SMSUpdatePackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSUpdatePackage")
                    },

                    new ModelEntitySettings <MultipleSMSModel> {
                        PartialViewName = e => ViewPrefix.FormatWith("MultipleSMS")
                    },
                });

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <Entity>(SMSMessageOperation.CreateSMSWithTemplateFromEntity)
                    {
                        Click = ctx => Module["createSmsWithTemplateFromEntity"](ctx.Options(), JsFunction.Event,
                                                                                 ctx.Url.Action((SMSController sms) => sms.CreateSMSMessageFromTemplate()),
                                                                                 SmsTemplateFindOptions(ctx.Entity.GetType()).ToJS(ctx.Prefix, "New"))
                    },

                    new ContextualOperationSettings <Entity>(SMSMessageOperation.SendSMSMessagesFromTemplate)
                    {
                        Click = ctx => Module["sendMultipleSMSMessagesFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                                     ctx.Url.Action((SMSController sms ) => sms.SendMultipleMessagesFromTemplate()),
                                                                                     SmsTemplateFindOptions(ctx.SingleType).ToJS(ctx.Prefix, "New"))
                    },

                    new ContextualOperationSettings <Entity>(SMSMessageOperation.SendSMSMessages)
                    {
                        Click = ctx => Module["sentMultipleSms"](ctx.Options(), JsFunction.Event, ctx.Prefix,
                                                                 ctx.Url.Action((SMSController sms) => sms.SendMultipleSMSMessagesModel()),
                                                                 ctx.Url.Action((SMSController sms) => sms.SendMultipleMessages()))
                    },
                });
            }
        }
Exemple #4
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>()
                {
                    new EntitySettings <DisconnectedMachineEntity> {
                        View = dm => new DisconnectedMachine()
                    },
                    new EntitySettings <DisconnectedExportEntity> {
                        View = dm => new DisconnectedExport()
                    },
                    new EntitySettings <DisconnectedImportEntity> {
                        View = dm => new DisconnectedImport()
                    },
                });

                Server.Connecting += UpdateCache;
                UpdateCache();

                Navigator.Manager.IsReadOnly += (type, entity) => entity is Entity && !Editable((Entity)entity, type);

                Navigator.Manager.IsCreable += type =>
                {
                    if (!type.IsEntity())
                    {
                        return(true);
                    }

                    if (!Server.OfflineMode)
                    {
                        return(true);
                    }

                    return(strategies[type].Upload != Upload.None);
                };

                Lite <DisconnectedMachineEntity> current = null;

                DisconnectedMachineEntity.CurrentVariable.ValueFactory = () =>
                {
                    if (current != null)
                    {
                        return(current);
                    }

                    current = Server.Return((IDisconnectedServer s) => s.GetDisconnectedMachine(Environment.MachineName));

                    if (current == null)
                    {
                        throw new ApplicationException("No {0} found for '{1}'".FormatWith(typeof(DisconnectedMachineEntity).NiceName(), Environment.MachineName));
                    }

                    return(current);
                };
            }
        }
Exemple #5
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <SMSMessageEntity> {
                        View = e => new SMSMessage(), Icon = ExtensionsImageLoader.GetImageSortName("sms.png")
                    },
                    new EntitySettings <SMSTemplateEntity> {
                        View = e => new SMSTemplate(), Icon = ExtensionsImageLoader.GetImageSortName("smstemplate.png")
                    },
                    new EmbeddedEntitySettings <SMSTemplateMessageEmbedded>()
                    {
                        View = e => new Signum.Windows.SMS.SMSTemplateMessage()
                    },
                    new EntitySettings <SMSSendPackageEntity> {
                        View = e => new SMSSendPackage(), Icon = ExtensionsImageLoader.GetImageSortName("package.png")
                    },
                    new EntitySettings <SMSUpdatePackageEntity> {
                        View = e => new SMSUpdatePackage(), Icon = ExtensionsImageLoader.GetImageSortName("package.png")
                    },
                    new ModelEntitySettings <MultipleSMSModel> {
                        View = e => new MultipleSMS(), Icon = ExtensionsImageLoader.GetImageSortName("package.png")
                    },
                });

                OperationClient.AddSetting(new EntityOperationSettings <Entity>(SMSMessageOperation.CreateSMSWithTemplateFromEntity)
                {
                    Click = FindAssociatedTemplates
                });

                OperationClient.AddSetting(new ContextualOperationSettings <Entity>(SMSMessageOperation.SendSMSMessages)
                {
                    Click = coc =>
                    {
                        MultipleSMSModel model = Navigator.View(new MultipleSMSModel());

                        if (model == null)
                        {
                            return;
                        }

                        var result = new ConstructorContext(coc.SearchControl, coc.OperationInfo).SurroundConstruct(ctx =>
                                                                                                                    Server.Return((IOperationServer s) => s.ConstructFromMany(coc.Entities, coc.Type, coc.OperationInfo.OperationSymbol, ctx.Args)));

                        if (result != null)
                        {
                            Navigator.Navigate(result);
                        }
                    }
                });
            }
        }
Exemple #6
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(TypeEntity)))
                {
                    Navigator.AddSetting(new EntitySettings <TypeEntity>());
                }

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new ModelEntitySettings <ChartPaletteModel>
                    {
                        PartialViewName = _ => ChartClient.ViewPrefix.FormatWith("ChartPalette"),
                        MappingDefault  = new EntityMapping <ChartPaletteModel>(true)
                                          .SetProperty(a => a.Colors, new MListDictionaryMapping <ChartColorEntity, Lite <Entity> >(cc => cc.Related,
                                                                                                                                    new EntityMapping <ChartColorEntity>(false)
                                                                                                                                    .CreateProperty(m => m.Color)
                                                                                                                                    .CreateProperty(c => c.Related)))
                    }
                });

                ChartUtils.GetChartColor = ChartColorLogic.ColorFor;

                ButtonBarEntityHelper.RegisterEntityButtons <ChartPaletteModel>((ctx, entity) =>
                {
                    var typeName = Navigator.ResolveWebTypeName(entity.Type.ToType());
                    return(new[]
                    {
                        new ToolBarButton(ctx.Prefix, "savePalette")
                        {
                            Text = ChartMessage.SavePalette.NiceToString(),
                            Style = BootstrapStyle.Primary,
                            OnClick = Module["savePalette"](ctx.Url.Action <ColorChartController>(pc => pc.SavePalette(typeName)))
                        },
                        new ToolBarButton(ctx.Prefix, "newPalette")
                        {
                            Text = ChartMessage.NewPalette.NiceToString(),
                            OnClick = Module["createPalette"](
                                ctx.Url.Action <ColorChartController>(pc => pc.CreateNewPalette(typeName)),
                                ChartColorLogic.Palettes.Keys,
                                ChartMessage.ChooseABasePalette.NiceToString())
                        },
                        new ToolBarButton(ctx.Prefix, "deletePalette")
                        {
                            Text = ChartMessage.DeletePalette.NiceToString(),
                            Style = BootstrapStyle.Danger,
                            OnClick = Module["deletePalette"](
                                ctx.Url.Action <ColorChartController>(pc => pc.DeletePalette(typeName)))
                        }
                    });
                });
            }
        }
Exemple #7
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                });

                Server.SetSymbolIds <FileTypeSymbol>();
            }
        }
Exemple #8
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(BasicClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <DateSpanEmbedded> {
                        PartialViewName = _ => ViewPrefix.FormatWith("DateSpan")
                    },
                });
            }
        }
Exemple #9
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(CultureInfoClient), "Cultures");

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <CultureInfoEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("CultureInfoView")
                    },
                });
            }
        }
Exemple #10
0
 public static void Start()
 {
     if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
     {
         Navigator.AddSettings(new List <EntitySettings>
         {
             new EntitySettings <QueryEntity>
             {
                 MappingMain = new EntityMapping <QueryEntity>(true).GetValue,
                 MappingLine = new EntityMapping <QueryEntity>(true).GetValue
             }
         });
     }
 }
Exemple #11
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>()
                {
                    new EntitySettings <ScheduledTaskEntity> {
                        View = e => new ScheduledTask(), Icon = Image("clock.png")
                    },

                    new EntitySettings <SimpleTaskSymbol> {
                        View = e => new SimpleTask(), Icon = Image("simpleTask.png")
                    },
                    new EntitySettings <ScheduledTaskLogEntity> {
                        View = e => new ScheduledTaskLog(), Icon = Image("scheduledTaskLog.png")
                    },

                    new EntitySettings <ScheduleRuleMonthsEntity> {
                        View = e => new ScheduleRuleMonths()
                    },
                    new EntitySettings <ScheduleRuleWeekDaysEntity> {
                        View = e => new ScheduleRuleWeekDays()
                    },
                    new EntitySettings <ScheduleRuleMinutelyEntity> {
                        View = e => new ScheduleRuleMinutely()
                    },
                    new EntitySettings <HolidayCalendarEntity> {
                        View = e => new HolidayCalendar()
                    },
                });

                Server.SetSymbolIds <SimpleTaskSymbol>();

                var executeGroup = new EntityOperationGroup
                {
                    Background     = Brushes.Gold,
                    AutomationName = "execute",
                    Text           = () => ITaskMessage.Execute.NiceToString() + "...",
                };

                OperationClient.AddSetting(new EntityOperationSettings <ITaskEntity>(ITaskOperation.ExecuteSync)
                {
                    Icon = Image("execute.png"), Group = executeGroup
                });
                OperationClient.AddSetting(new EntityOperationSettings <ITaskEntity>(ITaskOperation.ExecuteAsync)
                {
                    Icon = Image("execute.png"), Group = executeGroup
                });
            }
        }
Exemple #12
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());
            }
        }
Exemple #13
0
        public static void Start(bool simpleTask)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(SchedulerClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <ScheduledTaskLogEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduledTaskLog")
                    },
                    new EntitySettings <ScheduledTaskEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduledTask")
                    },

                    new EntitySettings <ScheduleRuleMinutelyEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduleRuleMinutely")
                    },
                    new EntitySettings <ScheduleRuleWeekDaysEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduleRuleWeekDays")
                    },
                    new EntitySettings <ScheduleRuleMonthsEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduleRuleMonths")
                    },

                    new EntitySettings <HolidayCalendarEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("HolidayCalendar")
                    },
                    new EmbeddedEntitySettings <HolidayEmbedded> {
                        PartialViewName = _ => ViewPrefix.FormatWith("Holiday")
                    },
                });

                if (simpleTask)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SimpleTaskSymbol> {
                            PartialViewName = _ => ViewPrefix.FormatWith("SimpleTask")
                        },
                    });
                }

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("SchedulerPanel",
                                                                         () => SchedulerPermission.ViewSchedulerPanel.IsAuthorized(),
                                                                         uh => uh.Action((SchedulerController sc) => sc.View())));
            }
        }
Exemple #14
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.Manager.RetrievingForView += Manager_RetrievingForView;

                Navigator.RegisterArea(typeof(ViewLogClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <ViewLogEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ViewLog")
                    },
                });
            }
        }
Exemple #15
0
        public static void Start(bool packages, bool packageOperations)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(ProcessClient), "Processes");

                UrlsRepository.DefaultSFUrls.Add("processFromMany", url => url.Action((ProcessController pc) => pc.ProcessFromMany()));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <ProcessEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("Process"),
                    },
                    new EntitySettings <ProcessAlgorithmSymbol> {
                        PartialViewName = e => ViewPrefix.FormatWith("ProcessAlgorithm")
                    },
                });

                if (packages || packageOperations)
                {
                    Navigator.AddSetting(new EntitySettings <PackageLineEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("PackageLine")
                    });
                }

                if (packages)
                {
                    Navigator.AddSetting(new EntitySettings <PackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("Package")
                    });
                }

                if (packageOperations)
                {
                    Navigator.AddSetting(new EntitySettings <PackageOperationEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("PackageOperation")
                    });

                    OperationClient.Manager.CustomizeMenuItem += CustomizeMenuItemForProcess;
                }

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ProcessPanel",
                                                                         () => ProcessPermission.ViewProcessPanel.IsAuthorized(),
                                                                         uh => uh.Action((ProcessController pc) => pc.View())));
            }
        }
Exemple #16
0
        public static void Start(bool smtp, bool pop3)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <EmailMessageEntity> {
                        View = e => new EmailMessage()
                    },
                    new EmbeddedEntitySettings <EmailAttachmentEmbedded> {
                        View = e => new EmailAttachment()
                    },
                    new EmbeddedEntitySettings <EmailAddressEmbedded> {
                        View = e => new EmailAddress()
                    },
                    new EmbeddedEntitySettings <EmailRecipientEntity> {
                        View = e => new EmailRecipient()
                    }
                });

                if (smtp || pop3)
                {
                    Navigator.AddSetting(new EmbeddedEntitySettings <ClientCertificationFileEmbedded> {
                        View = e => new ClientCertificationFile()
                    });
                }

                if (smtp)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SmtpConfigurationEntity> {
                            View = e => new SmtpConfiguration()
                        },
                    });
                }

                if (pop3)
                {
                    Navigator.AddSetting(new EntitySettings <Pop3ConfigurationEntity> {
                        View = e => new Pop3Configuration()
                    });
                }
            }
        }
Exemple #17
0
        public static void Start(params Type[] types)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                if (types == null)
                {
                    throw new ArgumentNullException("types");
                }

                Navigator.RegisterArea(typeof(AlertClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <AlertEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("Alert")
                    },
                    new EntitySettings <AlertTypeEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("AlertType")
                    },
                });

                Types = types;

                WidgetsHelper.GetWidget += WidgetsHelper_GetWidget;

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <Entity>(AlertOperation.CreateAlertFromEntity)
                    {
                        IsVisible = a => false
                    },
                    //new EntityOperationSettings<AlertEntity>(AlertOperation.SaveNew){ IsVisible = a => a.Entity.IsNew },
                    new EntityOperationSettings <AlertEntity>(AlertOperation.Save)
                    {
                        IsVisible = a => !a.Entity.IsNew
                    }
                });
            }
        }
Exemple #18
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(DisconnectedClient));

                Navigator.AddSettings(new List <EntitySettings>()
                {
                    new EntitySettings <DisconnectedMachineEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("DisconnectedMachine")
                    },
                    new EntitySettings <DisconnectedExportEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("DisconnectedExport")
                    },
                    new EntitySettings <DisconnectedImportEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("DisconnectedImport")
                    },
                });

                MapClient.GetColorProviders += GetMapColors;
            }
        }
Exemple #19
0
        public static void Start()
        {
            if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(FileEntity)))
            {
                throw new InvalidOperationException("Call FileClient.Start first with FileEntity");
            }

            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(ChartClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new ModelEntitySettings <ChartRequest>(),
                    new EmbeddedEntitySettings <ChartParameterEmbedded>(),
                    new EmbeddedEntitySettings <ChartColumnEmbedded> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ChartColumn")
                    },
                    new EmbeddedEntitySettings <ChartScriptColumnEmbedded> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ChartScriptColumn")
                    },
                    new EmbeddedEntitySettings <ChartScriptParameterEmbedded> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ChartScriptParameter")
                    },
                    new EntitySettings <ChartScriptEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ChartScript")
                    },
                });

                ButtonBarQueryHelper.RegisterGlobalButtons(ButtonBarQueryHelper_GetButtonBarForQueryName);

                RouteTable.Routes.MapRoute(null, "ChartFor/{webQueryName}",
                                           new { controller = "Chart", action = "Index", webQueryName = "" });

                UserChartClient.Start();
                ChartColorClient.Start();
            }
        }
Exemple #20
0
        public static void Start(params Type[] types)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                if (types == null)
                {
                    throw new ArgumentNullException("types");
                }

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <AlertTypeEntity> {
                        View = e => new AlertType()
                    },
                    new EntitySettings <AlertEntity>
                    {
                        View      = e => new Alert(),
                        IsCreable = EntityWhen.Never,
                        Icon      = ExtensionsImageLoader.GetImageSortName("alert.png"),
                    }
                });

                Server.SetSemiSymbolIds <AlertTypeEntity>();

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <Entity>(AlertOperation.CreateAlertFromEntity)
                    {
                        IsVisible = a => false
                    },
                });

                WidgetPanel.GetWidgets += (obj, mainControl) =>
                                          (obj is Entity && types.Contains(obj.GetType()) && !((Entity)obj).IsNew) &&
                                          Finder.IsFindable(typeof(AlertEntity)) ? new AlertsWidget() : null;
            }
        }
Exemple #21
0
        public static void Start(string imageFolder, string baseUrl)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                HelpUrls.BaseUrl      = baseUrl;
                HelpUrls.ImagesFolder = imageFolder;

                Navigator.RegisterArea(typeof(HelpClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <EntityHelpEntity>(),
                    new EntitySettings <QueryHelpEntity>(),
                    new EntitySettings <AppendixHelpEntity>(),
                    new EntitySettings <NamespaceHelpEntity>(),
                    new EmbeddedEntitySettings <PropertyRouteHelpEmbedded>(),
                    new EntitySettings <OperationHelpEntity>(),
                    new EmbeddedEntitySettings <QueryColumnHelpEmbedded>(),
                });

                Navigator.EmbeddedEntitySettings <PropertyRouteHelpEmbedded>().MappingDefault.AsEntityMapping()
                .SetProperty(a => a.Property, ctx =>
                {
                    var type = ctx.FindParent <EntityHelpEntity>().Value.Type.ToType();
                    return(PropertyRoute.Parse(type, ctx.Input).ToPropertyRouteEntity());
                });

                RegisterHelpRoutes();

                Common.CommonTask += Common_CommonTask;

                WidgetsHelper.GetWidget += WidgetsHelper_GetWidget;

                ButtonBarQueryHelper.RegisterGlobalButtons(ButtonBarQueryHelper_RegisterGlobalButtons);
            }
        }
Exemple #22
0
        public static void Start(bool smtpConfig, bool newsletter, bool pop3Config, bool emailReport, Type[] quickLinkFrom)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(MailingClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <EmailAttachmentEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailAttachment")
                    },
                    new EntitySettings <EmailPackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailPackage")
                    },

                    new EntitySettings <EmailMessageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMessage"), AvoidValidateRequest = true
                    },

                    new EmbeddedEntitySettings <EmailAddressEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailAddress")
                    },
                    new EmbeddedEntitySettings <EmailRecipientEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailRecipient")
                    },

                    new EmbeddedEntitySettings <EmailConfigurationEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailConfiguration")
                    },
                    new EntitySettings <SystemEmailEntity> {
                    },

                    new EntitySettings <EmailMasterTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMasterTemplate"), AvoidValidateRequest = true
                    },
                    new EmbeddedEntitySettings <EmailMasterTemplateMessageEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMasterTemplateMessage"),
                        MappingDefault  = new EntityMapping <EmailMasterTemplateMessageEmbedded>(true)
                                          .SetProperty(emtm => emtm.MasterTemplate, ctx =>
                        {
                            return((EmailMasterTemplateEntity)ctx.Parent.Parent.Parent.Parent.UntypedValue);
                        })
                    },

                    new EntitySettings <EmailTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplate"), AvoidValidateRequest = true
                    },
                    new EmbeddedEntitySettings <EmailTemplateMessageEmbedded>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateMessage")
                    },

                    new EmbeddedEntitySettings <EmailTemplateContactEmbedded>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateContact"),
                        MappingDefault  = new EntityMapping <EmailTemplateContactEmbedded>(true)
                                          .SetProperty(ec => ec.Token, ctx =>
                        {
                            string tokenStr = UserAssetsHelper.GetTokenString(ctx);
                            return(ParseQueryToken(tokenStr, ctx.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", EntityBaseKeys.RuntimeInfo)]));
                        }),
                    },

                    new EmbeddedEntitySettings <EmailTemplateRecipientEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateRecipient"),
                        MappingDefault  = new EntityMapping <EmailTemplateRecipientEntity>(true)
                                          .SetProperty(ec => ec.Token, ctx =>
                        {
                            string tokenStr = UserAssetsHelper.GetTokenString(ctx);

                            return(ParseQueryToken(tokenStr, ctx.Parent.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", EntityBaseKeys.RuntimeInfo)]));
                        })
                    },
                });

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <EmailTemplateEntity>(EmailMessageOperation.CreateEmailFromTemplate)
                    {
                        Group = EntityOperationGroup.None,
                        Click = ctx => Module["createMailFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                        new FindOptions(((EmailTemplateEntity)ctx.Entity).Query.ToQueryName()).ToJS(ctx.Prefix, "New"),
                                                                        ctx.Url.Action((MailingController mc) => mc.CreateMailFromTemplateAndEntity()))
                    }
                });

                if (smtpConfig)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SmtpConfigurationEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("SmtpConfiguration")
                        },
                        new EmbeddedEntitySettings <SmtpNetworkDeliveryEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("SmtpNetworkDelivery")
                        },
                        new EmbeddedEntitySettings <ClientCertificationFileEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("ClientCertificationFile")
                        },
                    });
                }

                if (newsletter)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <NewsletterEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Newsletter"), AvoidValidateRequest = true
                        },
                        new EntitySettings <NewsletterDeliveryEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("NewsletterDelivery")
                        },
                    });

                    OperationClient.AddSettings(new List <OperationSettings>
                    {
                        new EntityOperationSettings <NewsletterEntity>(NewsletterOperation.RemoveRecipients)
                        {
                            Click = ctx => Module["removeRecipients"](ctx.Options(),
                                                                      new FindOptions(typeof(NewsletterDeliveryEntity), "Newsletter", ctx.Entity).ToJS(ctx.Prefix, "New"),
                                                                      ctx.Url.Action((MailingController mc) => mc.RemoveRecipientsExecute()))
                        },

                        new EntityOperationSettings <NewsletterEntity>(NewsletterOperation.Send)
                        {
                            Group = EntityOperationGroup.None,
                        }
                    });
                }

                if (emailReport)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SendEmailTaskEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("SendEmailTask")
                        }
                    });
                }

                if (pop3Config)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <Pop3ConfigurationEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Pop3Configuration")
                        },
                        new EntitySettings <Pop3ReceptionEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Pop3Reception")
                        },
                    });
                }

                if (quickLinkFrom != null)
                {
                    LinksClient.RegisterEntityLinks <Entity>((lite, ctx) =>
                    {
                        if (!quickLinkFrom.Contains(lite.EntityType))
                        {
                            return(null);
                        }

                        return(new[] { new QuickLinkExplore(typeof(EmailMessageEntity), "Target", lite) });
                    });
                }


                TasksGetWebMailBody += WebMailProcessor.ReplaceUntrusted;
                TasksGetWebMailBody += WebMailProcessor.CidToFilePath;

                TasksSetWebMailBody += WebMailProcessor.AssertNoUntrusted;
                TasksSetWebMailBody += WebMailProcessor.FilePathToCid;

                Navigator.EntitySettings <EmailMessageEntity>().MappingMain.AsEntityMapping()
                .RemoveProperty(a => a.Body)
                .SetProperty(a => a.Body, ctx =>
                {
                    if (!ctx.HasInput)
                    {
                        return(ctx.None());
                    }

                    var email = ((EmailMessageEntity)ctx.Parent.UntypedValue);

                    return(SetWebMailBody(ctx.Input, new WebMailOptions
                    {
                        Attachments = email.Attachments,
                        UntrustedImage = null,
                        Url = RouteHelper.New(),
                    }));
                });

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("AsyncEmailPanel",
                                                                         () => AsyncEmailSenderPermission.ViewAsyncEmailSenderPanel.IsAuthorized(),
                                                                         uh => uh.Action((AsyncEmailSenderController pc) => pc.View())));
            }
        }
Exemple #23
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());
                });
            }
        }
Exemple #24
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());
                });
            }
        }
Exemple #25
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")
                    });
                };
            }
Exemple #26
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <AddressEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Address")
                    },

                    new EntitySettings <TerritoryEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Territory")
                    },
                    new EntitySettings <RegionEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Region")
                    },
                    new EntitySettings <EmployeeEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Employee")
                    },

                    new EntitySettings <SupplierEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Supplier")
                    },
                    new EntitySettings <ProductEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Product")
                    },
                    new EntitySettings <CategoryEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Category")
                    },

                    new EntitySettings <PersonEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Person")
                    },
                    new EntitySettings <CompanyEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Company")
                    },

                    new EntitySettings <OrderEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Order")
                    },
                    new EmbeddedEntitySettings <OrderDetailsEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("OrderDetails")
                    },
                    new EntitySettings <ShipperEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Shipper")
                    },

                    new EmbeddedEntitySettings <OrderFilterModel>(),

                    new EntitySettings <ApplicationConfigurationEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("ApplicationConfiguration")
                    },
                });

                Constructor.Register(ctx => new ApplicationConfigurationEntity
                {
                    Sms   = new SMSConfigurationEntity(),
                    Email = new EmailConfigurationEntity()
                });

                QuerySettings.RegisterPropertyFormat((CategoryEntity e) => e.Picture,
                                                     new CellFormatter((html, obj) => obj == null ? null :
                                                                       new HtmlTag("img")
                                                                       .Attr("src", Base64Data((EmbeddedFileEntity)obj))
                                                                       .Attr("alt", obj.ToString())
                                                                       .Attr("style", "width:48px").ToHtmlSelf())
                {
                    TextAlign = "center"
                });                                                                         // Category

                QuerySettings.RegisterPropertyFormat((EmployeeEntity e) => e.Photo,
                                                     new CellFormatter((html, obj) => obj == null ? null :
                                                                       new HtmlTag("img")
                                                                       .Attr("src", RouteHelper.New().Action((FileController c) => c.Download(new RuntimeInfo((Lite <FileEntity>)obj).ToString())))
                                                                       .Attr("alt", obj.ToString())
                                                                       .Attr("style", "width:48px").ToHtmlSelf())
                {
                    TextAlign = "center"
                });                                                                         //Emmployee


                Finder.AddQuerySetting(new QuerySettings(OrderQuery.OrderSimple)
                {
                    SimpleFilterBuilder = (html, ctx, querySettings, findOptions) => new SimpleFilterBuilder(
                        html.Partial(SouthwindClient.ViewPrefix.FormatWith("OrderFilter"), new TypeContext <OrderFilterModel>(new OrderFilterModel(), ctx.Prefix)),
                        html.UrlHelper().Action((HomeController s) => s.OrderFilterFilters()))
                });

                Constructor.Register(ctx => new EmployeeEntity {
                    Address = new AddressEntity()
                });
                Constructor.Register(ctx => new PersonEntity {
                    Address = new AddressEntity()
                });
                Constructor.Register(ctx => new CompanyEntity {
                    Address = new AddressEntity()
                });
                Constructor.Register(ctx => new SupplierEntity {
                    Address = new AddressEntity()
                });

                OperationClient.AddSettings(new List <OperationSettings>()
                {
                    new ConstructorOperationSettings <OrderEntity>(OrderOperation.Create)
                    {
                        ClientConstructor = ctx => OrderModule["createOrder"](ClientConstructorManager.ExtraJsonParams,
                                                                              new FindOptions(typeof(CustomerEntity))
                        {
                            SearchOnLoad = true
                        }.ToJS(ctx.ClientConstructorContext.Prefix, "cust")),

                        Constructor = ctx =>
                        {
                            var cust = ctx.ConstructorContext.Controller.TryParseLite <CustomerEntity>("customer");

                            return(OperationLogic.Construct(OrderOperation.Create, cust));
                        }
                    },

                    new ContextualOperationSettings <ProductEntity>(OrderOperation.CreateOrderFromProducts)
                    {
                        Click = ctx => OrderModule["createOrderFromProducts"](ctx.Options(),
                                                                              new FindOptions(typeof(CustomerEntity))
                        {
                            SearchOnLoad = true
                        }.ToJS(ctx.Prefix, "cust"),
                                                                              ctx.Url.Action((HomeController c) => c.CreateOrderFromProducts()),
                                                                              JsFunction.Event)
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.SaveNew)
                    {
                        IsVisible = ctx => ctx.Entity.IsNew
                    },
                    new EntityOperationSettings <OrderEntity>(OrderOperation.Save)
                    {
                        IsVisible = ctx => !ctx.Entity.IsNew
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Cancel)
                    {
                        ConfirmMessage = ctx => ((OrderEntity)ctx.Entity).State == OrderState.Shipped ? OrderMessage.CancelShippedOrder0.NiceToString(ctx.Entity) : null
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Ship)
                    {
                        Click = ctx => OrderModule["shipOrder"](ctx.Options(),
                                                                ctx.Url.Action((HomeController c) => c.ShipOrder()),
                                                                GetValueLineOptions(ctx.Prefix),
                                                                false),

                        Contextual =
                        {
                            Click = ctx => OrderModule["shipOrder"](ctx.Options(),
                                                                    ctx.Url.Action((HomeController c) => c.ShipOrder()),
                                                                    GetValueLineOptions(ctx.Prefix),
                                                                    true),
                        }
                    },
                });

                RegisterQuickLinks();
            }
        }
Exemple #27
0
        public static void Start(bool file, bool embeddedFile, bool filePath, bool embeddedFilePath)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(FilesClient));

                UrlsRepository.DefaultSFUrls.AddRange(new Dictionary <string, Func <UrlHelper, string> >
                {
                    { "uploadFile", url => url.Action <FileController>(fc => fc.Upload()) },
                    { "uploadDroppedFile", url => url.Action <FileController>(fc => fc.UploadDropped()) },
                });

                if (file)
                {
                    RegisterFileConstructor <FileEntity>(data =>
                    {
                        return(new FileEntity {
                            FileName = data.FileName, BinaryFile = data.Content
                        }.Save());
                    });

                    RegisterDownloadUrlConstructor <FileEntity>(fp =>
                    {
                        return(RouteHelper.New().Action((FileController fc) => fc.Download(new RuntimeInfo(fp).ToString())));
                    });

                    RegisterFileDownloadResult <FileEntity>(ri =>
                    {
                        FileEntity f = (FileEntity)ri.ToLite().Retrieve();

                        return(new StaticContentResult(f.BinaryFile, f.FileName));
                    });


                    var es = new EntitySettings <FileEntity>();
                    Navigator.AddSetting(es);

                    var baseMapping = (Mapping <FileEntity>)es.MappingLine.AsEntityMapping().RemoveProperty(fp => fp.BinaryFile);

                    es.MappingLine = ctx =>
                    {
                        RuntimeInfo runtimeInfo = ctx.GetRuntimeInfo();
                        if (runtimeInfo == null)
                        {
                            return(null);
                        }
                        else
                        {
                            if (runtimeInfo.IsNew)
                            {
                                HttpPostedFileBase hpf = GetHttpRequestFile(ctx);

                                if (hpf != null)
                                {
                                    return(new FileEntity
                                    {
                                        FileName = Path.GetFileName(hpf.FileName),
                                        BinaryFile = hpf.InputStream.ReadAllBytes()
                                    });
                                }
                                else
                                {
                                    throw new InvalidOperationException("Impossible to create new FileEntity {0}".FormatWith(ctx.Prefix));
                                }
                            }
                            else
                            {
                                return(baseMapping(ctx));
                            }
                        }
                    };

                    FileLogic.DownloadFileUrl = DownloadFileUrl;

                    var lm = new LiteMapping <FileEntity>();
                    lm.EntityHasChanges = ctx => ctx.GetRuntimeInfo().IsNew;
                    Mapping.RegisterValue <Lite <FileEntity> >(lm.GetValue);
                }

                if (embeddedFile)
                {
                    RegisterFileConstructor <FileEmbedded>(data =>
                    {
                        return(new FileEmbedded {
                            FileName = data.FileName, BinaryFile = data.Content
                        });
                    });

                    var es = new EmbeddedEntitySettings <FileEmbedded>();
                    Navigator.AddSetting(es);

                    var baseMapping = (Mapping <FileEmbedded>)es.MappingDefault.AsEntityMapping().RemoveProperty(fp => fp.BinaryFile);

                    es.MappingDefault = ctx =>
                    {
                        RuntimeInfo runtimeInfo = ctx.GetRuntimeInfo();
                        if (runtimeInfo == null)
                        {
                            return(null);
                        }
                        else
                        {
                            HttpPostedFileBase hpf = GetHttpRequestFile(ctx);

                            if (hpf != null && hpf.ContentLength != 0)
                            {
                                return(new FileEmbedded()
                                {
                                    FileName = Path.GetFileName(hpf.FileName),
                                    BinaryFile = hpf.InputStream.ReadAllBytes()
                                });
                            }
                            else if (ctx.Inputs.ContainsKey(EntityBaseKeys.EntityState))
                            {
                                return((FileEmbedded)Navigator.Manager.DeserializeEntity(ctx.Inputs[EntityBaseKeys.EntityState]));
                            }
                            else
                            {
                                return(baseMapping(ctx));
                            }
                        }
                    };
                }

                if (filePath)
                {
                    RegisterFileConstructor <FilePathEntity>(data =>
                    {
                        if (!data.FileType.HasText())
                        {
                            throw new InvalidOperationException("Couldn't create FilePath with unknown FileType for file '{0}'".FormatWith(data.FileName));
                        }

                        return(new FilePathEntity(SymbolLogic <FileTypeSymbol> .ToSymbol(data.FileType))
                        {
                            FileName = data.FileName,
                            BinaryFile = data.Content,
                            CalculatedDirectory = data.CalculatedDirectory
                        }.Save());
                    });

                    RegisterDownloadUrlConstructor <FilePathEntity>(fp =>
                    {
                        return(RouteHelper.New().Action((FileController fc) => fc.Download(new RuntimeInfo(fp).ToString())));
                    });

                    RegisterFileDownloadResult <FilePathEntity>(ri =>
                    {
                        FilePathEntity fp = (FilePathEntity)ri.ToLite().Retrieve();

                        return(new FilePathResult(fp.FullPhysicalPath(), MimeMapping.GetMimeMapping(fp.FullPhysicalPath()))
                        {
                            FileDownloadName = fp.FileName
                        });
                    });

                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <FilePathEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("FilePath")
                        },
                    });

                    var es = Navigator.EntitySettings <FilePathEntity>();

                    var baseMapping = (Mapping <FilePathEntity>)es.MappingLine.AsEntityMapping().RemoveProperty(fp => fp.BinaryFile);

                    es.MappingLine = ctx =>
                    {
                        RuntimeInfo runtimeInfo = ctx.GetRuntimeInfo();
                        if (runtimeInfo == null)
                        {
                            return(null);
                        }
                        else
                        {
                            if (runtimeInfo.IsNew)
                            {
                                HttpPostedFileBase hpf = GetHttpRequestFile(ctx);
                                if (hpf != null)
                                {
                                    string fileType = ctx.Inputs[FileLineKeys.FileType];
                                    return(new FilePathEntity(SymbolLogic <FileTypeSymbol> .ToSymbol(fileType))
                                    {
                                        FileName = Path.GetFileName(hpf.FileName),
                                        BinaryFile = hpf.InputStream.ReadAllBytes(),
                                    });
                                }
                                else
                                {
                                    throw new InvalidOperationException("Impossible to create new FilePath {0}".FormatWith(ctx.Prefix));
                                }
                            }
                            else
                            {
                                return(baseMapping(ctx));
                            }
                        }
                    };

                    es.MappingMain = es.MappingLine;

                    var lm = new LiteMapping <FilePathEntity>();
                    lm.EntityHasChanges = ctx => ctx.GetRuntimeInfo().IsNew;
                    Mapping.RegisterValue <Lite <FilePathEntity> >(lm.GetValue);
                }

                if (embeddedFilePath)
                {
                    RegisterFileConstructor <FilePathEmbedded>(data =>
                    {
                        if (!data.FileType.HasText())
                        {
                            throw new InvalidOperationException("Couldn't create FilePath with unknown FileType for file '{0}'".FormatWith(data.FileName));
                        }

                        return(new FilePathEmbedded(SymbolLogic <FileTypeSymbol> .ToSymbol(data.FileType))
                        {
                            FileName = data.FileName,
                            BinaryFile = data.Content,
                            CalculatedDirectory = data.CalculatedDirectory
                        }.SaveFile());
                    });

                    RegisterDownloadUrlConstructor <FilePathEmbedded>(fp =>
                    {
                        return(RouteHelper.New().Action((FileController fc) => fc.DownloadEmbedded(fp.FileType.ToLite(), fp.Suffix, fp.FileName)));
                    });

                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EmbeddedEntitySettings <FilePathEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("EmbeddedFilePath")
                        },
                    });

                    var es = Navigator.EmbeddedEntitySettings <FilePathEmbedded>();

                    var baseMapping = (Mapping <FilePathEmbedded>)es.MappingDefault.AsEntityMapping().RemoveProperty(fp => fp.BinaryFile);

                    es.MappingDefault = ctx =>
                    {
                        RuntimeInfo runtimeInfo = ctx.GetRuntimeInfo();
                        if (runtimeInfo == null)
                        {
                            return(null);
                        }
                        else
                        {
                            HttpPostedFileBase hpf = GetHttpRequestFile(ctx);
                            if (hpf != null)
                            {
                                string fileType = ctx.Inputs[FileLineKeys.FileType];
                                return(new FilePathEmbedded(SymbolLogic <FileTypeSymbol> .ToSymbol(fileType))
                                {
                                    FileName = Path.GetFileName(hpf.FileName),
                                    BinaryFile = hpf.InputStream.ReadAllBytes(),
                                });
                            }
                            else if (ctx.Inputs.ContainsKey(EntityBaseKeys.EntityState))
                            {
                                return((FilePathEmbedded)Navigator.Manager.DeserializeEntity(ctx.Inputs[EntityBaseKeys.EntityState]));
                            }

                            else
                            {
                                return(baseMapping(ctx));
                            }
                        }
                    };
                }



                if (filePath || embeddedFilePath)
                {
                    Navigator.AddSetting(new EntitySettings <FileTypeSymbol>());
                }

                var dqm = DynamicQueryManager.Current;

                QuerySettings.FormatRules.Add(new FormatterRule("WebImage",
                                                                col => col.Type == typeof(WebImage),
                                                                col => new CellFormatter((help, obj) =>
                                                                                         (obj == null || ((WebImage)obj)?.FullWebPath.HasText() == false) ? null :
                                                                                         new HtmlTag("img")
                                                                                         .Attr("src", RouteHelper.New().Content(((WebImage)obj).FullWebPath))
                                                                                         .Attr("alt", typeof(WebImage).NiceName())
                                                                                         .Attr("style", "width:80px").ToHtmlSelf())
                {
                    TextAlign = "center"
                }
                                                                ));

                QuerySettings.FormatRules.Add(new FormatterRule("WebDownload",
                                                                col => col.Type == typeof(WebDownload),
                                                                col => new CellFormatter((help, obj) => ((WebDownload)obj)?.FullWebPath.HasText() == false ? null :
                                                                                         new MvcHtmlString("<a href='{0}'>{1}</a>".FormatWith(RouteHelper.New().Content(((WebDownload)obj).FullWebPath), ((WebDownload)obj).FileName ?? typeof(WebDownload).NiceName())))
                {
                    TextAlign = "center"
                }
                                                                ));
            }
        }
Exemple #28
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <EmployeeEntity>()
                    {
                        View = e => new Employee()
                    },
                    new EntitySettings <TerritoryEntity>()
                    {
                        View = e => new Territory()
                    },
                    new EntitySettings <RegionEntity>()
                    {
                        View = e => new Region()
                    },

                    new EntitySettings <ProductEntity>()
                    {
                        View = e => new Product()
                    },
                    new EntitySettings <CategoryEntity>()
                    {
                        View = e => new Category(), IsViewable = true
                    },
                    new EntitySettings <SupplierEntity>()
                    {
                        View = e => new Supplier()
                    },

                    new EntitySettings <CompanyEntity>()
                    {
                        View = e => new Company()
                    },
                    new EntitySettings <PersonEntity>()
                    {
                        View = e => new Person()
                    },

                    new EntitySettings <OrderEntity>()
                    {
                        View = e => new Order()
                    },
                });


                QuerySettings.RegisterPropertyFormat((EmployeeEntity e) => e.Photo, b =>
                {
                    b.Converter = SouthwindConverters.ImageConverter;
                    return(Fluent.GetDataTemplate(() => new Image {
                        MaxHeight = 32.0, Stretch = Stretch.Uniform
                    }
                                                  .Bind(Image.SourceProperty, b)
                                                  .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear)));
                }); //Photo

                QuerySettings.RegisterPropertyFormat((CategoryEntity e) => e.Picture, b =>
                {
                    b.Converter = SouthwindConverters.EmbeddedImageConverter;
                    return(Fluent.GetDataTemplate(() => new Image {
                        MaxHeight = 32.0, Stretch = Stretch.Uniform
                    }
                                                  .Bind(Image.SourceProperty, b)
                                                  .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear)));
                }); //Picture

                Constructor.Register(ctx => new EmployeeEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new PersonEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new CompanyEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new SupplierEntity {
                    Address = new AddressEmbedded()
                });

                OperationClient.AddSettings(new List <OperationSettings>()
                {
                    new ConstructorOperationSettings <OrderEntity>(OrderOperation.Create)
                    {
                        Constructor = ctx =>
                        {
                            var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue

                            return(OperationServer.Construct(OrderOperation.Create, cust));
                        },
                    },


                    new ContextualOperationSettings <ProductEntity>(OrderOperation.CreateOrderFromProducts)
                    {
                        Click = ctx =>
                        {
                            var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue

                            var result = OperationServer.ConstructFromMany(ctx.Entities, OrderOperation.CreateOrderFromProducts, cust);

                            Navigator.Navigate(result);
                        },
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.SaveNew)
                    {
                        IsVisible = ctx => ctx.Entity.IsNew
                    },
                    new EntityOperationSettings <OrderEntity>(OrderOperation.Save)
                    {
                        IsVisible = ctx => !ctx.Entity.IsNew
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Cancel)
                    {
                        ConfirmMessage = ctx => ((OrderEntity)ctx.Entity).State == OrderState.Shipped ? OrderMessage.CancelShippedOrder0.NiceToString(ctx.Entity) : null
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Ship)
                    {
                        Click = ctx =>
                        {
                            DateTime shipDate = DateTime.Now;
                            if (!ValueLineBox.Show(ref shipDate,
                                                   labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
                                                   owner: Window.GetWindow(ctx.EntityControl)))
                            {
                                return(null);
                            }

                            try
                            {
                                return(ctx.Entity.Execute(OrderOperation.Ship, shipDate));
                            }
                            catch (IntegrityCheckException e)
                            {
                                ctx.Entity.SetGraphErrors(e);
                                throw e;
                            }
                        },

                        Contextual =
                        {
                            Click                 = ctx =>
                            {
                                DateTime shipDate = DateTime.Now;
                                if (!ValueLineBox.Show(ref shipDate,
                                                       labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
                                                       owner: Window.GetWindow(ctx.SearchControl)))
                                {
                                    return;
                                }

                                ctx.Entities.SingleEx().ExecuteLite(OrderOperation.Ship, shipDate);
                            }
                        }
                    },
                });

                //NotDefined
            }
        }
Exemple #29
0
        /// <param name="copyTranslationsToRootFolder">avoids Web Application restart when translations change</param>
        public static void Start(ITranslator translator, bool translatorUser, bool translationReplacement, bool instanceTranslator, bool copyNewTranslationsToRootFolder = true)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Translator = translator;

                Navigator.RegisterArea(typeof(TranslationClient));

                if (translatorUser)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <TranslatorUserEntity> {
                            PartialViewName = t => ViewPrefix.FormatWith("TranslatorUser")
                        },
                        new EmbeddedEntitySettings <TranslatorUserCultureEmbedded> {
                            PartialViewName = t => ViewPrefix.FormatWith("TranslatorUserCulture")
                        },
                    });
                }

                if (translationReplacement)
                {
                    FileRepositoryManager.Register(new LocalizedJavaScriptRepository(typeof(TranslationJavascriptMessage), "translation"));

                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <TranslationReplacementEntity> {
                            PartialViewName = t => ViewPrefix.FormatWith("TranslationReplacement")
                        },
                    });
                }

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("TranslateCode",
                                                                         () => TranslationPermission.TranslateCode.IsAuthorized(),
                                                                         uh => uh.Action((TranslationController tc) => tc.Index(null))));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("LocalizableTypeUsedNotLocalized",
                                                                         () => TranslationPermission.TranslateCode.IsAuthorized(),
                                                                         uh => uh.Action((TranslationController tc) => tc.LocalizableTypeUsedNotLocalized(null))));

                if (instanceTranslator)
                {
                    SpecialOmniboxProvider.Register(new SpecialOmniboxAction("TranslateInstances",
                                                                             () => TranslationPermission.TranslateInstances.IsAuthorized(),
                                                                             uh => uh.Action((TranslatedInstanceController tic) => tic.Index())));
                }


                if (copyNewTranslationsToRootFolder)
                {
                    string path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(new Uri(typeof(DescriptionManager).Assembly.CodeBase).LocalPath)), "Translations");

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    var existingFiles = Directory.GetFiles(path).ToHashSet();

                    foreach (string fromFile in Directory.GetFiles(DescriptionManager.TranslationDirectory))
                    {
                        string toFile = Path.Combine(path, Path.GetFileName(fromFile));

                        if (!existingFiles.Contains(toFile) || File.GetLastWriteTime(toFile) < File.GetLastWriteTime(fromFile))
                        {
                            File.Copy(fromFile, toFile, overwrite: true);
                        }
                    }

                    DescriptionManager.TranslationDirectory = path;
                }
            }
        }
Exemple #30
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 };
                };
            }
        }