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 } }); } }
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())) }, }); } }
public static void Start(bool package, bool packageOperation) { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { Navigator.AddSetting(new EntitySettings <ProcessAlgorithmSymbol> { View = e => new ProcessAlgorithm(), Icon = Image("processAlgorithm.png") }); Navigator.AddSetting(new EntitySettings <ProcessEntity> { View = e => new ProcessUI(), Icon = Image("process.png") }); Server.SetSymbolIds <ProcessAlgorithmSymbol>(); OperationClient.AddSettings(new List <OperationSettings>() { new EntityOperationSettings <ProcessEntity>(ProcessOperation.Plan) { Icon = Image("plan.png"), Click = ProcessOperation_Plan }, new EntityOperationSettings <ProcessEntity>(ProcessOperation.Cancel) { Icon = Image("stop.png") }, new EntityOperationSettings <ProcessEntity>(ProcessOperation.Execute) { Icon = Image("play.png") }, new EntityOperationSettings <ProcessEntity>(ProcessOperation.Suspend) { Icon = Image("pause.png") }, }); if (packageOperation || package) { Navigator.AddSetting(new EntitySettings <PackageLineEntity> { View = e => new PackageLine(), Icon = Image("packageLine.png") }); } if (package) { Navigator.AddSetting(new EntitySettings <PackageEntity> { View = e => new Package(), Icon = Image("package.png") }); } if (packageOperation) { Navigator.AddSetting(new EntitySettings <PackageOperationEntity> { View = e => new PackageOperation(), Icon = Image("package.png") }); SearchControl.GetContextMenuItems += SearchControl_GetContextMenuItems; } } }
public static void Start(params Type[] types) { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { if (types == null) { throw new ArgumentNullException("types"); } WidgetPanel.GetWidgets += (obj, mainControl) => { if (obj is Entity && types.Contains(obj.GetType()) && !((Entity)obj).IsNew && Finder.IsFindable(typeof(NoteEntity))) { return(new NotesWidget()); } return(null); }; Server.SetSemiSymbolIds <NoteTypeEntity>(); OperationClient.AddSettings(new List <OperationSettings> { new EntityOperationSettings <Entity>(NoteOperation.CreateNoteFromEntity) { IsVisible = _ => false } }); Navigator.AddSetting(new EntitySettings <NoteTypeEntity> { View = e => new NoteType() }); Navigator.AddSetting(new EntitySettings <NoteEntity> { View = e => new Note(), IsCreable = EntityWhen.Never, Icon = ExtensionsImageLoader.GetImageSortName("note2.png") }); } }
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 } }); } }
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; } }
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()))); } }
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()); }); } }
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 } }
public static void Start(bool types, bool property, bool queries, bool permissions, bool operations, bool defaultPasswordExpiresLogic) { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { Server.Connecting += UpdateCache; if (types) { TypeAuthClient.Start(); } if (property) { PropertyAuthClient.Start(); } if (queries) { QueryAuthClient.Start(); } if (permissions) { PermissionAuthClient.Start(); } if (operations) { OperationAuthClient.Start(); } UpdateCache(); Navigator.AddSetting(new EntitySettings <UserEntity> { View = e => new User(), Icon = ImageLoader.GetImageSortName("user.png") }); Navigator.AddSetting(new EntitySettings <RoleEntity> { View = e => new Role(), Icon = ImageLoader.GetImageSortName("role.png") }); if (defaultPasswordExpiresLogic) { Navigator.AddSetting(new EntitySettings <PasswordExpiresIntervalEntity> { View = e => new PasswordExpiresInterval() }); } OperationClient.AddSettings(new List <OperationSettings>() { new EntityOperationSettings <UserEntity>(UserOperation.SetPassword) { IsVisible = e => false }, new EntityOperationSettings <UserEntity>(UserOperation.SaveNew) { IsVisible = e => e.Entity.IsNew }, new EntityOperationSettings <UserEntity>(UserOperation.Save) { IsVisible = e => !e.Entity.IsNew } }); SpecialOmniboxProvider.Register(new SpecialOmniboxAction("UpdateAuthCache", () => true, win => { UpdateCache(); MessageBox.Show(AuthMessage.AuthorizationCacheSuccessfullyUpdated.NiceToString()); })); SpecialOmniboxProvider.Register(new SpecialOmniboxAction("DownloadAuthRules", () => BasicPermission.AdminRules.IsAuthorized(), win => { SaveFileDialog sfc = new SaveFileDialog() { FileName = "AuthRules.xml" }; if (sfc.ShowDialog() == true) { var bytes = Server.Return((ILoginServer ls) => ls.DownloadAuthRules()); File.WriteAllBytes(sfc.FileName, bytes); } })); } }
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(); } }
public static void Start(bool types, bool property, bool queries, bool resetPassword, bool passwordExpiration, bool singleSignOnMessage) { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { ResetPasswordStarted = resetPassword; SingleSignOnMessage = singleSignOnMessage; Navigator.RegisterArea(typeof(AuthClient)); if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(UserEntity))) { Navigator.AddSetting(new EntitySettings <UserEntity>()); } if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(RoleEntity))) { Navigator.AddSetting(new EntitySettings <RoleEntity>()); } if (resetPassword) { Navigator.AddSetting(new EntitySettings <ResetPasswordRequestEntity>()); } if (passwordExpiration) { Navigator.AddSetting(new EntitySettings <PasswordExpiresIntervalEntity> { PartialViewName = _ => ViewPrefix.FormatWith("PasswordValidInterval") }); } Navigator.AddSetting(new ModelEntitySettings <SetPasswordModel> { PartialViewName = _ => ViewPrefix.FormatWith("SetPassword"), MappingDefault = new EntityMapping <SetPasswordModel>(false) .SetProperty(a => a.PasswordHash, ctx => UserMapping.GetNewPassword(ctx, UserMapping.NewPasswordKey, UserMapping.NewPasswordBisKey)) }); if (property) { Common.CommonTask += TaskAuthorizeProperties; Mapping.CanChange += Mapping_CanChange; } var manager = Navigator.Manager; if (types) { manager.IsCreable += manager_IsCreable; manager.IsReadOnly += manager_IsReadOnly; manager.IsViewable += manager_IsViewable; } if (queries) { Finder.Manager.IsFindable += q => QueryAuthLogic.GetQueryAllowed(q) != QueryAllowed.None; } AuthenticationRequiredAttribute.Authenticate = context => { if (UserEntity.Current == null) { string returnUrl = context.HttpContext.Request.SuggestedReturnUrl().PathAndQuery; //send them off to the login page string loginUrl = PublicLoginUrl(returnUrl); context.Result = context.Controller.RedirectHttpOrAjax(loginUrl); } }; Schema.Current.EntityEvents <UserEntity>().Saving += AuthClient_Saving; var defaultException = SignumExceptionHandlerAttribute.OnControllerException; SignumExceptionHandlerAttribute.OnControllerException = ctx => { if (ctx.Exception is UnauthorizedAccessException && (UserEntity.Current == null || UserEntity.Current.Is(AuthLogic.AnonymousUser))) { string returnUrl = ctx.HttpContext.Request.SuggestedReturnUrl().PathAndQuery; string loginUrl = PublicLoginUrl(returnUrl); DefaultOnControllerUnauthorizedAccessException(ctx, loginUrl); } else { defaultException(ctx); } }; OperationClient.AddSettings(new List <OperationSettings> { new EntityOperationSettings <UserEntity>(UserOperation.SetPassword) { Click = ctx => Module["setPassword"](ctx.Options(), ctx.Url.Action((AuthController c) => c.SetPasswordModel()), ctx.Url.Action((AuthController c) => c.SetPasswordOnOk())) }, new EntityOperationSettings <UserEntity>(UserOperation.SaveNew) { Click = ctx => Module["saveNew"](ctx.Options(), ctx.Url.Action((AuthController c) => c.SaveNewUser())) } }); } }