/// <summary> /// Used to get the type of the Database /// </summary> /// <param name="ipWorkspace">Input database</param> /// <returns>The type of the input database</returns> private DatabaseType GetDatabaseType(IWorkspace ipWorkspace) { DatabaseType eDBType = DatabaseType.FGDB; if (null != ipWorkspace) { if (ipWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace) { eDBType = DatabaseType.SHAPEFILE; } else if (ipWorkspace.Type == esriWorkspaceType.esriLocalDatabaseWorkspace) { IWorkspaceFactory ipWSFact = ((ipWorkspace as IDataset).FullName as IWorkspaceName).WorkspaceFactory; UID temp = ipWSFact.GetClassID(); string strWorkspaceCLSID = Convert.ToString((ipWSFact.GetClassID().Value)); if (strWorkspaceCLSID.ToUpper() == "{DD48C96A-D92A-11D1-AA81-00C04FA33A15}".ToUpper()) { eDBType = DatabaseType.MDB; } else if (strWorkspaceCLSID.ToUpper() == "{71FE75F0-EA0C-4406-873E-B7D53748AE7E}".ToUpper()) { eDBType = DatabaseType.FGDB; } else if (strWorkspaceCLSID.ToUpper() == "{A06ADB96-D95C-11D1-AA81-00C04FA33A15}".ToUpper()) { eDBType = DatabaseType.SHAPEFILE; } } else if (ipWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) { IDatabaseConnectionInfo2 ipDBInfo = ipWorkspace as IDatabaseConnectionInfo2; esriConnectionDBMS eConnDBMS = ipDBInfo.ConnectionDBMS; if (eConnDBMS == esriConnectionDBMS.esriDBMS_Oracle) { eDBType = DatabaseType.ORACLE; } else if (eConnDBMS == esriConnectionDBMS.esriDBMS_PostgreSQL) { eDBType = DatabaseType.POSTGRESQL; } else if (eConnDBMS == esriConnectionDBMS.esriDBMS_SQLServer) { eDBType = DatabaseType.SQLSERVER; } } } return(eDBType); }
private void MenuItem_Activate(object sender, EventArgs e) { try { // // Error List Context Menu // if (sender == this.menuButtonItemScroll) { // Can only zoom to one item if (this.listViewErrorList.SelectedItems.Count != 1) { return; } // Get EsriTable containing the error ListViewItemError item = (ListViewItemError)this.listViewErrorList.SelectedItems[0]; EsriTable table = null; if (item.Error is ErrorTable) { ErrorTable errorTable = (ErrorTable)item.Error; table = errorTable.Table; } else if (item.Error is ErrorTableRow) { ErrorTableRow errorTableRow = (ErrorTableRow)item.Error; EsriTableRow esriTableRow = (EsriTableRow)errorTableRow.TableRow; table = (EsriTable)esriTableRow.Table; } else if (item.Error is ErrorObject) { ErrorObject errorObject = (ErrorObject)item.Error; table = errorObject.Table; } if (table == null) { return; } // Get Containing Model EsriModel model = (EsriModel)table.Container; // Scroll to Table model.ScrollToElement(table); // Flash Table table.Flash(); } else if (sender == this.menuButtonItemSelect) { // Can only zoom to one item if (this.listViewErrorList.SelectedItems.Count == 0) { return; } foreach (ListViewItemError item in this.listViewErrorList.SelectedItems) { EsriModel model = null; if (item.Error is ErrorTable) { ErrorTable errorTable = (ErrorTable)item.Error; EsriTable table = errorTable.Table; model = (EsriModel)table.Container; } else if (item.Error is ErrorTableRow) { ErrorTableRow errorTableRow = (ErrorTableRow)item.Error; EsriTableRow esriTableRow = (EsriTableRow)errorTableRow.TableRow; EsriTable table = (EsriTable)esriTableRow.Table; model = (EsriModel)table.Container; } else if (item.Error is ErrorObject) { ErrorObject errorObject = (ErrorObject)item.Error; EsriTable table = errorObject.Table; model = (EsriModel)table.Container; } if (model == null) { continue; } // Clear Model Selection model.SelectElements(false); } // foreach (ListViewItemError item in this.listViewErrorList.SelectedItems) { // Get Table EsriTable table = null; if (item.Error is ErrorTable) { ErrorTable errorTable = (ErrorTable)item.Error; table = errorTable.Table; } else if (item.Error is ErrorTableRow) { ErrorTableRow errorTableRow = (ErrorTableRow)item.Error; EsriTableRow esriTableRow = (EsriTableRow)errorTableRow.TableRow; table = (EsriTable)esriTableRow.Table; } else if (item.Error is ErrorObject) { ErrorObject errorObject = (ErrorObject)item.Error; table = errorObject.Table; } if (table == null) { continue; } // Flash Table table.Selected = true; } } else if (sender == this.menuButtonItemFlashError) { // Can only zoom to one item if (this.listViewErrorList.SelectedItems.Count == 0) { return; } // foreach (ListViewItemError item in this.listViewErrorList.SelectedItems) { // Get Table EsriTable table = null; if (item.Error is ErrorTable) { ErrorTable errorTable = (ErrorTable)item.Error; table = errorTable.Table; } else if (item.Error is ErrorTableRow) { ErrorTableRow errorTableRow = (ErrorTableRow)item.Error; EsriTableRow esriTableRow = (EsriTableRow)errorTableRow.TableRow; table = (EsriTable)esriTableRow.Table; } else if (item.Error is ErrorObject) { ErrorObject errorObject = (ErrorObject)item.Error; table = errorObject.Table; } if (table == null) { continue; } // Flash Table table.Flash(); } } else if (sender == this.menuButtonItemClearError) { // Remove Selected Items foreach (ListViewItemError item in this.listViewErrorList.SelectedItems) { if (this.m_errors.Contains(item.Error)) { this.m_errors.Remove(item.Error); } } // Refresh Error List this.RefreshErrorList(); } else if (sender == menuButtonItemClearAllErrors) { // Remove All Errors this.m_errors.Clear(); // Refresh Error List this.RefreshErrorList(); } // // Validator Dropdown Menu // else if (sender == this.menuButtonItemPGdb) { WorkspaceValidator.Default.Validator = new PersonalGeodatabaseValidator(); } else if (sender == this.menuButtonItemFGdb) { WorkspaceValidator.Default.Validator = new FileGeodatabaseValidator(); } else if (sender == this.menuButtonItemSelectGeodatabase) { // Create GxObjectFilter for GxDialog IGxObjectFilter gxObjectFilter = new GxFilterWorkspacesClass(); // Create GxDialog IGxDialog gxDialog = new GxDialogClass(); gxDialog.AllowMultiSelect = false; gxDialog.ButtonCaption = Resources.TEXT_SELECT; gxDialog.ObjectFilter = gxObjectFilter; gxDialog.RememberLocation = true; gxDialog.Title = Resources.TEXT_SELECT_EXISTING_GEODATABASE; // Declare Enumerator to hold selected objects IEnumGxObject enumGxObject = null; // Open Dialog if (!gxDialog.DoModalOpen(0, out enumGxObject)) { return; } if (enumGxObject == null) { return; } // Get Selected Object (if any) IGxObject gxObject = enumGxObject.Next(); if (gxObject == null) { return; } if (!gxObject.IsValid) { return; } // Get GxDatabase if (!(gxObject is IGxDatabase)) { return; } IGxDatabase gxDatabase = (IGxDatabase)gxObject; // Get Workspace IWorkspace workspace = gxDatabase.Workspace; if (workspace == null) { return; } // Get Workspace Factory IWorkspaceFactory workspaceFactory = workspace.WorkspaceFactory; if (workspaceFactory == null) { return; } // Get Workspace Factory ID IUID uid = workspaceFactory.GetClassID(); string guid = uid.Value.ToString().ToUpper(); switch (guid) { case EsriRegistry.GEODATABASE_PERSONAL: WorkspaceValidator.Default.Validator = new PersonalGeodatabaseValidator(workspace); break; case EsriRegistry.GEODATABASE_FILE: WorkspaceValidator.Default.Validator = new FileGeodatabaseValidator(workspace); break; case EsriRegistry.GEODATABASE_SDE: WorkspaceValidator.Default.Validator = new SdeValidator(workspace); break; default: break; } } else if ((sender is MenuButtonItem) && (((MenuButtonItem)sender).Parent == this.menuButtonItemSdeConnection)) { MenuButtonItem item = (MenuButtonItem)sender; if (item.Tag == null) { return; } WorkspaceValidator.Default.Validator = new SdeValidator(item.Tag.ToString()); } } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }