Esempio n. 1
0
        private Entities.SendSMSLog LoadSingleSendSMSLog(DataRow row)
        {
            Entities.SendSMSLog model = new Entities.SendSMSLog();

            if (row["RecID"].ToString() != "")
            {
                model.RecID = int.Parse(row["RecID"].ToString());
            }
            if (row["TemplateID"].ToString() != "")
            {
                model.TemplateID = int.Parse(row["TemplateID"].ToString());
            }
            model.CustID = row["CustID"].ToString();
            model.Mobile = row["Mobile"].ToString();
            if (row["SendTime"].ToString() != "")
            {
                model.SendTime = DateTime.Parse(row["SendTime"].ToString());
            }
            model.SendContent = row["SendContent"].ToString();
            if (row["CreateUserID"].ToString() != "")
            {
                model.CreateUserID = int.Parse(row["CreateUserID"].ToString());
            }
            return(model);
        }
        private void Send(out string msg)
        {
            msg = "";
            string[] telArry = Tels.Split(',');
            if (telArry.Length == 0)
            {
                msg = "电话号码不能为空";
                return;
            }
            if (telArry.Length > 2)
            {
                msg = "电话号码不能超过3个";
                return;
            }
            //Regex reTel = new Regex(@"(^13[0-9]{9}$)|(^15[0-9]{9}$)|(^17[0-9]{9}$)|(^18[0-9]{9}$)|(^14[0-9]{9}$)");
            foreach (string str in telArry)
            {
                if (!string.IsNullOrEmpty(str))
                {
                    if (!BLL.Util.IsHandset(str))
                    {
                        msg = "电话(" + str + ")不符合规则";
                        return;
                    }

                    #region 记录发送日志

                    Entities.SendSMSLog smsLogModel = new Entities.SendSMSLog();
                    smsLogModel.CreateUserID = BLL.Util.GetLoginUserID();
                    smsLogModel.CustID       = "无主订单";
                    smsLogModel.Mobile       = str;
                    smsLogModel.SendContent  = SendContent;
                    smsLogModel.SendTime     = DateTime.Now;
                    smsLogModel.TemplateID   = -1;
                    BLL.SendSMSLog.Instance.Insert(smsLogModel);

                    #endregion

                    //发送短信
                    //com.bitauto.mobile.MsgService msgService = new com.bitauto.mobile.MsgService();
                    //string md5 = msgService.MixMd5("6116" + str + SendContent + "Ytt1TEy3hnYIgqTOOIGEc0MFL9wrN0yJJuUUPVfjyM+dkY3ei/8WUc8L7qFqgCbp");
                    //int msgid = msgService.SendMsgImmediately("6116", str, SendContent, "", DateTime.Now.AddHours(1), md5);
                    string md5   = SMSServiceHelper.Instance.MixMd5(str, SendContent);
                    int    msgid = SMSServiceHelper.Instance.SendMsgImmediately(str, SendContent, DateTime.Now.AddHours(1), md5);
                    if (msgid > 0)
                    {
                        //插入发送短信记录
                        BLL.Util.InsertUserLog("给手机(" + str + ")发送短信成功,内容:【" + SendContent + "】");
                    }
                    else
                    {
                        msg = BLL.Util.GetEnumOptText(typeof(Entities.SendSMSInfo), msgid);
                        BLL.Util.InsertUserLog("给手机(" + str + ")发送短信失败【错误信息:" + msg + "】");
                    }
                }
            }
        }
 /// 保存数据表
 /// <summary>
 /// 保存数据表
 /// </summary>
 /// <param name="jsondata"></param>
 /// <param name="loginuserid"></param>
 private void SaveSendSMSLog(CommonCallJsonData jsondata, int loginuserid)
 {
     Entities.SendSMSLog smsLogModel = new Entities.SendSMSLog();
     smsLogModel.TemplateID   = jsondata.SMSData.TemplateID_Out;
     smsLogModel.CustID       = jsondata.CBID;
     smsLogModel.Mobile       = jsondata.SMSData.Phone_Out;
     smsLogModel.SendTime     = DateTime.Now;
     smsLogModel.SendContent  = jsondata.SMSData.Content_Out;
     smsLogModel.CreateUserID = loginuserid;
     BLL.SendSMSLog.Instance.Insert(smsLogModel);
 }
Esempio n. 4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(Entities.SendSMSLog model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@RecID",        SqlDbType.Int,          4),
                new SqlParameter("@TemplateID",   SqlDbType.Int,          4),
                new SqlParameter("@CustID",       SqlDbType.VarChar,     20),
                new SqlParameter("@Mobile",       SqlDbType.VarChar,     11),
                new SqlParameter("@SendTime",     SqlDbType.DateTime),
                new SqlParameter("@SendContent",  SqlDbType.NVarChar,  2000),
                new SqlParameter("@CreateUserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RecID;
            parameters[1].Value = model.TemplateID;
            parameters[2].Value = model.CustID;
            parameters[3].Value = model.Mobile;
            parameters[4].Value = model.SendTime;
            parameters[5].Value = model.SendContent;
            parameters[6].Value = model.CreateUserID;

            return(SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_SENDSMSLOG_UPDATE, parameters));
        }
        /// 发送短信
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="msg"></param>
        public void SendSMSToPeople(out string msg)
        {
            msg = string.Empty;
            try
            {
                string[] telArry = Tels.Split(',');
                if (telArry.Length == 0)
                {
                    msg = "电话号码不能为空";
                    msg = "{result:'false',msg:'" + msg + "'}";
                    return;
                }
                if (telArry.Length > 2)
                {
                    msg = "电话号码不能超过3个";
                    msg = "{result:'false',msg:'" + msg + "'}";
                    return;
                }
                foreach (string str in telArry)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        string telstr = str.Trim();
                        if (!BLL.Util.IsHandset(telstr))
                        {
                            msg = "电话(" + telstr + ")不符合规则";
                            msg = "{result:'false',msg:'" + msg + "'}";
                            return;
                        }
                        //计算客户id
                        string custid = CustID;
                        if (string.IsNullOrEmpty(custid))
                        {
                            custid = BLL.CustBasicInfo.Instance.GetMaxNewCustBasicInfoByTel(telstr);
                        }

                        //插入发送日志
                        Entities.SendSMSLog smsLogModel = new Entities.SendSMSLog();
                        smsLogModel.CreateUserID = BLL.Util.GetLoginUserID();
                        smsLogModel.CustID       = custid;
                        smsLogModel.Mobile       = telstr;
                        smsLogModel.SendContent  = SendContent;
                        smsLogModel.SendTime     = DateTime.Now;
                        smsLogModel.TemplateID   = CommonFunction.ObjectToInteger(TemplateID, -1);
                        BLL.SendSMSLog.Instance.Insert(smsLogModel);

                        //发送短信
                        int    status = -1;
                        string md5    = SMSServiceHelper.Instance.MixMd5(telstr, SendContent);
                        int    msgid  = SMSServiceHelper.Instance.SendMsgImmediately(telstr, SendContent, DateTime.Now.AddHours(1), md5);
                        if (msgid > 0)
                        {
                            //插入发送短信记录
                            status = 0;
                            BLL.Util.InsertUserLog("给手机(" + telstr + ")发送短信成功");
                            msg = "{result:'true',msg:''}";
                        }
                        else
                        {
                            msg = BLL.Util.GetEnumOptText(typeof(Entities.SendSMSInfo), msgid);
                            BLL.Util.InsertUserLog("给手机(" + telstr + ")发送短信失败【错误信息:" + msg + "】");
                            msg = "{result:'false',msg:'" + msg + "'}";
                        }

                        //插入发送短信记录
                        Entities.SMSSendHistory smssendhistory = new Entities.SMSSendHistory();
                        smssendhistory.CreateUserID = BLL.Util.GetLoginUserID();
                        smssendhistory.CustID       = custid;
                        smssendhistory.CRMCustID    = CRMCustID;
                        Entities.EmployeeAgent agent = new Entities.EmployeeAgent();
                        agent = BLL.EmployeeAgent.Instance.GetEmployeeAgentByUserID(Convert.ToInt32(smssendhistory.CreateUserID));
                        if (agent != null && agent.BGID > 0)
                        {
                            smssendhistory.BGID = agent.BGID;
                        }
                        smssendhistory.TemplateID = CommonFunction.ObjectToInteger(TemplateID, -1);
                        smssendhistory.TaskType   = CommonFunction.ObjectToInteger(TaskType, -1);
                        smssendhistory.TaskID     = TaskID;
                        smssendhistory.Phone      = telstr;
                        smssendhistory.Content    = SendContent;
                        smssendhistory.CreateTime = DateTime.Now;
                        smssendhistory.Status     = status;
                        BLL.SMSSendHistory.Instance.Insert(smssendhistory);

                        //成功后返回
                        if (status == 0)
                        {
                            msg = "{result:'true',msg:'',SMSSendHistoryRecID:'" + smssendhistory.RecID + "'}";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                msg = "{result:'false',msg:'" + ex.Message + "'}";
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.SendSMSLog model)
 {
     return(Dal.SendSMSLog.Instance.Update(model));
 }
Esempio n. 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Insert(Entities.SendSMSLog model)
 {
     return(Dal.SendSMSLog.Instance.Insert(model));
 }