private string SetPassWord(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SetPassWordRP> >(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); string error = ""; string pNewPass = MD5Helper.Encryption(rp.Parameters.pNewPWD); //pOldPWD = MD5Helper.Encryption(pOldPWD); rp.Parameters.pOldPWD = EncryptManager.Hash(rp.Parameters.pOldPWD, HashProviderType.MD5); string res = "{\"success\":\"false\",\"msg\":\"保存失败\"}"; //组装参数 JIT.CPOS.BS.Entity.User.UserInfo entity = new JIT.CPOS.BS.Entity.User.UserInfo(); var serviceBll = new cUserService(loggingSessionInfo); entity = serviceBll.GetUserById(loggingSessionInfo, rp.Parameters.pID); string apPwd = serviceBll.GetPasswordFromAP(loggingSessionInfo.ClientID, rp.Parameters.pID); //if (pOldPWD == entity.User_Password) if (rp.Parameters.pOldPWD == apPwd) { entity.userRoleInfoList = new cUserService(loggingSessionInfo).GetUserRoles(rp.Parameters.pID);//, PageBase.JITPage.GetApplicationId() entity.User_Password = pNewPass; entity.ModifyPassword = true; //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error); bool bReturn = serviceBll.SetUserPwd(loggingSessionInfo, pNewPass, out error); res = "{\"success\":\"true\",\"msg\":\"" + error + "\"}"; } else { res = "{\"success\":\"false\",\"msg\":\"旧密码不正确\"}"; } return(res); }
/// <summary> /// 下载用户配置信息接口(C006-下载门店用户(多个)配置信息接口) /// </summary> /// <param name="User_Id">用户标识</param> /// <param name="Customer_Id">客户标识</param> /// <param name="Unit_Id">门店标识</param> /// <returns>基础信息对象</returns> public BaseInfo GetUserBaseByUserId(string User_Id, string Customer_Id, string Unit_Id) { BaseInfo baseInfo = new BaseInfo(); baseInfo = new cUserService().GetUserBaseInfoByUserId(User_Id, Customer_Id, Unit_Id); return(baseInfo); }
private string SetPassWord(string pID, string pOldPWD, string pNewPWD) { string error = ""; string pNewPass = MD5Helper.Encryption(pNewPWD); //pOldPWD = MD5Helper.Encryption(pOldPWD); pOldPWD = EncryptManager.Hash(pOldPWD, HashProviderType.MD5); string res = "{success:false,msg:'保存失败'}"; //组装参数 UserInfo entity = new UserInfo(); var serviceBll = new cUserService(CurrentUserInfo); entity = serviceBll.GetUserById(CurrentUserInfo, pID); string apPwd = serviceBll.GetPasswordFromAP(CurrentUserInfo.ClientID, pID); //if (pOldPWD == entity.User_Password) if (pOldPWD == apPwd) { entity.userRoleInfoList = new cUserService(CurrentUserInfo).GetUserRoles(pID, PageBase.JITPage.GetApplicationId()); entity.User_Password = pNewPass; entity.ModifyPassword = true; //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error); bool bReturn = serviceBll.SetUserPwd(CurrentUserInfo, pNewPass, out error); res = "{success:true,msg:'" + error + "'}"; } else { res = "{success:false,msg:'旧密码不正确'}"; } return(res); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetPasswordRP> pRequest) { //基础数据初始化 string error = ""; EmptyResponseData emptyResponseData = new EmptyResponseData(); try { if (pRequest.Parameters.NewPassword.Length < 6) { throw new APIException("新密码不小于6位。") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } string newPassword = MD5Helper.Encryption(pRequest.Parameters.NewPassword); string oldPassword = EncryptManager.Hash(pRequest.Parameters.OldPassword, HashProviderType.MD5); //组装参数 UserInfo entity = new UserInfo(); var serviceBll = new cUserService(CurrentUserInfo); entity = serviceBll.GetUserById(CurrentUserInfo, CurrentUserInfo.UserID); string apPassword = serviceBll.GetPasswordFromAP(CurrentUserInfo.ClientID, CurrentUserInfo.UserID); if (oldPassword == apPassword) { entity.userRoleInfoList = new cUserService(CurrentUserInfo).GetUserRoles(CurrentUserInfo.UserID, PageBase.JITPage.GetApplicationId()); entity.User_Password = newPassword; entity.ModifyPassword = true; //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error); bool bReturn = serviceBll.SetUserPwd(CurrentUserInfo, newPassword, out error); if (!bReturn) { throw new APIException(error) { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } } else { throw new APIException("旧密码不正确") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } return(emptyResponseData); } catch (APIException apiEx) { throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.tbOldPwd.Text.Trim())) { this.InfoBox.ShowPopError("旧密码不能为空"); this.tbOldPwd.Focus(); return; } if (string.IsNullOrEmpty(this.tbNewPwd.Text.Trim())) { this.InfoBox.ShowPopError("新密码不能为空"); this.tbNewPwd.Focus(); return; } if (this.tbNewPwd.Text.Trim() != this.tbNewPwd2.Text.Trim()) { this.InfoBox.ShowPopError("新密码两次输入不一致"); this.tbNewPwd2.Focus(); return; } cUserService user_service = new cUserService(); string user_id = this.loggingSessionInfo.CurrentUser.User_Id; UserInfo user = user_service.GetUserById(this.loggingSessionInfo, user_id); if (user == null) { this.InfoBox.ShowPopError("当前用户不存在"); this.tbNewPwd.Focus(); return; } string old_pwd = EncryptManager.Hash(this.tbOldPwd.Text.Trim(), HashProviderType.MD5); if (!old_pwd.Equals(user.User_Password)) { this.InfoBox.ShowPopError("旧密码不正确"); this.tbOldPwd.Focus(); return; } string new_pwd = this.tbNewPwd.Text.Trim(); if (!user_service.IsValidPassword(loggingSessionInfo, user, new_pwd)) { this.InfoBox.ShowPopError("新密码无效"); this.tbNewPwd.Focus(); return; } if (user_service.ModifyUserPassword(this.loggingSessionInfo, user_id, new_pwd)) { this.InfoBox.ShowPopInfo("密码修改成功"); this.Response.Redirect("~/common/emtpy.aspx"); } else { this.InfoBox.ShowPopError("密码修改失败"); } }
private void SetPushInfo() { LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); loggingSessionInfo = new CLoggingSessionService().GetLoggingSessionInfo("f6a7da3d28f74f2abedfc3ea0cf65c01", "17e02a6dd0094de9b18da1ca73d37027"); string strOrderId = "1b4c3bfb63884f0b86bd4b5c771bccaf"; cUserService userServer = new cUserService(loggingSessionInfo); userServer.SendOrderMessage(strOrderId); }
//下载员工二维码 新 #region 导入用户 public string ImportUser() { var responseData = new ResponseData(); var userService = new cUserService(CurrentUserInfo); ExcelHelper excelHelper = new ExcelHelper(); if (Request("filePath") != null && Request("filePath").ToString() != "") { try { var rp = new ImportRP(); string strPath = Request("filePath").ToString(); string strFileName = string.Empty; DataSet ds = userService.ExcelToDb(HttpContext.Current.Server.MapPath(strPath), CurrentUserInfo); if (ds != null && ds.Tables.Count > 1 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { Workbook wb = JIT.Utility.DataTableExporter.WriteXLS(ds.Tables[0], 0); string savePath = HttpContext.Current.Server.MapPath(@"~/File/ErrFile/User"); if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } strFileName = "\\用户错误信息导出" + DateTime.Now.ToFileTime() + ".xls"; savePath = savePath + strFileName; wb.Save(savePath);//保存Excel文件 rp = new ImportRP() { Url = "/File/ErrFile/User" + strFileName, TotalCount = Convert.ToInt32(ds.Tables[1].Rows[0]["TotalCount"].ToString()), ErrCount = Convert.ToInt32(ds.Tables[1].Rows[0]["ErrCount"].ToString()) }; } else { rp = new ImportRP() { Url = "", TotalCount = Convert.ToInt32(ds.Tables[1].Rows[0]["TotalCount"].ToString()), ErrCount = Convert.ToInt32(ds.Tables[1].Rows[0]["ErrCount"].ToString()) }; responseData.success = true; } responseData.success = true; responseData.data = rp; } catch (Exception err) { responseData.success = false; responseData.msg = err.Message.ToString(); } } return(responseData.ToJSON()); }
/// <summary> ///返回用户信息、客户信息及用户所属门店的信息集合。(C005-下载用户信息与所属门店关系接口) /// </summary> /// <param name="User_Id">用户标识</param> /// <param name="Customer_Id">客户标识</param> /// <returns>返回用户model对象</returns> public UserInfo GetUserInfoByUserId(string User_Id, string Customer_Id) { UserInfo userInfo = new UserInfo(); cUserService userServices = new cUserService(); LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); loggingSessionInfo = new BaseService().GetLoggingSessionInfoByCustomerId(Customer_Id); userInfo = userServices.GetUserById(loggingSessionInfo, User_Id); userInfo.LoggingManagerInfo = loggingSessionInfo.CurrentLoggingManager; userInfo.UnitList = new UnitService().GetUnitListByUserId(loggingSessionInfo, User_Id); return(userInfo); }
private void loadUser(string customer_id, string token) { try { //获取登录管理平台的用户信息 AuthService AuthWebService = new AuthService(); //设置地址 AuthWebService.Url = ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx"; string str = AuthWebService.GetLoginUserInfo(token); cPos.Model.LoggingManager myLoggingManager = (cPos.Model.LoggingManager)cXMLService.Deserialize(str, typeof(cPos.Model.LoggingManager)); //判断登录进来的用户是否存在,并且返回用户信息 cPos.Service.cUserService userService = new cUserService(); LoggingSessionInfo loggingSession = new LoggingSessionInfo(); loggingSession.CurrentLoggingManager = myLoggingManager; if (!userService.IsExistUser(myLoggingManager)) { this.lbErr.Text = "用户不存在,请与管理员联系"; return; } cPos.Model.User.UserInfo login_user = userService.GetUserById(loggingSession, myLoggingManager.User_Id); loggingSession.CurrentUser = login_user; //SessionManager sm = new SessionManager(); //sm.UserInfo = login_user; //sm.LoggingManager = myLoggingManager; //sm.loggingSessionInfo = loggingSession; this.Session["UserInfo"] = login_user; this.Session["LoggingManager"] = myLoggingManager; this.Session["loggingSessionInfo"] = loggingSession; //保存Cookie //HttpCookie cookie = new HttpCookie("DRP"); //cookie.Values.Add("userid", login_user.User_Id); //cookie.Values.Add("username", login_user.User_Name); //cookie.Values.Add("languageid", ddlLanguage.SelectedItem.Value); //cookie.Expires = DateTime.Now.AddDays(7); //Response.AppendCookie(cookie); //清空密码 login_user.User_Password = null; string go_url = "~/login/SelectRoleUnit.aspx?p=0"; this.Response.Redirect(go_url); } catch (Exception ex) { PageLog.Current.Write(ex); lbErr.Text = "登录失败:" + ex.ToString(); } }
private void SetDexUserCertificate() { cUserService userService = new cUserService(); string customer_code = "IOSDLB"; cPos.Model.User.UserInfo userInfo = new cPos.Model.User.UserInfo(); userInfo.User_Id = "11111"; userInfo.User_Password = "******"; userInfo.User_Code = "11"; userInfo.customer_id = "11111"; //userService.SetDexUserCertificate(customer_code, userInfo); }
public string RevertPassword() { string user_id = Request("user"); var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } string error = ""; // var responseData = new ResponseData(); try { UserInfo user = new UserInfo(); var userService = new cUserService(loggingSessionInfo); //使用兼容模式 userService.SetUserPwd(loggingSessionInfo, user_id, MD5Helper.Encryption(Request("password")), out error); //使用兼容模式 responseData.success = true; } catch (Exception) { responseData.success = false; responseData.msg = "密码重置失败"; } return(responseData.ToJSON()); }
/// <summary> /// 获取登录用户的具体信息 /// </summary> /// <param name="cid">客户id</param> /// <param name="tid">令牌id</param> /// <returns></returns> public LoggingSessionInfo GetLoggingSessionInfo(string cid, string tid) { //获取登录管理平台的用户信息 var AuthWebService = new JIT.CPOS.BS.WebServices.AuthManagerWebServices.AuthServiceSoapClient(); AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress( ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx"); string str = AuthWebService.GetLoginUserInfo(tid); LoggingManager myLoggingManager = (LoggingManager)cXMLService.Deserialize(str, typeof(LoggingManager)); //判断用户是否存在,并且返回用户信息 UserInfo login_user = new UserInfo(); LoggingSessionInfo loggingSessionInfo1 = new LoggingSessionInfo(); loggingSessionInfo1.CurrentLoggingManager = myLoggingManager; cUserService userService = new cUserService(loggingSessionInfo1); //获取用户信息 if (userService.IsExistUser(loggingSessionInfo1)) { login_user = userService.GetUserById(loggingSessionInfo1, myLoggingManager.User_Id); } else { login_user.User_Id = "1"; } LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); loggingSessionInfo.CurrentUser = login_user; loggingSessionInfo.CurrentLoggingManager = myLoggingManager; UserRoleInfo ur = new UserRoleInfo(); ur.RoleId = "7064243380E24B0BA24E4ADC4E03968B"; ur.UnitId = "1"; loggingSessionInfo.CurrentUserRole = ur; return(loggingSessionInfo); }
/// <summary> /// 获取登录的model信息 /// </summary> /// <param name="Customer_Id">客户标识</param> /// <param name="User_Id">用户标识</param> /// <param name="Unit_Id">组织标识</param> /// <returns></returns> public LoggingSessionInfo GetLoggingSessionInfo(string Customer_Id, string User_Id, string Unit_Id) { UserInfo userInfo = new UserInfo(); cUserService userServices = new cUserService(); LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); UserRoleInfo userRoleInfo = new UserRoleInfo(); loggingSessionInfo = new BaseService().GetLoggingSessionInfoByCustomerId(Customer_Id); userInfo = userServices.GetUserById(loggingSessionInfo, User_Id); userInfo.LoggingManagerInfo = loggingSessionInfo.CurrentLoggingManager; userRoleInfo.UnitId = Unit_Id; userRoleInfo.RoleId = "7064243380E24B0BA24E4ADC4E03968B"; loggingSessionInfo.CurrentUserRole = userRoleInfo; loggingSessionInfo.CurrentUser = userInfo; return(loggingSessionInfo); }
/// <summary> /// 获取员工信息 /// </summary> public string GetUserList(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <GetUserListRP> >();//不需要参数 //string userId = rp.UserID; //string customerId = rp.CustomerID; var pageSize = rp.Parameters.PageSize; var pageIndex = rp.Parameters.PageIndex; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo); var userService = new cUserService(loggingSessionInfo); string PhoneList = ""; if (!string.IsNullOrEmpty(rp.Parameters.PhoneList)) { string[] phones = rp.Parameters.PhoneList.Split(new char[] { ',' }); string propIds = ""; foreach (var itemInfo in phones)//数组,更新数据 { if (!string.IsNullOrEmpty(itemInfo)) { if (propIds != "") { propIds += ","; } propIds += "'" + itemInfo + "'"; } } PhoneList = propIds; } var rd = new GetUserListRD(); var ds = userService.GetUserList(pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType, loggingSessionInfo.UserID, loggingSessionInfo.ClientID, PhoneList , rp.Parameters.UnitID); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { rd.UserList = DataTableToObject.ConvertToList <UserInfo>(ds.Tables[1]);//直接根据所需要的字段反序列化 rd.TotalCount = ds.Tables[0].Rows.Count; rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(ds.Tables[0].Rows.Count * 1.00 / (pageSize ?? 15) * 1.00))); } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
/// <summary> /// 获取列表 /// </summary> public string GetListData() { var service = new cUserService(new SessionManager().CurrentUserLoginInfo); IList <UserInfo> data = new List <UserInfo>(); string content = string.Empty; string key = "YearEvent"; data = service.GetUserListByRoleCode(key); var jsonData = new JsonData(); jsonData.totalCount = data.Count.ToString(); jsonData.data = data; content = jsonData.ToJSON(); return(content); }
/// <summary> /// 修改密码 /// </summary> /// <param name="User_Id">访问的用户标识</param> /// <param name="Customer_Id">访问的客户标识</param> /// <param name="Unit_Id">访问的组织标识</param> /// <param name="userId">需要修改的用户标识</param> /// <param name="userPwd">需要修改的密码</param> /// <returns></returns> public bool SetUserPassword(string User_Id, string Customer_Id, string Unit_Id, string userId, string userPwd) { UserInfo userInfo = new UserInfo(); cUserService userServices = new cUserService(); LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); loggingSessionInfo = new BaseService().GetLoggingSessionInfoByCustomerId(Customer_Id); string strError = string.Empty; cUserService userService = new cUserService(); bool b = userService.ModifyUserPassword_JK(loggingSessionInfo, userId, userPwd, out strError); if (b) { return(b); } else { throw new Exception(string.Format(strError, strError)); return(b); } }
public string setUser() { string content = string.Empty; var respData = new setUserRespData(); try { string reqContent = Request["ReqContent"]; Loggers.Debug(new DebugLogInfo() { Message = string.Format("setUser: {0}", reqContent) }); //解析请求字符串 var reqObj = reqContent.DeserializeJSONTo <setUserReqData>(); reqObj = reqObj == null ? new setUserReqData() : reqObj; #region 处理参数 //判断客户ID是否传递 if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); if (reqObj.special == null) { reqObj.special = new setUserReqSpecialData(); } if (reqObj.special == null) { respData.code = "102"; respData.description = "没有特殊参数"; return(respData.ToJSON().ToString()); } if (reqObj.special.userId == null || reqObj.special.userId.Equals("")) { respData.code = "2201"; respData.description = "userId不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.userCode == null || reqObj.special.userCode.Equals("")) { respData.code = "2201"; respData.description = "userCode不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.userName == null || reqObj.special.userName.Equals("")) { respData.code = "2201"; respData.description = "userName不能为空"; return(respData.ToJSON().ToString()); } if (reqObj.special.password == null || reqObj.special.password.Length == 0) { respData.code = "2201"; respData.description = "password不能为空"; return(respData.ToJSON().ToString()); } #endregion #region 处理业务 cUserService userService = new cUserService(loggingSessionInfo); var user = new UserInfo(); user.customer_id = customerId; user.User_Id = reqObj.special.userId; user.User_Code = reqObj.special.userCode; user.User_Name = reqObj.special.userName; user.User_Password = reqObj.special.password; user.User_Status = "1"; user.Fail_Date = "9999-12-31"; user.User_Telephone = reqObj.special.telephone; user.User_Email = reqObj.special.email; user.userRoleInfoList = new List <UserRoleInfo>(); user.userRoleInfoList.Add(new UserRoleInfo() { Id = Utils.NewGuid(), RoleId = "", UserId = reqObj.special.userId, Status = "1" }); user.Create_Time = Utils.GetNow(); user.Create_User_Id = loggingSessionInfo.CurrentUser.User_Id; user.Modify_Time = Utils.GetNow(); user.Modify_User_Id = loggingSessionInfo.CurrentUser.User_Id; string error = ""; var flag = userService.SetUserInfo(user, user.userRoleInfoList, out error); if (!flag) { respData.code = "103"; respData.description = error; return(respData.ToJSON().ToString()); } #endregion } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); Loggers.Debug(new DebugLogInfo() { Message = string.Format("setSignUp content: {0}", content) }); return(content); }
protected void btnLogin_Click(object sender, EventArgs e) { //string customerCode = this.txtCustomerCode.Value.Trim(); string account = this.txtUsername.Value.Trim(); string pwd = this.txtPassword.Value.Trim(); //string authCode = txtValidateCode.Text.Trim(); //将用户登录名密码提交到服务器检验 //if (string.IsNullOrEmpty(customerCode) || customerCode == "公司编码") //{ // lblInfor.Text = "请输入公司编码!"; // txtCustomerCode.Focus(); // return; //} if (string.IsNullOrEmpty(account) || account == "用户名") { lblInfor.Text = "请输入用户名!"; txtUsername.Focus(); return; } if (string.IsNullOrEmpty(pwd)) { lblInfor.Text = "请输入密码!"; txtPassword.Focus(); return; } Hashtable ht = new Hashtable(); UserInfo login_user = null; var loggingSessionInfo = GetLjLoggingSession(); var service = new cUserService(loggingSessionInfo); try { int ret = 0; var userList = service.SearchUserList(account, "", "", "", 1, 0); if (userList != null && userList.UserInfoList != null && userList.UserInfoList.Count > 0) { login_user = userList.UserInfoList[0]; login_user.customer_id = "43753855ae814fc093c281441972f8f1"; if (login_user.User_Status == "-1") { ret = -2; } else if (login_user.User_Password != EncryptManager.Hash(pwd, HashProviderType.MD5)) { ret = -3; } else { ret = 1; } } else { ret = -1; } switch (ret) { case -1: lblInfor.Text = "用户不存在"; return; case -2: lblInfor.Text = "用户被停用"; return; case -3: lblInfor.Text = "密码不正确"; return; case -4: lblInfor.Text = "用户不在线"; return; case 1: //用户名和密码验证通过 break; default: lblInfor.Text = "用户名和密码不正确"; return; } } catch { lblInfor.Text = "用户名和密码不正确"; return; } // chkRemember if (chkRemember.Checked) { Response.Cookies["cpos_sso_remember"].Value = "1"; Response.Cookies["cpos_sso_remember"].Expires = DateTime.MaxValue; Response.Cookies["cpos_sso_user"].Value = account; Response.Cookies["cpos_sso_user"].Expires = DateTime.MaxValue; Response.Cookies["cpos_sso_pwd"].Value = pwd; Response.Cookies["cpos_sso_pwd"].Expires = DateTime.MaxValue; } else { Response.Cookies["cpos_sso_remember"].Value = ""; Response.Cookies["cpos_sso_user"].Value = ""; Response.Cookies["cpos_sso_pwd"].Value = ""; } //判断登录进来的用户是否存在,并且返回用户信息 LoggingSessionInfo loggingSession = new LoggingSessionInfo(); loggingSession.CurrentLoggingManager = new LoggingManager(); loggingSession.CurrentLoggingManager.Connection_String = loggingSessionInfo.Conn; loggingSession.CurrentLoggingManager.Customer_Id = loggingSessionInfo.CurrentUser.customer_id; loggingSession.CurrentUser = login_user; // 获取角色 string applicationId = PageBase.JITPage.GetApplicationId(); IList <UserRoleInfo> userRoleList = service.GetUserRoles(login_user.User_Id, applicationId); if (userRoleList != null && userRoleList.Count > 0) { loggingSession.CurrentUserRole = new UserRoleInfo(); loggingSession.CurrentUserRole.UserId = login_user.User_Id; loggingSession.CurrentUserRole.UserName = login_user.User_Name; loggingSession.CurrentUserRole.RoleId = userRoleList[0].RoleId; loggingSession.CurrentUserRole.RoleName = userRoleList[0].RoleName; loggingSession.ClientID = login_user.customer_id; loggingSession.CurrentLoggingManager.Customer_Id = login_user.customer_id; loggingSession.UserID = loggingSession.CurrentUser.User_Id; try { loggingSession.CurrentUserRole.UnitId = service.GetDefaultUnitByUserIdAndRoleId( loggingSession.CurrentUserRole.UserId, loggingSession.CurrentUserRole.RoleId); } catch (Exception ex) { PageLog.Current.Write(ex); Response.Write("找不到默认单位"); Response.End(); } //try //{ // loggingSession.CurrentUserRole.UnitName = unitService.GetUnitById( // loggingSessionInfo, loggingSession.CurrentUserRole.UnitId).ShortName; //} //catch (Exception ex) //{ // PageLog.Current.Write(ex); // Response.Write("找不到单位"); // Response.End(); //} } //this.Session["UserInfo"] = login_user; //this.Session["LoggingManager"] = myLoggingManager; //this.Session["loggingSessionInfo"] = loggingSession; //loggingSession.CurrentLoggingManager = myLoggingManager; new SessionManager().SetCurrentUserLoginInfo(loggingSession); //清空密码 login_user.User_Password = null; string goURL = "~/Default.aspx"; this.Response.Redirect(goURL); }
/// <summary> /// 查询用户 /// </summary> public string GetUserListData() { var form = Request("form").DeserializeJSONTo <UserQueryEntity>(); var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } var userService = new cUserService(loggingSessionInfo); UserInfo data; string content = string.Empty; string user_code = form.user_code == null ? string.Empty : form.user_code; string user_name = form.user_name == null ? string.Empty : form.user_name; string user_tel = form.user_tel == null ? string.Empty : form.user_tel; string user_status = form.user_status == null ? string.Empty : form.user_status; string para_unit_id = form.unit_id ?? ""; string role_id = form.role_id ?? ""; //int maxRowCount = PageSize; int maxRowCount = Utils.GetIntVal(Request("limit")); int startRowIndex = Utils.GetIntVal(Request("start")); string NameOrPhone = form.NameOrPhone == null ? string.Empty : form.NameOrPhone; string key = string.Empty; if (Request("id") != null && Request("id") != string.Empty) { key = Request("id").ToString().Trim(); } data = userService.SearchUserListByUnitID( //SearchUserListByUnitID user_code, user_name, user_tel, user_status, maxRowCount, startRowIndex, CurrentUserInfo == null?"": CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, role_id, NameOrPhone); var jsonData = new JsonData(); jsonData.totalCount = data.ICount.ToString(); jsonData.data = data.UserInfoList; content = string.Format("{{\"success\":{2},\"msg\":{3},\"totalCount\":{1},\"topics\":{0}}}", data.UserInfoList.ToJSON(), data.ICount , 1, "\"\""); return(content); }
public string DeleteData2() { var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } var service = new cUserService(loggingSessionInfo);//使用兼容模式 string content = string.Empty; string error = ""; // var responseData = new ResponseData(); string key = string.Empty; if (FormatParamValue(Request("ids")) != null && FormatParamValue(Request("ids")) != string.Empty) { key = FormatParamValue(Request("ids")).ToString().Trim(); } if (key == null || key.Trim().Length == 0) { responseData.success = false; responseData.msg = "ID不能为空"; return(responseData.ToJSON()); } string[] ids = key.Split(','); foreach (var id in ids) { // service.SetUserStatus(key, status, CurrentUserInfo); service.physicalDeleteUser(id); } responseData.success = true; responseData.msg = error; content = responseData.ToJSON(); return(content); }
/// <summary> /// 保存用户 /// </summary> public string SaveUserData() { var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } var userService = new cUserService(loggingSessionInfo);//兼容模式 UserInfo user = new UserInfo(); string content = string.Empty; string error = ""; // var responseData = new ResponseData(); string key = string.Empty; string user_id = string.Empty; if (Request("user") != null && Request("user") != string.Empty) { key = Request("user").ToString().Trim(); } if (Request("user_id") != null && Request("user_id") != string.Empty) { user_id = Request("user_id").ToString().Trim(); } user = key.DeserializeJSONTo <UserInfo>(); if (userService.IsExistUserCode(user.User_Code, loggingSessionInfo, user_id))//使用兼容模式 { responseData.success = false; responseData.msg = "用户名已存在!"; return(responseData.ToJSON()); } if (user.User_Status == null || user.User_Status.Trim().Length == 0) { user.User_Status = "1"; } if (user_id.Trim().Length == 0 && string.IsNullOrEmpty(user.User_Password))//新增用户才需要提交密码 { responseData.success = false; responseData.msg = "用户密码不能为空"; return(responseData.ToJSON()); } if (user_id.Trim().Length == 0) { user.User_Id = Utils.NewGuid(); //user.UnitList = loggingSessionInfo.CurrentUserRole.UnitId; } else { user.User_Id = user_id; } if (user.User_Code == null || user.User_Code.Trim().Length == 0) { responseData.success = false; responseData.msg = "用户名不能为空"; return(responseData.ToJSON()); } if (user.User_Name == null || user.User_Name.Trim().Length == 0) { responseData.success = false; responseData.msg = "姓名不能为空"; return(responseData.ToJSON()); } //if (user.Fail_Date == null || user.Fail_Date.Trim().Length == 0) //{ // responseData.success = false; // responseData.msg = "用户有效日期不能为空"; // return responseData.ToJSON(); //} user.Fail_Date = "2030-12-30";//转换成最大的日期 //if (user.User_Telephone == null || user.User_Telephone.Trim().Length == 0) //{ // responseData.success = false; // responseData.msg = "用户手机不能为空"; // return responseData.ToJSON(); //} //if (user.User_Email == null || user.User_Email.Trim().Length == 0) //{ // responseData.success = false; // responseData.msg = "用户邮箱不能为空"; // return responseData.ToJSON(); //} if (user.userRoleInfoList == null || user.userRoleInfoList.Count == 0) { responseData.success = false; responseData.msg = "请添加角色配置"; return(responseData.ToJSON()); } //设为归属单位有且只能有一个*** int countDefaultFlag = user.userRoleInfoList.Where(p => p.DefaultFlag == 1).Count(); if (countDefaultFlag < 1) { responseData.success = false; responseData.msg = "必须设置一个单位为归属单位"; return(responseData.ToJSON()); } if (countDefaultFlag > 1) { responseData.success = false; responseData.msg = "只能设置一个单位为默认单位"; return(responseData.ToJSON()); } UserRoleInfo roleinfo = user.userRoleInfoList.Where(p => p.DefaultFlag == 1).ToArray()[0]; t_unitBLL t_unitBLL = new BLL.t_unitBLL(loggingSessionInfo);//使用兼容模式 t_unitEntity UnitEn = t_unitBLL.GetByID(roleinfo.UnitId); string unitName = ""; if (UnitEn != null && UnitEn.unit_name != null) { unitName = UnitEn.unit_name; } //增加用户标识 foreach (var userRoleItem in user.userRoleInfoList) { userRoleItem.UserId = user.User_Id; } user.Create_Time = Utils.GetNow(); user.Create_User_Id = loggingSessionInfo.CurrentUser.User_Id; //使用兼容模式 user.Modify_Time = Utils.GetNow(); user.Modify_User_Id = loggingSessionInfo.CurrentUser.User_Id; //使用兼容模式 userService.SetUserInfo(user, user.userRoleInfoList, out error); #region 生成员工二维码 /** * //微信 公共平台 * var wapentity = new WApplicationInterfaceBLL(CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity * { * CustomerId = CurrentUserInfo.ClientID, * IsDelete = 0 * }, null).FirstOrDefault();//取默认的第一个微信 * * var QRCodeId = Guid.NewGuid(); * var QRCodeManagerentity = new WQRCodeManagerBLL(this.CurrentUserInfo).QueryByEntity(new WQRCodeManagerEntity * { * ObjectId = user.User_Id * }, null).FirstOrDefault(); * if (QRCodeManagerentity != null) * { * QRCodeId = (Guid)QRCodeManagerentity.QRCodeId; * } * if (QRCodeManagerentity == null) * { * //二维码类别 * var wqrentity = new WQRCodeTypeBLL(this.CurrentUserInfo).QueryByEntity( * new WQRCodeTypeEntity { TypeCode = "UserQrCode" } * , null).FirstOrDefault(); * if (wqrentity == null) * { * responseData.success = false; * responseData.msg = "无法获取员工二维码类别"; * return responseData.ToJSON(); * } * //生成了微信二维码 * var wxCode = CretaeWxCode(); * //如果名称不为空,就把图片放在一定的背景下面 * if (!string.IsNullOrEmpty(user.User_Name)) * { * string apiDomain = ConfigurationManager.AppSettings["original_url"]; * wxCode.ImageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", wxCode.ImageUrl, unitName + "-" + user.User_Name); * } * * var WQRCodeManagerbll = new WQRCodeManagerBLL(CurrentUserInfo); * * // Guid QRCodeId = Guid.NewGuid(); * * if (!string.IsNullOrEmpty(wxCode.ImageUrl)) * { * WQRCodeManagerbll.Create(new WQRCodeManagerEntity * { * QRCodeId = QRCodeId, * QRCode = wxCode.MaxWQRCod.ToString(), * QRCodeTypeId = wqrentity.QRCodeTypeId, * IsUse = 1, * ObjectId = user.User_Id, * CreateBy = CurrentUserInfo.UserID, * ApplicationId = wapentity.ApplicationId, * IsDelete = 0, * ImageUrl = wxCode.ImageUrl, * CustomerId = CurrentUserInfo.ClientID * * }); * } * * * } * * * **/ #endregion string errorMsg = ""; //下载的时候再生成,这里就不生成了,业务太多 // string wxCodeImageUrl = CreateUserWxCode(user, unitName,loggingSessionInfo, out errorMsg); if (errorMsg != "") { responseData.success = false; responseData.msg = errorMsg; return(responseData.ToJSON()); } responseData.success = true; responseData.msg = error; content = responseData.ToJSON(); return(content); }
/// <summary> /// 通过ID获取用户角色信息 /// </summary> public string GetUserRoleInfoByUserIdData() { var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } var userService = new cUserService(loggingSessionInfo);//使用兼容模式 UserRoleInfo data = new UserRoleInfo(); string content = string.Empty; string key = string.Empty; if (Request("user_id") != null && Request("user_id") != string.Empty) { key = Request("user_id").ToString().Trim(); } data.UserRoleInfoList = userService.GetUserRoles(key); if (data.UserRoleInfoList == null) { data.UserRoleInfoList = new List <UserRoleInfo>(); } var jsonData = new JsonData(); jsonData.totalCount = data.UserRoleInfoList.Count.ToString(); jsonData.data = data.UserRoleInfoList; content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", data.UserRoleInfoList.ToJSON(), data.UserRoleInfoList.Count); return(content); }
/// <summary> /// 通过ID获取用户信息 /// </summary> public string GetUserInfoByIdData() { var responseData = new ResponseData(); LoggingSessionInfo loggingSessionInfo = null; if (CurrentUserInfo != null) { loggingSessionInfo = CurrentUserInfo; } else { if (string.IsNullOrEmpty(Request("CustomerID"))) { responseData.success = false; responseData.msg = "缺少商户标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else if (string.IsNullOrEmpty(Request("CustomerUserID"))) { responseData.success = false; responseData.msg = "缺少登陆员工的标识"; return(responseData.ToString()); } else { loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID")); } } var userService = new cUserService(loggingSessionInfo);//使用兼容模式 UserInfo data; string content = string.Empty; string key = string.Empty; if (Request("user_id") != null && Request("user_id") != string.Empty) { key = Request("user_id").ToString().Trim(); } data = userService.GetUserById(CurrentUserInfo, key); if (data != null) { data.userRoleInfoList = userService.GetUserRoles(key); } var jsonData = new JsonData(); jsonData.totalCount = "1"; jsonData.data = data; jsonData.success = true; jsonData.msg = ""; content = jsonData.ToJSON(); return(content); }
private void DownloadQRCodeNew()//新的下载二维码的方法 { //string weixinDomain = ConfigurationManager.AppSettings["original_url"]; //string sourcePath = this.CurrentContext.Server.MapPath("/QRCodeImage/qrcode.jpg"); //string targetPath = this.CurrentContext.Server.MapPath("/QRCodeImage/"); //string currentDomain = this.CurrentContext.Request.Url.Host; //string itemId = FormatParamValue(Request("item_id"));//商品ID //string itemName = FormatParamValue(Request("item_name"));//商品名 //string imageURL; //ObjectImagesBLL objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); ////查找是否已经生成了二维码 //ObjectImagesEntity[] objectImagesEntityArray = objectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = itemId, Description = "自动生成的产品二维码" }, null); //if (objectImagesEntityArray.Length == 0) //{ // //http://api.dev.chainclouds.com // // http://api.dev.chainclouds.com/WXOAuth/AuthUniversal.aspx?customerId=049b0a8f641f4ca7b17b0b7b6291de1f&applicationId=1D7A01FC1E7D41ECBAC2696D0D363315&goUrl=api.dev.chainclouds.com/HtmlApps/html/public/shop/goods_detail.html?rootPage=true&rootPage=true&goodsId=DBF5326F4C5B4B0F8508AB54B0B0EBD4&ver=1448273310707&scope=snsapi_userinfo // string itemUrl = weixinDomain + "/WXOAuth/AuthUniversal.aspx?customerId=" + CurrentUserInfo.ClientID // + "&goUrl=" + weixinDomain + "/HtmlApps/html/public/shop/goods_detail.html?goodsId=" // + itemId + "&scope=snsapi_userinfo"; // // string itemUrl = "http://*****:*****@"\"); var imagePath = dirPath + imageName;//整个 try { //要下载的文件名 FileInfo DownloadFile = new FileInfo(imagePath); //imagePath原来是这个,明天试试 if (DownloadFile.Exists) { CurrentContext.Response.Clear(); CurrentContext.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(user.User_Name, System.Text.Encoding.UTF8) + ".jpg" + "\""); CurrentContext.Response.AddHeader("Content-Length", DownloadFile.Length.ToString()); CurrentContext.Response.ContentType = "application/octet-stream"; CurrentContext.Response.TransmitFile(DownloadFile.FullName); CurrentContext.Response.Flush(); } else { Loggers.Debug(new DebugLogInfo() { Message = "二维码未找到" }); } } catch (Exception ex) { CurrentContext.Response.ContentType = "text/plain"; CurrentContext.Response.Write(ex.Message); } finally { CurrentContext.Response.End(); } }
/// <summary> /// 设置业务平台客户开户初始化 /// </summary> /// <param name="strCustomerInfo">客户信息字符窜</param> /// <param name="strUnitInfo">门店信息字符窜</param> /// <param name="typeId">处理类型typeId=1(总部与门店一起处理);typeId=2(只处理总部,不处理门店);typeId=3(只处理门店,不处理总部)</param> /// <returns></returns> public bool SetBSInitialInfo(string strCustomerInfo, string strUnitInfo, string strMenu, string typeId) { CustomerInfo customerInfo = new CustomerInfo(); #region 获取客户信息 if (!strCustomerInfo.Equals("")) { customerInfo = (JIT.CPOS.BS.Entity.CustomerInfo)cXMLService.Deserialize(strCustomerInfo, typeof(JIT.CPOS.BS.Entity.CustomerInfo)); if (customerInfo == null || customerInfo.ID.Equals("")) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "客户不存在或者没有获取合法客户信息") }); throw new Exception("客户不存在或者没有获取合法客户信息"); } } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "客户信息不存在") }); throw new Exception("客户信息不存在."); } #endregion //获取连接数据库信息 JIT.CPOS.BS.Entity.User.UserInfo userInfo = new JIT.CPOS.BS.Entity.User.UserInfo(); LoggingManager loggingManager = new cLoggingManager().GetLoggingManager(customerInfo.ID); LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); loggingSessionInfo.CurrentLoggingManager = loggingManager; loggingSessionInfo.CurrentUser = userInfo; #region 判断客户是否已经建立总部 typeId = "1";//统一作为1来处理 bool bReturn = false; string strError = string.Empty; string strReturn = string.Empty; // UnitInfo storeInfo = new UnitInfo(); cUserService userServer = new cUserService(loggingSessionInfo); #region 处理用户信息 userInfo.User_Id = BaseService.NewGuidPub(); //用户标识 userInfo.customer_id = customerInfo.ID; //客户标识 userInfo.User_Code = "admin"; userInfo.User_Name = "管理员"; userInfo.User_Gender = "1"; userInfo.User_Password = "******"; userInfo.User_Status = "1"; userInfo.User_Status_Desc = "正常"; userInfo.strDo = "Create"; #endregion #endregion UnitInfo unitInfo = new UnitInfo(); using (TransactionScope scope = new TransactionScope()) { #region 门店 /** * JIT.CPOS.BS.Entity.UnitInfo unitShopInfo = new JIT.CPOS.BS.Entity.UnitInfo();//门店 * if (!strUnitInfo.Equals(""))//把在运营商管理平台创建的门店(code就是商户的code)在这里反序列化 * { * unitShopInfo = (JIT.CPOS.BS.Entity.UnitInfo)cXMLService.Deserialize(strUnitInfo, typeof(JIT.CPOS.BS.Entity.UnitInfo)); * } * else * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "门店信息不存在") * }); * throw new Exception("门店信息不存在."); * } * **/ #region 门店是否存在(在这之前门店并没有插入到运营商管理平台的数据库,只是序列化在字符串里)***** /** * JIT.CPOS.BS.Entity.UnitInfo unitStoreInfo2 = new JIT.CPOS.BS.Entity.UnitInfo(); * try * { * unitStoreInfo2 = new UnitService(loggingSessionInfo).GetUnitById(unitShopInfo.Id); * } * catch (Exception ex) * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "获取门店失败") * }); * throw new Exception("获取门店失败:" + ex.ToString()); * } * if (unitStoreInfo2 == null || !string.IsNullOrEmpty(unitStoreInfo2.Id))//***这里的判断是不是错了,应该是(unitStoreInfo2 != null || !string.IsNullOrEmpty(unitStoreInfo2.Id)) * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "门店信息已经存在") * }); * throw new Exception("门店信息已经存在."); * } * **/ #endregion #endregion #region //创建商户自己的门店类型 T_TypeBLL t_TypeBLL = new T_TypeBLL(loggingSessionInfo); //创建总部类型 T_TypeEntity typeGeneral = new T_TypeEntity(); typeGeneral.type_id = BaseService.NewGuidPub();//去掉了中间的‘-’ typeGeneral.type_code = "总部"; typeGeneral.type_name = "总部"; typeGeneral.type_name_en = "总部"; typeGeneral.type_domain = "UnitType"; typeGeneral.type_system_flag = 1; typeGeneral.status = 1; typeGeneral.type_Level = 1; typeGeneral.customer_id = customerInfo.ID; t_TypeBLL.Create(typeGeneral); //创建门店类型 T_TypeEntity typeShop = new T_TypeEntity(); typeShop.type_id = BaseService.NewGuidPub();//去掉了中间的‘-’ typeShop.type_code = "门店"; typeShop.type_name = "门店"; typeShop.type_name_en = "门店"; typeShop.type_domain = "UnitType"; typeShop.type_system_flag = 1; typeShop.status = 1; typeShop.type_Level = 99;//等到在页面上保存时在根据增加的层级来改变他的层级 typeShop.customer_id = customerInfo.ID; t_TypeBLL.Create(typeShop); //创建在线商城类型 T_TypeEntity typeOnlineShopping = new T_TypeEntity(); typeOnlineShopping.type_id = BaseService.NewGuidPub();//去掉了中间的‘-’ typeOnlineShopping.type_code = "OnlineShopping"; typeOnlineShopping.type_name = "在线商城"; typeOnlineShopping.type_name_en = "OnlineShopping"; typeOnlineShopping.type_domain = "UnitType"; typeOnlineShopping.type_system_flag = 1; typeOnlineShopping.status = 1; typeOnlineShopping.type_Level = -99;//在线商城类型不算在组织类型里,因此排在外面 typeOnlineShopping.customer_id = customerInfo.ID; t_TypeBLL.Create(typeOnlineShopping); #endregion #region 新建角色 RoleModel roleInfo = new RoleModel(); if (typeId.Equals("1")) { roleInfo.Role_Id = BaseService.NewGuidPub(); roleInfo.Def_App_Id = "D8C5FF6041AA4EA19D83F924DBF56F93"; //创建了一个o2o业务系统的角色 roleInfo.Role_Code = "Admin"; roleInfo.Role_Name = "管理员"; roleInfo.Role_Eng_Name = "Admin"; roleInfo.Is_Sys = 1; roleInfo.Status = 1; roleInfo.customer_id = customerInfo.ID; roleInfo.Create_User_Id = userInfo.User_Id; roleInfo.Create_Time = new BaseService().GetCurrentDateTime(); //新加上所处的层级 roleInfo.type_id = typeGeneral.type_id; roleInfo.org_level = (int)typeGeneral.type_Level;//等级 string strerror = ""; strReturn = new RoleService(loggingSessionInfo).SetRoleInfo(roleInfo, out strerror, false);//这里没有创建他的菜单 if (!strReturn.Equals("成功")) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色失败") }); throw new Exception("新建角色失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色成功") }); } } #endregion #region 角色与流程关系 if (typeId.Equals("1")) { bReturn = new cBillService(loggingSessionInfo).SetBatBillActionRole(roleInfo.Role_Id);//不知道有什么作用 if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "创建角色与流程关系失败") }); throw new Exception("创建角色与流程关系失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "角色与流程关系成功") }); } } #endregion //UnitInfo unitInfo = new UnitInfo(); UnitService unitServer = new UnitService(loggingSessionInfo); unitInfo.Id = BaseService.NewGuidPub();//先把总部的标识生成好 #region 插入用户与角色与客户总部关系 IList <UserRoleInfo> userRoleInfoList = new List <UserRoleInfo>(); UserRoleInfo userRoleInfo = new UserRoleInfo();//后面要用到总部的信息 if (typeId.Equals("1") || typeId.Equals("2")) { userRoleInfo.Id = BaseService.NewGuidPub(); userRoleInfo.UserId = userInfo.User_Id; userRoleInfo.RoleId = roleInfo.Role_Id; //admin角色***** userRoleInfo.UnitId = unitInfo.Id; //总部下的*** userRoleInfo.Status = "1"; userRoleInfo.DefaultFlag = 1; userRoleInfoList.Add(userRoleInfo); } loggingSessionInfo.CurrentUserRole = userRoleInfo;//主要是保存总部和员工信息时,会用到 #region 处理新建客户总部 if (typeId.Equals("1") || typeId.Equals("2")) { // unitInfo.TypeId = "2F35F85CF7FF4DF087188A7FB05DED1D";//这里要替换成该商户自己的门店类型标识**** unitInfo.TypeId = typeGeneral.type_id; //*** unitInfo.Code = "总部"; //customerInfo.Code + unitInfo.Name = "总部"; // customerInfo.Name + unitInfo.CityId = customerInfo.city_id; unitInfo.Status = "1"; unitInfo.Status_Desc = "正常"; unitInfo.CustomerLevel = 1; unitInfo.customer_id = customerInfo.ID; unitInfo.Parent_Unit_Id = "-99"; unitInfo.strDo = "Create"; strReturn = unitServer.SetUnitInfo(loggingSessionInfo, unitInfo, false); Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "提交总部:" + strReturn.ToString()) }); } #endregion #region 处理门店,用的是商户的code和名称,id没有用***** /** * storeInfo.Id = unitShopInfo.Id;//(运营商管理平台创建的门店(Shop代表门店***) * if (string.IsNullOrEmpty(unitShopInfo.Id)) * { * storeInfo.Id = BaseService.NewGuidPub(); * } * // storeInfo.TypeId = "EB58F1B053694283B2B7610C9AAD2742"; //整个平台的系统类型(门店类型) * storeInfo.TypeId = typeShop.type_id;//上面创建的门店类型 * storeInfo.Code = customerInfo.Code;//商户的code * storeInfo.Name = customerInfo.Name;//商户的name * storeInfo.Name = customerInfo.Name;//商户的name * * storeInfo.CityId = customerInfo.city_id; * storeInfo.Status = "1"; * storeInfo.Status_Desc = "正常"; * storeInfo.CustomerLevel = 1; * storeInfo.customer_id = customerInfo.ID; * storeInfo.Parent_Unit_Id = unitInfo.Id;//总部下面的一个门店 * storeInfo.strDo = "Create"; * storeInfo.StoreType = "DirectStore";//设置为直营店 * strReturn = unitServer.SetUnitInfo(loggingSessionInfo, storeInfo,false); * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "提交门店:" + strReturn.ToString()) * }); * **/ #endregion //在线商城门店是在存储过程[spBasicSetting]里添加的 //不建立下面的关系,就可以之保留admin的总部角色权限了 /** * UserRoleInfo userRoleInfo1 = new UserRoleInfo(); * userRoleInfo1.Id = BaseService.NewGuidPub(); * userRoleInfo1.UserId = userInfo.User_Id; * userRoleInfo1.RoleId = roleInfo.Role_Id; * userRoleInfo1.UnitId = storeInfo.Id;//还和子门店建立了关系(id为商户的id) * userRoleInfo1.Status = "1"; * userRoleInfo1.DefaultFlag = 0; * userRoleInfoList.Add(userRoleInfo1); * * **/ bReturn = userServer.SetUserInfo(userInfo, null, out strError, false); //保存用户信息(这里会把之前建的会员的角色信息给删除掉),所以要在后面再建立角色和会员的关系 bReturn = userServer.SetUserRoleTableInfo(loggingSessionInfo, userRoleInfoList, userInfo); //只建立了用户和总部之间的关系 if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色用户门店关系失败") }); throw new Exception("新建角色用户门店关系失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "新建角色用户门店关系成功") }); } #endregion #region 处理用户信息 if (typeId.Equals("1")) { /** * IList<UserRoleInfo> userRoleInfos = new List<UserRoleInfo>(); * UserRoleInfo userRoleInfo = new UserRoleInfo(); * userRoleInfo.Id = BaseService.NewGuidPub(); * userRoleInfo.RoleId = roleInfo.Role_Id;// 加上管理员权限 * userRoleInfo.UserId = userInfo.User_Id; * userRoleInfo.UnitId = unitShopInfo.Id;//新建的门店标识(运营商管理平台创建的门店(Shop代表门店***),code=customer_code,name=customer_name) * userRoleInfos.Add(userRoleInfo); * loggingSessionInfo.CurrentUserRole = userRoleInfo; * **/ //先给admin键了一个门店的权限*****,可以给去掉,去掉上面一句话就可以了**** if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "保存用户失败") }); throw new Exception("保存用户失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "保存用户成功") }); } } #endregion #region 添加仓库以及仓库与门店关系 /** * JIT.CPOS.BS.Entity.Pos.WarehouseInfo warehouseInfo = new JIT.CPOS.BS.Entity.Pos.WarehouseInfo(); * warehouseInfo.warehouse_id = BaseService.NewGuidPub(); * warehouseInfo.wh_code = storeInfo.Code + "_wh";//建立了刚才见的子门点的仓库 * warehouseInfo.wh_name = storeInfo.Name + "仓库"; * warehouseInfo.is_default = 1; * warehouseInfo.wh_status = 1; * warehouseInfo.CreateUserID = userInfo.User_Id; * warehouseInfo.CreateTime = Convert.ToDateTime(new BaseService().GetCurrentDateTime()); * warehouseInfo.CreateUserName = userInfo.User_Name; * warehouseInfo.Unit = storeInfo; * * PosService posService = new PosService(loggingSessionInfo); * bReturn = posService.InsertWarehouse(warehouseInfo,false); * if (!bReturn) * { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建仓库失败") * }); * throw new Exception("新建仓库失败"); * } * else { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建仓库成功") * }); * } * **/ #endregion #region 设置菜单信息 //在存储过程里初始化了 /*** * if (typeId.Equals("1") || typeId.Equals("2")) * { * if (!strMenu.Equals("")) * { * CMenuService menuServer = new CMenuService(loggingSessionInfo); * bReturn = new CMenuService(loggingSessionInfo).SetMenuInfo(strMenu, customerInfo.ID, false); * if (!bReturn) { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建菜单失败") * }); * throw new Exception("新建菜单失败"); } * else { * Loggers.Debug(new DebugLogInfo() * { * Message = string.Format("SetBSInitialInfo:{0}", "新建菜单成功") * }); * } * } * } * **/ #endregion #region 20131127设置固定标签 TagsBLL tagsServer = new TagsBLL(loggingSessionInfo); bool bReturnTags = tagsServer.setCopyTag(customerInfo.ID); #endregion scope.Complete(); scope.Dispose(); } #region 管理平台--插入客户下的用户信息 if (typeId.Equals("1")) { if (!new cUserService(loggingSessionInfo).SetManagerExchangeUserInfo(loggingSessionInfo, userInfo, 1)) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "提交管理平台用户信息失败") }); strError = "提交管理平台失败"; bReturn = false; return(bReturn); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "提交管理平台用户信息成功") }); } } #endregion #region 管理平台--插入客户下的门店信息(只是提交门店级别的) // bReturn = new UnitService(loggingSessionInfo).SetManagerExchangeUnitInfo(loggingSessionInfo, storeInfo, 1); bReturn = new UnitService(loggingSessionInfo).SetManagerExchangeUnitInfo(loggingSessionInfo, unitInfo, 1); if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "门店插入管理平台失败") }); throw new Exception("门店插入管理平台失败"); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "门店插入管理平台成功") }); } #endregion #region 中间层--插入用户,客户关系 if (typeId.Equals("1")) { userInfo.customer_id = customerInfo.ID; string strResult = cUserService.SetDexUserCertificate(loggingSessionInfo, userInfo); if (!(strResult.Equals("True") || strResult.Equals("true"))) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "插入SSO失败") }); strError = "插入SSO失败"; bReturn = false; return(bReturn); } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetBSInitialInfo:{0}", "插入SSO成功") }); } } #endregion return(true); }
/// <summary> /// 门店内员工排名 /// 排名规则: /// 1.取出打赏金额大于零的员工 /// 2.比较打赏金额,(金额高的往前排) /// 3.金额相同,比较评价等级 (等级高的往前排) /// 4.如果还相同,比较打赏时间(时间靠前,往前排) /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetTopRewardListRD ProcessRequest(DTO.Base.APIRequest <GetTopRewardListRP> pRequest) { var rd = new GetTopRewardListRD(); var customerId = CurrentUserInfo.ClientID; var trrBll = new T_RewardRecordBLL(CurrentUserInfo); var userBll = new T_UserBLL(CurrentUserInfo); //获取员工列表(门店内) var userList = userBll.QueryByEntity(new T_UserEntity() { customer_id = customerId }, null); var userService = new cUserService(CurrentUserInfo); CurrentUserInfo.CurrentUserRole.UnitId = string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId) ? "" : CurrentUserInfo.CurrentUserRole.UnitId; var para_unit_id = CurrentUserInfo.CurrentUserRole.UnitId; var maxRowCount = Utils.GetIntVal(Request("limit")); var startRowIndex = Utils.GetIntVal(Request("start")); var rowCount = maxRowCount > 0 ? maxRowCount : 999; //每页行数 var startIndex = startRowIndex > 0 ? startRowIndex : 0; //当前页的起始行数 var userdata = new JIT.CPOS.BS.Entity.User.UserInfo(); if (string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId)) { userdata = userService.SearchUserListByUnitID(string.Empty, string.Empty, string.Empty, string.Empty, rowCount, startIndex, CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, string.Empty, string.Empty); } else { userdata = userService.SearchUserListByUnitID(string.Empty, string.Empty, string.Empty, string.Empty, rowCount, startIndex, CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, string.Empty, string.Empty); } var orderBys = new OrderBy[1]; orderBys[0] = new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc }; var trrList = trrBll.QueryByEntity(new T_RewardRecordEntity() { PayStatus = 2, CustomerId = customerId }, orderBys); var oeBll = new ObjectEvaluationBLL(CurrentUserInfo); var oeList = oeBll.QueryByEntity(new ObjectEvaluationEntity() { Type = 4, CustomerID = customerId }, null); var allOE = (from p in oeList.AsEnumerable() group p by p.ObjectID into g select new { g.Key, SumValue = g.Average(p => p.StarLevel) }); var allRewards = (from p in trrList.AsEnumerable() group p by p.RewardedOP into g select new { g.Key, SumValue = g.Sum(p => p.RewardAmount) }).Where(g => g.SumValue > 0).OrderByDescending(g => g.SumValue); var rewardCount = allRewards.ToList().Count; //var top10Rewards = allRewards.Take(10); //金额相同,比较评价等级 (等级高的往前排) rd.RewardList = new List <RewardInfo>(); rd.MyReward = new RewardInfo(); var index = 1; foreach (var item in allRewards) { var tmpRewardInfo = new RewardInfo(); //var userinfo = userList.Where(t => t.user_id == item.Key).ToArray().FirstOrDefault(); var userinfo = userdata.UserInfoList.Where(t => t.User_Id == item.Key).ToArray().FirstOrDefault(); var oeinfo = allOE.Where(t => t.Key == item.Key).ToArray().FirstOrDefault(); if (userinfo != null) { tmpRewardInfo = new RewardInfo() { UserID = userinfo.User_Id, UserName = userinfo.User_Name, UserPhoto = userinfo.imageUrl, StarLevel = oeinfo != null?Convert.ToInt32(oeinfo.SumValue) : 0, Rank = index, RewardIncome = item.SumValue }; rd.RewardList.Add(tmpRewardInfo); if (userinfo.User_Id == pRequest.UserID) { rd.MyReward = tmpRewardInfo; } index++; } } if (string.IsNullOrEmpty(rd.MyReward.UserID))//Top10之外 { //var userinfo = userList.Where(t => t.user_id == pRequest.UserID).ToArray().FirstOrDefault(); var userinfo = userdata.UserInfoList.Where(t => t.User_Id == pRequest.UserID).ToArray().FirstOrDefault(); var oeinfo = allOE.Where(t => t.Key == pRequest.UserID).ToArray().FirstOrDefault(); var myReward = allRewards.Where(t => t.Key == pRequest.UserID).FirstOrDefault(); decimal?myRewardIncome = 0; if (myReward != null) { myRewardIncome = myReward.SumValue != null ? myReward.SumValue : 0; rewardCount = allRewards.Where(g => g.SumValue > myReward.SumValue).ToList().Count; } var myStarLevel = oeinfo != null?Convert.ToInt32(oeinfo.SumValue) : 0; if (userinfo != null) { rd.MyReward = new RewardInfo() { UserID = userinfo.User_Id, UserName = userinfo.User_Name, UserPhoto = userinfo.imageUrl, StarLevel = myStarLevel, Rank = myRewardIncome > 0 ? rewardCount + 1 : 0, RewardIncome = myRewardIncome }; } } return(rd); }
private void loadUser(string customer_id, string token) { //try //{ //获取登录管理平台的用户信息 var AuthWebService = new JIT.CPOS.BS.WebServices.AuthManagerWebServices.AuthServiceSoapClient(); AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress( ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx"); // AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:42305/AuthService.asmx"); //AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:7335/AuthService.asmx"); if (token == null) { token = ""; } string str = AuthWebService.GetLoginUserInfo(token); if (string.IsNullOrEmpty(str)) { //this.lbErr.Text = "用户不存在,请与管理员联系"; //return; PageLog.Current.Write("SSO登录失败,AuthWebService.asmx返回空数据"); //Response.Write("登录失败,请重试!"); //Response.End(); var redirectUrl = ConfigurationManager.AppSettings["sso_url"].ToString() + "?errorinfo=" + "网络繁忙,请重新登录!"; //var redirectUrl = "http://localhost:7335/login.aspx"; Response.Redirect(redirectUrl, true); } var myLoggingManager = (JIT.CPOS.BS.Entity.LoggingManager)cXMLService.Deserialize( str, typeof(JIT.CPOS.BS.Entity.LoggingManager)); //判断登录进来的用户是否存在,并且返回用户信息 LoggingSessionInfo loggingSession = new LoggingSessionInfo(); loggingSession.CurrentLoggingManager = myLoggingManager; cUserService userService = new cUserService(loggingSession); UnitService unitService = new UnitService(loggingSession); if (!userService.IsExistUser(loggingSession)) { this.lbErr.Text = "用户不存在,请与管理员联系"; return; } var login_user = userService.GetUserById(loggingSession, myLoggingManager.User_Id); loggingSession.CurrentUser = login_user; // 获取角色 string applicationId = PageBase.JITPage.GetApplicationId(); IList <UserRoleInfo> userRoleList = userService.GetUserRoles(login_user.User_Id, applicationId); if (userRoleList != null && userRoleList.Count > 0) { loggingSession.CurrentUserRole = new UserRoleInfo(); loggingSession.CurrentUserRole.UserId = login_user.User_Id; loggingSession.CurrentUserRole.UserName = login_user.User_Name; loggingSession.CurrentUserRole.RoleId = userRoleList[0].RoleId; loggingSession.CurrentUserRole.RoleCode = userRoleList[0].RoleCode; loggingSession.CurrentUserRole.RoleName = userRoleList[0].RoleName; loggingSession.ClientID = login_user.customer_id; loggingSession.CurrentLoggingManager.Customer_Id = login_user.customer_id; loggingSession.UserID = loggingSession.CurrentUser.User_Id; try { loggingSession.CurrentUserRole.UnitId = userService.GetDefaultUnitByUserIdAndRoleId( loggingSession.CurrentUserRole.UserId, loggingSession.CurrentUserRole.RoleId); } catch (Exception ex) { PageLog.Current.Write(ex); Response.Write("找不到默认单位"); Response.End(); } try { var unitInfo = unitService.GetUnitById(loggingSession.CurrentUserRole.UnitId); loggingSession.CurrentUserRole.UnitName = unitInfo.Name; loggingSession.CurrentUserRole.UnitShortName = unitInfo.ShortName; } catch (Exception ex) { PageLog.Current.Write(ex); Response.Write("找不到单位"); Response.End(); } } else { //PageLog.Current.Write(ex); Response.Write("该用户没有权限登录管理平台"); Response.End(); } //this.Session["UserInfo"] = login_user; //this.Session["LoggingManager"] = myLoggingManager; //this.Session["loggingSessionInfo"] = loggingSession; //loggingSession.CurrentLoggingManager = myLoggingManager; new SessionManager().SetCurrentUserLoginInfo(loggingSession); //清空密码 login_user.User_Password = null; //string go_url = "~/login/SelectRoleUnit.aspx?p=0"; string go_url = "~/Default.aspx"; if (loggingSession.CurrentUserRole != null && loggingSession.CurrentUserRole.RoleId == "860E69754D3B490F8A5B401DF3F66E15") { string eventId = string.Empty; //switch (loggingSession.CurrentUserRole.UserId.Trim()) //{ // case "FA1BDA8937924D45AFA3123FE4DEE8FA": // eventId = "0326056B219340D5B234BFAD9AF02AF5"; // break; // case "4913B21CFD714C7986842B859EC1289B": // eventId = "793150439CF94190A70CF2EC229A951D"; // break; // case "BD8079F886BD492E90A335EBC1DE9676": // eventId = "F8A7E2E8807B49558F1A516F23C34473"; // break; // default: // eventId = "793150439CF94190A70CF2EC229A951D"; // break; //} LEventsBLL lEventsBLL = new LEventsBLL(loggingSession); var eventList = lEventsBLL.QueryByEntity(new LEventsEntity() { EventManagerUserId = loggingSession.CurrentUserRole.UserId }, null); if (eventList != null && eventList.Length > 0) { eventId = eventList[0].EventID; loggingSession.CurrentUserRole.RoleName = eventId; Response.Redirect("~/Module/MarketEvent/EventList/EventAnalysisList4.aspx", true); } } else { //loggingSession.CurrentUserRole.RoleName = "793150439CF94190A70CF2EC229A951D"; Response.Redirect(go_url, true); } //} //catch (Exception ex) //{ // PageLog.Current.Write(ex); // lbErr.Text = "登录失败"; //} }
/// <summary> /// 获取BS用户登录信息 /// </summary> /// <param name="customerId"></param> /// <param name="userId"></param> /// <returns></returns> public static LoggingSessionInfo GetBSLoggingSession(string customerId, string userId) { if (userId == null || userId == string.Empty) { userId = "system"; } string conn = ""; string name = ""; CC_Connection connection = new RedisConnectionBLL().GetConnection(customerId);//从redis里获取商户数据库链接 RedisXML _RedisXML = new RedisXML(); //如果从缓存里获取不到信息,就从数据库读取,并种到缓存里 if (connection == null || string.IsNullOrEmpty(connection.ConnectionStr) || string.IsNullOrEmpty(connection.Customer_Name)) { //记录redis读取不成功,从数据库里读取数据的情况 _RedisXML.RedisReadDBCount("Connection", "商户数据库链接", 2); conn = GetCustomerConn(customerId); name = GetCustomerName(customerId); string code = GetCustomerCode(customerId); new RedisConnectionBLL().SetConnection(customerId, conn, name, code); } else { //记录redis读取日志 _RedisXML.RedisReadDBCount("Connection", "商户数据库链接", 1); conn = connection.ConnectionStr; name = connection.Customer_Name; } LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); //loggingSessionInfo = new CLoggingSessionService().GetLoggingSessionInfo(customerId, "7d4cda48970b4ed0aa697d8c2c2e4af3"); loggingSessionInfo.CurrentUser = new BS.Entity.User.UserInfo(); loggingSessionInfo.CurrentUser.User_Id = userId; loggingSessionInfo.CurrentUser.customer_id = customerId; loggingSessionInfo.UserID = loggingSessionInfo.CurrentUser.User_Id; loggingSessionInfo.ClientID = customerId; loggingSessionInfo.Conn = conn; loggingSessionInfo.CurrentLoggingManager = new LoggingManager(); loggingSessionInfo.CurrentLoggingManager.Connection_String = loggingSessionInfo.Conn; loggingSessionInfo.CurrentLoggingManager.User_Id = userId; loggingSessionInfo.CurrentLoggingManager.Customer_Id = customerId; loggingSessionInfo.CurrentLoggingManager.Customer_Name = name; loggingSessionInfo.CurrentLoggingManager.User_Name = ""; if (!string.IsNullOrEmpty(conn)) { //用户角色信息 cUserService userService = new cUserService(loggingSessionInfo); string applicationId = "649F8B8BDA9840D6A18130A5FF4CB9C8";//[T_Def_App] app IList <UserRoleInfo> userRoleList = userService.GetUserRoles(loggingSessionInfo.UserID, applicationId); if (userRoleList != null && userRoleList.Count > 0) { loggingSessionInfo.CurrentUserRole = new UserRoleInfo(); loggingSessionInfo.CurrentUserRole.UserId = loggingSessionInfo.UserID; //loggingSessionInfo.CurrentUserRole.UserName = login_user.User_Name; loggingSessionInfo.CurrentUserRole.RoleId = userRoleList[0].RoleId; loggingSessionInfo.CurrentUserRole.RoleCode = userRoleList[0].RoleCode; loggingSessionInfo.CurrentUserRole.RoleName = userRoleList[0].RoleName; loggingSessionInfo.CurrentUserRole.UnitId = userService.GetDefaultUnitByUserIdAndRoleId( loggingSessionInfo.CurrentUserRole.UserId, loggingSessionInfo.CurrentUserRole.RoleId); } loggingSessionInfo.ClientName = name; } return(loggingSessionInfo); }
/// <summary> /// 处理订单支付之后业务标识 /// </summary> /// <param name="OrderCustomerInfo"></param> /// <param name="strResult"></param> /// <param name="strOutTradeNo"></param> private void SetPayOrderInfo(string OrderCustomerInfo, string strResult, string strOutTradeNo) { //order_id: 订单号 //result: success(交易成功) 或者 fail(交易失败) //out_trade_no: 与订单号对应的外部交易号(方便日后查询交易中的详细信息) try { #region check if (OrderCustomerInfo == null || OrderCustomerInfo.Equals("")) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo: {0}", "返回订单号为空") }); return; } if (strResult == null || strResult.Equals("fail")) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo: {0}", "支付失败") }); return; } #endregion #region 处理业务 var infos = OrderCustomerInfo.Split(','); if (infos.Length != 2) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo-OrderCustomerInfo: {0}", "长度错误") }); return; } string customerId = infos[0].ToString().Trim(); string orderCode = infos[1].ToString().Trim(); var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); InoutService service = new InoutService(loggingSessionInfo); SetOrderEntity orderInfo = new SetOrderEntity(); orderInfo.OrderCode = orderCode; orderInfo.PaymentTypeId = "BB04817882B149838B19DE2BDDA5E91B"; //orderInfo.PaymentAmount = Convert.ToDecimal(reqObj.special.paymentAmount); //orderInfo.LastUpdateBy = ToStr(reqObj.common.userId); orderInfo.PaymentTime = System.DateTime.Now; orderInfo.Status = "2"; orderInfo.StatusDesc = "已支付"; orderInfo.OutTradeNo = strOutTradeNo; string strError = string.Empty; bool bReturn = service.SetOrderPayment(orderInfo, out strError); if (!bReturn) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo: {0}", "提交失败") }); } else { string openId = string.Empty; string amount = string.Empty; string orderId = string.Empty; //支付成功,发送邮件与短信 cUserService userServer = new cUserService(loggingSessionInfo); userServer.SendOrderMessage(orderCode); bool bReturnx = service.GetOrderOpenId(orderCode, out openId, out amount, out orderId); //推送消息 if (bReturnx) { string dataStr = "{ \"OpenID\":\"" + openId + "\", \"" + amount + "\":2877 }"; //bool bReturnt = SetVipIntegral(loggingSessionInfo, dataStr); VipIntegralBLL vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); bool bReturnt = vipIntegralBLL.SetPushIntegral(orderId , ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim() , out strError); if (!bReturnt) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo-失败: {0}", "发送失败") }); } } else { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo-失败: {0}", "获取信息失败") }); } } #endregion } catch (Exception ex) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetPayOrderInfo-失败: {0}", ex.ToString()) }); } }