private void QuartzGuidForach(object quartzParam) { if (this.InvokeRequired) {//是否通过其他形式调用 DelegateData.BaseDelegate bd = new DelegateData.BaseDelegate(QuartzGuidForach); this.Invoke(bd, quartzParam); return; } LoggerWriter.CreateLogFile(Cookie, (new QQDataDA().GeneratePathTimeSpan(Cookie)), ELogType.SessionOrCookieLog); QueryQQParam param = GetBaseQueryParam(); QQDataDA da = new QQDataDA(); da.QueryParam = param; PickUpQQDoResponse response = da.QueryQQData(Cookie); // QueryTodayPickUp(); //为下一次产生随机参数 Guid gid = Guid.NewGuid(); Random ran = new Random(gid.GetHashCode()); //所在城市联动 int szd = ran.Next(0, 8); int ps = cmbProvince.Items.Count; int guidP = ran.Next(0, ps); cmbProvince.SelectedIndex = guidP; QuartzCallBack(response); }
private PickUpQQDoResponse ForeachFindQQ(QueryQQParam param, string cookie) { string json = param.UrlParam(); string logPath = LogPrepare.GetLogPath(); LoggerWriter.CreateLogFile(json, logPath, ELogType.ParamLog); string response = HttpClientExtend.HttpWebRequestPost(findQQAccountUrl, json, cookie); //将查询反馈的数据写入到数据库中 // LoggerWriter.CreateLogFile(response, logPath, ELogType.DataLog); ConfigurationItems c = new ConfigurationItems(); FindQQDataManage manage = new FindQQDataManage(c.TecentDA_Read); JsonData jsondata = new JsonData(); PickUpQQDoResponse pickup = new PickUpQQDoResponse(); pickup.responseData = manage.SaveFindQQ(response); //此处开启一个线程查询qq群组 pickup.cookie = cookie; pickup.request = json; pickup.responseJson = response; if (callback != null) { } return(pickup); }
private PickUpQQDoResponse QueryTecentQQData(string cookie) { //从cookie中获取skey RequestHeaderHelper request = new RequestHeaderHelper(); Dictionary <string, string> req = request.PickUpRequestHeader(findQQAcountRequestHeader); string key = request.SplitCookie(cookie)["skey"]; //key = "@66i3M9kYA";//799103928 int n = 5381;//这一步生成腾讯需要的key int cal; for (int r = 0, i = key.Length; r < i; ++r) { char ch = (char)key.Substring(r, 1)[0]; int acsii = (int)ch; n += (n << 5) + acsii; } QueryQQParam param = new QueryQQParam(); if (QueryParam != null) { param = QueryParam; } param.ldw = (n & 2147483647); object obj = ForeachFindQQ(param, cookie); System.Threading.Thread th = new Thread(new ThreadStart(delegate() { if (callback != null) { callback(obj); } })); th.Start(); return((PickUpQQDoResponse)obj); }
/// <summary> /// 提取查询qq数据使用的参数 /// </summary> /// <returns></returns> private QueryQQParam GetBaseQueryParam() { int interval = 0; string inter = txtTimeSpan.Text; int.TryParse(inter, out interval); int repeact = 0; string rep = txtRepeact.Text; int.TryParse(rep, out repeact); QueryQQParam param = new QueryQQParam(); int limit = 30; if (int.TryParse(txtCurrentLimit.Text, out limit)) { param.num = limit; } EGender gender; string obj = ((KeyValuePair <string, object>)cmbGender.SelectedItem).Key as string; Enum.TryParse(obj, out gender); param.sex = gender.GetHashCode(); NodeData pro = (NodeData)cmbProvince.SelectedItem; if (string.IsNullOrEmpty(pro.Code)) { return(param); } param.province = pro.Code; NodeData city = (NodeData)cmbCity.SelectedItem; if (city == null) { return(param); } if (string.IsNullOrEmpty(city.Code)) { return(param); } param.city = city.Code; NodeData dist = (NodeData)cmbDistinct.SelectedItem; if (string.IsNullOrEmpty(dist.Code)) { return(param); } param.district = dist.Code; return(param); }
private void JustQuery(QueryQQParam param) { QQDataDA da = new QQDataDA(); da.QueryParam = param; SendNotification(AppNotify.Name_Backstage, null, AppNotify.Get_UsableProxy); PickUpQQDoResponse response = da.QueryQQData(Cookie); if (GatherFirstUin || !SystemConfig.OpenAutoQuertyDBTotal) {//这里要改成在页面初始化时查询当前库数据量,其他情形交给另一线程查询 SyncUinStatics(); GatherFirstUin = false; } QuartzCallBack(response); }
private void QuartzForeachPage(object data) { if (this.InvokeRequired) {//是否通过其他形式调用 DelegateData.BaseDelegate bd = new DelegateData.BaseDelegate(QuartzForeachPage); this.Invoke(bd, data); return; } QueryQQParam param = GetBaseQueryParam(); int page = currentIndex + 1; param.page = page; QQDataDA da = new QQDataDA(); da.QueryParam = param; PickUpQQDoResponse response = da.QueryQQData(Cookie); if (response == null) { rtbTip.Text = "No Cookie"; return; } FindQQResponse resp = response.responseData; if (resp != null && resp.retcode == 0 && resp.result.buddy.totalnum > param.num) { txtPageIndex.Text = (page + 1).ToString(); } else { page = 1; txtPageIndex.Text = page.ToString(); } QueryResponseAction(response); if (!SystemConfig.OpenAutoQuertyDBTotal) { SyncUinStatics(); } }
private void BackGrounForeachCallType(QueryQQParam param) {//backGroundwork string key = ForachCallEvent.PickUpUin.ToString(); DelegateData delete = new DelegateData() { BaseDelegateParam = param }; //要实现定时 if (BackGroundCallRunEvent.ContainsKey(key)) { BackGroundCallRunEvent.Remove(key); } if (ckStartQuartz.Checked && rbGuid.Checked) {//开启随机轮询 delete.BaseDel = QuartzGuidForach; BackGroundCallRunEvent.Add(key, delete); //QuartzGuidForach(param); } else if (ckStartQuartz.Checked && rbDepth.Checked) {//该查询结果页轮询 delete.BaseDel = QuartzForeachPage; BackGroundCallRunEvent.Add(key, delete); //QuartzForeachPage(param); } else if (ckStartQuartz.Checked) { delete.BaseDel = QuartzCallBack; BackGroundCallRunEvent.Add(key, delete); //QuartzCallBack(param); } else { //只查询一遍 JustQuery(param); } }
private void btnQuery_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Cookie)) { rtbTip.Text = "please login,and get cookie,and continue"; return; } // int interval = 0; string inter = txtTimeSpan.Text; int.TryParse(inter, out interval); if (interval > 0) { intervalSec = interval; } else { interval = intervalSec; } int repeact = 0; string rep = txtRepeact.Text; int.TryParse(rep, out repeact); QQDataDA das = new QQDataDA(); string path = LogPrepare.GetLogPath(); LoggerWriter.CreateLogFile(Cookie, das.GeneratePathTimeSpan(Cookie), ELogType.SessionOrCookieLog); Uin = das.GetUinFromCookie(Cookie);//当前登录的账户 //useralias 这是提取账户名称的元素 QueryQQParam param = GetBaseQueryParam(); ParameterizedThreadStart pth; if (!ckStartQuartz.Checked) {//不进行轮询 JustQuery(param); } else if (!ckBackGroundCall.Checked) { #region 进行的是quartz.net轮询调度 if (ckStartQuartz.Checked && rbGuid.Checked) {//开启随机轮询 DelegateData.BaseDelegate del = QuartzGuidForach; QuartzJobParam p = new QuartzJobParam() { JobExecutionContextJobDataMap = new object[] { del, param, null }, StartTime = DateTime.Now.AddSeconds(interval), TriggerRepeat = repeact, TrigggerInterval = interval }; pth = new ParameterizedThreadStart(BackstageRun <JobDelegateFunction>); Thread th = new Thread(pth); th.Start(p); // job.CreateJobWithParam<JobDelegateFunction>(new object[] { del, param,null }, DateTime.Now.AddSeconds(interval), interval, repeact); } else if (ckStartQuartz.Checked && rbDepth.Checked) {//该查询结果页轮询 DelegateData.BaseDelegate del = QuartzForeachPage; QuartzJobParam p = new QuartzJobParam() { JobExecutionContextJobDataMap = new object[] { del, null, null }, StartTime = DateTime.Now.AddSeconds(interval), TriggerRepeat = repeact, TrigggerInterval = interval }; pth = new ParameterizedThreadStart(BackstageRun <JobDelegateFunction>); Thread th = new Thread(pth); th.Start(p); //job.CreateJobWithParam<JobDelegateFunction>(new object[] { del, null,null }, DateTime.Now.AddSeconds(interval), interval, repeact); } else if (ckStartQuartz.Checked) { DelegateData.BaseDelegate del = QuartzCallBack; QuartzJobParam p = new QuartzJobParam() { JobExecutionContextJobDataMap = new object[] { Cookie, param, del }, StartTime = DateTime.Now.AddSeconds(interval), TriggerRepeat = repeact, TrigggerInterval = interval }; pth = new ParameterizedThreadStart(BackstageRun <JobAction <QQDataDA> >); Thread th = new Thread(pth); th.Start(p); // job.CreateJobWithParam<JobAction<QQDataDA>>(new object[] { Cookie, param, del }, DateTime.Now, interval, repeact); } else { JustQuery(param); } #endregion } else if (ckBackGroundCall.Checked && ckStartQuartz.Checked) {//轮询但是使用的是后台进程 #region 使用的是后台进程 BackGrounForeachCallType(param); #endregion } #region 数据同步到核心库 if (ckSyncUin.Checked) { //同步数据 string key = ForachCallEvent.SyncUinToCodeDB.ToString(); if (BackGroundCallRunEvent.ContainsKey(key)) { BackGroundCallRunEvent.Remove(key); } DelegateData del = new DelegateData() { BaseDel = BackGrounSyncUinToCoreDB, BaseDelegateParam = null }; BackGroundCallRunEvent.Add(key, del); } #endregion if (!backRun.IsBusy) { backRun.RunWorkerAsync(); } }