Ejemplo n.º 1
0
 /// <summary>
 /// 阿里 短信接口
 /// </summary>
 /// <param name="SMS"></param>
 private static void SendWithAli(this ShortMsgModel SMS)
 {
     SMS.sendText = "{\"code\":\"" + SMS.yzm.Trim() + "\"}";
     if (SMS.statu == "sending")
     {
         string text = new AliSms.AliSms(SMS.accessKeyID, SMS.accessKeySecret)
         {
             PhoneNumbers  = SMS.tel,
             SignName      = SMS.smsSign,
             TemplateCode  = SMS.template,
             TemplateParam = SMS.sendText
         }.Send();
         if (text == "OK")
         {
             SMS.result = "";
             SMS.statu  = "ok";
         }
         else
         {
             SMS.result = text;
             SMS.statu  = "error";
         }
         SMS.sendTime = new System.DateTime?(System.DateTime.Now);
         new ShortMsgBll().Update(SMS);
     }
 }
Ejemplo n.º 2
0
 public static void SendSms(this ShortMsgModel S)
 {
     S.FillFeild();                    //从数据库填充相应字段
     if (!string.IsNullOrEmpty(S.yzm)) //验证码不能为空
     {
         if (!string.IsNullOrEmpty(S.tel))
         {
             bool r = new ShortMsgBll().Add(S);
             if (r)
             {
                 //用阿里短信接口发送
                 if (S.supplier.Equals("ali", StringComparison.OrdinalIgnoreCase))
                 {
                     if (!string.IsNullOrEmpty(S.template))
                     {
                         if (!string.IsNullOrEmpty(S.smsSign))
                         {
                             SendWithAli(S);
                         }
                     }
                 }
                 else  //用默认的云片网短信接口发送
                 {
                     //易开工?
                     if (!string.IsNullOrEmpty(S.smsSign))
                     {
                         SendWithYunPian(S);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 云片网 短信接口
 /// </summary>
 /// <param name="SMS"></param>
 private static void SendWithYunPian(this ShortMsgModel SMS)
 {
     SMS.sendText = SMS.templateParam.Replace("code", SMS.yzm.Trim());
     if (SMS.statu == "sending")
     {
         string text = new YunPianSms.YunPianSms(SMS.accessKeySecret)
         {
             mobile = SMS.tel,
             text   = SMS.sendText
         }.Send();
         if (text == "OK")
         {
             SMS.result = "";
             SMS.remark = "1";
             SMS.statu  = "ok";
         }
         else
         {
             SMS.result = text;
             SMS.remark = "0|" + text;
             SMS.statu  = "error";
         }
         SMS.sendTime = new System.DateTime?(System.DateTime.Now);
         new ShortMsgBll().Update(SMS);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShortMsgModel DataRowToModel(DataRow row)
        {
            ShortMsgModel model = new ShortMsgModel();

            if (row != null)
            {
                if (row["sysnumber"] != null)
                {
                    model.sysnumber = row["sysnumber"].ToString();
                }
                if (row["tel"] != null)
                {
                    model.tel = row["tel"].ToString();
                }
                if (row["yzm"] != null)
                {
                    model.yzm = row["yzm"].ToString();
                }
                if (row["statu"] != null)
                {
                    model.statu = row["statu"].ToString();
                }
                if (row["sendTime"] != null && row["sendTime"].ToString() != "")
                {
                    model.sendTime = DateTime.Parse(row["sendTime"].ToString());
                }
                if (row["outSendTime"] != null && row["outSendTime"].ToString() != "")
                {
                    model.outSendTime = DateTime.Parse(row["outSendTime"].ToString());
                }
                if (row["remark"] != null)
                {
                    model.remark = row["remark"].ToString();
                }
                if (row["template"] != null)
                {
                    model.template = row["template"].ToString();
                }
                if (row["smsSign"] != null)
                {
                    model.smsSign = row["smsSign"].ToString();
                }
                if (row["result"] != null)
                {
                    model.result = row["result"].ToString();
                }
                if (row["sendText"] != null)
                {
                    model.sendText = row["sendText"].ToString();
                }
                if (row["supplier"] != null)
                {
                    model.supplier = row["supplier"].ToString();
                }
            }
            return(model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ShortMsgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_ShortMessage_Log set ");
            strSql.Append("tel=@tel,");
            strSql.Append("yzm=@yzm,");
            strSql.Append("statu=@statu,");
            strSql.Append("sendTime=@sendTime,");
            strSql.Append("outSendTime=@outSendTime,");
            strSql.Append("remark=@remark,");
            strSql.Append("template=@template,");
            strSql.Append("smsSign=@smsSign,");
            strSql.Append("result=@result,");
            strSql.Append("sendText=@sendText,");
            strSql.Append("supplier=@supplier");
            strSql.Append(" where sysnumber=@sysnumber");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sysnumber",   SqlDbType.VarChar,    50),
                new SqlParameter("@tel",         SqlDbType.VarChar,    50),
                new SqlParameter("@yzm",         SqlDbType.VarChar,    10),
                new SqlParameter("@statu",       SqlDbType.VarChar,    20),
                new SqlParameter("@sendTime",    SqlDbType.DateTime),
                new SqlParameter("@outSendTime", SqlDbType.DateTime),
                new SqlParameter("@remark",      SqlDbType.VarChar,   500),
                new SqlParameter("@template",    SqlDbType.VarChar,    50),
                new SqlParameter("@smsSign",     SqlDbType.NVarChar,  100),
                new SqlParameter("@result",      SqlDbType.NVarChar,  200),
                new SqlParameter("@sendText",    SqlDbType.NText),
                new SqlParameter("@supplier",    SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.sysnumber;
            parameters[1].Value  = model.tel;
            parameters[2].Value  = model.yzm;
            parameters[3].Value  = model.statu;
            parameters[4].Value  = model.sendTime;
            parameters[5].Value  = model.outSendTime;
            parameters[6].Value  = model.remark;
            parameters[7].Value  = model.template;
            parameters[8].Value  = model.smsSign;
            parameters[9].Value  = model.result;
            parameters[10].Value = model.sendText;
            parameters[11].Value = model.supplier;
            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ShortMsgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_ShortMessage_Log(");
            strSql.Append("sysnumber,tel,yzm,statu,sendTime,outSendTime,remark,template,smsSign,result,sendText,supplier)");
            strSql.Append(" values (");
            strSql.Append("@sysnumber,@tel,@yzm,@statu,@sendTime,@outSendTime,@remark,@template,@smsSign,@result,@sendText,@supplier)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sysnumber",   SqlDbType.VarChar,    50),
                new SqlParameter("@tel",         SqlDbType.VarChar,    50),
                new SqlParameter("@yzm",         SqlDbType.VarChar,    10),
                new SqlParameter("@statu",       SqlDbType.VarChar,    20),
                new SqlParameter("@sendTime",    SqlDbType.DateTime),
                new SqlParameter("@outSendTime", SqlDbType.DateTime),
                new SqlParameter("@remark",      SqlDbType.VarChar,   500),
                new SqlParameter("@template",    SqlDbType.VarChar,    50),
                new SqlParameter("@smsSign",     SqlDbType.NVarChar,  100),
                new SqlParameter("@result",      SqlDbType.NVarChar,  200),
                new SqlParameter("@sendText",    SqlDbType.NText),
                new SqlParameter("@supplier",    SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.sysnumber;
            parameters[1].Value  = model.tel;
            parameters[2].Value  = model.yzm;
            parameters[3].Value  = model.statu;
            parameters[4].Value  = model.sendTime;
            parameters[5].Value  = model.outSendTime;
            parameters[6].Value  = model.remark;
            parameters[7].Value  = model.template;
            parameters[8].Value  = model.smsSign;
            parameters[9].Value  = model.result;
            parameters[10].Value = model.sendText;
            parameters[11].Value = model.supplier;
            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 补充字段
        /// </summary>
        /// <param name="SMS"></param>
        private static void FillFeild(this ShortMsgModel SMS)
        {
            ShortMsgSupBll   supBll = new ShortMsgSupBll();
            ShortMsgSupModel supMod = supBll.GetDefault();

            if (supMod != null) //数据库没有数据
            {
                List <ShortMsgTempModel> tmpList = supMod.tempList;
                SMS.smsSign         = supMod.smsSign;
                SMS.supplier        = supMod.flag;
                SMS.sysnumber       = Guid.NewGuid().ToString();
                SMS.statu           = "sending";
                SMS.accessKeyID     = supMod.accessKeyID;
                SMS.accessKeySecret = supMod.accessKeySecret;

                //sms.flag  为 reg   or  login 注册登陆
                ShortMsgTempModel tmpMod = tmpList.Find(a => a.isUse == 1 && a.flag == SMS.flag);
                if (tmpMod != null)
                {
                    SMS.template      = tmpMod.templateCode;
                    SMS.templateParam = tmpMod.templateParam;
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ShortMsgModel model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ShortMsgModel model)
 {
     return(dal.Add(model));
 }