Пример #1
0
        public ShortMsgSupModel GetDefault()
        {
            string strWhere = "isUse=1";
            List <ShortMsgSupModel> list = GetModelList(strWhere);

            if (list.Count > 0)
            {
                ShortMsgSupModel m = list.Find(a => a.isDefault == 1);
                if (m != null)
                {
                    ShortMsgTempBll          tmpBll  = new ShortMsgTempBll();
                    List <ShortMsgTempModel> tmpList = tmpBll.GetModelList("supplierFlag='" + m.flag + "' and supplierId=" + m.supplierId);
                    m.tempList = tmpList;
                    return(m);
                }
                else
                {
                    return(list[0]);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ShortMsgSupModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_ShortMessage_Supplier set ");
            strSql.Append("flag=@flag,");
            strSql.Append("supplierName=@supplierName,");
            strSql.Append("smsSign=@smsSign,");
            strSql.Append("accessKeyID=@accessKeyID,");
            strSql.Append("accessKeySecret=@accessKeySecret,");
            strSql.Append("isUse=@isUse,");
            strSql.Append("isDefault=@isDefault,");
            strSql.Append("sort=@sort");
            strSql.Append(" where supplierId=@supplierId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@supplierId",      SqlDbType.VarChar,   50),
                new SqlParameter("@flag",            SqlDbType.VarChar,   50),
                new SqlParameter("@supplierName",    SqlDbType.NVarChar, 100),
                new SqlParameter("@smsSign",         SqlDbType.NVarChar,  50),
                new SqlParameter("@accessKeyID",     SqlDbType.NVarChar,  50),
                new SqlParameter("@accessKeySecret", SqlDbType.NVarChar,  50),
                new SqlParameter("@isUse",           SqlDbType.Int,        4),
                new SqlParameter("@isDefault",       SqlDbType.Int,        4),
                new SqlParameter("@sort",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.supplierId;
            parameters[1].Value = model.flag;
            parameters[2].Value = model.supplierName;
            parameters[3].Value = model.smsSign;
            parameters[4].Value = model.accessKeyID;
            parameters[5].Value = model.accessKeySecret;
            parameters[6].Value = model.isUse;
            parameters[7].Value = model.isDefault;
            parameters[8].Value = model.sort;

            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShortMsgSupModel DataRowToModel(DataRow row)
        {
            ShortMsgSupModel model = new ShortMsgSupModel();

            if (row != null)
            {
                if (row["supplierId"] != null)
                {
                    model.supplierId = row["supplierId"].ToString();
                }
                if (row["flag"] != null)
                {
                    model.flag = row["flag"].ToString();
                }
                if (row["supplierName"] != null)
                {
                    model.supplierName = row["supplierName"].ToString();
                }
                if (row["smsSign"] != null)
                {
                    model.smsSign = row["smsSign"].ToString();
                }
                if (row["accessKeyID"] != null)
                {
                    model.accessKeyID = row["accessKeyID"].ToString();
                }
                if (row["accessKeySecret"] != null)
                {
                    model.accessKeySecret = row["accessKeySecret"].ToString();
                }
                if (row["isUse"] != null && row["isUse"].ToString() != "")
                {
                    model.isUse = int.Parse(row["isUse"].ToString());
                }
                if (row["isDefault"] != null && row["isDefault"].ToString() != "")
                {
                    model.isDefault = int.Parse(row["isDefault"].ToString());
                }
                if (row["sort"] != null && row["sort"].ToString() != "")
                {
                    model.sort = int.Parse(row["sort"].ToString());
                }
            }
            return(model);
        }
Пример #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ShortMsgSupModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_ShortMessage_Supplier(");
            strSql.Append("supplierId,flag,supplierName,smsSign,accessKeyID,accessKeySecret,isUse,isDefault,sort)");
            strSql.Append(" values (");
            strSql.Append("@supplierId,@flag,@supplierName,@smsSign,@accessKeyID,@accessKeySecret,@isUse,@isDefault,@sort)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@supplierId",      SqlDbType.VarChar,   50),
                new SqlParameter("@flag",            SqlDbType.VarChar,   50),
                new SqlParameter("@supplierName",    SqlDbType.NVarChar, 100),
                new SqlParameter("@smsSign",         SqlDbType.NVarChar,  50),
                new SqlParameter("@accessKeyID",     SqlDbType.NVarChar,  50),
                new SqlParameter("@accessKeySecret", SqlDbType.NVarChar,  50),
                new SqlParameter("@isUse",           SqlDbType.Int,        4),
                new SqlParameter("@isDefault",       SqlDbType.Int,        4),
                new SqlParameter("@sort",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.supplierId;
            parameters[1].Value = model.flag;
            parameters[2].Value = model.supplierName;
            parameters[3].Value = model.smsSign;
            parameters[4].Value = model.accessKeyID;
            parameters[5].Value = model.accessKeySecret;
            parameters[6].Value = model.isUse;
            parameters[7].Value = model.isDefault;
            parameters[8].Value = model.sort;
            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShortMsgSupModel GetModel(string supplierId)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 supplierId,flag,supplierName,smsSign,accessKeyID,accessKeySecret,isUse,isDefault,sort from T_ShortMessage_Supplier ");
            strSql.Append(" where supplierId=@supplierId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@supplierId", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = supplierId;
            ShortMsgSupModel model = new ShortMsgSupModel();
            DataSet          ds    = adoHelper.ExecuteSqlDataset(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
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;
                }
            }
        }
Пример #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ShortMsgSupModel model)
 {
     return(dal.Update(model));
 }
Пример #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ShortMsgSupModel model)
 {
     return(dal.Add(model));
 }