private void ExecuteSql(string themeName, int type, DbConnection dbConnection, DbTransaction dbTransaction) { string folder = type == 1 ? "uninstall" : "install"; string path = _hostingEnvironment.MapWebRootPath(_themeName, themeName, _sqlName, folder); var files = ExtFile.GetFiles(path, _sql); if (files != null && files.Length > 0) { foreach (var item in files) { foreach (var sql in ReadSql(item)) { if (sql.IsNullOrWhiteSpace()) { continue; } using (var command = dbConnection.CreateCommand()) { command.Transaction = dbTransaction; command.CommandTimeout = 0; command.CommandText = sql; command.ExecuteNonQuery(); } } } } }
private List <TemplateFile> GetTemplateFiles() { var templateFiles = new List <TemplateFile>(); List <string> themes = GetThemeNames(); //if (theme.IsNullOrWhiteSpace()) //{ // themes = GetThemeNames(); //} //else //{ // themes = new List<string>() { theme }; //} Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >(); foreach (var item in themes) { List <string> temFiles = new List <string>(); string path = _env.MapWebRootPath(_themeName, item, _viewName); var fs = ExtFile.GetFiles(path, _cshtml); if (fs != null && fs.Length > 0) { temFiles.AddRange(fs); } var fs2 = ExtFile.GetFiles(path, _fluid); if (fs2 != null && fs2.Length > 0) { temFiles.AddRange(fs2); } dic.Add(item, temFiles); } int index = _env.WebRootPath.Length; int id = 0; foreach (var d in dic) { foreach (var item in d.Value) { TemplateFile file = new TemplateFile() { Id = ++id, ThemeName = d.Key, Name = Path.GetFileName(item), Path = item, RelativePath = GetRelativePath(item, index), LastUpdateTime = File.GetLastWriteTime(item) }; templateFiles.Add(file); } } return(templateFiles); }
private List <TemplateFile> GetTemplateFiles() { return(_cacheMgr.GetOrAdd(_templateFilesCacheKey, key => { var allTemplateFiles = new List <TemplateFile>(); List <string> themes = GetThemeNames(); Dictionary <string, List <string> > themeTemplateFiles = new Dictionary <string, List <string> >(); foreach (var theme in themes) { List <string> templateFiles = new List <string>(); string path = _webHostEnvironment.MapWebRootPath(_themeFolderName, theme, _viewFolderName); foreach (var extension in GetSupportFileExtensions()) { var fs = ExtFile.GetFiles(path, "*" + extension); if (fs != null && fs.Length > 0) { templateFiles.AddRange(fs); } } themeTemplateFiles.Add(theme, templateFiles); } int index = _webHostEnvironment.WebRootPath.Length; int id = 0; foreach (var theme in themeTemplateFiles) { foreach (var item in theme.Value) { TemplateFile file = new TemplateFile { Id = ++id, ThemeName = theme.Key, ThemeViewsFolder = GetThemeViewsFolder(theme.Key), Name = Path.GetFileName(item), Path = item, RelativePath = GetRelativePath(item, index), LastUpdateTime = File.GetLastWriteTime(item) }; allTemplateFiles.Add(file); } } return allTemplateFiles; })); }
private List <TemplateFile> GetTemplateFiles() { return(_cacheMgr.GetOrAdd(_templateFilesCacheKey, key => { var templateFiles = new List <TemplateFile>(); List <string> themes = GetThemeNames(); Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >(); foreach (var item in themes) { List <string> temFiles = new List <string>(); string path = _webHostEnvironment.MapWebRootPath(_themeName, item, _viewName); var fs = ExtFile.GetFiles(path, _cshtml); if (fs != null && fs.Length > 0) { temFiles.AddRange(fs); } dic.Add(item, temFiles); } int index = _webHostEnvironment.WebRootPath.Length; int id = 0; foreach (var d in dic) { foreach (var item in d.Value) { TemplateFile file = new TemplateFile() { Id = ++id, ThemeName = d.Key, Name = Path.GetFileName(item), Path = item, RelativePath = GetRelativePath(item, index), LastUpdateTime = File.GetLastWriteTime(item) }; templateFiles.Add(file); } } return templateFiles; })); }