public IActionResult DB_Backup() { //string dbPath = !this.chBackup.Checked ? backPath : AppDomain.CurrentDomain.BaseDirectory; string dbname = DBHelper.GetAttrByStr(DBCenter.DB.ConnectionString, "Initial Catalog"); string DatabasePath = GetParam("DatabasePath").Split('.')[0]; if (SafeC.FileNameCheck(DatabasePath)) { return(WriteErr("文件名不规范")); } string savePath = ""; if (DBHelper.IsLocalDB(HttpContext.Connection.LocalIpAddress.ToString(), System.Environment.MachineName)) { savePath = function.VToP(dbPath + GetParam("DatabasePath") + ".bak"); } else { savePath = "D:\\backup\\" + DatabasePath + ".bak"; } string sql = "backup database [" + dbname + "] to disk='" + savePath + "' with init "; if (!Directory.Exists(function.VToP(dbPath))) { SafeSC.CreateDir(dbPath); } SqlHelper.ExecuteSql(sql); return(WriteOK("数据库备份成功", "DBBackUP")); }
public IActionResult CSSEdit_Submit() { string CSSPath = ""; if (!string.IsNullOrEmpty(FilePath)) { CSSPath = CSSBaseDir + FilePath.Split('.')[0] + ".css"; } else { string fname = GetParam("TxtFilename").Replace(" ", "").Split('.')[0]; if (SafeC.FileNameCheck(fname)) { return(WriteErr("文件名不符合规则")); } CSSPath = CSSBaseDir + fname + ".css"; } SafeSC.WriteFile(CSSPath, GetParam("textContent")); return(WriteOK("操作成功", "CSSManage")); }
public static bool FileNameCheck(params string[] fnames) { return(SafeC.FileNameCheck(fnames)); }