Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="wid">微帐号主键Id</param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public MxWeiXinPF.Model.wx_requestRule GetTop1Model(int wid, string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wId,uId,ruleName,reqKeywords,reqestType,responseType,isDefault,modelFunctionName,modelFunctionId,seq,createDate,agentUrl,agentToken,isLikeSearch,extInt,extInt2,extStr,extStr2,extStr3,extStr4 from wx_requestRule ");
            strSql.Append(" where wId=" + wid);
            if (strWhere != null && strWhere.Length > 0)
            {
                strSql.Append(" and " + strWhere);
            }

            MxWeiXinPF.Model.wx_requestRule model = new MxWeiXinPF.Model.wx_requestRule();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_requestRule GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wId,uId,ruleName,reqKeywords,reqestType,responseType,isDefault,modelFunctionName,modelFunctionId,seq,createDate,agentUrl,agentToken,isLikeSearch,extInt,extInt2,extStr,extStr2,extStr3,extStr4 from wx_requestRule ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_requestRule model = new MxWeiXinPF.Model.wx_requestRule();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_requestRule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_requestRule(");
            strSql.Append("wId,uId,ruleName,reqKeywords,reqestType,responseType,isDefault,modelFunctionName,modelFunctionId,seq,createDate,agentUrl,agentToken,isLikeSearch,extInt,extInt2,extStr,extStr2,extStr3,extStr4)");
            strSql.Append(" values (");
            strSql.Append("@wId,@uId,@ruleName,@reqKeywords,@reqestType,@responseType,@isDefault,@modelFunctionName,@modelFunctionId,@seq,@createDate,@agentUrl,@agentToken,@isLikeSearch,@extInt,@extInt2,@extStr,@extStr2,@extStr3,@extStr4)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wId",               SqlDbType.Int,          4),
                new SqlParameter("@uId",               SqlDbType.Int,          4),
                new SqlParameter("@ruleName",          SqlDbType.VarChar,    200),
                new SqlParameter("@reqKeywords",       SqlDbType.VarChar,   2000),
                new SqlParameter("@reqestType",        SqlDbType.Int,          4),
                new SqlParameter("@responseType",      SqlDbType.Int,          4),
                new SqlParameter("@isDefault",         SqlDbType.Bit,          1),
                new SqlParameter("@modelFunctionName", SqlDbType.VarChar,    200),
                new SqlParameter("@modelFunctionId",   SqlDbType.Int,          4),
                new SqlParameter("@seq",               SqlDbType.Int,          4),
                new SqlParameter("@createDate",        SqlDbType.DateTime),
                new SqlParameter("@agentUrl",          SqlDbType.VarChar,   1000),
                new SqlParameter("@agentToken",        SqlDbType.VarChar,    200),
                new SqlParameter("@isLikeSearch",      SqlDbType.Bit,          1),
                new SqlParameter("@extInt",            SqlDbType.Int,          4),
                new SqlParameter("@extInt2",           SqlDbType.Int,          4),
                new SqlParameter("@extStr",            SqlDbType.VarChar,    200),
                new SqlParameter("@extStr2",           SqlDbType.VarChar,    500),
                new SqlParameter("@extStr3",           SqlDbType.VarChar,    800),
                new SqlParameter("@extStr4",           SqlDbType.VarChar, 1000)
            };
            parameters[0].Value  = model.wId;
            parameters[1].Value  = model.uId;
            parameters[2].Value  = model.ruleName;
            parameters[3].Value  = model.reqKeywords;
            parameters[4].Value  = model.reqestType;
            parameters[5].Value  = model.responseType;
            parameters[6].Value  = model.isDefault;
            parameters[7].Value  = model.modelFunctionName;
            parameters[8].Value  = model.modelFunctionId;
            parameters[9].Value  = model.seq;
            parameters[10].Value = model.createDate;
            parameters[11].Value = model.agentUrl;
            parameters[12].Value = model.agentToken;
            parameters[13].Value = model.isLikeSearch;
            parameters[14].Value = model.extInt;
            parameters[15].Value = model.extInt2;
            parameters[16].Value = model.extStr;
            parameters[17].Value = model.extStr2;
            parameters[18].Value = model.extStr3;
            parameters[19].Value = model.extStr4;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_requestRule DataRowToModel(DataRow row)
        {
            MxWeiXinPF.Model.wx_requestRule model = new MxWeiXinPF.Model.wx_requestRule();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["wId"] != null && row["wId"].ToString() != "")
                {
                    model.wId = int.Parse(row["wId"].ToString());
                }

                if (row["uId"] != null && row["uId"].ToString() != "")
                {
                    model.uId = int.Parse(row["uId"].ToString());
                }
                if (row["ruleName"] != null)
                {
                    model.ruleName = row["ruleName"].ToString();
                }
                if (row["reqKeywords"] != null)
                {
                    model.reqKeywords = row["reqKeywords"].ToString();
                }
                if (row["reqestType"] != null && row["reqestType"].ToString() != "")
                {
                    model.reqestType = int.Parse(row["reqestType"].ToString());
                }
                if (row["responseType"] != null && row["responseType"].ToString() != "")
                {
                    model.responseType = int.Parse(row["responseType"].ToString());
                }
                if (row["isDefault"] != null && row["isDefault"].ToString() != "")
                {
                    if ((row["isDefault"].ToString() == "1") || (row["isDefault"].ToString().ToLower() == "true"))
                    {
                        model.isDefault = true;
                    }
                    else
                    {
                        model.isDefault = false;
                    }
                }
                if (row["modelFunctionName"] != null)
                {
                    model.modelFunctionName = row["modelFunctionName"].ToString();
                }
                if (row["modelFunctionId"] != null && row["modelFunctionId"].ToString() != "")
                {
                    model.modelFunctionId = int.Parse(row["modelFunctionId"].ToString());
                }
                if (row["seq"] != null && row["seq"].ToString() != "")
                {
                    model.seq = int.Parse(row["seq"].ToString());
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["agentUrl"] != null)
                {
                    model.agentUrl = row["agentUrl"].ToString();
                }
                if (row["agentToken"] != null)
                {
                    model.agentToken = row["agentToken"].ToString();
                }
                if (row["isLikeSearch"] != null && row["isLikeSearch"].ToString() != "")
                {
                    if ((row["isLikeSearch"].ToString() == "1") || (row["isLikeSearch"].ToString().ToLower() == "true"))
                    {
                        model.isLikeSearch = true;
                    }
                    else
                    {
                        model.isLikeSearch = false;
                    }
                }
                if (row["extInt"] != null && row["extInt"].ToString() != "")
                {
                    model.extInt = int.Parse(row["extInt"].ToString());
                }
                if (row["extInt2"] != null && row["extInt2"].ToString() != "")
                {
                    model.extInt2 = int.Parse(row["extInt2"].ToString());
                }
                if (row["extStr"] != null)
                {
                    model.extStr = row["extStr"].ToString();
                }
                if (row["extStr2"] != null)
                {
                    model.extStr2 = row["extStr2"].ToString();
                }
                if (row["extStr3"] != null)
                {
                    model.extStr3 = row["extStr3"].ToString();
                }
                if (row["extStr4"] != null)
                {
                    model.extStr4 = row["extStr4"].ToString();
                }
            }
            return(model);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_requestRule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_requestRule set ");
            strSql.Append("wId=@wId,");
            strSql.Append("uId=@uId,");
            strSql.Append("ruleName=@ruleName,");
            strSql.Append("reqKeywords=@reqKeywords,");
            strSql.Append("reqestType=@reqestType,");
            strSql.Append("responseType=@responseType,");
            strSql.Append("isDefault=@isDefault,");
            strSql.Append("modelFunctionName=@modelFunctionName,");
            strSql.Append("modelFunctionId=@modelFunctionId,");
            strSql.Append("seq=@seq,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("agentUrl=@agentUrl,");
            strSql.Append("agentToken=@agentToken,");
            strSql.Append("isLikeSearch=@isLikeSearch,");
            strSql.Append("extInt=@extInt,");
            strSql.Append("extInt2=@extInt2,");
            strSql.Append("extStr=@extStr,");
            strSql.Append("extStr2=@extStr2,");
            strSql.Append("extStr3=@extStr3,");
            strSql.Append("extStr4=@extStr4");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wId",               SqlDbType.Int,          4),
                new SqlParameter("@uId",               SqlDbType.Int,          4),
                new SqlParameter("@ruleName",          SqlDbType.VarChar,    200),
                new SqlParameter("@reqKeywords",       SqlDbType.VarChar,   2000),
                new SqlParameter("@reqestType",        SqlDbType.Int,          4),
                new SqlParameter("@responseType",      SqlDbType.Int,          4),
                new SqlParameter("@isDefault",         SqlDbType.Bit,          1),
                new SqlParameter("@modelFunctionName", SqlDbType.VarChar,    200),
                new SqlParameter("@modelFunctionId",   SqlDbType.Int,          4),
                new SqlParameter("@seq",               SqlDbType.Int,          4),
                new SqlParameter("@createDate",        SqlDbType.DateTime),
                new SqlParameter("@agentUrl",          SqlDbType.VarChar,   1000),
                new SqlParameter("@agentToken",        SqlDbType.VarChar,    200),
                new SqlParameter("@isLikeSearch",      SqlDbType.Bit,          1),
                new SqlParameter("@extInt",            SqlDbType.Int,          4),
                new SqlParameter("@extInt2",           SqlDbType.Int,          4),
                new SqlParameter("@extStr",            SqlDbType.VarChar,    200),
                new SqlParameter("@extStr2",           SqlDbType.VarChar,    500),
                new SqlParameter("@extStr3",           SqlDbType.VarChar,    800),
                new SqlParameter("@extStr4",           SqlDbType.VarChar,   1000),
                new SqlParameter("@id",                SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wId;
            parameters[1].Value  = model.uId;
            parameters[2].Value  = model.ruleName;
            parameters[3].Value  = model.reqKeywords;
            parameters[4].Value  = model.reqestType;
            parameters[5].Value  = model.responseType;
            parameters[6].Value  = model.isDefault;
            parameters[7].Value  = model.modelFunctionName;
            parameters[8].Value  = model.modelFunctionId;
            parameters[9].Value  = model.seq;
            parameters[10].Value = model.createDate;
            parameters[11].Value = model.agentUrl;
            parameters[12].Value = model.agentToken;
            parameters[13].Value = model.isLikeSearch;
            parameters[14].Value = model.extInt;
            parameters[15].Value = model.extInt2;
            parameters[16].Value = model.extStr;
            parameters[17].Value = model.extStr2;
            parameters[18].Value = model.extStr3;
            parameters[19].Value = model.extStr4;
            parameters[20].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }