.
leo
2022-10-28 fd4f799969e028c975e489614c4ab5fe118d9974
.
3个文件已修改
324 ■■■■■ 已修改文件
BankRobot/app.config 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BankRobot/frmCollectTI.Designer.cs 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BankRobot/frmCollectTI.cs 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BankRobot/app.config
@@ -76,5 +76,8 @@
    <!--支付截图位置-->
    <add key="iLeft" value="670" />
    <add key="iTop" value="235" />
    <!--判断是否缺货位置-->
    <add key="OutofstockLeft" value="670" />
    <add key="OutofstockTop" value="235" />
  </appSettings>
</configuration>
BankRobot/frmCollectTI.Designer.cs
@@ -35,13 +35,16 @@
            this.btnStart = new System.Windows.Forms.Button();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.richTextLog = new System.Windows.Forms.RichTextBox();
            this.lblStatus = new System.Windows.Forms.Label();
            this.txtURL = new System.Windows.Forms.TextBox();
            this.btnStop = new System.Windows.Forms.Button();
            this.btnContinue = new System.Windows.Forms.Button();
            this.txtquantity = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.txtproduct = new System.Windows.Forms.TextBox();
            this.btnrepeat = new System.Windows.Forms.Button();
            this.lblStatus = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // btnTest
@@ -64,11 +67,18 @@
            // 
            // btnStart
            // 
<<<<<<< HEAD
            this.btnStart.Location = new System.Drawing.Point(494, 11);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(56, 23);
=======
            this.btnStart.Location = new System.Drawing.Point(663, 10);
            this.btnStart.Margin = new System.Windows.Forms.Padding(4);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(110, 42);
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            this.btnStart.TabIndex = 21;
            this.btnStart.Text = "启动";
            this.btnStart.Text = "启动有存货的";
            this.btnStart.UseVisualStyleBackColor = true;
            this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
            // 
@@ -76,6 +86,7 @@
            // 
            this.richTextLog.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
<<<<<<< HEAD
            this.richTextLog.Location = new System.Drawing.Point(16, 80);
            this.richTextLog.Name = "richTextLog";
            this.richTextLog.Size = new System.Drawing.Size(772, 190);
@@ -96,13 +107,33 @@
            this.txtURL.Location = new System.Drawing.Point(92, 14);
            this.txtURL.Name = "txtURL";
            this.txtURL.Size = new System.Drawing.Size(280, 21);
=======
            this.richTextLog.Location = new System.Drawing.Point(22, 118);
            this.richTextLog.Margin = new System.Windows.Forms.Padding(4);
            this.richTextLog.Name = "richTextLog";
            this.richTextLog.Size = new System.Drawing.Size(1028, 324);
            this.richTextLog.TabIndex = 26;
            this.richTextLog.Text = "";
            //
            // txtURL
            //
            this.txtURL.Location = new System.Drawing.Point(176, 18);
            this.txtURL.Margin = new System.Windows.Forms.Padding(4);
            this.txtURL.Name = "txtURL";
            this.txtURL.Size = new System.Drawing.Size(283, 25);
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            this.txtURL.TabIndex = 23;
            this.txtURL.Text = "txs0104ed";
            // 
            // btnStop
            // 
            this.btnStop.Enabled = false;
<<<<<<< HEAD
            this.btnStop.Location = new System.Drawing.Point(626, 13);
=======
            this.btnStop.Location = new System.Drawing.Point(878, 10);
            this.btnStop.Margin = new System.Windows.Forms.Padding(4);
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            this.btnStop.Name = "btnStop";
            this.btnStop.Size = new System.Drawing.Size(55, 23);
            this.btnStop.TabIndex = 19;
@@ -113,7 +144,12 @@
            // btnContinue
            // 
            this.btnContinue.Enabled = false;
<<<<<<< HEAD
            this.btnContinue.Location = new System.Drawing.Point(563, 13);
=======
            this.btnContinue.Location = new System.Drawing.Point(795, 10);
            this.btnContinue.Margin = new System.Windows.Forms.Padding(4);
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            this.btnContinue.Name = "btnContinue";
            this.btnContinue.Size = new System.Drawing.Size(56, 23);
            this.btnContinue.TabIndex = 20;
@@ -127,7 +163,11 @@
            this.txtquantity.Name = "txtquantity";
            this.txtquantity.Size = new System.Drawing.Size(43, 21);
            this.txtquantity.TabIndex = 32;
<<<<<<< HEAD
            this.txtquantity.Text = "3";
=======
            this.txtquantity.Text = "10";
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            // 
            // label1
            // 
@@ -142,18 +182,70 @@
            // label2
            // 
            this.label2.AutoSize = true;
<<<<<<< HEAD
            this.label2.Location = new System.Drawing.Point(14, 20);
            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(53, 12);
=======
            this.label2.Location = new System.Drawing.Point(28, 26);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(142, 15);
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            this.label2.TabIndex = 34;
            this.label2.Text = "产品名称";
            this.label2.Text = "有存货的产品名称:";
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(43, 65);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(127, 15);
            this.label3.TabIndex = 35;
            this.label3.Text = "缺货的产品名称:";
            //
            // txtproduct
            //
            this.txtproduct.Location = new System.Drawing.Point(176, 57);
            this.txtproduct.Margin = new System.Windows.Forms.Padding(4);
            this.txtproduct.Name = "txtproduct";
            this.txtproduct.Size = new System.Drawing.Size(283, 25);
            this.txtproduct.TabIndex = 36;
            this.txtproduct.Text = "ISO5452DWR";
            //
            // btnrepeat
            //
            this.btnrepeat.Location = new System.Drawing.Point(663, 60);
            this.btnrepeat.Margin = new System.Windows.Forms.Padding(4);
            this.btnrepeat.Name = "btnrepeat";
            this.btnrepeat.Size = new System.Drawing.Size(110, 41);
            this.btnrepeat.TabIndex = 37;
            this.btnrepeat.Text = "启动缺货的";
            this.btnrepeat.UseVisualStyleBackColor = true;
            this.btnrepeat.Click += new System.EventHandler(this.repeat_Click);
            //
            // lblStatus
            //
            this.lblStatus.AutoSize = true;
            this.lblStatus.Location = new System.Drawing.Point(500, 65);
            this.lblStatus.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
            this.lblStatus.Name = "lblStatus";
            this.lblStatus.Size = new System.Drawing.Size(127, 15);
            this.lblStatus.TabIndex = 25;
            this.lblStatus.Text = "系统初始化完成!";
            // 
            // frmCollectTI
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
<<<<<<< HEAD
            this.ClientSize = new System.Drawing.Size(809, 299);
=======
            this.ClientSize = new System.Drawing.Size(1079, 516);
            this.Controls.Add(this.btnrepeat);
            this.Controls.Add(this.txtproduct);
            this.Controls.Add(this.label3);
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.txtquantity);
@@ -182,12 +274,15 @@
        private System.Windows.Forms.Button btnStart;
        private System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.RichTextBox richTextLog;
        private System.Windows.Forms.Label lblStatus;
        private System.Windows.Forms.TextBox txtURL;
        private System.Windows.Forms.Button btnStop;
        private System.Windows.Forms.Button btnContinue;
        private System.Windows.Forms.TextBox txtquantity;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox txtproduct;
        private System.Windows.Forms.Button btnrepeat;
        private System.Windows.Forms.Label lblStatus;
    }
}
BankRobot/frmCollectTI.cs
@@ -98,6 +98,7 @@
        private void btnStart_Click(object sender, EventArgs e)
        {
            //启动
<<<<<<< HEAD
            try
            {
                bStop = false;
@@ -117,6 +118,17 @@
                //btnContinue.Enabled = true;
                //btnStop.Enabled = true;
                //iStoreNum = 0;
=======
            StartCommit();
            //try
            //{
            //    解析获取具体链接
            //    bStop = false;
            //    btnStart.Enabled = false;
            //    btnContinue.Enabled = true;
            //    btnStop.Enabled = true;
            //    iStoreNum = 0;
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
                //if (cboxTime.Checked) //定时循环模式
                //{
@@ -201,6 +213,7 @@
        //}
<<<<<<< HEAD
        private void StartCollect()
        {
            //刷新
@@ -323,15 +336,148 @@
            JObject jo = new JObject();
            jo = JsonConvert.DeserializeObject<JObject>(Result);
            if (jo["words_result"] != null && jo["words_result"].ToString() != "")
=======
        private void StartCommit()
        {
            try
>>>>>>> 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
            {
                JObject words = jo["words_result"][0].Value<JObject>();
                richTextLog.Text += words["words"].ToString();
                MessageBox.Show("已成功完成订单,请支付");
                //刷新
                int refreshLeft = Convert.ToInt32(ConfigurationManager.AppSettings["refreshLeft"]);
                int refreshTop = Convert.ToInt32(ConfigurationManager.AppSettings["refreshTop"]);
                ClickButtonBy(refreshLeft, refreshTop);
                //输入产品
                int productLeft = Convert.ToInt32(ConfigurationManager.AppSettings["productLeft"]);
                int productTop = Convert.ToInt32(ConfigurationManager.AppSettings["productTop"]);
                if (txtURL.Text.Trim() != null)
                {
                    InputTextInfo(txtURL.Text.Trim(), productLeft, productTop);
                }
                else
                {
                    MessageBox.Show("请输入产品");
                }
                string strURL = HttpUtility.UrlEncode(txtURL.Text, Encoding.UTF8);
                DelayTime(3000);
                //点击搜索产品
                int searchproductLeft = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductLeft"]);
                int searchproductTop = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductTop"]);
                ClickButtonBy(searchproductLeft, searchproductTop);
                DelayTime(10000);
                //指定位置输入购买数量
                int purchasequantityLeft = Convert.ToInt32(ConfigurationManager.AppSettings["purchasequantityLeft"]);
                int purchasequantityTop = Convert.ToInt32(ConfigurationManager.AppSettings["purchasequantityTop"]);
                if (txtquantity.Text.Trim() != null)
                {
                    InputTextInfo(txtquantity.Text.Trim(), purchasequantityLeft, purchasequantityTop);
                    DelayTime(2000);
                }
                else
                {
                    MessageBox.Show("请输入购买产品的数量");
                }
                //点击加入购物车
                int shoppingcartLeft = Convert.ToInt32(ConfigurationManager.AppSettings["shoppingcartLeft"]);
                int shoppingcartTop = Convert.ToInt32(ConfigurationManager.AppSettings["shoppingcartTop"]);
                ClickButtonBy(shoppingcartLeft, shoppingcartTop);
                DelayTime(10000);
                //点击结算按钮
                int settlementLeft = Convert.ToInt32(ConfigurationManager.AppSettings["settlementLeft"]);
                int settlementTop = Convert.ToInt32(ConfigurationManager.AppSettings["settlementTop"]);
                ClickButtonBy(settlementLeft, settlementTop);
                DelayTime(12000);
                //点击购物车里结算按钮
                int settlementtwoLeft = Convert.ToInt32(ConfigurationManager.AppSettings["settlementtwoLeft"]);
                int settlementtwoTop = Convert.ToInt32(ConfigurationManager.AppSettings["settlementtwoTop"]);
                ClickButtonBy(settlementtwoLeft, settlementtwoTop);
                DelayTime(12000);
                //点击2次下滑,再点击(1)下一步
                int slidedownwardLeft = Convert.ToInt32(ConfigurationManager.AppSettings["slidedownwardLeft"]);
                int slidedownwardTop = Convert.ToInt32(ConfigurationManager.AppSettings["slidedownwardTop"]);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                DelayTime(2000);
                int nextstepLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepLeft"]);
                int nextstepTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepTop"]);
                ClickButtonBy(nextstepLeft, nextstepTop);
                DelayTime(15000);
                //2.先点击必选框,再一次点击下滑,最后点击(2)下一步
                int mandatoryLeft = Convert.ToInt32(ConfigurationManager.AppSettings["mandatoryLeft"]);
                int mandatoryTop = Convert.ToInt32(ConfigurationManager.AppSettings["mandatoryTop"]);
                ClickButtonBy(mandatoryLeft, mandatoryTop);
                DelayTime(1000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int nextsteptwoLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextsteptwoLeft"]);
                int nextsteptwoTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextsteptwoTop"]);
                ClickButtonBy(nextsteptwoLeft, nextsteptwoTop);
                //点击确认并继续
                int determineLeft = Convert.ToInt32(ConfigurationManager.AppSettings["determineLeft"]);
                int determineTop = Convert.ToInt32(ConfigurationManager.AppSettings["determineTop"]);
                ClickButtonBy(determineLeft, determineTop);
                DelayTime(20000);
                //3.先点击下滑再点击(3)下一步
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int nextstepthreeLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepthreeLeft"]);
                int nextstepthreeTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepthreeTop"]);
                ClickButtonBy(nextstepthreeLeft, nextstepthreeTop);
                DelayTime(15000);
                //4.第4步没有
                //5.先点击下滑再点击服务条款阅读,再点击接受,点击下滑,最后点击(4)下一步
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int serviceLeft = Convert.ToInt32(ConfigurationManager.AppSettings["serviceLeft"]);
                int serviceTop = Convert.ToInt32(ConfigurationManager.AppSettings["serviceTop"]);
                ClickButtonBy(serviceLeft, serviceTop);
                int acceptLeft = Convert.ToInt32(ConfigurationManager.AppSettings["acceptLeft"]);
                int acceptTop = Convert.ToInt32(ConfigurationManager.AppSettings["acceptTop"]);
                ClickButtonBy(acceptLeft, acceptTop);
                DelayTime(1000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int nextstepfourLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepfourLeft"]);
                int nextstepfourTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepfourTop"]);
                ClickButtonBy(nextstepfourLeft, nextstepfourTop);
                DelayTime(15000);
                //6.先点击下滑,再选择支付宝或者微信支付,最后点击支付
                //下滑
                DelayTime(3000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                //选择支付宝付款
                int alipayLeft = Convert.ToInt32(ConfigurationManager.AppSettings["alipayLeft"]);
                int alipayTop = Convert.ToInt32(ConfigurationManager.AppSettings["alipayTop"]);
                ClickButtonBy(alipayLeft, alipayTop);
                //选择微信支付
                //int weChatLeft = Convert.ToInt32(ConfigurationManager.AppSettings["weChatLeft"]);
                //int weChatTop = Convert.ToInt32(ConfigurationManager.AppSettings["weChatTop"]);
                //ClickButtonBy(weChatLeft, weChatTop);
                DelayTime(1000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                //点击支付
                int paymentLeft = Convert.ToInt32(ConfigurationManager.AppSettings["paymentLeft"]);
                int paymentTop = Convert.ToInt32(ConfigurationManager.AppSettings["paymentTop"]);
                ClickButtonBy(paymentLeft, paymentTop);
                DelayTime(10000);
                int iLeft = Convert.ToInt32(ConfigurationManager.AppSettings["iLeft"]);
                int iTop = Convert.ToInt32(ConfigurationManager.AppSettings["iTop"]);
                string Base64Pic = ScreenVerifyCode(iLeft, iTop);
                string Result = GetNumbers.GeneralBasic(Base64Pic);
                JObject jo = new JObject();
                jo = JsonConvert.DeserializeObject<JObject>(Result);
                if (jo["words_result"] != null && jo["words_result"].ToString() != "")
                {
                    JObject words = jo["words_result"][0].Value<JObject>();
                    richTextLog.Text += words["words"].ToString();
                    MessageBox.Show("已成功完成订单,请支付");
                }
                else
                {
                    MessageBox.Show("订单出现错误!");
                }
            }
            else
            catch (Exception)
            {
                MessageBox.Show("订单出现错误!");
                throw;
            }
        }
@@ -352,7 +498,7 @@
            gla.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            gla.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            gla.CopyFromScreen(iLeft, iTop, 0, 0, new Size(iWidth, iHeight));
            myImage.Save(System.AppDomain.CurrentDomain.BaseDirectory + "/ZFJT.png");
            myImage.Save(System.AppDomain.CurrentDomain.BaseDirectory + "/ZFZM.png");
            //字面是对当前图片进行了二进制转换
            MemoryStream ms = new MemoryStream();
            myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
@@ -401,8 +547,25 @@
        private void btnStop_Click(object sender, EventArgs e)
        {
            //ResetSystem("系统自动抓取手动停止!");
            ResetSystem("系统自动抓取手动停止!");
        }
        /// <summary>
        /// 系统重新置位
        /// </summary>
        /// <param name="strInfo"></param>
        private void ResetSystem(string strInfo, bool bContinueFlag = false)
        {
            bStop = true;
            btnStart.Enabled = !bContinueFlag;
            btnContinue.Enabled = bContinueFlag;
            btnStop.Enabled = bContinueFlag;
            lblStatus.Text = strInfo;
            timer1.Enabled = false;
            iCount = 0;
            richTextLog.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ResetSystem系统重置!原因:" + strInfo + "\r\n";
        }
        /// <summary>
        /// 延迟函数防止假死
@@ -425,5 +588,46 @@
            }
            return;
        }
        private void repeat_Click(object sender, EventArgs e)
        {
            try
            {
                int i = 1;
                while (1 < 3)
                {
                    //刷新
                    int refreshLeft = Convert.ToInt32(ConfigurationManager.AppSettings["refreshLeft"]);
                    int refreshTop = Convert.ToInt32(ConfigurationManager.AppSettings["refreshTop"]);
                    ClickButtonBy(refreshLeft, refreshTop);
                    //输入产品
                    int productLeft = Convert.ToInt32(ConfigurationManager.AppSettings["productLeft"]);
                    int productTop = Convert.ToInt32(ConfigurationManager.AppSettings["productTop"]);
                    if (txtproduct.Text.Trim() != null)
                    {
                        InputTextInfo(txtproduct.Text.Trim(), productLeft, productTop);
                    }
                    else
                    {
                        MessageBox.Show("请输入产品");
                    }
                    string strURL = HttpUtility.UrlEncode(txtproduct.Text, Encoding.UTF8);
                    DelayTime(2000);
                    //点击搜索产品
                    int searchproductLeft = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductLeft"]);
                    int searchproductTop = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductTop"]);
                    ClickButtonBy(searchproductLeft, searchproductTop);
                    MessageBox.Show("因为没有库存所以会每10秒循坏1次,因为是演示,所以只循环三次,当前是第" + i + "次循环");
                    i++;
                    DelayTime(10000);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}