public ActionResult IndexModel(int Id) { try { ViewBag.lishow = lishow; ViewBag.ashow = "war"; ViewBag.LfetShow = LfetShow; ViewBag.ashow = "war"; ViewBag.location = "所在位置:<a href='" + Url.Content("~/Warning/Index") + "'>布控管理</a> >>布控项详情"; UserInfo user = (UserInfo)Session["userInfo"]; BKBJ.AuditInfo audit = new AuditDAL().GetAuditInfoById(Id, user.ID); ViewBag.NetbarType = ChangeValue.GetLocaTypeList(); ViewBag.deploy = audit; ViewBag.DSArea = new AuditDAL().GetAreaList(); } catch (SqlException sqlex) { Logger.ErrorLog(sqlex, null); } catch (Exception ex) { Logger.ErrorLog(ex, null); } return(View()); }
public ActionResult RepIndex(string CaseType, string TaskName, string selTaskName, string keyWord, string selkeyWord, string HeadName, string selHeadName, string StartCreateTime, string EndCreateTime, string StartEndTime, string EndEndTime) { Dictionary <string, string> dic = new Dictionary <string, string>() { { "CaseType", CaseType }, { "TaskName", TaskName }, { "selTaskName", selTaskName }, { "keyWord", keyWord }, { "selkeyWord", selkeyWord }, { "Mac", "" }, { "selMac", "" }, { "Mobile", "" }, { "selMobile", "" }, { "IMEI", "" }, { "selIMEI", "" }, { "IM", "" }, { "selIM", "" }, { "HeadName", HeadName }, { "selHeadName", selHeadName }, { "StartCreateTime", StartCreateTime }, { "EndCreateTime", EndCreateTime }, { "StartEndTime", StartEndTime }, { "EndEndTime", EndEndTime }, { "Uid", ((UserInfo)Session["userinfo"]).Type == 1?"0":((UserInfo)Session["userinfo"]).ID.ToString() }, }; DataTable dt = new AuditDAL().ExportAuditDT(dic); Dictionary <string, string> Head_Dic = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(TaskName)) { Head_Dic.Add("审计任务名称", TaskName); } if (!string.IsNullOrEmpty(keyWord)) { Head_Dic.Add("布控内容", keyWord); } if (!string.IsNullOrEmpty(HeadName)) { Head_Dic.Add("负责人", HeadName); } if (!string.IsNullOrEmpty(StartCreateTime)) { Head_Dic.Add("审计任务添加开始时间", StartCreateTime); } if (!string.IsNullOrEmpty(EndCreateTime)) { Head_Dic.Add("审计任务添加结束时间", EndCreateTime); } if (!string.IsNullOrEmpty(StartEndTime)) { Head_Dic.Add("审计条件-审计有效开始时间", StartEndTime); } if (!string.IsNullOrEmpty(EndEndTime)) { Head_Dic.Add("审计条件-审计有效结束时间", EndEndTime); } Dictionary <string, string> Title_Dic = new Dictionary <string, string>(); if (CaseType == "1") { Title_Dic = new Dictionary <string, string>() { { "序号", "ID" }, { "布控任务名称", "TaskName" }, { "布控类型", "CaseItem" }, { "布控内容", "CaseValue" }, { "负责人", "HeadName" }, { "布控任务添加时间", "CreateTime" }, { "布控条件-审计有效时间", "EndTime" }, { "状态", "IsEnabled" }, }; } else { Title_Dic = new Dictionary <string, string>() { { "序号", "ID" }, { "审计任务名称", "TaskName" }, { "即时通讯标识", "CaseValue" }, { "即时通讯工具", "ST_NETWORK_APP" }, { "负责人", "HeadName" }, { "审计任务添加时间", "CreateTime" }, { "审计条件-审计有效时间", "EndTime" }, { "状态", "IsEnabled" }, }; } NPOISheetModel sheet = new NPOISheetModel(); sheet.dt = dt; sheet.ExcelTitle = CaseType == "1" ? "布控报警" : "即时通讯审计"; sheet.TableTitle = Title_Dic; sheet.TableSearch = Head_Dic; string path = new ComNPOIExcel().Export(sheet, Server.MapPath("~/") + "UserData/EXP/Audit/"); return(Content("{\"result\":\"" + path + "\"}")); }
public ActionResult AddIndex(FormCollection form) { AuditDAL auditdal = new AuditDAL(); UserInfo user = (UserInfo)Session["userInfo"]; BKBJ.AuditInfo audit = new BKBJ.AuditInfo(); try { if (form["txtCaseItem"] == "3") { if (Request.Files.Count >= 1 && Request.Files[0] != null) { HttpPostedFileBase file = Request.Files[0]; string path = Server.MapPath("~/UserData/Warning/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string ext = file.FileName.Substring(file.FileName.LastIndexOf(".")).Split('.')[1].ToString(); if (!(ext.ToLower() == "txt")) { return(Content("<script>alert('只支持后缀名为txt的文件格式');history.go(-1);</script>")); } else if (file.ContentLength == 0) { return(Content("<script>alert('导入文件不能为空');history.go(-1);</script>")); } else if (file.ContentLength > 20 * 1024 * 1024) { return(Content("<script>alert('文件不能大于20MB');history.go(-1);</script>")); } string extendName = file.FileName.Substring(file.FileName.LastIndexOf(".")).ToLower(); string wholePath = Path.Combine(path, DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + extendName); file.SaveAs(wholePath); string strval = string.Empty; FileStream fs = new FileStream(wholePath, FileMode.Open); StreamReader reader = new StreamReader(fs, Encoding.Default); int ErrNum = 0; int Count = 0; int skip = 0; while ((strval = reader.ReadLine()) != null) { if (strval.Contains("|")) { string[] TempArray = strval.Split('|'); for (int i = 0; i < TempArray.Length; i++) { audit.TaskName = i == 0 ? "黑名单:" + TempArray[0] : "黑名单:" + TempArray[1]; audit.Uid = user.ID; audit.ProID = user.ProID; audit.CityID = user.CityID; audit.AID = user.AId; audit.CaseItem = Convert.ToInt32(form["txtCaseItem"]); audit.CaseType = 1; audit.CaseValue = TempArray[i]; audit.NETWORK_APP = 0; audit.HeadName = form["txtHeadName"]; audit.HeadMobile = form["txtHeadMobile"]; audit.DeployArea = string.IsNullOrEmpty(form["ckAll"]) ? form["txtDeployArea"] : "0"; audit.IsEnabled = 2; audit.IsValid = 0; audit.MailWarn = Convert.ToInt32(form["txtMailWarn"]); audit.WMail = audit.MailWarn == 1 ? form["txtWMail"] : ""; audit.StartTime = DateTime.Now; audit.EndTime = Convert.ToDateTime(form["txtEndTime"]); audit.CreateTime = DateTime.Now; audit.Remark = form["txtRemark"]; audit.NetbarType = form["cbtype"]; if (auditdal.GetCaseTaskNameCount(audit.TaskName, 0, user.ID) > 0) { skip = skip + 1; //DirectoryInfo difo = new DirectoryInfo(file.FileName); //string path = difo.Parent.ToString(); //StreamWriter sw = new StreamWriter(file + "/布控失败" + difo.Name, true, Encoding.Default); //sw.WriteLine(string.Join("|", TempArray)); //sw.Close(); //sw.Dispose(); } else { if (new AuditDAL().AddAudit(audit) > 0) { log.What = "添加人员审计," + "用户ID:" + user.ID + ";审计类型:" + (audit.CaseItem == 1 ? "手机号码" : (audit.CaseItem == 2 ? "MAC地址" : "批量导入")) + ";审计内容:" + audit.CaseValue; } else { ErrNum = ErrNum + 1; } } } } Count = Count + 1; } fs.Close(); fs.Dispose(); reader.Close(); reader.Dispose(); return(Content("<script>alert('操作完成,成功‘" + ((Count - ErrNum - skip) > 0 ? (Count - ErrNum - skip) : 0) + "’条!,跳过重复添加‘" + (skip) + "’条,失败‘" + ErrNum + "’条,请重新添加。');location.replace('" + Url.Content("~/Warning/Index") + "');</script>")); } } else { if (string.IsNullOrEmpty(form["txtTaskName"])) { return(Content("<script>alert('布控任务名称不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["txtCaseItem"])) { return(Content("<script>alert('布控类型不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["keyWord"])) { return(Content("<script>alert('布控内容不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["txtEndTime"])) { return(Content("<script>alert('布控有效时间不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["txtDeployArea"])) { return(Content("<script>alert('布控范围不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["cbtype"])) { return(Content("<script>alert('布控场所类别不能为空。');history.go(-1);</script>")); } if (auditdal.GetCaseTaskNameCount(form["txtTaskName"], 0, user.ID) > 0) { return(Content("<script>alert('布控任务名称已存在,请重新输入。');history.go(-1);</script>")); } if (auditdal.GetCaseMobileCount(0, Convert.ToInt32(form["txtCaseItem"]), form["txtCaseValue"], -1, user.ID, 1) > 0) { return(Content("<script>alert('该" + (Convert.ToInt32(form["txtCaseItem"]) == 1 ? "手机号码" : (Convert.ToInt32(form["txtCaseItem"]) == 2 ? "MAC地址" : "IMEI")) + "已存在,请重新输入。');history.go(-1);</script>")); } audit.TaskName = form["txtTaskName"]; audit.Uid = user.ID; audit.ProID = user.ProID; audit.CityID = user.CityID; audit.AID = user.AId; audit.CaseItem = Convert.ToInt32(form["txtCaseItem"]); audit.CaseType = 1; audit.CaseValue = form["txtCaseValue"]; audit.NETWORK_APP = 0; audit.HeadName = form["txtHeadName"]; audit.HeadMobile = form["txtHeadMobile"]; audit.DeployArea = string.IsNullOrEmpty(form["ckAll"]) ? form["txtDeployArea"] : "0"; audit.IsEnabled = 2; audit.IsValid = 0; audit.MailWarn = Convert.ToInt32(form["txtMailWarn"]); audit.WMail = audit.MailWarn == 1 ? form["txtWMail"] : ""; audit.StartTime = DateTime.Now; audit.EndTime = Convert.ToDateTime(form["txtEndTime"]); audit.CreateTime = DateTime.Now; audit.Remark = form["txtRemark"]; audit.NetbarType = form["cbtype"]; if (new AuditDAL().AddAudit(audit) > 0) { log.What = "添加人员审计," + "用户ID:" + user.ID + ";审计类型:" + (audit.CaseItem == 1 ? "手机号码" : (audit.CaseItem == 2 ? "MAC地址" : "批量导入")) + ";审计内容:" + audit.CaseValue; return(Content("<script>alert('添加成功');location.replace('" + Url.Content("~/Warning/Index") + "');</script>")); } else { return(Content("<script>alert('添加失败');history.go(-1);</script>")); } } } catch (SqlException sqlException) { Logger.ErrorLog(sqlException, null); return(Content("<script>alert('添加失败,请稍后重试!');history.go(-1);</script>")); } catch (Exception ex) { Logger.ErrorLog(ex, null); return(Content("<script>alert('添加失败');history.go(-1);</script>")); } return(View()); }
public ActionResult EditIndex(FormCollection form) { try { AuditDAL auditdal = new AuditDAL(); UserInfo user = (UserInfo)Session["userInfo"]; BKBJ.AuditInfo audit = new BKBJ.AuditInfo(); audit.ID = Convert.ToInt32(form["ID"]); if (string.IsNullOrEmpty(form["txtTaskName"])) { return(Content("<script>alert('审计任务名称不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["txtCaseValue"])) { return(Content("<script>alert('审计条件不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["txtEndTime"])) { return(Content("<script>alert('审计有效时间不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["txtDeployArea"])) { return(Content("<script>alert('布控范围不能为空。');history.go(-1);</script>")); } if (string.IsNullOrEmpty(form["cbtype"])) { return(Content("<script>alert('布控场所类别不能为空。');history.go(-1);</script>")); } if (auditdal.GetCaseTaskNameCount(form["txtTaskName"], audit.ID, user.ID) > 0) { return(Content("<script>alert('审计任务名称已存在,请重新输入。');history.go(-1);</script>")); } if (auditdal.GetCaseMobileCount(audit.ID, Convert.ToInt32(form["txtCaseItem"]), form["txtCaseValue"], -1, user.ID, 1) > 0) { return(Content("<script>alert('该" + (Convert.ToInt32(form["txtCaseItem"]) == 1 ? "手机号码" : (Convert.ToInt32(form["txtCaseItem"]) == 2 ? "MAC地址" : "IMEI")) + "已存在,请重新输入。');history.go(-1);</script>")); } audit.TaskName = form["txtTaskName"]; audit.Uid = user.ID; audit.ProID = user.ProID; audit.CityID = user.CityID; audit.AID = user.AId; audit.CaseItem = Convert.ToInt32(form["txtCaseItem"]); audit.CaseType = 1; audit.CaseValue = form["txtCaseValue"]; audit.NETWORK_APP = 0; audit.HeadName = form["txtHeadName"]; audit.HeadMobile = form["txtHeadMobile"]; audit.DeployArea = string.IsNullOrEmpty(form["ckAll"]) ? form["txtDeployArea"] : "0"; audit.IsEnabled = 2; audit.IsValid = 0; audit.MailWarn = Convert.ToInt32(form["txtMailWarn"]); audit.WMail = audit.MailWarn == 1 ? form["txtWMail"] : ""; audit.StartTime = DateTime.Now; audit.EndTime = Convert.ToDateTime(form["txtEndTime"]); audit.CreateTime = DateTime.Now; audit.Remark = form["txtRemark"]; audit.NetbarType = form["cbtype"]; if (new AuditDAL().UpdateAudit(audit) > 0) { log.What = "修改人员审计," + "用户ID:" + user.ID + ";审计ID:" + audit.ID + ";审计类型:" + (audit.CaseItem == 1 ? "手机号码" : (audit.CaseItem == 2 ? "MAC地址" : "IMEI")) + ";审计内容:" + audit.CaseValue; new OPLogDAL().InsertLog(log); return(Content("<script>alert('修改成功');location.replace('" + Url.Content("~/Warning/Index") + "');</script>")); } else { return(Content("<script>alert('修改失败');history.go(-1);</script>")); } } catch (SqlException sqlException) { Logger.ErrorLog(sqlException, new Dictionary <string, string>() { { "Function", "AuditController.AddPersonAudit" } }); return(Content("<script>alert('修改失败,请稍后重试!');history.go(-1);</script>")); } }
public bool InsertAuditBL(AuditModel _AuditModel) { bool ret = AuditDAL.InsertAuditDetails(_AuditModel); return(ret); }