private void Init() { // 标准和方案 Dictionary <int, string> dicStandard = SysDbHelper.GetStandardInfo(); if (dicStandard == null) { MessageBoxApi.ShowWaringMessageBox("当前系统库中找不到质检标准,无法创建任务!"); this.Close(); this.DialogResult = DialogResult.Cancel; return; } Dictionary <int, string> .ValueCollection.Enumerator enName = dicStandard.Values.GetEnumerator(); while (enName.MoveNext()) { cmbStandard.Properties.Items.Add(enName.Current); } if (cmbStandard.Properties.Items.Count > 0) { cmbStandard.SelectedIndex = 0; } // 创建时间 dateTime.DateTime = DateTime.Now; }
private void wizardControl_CancelClick(object sender, CancelEventArgs e) { if (MessageBoxApi.ShowQuestionMessageBox("是否关闭创建任务向导?") == DialogResult.Yes) { BolFinished = true; this.DialogResult = DialogResult.Cancel; Close(); } }
private void txtfolder_Click(object sender, EventArgs e) { bool cancel = true; switch (m_DataType) { case enumDataType.VCT: dlgSourceFile.Filter = "VCT文件|*.VCT"; dlgSourceFile.FileName = txtDatasource.Text; if (dlgSourceFile.ShowDialog() == DialogResult.OK) { txtDatasource.Text = dlgSourceFile.FileName; cancel = false; } break; case enumDataType.FileGDB: case enumDataType.SHP: dlgSourceFolder.SelectedPath = txtDatasource.Text; if (dlgSourceFolder.ShowDialog() == DialogResult.OK) { txtDatasource.Text = dlgSourceFolder.SelectedPath; cancel = false; } break; case enumDataType.PGDB: dlgSourceFile.Filter = "PGDB(MDB)文件|*.MDB"; dlgSourceFile.FileName = txtDatasource.Text; if (dlgSourceFile.ShowDialog() == DialogResult.OK) { txtDatasource.Text = dlgSourceFile.FileName; cancel = false; } break; default: break; } if (string.IsNullOrEmpty(txtDatasource.Text)) { dxErrorProvider.SetError(txtDatasource, "数据源路径不能为空"); } else { dxErrorProvider.SetError(txtDatasource, null); } if (cancel) { return; } if (m_DataType != enumDataType.VCT) { try { // 空间参考列表 m_DicSpatialReference = new Dictionary <string, ISpatialReference>(); cmbSpatialRefLayer.Properties.Items.Clear(); IWorkspaceFactory wsFactory = null; switch (m_DataType) { case enumDataType.FileGDB: wsFactory = new FileGDBWorkspaceFactoryClass(); break; case enumDataType.SHP: wsFactory = new ShapefileWorkspaceFactoryClass(); break; case enumDataType.PGDB: wsFactory = new AccessWorkspaceFactoryClass(); break; default: break; } IWorkspace wsSource = wsFactory.OpenFromFile(txtDatasource.Text, 0); IEnumDataset enDataset = wsSource.get_Datasets(esriDatasetType.esriDTAny); IDataset ds = enDataset.Next(); while (ds != null) { IGeoDataset geoDs = ds as IGeoDataset; if (geoDs != null) { cmbSpatialRefLayer.Properties.Items.Add(ds.Name); m_DicSpatialReference.Add(ds.Name, geoDs.SpatialReference); } ds = enDataset.Next(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(wsSource); System.Runtime.InteropServices.Marshal.ReleaseComObject(wsFactory); wsSource = null; wsFactory = null; GC.Collect(); } catch { MessageBoxApi.ShowErrorMessageBox("选择的数据源不正确或者数据源中没有空间数据!"); txtDatasource.Text = ""; } if (cmbSpatialRefLayer.Properties.Items.Count == 0) { MessageBoxApi.ShowErrorMessageBox("选择的数据源不正确或者数据源中没有空间数据!"); //dxErrorProvider.SetError(txtDatasource, "当前数据源中没有空间数据", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning); txtDatasource.Text = ""; } else { dxErrorProvider.SetError(txtDatasource, null); cmbSpatialRefLayer.SelectedIndex = 0; } } }
/// <summary> /// 构建Task对象,进行创建 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void wizardControl_FinishClick(object sender, CancelEventArgs e) { this.m_Task = GenerateTask(); IDataImport dataImporter = null; switch (this.m_DataType) { case enumDataType.FileGDB: dataImporter = new FileGDBDataImport(); break; case enumDataType.PGDB: dataImporter = new MDBDataImport(); break; case enumDataType.SHP: dataImporter = new SHPDataImport(); break; case enumDataType.VCT: VCTDataImport vctDataImport = new VCTDataImport(); // vctDataImport.ConvertStepping += new VCTConvertStepHandler(vctDataImport_ConvertStepping); dataImporter = vctDataImport; break; } this.m_Task.DataImporter = dataImporter; this.m_Task.Messager = MessageHandler; //#if !DEBUG this.Hide(); //#endif #region 后台线程导入方式 //Hy.Common.UI.frmProgress frmProgress = new Hy.Common.UI.frmProgress(); //dataImporter.ImportingObjectChanged += new ImportingObjectChangedHandler(frmProgress.ShowDoing); //System.Threading.Thread newThread = new System.Threading.Thread(new System.Threading.ThreadStart(RunTaskCreate)); //newThread.Start(); //frmProgress.ShowGifProgress(); //frmProgress.ShowDialog(); #endregion // 线程显示进度方式 dataImporter.ImportingObjectChanged += new ImportingObjectChangedHandler(dataImporter_ImportingObjectChanged); try { bool isSucceed = m_Task.Create(); isSucceed = isSucceed && m_Task.CreateMXD(); if (isSucceed) { //MessageBoxApi.ShowFinishedMessageBox("任务创建成功!"); BolFinished = true; this.DialogResult = DialogResult.OK; } else { MessageBoxApi.ShowFinishedMessageBox("任务创建失败!"); this.DialogResult = DialogResult.Cancel; } } catch (Exception exp) { MessageHandler(enumMessageType.Exception, exp.ToString()); } finally { m_GifProgress.Hide(); //m_Progress.Hide(); } }
/// <summary> /// Sets the task. /// </summary> /// <param name="task">The task.</param> public void SetTask(CheckTask task) { XGifProgress progressbar = new XGifProgress(); try { //如果task为null则认为释放资源 if (task == null) { UCDispose(); return; } //如果不为空,做处理 m_CurrentTask = task; //如果打开新建的任务 progressbar.ShowHint("正在打开当前质检任务....."); //初始化规则树 this.ucRulesTree.CurrentSchemaId = task.SchemaID; this.ucRulesTree.CurrentTaskName = task.Name; //采用委托,在创建此控件的线程上调用加载tree方法,防止出现“当前对象正在其他地方使用”的错误; LoadRules Load = new LoadRules(this.ucRulesTree.LoadRulesTree); this.BeginInvoke(Load); this.ucResult.CurrentTask = m_CurrentTask; if (File.Exists(task.GetMXDFile())) { //打开配置的mxd模板图层 UcMap.LoadMxFile(task.GetMXDFile()); TocControl.SetBuddyControl(UcMap.Object); TocControl.Update(); UcMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); m_MapLayersController = new MapLayersController(UcMap.Map); } else { progressbar.Hide(); MessageBoxApi.ShowErrorMessageBox(task.GetMXDFile() + "不存在!无法打开此任务"); return; } //加载结果 if (task.ResultConnection != null) { //加载已经检查完成的任务 this.TabCtrl.ShowTabHeader = DefaultBoolean.True; this.TabCtrl.SelectedTabPage = this.TabPageCheckResults; this.ucResultsTree.CurrentSchemaId = task.SchemaID; this.ucResultsTree.CurrentTaskName = task.Name; Sundary.ResultDbOper resultOper = new Hy.Check.UI.UC.Sundary.ResultDbOper(task.ResultConnection); this.ucResultsTree.LayersResultsDt = resultOper.GetLayersResults(); this.ucResultsTree.ResultsDt = resultOper.GetAllResults(); this.ucResultsTree.CheckResultsCount = resultOper.GetResultsCount(); this.ucResultsTree.LoadResultsTree(); } else { TabCtrl.SelectedTabPage = this.TabPageRules; this.TabCtrl.ShowTabHeader = DefaultBoolean.False; this.ucResultsTree.CurrentTreeList.Nodes.Clear(); } //加载top错误图层到map if (task.TopoWorkspace != null) { //获取当前任务子库中的图层集名 m_pDatasetSon = TopoOperAPI.GetCurrentSonDataSet(task.TopoWorkspace as IFeatureWorkspace); // 获取子库中所有的要素类的名称 TopoOperAPI.GetFcTopoNameInSon(UcMap, task.TopoWorkspace as IFeatureWorkspace, m_pDatasetSon); } this.dockTree.Visibility = DockVisibility.Visible; this.dockTree.Text = "规则列表"; this.dockTree.Width = 260; this.dockLegend.Visibility = DockVisibility.Visible; } catch (Exception ex) { progressbar.Hide(); //GT_CONST.LogAPI.CheckLog.AppendErrLogs(ex.Message); XtraMessageBox.Show("打开结果库失败!", "提示"); } finally { progressbar.Hide(); //关闭打开结果库进度服务 } }