//保存测点对照表 public ActionResult SavePointmapdts(t_cm_pointmapdts model) { string result = "OK"; //新增 try { List <t_cm_pointmapdts> list = bll.t_cm_pointmapdts.Where(p => p.tagid == model.tagid).ToList(); if (list.Count > 0)//修改 { string strsql = "update t_cm_pointmapdts set dname='" + model.dname + "',channelsinfoid=" + model.channelsinfoid + ",cname='" + model.cname + "',zonename='" + model.zonename + "',zoneno=" + model.zoneno + " where tagid=" + model.tagid; bll.ExecuteStoreCommand(strsql, null); Common.InsertLog("光纤分区对照管理", CurrentUser.UserName, "修改光纤分区对照[测点ID:" + model.tagid + "]"); } else { bll.t_cm_pointmapdts.AddObject(model); bll.SaveChanges(); Common.InsertLog("光纤分区对照管理", CurrentUser.UserName, "新增光纤分区对照[定位点ID:" + model.tagid + "]"); } } catch (Exception ex) { result = ex.ToString(); } return(Content(result)); }
public ActionResult SaveLocate(t_cm_pointmapdts locate) { List <t_cm_pointmapdts> list = bll.t_cm_pointmapdts.ToList(); int locateid = locate.tagid; string result = "OK"; //新增 try { if (locateid < 1) { list = list.Where(s => s.tagname == locate.tagname).ToList(); if (list.Count > 0) { result = "此定位点已存在,请设置其他定位点!"; } else { bll.t_cm_pointmapdts.AddObject(locate); bll.SaveChanges(); locateid = locate.tagid; Common.InsertLog("定位点管理", CurrentUser.UserName, "新增定位点[定位点ID:" + locateid + "_" + locate.tagname + "]"); } } else//修改 { t_cm_pointmapdts model = bll.t_cm_pointmapdts.Where(l => l.tagid == locateid).First(); model.tagname = locate.tagname; model.pid = locate.pid; model.did = locate.did; model.devicesinfoid = locate.devicesinfoid; model.dname = locate.dname; model.channelsinfoid = locate.channelsinfoid; model.cname = locate.cname; model.zoneno = locate.zoneno; model.zonename = locate.zonename; model.parentid = locate.parentid; model.startPt = locate.startPt; model.endPt = locate.endPt; bll.ObjectStateManager.ChangeObjectState(model, EntityState.Modified); bll.SaveChanges(); Common.InsertLog("定位点管理", CurrentUser.UserName, "修改定位点[定位点ID:" + locateid + "_" + locate.tagname + "]"); } } catch (Exception ex) { result = ex.ToString(); } return(Content(result)); }
/// <summary> /// 获取工单详情 /// </summary> /// <param name="OrderID">工单ID</param> /// <returns></returns> public ActionResult LoadOrderInfo(int OrderID) { string strJson = "error"; string sessionid = ""; if (Request.Cookies["sid"] != null) { sessionid = Request.Cookies["sid"].Value; if (Session[sessionid] != null) { t_PM_Order order = bll.t_PM_Order.Where(o => o.OrderID == OrderID).First(); if (order != null) { strJson = Common.JsonDataInfo(order); //修改工单状态,已领取 if (order.OrderState == 0) { order.OrderState = 1; order.AcceptedDate = DateTime.Now; bll.ObjectStateManager.ChangeObjectState(order, EntityState.Modified); bll.SaveChanges(); } } } } return(Content(strJson)); }
/// <summary> /// 记录日志 /// </summary> /// <param name="logType">日志类型</param> /// <param name="username">操作人</param> /// <param name="contents">日志描述</param> public static void InsertLog(string logType, string username, string contents) { pdermsWebEntities bll = new pdermsWebEntities(); t_CM_Log log = new t_CM_Log(); log.LogDate = DateTime.Now; log.LogType = logType; log.UserName = username; log.Contents = contents; log.IPAddress = "";// GetIPAddress(); bll.t_CM_Log.AddObject(log); bll.SaveChanges(); }
public void SendConTemp(object sender, System.Timers.ElapsedEventArgs e) { try { var list = bll.t_ES_ContractTemplet.Where(p => p.IsOk == 0).ToList(); foreach (var item in list) { //var sss = item.StartTime.Value.Date; //var ss = DateTime.Now.AddDays(Convert.ToDouble(item.BeforDay)).Date; if (null != item.StartTime && null != item.AlarmTime) { if ( (item.StartTime.Value.Date == DateTime.Now.AddDays(Convert.ToDouble(item.BeforDay)).Date&& item.AlarmTime.Value.Date != DateTime.Now.Date) || item.AlarmTime.Value.Date == Convert.ToDateTime("1900-01-01").Date || (item.StartTime.Value.Date == DateTime.Now.Date && item.AlarmTime.Value.Date != DateTime.Now.Date) ) { t_CM_UserInfo user = bll.t_CM_UserInfo.Where(p => p.UserID == item.PersonID).FirstOrDefault(); if (user != null) { item.AlarmTime = DateTime.Now; bll.ObjectStateManager.ChangeObjectState(item, System.Data.EntityState.Modified); UtilsSms.smsConTemp(user.Telephone); } } } } bll.SaveChanges(); } catch (Exception ex) { string error = ex.ToString(); return; } }
public ActionResult SaveBugInfo(t_CM_BugInfo info) { string result = "OK"; try { List <t_CM_BugInfo> list = bll.t_CM_BugInfo.Where(p => p.BugLocation == info.BugLocation && p.BugID != info.BugID).ToList(); if (list.Count > 0) { result = "此隐患已存在,请重新录入! "; } else { if (info.BugID > 0) { t_CM_BugInfo Bug = bll.t_CM_BugInfo.Where(r => r.BugID == info.BugID).First(); //Bug.PID = info.PID; //Bug.PName = info.PName; //Bug.DID = info.DID; //Bug.DeviceName = info.DeviceName; //Bug.BugLevel = info.BugLevel; //Bug.BugLocation = info.BugLocation; //Bug.BugDesc = info.BugDesc; //Bug.ReportWay = info.ReportWay; Bug.HandeSituation = info.HandeSituation; //if (string.IsNullOrEmpty(Bug.UserName)) Bug.UserName = CurrentUser.UserName; //if (Bug.HandleDate == null) Bug.HandleDate = DateTime.Now; bll.ObjectStateManager.ChangeObjectState(Bug, EntityState.Modified); bll.SaveChanges(); Common.InsertLog("隐患管理", CurrentUser.UserName, "编辑隐患信息[" + Bug.BugLocation + "]"); result = "OKedit"; } else { info.ReportDate = DateTime.Now; info.HandeSituation = "未审核"; info.ReportUser = CurrentUser.UserName; bll.t_CM_BugInfo.AddObject(info); bll.SaveChanges(); Common.InsertLog("隐患管理", CurrentUser.UserName, "新增隐患信息[" + info.BugLocation + "]"); result = "OKadd"; } } } catch (Exception ex) { result = ex.ToString(); result = "出错了!"; } return(Content(result)); }
//新增文件 public ActionResult AddFile(t_cm_files file) { string strResult = "ok"; try { file.CommitTime = DateTime.Now; file.CommitUser = CurrentUser.UserName; bll.t_cm_files.AddObject(file); int recount = bll.SaveChanges(); //log Common.InsertLog("新增文件", CurrentUser.UserName, "新增资料,资料模块[" + file.Modules + "_" + file.ID + "]"); } catch { strResult = "error"; } return(Content(strResult)); }
//重置相间温度值 private void ResetAlternate(int pid = 1) { string strsql = "SELECT p.TagID, d.PID, d.PName, p.DID, d.DeviceName, p.Position,P.MPID,D.DTID,ABCID FROM t_CM_PointsInfo AS p JOIN t_DM_DeviceInfo AS d ON p.DID = d.DID WHERE P.DataTypeID=1 and mpid>0 "; if (pid > 0) { strsql = strsql + " and pid=" + pid; } //去掉重复项,只获取三相数据 strsql = strsql + " and ABCID>0 and TagID not in (select TagID_A from t_CM_AlternateSet) and TagID not in (select TagID_B from t_CM_AlternateSet) and TagID not in (select TagID_C from t_CM_AlternateSet) order by DID,Position,ABCID"; int pcount = 0;//计算器,计算ABC三相数据 double AlarmVal = 85, WarningVal = 75, IntersetVal = 65; List <BasicAlternate> list = bll.ExecuteStoreQuery <BasicAlternate>(strsql).ToList(); string bPosition = "", cPosition = ""; int eid = 0, bdid = 0, cdid = 0;//室内环境tagid strsql = "select top 1 TagID from t_CM_PointsInfo where DataTypeID in (12,24) and DID in (select DID from t_DM_DeviceInfo where PID=" + pid + ")"; List <int> eids = bll.ExecuteStoreQuery <int>(strsql).ToList(); if (eids.Count > 0) { eid = eids[0]; } if (eid > 0)//如果没有环境温度的值。取消执行 { t_CM_AlternateSet model = new t_CM_AlternateSet(); foreach (BasicAlternate alternate in list) { if (alternate.ABCID > 0) { cPosition = alternate.Position; cdid = alternate.DID; if (cPosition.Equals(bPosition) && cdid == bdid) { if (alternate.ABCID == 2) { model.TagID_B = alternate.TagID; } else if (alternate.ABCID == 3) { model.TagID_C = alternate.TagID; if (pcount == list.Count - 1) { bll.t_CM_AlternateSet.AddObject(model); bll.SaveChanges(); Common.InsertLog("相间报警设置", "系统管理员", "设置相间报警值[" + cPosition + "(" + model.DName + ")]"); } } } else { if (pcount > 0 && pcount % 3 == 0) { bll.t_CM_AlternateSet.AddObject(model); bll.SaveChanges(); Common.InsertLog("相间报警设置", "系统管理员", "设置相间报警值[" + cPosition + "(" + model.DName + ")]"); } model = new t_CM_AlternateSet(); model.AlarmVal = AlarmVal; model.DID = alternate.DID; model.DName = alternate.DeviceName; model.DTID = alternate.DTID; model.IntersetVal = IntersetVal; model.MPID = alternate.MPID; model.PID = alternate.PID; model.PName = alternate.PName; model.Position = cPosition; model.UpdateDate = DateTime.Now; model.Updater = "系统管理员"; model.WarningVal = WarningVal; model.TagID = eid; model.TagID_A = alternate.TagID; } bPosition = cPosition; bdid = cdid; pcount++; } } } }
/// <summary> /// 资料上传《对外接口》 /// </summary> /// <param name="files">文件列表</param> /// <param name="Modules">所属模块</param> /// <param name="fk_id">ID</param> /// <param name="FSource">来源</param> /// <param name="FileType">资料类型(图片,视频)</param> /// <param name="Remark">备注</param> /// <param name="CommitUser">上传用户</param> /// <returns>0表示未登录,1表示成功,2表示太大 3上传失败,网络超时</returns> public ActionResult MultiUpload(IEnumerable <HttpPostedFileBase> files, string Modules, int fk_id, string FSource, string Remark, string CommitUser) { string reCode = "0"; try { double maxsize = 1024; //设置文件上传路径 string pathForSaving = "";// Server.MapPath("~/UploadFiles/" + Modules + DateTime.Now.ToString("yyMM")); //检查目录是否存在,如果不存在,则新建目录 string filename, filePath, fileExtension, saveName; //原文件名称,文件路径,文件后缀,文件重命名 int fileSize; //文件大小 byte[] FileData; //获取文件信息 double fileSizeKB; //转换文件大小,单位KB string fSize; //文件大小完整,如:54KB string FileType = "unknow"; //文件类型 t_cm_files obj; string[] pic = { ".jpg", ".jpeg", ".bmp", ".png", ".gif" }; string[] ved = { ".avi", ".rmvb", ".mp4", ".flv", ".wmv", ".mkv", ".mpeg" }; string[] voi = { ".wav", ".mp3", ".wma", ".ogg", ".ape", ".acc", ".3gp" }; // 遍历文件 foreach (var file in files) { if (file != null && file.ContentLength > 0) { filename = file.FileName; fileExtension = Path.GetExtension(filename); //文件扩展名 saveName = DateTime.Now.Ticks + fileExtension; //文件重命名 //根据判断文件类型 string LFE = fileExtension.ToLower(); if (pic.Contains(LFE)) { FileType = "image"; } else if (ved.Contains(LFE)) { FileType = "infrared"; } else if (voi.Contains(LFE)) { FileType = "voice"; } pathForSaving = Server.MapPath("~/UploadFiles/" + Modules + DateTime.Now.ToString("yyMM") + "/" + FileType); //判断文件是否存在 if (this.CreateFolderIfNeeded(pathForSaving)) { //上传资料 var path = Path.Combine(pathForSaving, saveName); file.SaveAs(path);//上传资料到服务器 FileData = ReadFileBytes(file); fileSize = FileData.Length; fileSizeKB = fileSize / 1024; fileSizeKB = Math.Round(fileSizeKB, 2); if (ConfigurationManager.AppSettings[Modules + "size"] != null) { maxsize = Convert.ToDouble(ConfigurationManager.AppSettings[Modules + "size"]); } //判断资料大小 //if (fileSizeKB > maxsize) //{ // reCode = "2"; // break; //} //else //{} fSize = fileSizeKB + "KB"; //文件大小限制(后期添加) filePath = "~/UploadFiles/" + Modules + DateTime.Now.ToString("yyMM") + "/" + FileType + "/" + saveName; //保存到资料库 obj = new t_cm_files(); obj.CommitTime = DateTime.Now; obj.CommitUser = CommitUser; obj.FileName = filename; obj.FilePath = filePath; obj.FileExtension = fileExtension; obj.FileSize = fSize; obj.FileType = FileType; obj.Fk_ID = fk_id; obj.FSource = FSource; obj.MaxTemp = 0; obj.MinTemp = 0; obj.Remark = Remark; obj.Modules = Modules; bll.t_cm_files.AddObject(obj); bll.SaveChanges(); } } } reCode = "1"; } catch (Exception ex) { reCode = "3"; } return(Content(reCode)); }
public ActionResult SaveDataTransferInfo(t_CM_DataTransfer info) { string result = "OK"; try { List <t_CM_DataTransfer> list = bll.t_CM_DataTransfer.Where(p => p.SysCode == info.SysCode && p.ID != info.ID).ToList(); if (list.Count > 0) { result = "此子站名称已存在,请重新录入! "; } else { if (info.ID > 0) { t_CM_DataTransfer DataTransferInfo = bll.t_CM_DataTransfer.Where(r => r.ID == info.ID).First(); DataTransferInfo.SysCode = info.SysCode; DataTransferInfo.SysName = info.SysName; DataTransferInfo.address = info.address; DataTransferInfo.SetupDate = info.SetupDate; DataTransferInfo.CommStatus = info.CommStatus; DataTransferInfo.UploadDate = info.UploadDate; DataTransferInfo.SysVersion = info.SysVersion; DataTransferInfo.SysUpdateDate = info.SysUpdateDate; DataTransferInfo.pointLimit = info.pointLimit; DataTransferInfo.timeLimit = info.timeLimit; DataTransferInfo.CenterIP = info.CenterIP; DataTransferInfo.CenterPort = info.CenterPort; DataTransferInfo.UserName = info.UserName; DataTransferInfo.Pwd = info.Pwd; DataTransferInfo.DBType = info.DBType; DataTransferInfo.DBName = info.DBName; DataTransferInfo.ConnectString = info.ConnectString; if (info.Remarks != null) { DataTransferInfo.Remarks = Server.HtmlEncode(info.Remarks).Replace("\n", "<br>"); } else { DataTransferInfo.Remarks = info.Remarks; } bll.ObjectStateManager.ChangeObjectState(DataTransferInfo, EntityState.Modified); bll.SaveChanges(); Common.InsertLog("子站管理", CurrentUser.UserName, "编辑子站管理信息[" + DataTransferInfo.SysCode + "]"); } else { if (info.Remarks != null) { info.Remarks = info.Remarks.Replace("\n", "<br>"); } else { info.Remarks = info.Remarks; } info.UseState = "0"; bll.t_CM_DataTransfer.AddObject(info); bll.SaveChanges(); Common.InsertLog("子站管理", CurrentUser.UserName, "新增子站管理信息[" + info.SysCode + "]"); } } } catch (Exception ex) { result = ex.ToString(); result = "出错了!"; } return(Content(result)); }
public ActionResult SaveSupplierInfo(t_CM_SupplierInfo supplier) { string result = "0"; try { List <t_CM_SupplierInfo> list = bll.t_CM_SupplierInfo.Where(d => (d.SupplierCode == supplier.SupplierCode || d.SupplierName == supplier.SupplierName) && d.SupplierID != supplier.SupplierID).ToList(); if (list.Count > 0) { result = "此供应商名称或编码已存在,请重新录入!"; } else { //编辑 if (supplier.SupplierID > 0) { t_CM_SupplierInfo info = bll.t_CM_SupplierInfo.Where(d => d.SupplierID == supplier.SupplierID).First(); info.SupplierID = supplier.SupplierID; info.SupplierCode = supplier.SupplierCode; info.SupplierName = supplier.SupplierName; info.Contacter = supplier.Contacter; info.MobilePhone = supplier.MobilePhone; info.Telephone = supplier.Telephone; info.SupplierAddress = supplier.SupplierAddress; info.PID = supplier.PID; info.UseState = supplier.UseState; if (supplier.Remarks != null) { info.Remarks = supplier.Remarks.Replace("\n", "<br>"); } else { info.Remarks = supplier.Remarks; } bll.ObjectStateManager.ChangeObjectState(info, EntityState.Modified); bll.SaveChanges(); result = "ok1"; Common.InsertLog("供应商管理", CurrentUser.UserName, "编辑供应商信息[" + info.SupplierName + "(" + info.SupplierCode + ")_" + info.SupplierID + "]"); } else { //新增 if (supplier.Remarks != null) { supplier.Remarks = supplier.Remarks.Replace("\n", "<br>"); } else { supplier.Remarks = supplier.Remarks; } bll.t_CM_SupplierInfo.AddObject(supplier); bll.SaveChanges(); result = "ok2"; Common.InsertLog("供应商管理", CurrentUser.UserName, "新增供应商信息[" + supplier.SupplierName + "(" + supplier.SupplierCode + ")]"); } } return(Content(result)); } catch (Exception ex) { return(Content(ex.ToString())); } }
public ActionResult SaveSparePartInfo(t_CM_SparePartInfo sparepart) { string result = "0"; try { //编辑 if (sparepart.SparePartID > 0) { t_CM_SparePartInfo info = bll.t_CM_SparePartInfo.Where(d => d.SparePartID == sparepart.SparePartID).First(); info.SparePartID = sparepart.SparePartID; info.SparePartCode = sparepart.SparePartCode; info.SparePartName = sparepart.SparePartName; info.StockCount = sparepart.StockCount; info.SupplierID = sparepart.SupplierID; info.EadoCode = sparepart.EadoCode; info.UseState = sparepart.UseState; info.pid = sparepart.pid; if (sparepart.Remarks != null) { info.Remarks = sparepart.Remarks.Replace("\n", "<br>"); } else { info.Remarks = sparepart.Remarks; } bll.ObjectStateManager.ChangeObjectState(info, EntityState.Modified); bll.SaveChanges(); result = "ok1"; Common.InsertLog("备件管理", CurrentUser.UserName, "编辑备件信息[" + info.SparePartName + "(" + info.SparePartCode + ")_" + info.SparePartID + "]"); } else { List <t_CM_SparePartInfo> list = bll.t_CM_SparePartInfo.Where(d => (d.SparePartCode == sparepart.SparePartCode || d.SparePartName == sparepart.SparePartName) && d.SparePartID != sparepart.SparePartID).ToList(); if (list.Count > 0) { result = "此备件名称或编码已存在,请重新录入!"; } else { //新增 if (sparepart.Remarks != null) { sparepart.Remarks = sparepart.Remarks.Replace("\n", "<br>"); } else { sparepart.Remarks = sparepart.Remarks; } bll.t_CM_SparePartInfo.AddObject(sparepart); bll.SaveChanges(); result = "ok2"; Common.InsertLog("备件管理", CurrentUser.UserName, "新增备件信息[" + sparepart.SparePartName + "(" + sparepart.SparePartCode + ")]"); } } return(Content(result)); } catch (Exception ex) { return(Content(ex.ToString())); } }
public static string doImport2003(DataSet tDS, int Mode) { StringBuilder Result = new StringBuilder(); string TagIDs = ""; int errorCount = 0; try { pdermsWebEntities bll = new pdermsWebEntities(); //检验excel表格中的数据是否符合格式 //检查列数是否与数据库一致 if (tDS.Tables[0].Columns.Count == 42) { for (int i = 0; i < tDS.Tables[0].Rows.Count; i++) { string MDate = tDS.Tables[0].Rows[i][1].ToString(); string Val = tDS.Tables[0].Rows[i][2].ToString(); for (int j = 0; j < tDS.Tables[0].Columns.Count; j++) { //检查TagID if (tDS.Tables[0].Rows[i][0].ToString() == "") { Result.Append("错误:第" + i + "列,缺少TagID。<br>"); errorCount++; } else { TagIDs += tDS.Tables[0].Rows[i][0].ToString() + ","; } //检查DID if (tDS.Tables[0].Rows[i][2].ToString() == "") { Result.Append("错误:第" + i + "列,缺少DID。<br>"); errorCount++; } //检查实时库索引 if (tDS.Tables[0].Rows[i][14].ToString() == "") { Result.Append("错误:第" + i + "列,缺少实时库索引。<br>"); errorCount++; } //检查PID if (tDS.Tables[0].Rows[i][15].ToString() == "") { Result.Append("错误:第" + i + "列,缺少PID。<br>"); errorCount++; } } } } else { Result.Append("错误:列数错误。\r"); errorCount++; } string pointSQL = "SELECT * FROM t_CM_PointsInfo WHERE TagID in (" + TagIDs.TrimEnd(',') + ")"; List <t_CM_PointsInfo> list = bll.ExecuteStoreQuery <t_CM_PointsInfo>(pointSQL).ToList(); if (list.Count > 0) { //覆盖模式下删除重复数据 if (Mode > 0) { list.ForEach(i => { bll.AttachTo("t_CM_PointsInfo", i); bll.t_CM_PointsInfo.DeleteObject(i); }); bll.SaveChanges(); } else { foreach (t_CM_PointsInfo p in list) { Result.Append("错误:数据库中已经存在 TagID = " + p.TagID + "的行。<br>"); errorCount++; } } } StringBuilder strSQL = new StringBuilder(); if (errorCount < 1) { //关闭标识 strSQL.Append("set IDENTITY_INSERT t_CM_PointsInfo ON "); //插入数据库 for (int i = 0; i < tDS.Tables[0].Rows.Count; i++) { strSQL.Append("insert into t_CM_PointsInfo (TagID,TagName,DID,DataTypeID,Position,MPID,UseState,PIOID,ABCID,Remarks,数据类型,设备点名,中文描述,站内点号,实时库索引,PID,通信地址,例外报告死区,工程下限,工程上限,码值下限,码值上限,远动数据类型,报警下限1,报警上限1,报警定义,置0说明,置1说明,单位,分组,最大间隔时间,小信号切除值,报警下限2,报警上限2,报警下限3,报警上限3,报警死区,报警级别,报警方式,速率报警限制,初始值,传感器SN编码) "); strSQL.Append("values (" + "" + tDS.Tables[0].Rows[i][0] + "," + "'" + tDS.Tables[0].Rows[i][1] + "'," + "" + tDS.Tables[0].Rows[i][2] + "," + "" + tDS.Tables[0].Rows[i][3] + "," + "'" + tDS.Tables[0].Rows[i][4] + "'," + "" + tDS.Tables[0].Rows[i][5] + "," + "" + tDS.Tables[0].Rows[i][6] + "," + "" + tDS.Tables[0].Rows[i][7] + "," + "" + tDS.Tables[0].Rows[i][8] + "," + "'" + tDS.Tables[0].Rows[i][9] + "'," + "'" + tDS.Tables[0].Rows[i][10] + "'," + "'" + tDS.Tables[0].Rows[i][11] + "'," + "'" + tDS.Tables[0].Rows[i][12] + "'," + "'" + tDS.Tables[0].Rows[i][13] + "'," + "" + tDS.Tables[0].Rows[i][14] + "," + "" + tDS.Tables[0].Rows[i][15] + "," + "" + tDS.Tables[0].Rows[i][16] + "," + "" + tDS.Tables[0].Rows[i][17] + "," + "" + tDS.Tables[0].Rows[i][18] + "," + "" + tDS.Tables[0].Rows[i][19] + "," + "" + tDS.Tables[0].Rows[i][20] + "," + "" + tDS.Tables[0].Rows[i][21] + "," + "'" + tDS.Tables[0].Rows[i][22] + "'," + "" + tDS.Tables[0].Rows[i][23] + "," + "" + tDS.Tables[0].Rows[i][24] + "," + "" + tDS.Tables[0].Rows[i][25] + "," + "'" + tDS.Tables[0].Rows[i][26] + "'," + "'" + tDS.Tables[0].Rows[i][27] + "'," + "'" + tDS.Tables[0].Rows[i][28] + "'," + "" + tDS.Tables[0].Rows[i][29] + "," + "" + tDS.Tables[0].Rows[i][30] + "," + "" + tDS.Tables[0].Rows[i][31] + "," + "" + tDS.Tables[0].Rows[i][32] + "," + "" + tDS.Tables[0].Rows[i][33] + "," + "" + tDS.Tables[0].Rows[i][34] + "," + "" + tDS.Tables[0].Rows[i][35] + "," + "" + tDS.Tables[0].Rows[i][36] + "," + "" + tDS.Tables[0].Rows[i][37] + "," + "" + tDS.Tables[0].Rows[i][38] + "," + "" + tDS.Tables[0].Rows[i][39] + "," + "" + tDS.Tables[0].Rows[i][40] + "," + "'" + tDS.Tables[0].Rows[i][41] + "')"); } strSQL.Append("set IDENTITY_INSERT t_CM_PointsInfo OFF"); bll.ExecuteStoreCommand(strSQL.ToString()); Result.Append("OK"); } return(Result.ToString()); } catch (Exception e) { string a = e.ToString(); return(a); } }
/// <summary> /// 向应急预案表中添加记录。 /// </summary> /// <param name="EmergencyPlan">应急预案记录</param> /// <returns>true:表示保存成功,false:表示保存失败</returns> private bool AddEmergencyPlanInfo(t_PM_EmergencyPlan EmergencyPlan) { bool flag = false; try { bll.t_PM_EmergencyPlan.AddObject(EmergencyPlan); bll.SaveChanges(); flag = true; } catch (Exception ex) { flag = false; } return(flag); }
public ActionResult DelAlarmById(int AlarmID, string AlarmTreatment) { try { string PDRList = HomeController.GetPID(CurrentUser.UNITList); //string PDRList = CurrentUser.PDRList; if (!PDRList.Equals("")) { string sSql = "update [t_AlarmTable_en] set AlarmState = 0,AlarmTreatment = '" + AlarmTreatment + "',AlarmConfirm='已确认',UserName='******',ConfirmDate='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "' where PID in (" + PDRList + ") and AlarmConfirm='未确认' and AlarmState>0 and AlarmID=" + AlarmID; bll.ExecuteStoreCommand(sSql); if (AlarmTreatment != null && AlarmTreatment.Contains("真实"))//添加隐患,并且下发工单; { List <t_AlarmTable_en> list = bll.t_AlarmTable_en.Where(p => p.AlarmID == AlarmID).ToList(); if (list != null && list.Count > 0) { try { t_AlarmTable_en alarm = list.First(); t_PM_Order order = new t_PM_Order(); order.PID = alarm.PID; t_CM_PDRInfo pdrinfo = bll.t_CM_PDRInfo.Where(p => p.PID == alarm.PID).ToList().First(); order.PName = pdrinfo.Name; try { string c = pdrinfo.Coordination; string[] xx = c.Split('|'); order.Latitude = decimal.Parse(xx[1]); order.Longtitude = decimal.Parse(xx[0]); } catch { } order.OrderName = order.PName + "应急抢修" + DateTime.Now; List <t_CM_Constract> ll = bll.t_CM_Constract.Where(p => p.CtrPid == alarm.PID).ToList(); if (ll == null || ll.Count <= 0) { return(Content("报警已确认!\n未找到合同中的负责人!\n自动下发工单失败,请手工处理!")); } t_CM_Constract t = ll.First(); string sql = "SELECT * FROM t_CM_UserInfo WHERE UserName='******'"; List <t_CM_UserInfo> listUsers = bll.ExecuteStoreQuery <t_CM_UserInfo>(sql).ToList(); if (listUsers == null | listUsers.Count <= 0) { return(Content("报警已确认!\n未找到工单需要下发的人员!\n自动下发工单失败,请手工处理!")); } order.UserName = t.person;//根据pid,类型查找合同,到名字; order.PlanDate = DateTime.Now; order.UserID = listUsers.First().UserID; order.Priority = 1; order.OrderNO = DateTime.Now.Ticks + ""; order.OrderType = "应急抢修"; order.DressCodeID = 2; order.OrderState = 0; //0待接收 1已受理 2已完成 order.IsQualified = -1; //-1 未检查 0不合格 1合格 order.CreateDate = DateTime.Now; order.Creater = CurrentUser.UserName; order.OrderTypeId = 3; order.OrderContent = "报警内容:" + alarm.ALarmType + ";" + alarm.AlarmDateTime + ";" + alarm.AlarmCate + ";" + ValueReset((double)alarm.AlarmValue, alarm.AlarmCate) + ";" + alarm.AlarmAddress + ";" + alarm.AlarmArea + ";" + alarm.Company + "。已确认为真实故障,请立即检修。"; bll.t_PM_Order.AddObject(order); bll.SaveChanges(); //发送短信; Result a = UtilsSms.smsOrderAdd(order.UserName, order.OrderName, bll); AddBugInfo(AlarmID); return(Content("报警已确认!" + "\n\n" + parserContent(a))); } catch (Exception ex) { string error = ex.ToString(); return(Content("报警已确认!\n自动下发工单失败,请手工处理!")); } } } return(Content("报警已确认!")); } else { return(Content("没有权限,报警未确认!")); } } catch (Exception ex) { string error = ex.ToString(); return(Content("报警确认失败!")); } }