Ejemplo n.º 1
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;
        }
    }