/// <summary> /// 添加一条新规则 /// </summary> /// <param name="rule"></param> /// <returns></returns> public static bool Add(Model.Rule rule) { StringBuilder sb = new StringBuilder(); sb.Append("insert into rules (rulename,ruletype,rulevalue,msgtype,msgvalue,rank,idtime,videotitle,videodescription)"); sb.Append(" values (@rulename,@ruletype,@rulevalue,@msgtype,@msgvalue,@rank,@idtime,@videotitle,@videodescription)"); SqlParameter[] paras = { new SqlParameter("@rulename", rule.RuleName), new SqlParameter("@ruletype", rule.RuleType), new SqlParameter("@rulevalue", rule.RuleValue), new SqlParameter("@msgtype", rule.MsgType), new SqlParameter("@msgvalue", rule.MsgValue), new SqlParameter("@rank", rule.Rank), new SqlParameter("@idtime", rule.IdTime), new SqlParameter("@videotitle", rule.VideoTitle), new SqlParameter("@videodescription", rule.VideoDescription) }; int n = SqlDbHelper.ExecuteNonQuery(sb.ToString(), CommandType.Text, paras); if (n == 0) { return(false); } else { return(true); } }
/// <summary> /// 更新规则 /// </summary> /// <param name="rule"></param> /// <returns></returns> public static bool Update(Model.Rule rule) { StringBuilder sb = new StringBuilder(); sb.Append("update rules set rulename=@rulename,"); sb.Append("msgtype=@msgtype,msgvalue=@msgvalue,"); sb.Append("ruletype=@ruletype,rulevalue=@rulevalue,"); sb.Append("rank=@rank,idtime=@idtime,"); sb.Append("videotitle=@videotitle,videodescription=@videodescription"); sb.Append(" where id = " + rule.ID); SqlParameter[] paras = { new SqlParameter("@rulename", rule.RuleName), new SqlParameter("@msgtype", rule.MsgType), new SqlParameter("@msgvalue", rule.MsgValue), new SqlParameter("@ruletype", rule.RuleType), new SqlParameter("@rulevalue", rule.RuleValue), new SqlParameter("@rank", rule.Rank), new SqlParameter("@idtime", rule.IdTime), new SqlParameter("@videotitle", rule.VideoTitle), new SqlParameter("@videodescription", rule.VideoDescription) }; int n = SqlDbHelper.ExecuteNonQuery(sb.ToString(), CommandType.Text, paras); if (n == 0) { return(false); } else { return(true); } }
/// <summary> /// 根据ID获取规则详细信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static Model.Rule GetRuleById(int id) { Model.Rule rule = new Model.Rule(); StringBuilder sb = new StringBuilder(); sb.Append("select id,rulename,msgtype,msgvalue,ruletype,rulevalue,rank,idtime,videotitle,videodescription from rules"); sb.Append(" where id = " + id); SqlDataReader sdr = SqlDbHelper.ExecuteReader(sb.ToString()); if (sdr.Read()) { rule.ID = id; rule.RuleName = sdr["rulename"].ToString(); rule.MsgType = sdr["msgtype"].ToString(); rule.MsgValue = sdr["msgvalue"].ToString(); rule.RuleType = sdr["ruletype"].ToString(); rule.RuleValue = sdr["rulevalue"].ToString(); rule.Rank = Convert.ToInt32(sdr["rank"]); rule.IdTime = Convert.ToDateTime(sdr["idtime"]); rule.VideoTitle = sdr["videotitle"].ToString(); rule.VideoDescription = sdr["videodescription"].ToString(); return(rule); } return(null); }
private ListViewItem CreateListViewItem(Model.Rule rule) { return (new ListViewItem { Text = rule.Name, SubItems = { string.Join(" И ", rule.Premise), string.Join(", ", rule.Conclusion), rule.Reason }, Tag = rule }); }
protected void Page_Load(object sender, EventArgs e) { mgs.type = "video"; mgs.offset = 0; mgs.count = 50; string corpId = ConfigurationManager.AppSettings["qyhCorpId"]; string secret = ConfigurationManager.AppSettings["qyhSecret"]; qyhModel.Auths.Access_Token qyh = qyhBLL.Require.GetAccessToken(corpId, secret, ref err); if (err.errcode == 0) { string mcRet = qyhBLL.Material.GetMaterialCount(qyh.access_token); mCount = JsonConvert.DeserializeObject <qyhModel.MaterialCount>(mcRet); //获取视频 string strRet = qyhBLL.Material.GetMaterialListPermanent(qyh.access_token, mgs); mList = JsonConvert.DeserializeObject <qyhModel.MaterialListPermanent>(strRet); item.Add("video", mList); //获取图文 mgs.type = "mpnews"; string mpnewsRet = qyhBLL.Material.GetMaterialListPermanent(qyh.access_token, mgs); mpnewsList = JsonConvert.DeserializeObject <qyhModel.MPNews>(mpnewsRet); item.Add("mpnews", mpnewsList); strRet = qyhBLL.Tag.GetTagList(qyh.access_token); tagList = JsonConvert.DeserializeObject <qyhModel.TagList>(strRet); } if (Request["act"] == null) { act = "add"; return; } act = Request["act"]; if (act == "edit") { if (Request["id"] == null) { act = "add"; return; } else { int id = Convert.ToInt32(Request["id"]); rule = Bll.Rule.GetRuleById(id); } } }
/// <summary> /// 判断规则是否存在,存在:返回true,不存在:返回false /// </summary> /// <param name="rule"></param> /// <returns></returns> public static bool CheckRule(Model.Rule rule) { StringBuilder sb = new StringBuilder(); sb.Append("select count(*) from rules"); sb.AppendFormat(" where ruletype='{0}' and rulevalue='{1}'", rule.RuleType, rule.RuleValue); int n = Convert.ToInt32(SqlDbHelper.ExecuteScalar(sb.ToString())); if (n == 0) { return(false); } else { return(true); } }