/// <summary> /// 获取验证码 /// </summary> private void GetAuthCode() { DataTable dtList = ds.Tables["List"]; DataTable dtVexSSO = new MDM.VEXSSOUserDataTable(); string strSQL = ""; int nCount = 0; //认证类型 string strAuthType = dtList.Rows[0]["AuthType"].ToString().ToUpper(); string strContent = ""; string strAuthCode = ""; string strPhone = dtList.Rows[0]["Phone"].ToString().ToUpper(); if (strAuthType == "") { throw new Exception("AuthType不能为空!"); } if (strPhone == "") { throw new Exception("Phone不能为空!"); } if (m_tranFlag == true) { m_conn.BeginTransaction(); } //用户注册 if (strAuthType.ToUpper() == "signup".ToUpper()) { //判断手机是否已经被注册 VexSSOUser cls = new VexSSOUser(); if (cls.CheckUserExist(strPhone)) { throw new Exception("该手机号已注册,请使用找回密码功能。"); } Random ra = new Random(); strAuthCode = ra.Next(1000, 9999).ToString(); strContent = "您正在申请注册单点登录账户,验证码:" + strAuthCode + ",请勿向任何人提供您收到的验证码。(有效期:1小时)"; } else if (strAuthType.ToUpper() == "getPassword".ToUpper()) { //判断手机是否已经被注册 VexSSOUser cls = new VexSSOUser(); if (!cls.CheckUserExist(strPhone)) { throw new Exception("手机号还末注册帐户,请先注册。"); } Random ra = new Random(); strAuthCode = ra.Next(1000, 9999).ToString(); strContent = "您正在申请单点登录账户密码取回,验证码:" + strAuthCode + ",请勿向任何人提供您收到的验证码。(有效期:1小时)"; } else { throw new Exception("认证类型不支持!"); } DataTable dtAuthCode = new MDM.VEXSSOAuthCodeDataTable(); DataRow dr = dtAuthCode.NewRow(); dr["ID"] = Guid.NewGuid(); dr["Type"] = strAuthType; dr["Phone"] = strPhone; dr["Content"] = strContent; dr["AuthCode"] = strAuthCode; dtAuthCode.Rows.Add(dr); m_conn.BeginTransaction(); m_conn.HZYMessage = this.hzyMessage; m_conn.InsertByVex("B01_MDM.VEXSSOAuthCode", dtAuthCode); HZY.COM.WS.AM.SMSSendImmediately.Send(strPhone, strContent); if (m_tranFlag == true) { m_conn.CommitTransaction(); } dt_EditResult.Rows.Add(new object[] { true, "发送成功!" }); m_dsRequturn.Tables.Add(dt_EditResult); }
/// <summary> /// 根据3S微信号获取导购相关信息 /// </summary> private void GetEmployeeInfoBy3SWeChat() { DataTable dt = ds.Tables["List"]; string str3SWeChatUserID = dt.Rows[0]["S3WeChatID"].ToString(); if (str3SWeChatUserID == "") { throw new Exception("3S微信号不允许为空"); } DataSet dsResponse = null; try { //判断是否已经绑定EHR VexSSOUser cls = new VexSSOUser(); string[] strColumns = new string[] { "CurrentEnvSN", "TargetEnvSN", "UserName", "Password" }; string[] strValues = new string[] { "3SWeChat", "EHRCARD", str3SWeChatUserID, "" }; DataSet dsRequestCls = Common.Common.GetDataSetContainsRequestExcelXML(strColumns, strValues, "GetUserInfo"); cls.Request = dsRequestCls; dsResponse = cls.GetData(); } catch (Exception ex) { dt_EditResult.Rows.Add(new object[] { "1", "末绑定EHR!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); return; } if (dsResponse.Tables[0].Rows.Count == 0 || dsResponse.Tables[0].Rows[0]["App_UserName"].ToString() == "") { dt_EditResult.Rows.Add(new object[] { "1", "末绑定EHR!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); return; } else { string strName = dsResponse.Tables[0].Rows[0]["App_UserName"].ToString(); string strCardMD5 = dsResponse.Tables[0].Rows[0]["App_Password"].ToString(); Dbconn connEHR = new Dbconn("EHR"); string strSQL1 = @" SELECT C_NAME,C_IDCARD FROM ehr.TB_INF_EMPLOYEE WHERE C_employeestatus<>3 AND C_NAME=@Param0 AND right(sys.fn_VarBinToHexStr(hashbytes('MD5',Convert(varchar(100),C_IDCARD))),32)=@param1 "; DataTable dtEHR = connEHR.GetDataTable(strSQL1, new string[] { strName, strCardMD5 }); if (dtEHR.Rows.Count == 0) { dt_EditResult.Rows.Add(new object[] { "1", "您的信息在EHR状态为离职,请与人资部联系!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); return; } } try { //判断是否已经绑定POS VexSSOUser cls = new VexSSOUser(); string[] strColumns = new string[] { "CurrentEnvSN", "TargetEnvSN", "UserName", "Password" }; string[] strValues = new string[] { "3SWeChat", "POSEmployee", str3SWeChatUserID, "" }; DataSet dsRequestCls = Common.Common.GetDataSetContainsRequestExcelXML(strColumns, strValues, "GetUserInfo"); cls.Request = dsRequestCls; dsResponse = cls.GetData(); } catch (Exception ex) { dt_EditResult.Rows.Add(new object[] { "2", "末绑定POS!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); return; } string strApp_UserName = ""; if (dsResponse.Tables[0].Rows.Count == 0 || dsResponse.Tables[0].Rows[0]["App_UserName"].ToString() == "") { dt_EditResult.Rows.Add(new object[] { "2", "末绑定POS!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); } else { string strSQL = ""; string strVexSSOLoginUser = dsResponse.Tables[0].Rows[0]["VexSSOLoginUser"].ToString(); strApp_UserName = dsResponse.Tables[0].Rows[0]["App_UserName"].ToString(); strSQL = @" SELECT '3' as Result, '' as Message, employeeid , names , t1.depotid , t2.d_name , t1.valid, t2.d_dq, t2.d_dd, t1.position FROM j_employee t1 , j_depot t2 WHERE t1.depotid = t2.depotid AND t1.valid = 0 --0在岗 1离职 AND employeeid=@param0 "; Dbconn conn = new Dbconn("F22GP"); DataTable dtResult = conn.GetDataTable(strSQL, new string[] { strApp_UserName }); strSQL = @"SELECT dbo.j_depot.freeze FROM dbo.j_employee inner JOIN dbo.j_depot ON dbo.j_depot.depotid = dbo.j_employee.depotid WHERE employeeid=@param0 AND freeze=1 "; DataTable dtDepotResult = conn.GetDataTable(strSQL, new string[] { strApp_UserName }); //说明店铺已关闭 if (dtDepotResult.Rows.Count > 0) { dt_EditResult.Rows.Add(new object[] { "2", "店铺已关闭,请重新绑定新导购编号!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); } //如果员工已离职,需要对SSO进行解绑 else if (dtResult.Rows.Count == 0) { dt_EditResult.Rows.Add(new object[] { "2", "员工已离职!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); } else { m_dsRetrun.Tables.Add(dtResult.Copy()); } //如果员工已离职,需要对SSO进行解绑 if (dtResult.Rows.Count == 0 || dtDepotResult.Rows.Count > 0) { //进行SSO解绑 try { VexSSOUser cls = new VexSSOUser(); string[] strColumns = new string[] { "LoginUser", "BindUser", "AccreditationType" }; string[] strValues = new string[] { strVexSSOLoginUser, strApp_UserName, "POSEmployee" }; DataSet dsRequestCls = Common.Common.GetDataSetContainsRequestExcelXML(strColumns, strValues, "UnBind"); cls.Request = dsRequestCls; dsResponse = cls.GetData(); } catch (Exception ex) { dt_EditResult.Clear(); dt_EditResult.Rows.Add(new object[] { "4", "解绑失败!" }); m_dsRetrun.Tables.Add(dt_EditResult.Copy()); return; } } } }