Example #1
0
        public static Type ToType(this SystemEmailEntity systemEmail)
        {
            if (systemEmail == null)
            {
                return(null);
            }

            return(systemEmailToType.Value.GetOrThrow(systemEmail, "The system email {0} was not registered"));
        }
Example #2
0
        internal static EmailTemplateEntity CreateDefaultTemplate(SystemEmailEntity systemEmail)
        {
            SystemEmailInfo info = systemEmails.GetOrThrow(systemEmailToType.Value.GetOrThrow(systemEmail));

            EmailTemplateEntity template = info.DefaultTemplateConstructor();

            if (template.MasterTemplate != null)
            {
                template.MasterTemplate = EmailMasterTemplateLogic.GetDefaultMasterTemplate();
            }

            if (template.Name == null)
            {
                template.Name = systemEmail.FullClassName;
            }

            template.SystemEmail = systemEmail;
            template.Query       = QueryLogic.GetQueryEntity(info.QueryName);

            template.ParseData(DynamicQueryManager.Current.QueryDescription(info.QueryName));

            return(template);
        }
Example #3
0
        private static EmailTemplateEntity GetDefaultTemplate(SystemEmailEntity systemEmailEntity, Entity entity)
        {
            var isAllowed = Schema.Current.GetInMemoryFilter <EmailTemplateEntity>(userInterface: false);

            var templates = SystemEmailsToEmailTemplates.Value.TryGetC(systemEmailEntity.ToLite()).EmptyIfNull();

            if (templates.IsNullOrEmpty())
            {
                using (ExecutionMode.Global())
                    using (OperationLogic.AllowSave <EmailTemplateEntity>())
                        using (Transaction tr = Transaction.ForceNew())
                        {
                            var template = CreateDefaultTemplate(systemEmailEntity);

                            template.Save();

                            return(tr.Commit(template));
                        }
            }

            templates = templates.Where(isAllowed);
            return(templates.Where(t => t.IsApplicable(entity)).SingleEx(() => "Active EmailTemplates for SystemEmail {0}".FormatWith(systemEmailEntity)));
        }
Example #4
0
        public string GetConstructorType(SystemEmailEntity systemEmailTemplate)
        {
            var type = SystemEmailLogic.GetEntityType(systemEmailTemplate.ToType());

            return(ReflectionServer.GetTypeName(type));
        }
Example #5
0
 public static ISystemEmail CreateSystemEmail(SystemEmailEntity systemEmail, ModifiableEntity model)
 {
     return((ISystemEmail)SystemEmailLogic.GetEntityConstructor(systemEmail.ToType()).Invoke(new[] { model }));
 }
Example #6
0
        internal static bool HasDefaultTemplateConstructor(SystemEmailEntity systemEmailTemplate)
        {
            SystemEmailInfo info = systemEmails.GetOrThrow(systemEmailTemplate.ToType());

            return(info.DefaultTemplateConstructor != null);
        }
Example #7
0
 public static bool RequiresExtraParameters(SystemEmailEntity systemEmailEntity)
 {
     return(GetEntityConstructor(systemEmailToType.Value.GetOrThrow(systemEmailEntity)) == null);
 }