/// <summary> /// 得到一个对象实体 /// </summary> public Model.weixin_request_content GetModel(int rule_id) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); Model.weixin_request_content model = new Model.weixin_request_content(); //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); foreach (PropertyInfo p in pros) { str1.Append(p.Name + ",");//拼接字段 } strSql.Append("select top 1 " + str1.ToString().Trim(',')); strSql.Append(" from " + databaseprefix + "weixin_request_content"); strSql.Append(" where rule_id=@rule_id"); SqlParameter[] parameters = { new SqlParameter("@rule_id", SqlDbType.Int, 4) }; parameters[0].Value = rule_id; DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0]; if (dt.Rows.Count > 0) { return(DataRowToModel(dt.Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.weixin_request_content DataRowToModel(DataRow row) { Model.weixin_request_content model = new Model.weixin_request_content(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["account_id"] != null && row["account_id"].ToString() != "") { model.account_id = int.Parse(row["account_id"].ToString()); } if (row["rule_id"] != null && row["rule_id"].ToString() != "") { model.rule_id = int.Parse(row["rule_id"].ToString()); } if (row["title"] != null) { model.title = row["title"].ToString(); } if (row["content"] != null) { model.content = row["content"].ToString(); } if (row["link_url"] != null) { model.link_url = row["link_url"].ToString(); } if (row["img_url"] != null) { model.img_url = row["img_url"].ToString(); } if (row["media_id"] != null) { model.media_id = row["media_id"].ToString(); } if (row["media_url"] != null) { model.media_url = row["media_url"].ToString(); } if (row["meida_hd_url"] != null) { model.meida_hd_url = row["meida_hd_url"].ToString(); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } } return(model); }
private bool DoAdd() { bool result = false; Model.weixin_request_rule model = new Model.weixin_request_rule(); BLL.weixin_request_rule bll = new BLL.weixin_request_rule(); model.name = "图文回复"; model.request_type = 1; //关键词回复 model.response_type = 2; //回复的类型:文本1,图文2,语音3,视频4,第三方接口5 model.account_id = Utils.StrToInt(ddlAccountId.SelectedValue, 0); model.keywords = txtKeywords.Text.Trim(); model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); #region 赋值规则图片 string[] itemIdArr = Request.Form.GetValues("item_id"); string[] itemTitleArr = Request.Form.GetValues("item_title"); string[] itemContentArr = Request.Form.GetValues("item_content"); string[] itemImgUrlArr = Request.Form.GetValues("item_imgurl"); string[] itemLinkUrlArr = Request.Form.GetValues("item_linkurl"); string[] itemSortIdArr = Request.Form.GetValues("item_sortid"); if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemSortIdArr != null && itemContentArr != null) { if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length) && (itemLinkUrlArr.Length == itemSortIdArr.Length) && (itemSortIdArr.Length == itemContentArr.Length)) { List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>(); for (int i = 0; i < itemIdArr.Length; i++) { Model.weixin_request_content modelt = new Model.weixin_request_content(); modelt.id = Utils.StrToInt(itemIdArr[i].Trim(), 0); modelt.account_id = model.account_id; modelt.title = itemTitleArr[i].Trim(); modelt.content = itemContentArr[i].Trim(); modelt.img_url = itemImgUrlArr[i].Trim(); modelt.link_url = itemLinkUrlArr[i].Trim(); modelt.sort_id = Utils.StrToInt(itemSortIdArr[i].Trim(), 99); ls.Add(modelt); } model.contents = ls; } } else { model.contents = null; } #endregion if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信图文回复,关健字:" + model.keywords); //记录日志 result = true; } return(result); }
/// <summary> /// 将对象转换实体 /// </summary> public Model.weixin_request_rule DataRowToModel(DataRow row) { Model.weixin_request_rule model = new Model.weixin_request_rule(); if (row != null) { #region 主表信息====================== //利用反射获得属性的所有公共属性 Type modelType = model.GetType(); for (int i = 0; i < row.Table.Columns.Count; i++) { //查找实体是否存在列表相同的公共属性 PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName); if (proInfo != null && row[i] != DBNull.Value) { proInfo.SetValue(model, row[i], null);//用索引值设置属性值 } } #endregion #region 子表信息====================== StringBuilder strSql1 = new StringBuilder(); strSql1.Append("select * from " + databaseprefix + "weixin_request_content"); strSql1.Append(" where rule_id=@rule_id"); SqlParameter[] parameters1 = { new SqlParameter("@rule_id", SqlDbType.Int, 4) }; parameters1[0].Value = model.id; DataTable dt1 = DbHelperSQL.Query(strSql1.ToString(), parameters1).Tables[0]; if (dt1.Rows.Count > 0) { int rowsCount = dt1.Rows.Count; List <Model.weixin_request_content> models = new List <Model.weixin_request_content>(); Model.weixin_request_content modelt; for (int n = 0; n < rowsCount; n++) { modelt = new Model.weixin_request_content(); Type modeltType = modelt.GetType(); for (int i = 0; i < dt1.Rows[n].Table.Columns.Count; i++) { PropertyInfo proInfo = modeltType.GetProperty(dt1.Rows[n].Table.Columns[i].ColumnName); if (proInfo != null && dt1.Rows[n][i] != DBNull.Value) { proInfo.SetValue(modelt, dt1.Rows[n][i], null); } } models.Add(modelt); } model.contents = models; } #endregion } return(model); }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.weixin_request_content DataRowToModel(DataRow row) { Model.weixin_request_content model = new Model.weixin_request_content(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["account_id"] != null && row["account_id"].ToString() != "") { model.account_id = int.Parse(row["account_id"].ToString()); } if (row["rule_id"] != null && row["rule_id"].ToString() != "") { model.rule_id = int.Parse(row["rule_id"].ToString()); } if (row["title"] != null) { model.title = row["title"].ToString(); } if (row["content"] != null) { model.content = row["content"].ToString(); } if (row["link_url"] != null) { model.link_url = row["link_url"].ToString(); } if (row["img_url"] != null) { model.img_url = row["img_url"].ToString(); } if (row["media_url"] != null) { model.media_url = row["media_url"].ToString(); } if (row["meida_hd_url"] != null) { model.meida_hd_url = row["meida_hd_url"].ToString(); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } } return model; }
/// <summary> /// 将对象转换实体 /// </summary> public Model.weixin_request_content DataRowToModel(DataRow row) { Model.weixin_request_content model = new Model.weixin_request_content(); if (row != null) { //利用反射获得属性的所有公共属性 Type modelType = model.GetType(); for (int i = 0; i < row.Table.Columns.Count; i++) { //查找实体是否存在列表相同的公共属性 PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName); if (proInfo != null && row[i] != DBNull.Value) { proInfo.SetValue(model, row[i], null);//用索引值设置属性值 } } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.weixin_request_rule DataRowToModel(DataRow row) { Model.weixin_request_rule model = new Model.weixin_request_rule(); if (row != null) { #region 主表信息====================== if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["account_id"] != null && row["account_id"].ToString() != "") { model.account_id = int.Parse(row["account_id"].ToString()); } if (row["name"] != null) { model.name = row["name"].ToString(); } if (row["keywords"] != null) { model.keywords = row["keywords"].ToString(); } if (row["request_type"] != null && row["request_type"].ToString() != "") { model.request_type = int.Parse(row["request_type"].ToString()); } if (row["response_type"] != null && row["response_type"].ToString() != "") { model.response_type = int.Parse(row["response_type"].ToString()); } if (row["is_like_query"] != null && row["is_like_query"].ToString() != "") { model.is_like_query = int.Parse(row["is_like_query"].ToString()); } if (row["is_default"] != null && row["is_default"].ToString() != "") { model.is_default = int.Parse(row["is_default"].ToString()); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } #endregion #region 子表信息====================== StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select id,account_id,rule_id,title,content,link_url,img_url,media_url,meida_hd_url,sort_id,add_time"); strSql2.Append(" from " + databaseprefix + "weixin_request_content"); strSql2.Append(" where rule_id=@rule_id"); SqlParameter[] parameters2 = { new SqlParameter("@rule_id", SqlDbType.Int,4)}; parameters2[0].Value = model.id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>(); for (int n = 0; n < ds2.Tables[0].Rows.Count; n++) { Model.weixin_request_content modelt = new Model.weixin_request_content(); if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString()); } if (ds2.Tables[0].Rows[n]["account_id"] != null && ds2.Tables[0].Rows[n]["account_id"].ToString() != "") { modelt.account_id = int.Parse(ds2.Tables[0].Rows[n]["account_id"].ToString()); } if (ds2.Tables[0].Rows[n]["rule_id"] != null && ds2.Tables[0].Rows[n]["rule_id"].ToString() != "") { modelt.rule_id = int.Parse(ds2.Tables[0].Rows[n]["rule_id"].ToString()); } if (ds2.Tables[0].Rows[n]["title"] != null) { modelt.title = ds2.Tables[0].Rows[n]["title"].ToString(); } if (ds2.Tables[0].Rows[n]["content"] != null) { modelt.content = ds2.Tables[0].Rows[n]["content"].ToString(); } if (ds2.Tables[0].Rows[n]["link_url"] != null) { modelt.link_url = ds2.Tables[0].Rows[n]["link_url"].ToString(); } if (ds2.Tables[0].Rows[n]["img_url"] != null) { modelt.img_url = ds2.Tables[0].Rows[n]["img_url"].ToString(); } if (ds2.Tables[0].Rows[n]["media_url"] != null) { modelt.media_url = ds2.Tables[0].Rows[n]["media_url"].ToString(); } if (ds2.Tables[0].Rows[n]["meida_hd_url"] != null) { modelt.meida_hd_url = ds2.Tables[0].Rows[n]["meida_hd_url"].ToString(); } if (ds2.Tables[0].Rows[n]["sort_id"] != null && ds2.Tables[0].Rows[n]["sort_id"].ToString() != "") { modelt.sort_id = int.Parse(ds2.Tables[0].Rows[n]["sort_id"].ToString()); } if (ds2.Tables[0].Rows[n]["add_time"] != null && ds2.Tables[0].Rows[n]["add_time"].ToString() != "") { modelt.add_time = DateTime.Parse(ds2.Tables[0].Rows[n]["add_time"].ToString()); } ls.Add(modelt); } model.contents = ls; } #endregion } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.weixin_request_rule DataRowToModel(DataRow row) { Model.weixin_request_rule model = new Model.weixin_request_rule(); if (row != null) { #region 主表信息====================== if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["account_id"] != null && row["account_id"].ToString() != "") { model.account_id = int.Parse(row["account_id"].ToString()); } if (row["name"] != null) { model.name = row["name"].ToString(); } if (row["keywords"] != null) { model.keywords = row["keywords"].ToString(); } if (row["request_type"] != null && row["request_type"].ToString() != "") { model.request_type = int.Parse(row["request_type"].ToString()); } if (row["response_type"] != null && row["response_type"].ToString() != "") { model.response_type = int.Parse(row["response_type"].ToString()); } if (row["is_like_query"] != null && row["is_like_query"].ToString() != "") { model.is_like_query = int.Parse(row["is_like_query"].ToString()); } if (row["is_default"] != null && row["is_default"].ToString() != "") { model.is_default = int.Parse(row["is_default"].ToString()); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } #endregion #region 子表信息====================== StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select id,account_id,rule_id,title,content,link_url,img_url,media_id,media_url,meida_hd_url,sort_id,add_time"); strSql2.Append(" from " + databaseprefix + "weixin_request_content"); strSql2.Append(" where rule_id=@rule_id"); SqlParameter[] parameters2 = { new SqlParameter("@rule_id", SqlDbType.Int, 4) }; parameters2[0].Value = model.id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>(); for (int n = 0; n < ds2.Tables[0].Rows.Count; n++) { Model.weixin_request_content modelt = new Model.weixin_request_content(); if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString()); } if (ds2.Tables[0].Rows[n]["account_id"] != null && ds2.Tables[0].Rows[n]["account_id"].ToString() != "") { modelt.account_id = int.Parse(ds2.Tables[0].Rows[n]["account_id"].ToString()); } if (ds2.Tables[0].Rows[n]["rule_id"] != null && ds2.Tables[0].Rows[n]["rule_id"].ToString() != "") { modelt.rule_id = int.Parse(ds2.Tables[0].Rows[n]["rule_id"].ToString()); } if (ds2.Tables[0].Rows[n]["title"] != null) { modelt.title = ds2.Tables[0].Rows[n]["title"].ToString(); } if (ds2.Tables[0].Rows[n]["content"] != null) { modelt.content = ds2.Tables[0].Rows[n]["content"].ToString(); } if (ds2.Tables[0].Rows[n]["link_url"] != null) { modelt.link_url = ds2.Tables[0].Rows[n]["link_url"].ToString(); } if (ds2.Tables[0].Rows[n]["img_url"] != null) { modelt.img_url = ds2.Tables[0].Rows[n]["img_url"].ToString(); } if (ds2.Tables[0].Rows[n]["media_id"] != null) { modelt.media_id = ds2.Tables[0].Rows[n]["media_id"].ToString(); } if (ds2.Tables[0].Rows[n]["media_url"] != null) { modelt.media_url = ds2.Tables[0].Rows[n]["media_url"].ToString(); } if (ds2.Tables[0].Rows[n]["meida_hd_url"] != null) { modelt.meida_hd_url = ds2.Tables[0].Rows[n]["meida_hd_url"].ToString(); } if (ds2.Tables[0].Rows[n]["sort_id"] != null && ds2.Tables[0].Rows[n]["sort_id"].ToString() != "") { modelt.sort_id = int.Parse(ds2.Tables[0].Rows[n]["sort_id"].ToString()); } if (ds2.Tables[0].Rows[n]["add_time"] != null && ds2.Tables[0].Rows[n]["add_time"].ToString() != "") { modelt.add_time = DateTime.Parse(ds2.Tables[0].Rows[n]["add_time"].ToString()); } ls.Add(modelt); } model.contents = ls; } #endregion } return(model); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { //检查权限 switch (this.action.ToLower()) { case "default": ChkAdminLevel("weixin_subscribe_default", DTEnums.ActionEnum.Edit.ToString()); break; case "cancel": ChkAdminLevel("weixin_subscribe_cancel", DTEnums.ActionEnum.Edit.ToString()); break; default: ChkAdminLevel("weixin_subscribe_subscribe", DTEnums.ActionEnum.Edit.ToString()); break; } //开始保存数据 string ruleName = string.Empty; //规格名称 int ruleId = Utils.StrToInt(hideId.Value, 0); //规则ID int requestType = int.Parse(hideReqestType.Value);//请求的类别 int responseType = int.Parse(rblResponseType.SelectedItem.Value); //回复的类别 if (requestType == 6) { ruleName = "关注时的触发内容"; } else if (requestType == 0) { ruleName = "默认回复内容"; } else if (requestType == 7) { ruleName = "取消关注时的触发内容"; } Model.weixin_request_rule model = new BLL.weixin_request_rule().GetModel(ruleId); if (model == null) { model = new Model.weixin_request_rule(); } model.account_id = this.id; model.name = ruleName; model.request_type = requestType; model.is_default = 0; model.add_time = DateTime.Now; if (responseType == 0) //纯文本 { if (txtContent.Text.Trim().Length == 0) { JscriptMsg("回复内容不能为空!", string.Empty); return; } model.response_type = 1;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>(); ls.Add(new Model.weixin_request_content() { account_id = this.id, rule_id = ruleId, content = txtContent.Text.Trim() }); model.contents = ls; } else if (rblResponseType.SelectedItem.Value == "1") //图文 { model.response_type = 2;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 #region 赋值规则图片 string[] itemIdArr = Request.Form.GetValues("item_id"); string[] itemTitleArr = Request.Form.GetValues("item_title"); string[] itemContentArr = Request.Form.GetValues("item_content"); string[] itemImgUrlArr = Request.Form.GetValues("item_imgurl"); string[] itemLinkUrlArr = Request.Form.GetValues("item_linkurl"); string[] itemSortIdArr = Request.Form.GetValues("item_sortid"); if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemSortIdArr != null && itemContentArr != null) { if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length) && (itemLinkUrlArr.Length == itemSortIdArr.Length) && (itemSortIdArr.Length == itemContentArr.Length)) { List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>(); for (int i = 0; i < itemIdArr.Length; i++) { Model.weixin_request_content modelt = new Model.weixin_request_content(); modelt.id = Utils.StrToInt(itemIdArr[i].Trim(), 0); modelt.account_id = this.id; modelt.rule_id = ruleId; modelt.title = itemTitleArr[i].Trim(); modelt.content = itemContentArr[i].Trim(); modelt.img_url = itemImgUrlArr[i].Trim(); modelt.link_url = itemLinkUrlArr[i].Trim(); modelt.sort_id = Utils.StrToInt(itemSortIdArr[i].Trim(), 99); ls.Add(modelt); } model.contents = ls; } } else { model.contents = null; } #endregion } else if (rblResponseType.SelectedItem.Value == "2") //语音 { if (txtSoundTitle.Text.Trim().Length == 0) { JscriptMsg("语音标题不能为空!", string.Empty); return; } if (txtSoundUrl.Text.Trim().Length == 0) { JscriptMsg("文件地址不能为空!", string.Empty); return; } model.response_type = 3;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>(); ls.Add(new Model.weixin_request_content() { account_id = this.id, rule_id = ruleId, title = txtSoundTitle.Text.Trim(), media_url = txtSoundUrl.Text.Trim(), content = txtSoundContent.Text.Trim() }); model.contents = ls; } //判断是新增还是修改 if (model.id > 0 && new BLL.weixin_request_rule().Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "新增微信" + ruleName); //记录日志 JscriptMsg("编辑" + ruleName + "成功!", "subscribe_edit.aspx?action=" + this.action + "&id=" + this.id); return; } else if (new BLL.weixin_request_rule().Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "编辑微信" + ruleName); //记录日志 JscriptMsg("新增" + ruleName + "成功!", "subscribe_edit.aspx?action=" + this.action + "&id=" + this.id); return; } JscriptMsg("保存" + ruleName + "失败!", string.Empty); return; }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { //检查权限 switch (this.action.ToLower()) { case "default": ChkAdminLevel("weixin_subscribe_default", DTEnums.ActionEnum.Edit.ToString()); break; case "cancel": ChkAdminLevel("weixin_subscribe_cancel", DTEnums.ActionEnum.Edit.ToString()); break; default: ChkAdminLevel("weixin_subscribe_subscribe", DTEnums.ActionEnum.Edit.ToString()); break; } //开始保存数据 string ruleName = string.Empty; //规格名称 int ruleId = Utils.StrToInt(hideId.Value, 0); //规则ID int requestType = int.Parse(hideReqestType.Value); //请求的类别 int responseType = int.Parse(rblResponseType.SelectedItem.Value); //回复的类别 if (requestType == 6) { ruleName = "关注时的触发内容"; } else if (requestType == 0) { ruleName = "默认回复内容"; } else if (requestType == 7) { ruleName = "取消关注时的触发内容"; } Model.weixin_request_rule model = new BLL.weixin_request_rule().GetModel(ruleId); if (model == null) { model = new Model.weixin_request_rule(); } model.account_id = this.id; model.name = ruleName; model.request_type = requestType; model.is_default = 0; model.add_time = DateTime.Now; if (responseType == 0) //纯文本 { if (txtContent.Text.Trim().Length == 0) { JscriptMsg("回复内容不能为空!", string.Empty); return; } model.response_type = 1;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>(); ls.Add(new Model.weixin_request_content() { account_id = this.id, rule_id = ruleId, content = txtContent.Text.Trim() }); model.contents = ls; } else if (rblResponseType.SelectedItem.Value == "1") //图文 { model.response_type = 2; //回复的类型:文本1,图文2,语音3,视频4,第三方接口5 #region 赋值规则图片 string[] itemIdArr = Request.Form.GetValues("item_id"); string[] itemTitleArr = Request.Form.GetValues("item_title"); string[] itemContentArr = Request.Form.GetValues("item_content"); string[] itemImgUrlArr = Request.Form.GetValues("item_imgurl"); string[] itemLinkUrlArr = Request.Form.GetValues("item_linkurl"); string[] itemSortIdArr = Request.Form.GetValues("item_sortid"); if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemSortIdArr != null && itemContentArr != null) { if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length) && (itemLinkUrlArr.Length == itemSortIdArr.Length) && (itemSortIdArr.Length == itemContentArr.Length)) { List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>(); for (int i = 0; i < itemIdArr.Length; i++) { Model.weixin_request_content modelt = new Model.weixin_request_content(); modelt.id = Utils.StrToInt(itemIdArr[i].Trim(), 0); modelt.account_id = this.id; modelt.rule_id = ruleId; modelt.title = itemTitleArr[i].Trim(); modelt.content = itemContentArr[i].Trim(); modelt.img_url = itemImgUrlArr[i].Trim(); modelt.link_url = itemLinkUrlArr[i].Trim(); modelt.sort_id = Utils.StrToInt(itemSortIdArr[i].Trim(), 99); ls.Add(modelt); } model.contents = ls; } } else { model.contents = null; } #endregion } else if (rblResponseType.SelectedItem.Value == "2") //语音 { if (txtSoundTitle.Text.Trim().Length == 0) { JscriptMsg("语音标题不能为空!", string.Empty); return; } if (txtSoundUrl.Text.Trim().Length == 0) { JscriptMsg("文件地址不能为空!", string.Empty); return; } model.response_type = 3;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>(); ls.Add(new Model.weixin_request_content() { account_id = this.id, rule_id = ruleId, title = txtSoundTitle.Text.Trim(), media_url = txtSoundUrl.Text.Trim(), content = txtSoundContent.Text.Trim() }); model.contents = ls; } //判断是新增还是修改 if (model.id > 0 && new BLL.weixin_request_rule().Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "新增微信" + ruleName); //记录日志 JscriptMsg("编辑" + ruleName + "成功!", "subscribe_edit.aspx?action=" + this.action + "&id=" + this.id); return; } else if (new BLL.weixin_request_rule().Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "编辑微信" + ruleName); //记录日志 JscriptMsg("新增" + ruleName + "成功!", "subscribe_edit.aspx?action=" + this.action + "&id=" + this.id); return; } JscriptMsg("保存" + ruleName + "失败!", string.Empty); return; }
private bool DoAdd() { bool result = false; Model.weixin_request_rule model = new Model.weixin_request_rule(); BLL.weixin_request_rule bll = new BLL.weixin_request_rule(); model.name = "图文回复"; model.request_type = 1; //关键词回复 model.response_type = 2; //回复的类型:文本1,图文2,语音3,视频4,第三方接口5 model.account_id = Utils.StrToInt(ddlAccountId.SelectedValue, 0); model.keywords = txtKeywords.Text.Trim(); model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); #region 赋值规则图片 string[] itemIdArr = Request.Form.GetValues("item_id"); string[] itemTitleArr = Request.Form.GetValues("item_title"); string[] itemContentArr = Request.Form.GetValues("item_content"); string[] itemImgUrlArr = Request.Form.GetValues("item_imgurl"); string[] itemLinkUrlArr = Request.Form.GetValues("item_linkurl"); string[] itemSortIdArr = Request.Form.GetValues("item_sortid"); if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemSortIdArr != null && itemContentArr != null) { if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length) && (itemLinkUrlArr.Length == itemSortIdArr.Length) && (itemSortIdArr.Length == itemContentArr.Length)) { List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>(); for (int i = 0; i < itemIdArr.Length; i++) { Model.weixin_request_content modelt = new Model.weixin_request_content(); modelt.id = Utils.StrToInt(itemIdArr[i].Trim(), 0); modelt.account_id = model.account_id; modelt.title = itemTitleArr[i].Trim(); modelt.content = itemContentArr[i].Trim(); modelt.img_url = itemImgUrlArr[i].Trim(); modelt.link_url = itemLinkUrlArr[i].Trim(); modelt.sort_id = Utils.StrToInt(itemSortIdArr[i].Trim(), 99); ls.Add(modelt); } model.contents = ls; } } else { model.contents = null; } #endregion if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信图文回复,关健字:" + model.keywords); //记录日志 result = true; } return result; }