Exemplo n.º 1
0
 /// <summary>
 /// 插入一条发送短信的记录
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>int</returns>
 public int AddSMSRecord(T_FLOW_SMSRECORD entity)
 {
     try
     {
         string sql = "INSERT INTO T_WF_SMSRECORD(SMSRECORD,BATCHNUMBER,COMPANYID,SENDSTATUS,ACCOUNT,MOBILE,SENDMESSAGE,SENDTIME,OWNERID,OWNERNAME,TASKCOUNT,REMARK) ";
         sql += " VALUES ('" + entity.SMSRECORD + "','" + entity.BATCHNUMBER + "','" + entity.COMPANYID + "','" + entity.SENDSTATUS + "','" + entity.ACCOUNT + "',";
         sql += " '" + entity.MOBILE + "','" + entity.SENDMESSAGE + "',to_date('" + entity.SENDTIME + "','YYYY-MM-DD hh24:mi:ss'),'" + entity.OWNERID + "','" + entity.OWNERNAME + "'," + entity.TASKCOUNT + ",'" + entity.REMARK + "')";
         dao.Open();
         int result = dao.ExecuteNonQuery(sql);
         return(result);
     }
     catch (Exception ex)
     {
         Log.WriteLog(this, "AddSMSRecord()", "插入一条发送短信的记录", ex);
         return(0);
     }
     finally
     {
         dao.Close();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 插入一条发送短信的记录
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>int</returns>
        public int AddSMSRecord(T_FLOW_SMSRECORD entity)
        {
            try
            {
                string sql = "INSERT INTO T_WF_SMSRECORD(SMSRECORD,BATCHNUMBER,COMPANYID,SENDSTATUS,ACCOUNT,MOBILE,SENDMESSAGE,SENDTIME,OWNERID,OWNERNAME,TASKCOUNT,REMARK) ";
                sql += " VALUES ('" + entity.SMSRECORD + "','" + entity.BATCHNUMBER + "','" + entity.COMPANYID + "','" + entity.SENDSTATUS + "','" + entity.ACCOUNT + "',";
                sql += " '" + entity.MOBILE + "','" + entity.SENDMESSAGE + "',to_date('" + entity.SENDTIME + "','YYYY-MM-DD hh24:mi:ss'),'" + entity.OWNERID + "','" + entity.OWNERNAME + "'," + entity.TASKCOUNT + ",'" + entity.REMARK + "')";

                int result = dao.ExecuteNonQuery(sql);
                return result;
            }
            catch (Exception ex)
            {
                Log.WriteLog(this, "AddSMSRecord()", "插入一条发送短信的记录", ex);
                return 0;
            }
            finally
            {

            }
        }
Exemplo n.º 3
0
        /// <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());
            }
        }
Exemplo n.º 4
0
 private static void SendSMS(DataRow dr)
 {
     try
     {
         if (dr["RECEIVERUSERID"] != null&&dr["MESSAGEBODY"]!=null)
         {
             SMSService.MessageEntity[] entity = new SMSService.MessageEntity[1];
             entity[0] = new SMSService.MessageEntity();
             entity[0].ACCOUNTID = Config.Account;
             entity[0].MOBILE = dr["RECEIVERUSERID"].ToString();
             entity[0].SENDMESSAGE = dr["MESSAGEBODY"].ToString();
             entity[0].SENDTIME = DateTime.Now;
             entity[0].REMARK = "新平台短信提醒";
             entity[0].OWNERID = "";
             entity[0].OWNERNAME = dr["RECEIVERNAME"].ToString();
             entity[0].OWNERCOMPANYID = "";
             entity[0].OWNERDEPARTMENTID = "";
             entity[0].OWNERPOSTID = "";
             entity[0].CREATEUSERID = "";
             entity[0].CREATEUSERNAME = "******";
             entity[0].CREATECOMPANYID = "bac05c76-0f5b-40ae-b73b-8be541ed35ed";
             entity[0].CREATEDEPARTMENTID = "";
             entity[0].CREATEPOSTID = "";
             entity[0].CREATEDATE = DateTime.Now;
             entity[0].SMSTYPE = 0;
             T_FLOW_SMSRECORD ent = new T_FLOW_SMSRECORD();
             ent.SMSRECORD = Guid.NewGuid().ToString();
             ent.SENDTIME = DateTime.Now;
             ent.MOBILE = dr["RECEIVERUSERID"].ToString();
             ent.COMPANYID = "系统发送短信提醒";
             ent.BATCHNUMBER = string.Format("{0}_{1}", DateTime.Now.ToString("yyyyMMddHHmm"), entity.Length);
             ent.ACCOUNT = Config.Account;
             ent.OWNERNAME = dr["RECEIVERNAME"].ToString();
             ent.SENDSTATUS = 1;//已发送
             ent.OWNERID = "";
             ent.TASKCOUNT = 1;
             ent.SENDMESSAGE = dr["MESSAGEBODY"].ToString();
             dal.AddSMSRecord(ent);//插入发送记录
             try
             {                    
                 //调用短信接口服务
                 string strMsg = client.SendMsg(entity);//调试不发送
                 Log.WriteLog("调用短信接口结束,返回信息SendSMS():" + strMsg +  dr["RECEIVERNAME"].ToString());
             }
             catch (Exception ex)
             {
                 Log.WriteLog("调用短信接口结束(异常消息),返回信息SendSMS():" + ex.ToString() + DateTime.Now.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         Log.WriteLog("调用短信SendSMS(),返回信息:" + ex.ToString());
     }
 }