Ejemplo n.º 1
0
        public static void Start(HttpConfiguration config)
        {
            SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod());

            ReflectionServer.RegisterLike(typeof(TemplateTokenMessage));

            EntityJsonConverter.AfterDeserilization.Register((EmailTemplateEntity et) =>
            {
                if (et.Query != null)
                {
                    var qd = DynamicQueryManager.Current.QueryDescription(et.Query.ToQueryName());
                    et.ParseData(qd);
                }
            });

            QueryDescriptionTS.AddExtension += qd =>
            {
                object type      = QueryLogic.ToQueryName(qd.queryKey);
                var    templates = EmailTemplateLogic.GetApplicableEmailTemplates(type, null, EmailTemplateVisibleOn.Query);

                if (templates.HasItems())
                {
                    qd.Extension.Add("emailTemplates", templates);
                }
            };
        }
Ejemplo n.º 2
0
        private static string GetTemplateString(string title, ref object titleNode, EmailTemplateLogic.GenerateAttachmentContext ctx)
        {
            var block = titleNode != null ? (EmailTemplateParser.BlockNode)titleNode :
                (EmailTemplateParser.BlockNode)(titleNode = EmailTemplateParser.Parse(title, ctx.QueryDescription, ctx.ModelType));

            return block.Print(new EmailTemplateParameters(ctx.Entity, ctx.Culture, ctx.ResultColumns, ctx.CurrentRows) { SystemEmail = ctx.SystemEmail });
        }
Ejemplo n.º 3
0
        public static void Start(IApplicationBuilder app)
        {
            TypeHelpServer.Start(app);
            SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod());

            ReflectionServer.RegisterLike(typeof(TemplateTokenMessage));

            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);
                    }
                }
            };
        }
Ejemplo n.º 4
0
        public List <Lite <EmailTemplateEntity> > GetEmailTemplates(string queryKey, EmailTemplateVisibleOn visibleOn, [Required, FromBody] GetEmailTemplatesRequest request)
        {
            object queryName = QueryLogic.ToQueryName(queryKey);

            var entity = request.lite?.RetrieveAndForget();

            return(EmailTemplateLogic.GetApplicableEmailTemplates(queryName, entity, visibleOn));
        }
Ejemplo n.º 5
0
        public List <Lite <EmailTemplateEntity> > GetWordTemplates(string queryKey, EmailTemplateVisibleOn visibleOn, Lite <Entity> lite)
        {
            object queryName = QueryLogic.ToQueryName(queryKey);

            var entity = lite?.RetrieveAndForget();

            return(EmailTemplateLogic.GetApplicableEmailTemplates(queryName, entity, visibleOn));
        }
Ejemplo n.º 6
0
        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);
                    }
                });
Ejemplo n.º 7
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;
        }
    }
Ejemplo n.º 8
0
        static string?ExcelAttachmentFileName_StaticPropertyValidation(ExcelAttachmentEntity excelAttachment, PropertyInfo pi)
        {
            var template = excelAttachment.TryGetParentEntity <EmailTemplateEntity>() !;

            if (template != null && excelAttachment.FileNameNode as TextTemplateParser.BlockNode == null)
            {
                try
                {
                    excelAttachment.FileNameNode = EmailTemplateLogic.ParseTemplate(template, excelAttachment.FileName, out string errorMessage);
                    return(errorMessage.DefaultToNull());
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }

            return(null);
        }
Ejemplo n.º 9
0
        static string WordAttachmentFileName_StaticPropertyValidation(WordAttachmentEntity WordAttachment, PropertyInfo pi)
        {
            var template = (EmailTemplateEntity)WordAttachment.GetParentEntity();

            if (template != null && WordAttachment.FileNameNode as EmailTemplateParser.BlockNode == null)
            {
                try
                {
                    WordAttachment.FileNameNode = EmailTemplateLogic.ParseTemplate(template, WordAttachment.FileName, out string errorMessage);
                    return(errorMessage.DefaultText(null));
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }

            return(null);
        }