Beispiel #1
0
        public static void Start(
            SchemaBuilder sb,
            Func <EmailConfigurationEmbedded> getConfiguration,
            Func <EmailTemplateEntity?, Lite <Entity>?, SmtpConfigurationEntity> getSmtpConfiguration,
            Func <EmailMessageEntity, SmtpClient>?getSmtpClient = null,
            IFileTypeAlgorithm?attachment = null)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                if (getSmtpClient == null && getSmtpConfiguration != null)
                {
                    getSmtpClient = message => getSmtpConfiguration(message.Template?.Let(a => EmailTemplateLogic.EmailTemplatesLazy.Value.GetOrThrow(a)), message.Target).GenerateSmtpClient();
                }

                FilePathEmbeddedLogic.AssertStarted(sb);
                CultureInfoLogic.AssertStarted(sb);
                EmailLogic.getConfiguration = getConfiguration;
                EmailLogic.GetSmtpClient    = getSmtpClient ?? throw new ArgumentNullException(nameof(getSmtpClient));
                EmailTemplateLogic.Start(sb, getSmtpConfiguration);
                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();

                EmailGraph.Register();
            }
        }
Beispiel #2
0
        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;
            }
        }