public void UpdateMediaID(string updateValue, string wxstring) { MeidaInformation objMeida = JsonConvert.DeserializeObject <MeidaInformation>(wxstring); CRMLIBASHX obj = JsonConvert.DeserializeObject <CRMLIBASHX>(updateValue); DbConnection conn = CyDbConnManager.GetDbConnection("CRMDB"); try { conn.Open(); } catch (Exception e) { throw new MyDbException(e.Message, true); } CyQuery query = new CyQuery(conn); try { query.SQL.Text = "update WX_MEDIADY set MEDIA_ID=:MEDIA_ID where JLBH=:JLBH"; query.ParamByName("MEDIA_ID").AsString = objMeida.media_id; query.ParamByName("JLBH").AsInteger = obj.iJLBH; query.ExecSQL(); } catch (Exception e) { if (e is MyDbException) { throw e; } throw new MyDbException(e.Message, query.SqlText); } }
public override List <TagJsonBQ> GetTagList(out string msg, string PUBLICID, string PUBLICIF, string updateValue, HttpContext context = null) { msg = string.Empty; method = "POST"; //var PUBLICIF1 = "http://wx.changyi.com/SaveWeChatData.ashx"; //Token = (new WX_Token()).getToken(PUBLICIF1); Token = (new WX_Token()).getToken(PUBLICIF); Token1 oToken = new Token1(); oToken = JsonConvert.DeserializeObject <Token1>(Token); Url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token=" + oToken.result; var result = JsonHelper <TagresultBQ> .ConvertJsonGET(Url); DbConnection conn = CyDbConnManager.GetActiveDbConnection("CRMDB"); CyQuery query = new CyQuery(conn); for (var i = 0; i < result.tags.Count; i++) { query.SQL.Text = "update WX_BQDY set COUNT=:COUNT"; query.SQL.Add(" where TAGID=:TAGID"); query.ParamByName("TAGID").AsInteger = result.tags[i].id; query.ParamByName("COUNT").AsInteger = result.tags[i].count; query.ExecSQL(); } return(result.tags); }
public override string DeleteNews(out string msg, string PUBLICID, string PUBLICIF, string updateValue, HttpContext context = null) { method = "POST"; Token = (new WX_Token()).getToken(PUBLICIF); Token1 oToken = new Token1(); oToken = JsonConvert.DeserializeObject <Token1>(Token); Url = "https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=" + oToken.result; string wxstring = WXRequestString(out msg, context, updateValue); if (msg.Length > 0) { WriteToLog(msg); } else { MeidaInformation objMeida = JsonConvert.DeserializeObject <MeidaInformation>(updateValue); DbConnection conn = CyDbConnManager.GetDbConnection("CRMDB"); try { conn.Open(); } catch (Exception e) { throw new MyDbException(e.Message, true); } CyQuery query = new CyQuery(conn); try { query.SQL.Text = "delete from WX_MEDIADY where MEDIA_ID=:MEDIA_ID"; query.ParamByName("MEDIA_ID").AsString = objMeida.media_id; query.ExecSQL(); query.SQL.Text = "delete from WX_NEWSDY_ITEM where JLBH=(select JLBH from WX_MEDIADY where MEDIA_ID=:MEDIA_ID)"; query.ParamByName("MEDIA_ID").AsString = objMeida.media_id; query.ExecSQL(); } catch (Exception e) { if (e is MyDbException) { throw e; } throw new MyDbException(e.Message, query.SqlText); } } return(wxstring); }
public override TagJson CreateTag(out string msg, string PUBLICID, string PUBLICIF, string updateValue, HttpContext context = null) { msg = string.Empty; method = "POST"; //var PUBLICIF1 = "http://wx.changyi.com/SaveWeChatData.ashx"; //Token = (new WX_Token()).getToken(PUBLICIF1); Token = (new WX_Token()).getToken(PUBLICIF); Token1 oToken = new Token1(); oToken = JsonConvert.DeserializeObject <Token1>(Token); Url = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=" + oToken.result; //BQ content_out = new BQ(); var data = new { tag = new { name = updateValue } }; var postData = JsonConvert.SerializeObject(data); var postData1 = JsonConvert.DeserializeObject(postData); var postData2 = (postData1.ToString()); var result = JsonHelper <Tagresult> .ConvertJson(Url, postData2); DbConnection conn = CyDbConnManager.GetActiveDbConnection("CRMDB"); CyQuery query = new CyQuery(conn); if (result.tag.id != 0 && result.tag.name != null) { query.SQL.Text = "update WX_BQDY set TAGID=:TAGID"; query.SQL.Add(" where TAGMC=:TAGMC"); query.ParamByName("TAGID").AsInteger = result.tag.id; query.ParamByName("TAGMC").AsString = result.tag.name; //query.ParamByName("COUNT").AsInteger = result.tag.count; query.ExecSQL(); } return(result.tag); }
public override TagJsonBJ UpdateTag(out string msg, string PUBLICID, string PUBLICIF, string updateValue, HttpContext context = null) { msg = string.Empty; method = "POST"; //var PUBLICIF1 = "http://wx.changyi.com/SaveWeChatData.ashx"; //Token = (new WX_Token()).getToken(PUBLICIF1); Token1 oToken = new Token1(); oToken = JsonConvert.DeserializeObject <Token1>(Token); Url = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token=" + oToken.result; var result = JsonHelper <TagJsonBJ> .ConvertJson(Url, updateValue); string str = updateValue; JObject o = JObject.Parse(str); var id = o["tag"]["id"].ToString(); var name = o["tag"]["name"].ToString(); DbConnection conn = CyDbConnManager.GetActiveDbConnection("CRMDB"); CyQuery query = new CyQuery(conn); query.SQL.Text = "update WX_BQDY set TAGMC=:TAGMC"; query.SQL.Add(" where TAGID=:TAGID"); query.ParamByName("TAGID").AsInteger = int.Parse(id); query.ParamByName("TAGMC").AsString = name; query.ExecSQL(); return(result); }
//批量取消标签 public override TagJsonBJ PLQXBQTag(out string msg, string PUBLICID, string PUBLICIF, string updateValue, string iDJR, string sDJRMC, HttpContext context = null) { msg = string.Empty; method = "POST"; //var PUBLICIF1 = "http://wx.changyi.com/SaveWeChatData.ashx"; //Token = (new WX_Token()).getToken(PUBLICIF1); Token = (new WX_Token()).getToken(PUBLICIF); Token1 oToken = new Token1(); oToken = JsonConvert.DeserializeObject <Token1>(Token); Url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=" + oToken.result; var result = JsonHelper <TagJsonBJ> .ConvertJson(Url, updateValue); string str = updateValue; JObject o = JObject.Parse(str); var tagid = o["tagid"].ToString(); var openid_LS = o["openid_list"]; string str_LS = openid_LS.ToString(); int count = str_LS.Split(',').Length; DbConnection conn = CyDbConnManager.GetActiveDbConnection("CRMDB"); CyQuery query = new CyQuery(conn); if (result.errmsg == "ok") { for (var i = 0; i < count; i++) { var openid = o["openid_list"][i].ToString(); query.SQL.Text = "update WX_HYBQJL set CZLX=3"; query.SQL.Add(" where OPENID=:OPENID AND TAGID=:TAGID "); query.ParamByName("TAGID").AsInteger = int.Parse(tagid); query.ParamByName("OPENID").AsString = openid; query.ExecSQL(); query.SQL.Text = "delete from WX_HYBQ where TAGID=" + int.Parse(tagid) + "And OPENID=" + "'" + openid + "'"; query.ExecSQL(); } } else { for (var i = 0; i < count; i++) { var openid = o["openid_list"][i].ToString(); query.SQL.Text = "update WX_HYBQJL set CZLX=4"; query.SQL.Add(" where OPENID=:OPENID AND TAGID=:TAGID "); query.ParamByName("TAGID").AsInteger = int.Parse(tagid); query.ParamByName("OPENID").AsString = openid; query.ExecSQL(); } } return(result); }
//批量打标签 public override TagJsonBJ PLDBQTag(out string msg, string PUBLICID, string PUBLICIF, string updateValue, string iDJR, string sDJRMC, HttpContext context = null) { msg = string.Empty; method = "POST"; //var PUBLICIF1 = "http://wx.changyi.com/SaveWeChatData.ashx"; //Token = (new WX_Token()).getToken(PUBLICIF1); Token = (new WX_Token()).getToken(PUBLICIF); Token1 oToken = new Token1(); oToken = JsonConvert.DeserializeObject <Token1>(Token); Url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=" + oToken.result; string str = updateValue; JObject o = JObject.Parse(str); var tagid = o["tagid"].ToString(); var openid_LS = o["openid_list"]; string str_LS = openid_LS.ToString(); int count = str_LS.Split(',').Length; DbConnection conn = CyDbConnManager.GetActiveDbConnection("CRMDB"); CyQuery query = new CyQuery(conn); for (var i = 0; i < count; i++) { var openid = o["openid_list"][i].ToString(); int iJLBH = SeqGenerator.GetSeq("WX_HYBQJL"); query.SQL.Text = "insert into WX_HYBQJL(JLBH,TAGID,OPENID,DJR,DJRMC,DJSJ,CZLX,PUBLICID)"; query.SQL.Add(" values(:JLBH,:TAGID,:OPENID,:DJR,:DJRMC,:DJSJ,:CZLX,:PUBLICID)"); query.ParamByName("JLBH").AsInteger = iJLBH; query.ParamByName("DJR").AsInteger = int.Parse(iDJR); query.ParamByName("DJRMC").AsString = sDJRMC; query.ParamByName("OPENID").AsString = openid; query.ParamByName("TAGID").AsInteger = int.Parse(tagid); query.ParamByName("CZLX").AsInteger = 0; query.ParamByName("DJSJ").AsDateTime = DateTime.Now; query.ParamByName("PUBLICID").AsInteger = int.Parse(PUBLICID); query.ExecSQL(); } var result = JsonHelper <TagJsonBJ> .ConvertJson(Url, updateValue); if (result.errmsg == "ok") { for (var i = 0; i < count; i++) { var openid = o["openid_list"][i].ToString(); query.SQL.Text = "update WX_HYBQJL set CZLX=1"; query.SQL.Add(" where OPENID=:OPENID AND TAGID=:TAGID "); query.ParamByName("TAGID").AsInteger = int.Parse(tagid); query.ParamByName("OPENID").AsString = openid; query.ExecSQL(); query.SQL.Text = "select * FROM WX_HYBQ where TAGID=" + int.Parse(tagid) + "and OPENID=" + "'" + openid + "'"; query.Open(); if (query.IsEmpty) { query.SQL.Text = "insert into WX_HYBQ(TAGID,OPENID,CREATETIME,PUBLICID)"; query.SQL.Add(" values(:TAGID,:OPENID,:CREATETIME,:PUBLICID)"); query.ParamByName("TAGID").AsInteger = int.Parse(tagid); query.ParamByName("OPENID").AsString = openid; query.ParamByName("CREATETIME").AsDateTime = DateTime.Now; query.ParamByName("PUBLICID").AsInteger = int.Parse(PUBLICID); query.ExecSQL(); } } } else { for (var i = 0; i < count; i++) { var openid = o["openid_list"][i].ToString(); query.SQL.Text = "update WX_HYBQJL set CZLX=2"; query.SQL.Add(" where OPENID=:OPENID AND TAGID=:TAGID "); query.ParamByName("TAGID").AsInteger = int.Parse(tagid); query.ParamByName("OPENID").AsString = openid; query.ExecSQL(); } } return(result); }