public string EditEmployee(EmployeeModel u) { int k; string msg = "用户编辑失败。"; if (HasEmployeeNo(u.FEmployeeNo, u.FID)) { k = -2; msg = "员工编号已存在。"; } else { var oldEmployee = EmployeeDal.Instance.Get(u.FID); k = EmployeeDal.Instance.Update(u); if (k > 0) { msg = "员工编辑成功。"; LogBll <EmployeeModel> log = new LogBll <EmployeeModel>(); log.AddLog(u); } } return(new JsonMessage { Data = k.ToString(), Message = msg, Success = k > 0 }.ToString()); }
public string AddEmployee(EmployeeModel u) { string uid = "0"; string msg = "用户添加失败!"; if (HasEmployeeNo(u.FEmployeeNo, u.FID)) { uid = "-2"; msg = "员工编号已存在。"; } else { uid = EmployeeDal.Instance.Insert(u); if (uid != "") { msg = "添加新员工成功!"; LogBll <EmployeeModel> log = new LogBll <EmployeeModel>(); u.FID = uid; log.AddLog(u); } } return(new JsonMessage { Data = uid.ToString(), Message = msg, Success = uid != "" }.ToString()); }
public string DelBackup(FormCollection context) { string basepath = Server.MapPath("~/dbase/"); string filename = Request["n"].ToString(); string downpath = basepath + filename; System.IO.File.Delete(downpath); //写入操作日志 LogBll <object> log = new LogBll <object>(); log.AddLog("删除备份文件", "数据库备份文件删除成功,文件名:" + filename); return(new JsonMessage { Data = "1", Message = "删除成功。", Success = true }.ToString()); }
//删除备份文件 void DeleteFile(HttpContext context) { string basepath = context.Server.MapPath("~/dbase/"); string filename = context.Request["n"].ToString(); string downpath = basepath + filename; File.Delete(downpath); //写入操作日志 LogBll <object> log = new LogBll <object>(); log.AddLog("删除备份文件", "数据库备份文件删除成功,文件名:" + filename); context.Response.Write(new JsonMessage { Data = "1", Message = "删除成功。", Success = true }.ToString()); context.Response.End(); }
public string BackUp(FormCollection context) { string dbname = ConfigHelper.GetValue("dbname"); string backupName = StringHelper.CreateIDCode(); string savePath = Server.MapPath("~/dbase/"); StringBuilder sql = new StringBuilder(); sql.AppendLine(""); sql.AppendLine("USE [master];"); sql.AppendLine("ALTER DATABASE {0} SET RECOVERY SIMPLE WITH NO_WAIT;"); sql.AppendLine("ALTER DATABASE {0} SET RECOVERY SIMPLE;"); sql.AppendLine("USE {0};"); sql.AppendLine("DBCC SHRINKFILE (N'{0}_Log' , 11, TRUNCATEONLY);"); sql.AppendLine("USE [master]; "); sql.AppendLine("ALTER DATABASE {0} SET RECOVERY FULL WITH NO_WAIT;"); sql.AppendLine("ALTER DATABASE {0} SET RECOVERY FULL;"); sql.AppendLine("USE {0};"); sql.AppendLine("BACKUP DATABASE {0} to DISK ='{1}'"); string backupSql = sql.ToString();// "DUMP TRANSACTION {0} WITH NO_LOG; BACKUP DATABASE {0} to DISK ='{1}' "; backupSql = string.Format(backupSql, dbname, savePath + backupName + ".bak"); try { //执行备份 hn.Common.Data.DbUtils.ExecuteNonQuery(backupSql, null); //addZipEntry(backupName, savePath); //写入操作日志 LogBll <object> log = new LogBll <object>(); log.AddLog("备份数据库", "数据库备份成功,文件名:" + backupName + ".bak"); return(new JsonMessage { Data = "1", Message = "数据库备份成功。", Success = true }.ToString()); } catch (Exception ex) { return(new JsonMessage { Data = "1", Message = ex.StackTrace, Success = false }.ToString()); } }
private void AddButton(Button b, HttpContext context) { int k = ButtonDal.Instance.Insert(b); var msg = "添加成功。"; if (k <= 0) { msg = "添加失败。"; } else { LogBll <Button> log = new LogBll <Button>(); b.KeyId = k; log.AddLog(b); } context.Response.Write(new JsonMessage { Success = true, Data = k.ToString(), Message = msg }.ToString()); }
//下载备份文件 void DownloadFile(HttpContext context) { string basepath = context.Server.MapPath("~/dbase/"); string filename = context.Request["n"]; string downpath = basepath + filename; MemoryStream ms = null; context.Response.ContentType = "application/octet-stream"; context.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename); ms = new MemoryStream(File.ReadAllBytes(downpath)); //写入操作日志 LogBll <object> log = new LogBll <object>(); log.AddLog("下载备份数据库", "数据库备份文件下载,文件名:" + filename); context.Response.Clear(); context.Response.BinaryWrite(ms.ToArray()); context.Response.End(); }
public string AddFranchisee(FranchiseeModel u) { string uid = "0"; string msg = "加盟商添加失败!"; if (HasFranchiseeNo(u.COMPANY_NAME, u.FID)) { uid = "-2"; msg = "加盟商已存在。"; } else { uid = FranchiseeDal.Instance.Insert(u); if (uid != "") { OrganizeModel model = new OrganizeModel(); model.CODE = uid; model.NAME = u.COMPANY_NAME; model.SHORTNAME = u.COMPANY_NAME; model.LINKMAN = u.LINK_MAN; model.PHONE = u.TEL; model.FAX = ""; model.EMAIL = ""; model.ADDRESS = u.ADDRESS; model.POSTCODE = u.ZIP_CODE; model.DISABLED = 1; model.DESCRIPTION = u.REMARK; model.TYPE = 1; OrganizeDal.Instance.Insert(model); msg = "添加加盟商成功!"; LogBll <FranchiseeModel> log = new LogBll <FranchiseeModel>(); u.FID = uid; log.AddLog(u); } } return(new JsonMessage { Data = uid.ToString(), Message = msg, Success = uid != "" }.ToString()); }
/// <summary> /// 打印出错状态处理 /// </summary> public void PrintWrong() { PrintServer ps = new PrintServer(); PrintQueue queue = ps.GetPrintQueue(ConfigurationManager.AppSettings["printer"]); //int sendResult = 0; try { string proResult = ""; getWrongMsg(ref proResult, queue); //messgeBoxBll msgBox = new messgeBoxBll(); messgeBoxBll.Show("打印机出现问题,已经删除打印任务,本次操作不会计费", "问题排查:\n" + proResult); configbll.SaveConfig("printerStatus", "wrong"); //if (queue.NumberOfJobs == 0 || wrongnum > 6) //{ JObject jo; //上传结果 string result = httpbll.updatePrintStatus("0"); jsonbll.jsonToJobject(result, out jo); if (jo["code"].ToString() == "200") { messgeBoxBll.Show("结果上传成功", jo["msg"].ToString()); //if (wrongnum > 6) //{ // messgeBoxBll.Show( "无法清理残余任务请联系管理员","问题排查:\n" + proResult); //} if (sameJobNum > 30) { messgeBoxBll.Show("超时", "打印机停留在同一任务时间过长"); proResult += "打印机停留在同一任务时间过长"; } Log_m log = new Log_m("打印出错上传结果", "Y", "问题:" + proResult); logbll.AddLog(log, ConfigurationManager.AppSettings["logFile"]); } else { messgeBoxBll.Show("结果上传失败", jo["msg"].ToString()); //if (wrongnum > 6) //{ // messgeBoxBll.Show("无法清理残余任务请联系管理员", "问题排查:\n" + proResult); //} Log_m log = new Log_m("打印出错上传结果", "N", "问题:" + proResult + jo["msg"].ToString()); logbll.AddLog(log, ConfigurationManager.AppSettings["logFile"]); } //PrintBLL printbll = new PrintBLL(); //printbll.ClearJobs(); //} //else //{ // messgeBoxBll.Show("...........","正在还原初始状态"); //} } catch (Exception ex) { messgeBoxBll.Show(ex.Message, "意外错误"); Log_m log = new Log_m("打印出错上传结果", "N", "问题:" + ex.Message); logbll.AddLog(log, ConfigurationManager.AppSettings["logFile"]); //PrintBLL printbll = new PrintBLL(); //printbll.ClearJobs(); } }