コード例 #1
0
        public OperationDataResult <HeaderSettingsModel> GetPageHeaderSettings()
        {
            try
            {
                var model = new HeaderSettingsModel()
                {
                    ImageLink            = _headerSettings.Value.ImageLink,
                    ImageLinkVisible     = _headerSettings.Value.ImageLinkVisible,
                    MainText             = _headerSettings.Value.MainText,
                    MainTextVisible      = _headerSettings.Value.MainTextVisible,
                    SecondaryText        = _headerSettings.Value.SecondaryText,
                    SecondaryTextVisible = _headerSettings.Value.SecondaryTextVisible,
                };

                return(new OperationDataResult <HeaderSettingsModel>(true, model));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(new OperationDataResult <HeaderSettingsModel>(false, "Can't obtain settings from web.config"));
            }
        }
コード例 #2
0
 public OperationDataResult <HeaderSettingsModel> GetPageHeaderSettings()
 {
     try
     {
         var configuration = WebConfigurationManager.OpenWebConfiguration("~");
         var section       = (AppSettingsSection)configuration.GetSection("appSettings");
         var model         = new HeaderSettingsModel()
         {
             ImageLink            = section.Settings["header:imageLink"]?.Value,
             ImageLinkVisible     = section.Settings["header:imageLinkVisible"].Value.Equals("True"),
             MainText             = section.Settings["header:mainText"]?.Value,
             MainTextVisible      = section.Settings["header:mainTextVisible"].Value.Equals("True"),
             SecondaryText        = section.Settings["header:secondaryText"]?.Value,
             SecondaryTextVisible = section.Settings["header:secondaryTextVisible"].Value.Equals("True")
         };
         return(new OperationDataResult <HeaderSettingsModel>(true, model));
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
         return(new OperationDataResult <HeaderSettingsModel>(false, "Can't obtain settings from web.config"));
     }
 }
コード例 #3
0
 public AdminSettingsModel()
 {
     HeaderSettingsModel    = new HeaderSettingsModel();
     LoginPageSettingsModel = new LoginPageSettingsModel();
     SMTPSettingsModel      = new SMTPSettingsModel();
 }
コード例 #4
0
        public OperationDataResult <HeaderSettingsModel> GetPageHeaderSettings()
        {
            try
            {
                var model = new HeaderSettingsModel()
                {
                    ImageLink            = _headerSettings.Value.ImageLink,
                    ImageLinkVisible     = _headerSettings.Value.ImageLinkVisible,
                    MainText             = _headerSettings.Value.MainText,
                    MainTextVisible      = _headerSettings.Value.MainTextVisible,
                    SecondaryText        = _headerSettings.Value.SecondaryText,
                    SecondaryTextVisible = _headerSettings.Value.SecondaryTextVisible,
                };

                var core      = _coreHelper.GetCore().GetAwaiter().GetResult();
                var dbContext = core.DbContextHelper.GetDbContext();
                var folders   = dbContext.Folders.Where(x => !string.IsNullOrEmpty(x.Name) && x.WorkflowState != Microting.eForm.Infrastructure.Constants.Constants.WorkflowStates.Removed).ToList();
                foreach (Folder folder in folders)
                {
                    List <string> nameTexts        = folder.Name.Split("|").ToList();
                    List <string> descriptionTexts = folder.Description.Split("|").ToList();


                    List <KeyValuePair <string, string> > names        = new List <KeyValuePair <string, string> >();
                    List <KeyValuePair <string, string> > descriptions = new List <KeyValuePair <string, string> >();

                    names.Add(new KeyValuePair <string, string> ("da", nameTexts[0]));
                    descriptions.Add(new KeyValuePair <string, string>("da", descriptionTexts[0].Replace("&nbsp;", " ")));
                    if (descriptionTexts.Count > 1)
                    {
                        descriptions.Add(new KeyValuePair <string, string>("en-US", descriptionTexts[1].Replace("&nbsp;", " ")));
                    }
                    else
                    {
                        descriptions.Add(new KeyValuePair <string, string>("en-US", " "));
                    }
                    if (descriptionTexts.Count > 2)
                    {
                        descriptions.Add(new KeyValuePair <string, string>("de-DE", descriptionTexts[2].Replace("&nbsp;", " ")));
                    }
                    else
                    {
                        descriptions.Add(new KeyValuePair <string, string>("de-DE", " "));
                    }
                    if (nameTexts.Count > 1)
                    {
                        if (descriptions.Count != 2)
                        {
                            descriptions.Add(new KeyValuePair <string, string>("en-US", " "));
                        }
                        names.Add(new KeyValuePair <string, string> ("en-US", nameTexts[1]));
                    }
                    else
                    {
                        names.Add(new KeyValuePair <string, string>("en-US", " "));
                    }
                    if (nameTexts.Count > 2)
                    {
                        if (descriptions.Count != 3)
                        {
                            descriptions.Add(new KeyValuePair <string, string>("de-DE", " "));
                        }
                        names.Add(new KeyValuePair <string, string> ("de-DE", nameTexts[2]));
                    }
                    else
                    {
                        names.Add(new KeyValuePair <string, string>("de-DE", " "));
                    }

                    core.FolderUpdate(folder.Id, names, descriptions, folder.ParentId).GetAwaiter().GetResult();
                    folder.Name        = null;
                    folder.Description = null;
                    folder.Update(dbContext).GetAwaiter().GetResult();
                }

                return(new OperationDataResult <HeaderSettingsModel>(true, model));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(new OperationDataResult <HeaderSettingsModel>(false, "Can't obtain settings from web.config"));
            }
        }