Exemplo n.º 1
0
        /// <summary>
        /// “上传走步数据”按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButtonUploadStepData_Click(object sender, EventArgs e)
        {
            if (!CheckLoginState())
            {
                return;
            }

            var frmStepDataGen = new FrmStepDataGen();

            if (frmStepDataGen.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string certPath = MyCertPath;

            if (certPath == null || !System.IO.File.Exists(certPath)) // 证书路径不存在,则重新选择
            {
                if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                certPath = this.openFileDialog1.FileName;
            }

            try
            {
                var result = PH.UploadWalkData(MyUserInfo.id.ToString(), MyCookie, certPath, frmStepDataGen.StepCount);
                if (result == null)
                {
                    SetMyCertPath(null);
                    MsgBox.ShowInfo("无效证书!");
                    return;
                }
                if (result.Content[0].Value)
                {
                    MsgBox.ShowInfo("上传成功!");
                }
                SetMyCertPath(certPath);
            }
            catch (Exception ex)
            {
                SetMyCertPath(null);
                MsgBox.ShowInfo("上传失败," + ex.Message);
            }
            UpdateCertPathDisplay();
        }
Exemplo n.º 2
0
        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);
            });
        }