/// <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> /// 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 }
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 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 }
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 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 }
/// <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 }
/// <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 }