public int InsertsObtainGzListSplit(ObtainGzListSplit splitmodel) { using (var helper = new SqlHelper()) { int result = new InternalObtainGzListSplit(helper).InsertsObtainGzListSplit(splitmodel); return(result); } }
internal ObtainGzListSplit GetObtainGzListSplit(int id) { string sql = @"SELECT [id] ,[total] ,[splitcount] ,[splitopenid] ,[splittime] ,[dealerid] ,[comid] ,[obtainno] ,[splitno] ,[issuc] FROM [EtownDB].[dbo].[ObtainGzList_Split] where id=@id"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@id", id); using (var reader = cmd.ExecuteReader()) { ObtainGzListSplit u = null; if (reader.Read()) { u = new ObtainGzListSplit { Id = reader.GetValue <int>("id"), Total = reader.GetValue <int>("total"), Splitcount = reader.GetValue <int>("splitcount"), Splitopenid = reader.GetValue <string>("splitopenid"), Splittime = reader.GetValue <DateTime>("splittime"), Dealerid = reader.GetValue <int>("dealerid"), Comid = reader.GetValue <int>("comid"), Obtainno = reader.GetValue <int>("obtainno"), Splitno = reader.GetValue <int>("splitno"), Issuc = reader.GetValue <int>("issuc"), }; } return(u); } }
protected void Button2_Click(object sender, EventArgs e) { initJavascript(); //获得以前总共抓取关注者列表的次数 int MaxOtainNo = new ObtainGzListLogData().GetMaxObtainNo(comid); if (MaxOtainNo == 0) { Literal2.Text = "还未获取过微信关注者列表"; } else { ////验证一下是否拆分过,拆分过不在拆分 //bool issplited = false; //if (issplited == true) //{ // Literal2.Text = "关注者列表已经拆分过无需再分"; // return; //} //else //{ //获得以前总共拆分过关注者列表的次数 int MaxSplitNo = new ObtainGzListSplitData().MaxSplitNo(comid, MaxOtainNo); IList <ObtainGzListLog> loglist = new ObtainGzListLogData().GetObtaingzlistlog(comid, MaxOtainNo); if (loglist != null) { string openidstr = ""; foreach (ObtainGzListLog log in loglist) { openidstr += log.Openid + ","; } openidstr = openidstr.Substring(0, openidstr.Length - 1); string[] str = openidstr.Split(','); //每20000个一组,判断可以拆分为几组 int splitnum = int.Parse(Math.Ceiling((double)(str.Length) / (double)20000).ToString()); if (splitnum == 1) { ObtainGzListSplit splitmodel = new ObtainGzListSplit { Id = 0, Comid = comid, Dealerid = dealuserid, Total = str.Length, Splitcount = str.Length, Splitno = MaxSplitNo + 1, Obtainno = MaxOtainNo, Splittime = DateTime.Now, Splitopenid = openidstr, Issuc = 1 }; new ObtainGzListSplitData().InsertsObtainGzListSplit(splitmodel); } else { //获取拆分的openid字符串 for (int i = 1; i <= splitnum; i++) { if (i == splitnum) { //录入最后不满20000的openid字符串 string splitopenid = ""; for (int j = 20000 * (splitnum - 1); j < str.Length; j++) { splitopenid += str[j] + ","; } splitopenid = splitopenid.Substring(0, splitopenid.Length - 1); ObtainGzListSplit splitmodel = new ObtainGzListSplit { Id = 0, Comid = comid, Dealerid = dealuserid, Total = str.Length, Splitcount = (str.Length) % 20000, Splitno = MaxSplitNo + 1, Obtainno = MaxOtainNo, Splittime = DateTime.Now, Splitopenid = splitopenid, Issuc = 1 }; new ObtainGzListSplitData().InsertsObtainGzListSplit(splitmodel); } else { string splitopenid = ""; for (int j = 20000 * (i - 1); j < 20000 * i; j++) { splitopenid += str[j] + ","; } splitopenid = splitopenid.Substring(0, splitopenid.Length - 1); ObtainGzListSplit splitmodel = new ObtainGzListSplit { Id = 0, Comid = comid, Dealerid = dealuserid, Total = str.Length, Splitcount = 20000, Splitno = MaxSplitNo + 1, Obtainno = MaxOtainNo, Splittime = DateTime.Now, Splitopenid = splitopenid, Issuc = 1 }; new ObtainGzListSplitData().InsertsObtainGzListSplit(splitmodel); } } } UnloadJavascript(); Literal2.Text = "微信关注者总数目:" + str.Length; BindGrid2(comid, MaxSplitNo + 1, MaxOtainNo); } else { UnloadJavascript(); Literal2.Text = "获取微信关注者列表为空"; } //} } }