/// <summary>
        /// Get complex setting setup
        /// </summary>
        /// <returns></returns>
        public override ComplexSettingSetup GetSetup()
        {
            var mappingsContent = DataInitializeHelper.GetResourceContent("ProtectedDocuments.DocumentTypeMappings.csv", DataSetupResourceType.SiteSetting);

            List <string> countryList = mappingsContent.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();

            var mappings = new List <DocumentClassMapping>();

            foreach (var item in countryList)
            {
                var parts = item.Split(',');
                if (parts.Count() < 2)
                {
                    continue;
                }
                var mapping = new DocumentClassMapping
                {
                    Extension = parts[0].Trim(),
                    ClassName = parts[1].Trim()
                };

                mappings.Add(mapping);
            }

            return(new ComplexSettingSetup
            {
                Name = SettingNames.DocumentTypeMapping,
                SettingType = "system",
                DefaultValue = new DocumentTypeMappingSetting
                {
                    Mappings = mappings
                }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize default languages
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                #region Add countries

                if (!context.Countries.Any())
                {
                    var countryData = DataInitializeHelper.GetResourceContent("Country.Countries.txt",
                                                                              DataSetupResourceType.Others);
                    List <string> countryList =
                        countryData.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    int i         = 0;
                    var countries = new List <Country>();
                    foreach (var item in countryList)
                    {
                        i = i + 1;
                        var country = new Country
                        {
                            Name        = item,
                            RecordOrder = i * 10
                        };

                        countries.Add(country);
                    }

                    var dbContext = new EzCMSEntities();
                    dbContext.Countries.AddIfNotExist(country => country.Name, countries.ToArray());
                    dbContext.SaveChanges();
                }

                #endregion

                #region Add Languages

                var languages = new[]
                {
                    new Language
                    {
                        Name        = "English",
                        Culture     = "United States",
                        Key         = "en-US",
                        IsDefault   = false,
                        RecordOrder = 20
                    }
                };
                context.Languages.AddIfNotExist(l => l.Name, languages);

                #endregion
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get complex setting setup
 /// </summary>
 /// <returns></returns>
 public override ComplexSettingSetup GetSetup()
 {
     return(new ComplexSettingSetup
     {
         Name = SettingNames.EditorSetting,
         SettingType = "system",
         DefaultValue = new EditorSetting
         {
             ScriptContent = DataInitializeHelper.GetResourceContent("EditorSetting.editor.js", DataSetupResourceType.SiteSetting),
             StyleContent = DataInitializeHelper.GetResourceContent("EditorSetting.editor.css", DataSetupResourceType.SiteSetting)
         }
     });
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Get complex setting setup
 /// </summary>
 /// <returns></returns>
 public override ComplexSettingSetup GetSetup()
 {
     return(new ComplexSettingSetup
     {
         Name = SettingNames.FormBuilderSetting,
         SettingType = "system",
         DefaultValue = new FormBuilderSetting
         {
             EmbeddedTemplate = DataInitializeHelper.GetResourceContent("FormBuilder.EmbeddedTemplate.html", DataSetupResourceType.SiteSetting),
             RenderScriptTemplate = DataInitializeHelper.GetResourceContent("FormBuilder.RenderScriptTemplate.js", DataSetupResourceType.SiteSetting),
             SubmitFormBodyTemplate = DataInitializeHelper.GetResourceContent("FormBuilder.SubmitFormBodyTemplate.cshtml", DataSetupResourceType.SiteSetting),
             SubmitFormSubject = "Form Email Notification"
         }
     });
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize default settings
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                var subscriptionTemplates = new[]
                {
                    new SubscriptionTemplate
                    {
                        Name   = SubscriptionEnums.SubscriptionModule.Page.GetEnumName(),
                        Module = SubscriptionEnums.SubscriptionModule.Page,
                        Body   = DataInitializeHelper.GetResourceContent("PageSubscribeNotification.cshtml",
                                                                         DataSetupResourceType.SubscriptionTemplate)
                    }
                };

                context.SubscriptionTemplates.AddIfNotExist(t => t.Name, subscriptionTemplates);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get complex setting setup
        /// </summary>
        /// <returns></returns>
        public override ComplexSettingSetup GetSetup()
        {
            var configurations = EnumUtilities.GetAllItems <LoginEnums.LoginTemplateConfiguration>();

            var templates = new List <TemplateConfiguration>();

            foreach (var configuration in configurations)
            {
                var templateConfiguration = new TemplateConfiguration
                {
                    LoginTemplateConfiguration = configuration,
                    Enable         = true,
                    EnableTemplate = false,
                    Template       = string.Empty
                };

                try
                {
                    templateConfiguration.Template =
                        DataInitializeHelper.GetResourceContent(
                            string.Format("LoginTemplateSetting_{0}.cshtml", configuration),
                            DataSetupResourceType.SiteSetting);
                }
                catch (Exception)
                {
                    //Do nothing
                }

                templates.Add(templateConfiguration);
            }

            return(new ComplexSettingSetup
            {
                Name = SettingNames.LoginTemplateSetting,
                SettingType = "system",
                DefaultValue = new LoginTemplateSetting
                {
                    Configurations = templates
                }
            });
        }
        /// <summary>
        /// Initialize default settings
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                var notificationTemplates = new[]
                {
                    new NotificationTemplate
                    {
                        Name    = "Default Page Notification Template",
                        Subject = "Page Notification",
                        Body    =
                            DataInitializeHelper.GetResourceContent("Default.PageNotification.cshtml",
                                                                    DataSetupResourceType.NotificationTemplate),
                        IsDefaultTemplate = true,
                        Module            = NotificationEnums.NotificationModule.Page
                    }
                };

                context.NotificationTemplates.AddIfNotExist(t => t.Name, notificationTemplates);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialize default settings
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                if (!context.FormTabs.Any())
                {
                    var now = DateTime.UtcNow;

                    #region Save Templates

                    var embeddedResources = DataInitializeHelper.GetAllResourcesInFolder("FormBuilder.Components",
                                                                                         DataSetupResourceType.Others);

                    foreach (var embeddedResource in embeddedResources)
                    {
                        var formComponentTemplate = new FormComponentTemplate
                        {
                            Name    = Path.GetFileNameWithoutExtension(embeddedResource.Name),
                            Content = embeddedResource.Content
                        };
                        context.FormComponentTemplates.AddEntities(formComponentTemplate);
                    }
                    context.SaveChanges();

                    #endregion

                    #region Save Tabs

                    var setup = DataInitializeHelper.GetResourceContent("FormBuilder.Tabs.json", DataSetupResourceType.Others);
                    var tabs  = SerializeUtilities.Deserialize <List <FormTabModel> >(setup);

                    var tabOrder = 0;
                    foreach (var item in tabs)
                    {
                        tabOrder += 10;
                        var tab = new FormTab
                        {
                            Name        = item.title,
                            RecordOrder = tabOrder,
                            Created     = now,
                            CreatedBy   = FrameworkConstants.DefaultMigrationAccount
                        };

                        var componentOrder = 0;
                        foreach (var data in item.data)
                        {
                            // Get templates for component
                            var formComponentTemplate = context.FormComponentTemplates.First(t => t.Name.Equals(data.template));

                            componentOrder += 10;
                            var component = new FormComponent
                            {
                                FormTab = tab,
                                FormComponentTemplate = formComponentTemplate,
                                Name        = data.title,
                                RecordOrder = componentOrder,
                                Created     = now,
                                CreatedBy   = FrameworkConstants.DefaultMigrationAccount
                            };

                            if (data.fields != null && data.fields.Keys.Any())
                            {
                                var fieldOrder = 0;
                                foreach (var field in data.fields)
                                {
                                    fieldOrder += 10;
                                    var formField = new FormComponentField
                                    {
                                        FormComponent = component,
                                        Name          = field.Key,
                                        Attributes    = SerializeUtilities.Serialize(field.Value),
                                        RecordOrder   = fieldOrder,
                                        Created       = now,
                                        CreatedBy     = FrameworkConstants.DefaultMigrationAccount
                                    };

                                    context.FormComponentFields.AddEntities(formField);
                                }
                            }
                            else
                            {
                                context.FormComponents.AddEntities(component);
                            }
                        }
                    }

                    #endregion

                    #region Save Default Form components

                    var componentsSetup       = DataInitializeHelper.GetResourceContent("FormBuilder.DefaultFormComponents.json", DataSetupResourceType.Others);
                    var defaultFormComponents = SerializeUtilities.Deserialize <List <FormData> >(componentsSetup);

                    var defaultComponentOrder = 0;
                    foreach (var data in defaultFormComponents)
                    {
                        defaultComponentOrder += 10;

                        // Get template for component
                        var formComponentTemplate = context.FormComponentTemplates.First(t => t.Name.Equals(data.template));

                        var component = new FormDefaultComponent
                        {
                            FormComponentTemplate = formComponentTemplate,
                            Name        = data.title,
                            RecordOrder = defaultComponentOrder,
                            Created     = now,
                            CreatedBy   = FrameworkConstants.DefaultMigrationAccount
                        };

                        if (data.fields != null && data.fields.Keys.Any())
                        {
                            var fieldOrder = 0;
                            foreach (var field in data.fields)
                            {
                                fieldOrder += 10;
                                var formField = new FormDefaultComponentField
                                {
                                    FormDefaultComponent = component,
                                    Name        = field.Key,
                                    Attributes  = SerializeUtilities.Serialize(field.Value),
                                    RecordOrder = fieldOrder,
                                    Created     = now,
                                    CreatedBy   = FrameworkConstants.DefaultMigrationAccount
                                };

                                context.FormDefaultComponentFields.AddEntities(formField);
                            }
                        }
                        else
                        {
                            context.FormDefaultComponents.AddEntities(component);
                        }
                    }
                    #endregion

                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initialize default settings
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                var emailTemplates = new[]
                {
                    new EmailTemplate
                    {
                        Name    = "Forgot Password Notification",
                        Subject = "Forgot Password Notification",
                        Body    =
                            DataInitializeHelper.GetResourceContent("ForgotPasswordTemplate.cshtml",
                                                                    DataSetupResourceType.EmailTemplate),
                        DataType = typeof(ForgotPasswordEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.ForgotPassword,
                    },
                    new EmailTemplate
                    {
                        Name    = "Register Email Notification",
                        Subject = "Register Email Notification",
                        Body    =
                            DataInitializeHelper.GetResourceContent("RegisterUserTemplate.cshtml",
                                                                    DataSetupResourceType.EmailTemplate),
                        DataType = typeof(RegisterEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.RegisterUser,
                    },
                    new EmailTemplate
                    {
                        Name    = "User Created Notification Template",
                        Subject = "User Created Notification",
                        Body    = DataInitializeHelper.GetResourceContent("UserCreatedTemplate.cshtml",
                                                                          DataSetupResourceType.EmailTemplate),
                        DataType = typeof(UserCreatedEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.UserCreatedNotification
                    },
                    new EmailTemplate
                    {
                        Name    = "Contact Form Notification",
                        Subject = "Contact Form Notification",
                        Body    =
                            DataInitializeHelper.GetResourceContent("ContactFormTemplate.cshtml",
                                                                    DataSetupResourceType.EmailTemplate),
                        DataType = typeof(ContactFormEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.ContactForm,
                    },
                    new EmailTemplate
                    {
                        Name    = "Protected Document Feedback",
                        Subject = "Protected Document Feedback",
                        Body    =
                            DataInitializeHelper.GetResourceContent("ProtectedDocumentFeedbackTemplate.cshtml",
                                                                    DataSetupResourceType.EmailTemplate),
                        DataType = typeof(ProtectedDocumentEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.ProtectedDocumentForm,
                    },
                    new EmailTemplate
                    {
                        Name    = "Subscribe Notification Template",
                        Subject = "Subscribe Notification",
                        Body    = DataInitializeHelper.GetResourceContent("SubscribeNotificationTemplate.cshtml",
                                                                          DataSetupResourceType.EmailTemplate),
                        DataType = typeof(SubscribeNoticationEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.SubscribeNotification
                    },
                    new EmailTemplate
                    {
                        Name    = "Account Expired Notification Template",
                        Subject = "Account Expired Notification",
                        Body    = DataInitializeHelper.GetResourceContent("AccountExpiredNotificationTemplate.cshtml",
                                                                          DataSetupResourceType.EmailTemplate),
                        DataType = typeof(NotifyAccountExpiredEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.AccountExpiredNotification
                    },
                    new EmailTemplate
                    {
                        Name    = "Deactivate Expired Account Notification Template",
                        Subject = "Deactivate Expired Account Notification",
                        Body    =
                            DataInitializeHelper.GetResourceContent("DeactiveExpiredAccountNotificationTemplate.cshtml",
                                                                    DataSetupResourceType.EmailTemplate),
                        DataType = typeof(NotifyAccountDeactivatedEmailModel).AssemblyQualifiedName,
                        Type     = EmailEnums.EmailTemplateType.DeactivateAccountNotification
                    }
                };

                context.EmailTemplates.AddIfNotExist(t => t.Name, emailTemplates);
            }
        }