x86.frmMain.click_jd C# (CSharp) Method

click_jd() private method

private click_jd ( System.Windows.Forms.WebBrowser web ) : void
web System.Windows.Forms.WebBrowser
return void
        private void click_jd(WebBrowser web)
        {
            try
            {
                this.lastCheckClick = DateTime.Now.AddSeconds(60.0);
                HtmlDocument document = web.Document;
                Encoding encoding = Encoding.GetEncoding("gb2312");
                string documentText = this.webBrowser1.DocumentText;
                if (documentText != null && documentText.Trim() != "")
                {
                    byte[] numArray = new byte[web.DocumentStream.Length];
                    web.DocumentStream.Read(numArray, 0, (int)web.DocumentStream.Length);
                    char[] chars = new char[encoding.GetCharCount(numArray, 0, numArray.Length)];
                    encoding.GetChars(numArray, 0, numArray.Length, chars, 0);
                    string str1 = new string(chars);
                    HtmlElementCollection elementsByTagName1;
                    string outerHtml1;
                    string innerText1;
                    if (this._curTask.comeType == "直通车")
                    {
                        elementsByTagName1 = web.Document.GetElementsByTagName("a");
                        for (int index = 0; index < document.Links.Count; ++index)
                        {
                            outerHtml1 = document.Links[index].OuterHtml;
                            string innerText2 = document.Links[index].InnerText;
                            if (innerText2 != null && innerText2.IndexOf(this._curTask.title.Trim()) != -1)
                            {
                                this.isLoad = false;
                                document.Links[index].SetAttribute("target", "_self");
                                document.Links[index].InvokeMember("Click");
                                this._curTask.Stu = "浏览进店页";
                                string format = "{0} 找到“" + this._curTask.keyword + "”宝贝,执行浏览宝贝.";
                                DateTime now = DateTime.Now;
                                string str2 = now.ToString();
                                this.strLog = string.Format(format, (object)str2);
                                // ISSUE: method pointer
                                this.BeginInvoke(showdelegate, (object)this.strLog);
                                this._curTask.jd = 1;
                                // ISSUE: explicit reference operation
                                // ISSUE: variable of a reference type
                                TaskTBSturct local = this._curTask;
                                now = DateTime.Now;
                                string str3 = now.ToString("yyyy-MM-dd HH:mm:ss");
                                // ISSUE: explicit reference operation
                                (local).startTime = str3;
                                if (this._curTask.jdTime1 == this._curTask.jdTime2)
                                {
                                    now = DateTime.Now;
                                    this.lastCheckClick = now.AddSeconds((double)this._curTask.jdTime1);
                                    return;
                                }
                                this._curTask.jdTime1 = new Random().Next(this._curTask.jdTime1, this._curTask.jdTime2);
                                now = DateTime.Now;
                                this.lastCheckClick = now.AddSeconds((double)this._curTask.jdTime1);
                                return;
                            }
                        }
                    }
                    else if (this._curTask.comeType == "按类目")
                    {
                        elementsByTagName1 = web.Document.GetElementsByTagName("a");
                        for (int index = 0; index < document.Links.Count; ++index)
                        {
                            string str2 = this._curTask.spid;
                            string outerHtml2 = document.Links[index].OuterHtml;
                            innerText1 = document.Links[index].InnerText;
                            if (outerHtml2 != null && outerHtml2.IndexOf(str2) > 0)
                            {
                                this.isLoad = false;
                                document.Links[index].Focus();
                                Thread.Sleep(1000);
                                document.Links[index].SetAttribute("target", "_self");
                                document.Links[index].InvokeMember("Click");
                                this._curTask.Stu = "浏览进店页";
                                this.strLog = string.Format("{0} 找到“" + this._curTask.keyword + "”宝贝,执行浏览宝贝.", (object)DateTime.Now.ToString());
                                // ISSUE: method pointer
                                this.BeginInvoke(showdelegate, (object)this.strLog);
                                this._curTask.jd = 1;
                                this._curTask.startTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                if (this._curTask.jdTime1 == this._curTask.jdTime2)
                                {
                                    this.lastCheckClick = DateTime.Now.AddSeconds((double)this._curTask.jdTime1);
                                    return;
                                }
                                this._curTask.jdTime1 = new Random().Next(this._curTask.jdTime1, this._curTask.jdTime2);
                                this.lastCheckClick = DateTime.Now.AddSeconds((double)this._curTask.jdTime1);
                                return;
                            }
                        }
                    }
                    else if (this._curTask.comeType == "按京东")
                    {
                        elementsByTagName1 = web.Document.GetElementsByTagName("a");
                        for (int index = 0; index < document.Links.Count; ++index)
                        {
                            outerHtml1 = document.Links[index].OuterHtml;
                            string innerText2 = document.Links[index].InnerText;
                            if (innerText2 != null && innerText2.IndexOf(this._curTask.title.Trim()) != -1)
                            {
                                this.isLoad = false;
                                document.Links[index].SetAttribute("target", "_self");
                                document.Links[index].InvokeMember("Click");
                                this._curTask.Stu = "浏览进店页";
                                string format = "{0} 找到“" + this._curTask.keyword + "”宝贝,执行浏览宝贝.";
                                DateTime now = DateTime.Now;
                                string str2 = now.ToString();
                                this.strLog = string.Format(format, (object)str2);
                                // ISSUE: method pointer
                                this.BeginInvoke(showdelegate, (object)this.strLog);
                                this._curTask.jd = 1;
                                // ISSUE: explicit reference operation
                                // ISSUE: variable of a reference type
                                TaskTBSturct local = this._curTask;
                                now = DateTime.Now;
                                string str3 = now.ToString("yyyy-MM-dd HH:mm:ss");
                                // ISSUE: explicit reference operation
                                (local).startTime = str3;
                                if (this._curTask.jdTime1 == this._curTask.jdTime2)
                                {
                                    now = DateTime.Now;
                                    this.lastCheckClick = now.AddSeconds((double)this._curTask.jdTime1);
                                    return;
                                }
                                this._curTask.jdTime1 = new Random().Next(this._curTask.jdTime1, this._curTask.jdTime2);
                                now = DateTime.Now;
                                this.lastCheckClick = now.AddSeconds((double)this._curTask.jdTime1);
                                return;
                            }
                        }
                    }
                    else
                    {
                        elementsByTagName1 = web.Document.GetElementsByTagName("a");
                        for (int index = 0; index < document.Links.Count; ++index)
                        {
                            string str2 = this._curTask.spid;
                            string outerHtml2 = document.Links[index].OuterHtml;
                            innerText1 = document.Links[index].InnerText;
                            if (outerHtml2 != null && outerHtml2.IndexOf(str2) > 0)
                            {
                                this.isLoad = false;
                                document.Links[index].Focus();
                                Thread.Sleep(1000);
                                document.Links[index].SetAttribute("target", "_self");
                                document.Links[index].InvokeMember("Click");
                                this._curTask.Stu = "浏览进店页";
                                this.strLog = string.Format("{0} 找到“" + this._curTask.keyword + "”宝贝,执行浏览宝贝.", (object)DateTime.Now.ToString());
                                // ISSUE: method pointer
                                this.BeginInvoke(showdelegate, (object)this.strLog);
                                this._curTask.jd = 1;
                                this._curTask.startTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                if (this._curTask.jdTime1 == this._curTask.jdTime2)
                                {
                                    this.lastCheckClick = DateTime.Now.AddSeconds((double)this._curTask.jdTime1);
                                    return;
                                }
                                this._curTask.jdTime1 = new Random().Next(this._curTask.jdTime1, this._curTask.jdTime2);
                                this.lastCheckClick = DateTime.Now.AddSeconds((double)this._curTask.jdTime1);
                                return;
                            }
                        }
                    }
                    this._curTask.noFind = this._curTask.noFind + 1;
                    if (this._curTask.noFind < this._curTask.pageNum)
                    {
                        HtmlElementCollection elementsByTagName2;
                        try
                        {
                            elementsByTagName2 = this.webBrowser1.Document.GetElementById("list-page").Document.GetElementsByTagName("a");
                        }
                        catch
                        {
                            elementsByTagName2 = this.webBrowser1.Document.GetElementsByTagName("a");
                        }
                        for (int index = 0; index < elementsByTagName2.Count; ++index)
                        {
                            outerHtml1 = elementsByTagName2[index].OuterHtml;
                            string innerText2 = elementsByTagName2[index].InnerText;
                            if (innerText2 != null && innerText2.Trim() == (this._curTask.noFind + 1).ToString())
                            {
                                this.isLoad = false;
                                elementsByTagName2[index].InvokeMember("Click");
                                break;
                            }
                        }
                        this.strLog = string.Format("{0} 第" + (object)this._curTask.noFind + "页展现完成,准备找第" + (string)(object)(this._curTask.noFind + 1) + "页.", (object)DateTime.Now.ToString());
                        // ISSUE: method pointer
                        this.BeginInvoke(showdelegate, (object)this.strLog);
                        this.lastCheckClick = DateTime.Now.AddSeconds(20.0);
                    }
                    else
                    {
                        this.strLog = string.Format("{0} 展现任务完成,正在提交任务.", (object)DateTime.Now.ToString());
                        // ISSUE: method pointer
                        this.BeginInvoke(showdelegate, (object)this.strLog);
                        this.lastCheckClick.AddMinutes(2.0);
                        int num = 0;
                        while (num < 3)
                        {
                            if (this.postTask(1))
                            {
                                num = 10;
                            }
                            else
                            {
                                ++num;
                                Thread.Sleep(20000);
                            }
                        }
                        this._curTask.Stu = "";
                        this.lastCheckClick = DateTime.Now.AddSeconds(5.0);
                        this._curTask.optStu = 0;
                        this.strLog = string.Format("{0} 20秒后重新获取任务.", (object)DateTime.Now.ToString());
                        // ISSUE: method pointer
                        this.BeginInvoke(showdelegate, (object)this.strLog);
                    }
                }
            }
            catch
            {
                try
                {
                    this.postTask(0);
                    this._curTask.Stu = "";
                    this._curTask.optStu = 0;
                    this.lastCheckClick = DateTime.Now.AddSeconds(50.0);
                }
                catch
                {
                }
            }
        }
        private void click_lm(WebBrowser web)
frmMain