public ActionResult shrink() { string iduser = Session.getIdUser(); var tsql = new List <string> { local.getTsqlInsertHistory("shrink Data", iduser, "shrink Data") }; using (var db = local.getDataObject()) { tsql.Add($"DBCC SHRINKDATABASE ([{db.Connection.Database}], TRUNCATEONLY)"); } var arg = new itemScheduler("shrink Data", iduser, ListFile: string.Join("\ngo\n", tsql), iRequest: Request.toRequestString(), iData: tsql); return(Content(arg.callTaskScheduler())); }
public ActionResult Backup() { string iduser = Session.getIdUser(); string name = $"db_{DateTime.Now:ddMMyy_HHmmss}.bak"; var tsql = new List <string> { local.getTsqlInsertHistory("Backup Data", iduser, "Backup Data") }; using (var db = local.getDataObject()) { tsql.Add($"BACKUP DATABASE [{db.Connection.Database}] TO DISK = N'{Folders.Backup}\\{name}' WITH NOFORMAT, NOINIT, NAME = N'Full Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 "); } var arg = new itemScheduler("Backup Data", iduser, ListFile: string.Join("\ngo\n", tsql), iRequest: Request.toRequestString(), iData: tsql); return(Content(arg.callTaskScheduler())); }
public ActionResult accdb() { var args = new itemScheduler(); args.action = actionName; args.packetSize = int.Parse(Request.getValue("packetsize")); args.request = Request.toRequestString(); args.listFile = Request.getValue("table"); args.idUser = Session.getIdUser(); args.data = (Action)(() => bwDoWork(args)); Session[keyS.Message] = args.callTaskScheduler(); return(RedirectToAction("index")); }
/// <summary> /// ID: Mã bảo hiểm cấp huyện; f: Tên tập tin xử lý; Mode = 1: Xóa tập tin, ngược lại cập nhật danh sách tst; listfile: danh sách tập tin cần xử lý /// </summary> /// <returns></returns> public ActionResult import() { string folder = Folders.temp + "\\test"; string filename = ""; /* Check Exits File, Kiểm tra tham số */ try { if (Request.getValue("mode") == "1") { /* Xóa tập tin */ if (Request["f"] != null) { var f = new FileInfo(folder + "\\" + Request.getValue("f")); if (f.Exists) { f.Delete(); } } else { foreach (var v in Request.Form.GetValues("listfile")) { var f = new FileInfo(folder + "\\" + v); if (f.Exists) { f.Delete(); } } } Session[keyS.Message] = messageKey.actionSuccess; return(RedirectToAction("index")); } string id = Request.getValue("f"); if (string.IsNullOrEmpty(id) == false) { var f = new FileInfo(folder + "\\" + id); if (f.Exists == false) { throw new Exception(messageKey.notFoundFile(f.FullName)); } filename = f.FullName; } else { if (Request["listfile"] == null) { throw new Exception(messageKey.thamSoKhongDung); } } } catch (Exception ex) { Session[keyS.Error] = ex.saveMessage(); return(RedirectToAction("index")); } /* */ try { var args = new itemScheduler { function = keyFunction.importExcel, idObject = "", idUser = Session.getIdUser(), action = actionName, packetSize = 10000, listFile = filename, typeProcess = "", times = DateTime.Now, request = Request.toRequestString() }; if (string.IsNullOrEmpty(filename)) { /* Excel */ var ls = new List <string>(); var vals = Request.Form.GetValues("listfile"); foreach (var v in vals) { ls.Add(folder + "\\" + v); } args.listFile = string.Join(",", ls); } else { throw new Exception("Chưa chọn tập tin import"); } Session[keyS.Message] = args.callTaskScheduler(); } catch (Exception ex) { Session.saveError(ex.saveMessage()); } return(RedirectToAction("index")); }