public static void GetUserInfo(string User, ref string strUserMail, ref string strRtxAccount) { try { PersonnelService.PersonnelServiceClient Client = new PersonnelService.PersonnelServiceClient(); string[] strUser = new string[1]; strUser[0] = User; PersonnelService.EmployeeContactWays[] List = Client.GetEmployeeToEngine(strUser); if (List.Length > 0) { strUserMail = List[0].MAILADDRESS; //strRtxAccount = List[0].RTX; } } catch (Exception e) { Log.WriteLog("GetUserInfo()调用HRUserInfo出现异常" + e.Message); } }
/// <summary> /// 发送短信 /// </summary> /// <param name="dr"></param> private static void SendDoTaskSMS() { try { DataTable dt = dal.GetSMSDoTask(); if (dt.Rows.Count > 0) { Log.WriteLog("查询到得代办数据总数:" + dt.Rows.Count); SMSService.MessageEntity[] entity = null; string[] strUser = new string[dt.Rows.Count]; IDictionary <string, string> dict = new Dictionary <string, string>(); Hashtable has = new Hashtable(); for (int i = 0; i < dt.Rows.Count; i++) { strUser[i] = dt.Rows[i]["RECEIVEUSERID"].ToString(); has.Add(dt.Rows[i]["RECEIVEUSERID"].ToString(), dt.Rows[i]["TASKCOUNT"].ToString()); } if (strUser != null) { //EMPLOYEESTATE 员工状态 0:试用期、1:在职、2:离职、3:离职中 4:未入职 PersonnelService.EmployeeContactWays[] List = Client.GetEmployeeToEngine(strUser); var employeeOnDuty = from emp in List where emp.EMPLOYEESTATE == "1" || emp.EMPLOYEESTATE == "3" select emp; if (employeeOnDuty != null && employeeOnDuty.Count() > 0) { Log.WriteLog("真实发送短信数据总数:" + dt.Rows.Count); entity = new SMSService.MessageEntity[employeeOnDuty.Count()]; int i = 0; foreach (var employee in employeeOnDuty) { string taskCount = has[employee.EMPLOYEEID].ToString(); string sendMsg = string.Format("温馨提醒:截止{0}您还有{1}条待办任务未处理,请及时处理,谢谢!【协同办公系统】", DateTime.Now.ToString("HH时mm分"), taskCount); dict.Add(employee.EMPLOYEEID, taskCount); entity[i] = new SMSService.MessageEntity(); entity[i].ACCOUNTID = employee.EMPLOYEEID; entity[i].MOBILE = employee.TELPHONE; entity[i].SENDMESSAGE = sendMsg; entity[i].SENDTIME = DateTime.Now; entity[i].REMARK = "引擎发送待办短信"; entity[i].OWNERID = employee.EMPLOYEEID; entity[i].OWNERNAME = employee.EMPLOYEENAME; entity[i].OWNERCOMPANYID = employee.COMPANYID; entity[i].OWNERDEPARTMENTID = employee.DEPARTMENTID; entity[i].OWNERPOSTID = employee.POSTID; entity[i].CREATEUSERID = ""; entity[i].CREATEUSERNAME = "******"; entity[i].CREATECOMPANYID = "bac05c76-0f5b-40ae-b73b-8be541ed35ed"; entity[i].CREATEDEPARTMENTID = employee.DEPARTMENTID; entity[i].CREATEPOSTID = employee.POSTID; entity[i].CREATEDATE = DateTime.Now; entity[i].SMSTYPE = 0; i++; } } #region 插入短信发送的记录 if (entity != null) { for (int i = 0; i < entity.Length; i++) { if (entity[i] != null) { string account = entity[i].ACCOUNTID; T_FLOW_SMSRECORD ent = new T_FLOW_SMSRECORD(); ent.SMSRECORD = Guid.NewGuid().ToString(); ent.SENDTIME = entity[i].SENDTIME; ent.MOBILE = entity[i].MOBILE; ent.COMPANYID = entity[i].CREATECOMPANYID; ent.BATCHNUMBER = string.Format("{0}_{1}", DateTime.Now.ToString("yyyyMMddHHmm"), entity.Length); ent.ACCOUNT = entity[i].ACCOUNTID; ent.OWNERNAME = entity[i].OWNERNAME; ent.SENDSTATUS = 1;//已发送 ent.OWNERID = entity[i].OWNERID; ent.TASKCOUNT = Convert.ToInt32(dict[account]); ent.SENDMESSAGE = entity[i].SENDMESSAGE; dal.AddSMSRecord(ent);//插入发送记录 } } } #endregion try { Log.WriteLog("调用短信接口开始:" + DateTime.Now.ToString()); //调用短信接口服务 string strMsg = client.SendMsg(entity);//调试不发送 Log.WriteLog("调用短信接口结束,返回信息:" + strMsg + DateTime.Now.ToString()); } catch (Exception ex) { Log.WriteLog("调用短信接口结束(异常消息),返回信息:" + ex.ToString() + DateTime.Now.ToString()); } } } } catch (Exception ex) { Log.WriteLog("调用短信SendDoTaskSMS(),返回信息:" + ex.ToString() + DateTime.Now.ToString()); } }