/// <summary> /// 填报按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartFill_ItemClick(object sender, ItemClickEventArgs e) { try { if (String.IsNullOrEmpty(this.importDataFilter)) { throw new Exception("未指定数据文件"); } FillManagerBase test = GetFillManager(this.importDataFilter, mainWebBrowser); if (test == null) { return; } if (test is CCCFillManager) { this.Start3CFill(); } test.Finished += FillManager_Finished; this._fillManager = test; this.tabPage.FillManager = this._fillManager as WebFillManager; test.BeginFill(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace + ex.Message); } }
private void Validate_ItemClick(object sender, ItemClickEventArgs e) { try { if (String.IsNullOrEmpty(this.importDataFilter)) { throw new Exception("未指定数据文件"); } FillManagerBase test = GetFillManager(this.importDataFilter, mainWebBrowser); if (test == null) { return; } if (test.DataProvider.CanValidation) { test.DataProvider.DataSourceFile = this.importDataFilter; if (test.DataProvider.Validate() == false) { MessageBox.Show("数据文件中存在错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("数据已验证!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.StackTrace + ex.Message); } }
private FillManagerBase GetFillManager(string dataFile, WebBrowser2 browser) { FillManagerBase manager = null; if (ribbon.SelectedPage == ghsite) { manager = new GHFillManager(browser, dataFile); } else if (ribbon.SelectedPage == fdlsite) { manager = new FDLFillManager(browser, dataFile); } else if (ribbon.SelectedPage == bhsite) { manager = new BHFillManager(browser, dataFile); } else if (ribbon.SelectedPage == xnysite) { manager = new XNYFillManager(browser, dataFile); } else if (ribbon.SelectedPage == cocsite) { manager = new COCFillManager(browser, dataFile); } else if (ribbon.SelectedPage == pzhsite) { manager = new PZHFillManager(browser, dataFile); } else if (ribbon.SelectedPage == cccsite) { if (cccProcess == null) { this.Start3CProcess(); if (cccProcess == null) { return(null); } while (cccProcess.MainWindowHandle == IntPtr.Zero) { Application.DoEvents(); } } manager = new CCCFillManager((uint)cccProcess.Id, dataFile); } // 为填报器指定数据提供程序。 if (manager != null) { string entripise = FileHelper.GetEntName(); manager.DataProvider = DataProviders.DataProviderFactory.CreateProvider(entripise, GetSelectedPageType()); manager.DataProvider.DataSourceFile = dataFile; if (manager.DataProvider.AllowAlternately) { bool result = manager.DataProvider.ShowWindow(); return(result ? manager : null); } } return(manager); }
private void Start3CProcess() { cccProcess = Get3CProcess(); if (cccProcess == null) { try { RegistryKey sub = null; sub = Registry.LocalMachine.OpenSubKey(string.Format(@"SOFTWARE\{0}ManuFaxturer", Environment.Is64BitOperatingSystem ? @"Wow6432Node\" : "")); object path = sub == null ? null : sub.GetValue("path", null); if (path == null) { path = string.Format(@"{0}\参数填报工具", Environment.GetEnvironmentVariable("programfiles")); } if (File.Exists("licenses.xml")) { File.Copy("licenses.xml", string.Format("{0}\\licenses.xml", path), true); } cccProcess = Process.Start(string.Format(@"{0}\ManuFaxturer.exe", path)); } catch (System.ComponentModel.Win32Exception) { System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Filter = "(应用程序文件)|*.exe"; dialog.CheckFileExists = true; dialog.Title = "打开“参数填报工具”应用程序"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileInfo file = new FileInfo(dialog.FileName); if (File.Exists("licenses.xml")) { File.Copy("licenses.xml", string.Format("{0}\\licenses.xml", file.DirectoryName), true); } cccProcess = Process.Start(dialog.FileName); } else { return; } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK); return; } } this.resumeLocation = this.Location; this.resumeSize = this.Size; mainWebBrowser.Navigate("about:blank"); System.Threading.ThreadPool.QueueUserWorkItem((state) => { cccProcess.WaitForExit(); if (_fillManager != null && _fillManager is CCCFillManager) { _fillManager.EndFill(); _fillManager = null; } cccProcess = null; this.Invoke((Action)(() => { this.TopMost = false; this.Size = resumeSize; this.Location = resumeLocation; })); }, null); }
private void FillManager_Finished(object sender, EventArgs e) { FillManagerBase fillManager = sender as FillManagerBase; if (fillManager is CCCFillManager) { if (this.InvokeRequired) { this.Invoke((Action)(() => { End3CFill(); })); } else { End3CFill(); } } foreach (TabPageWithWebBrowser item in this.tabPageControl.TabPages) { if (item != null && item.FillManager == this._fillManager) { item.FillManager = null; } } this.Invoke((Action)(() => { XtraTabPage result = new XtraTabPage(); System.Windows.Forms.Integration.ElementHost elementHost1 = new System.Windows.Forms.Integration.ElementHost(); elementHost1.Dock = DockStyle.Fill; System.Windows.Controls.ContentControl contentCtrl = new System.Windows.Controls.ContentControl(); System.Windows.ResourceDictionary res = new System.Windows.ResourceDictionary(); res.BeginInit(); res.Source = new Uri("pack://application:,,,/Assistant;component/Template/FillResult.xaml"); res.EndInit(); contentCtrl.ContentTemplate = res["fillResult"] as System.Windows.DataTemplate; contentCtrl.DataContext = fillManager.FillRecords; contentCtrl.Content = fillManager.FillRecords; elementHost1.Child = contentCtrl; result.Controls.Add(elementHost1); result.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True; result.Text = "填报结果"; this.tabPageControl.TabPages.Add(result); this.tabPageControl.SelectedTabPage = result; })); if (fillManager != null) { fillManager.Finished -= FillManager_Finished; try { HistoryHelper.InsertList(fillManager.FillRecords, fillManager.FillType, Constants.CurrentUser == null ? "测试用户" : Constants.CurrentUser.userName); this._fillManager = null; } catch (Exception ex) { this.Invoke((Action)(() => { MessageBox.Show(ex.Message); })); } } }