Example #1
0
        private void mainWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            IHTMLDocument2 win = (IHTMLDocument2)this.mainWebBrowser.Document.DomDocument;
            // 流转控制
            string s = @"function confirm() {";

            s += @"return true;";
            s += @"}";
            s += @"function alert(str)";
            s += @"{";
            s += @"window.external.alertMessage(str);";
            s += @"}";
            win.parentWindow.execScript(s, "javascript");
            this.mainWebBrowser.ObjectForScripting = this;

            if (win.url.Equals(Constants.MAIN_MENU))
            {
                this.mainWebBrowser.Navigate(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE);
            }
            else if (win.url.Equals(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE))
            {
                // 调用填参方法
                FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);
                f.tryFillConfiguration();
            }
        }
Example #2
0
        private void mainWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            IHTMLDocument2 win = (IHTMLDocument2)this.mainWebBrowser.Document.DomDocument;



            // 流转控制
            if (win.url.Equals(Constants.LOGIN_PAGE))
            {
                LoginAction.tryLogin(this.mainWebBrowser);
            }
            else if (win.url.Equals(Constants.MAIN_MENU))
            {
                this.mainWebBrowser.Navigate(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE);
            }
            else if (win.url.Equals(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE))
            {
                // 重写js文件中的alert方法。将alert参数导出。

                /*
                 * win.parentWindow.execScript("var testparam='';function nalert(ss){testparam =ss;}", "javascript");
                 * win.parentWindow.execScript("window.alert=nalert;window.onerror=null;window.confirm=null;window.open=null;window.showModalDialog=null;", "javascript");
                 *
                 * try
                 * {
                 *
                 *  win.parentWindow.execScript("window.alert=nalert;");
                 *  win.parentWindow.execScript("alert(11);", "javascript");
                 * }
                 * catch
                 * { }
                 *
                 * // 启动timer
                 * this.timer1.Enabled = true;
                 * this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
                 */

                // 调用填参方法
                FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);
                f.tryFillConfiguration();
            }

            /*
             *
             * win.parentWindow.execScript("var testparam='';function nalert(ss){testparam =ss;}", "javascript");
             *  win.parentWindow.execScript("window.alert=nalert;window.onerror=null;window.confirm=null;window.open=null;window.showModalDialog=null;", "javascript");
             *  win.parentWindow.execScript("alert(11);", "javascript");
             *  try
             *  {
             *      win.parentWindow.execScript("document.getElementById('iframemenupage').contentWindow.alert=nalert;");
             *  }
             *  catch
             *  { }
             *  win = null;
             *
             *  // 调用填参方法
             *  FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);
             *  f.tryFillConfiguration();
             * */
        }
Example #3
0
        private void button19_Click(object sender, EventArgs e)
        {
            FillConfigurationAction f2 = new FillConfigurationAction(this.mainWebBrowser);

            f2.selectItemAndPageChange();
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 执行操作之前的验证
            //if (!this.validateInput())
            //{
            //    return;
            //}

            //Matcher.Matcher.readMatchRules("", this.marketFileTextBox.Text);

            // 开始填报


            this.mainWebBrowser.Url = new Uri("http://www.vecc-mep.org.cn/newvip/login.jsp");
            while (this.mainWebBrowser.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }
            if (this.mainWebBrowser.ReadyState == WebBrowserReadyState.Complete)
            {
                // 调用填参方法
                FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);
                f.tryFillGHStep1();
                f.tryFillGHStep1Submit();
                this.textBox1.Text += "成功登入国环申报系统";
                this.textBox1.Text += "\r\n";
            }

            while (this.mainWebBrowser.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            //第二步直接跳转到填报页面
            if (this.mainWebBrowser.ReadyState == WebBrowserReadyState.Complete)
            {
                // 直接跳转页面
                this.mainWebBrowser.Navigate("http://www.vecc-mep.org.cn/newvip/newplan/step01.jsp");

                this.textBox1.Text += "第一次跳转,成功跳转页面进入第一步填报";
                this.textBox1.Text += "\r\n";
                while (this.mainWebBrowser.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }
            }
            //在页面上填报内部编号,选择排放标准和车辆类型
            if (this.mainWebBrowser.ReadyState == WebBrowserReadyState.Complete)
            {
                // 直接跳转页面
                FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);
                f.tryFillGHStep2();
                //f.tryFillGHStep2Submit();

                this.textBox1.Text += "第二次跳转,成功跳转页面进入第二步填报";
                this.textBox1.Text += "\r\n";
                while (this.mainWebBrowser.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }
            }
        }
Example #5
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);

            f.submit();
        }
Example #6
0
        //private void Form1_FormClosing(object sender, EventArgs e)
        //{
        //    Application.Exit();
        //}

        //protected override void OnResize(EventArgs e)
        //{
        //    base.OnResize(e);
        //    if (cccFiller != null && ribbon.SelectedPage.Text == "CCC")
        //        cccFiller.SetWindowPos();
        //}

        //protected override void OnLocationChanged(EventArgs e)
        //{
        //    base.OnLocationChanged(e);
        //    if (cccFiller != null && ribbon.SelectedPage.Text == "CCC")
        //        cccFiller.SetWindowPos();
        //}

        //protected override void OnSizeChanged(EventArgs e)
        //{
        //    base.OnSizeChanged(e);
        //    if (cccFiller != null && ribbon.SelectedPage.Text == "CCC")
        //        cccFiller.SetWindowPos();
        //}

        private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                //判断dataFile地址是不是为空
                if (this.dataFileTextBox.EditValue == null)
                {
                    throw new Exception("数据文件未导入,请选择数据文件");
                }
                String        dataFilePath    = this.dataFileTextBox.EditValue.ToString();
                String        ruleFilePath    = ParamsCollection.localAddr + "rules.xls";
                ImportAction  importAction    = new ImportAction();
                List <String> listPackageCode = importAction.importDataAndRules(ruleFilePath, dataFilePath);

                ChooseSample cs = new ChooseSample();
                if (cs.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                {
                    importAction.deleteUnselectedCarParams(ParamsCollection.selectedPackageCodes);
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < ParamsCollection.carParams.Count; i++)
                    {
                        CarParams cps = ParamsCollection.carParams[i];
                        ParamsCollection.runningCarParams = cps;
                        this.RunningCarInfo.Caption       = "当前正在处理的车型为" + cps.packageCode + "  (" + (i + 1) + "/" + ParamsCollection.carParams.Count + ")";
                        cps.listHtmlAttributes.Clear();
                        cps.listHtmlAttributes.AddRange(DataTransformServiceForHCBM.getAllHAInACar(cps.listParams, ParamsCollection.dicRules));
                        LoginAction.tryLogin(this.mainWebBrowser);
                        this.wait(1);
                        this.mainWebBrowser.Navigate(Constants.APPLY_TEMPORARY_SEQUENCE_NUMBER_PAGE);
                        this.wait(1);
                        FillConfigurationAction f = new FillConfigurationAction(this.mainWebBrowser);
                        f.fillConfigTest(cps.listHtmlAttributes);
                        this.wait(1);
                        //f.submit();
                        this.wait(1);
                        //while (String.IsNullOrEmpty(ParamsCollection.runningCarParams.configCode))
                        //{
                        //    Application.DoEvents();
                        //}
                        this.wait(1);
                        f = new FillConfigurationAction(this.mainWebBrowser);
                        ExportServiceForHCBM.exportCarParams(dataFilePath, cps);
                        //在网页上直接提交车型
                        //f.submitConfigCode(ParamsCollection.runningCarParams.configCode);
                        //while (ParamsCollection.runningCarParams.submitConfigCode != true)
                        //{
                        //    Application.DoEvents();
                        //}
                    }
                    //LoggerUtils.LoggerUtils.loggerTxt(@"d:\test.txt", sb.ToString());
                    this.mainWebBrowser.Url     = new Uri(DeclarationSite.PZSite);
                    this.RunningCarInfo.Caption = "全部任务完成";
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace + ex.Message);
            }
        }