private void toolStripButtonDelete_Click(object sender, EventArgs e) { if (this.listView1.CheckedItems.Count < 1) { MsgBox.ShowInfo("请勾选账号!"); return; } if (MsgBox.ShowOkCancel("确定要删除勾选的账号?", "提示") == DialogResult.Cancel) { return; } for (int i = this.listView1.CheckedItems.Count - 1; i >= 0; i--) { int index = this.listView1.CheckedItems[i].Index; string cookie = GetListViewItemValue(this.listView1, index, 3); string name = GetListViewItemValue(this.listView1, index, 1); ConfigStorage.GetInstance().RemoveCookieInfo(new CookieInfo() { Cookie = cookie }); this.listView1.Items.RemoveAt(index); } // 重新排序 for (var i = 0; i < this.listView1.Items.Count; i++) { this.listView1.Items[i].SubItems[0].Text = (i + 1).ToString(); } }
private void button2_MouseClick(object sender, MouseEventArgs e) { var configInfo = ConfigStorage.GetInstance().GetConfigInfo(); ContextMenuStrip cms = new ContextMenuStrip(); configInfo.HistoryCookies.ForEach(action => { var item = cms.Items.Add(action.Name, null, (o, args) => { var menuItem = o as ToolStripItem; var cookieInfo = menuItem.Tag as CookieInfo; try { //打开证书 System.Security.Cryptography.X509Certificates.X509Certificate2 x509 = new System.Security.Cryptography.X509Certificates.X509Certificate2( cookieInfo.CertPath, PapdHelper.DEFAULT_PFX_PASSWORD, X509KeyStorageFlags.Exportable); MsgBox.ShowInfo("证书是别名:" + x509.SubjectName.Name); //x509.Thumbprint; //x509.PublicKey.Key.ToXmlString(false); GlobalContext.CurrentPfxPrivateKey = x509.PrivateKey.ToXmlString(true); } catch (Exception ex) { MsgBox.ShowInfo("证书无效," + ex.Message); } }); item.Tag = action; }); cms.Show(this.button2, e.Location); }
private void toolStripButton1_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem(o => { SetControlEnabled(this.toolStrip1, false); try { var config = ConfigStorage.GetInstance().GetConfigInfo(); ClearListView(this.listView1); for (int i = 0; i < config.HistoryCookies.Count; i++) { var info = config.HistoryCookies[i]; AddListViewmItem(this.listView1, new object[] { (i + 1).ToString(), info.Name, info.Id == null ? string.Empty : info.Id.ToString(), info.Cookie, CertificateUtil.GetCertSubjectName(info.CertPath) }); SetListViewItemTag(this.listView1, i, info); SetListViewItemChecked(this.listView1, i, true); } } catch (Exception ex) { } SetControlEnabled(this.toolStrip1, true); }); }
/// <summary> /// 窗体载入函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmStepDataGen_Load(object sender, EventArgs e) { // 初始化步数 var configInfo = ConfigStorage.GetInstance().GetConfigInfo(); this.textBox1.Text = new Random().Next(configInfo.RandomMinStep, configInfo.RandomMaxStep) + ""; this.textBox1.Select(this.textBox1.TextLength, 1); }
private void button1_Click(object sender, EventArgs e) { var configInfo = ConfigStorage.GetInstance().GetConfigInfo(); configInfo.IsAutoUploadWalkData = this.checkBox1.Checked; configInfo.IsAutoGrabGold = this.checkBox2.Checked; configInfo.IsAutoFetchYesterdayBonus = this.checkBox3.Checked; configInfo.IsAutoGrabTreasure = this.checkBox4.Checked; configInfo.RandomMinStep = Convert.ToInt32(this.numericUpDown1.Value); configInfo.RandomMaxStep = Convert.ToInt32(this.numericUpDown2.Value); configInfo.CreateOrderTimespan = Convert.ToInt32(this.numericUpDown3.Value); ConfigStorage.GetInstance().UpdateAutoConfigInfo(configInfo); this.DialogResult = DialogResult.OK; }
private void Init() { var configInfo = ConfigStorage.GetInstance().GetConfigInfo(); this.checkBox1.Checked = configInfo.IsAutoUploadWalkData; this.checkBox2.Checked = configInfo.IsAutoGrabGold; this.checkBox3.Checked = configInfo.IsAutoFetchYesterdayBonus; this.checkBox4.Checked = configInfo.IsAutoGrabTreasure; this.numericUpDown1.Minimum = 100; this.numericUpDown1.Maximum = 100000; this.numericUpDown1.Value = configInfo.RandomMinStep; this.numericUpDown2.Minimum = 100; this.numericUpDown2.Maximum = 100000; this.numericUpDown2.Value = configInfo.RandomMaxStep; this.numericUpDown3.Value = configInfo.CreateOrderTimespan; }
private void toolStripButton2_Click(object sender, EventArgs e) { if (this.listView1.CheckedItems.Count < 1) { MsgBox.ShowInfo("请勾选账号!"); return; } List <int> checkedRows = new List <int>(); for (int i = 0; i < this.listView1.CheckedItems.Count; i++) { checkedRows.Add(this.listView1.CheckedItems[i].Index); } ThreadPool.QueueUserWorkItem(o => { var configInfo = ConfigStorage.GetInstance().GetConfigInfo(); SetControlEnabled(this.toolStrip1, false); for (int i = 0; i < checkedRows.Count; i++) { int index = checkedRows[i]; CookieInfo cookieInfo = GetListViewItemTag <CookieInfo>(this.listView1, index); string cookie = cookieInfo.Cookie; string id = cookieInfo.Id.ToString(); string cert = cookieInfo.CertPath; bool fetchYestodayReward = true; if (configInfo.IsAutoFetchYesterdayBonus) { #region 领取昨日奖励 SetListViewItemValue(this.listView1, index, 7, "正在领取奖励"); try { var rewardInfo = PH.QueryRewardInfo(cookie, 3000); if (!rewardInfo.IsPreMoneyFetch()) { var fetchRewardResult = PH.FetchReward(cookie, rewardInfo.preRewardId); SetListViewItemValue(this.listView1, index, 7, "昨日奖励领取成功!"); } else { SetListViewItemValue(this.listView1, index, 7, "昨日奖励已领取。"); } } catch (Exception ex) { SetListViewItemValue(this.listView1, index, 7, "昨日奖励领取失败!"); fetchYestodayReward = false; } #endregion } Thread.Sleep(1000); int grabGoldSuccess = 0; if (configInfo.IsAutoGrabGold) { #region 抢金 SetListViewItemValue(this.listView1, index, 7, "正在抢金"); try { var grabGoldInfo = PH.GetGrabGoldInfo(cookie, 1); for (int j = 0; j < grabGoldInfo.userRankingList.Length; j++) { var user = grabGoldInfo.userRankingList[j]; if (!user.IsGrabGoldAvailable()) { continue; } try { PH.GrabGoldFromFollower(cookie, user.userInfo.userId); grabGoldSuccess++; } catch (Exception ex) { SetListViewItemValue(this.listView1, index, 7, "抢金错误"); } } SetListViewItemValue(this.listView1, index, 7, "成功抢金" + grabGoldSuccess + "个好友!"); } catch (Exception ex) { SetListViewItemValue(this.listView1, index, 7, "抢金失败"); } #endregion } int fetchBoxCount = 0; if (configInfo.IsAutoGrabTreasure) { #region 步步夺宝 SetListViewItemValue(this.listView1, index, 7, "正在夺宝..."); var fetchBoxFuncList = new List <Func <string, PajkResultList <PajkFetchBoxResult> > >(); fetchBoxFuncList.Add(PH.FetchBoxByShareReading); fetchBoxFuncList.Add(PH.FetchBoxByWalkMall); fetchBoxFuncList.Add(PH.FetchBoxByInviteFriend); fetchBoxFuncList.Add(PH.FetchBoxByVideo); for (int j = 0; j < fetchBoxFuncList.Count; j++) { try { var fetchResult = fetchBoxFuncList[j](cookie); Thread.Sleep(1200); SetListViewItemValue(this.listView1, index, 7, "得到宝箱:" + fetchResult.Content[0].BoxGiftList[0].GiftName); fetchBoxCount += fetchResult.Content[0].BoxGiftList.Length; } catch (Exception ex) { } } #endregion } Thread.Sleep(1000); bool uploadWalkData = true; float sc = 0f; if (configInfo.IsAutoUploadWalkData) { #region 走步数据 SetListViewItemValue(this.listView1, index, 7, "正在上传走步数据"); try { var downloadResult = PH.DownloadWalkData(id, cookie, cert); if (downloadResult != null) { PajkWalkDataInfo today = null; if (downloadResult.Content[0].walkDataInfos == null || (today = downloadResult.Content[0].walkDataInfos.Find( match => match.walkDate == DateTime.Now.ToString("yyyyMMdd"))) == null) { int stepCount = new Random((int)DateTime.Now.Ticks).Next( GlobalContext.CurrentConfigInfo.RandomMinStep, GlobalContext.CurrentConfigInfo.RandomMaxStep); sc = stepCount; var result = PH.UploadWalkData(id, cookie, cert, stepCount); if (result.Content[0].Value) { SetListViewItemValue(this.listView1, index, 7, "成功上传走步" + stepCount + "!"); } else { throw new Exception(result.Stat.Code.ToString()); } } else { sc = today.stepCount; SetListViewItemValue(this.listView1, index, 7, "今天已上传走步" + today.stepCount + "。"); } } } catch (Exception ex) { SetListViewItemValue(this.listView1, index, 7, "上传走步失败"); uploadWalkData = false; } #endregion } SetListViewItemValue(this.listView1, index, 7, string.Format("领取昨日奖励:{0},上传走步:{1},成功抢金:{2}个,得到宝箱:{3}个", fetchYestodayReward?"成功":"失败", uploadWalkData?sc.ToString():"失败", grabGoldSuccess, fetchBoxCount)); } SetControlEnabled(this.toolStrip1, true); }); }
/// <summary> /// 重新读取配置文件 /// </summary> public static void RereadConfig() { CurrentConfigInfo = ConfigStorage.GetInstance().GetConfigInfo(); HistoryCookies = CurrentConfigInfo.HistoryCookies; IsTestMode = CurrentConfigInfo.IsTestMode; }