public static void Start(IApplicationBuilder app) { TypeHelpServer.Start(app); SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod()); ReflectionServer.OverrideIsNamespaceAllowed.Add(typeof(ExchangeVersion).Namespace !, () => TypeAuthLogic.GetAllowed(typeof(EmailSenderConfigurationEntity)).MaxUI() > TypeAllowedBasic.None); ReflectionServer.OverrideIsNamespaceAllowed.Add(typeof(SmtpDeliveryMethod).Namespace !, () => TypeAuthLogic.GetAllowed(typeof(EmailSenderConfigurationEntity)).MaxUI() > TypeAllowedBasic.None); TemplatingServer.Start(app); EntityJsonConverter.AfterDeserilization.Register((EmailTemplateEntity et) => { if (et.Query != null) { var qd = QueryLogic.Queries.QueryDescription(et.Query.ToQueryName()); et.ParseData(qd); } }); QueryDescriptionTS.AddExtension += qd => { object type = QueryLogic.ToQueryName(qd.queryKey); if (Schema.Current.IsAllowed(typeof(EmailTemplateEntity), true) == null) { var templates = EmailTemplateLogic.GetApplicableEmailTemplates(type, null, EmailTemplateVisibleOn.Query); if (templates.HasItems()) { qd.Extension.Add("emailTemplates", templates); } } }; if (Schema.Current.Tables.ContainsKey(typeof(EmailSenderConfigurationEntity))) { var piPassword = ReflectionTools.GetPropertyInfo((SmtpNetworkDeliveryEmbedded e) => e.Password); var pcs = PropertyConverter.GetPropertyConverters(typeof(SmtpNetworkDeliveryEmbedded)); pcs.GetOrThrow("password").CustomWriteJsonProperty = ctx => { }; pcs.Add("newPassword", new PropertyConverter { AvoidValidate = true, CustomWriteJsonProperty = ctx => { }, CustomReadJsonProperty = ctx => { EntityJsonConverter.AssertCanWrite(ctx.ParentPropertyRoute.Add(piPassword)); var password = (string)ctx.JsonReader.Value !; ((SmtpNetworkDeliveryEmbedded)ctx.Entity).Password = EmailSenderConfigurationLogic.EncryptPassword(password); } });
public static void Start( SchemaBuilder sb, Func <EmailConfigurationEmbedded> getConfiguration, Func <EmailTemplateEntity?, Lite <Entity>?, EmailMessageEntity?, EmailSenderConfigurationEntity> getEmailSenderConfiguration, IFileTypeAlgorithm?attachment = null) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { FilePathEmbeddedLogic.AssertStarted(sb); CultureInfoLogic.AssertStarted(sb); EmailLogic.getConfiguration = getConfiguration; EmailTemplateLogic.Start(sb, getEmailSenderConfiguration); EmailSenderConfigurationLogic.Start(sb); if (attachment != null) { FileTypeLogic.Register(EmailFileType.Attachment, attachment); } Schema.Current.WhenIncluded <ProcessEntity>(() => EmailPackageLogic.Start(sb)); sb.Include <EmailMessageEntity>() .WithQuery(() => e => new { Entity = e, e.Id, e.State, e.Subject, e.Template, e.Sent, e.Target, e.Package, e.Exception, }); PermissionAuthLogic.RegisterPermissions(AsyncEmailSenderPermission.ViewAsyncEmailSenderPanel); SenderManager = new EmailSenderManager(getEmailSenderConfiguration); EmailGraph.Register(); QueryLogic.Expressions.Register((EmailPackageEntity a) => a.EmailMessages(), () => typeof(EmailMessageEntity).NicePluralName()); ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; ExceptionLogic.DeleteLogs += ExceptionLogic_DeletePackages; } }