public Stream CreateReport(string patrolno) { string reportid = String.Empty; bool success = false; Console.WriteLine("特巡编号" + patrolno); try { //将特巡报告ID进行加密 reportid = CreateReportId(); Console.WriteLine(reportid); success = PatrolEntity.CreateReportUri(reportid, patrolno); } catch (Exception ex) { Console.WriteLine("报告书失败" + ex.Message); #region 日志输出 CommonInfo.Error("创建特巡报告书错误" + ex.Message); #endregion } if (!success) { reportid = String.Empty; } MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(reportid)); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
/// <summary> /// 分公司列表类型转换 /// </summary> /// <param name="source">数据字典列表</param> /// <returns></returns> public static List <NodeInfo> List2Tree(List <SUBCOMPANYMST> source) { List <NodeInfo> list = new List <NodeInfo>(); try { if (source != null && source.Count > 0) { foreach (SUBCOMPANYMST item in source) { NodeInfo temp = new NodeInfo(); temp.code = item.SUBCOMPANYCD; temp.name = item.SUBCOMPANYNM; list.Add(temp); } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("User分公司转换列表错误" + ex.Message); #endregion } return(list); }
/// <summary> /// 列表类型转换 /// </summary> /// <param name="source">数据字典列表</param> /// <returns></returns> public static List <NodeInfo> List2Tree(List <PatrolCodeMst> source) { List <NodeInfo> list = new List <NodeInfo>(); try { if (source != null && source.Count > 0) { foreach (PatrolCodeMst item in source) { NodeInfo temp = new NodeInfo(); temp.code = item.CodeCD; temp.name = item.CodeName; list.Add(temp); } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("特巡数据字典转换错误" + ex.Message); #endregion } return(list); }
/// <summary> /// 列表类型转换 /// </summary> /// <param name="source">数据字典列表</param> /// <returns></returns> public static List <ServerInfo> List2Tree(List <PatrolServerList> source) { List <ServerInfo> list = new List <ServerInfo>(); try { if (source != null && source.Count > 0) { foreach (PatrolServerList item in source) { ServerInfo temp = new ServerInfo(); temp.address = item.Address; temp.name = item.Name; temp.isMainServer = item.IsMainServer; temp.website_url = item.WebsiteUrl; list.Add(temp); } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("手机端特巡服务器转换列表发生错误" + ex.Message); #endregion } return(list); }
/// <summary> /// 机型列表类型转换 /// </summary> /// <param name="source">数据字典列表</param> /// <returns></returns> public static List <NodeInfo> List2Tree(List <MACHINETYPEMST> source) { List <NodeInfo> list = new List <NodeInfo>(); try { if (source != null && source.Count > 0) { foreach (MACHINETYPEMST item in source) { NodeInfo temp = new NodeInfo(); temp.code = item.MACHINECD; temp.name = item.MACHINENM; list.Add(temp); } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("手机端机型转换列表发生错误" + ex.Message); #endregion } return(list); }
/// <summary> /// 获取服务器列表 /// </summary> /// <returns></returns> public Stream GetServerList() { ResGetServerList response = new ResGetServerList(); try { //*.取得机型列表 List <ServerInfo> server_list = List2Tree(PatrolServerListRule.GetList()); //组织数据 response.server_list = server_list; //输出成功状态 response.SetSuccess(); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("手机端获取服务器列表错误" + ex.Message); #endregion } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetServerList)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
public Stream GetBaseInfo() { ResGetBaseInfo response = new ResGetBaseInfo(); try { //*.取得机型列表 List <NodeInfo> modelList = List2Tree(MACHINETYPEMSTRule.GetList()); //*.取得点检部位树形菜单 List <PatrolSpotParts> spotPartsListBase = PatrolSpotPartsRule.GetList(); List <NodeInfo> checkList = SpotPartsList2Tree(spotPartsListBase); //*.取得机器状态列表 List <NodeInfo> machineStatusList = List2Tree(PatrolCodeMstRule.GetListOfMachineStatus()); //*.取得问题程度列表 List <NodeInfo> questionLevelList = List2Tree(PatrolCodeMstRule.GetListOfQuestionLevel()); //*.取得点检状态列表 List <NodeInfo> spotStatusList = List2Tree(PatrolCodeMstRule.GetListOfSpotStatus()); //*.取得联系方式列表 List <NodeInfo> contactTypeList = List2Tree(PatrolCodeMstRule.GetListOfContactType()); //*.取得联系人类型列表 List <NodeInfo> contactorTypeList = List2Tree(PatrolCodeMstRule.GetListOfContactorType()); //组织数据 response.model_list = modelList; response.check_list = checkList; response.machine_status_list = machineStatusList; response.level_list = questionLevelList; response.spot_status_list = spotStatusList; response.phone_type_list = contactTypeList; response.contact_type_list = contactorTypeList; //输出成功状态 response.SetSuccess(); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("手机端获取基础数据错误" + ex.Message); #endregion } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetBaseInfo)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
/// <summary> /// 展示某个特巡报告,用于生成报表数据 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream ShowReport(string reportid) { #region 查找数据 ResShowReport response = new ResShowReport(); bool success = false; try { if (reportid != null && reportid != String.Empty) { string patrolno = PatrolEntity.getPatrolNobyReportId(reportid); if (patrolno != null && patrolno != String.Empty) { DataTable header = PatrolEntity.getPatrolHeader4Report(patrolno); DataTable detail = PatrolEntity.getPatrolDetail4Report(patrolno); //DataTable facadeList = PatrolEntity.getFacadeList4Report(patrolno); List <PatrolDetailInfo> detailList = ResShowReport.getPatrolDetailList(detail); response.patrol_header = ResShowReport.getPatrolHeader(header); response.facade_list = ResShowReport.getFacadeImageList(detailList); response.patrol_detail_list = detailList; //设置成功状态 success = true; } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("显示特巡报告书数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResShowReport)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// 将代理店分公司员工转换为树形列表 /// </summary> /// <param name="source">点检部位列表</param> /// <returns></returns> public static List <NodeInfo> GetCompanyTree(List <COMPANYMST> company, List <SUBCOMPANYMST> subcompany, List <StaffUserInfo> staff) { List <NodeInfo> tree = new List <NodeInfo>(); try { if (company != null && company.Count > 0) { foreach (COMPANYMST com in company) { NodeInfo companyTree = new NodeInfo(); companyTree.code = com.COMPANYCD; companyTree.name = com.COMPANYNM; companyTree.sub_list = new List <NodeInfo>(); List <SUBCOMPANYMST> subList = subcompany.Where(p => p.COMPANYCD == com.COMPANYCD).ToList <SUBCOMPANYMST>(); foreach (SUBCOMPANYMST sub in subList) { NodeInfo subTree = new NodeInfo(); subTree.code = sub.SUBCOMPANYCD; subTree.name = sub.SUBCOMPANYNM; subTree.sub_list = new List <NodeInfo>(); List <StaffUserInfo> staffList = staff.Where(p => p.subcompanycd == sub.SUBCOMPANYCD).ToList <StaffUserInfo>(); foreach (StaffUserInfo staffuser in staffList) { NodeInfo temp = new NodeInfo(); temp.code = staffuser.staffcd; temp.name = staffuser.staffname; //分公司下所有员工 subTree.sub_list.Add(temp); } //代理店下分公司 companyTree.sub_list.Add(subTree); } //所有代理店 tree.Add(companyTree); } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("代理店分公司员工转换树形数据错误" + ex.Message); #endregion } return(tree); }
/// <summary> /// 导出Excel文件 /// </summary> /// <param name="patrolno"></param> /// <returns></returns> public Stream ExportExcel(string patrolno) { #region 查找数据 ResExportExcel response = new ResExportExcel(); bool success = false; try { if (patrolno != null && patrolno != String.Empty && patrolno != "undefined") { ExcelEntity en = new ExcelEntity(); ResShowReport data = en.GetData(patrolno);//"PRN2017071800003"); //随机文件夹防止同时访问一个文件 string dirName = DateTime.Now.ToString("yyyyMMdd") + "\\" + data.patrol_header.report_uri; string excelFileName = dirName + "\\" + CreateReportId(); response.excel_filename = excelFileName + CommonInfo.PDFExtend; //设置成功状态 success = en.ExportExcel(data, dirName, excelFileName); } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("显示特巡报告书数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResExportExcel)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// 将点检部位列表转换为树形列表 /// </summary> /// <param name="source">点检部位列表</param> /// <returns></returns> public static List <NodeInfo> SpotPartsList2Tree(List <PatrolSpotParts> source) { List <NodeInfo> tree = new List <NodeInfo>(); try { if (source != null && source.Count > 0) { List <PatrolSpotParts> partsList = source.Where(p => p.ParentID == "root").ToList <PatrolSpotParts>(); foreach (PatrolSpotParts item in partsList) { NodeInfo subTree = new NodeInfo(); subTree.code = item.ID; subTree.name = item.Name; List <PatrolSpotParts> subList = source.Where(p => p.ParentID == item.ID).ToList <PatrolSpotParts>(); List <NodeInfo> subNode = new List <NodeInfo>(); foreach (PatrolSpotParts instance in subList) { NodeInfo temp = new NodeInfo(); temp.code = instance.ID; temp.name = instance.Name; subNode.Add(temp); } subTree.sub_list = subNode; tree.Add(subTree); } } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("手机端点检部位转换列表发生错误" + ex.Message); #endregion } return(tree); }
/// <summary> /// 获取用户列表 /// </summary> /// <returns></returns> public Stream GetUserList() { ResGetUserList response = new ResGetUserList(); try { //获取数据调用数据库接口 DataTable dt = UserEntity.getUserList4App(); UserListInfo userlist = new UserListInfo(); List <UserInfo> userinfoList = ResGetUserList.Transfer(dt); userlist.count = UserEntity.getUserCount4App(); userlist.list = userinfoList; //组织数据 response.userlist = userlist; //输出成功状态 response.SetSuccess(); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("手机端获取用户列表错误" + ex.Message); #endregion } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetUserList)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
/// <summary> /// 字节数组存储为文件 /// </summary> /// <param name="data"></param> /// <returns></returns> private static string Save2File(string dirname, byte[] data) { string fileName = GenerateFileName(DateTime.Now.Millisecond); string fileExt = ".jpg"; string fileFullName = fileName + fileExt; string tempDir = CommonInfo.ImageTempUrl + "/" + dirname; try { //创建临时文件夹,以日期为名称 if (!Directory.Exists(tempDir)) { Console.WriteLine("新创建" + tempDir); #region 日志输出 CommonInfo.Log("新创建" + tempDir); #endregion Directory.CreateDirectory(tempDir); } FileStream fs = new FileStream(tempDir + "/" + fileFullName, FileMode.Create, FileAccess.ReadWrite); fs.Write(data, 0, data.Length); fs.Close(); //裁剪图片 CommonInfo.ImageProcess(tempDir + "/" + fileFullName); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("保存图片错误" + ex.Message); #endregion return(String.Empty); } Console.WriteLine("图片保存成功"); return(fileFullName); }
private static bool getImageData(MemoryStream source, int start) { BinaryReader br = new BinaryReader(source, Encoding.UTF8); byte[] dataSource = source.ToArray(); try { //设置流位置 source.Position = start; int intBoundary = 0; for (int i = start; i < dataSource.Length - 2; i++) { if (dataSource[i] == 13 && dataSource[i + 1] == 10) { intBoundary = i + 1; break; } } //获得分隔符 source.Position = start; byte[] boundary = br.ReadBytes(intBoundary + 1); //头部数据 int bodyStart = 0; for (int i = start + intBoundary + 1; i < dataSource.Length - 2; i++) { if (dataSource[i] == 13 && dataSource[i + 1] == 10 && dataSource[i + 2] == 13 && dataSource[i + 3] == 10) { bodyStart = i + 3; break; } } //解析头部数据 source.Position = start + intBoundary + 1; byte[] hdata = br.ReadBytes(bodyStart - 4 - intBoundary + 1); //减去\r\n\r\n string sdata = Encoding.UTF8.GetString(hdata); //获取下一个分隔符位置 来取得数据体范围 int bodyEnd = 0; source.Position = start + bodyStart + 1; //最后一个分隔符多了一个\r\n long dataEnd = dataSource.Length - 2 - boundary.Length; //最后一个分隔符 除去 for (int i = bodyStart + 1; i < dataEnd; i++) { byte[] temp = br.ReadBytes(boundary.Length); if (temp == boundary) { bodyEnd = i - 1; break; } } //如果取得数据,最后一个文件块 if (bodyEnd == 0) { bodyEnd = (int)dataEnd; } //处理数据体 source.Position = start + bodyStart + 1; byte[] dataBuffer = br.ReadBytes(bodyEnd - bodyStart + 1); //取得文件名 string fileinfo = Save2File("Helloworld", dataBuffer); int nextStart = (int)source.Position + boundary.Length + 1; if (bodyEnd != dataEnd) { getImageData(source, nextStart); } } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取图片数据错误" + ex.Message); #endregion return(false); } return(true); }
/// <summary> /// 上传特巡报告 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream UploadPatrolInformation(Stream data) { #region 查找数据 ResUploadPatrolInformation response = new ResUploadPatrolInformation(); bool success = false; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqUploadPatrolInformation)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqUploadPatrolInformation request = new ReqUploadPatrolInformation(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqUploadPatrolInformation; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { #region **********(此处加入代码) 根据查询条件 加入业务逻辑代码************* // 身份验证 if (request.user_id != String.Empty && request.token != String.Empty) { PatrolReportHeader header = ReportService.getHeader(request); List <PatrolReportDetail> detailList = ReportService.getDetailList(request, header, request.dir_name); success = PatrolEntity.InsertPatrol(header, detailList); if (success) { //将点检图片存到正式文件夹 if (request.dir_name != null && request.dir_name != String.Empty) { string saveDir = CommonInfo.ImageSaveUrl + "/" + request.dir_name; string tempDir = CommonInfo.ImageTempUrl + "/" + request.dir_name; if (Directory.Exists(tempDir)) { if (success) { //将临时文件夹拷贝到正式文件夹 Directory.Move(tempDir, saveDir); success = true; //事务成功完成 response.patrol_id = request.patrol_id; } } } } } #endregion } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("上传特巡报告错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResUploadPatrolInformation)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// web登录验证 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream WebLogin(Stream data) { #region 查找数据 ResWebLogin response = new ResWebLogin(); bool success = false; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqWebLogin)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqWebLogin request = new ReqWebLogin(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqWebLogin; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //**********(此处加入代码) 根据查询条件 加入业务逻辑代码************* string token = PatrolUserInfoRule.LoginCheck(request.user_id, request.password); if (token != String.Empty) { success = true; } //验证成功后 获取用户数据 if (success) { if (request.user_id != null && request.user_id != String.Empty) { DataTable user = UserEntity.getUserInfo(request.user_id); response.user = ResWebLogin.getUserInfo(user); //设置成功状态 success = true; } } } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("Web登录发生错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResWebLogin)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// 重置用户密码 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream ResetPassword(Stream data) { bool success = false; ResResetPassword response = new ResResetPassword(); try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqResetPassword)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqResetPassword request = new ReqResetPassword(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqResetPassword; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //*.数据合法性检查 //*.更新 if (request.account != null && request.user_id != null) { success = PatrolUserInfoRule.ResetPassword(request.user_id, request.account); } } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("重置密码错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResResetPassword)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
/// <summary> /// 取得基础数据 用于查询用户条件 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream GetUserBase(Stream data) { #region 查找数据 ResGetUserBase response = new ResGetUserBase(); bool success = true; try { UserBaseInfo userbase = new UserBaseInfo(); ////代理店信息列表 //List<NodeInfo> agency_shop_list = List2Tree(COMPANYMSTRule.GetList()); ////分公司信息列表 //List<NodeInfo> filiale_list = List2Tree(SUBCOMPANYMSTRule.GetList()); //代理店信息列表 List <COMPANYMST> agency_shop_list = COMPANYMSTRule.GetList(); //分公司信息列表 List <SUBCOMPANYMST> filiale_list = SUBCOMPANYMSTRule.GetList(); //代理店分公司树形结构数据 List <NodeInfo> company_list = GetCompanyTree(agency_shop_list, filiale_list); //userbase.agency_shop_list = agency_shop_list; //userbase.filiale_list = filiale_list; userbase.company_list = company_list; //组织数据 response.userbase = userbase; //输出成功状态 success = true; } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取用户列表数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetUserBase)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// 取得基础数据 用于查询特巡报告条件 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream GetPatrolBase(Stream data) { #region 查找数据 ResGetPatrolBase response = new ResGetPatrolBase(); bool success = false; try { PatrolBaseInfo patrolbase = new PatrolBaseInfo(); #region 单独处理 未启用 ////代理店信息列表 //List<NodeInfo> agency_shop_list = List2Tree(COMPANYMSTRule.GetList()); ////分公司信息列表 //List<SUBCOMPANYMST> filiale_list = List2Tree(SUBCOMPANYMSTRule.GetList()); ////报告人信息列表(建友用户系统) //List<NodeInfo> reporter_list = List2Tree(STAFFMSTRule.GetList()); #endregion //代理店信息列表 List <CompanyInfo> agency_shop_list = ResGetPatrolBase.Transfer(COMPANYMSTRule.GetList()); //分公司信息列表 List <SubCompanyInfo> filiale_list = ResGetPatrolBase.Transfer(SUBCOMPANYMSTRule.GetList()); ////报告人信息列表(建友用户系统) List <StaffInfo> reporter_list = ResGetPatrolBase.Transfer(BaseEntity.getStaffListInPatrol()); ////代理店分公司树形结构数据 //List<NodeInfo> company_list = GetCompanyTree(agency_shop_list, filiale_list, reporter_list); //机型信息列表 List <NodeInfo> machine_type_list = List2Tree(MACHINETYPEMSTRule.GetList());; //机器状态信息列表 List <NodeInfo> machine_status_list = List2Tree(PatrolCodeMstRule.GetListOfMachineStatus()); //*.取得点检部位树形菜单 List <PatrolSpotParts> spotPartsListBase = PatrolSpotPartsRule.GetList(); List <NodeInfo> checkList = SpotPartsList2Tree(spotPartsListBase); //组织数据 patrolbase.agency_shop_list = agency_shop_list; patrolbase.filiale_list = filiale_list; patrolbase.reporter_list = reporter_list; patrolbase.machine_type_list = machine_type_list; patrolbase.machine_status_list = machine_status_list; patrolbase.check_list = checkList; response.patrolbase = patrolbase; //输出成功状态 success = true; } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡基础数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetPatrolBase)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
public Stream DeleteUser(Stream data) { #region 查找数据 ResDeleteUser response = new ResDeleteUser(); bool success = true; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqDeleteUser)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqDeleteUser request = new ReqDeleteUser(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqDeleteUser; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //**********(此处加入代码) 根据查询条件 加入业务逻辑代码************* if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty) { string user = getDeleteUserSqlString(request); success = UserEntity.deleteUser(user); } } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡列表数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResDeleteUser)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
public Stream AddUser(Stream data) { #region 查找数据 ResAddUser response = new ResAddUser(); bool success = true; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqAddUser)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqAddUser request = new ReqAddUser(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqAddUser; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //**********(此处加入代码) 根据查询条件 加入业务逻辑代码************* if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty) { if (request.user != null) { Console.WriteLine("开始新增用户"); PatrolUserInfo userinfo = new PatrolUserInfo(); userinfo.UserCD = request.user.user_id; userinfo.UserPassword = CommonInfo.DefaultPassword + userinfo.UserCD; userinfo.SearchRange = SetSearchRange(request.user.search_range); userinfo.IsAdmin = SetAdmin(request.user.isadmin); userinfo.IsAvailable = "1"; userinfo.CreatedAt = DateTime.Now; userinfo.Creator = request.account; Console.WriteLine("我的测试数据" + userinfo.IsAdmin); success = UserEntity.InsertUser(userinfo); } } else { Console.WriteLine("用户验证失败"); } } else { Console.WriteLine("请求对象为空"); } } sr.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡列表数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResAddUser)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// 登录验证接口 接口编号 = 1006 /// </summary> /// <param name="data">Post数据</param> /// <returns></returns> public Stream LoginCheck(Stream data) { System.ServiceModel.Channels.Message o = OperationContext.Current.RequestContext.RequestMessage; bool success = false; ResLoginCheck response = new ResLoginCheck(); try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqLoginCheck)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqLoginCheck request = new ReqLoginCheck(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqLoginCheck; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //*.数据合法性检查 //*.更新 response.token = PatrolUserInfoRule.LoginCheck(request.user_id, request.password); if (response.token != String.Empty) { success = true; } } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡列表数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResLoginCheck)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
/// <summary> /// 取得特巡报告列表 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream GetPatrolList(Stream data) { int starttime = Environment.TickCount; Console.WriteLine("特巡开始时间:" + starttime); #region 查找数据 ResGetPatrolList response = new ResGetPatrolList(); bool success = true; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqGetPatrolList)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqGetPatrolList request = new ReqGetPatrolList(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqGetPatrolList; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { #region **********(此处加入代码) 根据查询条件 加入业务逻辑代码************* // 身份验证 if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty) { // sql查询字符串组织 string queryString = String.Empty; string rangeString = String.Empty; // 按条件查询 if (request.search_info != null) { #region 属性查询对应 if (request.search_info.AgencyShop != null && request.search_info.AgencyShop != String.Empty) { queryString += " and sta.CompanyCD = '" + request.search_info.AgencyShop + "' "; } if (request.search_info.Customer != null && request.search_info.Customer != String.Empty) { queryString += " and t.ContactorName1 like '%" + request.search_info.Customer + "%' "; } if (request.search_info.MachineStatus != null && request.search_info.MachineStatus != String.Empty) { queryString += " and t.MachineStatus = '" + request.search_info.MachineStatus + "' "; } if (request.search_info.Filiale != null && request.search_info.Filiale != String.Empty) { queryString += " and sta.SubCompanyCD = '" + request.search_info.Filiale + "' "; } if (request.search_info.HasErrorImage != null && request.search_info.HasErrorImage != String.Empty) { string haserror = request.search_info.HasErrorImage.Trim().ToUpper(); if (haserror == "0") { //无不正常图片 queryString += " and dc.ErrImageCount is null "; } else { //所有不正常图片 queryString += " and dc.ErrImageCount > 0 "; } } if (request.search_info.IsEmergency != null && request.search_info.IsEmergency != String.Empty) { //前台过来的是true和false 需要转换 string istrue = (request.search_info.IsEmergency.Trim().ToLower() == "true") ? "1" : "0"; queryString += " and t.IsEmergency = '" + istrue + "' "; } if (request.search_info.MachineNO != null && request.search_info.MachineNO != String.Empty) { queryString += " and t.MachineNO like '%" + request.search_info.MachineNO + "%' "; } if (request.search_info.MachineType != null && request.search_info.MachineType != String.Empty) { queryString += " and t.MachineType = '" + request.search_info.MachineType + "' "; } if (request.search_info.LocationCode != null && request.search_info.LocationCode != String.Empty) { queryString += " and d.LocationCode = '" + request.search_info.LocationCode + "' "; } if (request.search_info.SpotCode != null && request.search_info.SpotCode != String.Empty) { queryString += " and d.SpotCode = '" + request.search_info.SpotCode + "' "; } if (request.search_info.Remarks != null && request.search_info.Remarks != String.Empty) { queryString += " and d.Remarks like '%" + request.search_info.Remarks + "%' "; } if (request.search_info.ReportDateStart != null && request.search_info.ReportDateStart != String.Empty) { queryString += " and t.ReportDate >= '" + request.search_info.ReportDateStart + "' "; } if (request.search_info.ReportDateClosed != null && request.search_info.ReportDateClosed != String.Empty) { queryString += " and t.ReportDate <= '" + request.search_info.ReportDateClosed + "' "; } if (request.search_info.Reporter != null && request.search_info.Reporter != String.Empty) { queryString += " and t.Reporter = '" + request.search_info.Reporter + "' "; } if (request.search_info.ReportStatus != null && request.search_info.ReportStatus != String.Empty) { queryString += " and t.ReportStatus = '" + request.search_info.ReportStatus + "' "; } //分页控制对象范围 int pageIndex = 1; int pageSize = 10; if (request.search_info.Paginator != null) { pageIndex = request.search_info.Paginator.PageIndex; pageIndex = pageIndex > 0 ? pageIndex : 1; pageSize = request.search_info.Paginator.PageSize; pageSize = pageSize > 0 ? pageSize : 10; int rangeStart = (pageIndex - 1) * pageSize + 1; int rangeEnd = pageIndex * pageSize; rangeString += " and orderno between " + rangeStart + " and " + rangeEnd + " "; } else { rangeString += " and orderno between " + pageIndex + " and " + pageSize + " "; } //获取数据调用数据库接口 DataTable dt = PatrolEntity.getPatrolList(queryString, rangeString); //转换数据 response.patrol_list = ResGetPatrolList.Transfer(dt); response.count = PatrolEntity.getPatrolCount(queryString); success = true; #endregion } } #endregion } } sr.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡列表数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); #region 日志输出 CommonInfo.Log("获取特巡列表成功 总数量" + response.count.ToString()); #endregion } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetPatrolList)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; Console.WriteLine("结束时间:" + (Environment.TickCount - starttime)); return(ms); #endregion }
/// <summary> /// 取得指定编号特巡报告 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream GetPatrol(Stream data) { #region 查找数据 ResGetPatrol response = new ResGetPatrol(); bool success = false; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqGetPatrol)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqGetPatrol request = new ReqGetPatrol(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqGetPatrol; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //**********(此处加入代码) 根据查询条件 加入业务逻辑代码************* if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty) { if (request.patrol_no != null && request.patrol_no != String.Empty) { DataTable header = PatrolEntity.getPatrolHeader(request.patrol_no); DataTable detail = PatrolEntity.getPatrolDetail(request.patrol_no); response.patrol_header = ResGetPatrol.getPatrolHeader(header); response.patrol_detail_list = ResGetPatrol.getPatrolDetailList(detail); //设置成功状态 success = true; } } } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡数据" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetPatrol)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
public Stream GetUserList(Stream data) { #region 查找数据 ResGetUserList response = new ResGetUserList(); bool success = true; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqGetUserList)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqGetUserList request = new ReqGetUserList(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqGetUserList; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null) { //**********(此处加入代码) 根据查询条件 加入业务逻辑代码************* // 身份验证 if (request.account != null && request.account != String.Empty && request.token != null && request.token != String.Empty) { //管理员权限验证 bool isAdmin = PatrolUserInfoRule.AdminCheck(request.account, request.token); if (isAdmin) { // sql查询字符串组织 string queryString = String.Empty; string rangeString = String.Empty; // 按条件查询 if (request.search_info != null) { #region 属性查询对应 if (request.search_info.agency_shop != null && request.search_info.agency_shop != String.Empty) { queryString += " and t.CompanyCD = '" + request.search_info.agency_shop + "' "; } if (request.search_info.filiale != null && request.search_info.filiale != String.Empty) { queryString += " and t.SubCompanyCD = '" + request.search_info.filiale + "' "; } if (request.search_info.user_id != null && request.search_info.user_id != String.Empty) { //用户编号或者名称 queryString += " and (t.StaffCD = '" + request.search_info.user_id + "' or t.StaffNM = '" + request.search_info.user_id + "' ) "; } //分页控制对象范围 int pageIndex = 1; int pageSize = 10; if (request.search_info.Paginator != null) { pageIndex = request.search_info.Paginator.PageIndex; pageIndex = pageIndex > 0 ? pageIndex : 1; pageSize = request.search_info.Paginator.PageSize; pageSize = pageSize > 0 ? pageSize : 10; int rangeStart = (pageIndex - 1) * pageSize + 1; int rangeEnd = pageIndex * pageSize; rangeString += " and orderno between " + rangeStart + " and " + rangeEnd + " "; } else { rangeString += " and orderno between " + pageIndex + " and " + pageSize + " "; } //获取数据调用数据库接口 DataTable dt = UserEntity.getUserList(queryString, rangeString); //转换数据 response.user_list = ResGetUserList.Transfer(dt); response.count = UserEntity.getUserCount(queryString); success = true; #endregion } } } } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("获取特巡列表数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResGetUserList)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }
/// <summary> /// 上传特巡图片 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream UploadImage(Stream data) { ResUploadImage response = new ResUploadImage(); MemoryStream source = new MemoryStream(); //FileStream fst = new FileStream("uploaddata.txt",FileMode.Open,FileAccess.ReadWrite); try { data.CopyTo(source); source.Position = 0; ReqUploadImage req = new ReqUploadImage(); List <MultipartParser> list = new List <MultipartParser>(); MultipartParser parser = new MultipartParser(source, 0); while (parser.Success) { list.Add(parser); int startPoint = parser.EndPoint + 2; source.Position = startPoint; parser = new MultipartParser(source, startPoint); } //保存图片 List <Response.Entity.PicInfo> imageList = new List <Response.Entity.PicInfo>(); if (list != null && list.Count > 0) { string dirName = GenerateDirName(DateTime.Now.Millisecond); req.user_id = Encoding.UTF8.GetString(list[0].FileContents); req.token = Encoding.UTF8.GetString(list[1].FileContents); Console.WriteLine(req.user_id); Console.WriteLine(req.token); if (req.user_id != null && req.user_id != String.Empty && req.token != null && req.token != String.Empty) { //用于判断图片是否全部保存成功 bool saveSuccess = true; for (int i = 2; i < list.Count; i++) { MultipartParser item = list[i]; Console.WriteLine(item.Filename + " --- " + item.FileContents.Length); Response.Entity.PicInfo image = new Response.Entity.PicInfo(); string filename = Save2File(dirName, item.FileContents); if (filename == String.Empty) { //保存失败 结束后续操作 LogWriter.MyLog.Error(dirName + "保存图片未获得文件名称"); saveSuccess = false; break; } image.image_name = item.Filename; image.pic_url = filename; imageList.Add(image); } response.model_list = imageList; response.dir_name = dirName; if (saveSuccess) { response.SetSuccess(); } else { response.SetFailed(); } } } #region 注释 ////重置流位置 //source.Position = 0; //BinaryReader br = new BinaryReader(source, Encoding.UTF8); //byte[] dataSource = source.ToArray(); //int intBoundary = 0; ////索引值 //for (int i = 0; i < dataSource.Length - 2; i++) //{ // if (dataSource[i] == 13 && dataSource[i + 1] == 10) // { // intBoundary = i + 1; // break; // } //} ////获得分隔符 //source.Position = 0; //byte[] boundary = br.ReadBytes(intBoundary + 1); ////头部数据 //int bodyStart = 0; //for (int i = intBoundary + 1; i < dataSource.Length - 2; i++) //{ // if (dataSource[i] == 13 && dataSource[i + 1] == 10 && dataSource[i + 2] == 13 && dataSource[i + 3] == 10) // { // bodyStart = i + 3; // break; // } //} ////解析头部数据 //source.Position = intBoundary + 1; //byte[] hdata = br.ReadBytes(bodyStart - 4 - intBoundary); //string sdata = Encoding.UTF8.GetString(hdata); ////获取下一个分隔符位置 来取得数据体范围 //int bodyEnd = 0; //source.Position = bodyStart + 1; ////最后一个分隔符多了一个\r\n //long dataEnd = dataSource.Length - 2 - boundary.Length; //最后一个分隔符 除去 //for (int i = bodyStart + 1; i < dataEnd; i++) //{ // byte[] temp = br.ReadBytes(boundary.Length); // if (temp == boundary) // { // bodyEnd = i - 1; // break; // } //} ////表单数据体 //source.Position = bodyStart + 1; //byte[] formData = br.ReadBytes(bodyEnd - bodyStart); //int nextStart = bodyEnd + boundary.Length + 1; ////图片数据 //getImageData(source, nextStart); #endregion } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("上传图片发生错误" + ex.Message); #endregion } source.Close(); //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResUploadImage)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); }
/// <summary> /// 删除特巡报告头表以及所有明细 /// </summary> /// <param name="data"></param> /// <returns></returns> public Stream DeletePatrol(Stream data) { #region 查找数据 ResDeletePatrol response = new ResDeletePatrol(); bool success = false; try { DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(ReqDeletePatrol)); //读取器 StreamReader sr = new StreamReader(data); string dataString = String.Empty; while (!sr.EndOfStream) { dataString = sr.ReadToEnd(); Console.WriteLine(dataString); #region 日志输出 CommonInfo.Log(dataString); #endregion //反序列化json为对象注意顺序很重要 ReqDeletePatrol request = new ReqDeletePatrol(); MemoryStream temp = new MemoryStream(Encoding.UTF8.GetBytes(dataString)); request = json.ReadObject(temp) as ReqDeletePatrol; //关闭临时流 temp.Close(); //调用用户更新密码接口 if (request != null && request.patrol_no.Length > 0 & request.account.Length > 0) { //**********(此处加入代码) 根据查询条件 加入业务逻辑代码************* Console.WriteLine("{0}正在删除特巡:{1}", request.account, request.patrol_no); #region 日志输出 CommonInfo.Log(request.account + "正在删除特巡:" + request.patrol_no); #endregion success = PatrolEntity.DeleteReport(request.patrol_no); } } sr.Close(); Console.WriteLine(data); } catch (Exception ex) { Console.WriteLine(ex.Message); #region 日志输出 CommonInfo.Error("删除特巡数据错误" + ex.Message); #endregion } //返回消息体 if (success) { response.SetSuccess(); } else { ////默认是失败 //response.SetFailed(); } //将消息序列化为Json格式数据 DataContractJsonSerializer obj2Json = new DataContractJsonSerializer(typeof(ResDeletePatrol)); MemoryStream ms = new MemoryStream(); obj2Json.WriteObject(ms, response); //注意一定要设置流的位置到开始位置,否则没有消息输出 ms.Position = 0; return(ms); #endregion }