コード例 #1
0
        public static UpdateViewModel GetDefault(MixEnums.EnumTemplateFolder folderType, string specificulture
                                                 , MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            string activedTheme = MixService.GetConfig <string>(MixAppSettingKeywords.ThemeFolder, specificulture)
                                  ?? MixService.GetConfig <string>(MixAppSettingKeywords.DefaultTheme);
            string folder = CommonHelper.GetFullPath(new string[]
            {
                MixFolders.TemplatesFolder
                , activedTheme
                , folderType.ToString()
            });
            var defaulTemplate = MixTemplates.UpdateViewModel.Repository.GetModelListBy(
                t => t.Theme.Name == activedTheme && t.FolderType == folderType.ToString()
                , _context, _transaction
                ).Data?.FirstOrDefault();

            return(defaulTemplate ?? new UpdateViewModel(new MixTemplate()
            {
                ThemeId = MixService.GetConfig <int>(MixAppSettingKeywords.ThemeId, specificulture),
                ThemeName = MixService.GetConfig <string>(MixAppSettingKeywords.ThemeFolder, specificulture),
                FileName = MixService.GetConfig <string>(MixAppSettingKeywords.DefaultTemplate),
                Extension = MixService.GetConfig <string>(MixAppSettingKeywords.TemplateExtension),
                Content = MixService.GetConfig <string>(MixAppSettingKeywords.DefaultTemplateContent),
                FolderType = folderType.ToString(),
                FileFolder = folder.ToString()
            }));
        }
コード例 #2
0
        public static UpdateViewModel GetDefault(MixEnums.EnumTemplateFolder folderType, string specificulture)
        {
            string activedTheme = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.Theme, specificulture)
                                  ?? MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.DefaultTheme);
            string folder = CommonHelper.GetFullPath(new string[]
            {
                MixConstants.Folder.TemplatesFolder
                , activedTheme
                , folderType.ToString()
            });

            return(new UpdateViewModel(new MixTemplate()
            {
                ThemeId = MixService.GetConfig <int>(MixConstants.ConfigurationKeyword.ThemeId, specificulture),
                ThemeName = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.Theme, specificulture),
                FileName = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.DefaultTemplate),
                Extension = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.TemplateExtension),
                Content = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.DefaultTemplateContent),
                FolderType = folderType.ToString(),
                FileFolder = folder.ToString()
            }));
        }
コード例 #3
0
        public static ImportViewModel GetDefault(MixEnums.EnumTemplateFolder folderType, string specificulture)
        {
            string activedTheme = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.ThemeFolder, specificulture)
                                  ?? MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.DefaultTheme);
            string folder = CommonHelper.GetFullPath(new string[]
            {
                MixConstants.Folder.TemplatesFolder
                , activedTheme
                , folderType.ToString()
            });
            var defaulTemplate = MixTemplates.ImportViewModel.Repository.GetModelListBy(
                t => t.Theme.Name == activedTheme && t.FolderType == folderType.ToString()).Data?.FirstOrDefault();

            return(defaulTemplate ?? new ImportViewModel(new MixTemplate()
            {
                ThemeId = MixService.GetConfig <int>(MixConstants.ConfigurationKeyword.ThemeId, specificulture),
                ThemeName = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.ThemeFolder, specificulture),
                FileName = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.DefaultTemplate),
                Extension = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.TemplateExtension),
                Content = MixService.GetConfig <string>(MixConstants.ConfigurationKeyword.DefaultTemplateContent),
                FolderType = folderType.ToString(),
                FileFolder = folder.ToString()
            }));
        }
コード例 #4
0
        public static UpdateViewModel GetTemplateByPath(string path, string specificulture, MixEnums.EnumTemplateFolder folderType, MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            string templateName = path?.Split('/')[1];
            int    themeId      = MixService.GetConfig <int>(MixConstants.ConfigurationKeyword.ThemeId, specificulture);
            var    getView      = UpdateViewModel.Repository.GetSingleModel(t =>
                                                                            t.ThemeId == themeId && t.FolderType == folderType.ToString() &&
                                                                            !string.IsNullOrEmpty(templateName) && templateName.Equals($"{t.FileName}{t.Extension}"), _context, _transaction);

            return(getView.Data ?? GetDefault(folderType, specificulture));
        }
コード例 #5
0
        public static UpdateViewModel GetTemplateByPath(string path, string specificulture, MixEnums.EnumTemplateFolder folderType
                                                        , MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            string templateName = !string.IsNullOrEmpty(path) ? path.Substring(path.LastIndexOf('/') + 1) : null;
            string filename     = templateName?.Substring(0, templateName.LastIndexOf('.'));
            string ext          = templateName?.Substring(templateName.LastIndexOf('.'));
            int    themeId      = MixService.GetConfig <int>(MixAppSettingKeywords.ThemeId, specificulture);
            string themeName    = MixService.GetConfig <string>(MixAppSettingKeywords.ThemeName, specificulture);
            var    getView      = UpdateViewModel.Repository.GetSingleModel(t =>
                                                                            t.ThemeId == themeId && t.FolderType == folderType.ToString() &&
                                                                            !string.IsNullOrEmpty(templateName) && t.FileName == filename && t.Extension == ext
                                                                            , _context, _transaction);

            return(getView.Data ?? GetDefault(folderType, specificulture, _context, _transaction));
        }