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);
                    }
                });
Exemple #2
0
        public static void Start(IApplicationBuilder app)
        {
            TypeHelpServer.Start(app);
            SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod());

            TemplatingServer.Start(app);

            CustomizeFiltersModel();

            EntityPackTS.AddExtension += ep =>
            {
                if (ep.entity.IsNew || !WordTemplatePermission.GenerateReport.IsAuthorized())
                {
                    return;
                }

                var wordTemplates = WordTemplateLogic.TemplatesByEntityType.Value.TryGetC(ep.entity.GetType());
                if (wordTemplates != null)
                {
                    var applicable = wordTemplates.Where(a => a.IsApplicable(ep.entity));
                    if (applicable.HasItems())
                    {
                        ep.extension.Add("wordTemplates", applicable.Select(a => a.ToLite()).ToList());
                    }
                }
            };

            QueryDescriptionTS.AddExtension += qd =>
            {
                object type = QueryLogic.ToQueryName(qd.queryKey);
                if (Schema.Current.IsAllowed(typeof(WordTemplateEntity), true) == null)
                {
                    var templates = WordTemplateLogic.GetApplicableWordTemplates(type, null, WordTemplateVisibleOn.Query);

                    if (templates.HasItems())
                    {
                        qd.Extension.Add("wordTemplates", templates);
                    }
                }
            };

            EntityJsonConverter.AfterDeserilization.Register((WordTemplateEntity uq) =>
            {
                if (uq.Query != null)
                {
                    var qd = QueryLogic.Queries.QueryDescription(uq.Query.ToQueryName());
                    uq.ParseData(qd);
                }
            });
        }