private ISet GetSelectedPrimaryParcels(IFeatureLayer surveyParcelLayer, IWorkspace tantalisWorkspace) { // Mar 12, 2008 m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); //(ISDUTExtension)_App.FindExtensionByName("SUITT Extension"); this.TANTschema = m_pISDUTExt.get_SystemValue("db.tant.schema") + "."; ISet theReturn = null; if (surveyParcelLayer == null) return null; IQueryFilter theQF = new QueryFilterClass(); util.Logger.Write("Fetching all selected parcels"); //theQF.WhereClause = PARCEL_TYPE_FIELD_NAME + " = " + PRIMARY_PARCEL_CODE; //util.Logger.Write("Fetching parcels where: " + PARCEL_TYPE_FIELD_NAME + " = " + PRIMARY_PARCEL_CODE); if (tantalisWorkspace != null) { // Create in-memory join IRelationshipClass2 theRC = null; try { // Open the related table ITable theOsdbTable = ((IFeatureWorkspace)tantalisWorkspace).OpenTable(TANTschema + SURVEY_PARCEL_TAB_NAME); IMemoryRelationshipClassFactory theFactory = new MemoryRelationshipClassFactoryClass(); theRC = (IRelationshipClass2)theFactory.Open( SURVEY_PARCEL_FC_NAME + "_to_" + SURVEY_PARCEL_TAB_NAME, (IObjectClass)surveyParcelLayer.FeatureClass, SURVEY_PARCEL_FK_NAME, (IObjectClass)theOsdbTable, SURVEY_PARCEL_FK_NAME, "forward", "backward", esriRelCardinality.esriRelCardinalityOneToOne); } catch (Exception ex) { util.Logger.Write("Error creating memory relationship class between " + SURVEY_PARCEL_FC_NAME + " and " + SURVEY_PARCEL_TAB_NAME + ":" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); return null; } // Loop through the selected features ISet theSelectedSPs = new SetClass(); ICursor theCursor = null; ((IFeatureSelection)surveyParcelLayer).SelectionSet.Search(null, false, out theCursor); IRow theSPRow = theCursor.NextRow(); while (theSPRow != null) { theSelectedSPs.Add(theSPRow); theSPRow = theCursor.NextRow(); } Marshal.ReleaseComObject(theCursor); IRelClassEnumRowPairs thePairs = theRC.GetObjectsMatchingObjectSetEx(theSelectedSPs, theQF, true); theReturn = new SetClass(); IRow theOsdbRow; thePairs.Next(out theSPRow, out theOsdbRow); while (theSPRow != null) { theReturn.Add(theSPRow); thePairs.Next(out theSPRow, out theOsdbRow); } } else { // Loop through the selected features theReturn = new SetClass(); ICursor theCursor = null; ((IFeatureSelection)surveyParcelLayer).SelectionSet.Search(theQF, false, out theCursor); IRow theSPRow = theCursor.NextRow(); while (theSPRow != null) { theReturn.Add(theSPRow); theSPRow = theCursor.NextRow(); } Marshal.ReleaseComObject(theCursor); } return theReturn; }
public CreateWellSitePointForm(IApplication pApp, IFeatureLayer pFeatureLayerBCGS) { // // Required for Windows Form Designer support // InitializeComponent(); m_pApp = pApp; //m_pMxDoc = (IMxDocument)m_pApp.Document; try { m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); //(ISDUTExtension)m_pApp.FindExtensionByName("SUITT Extension"); this.TANTschema = m_pISDUTExt.get_SystemValue("db.tant.schema") + "."; // this.BCGSMAPLAYER = m_pISDUTExt.get_SystemValue("tools.bcgs.datasetname"); m_pFeatureLayerBCGS = pFeatureLayerBCGS; string bcgsfields = m_pISDUTExt.get_SystemValue("tools.bcgs.fieldname"); m_BCGSFields = bcgsfields.Split(",".ToCharArray()); m_pFeatureLayerWellsTM = tools.utils.LoadFeatureLayerByDatasetName(TANTschema + WELLS_SHAPE,null,m_pISDUTExt.TransactionManager.Current().PGDBConnection); m_pFeatureLayerWellsOSDB = tools.utils.LoadFeatureLayerByDatasetName(TANTschema + WELLS_SHAPE,null,m_pISDUTExt.TransactionManager.ConnectionManager.Tant); m_pTableWellsOSDB = tools.utils.LoadTableByDatasetName(TANTschema + WELLS_TABLE,m_pISDUTExt.TransactionManager.ConnectionManager.Tant); } catch { } }
public override void OnCreate(object hook) { try { if (hook != null) { if (hook is IMxApplication) { // create / access core AO variables. m_app = (IApplication) hook; //m_pMxDoc = (IMxDocument)m_app.Document; // UID pUID; // pUID = new UIDClass(); // pUID.Value = "esriEditor.Editor"; // m_pEditor = (IEditor)m_app.FindExtensionByCLSID(pUID); try { m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); //(ISDUTExtension)m_app.FindExtensionByName("SUITT Extension"); this.BCGSMAPLAYER = m_pISDUTExt.get_SystemValue("tools.bcgs.datasetname"); } catch { throw new Exception("SUITT Extension not found."); } } } } catch(Exception ex) { util.Logger.Write("Failed to Create '" + this.Name + "': " + ex.Message + Environment.NewLine + ex.StackTrace); } }
public override void OnCreate(object hook) { try { if (hook != null) { if (hook is IMxApplication) { // create / access core AO variables. m_app = (IApplication) hook; try { m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); //(ISDUTExtension)m_app.FindExtensionByName("SUITT Extension"); this.ISDUTschema = m_pISDUTExt.get_SystemValue("db.isdut.schema") + "."; } catch { throw new Exception("SUITT Extension not found."); } } } } catch(Exception ex) { util.Logger.Write(" Descrip : Creating command and accessing SUITT extension." + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); } }
public void Init(IWorkspace con, ISDUTExtension ext) { try { adminLayers = new Hashtable(); tantalisLayers = new Hashtable(); if(con==null) return; string prefix = ext.get_SystemValue(DAOUtils.ISDUT_SCHEMA_KEY); if(prefix !=null && !prefix.Equals("") && !prefix.EndsWith(".")) { prefix = prefix+"."; } // load FADM init(con,prefix,BusinessArea.ForAdmBound,adminLayers); // load TANT init(con,prefix,BusinessArea.Tantalis,tantalisLayers); } catch(HandledException e) { throw e; } catch(Exception e) { Logger.Write(e); throw new HandledException(e); } }
public GPSManageForm(IApplication pApp) { try { InitializeComponent(); m_pApp = pApp; //m_pMxDoc = (IMxDocument)m_pApp.Document; sortAscending = true; lastcolumn = string.Empty; try { m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); // (ISDUTExtension)m_pApp.FindExtensionByName("SUITT Extension"); // get the BCGS dataset name and this.BCGSMAPLAYER = m_pISDUTExt.get_SystemValue("tools.bcgs.datasetname"); string bcgsfields = m_pISDUTExt.get_SystemValue("tools.bcgs.fieldname"); m_BCGSFields = bcgsfields.Split(",".ToCharArray()); } catch { throw new Exception("Could not access SUITT Extension or system default values."); } } catch(Exception ex) { util.Logger.Write(" Descrip : Form constructor - access SUITT extension and ISDUT_defaults file." + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); } }
public override void OnCreate(object hook) { try { if (hook != null) { if (hook is IMxApplication) { // create / access core AO variables. m_app = (IApplication) hook; UID pUID; pUID = new UIDClass(); pUID.Value = "esriEditor.Editor"; m_pEditor = (IEditor)m_app.FindExtensionByCLSID(pUID); try { m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); //(ISDUTExtension)m_app.FindExtensionByName("SUITT Extension"); this.TemplateFolder = m_pISDUTExt.get_SystemValue("tools.mapping.templatefolder"); try { string scales = m_pISDUTExt.get_SystemValue("tools.mapping.scales"); m_scales = scales.Split(",".ToCharArray()); } catch{} } catch { throw new Exception("SUITT Extension not found."); } } } } catch(Exception ex) { util.Logger.Write(" Descrip : Creating command and accessing SUITT extension." + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); } }
public static IFeatureClass setupSEELayer(ISDUTExtension ext) { try { string see_layer_name = ext.get_SystemValue(SEE_LAYER_NAME_KEY); Logger.Write("Create SEE Layer: "+see_layer_name); // temp pgdb IWorkspace ws = (new ScratchWorkspaceFactory()).CreateNewScratchWorkspace(); IFeatureWorkspace fws = (IFeatureWorkspace)ws; IFields fields = new FieldsClass(); IFieldsEdit fieldsEdit = (IFieldsEdit)fields; // Make the shape field // it will need a geometry definition, with a spatial reference FieldClass pField = new FieldClass(); ((IFieldEdit)pField).Name_2 = SHAPE_FIELD_NAME; ((IFieldEdit)pField).Type_2 = esriFieldType.esriFieldTypeGeometry; GeometryDefClass pGeomDef = new GeometryDefClass(); ((IGeometryDefEdit)pGeomDef).GeometryType_2 = esriGeometryType.esriGeometryPolygon; ((IGeometryDefEdit)pGeomDef).SpatialReference_2 = ext.FocusMap.SpatialReference; ((IFieldEdit)pField).GeometryDef_2 = pGeomDef; ((IFieldsEdit)fields).AddField(pField); pField = new FieldClass(); ((IFieldEdit)pField).Name_2 = "OID"; ((IFieldEdit)pField).Type_2 = esriFieldType.esriFieldTypeOID; ((IFieldsEdit)fields).AddField(pField); IFeatureClass pFeatureClass = fws.CreateFeatureClass(see_layer_name,fields, null, null, esriFeatureType.esriFTSimple, SHAPE_FIELD_NAME, ""); // Add feature class as layer to the map IFeatureLayer pFeatureLayer = new FeatureLayer(); pFeatureLayer.Visible = true; pFeatureLayer.Name = see_layer_name; pFeatureLayer.FeatureClass = pFeatureClass; pFeatureLayer.Selectable = false; pFeatureLayer.SpatialReference = ((IGeoDataset)pFeatureClass).SpatialReference; Logger.Write("Adding layer"); ext.FocusMap.AddLayer(pFeatureLayer); return pFeatureClass; } catch(Exception e) { MessageBox.Show("An error occured adding/creating the temporary Spatial Edit Extent Layer "+e.Message, "EXCEPTION", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new HandledException(e); } }
public static void removeSEELayer(IFeatureClass featureClass, ISDUTExtension ext) { try { string see_layer_name = ext.get_SystemValue(SEE_LAYER_NAME_KEY); if (featureClass != null) { IMap map = ext.FocusMap; IEnumLayer el = map.get_Layers(null,false); for(ILayer lyr = el.Next();lyr!=null;lyr = el.Next()) { if((lyr is IFeatureLayer && ((IFeatureLayer)lyr).FeatureClass!=null && ((IFeatureLayer)lyr).FeatureClass.Equals(featureClass)) || (lyr != null && lyr.Name != null && lyr.Name.Equals(see_layer_name))) { ((IFeatureLayer)lyr).FeatureClass = null; map.DeleteLayer(lyr); } } } } catch(Exception e) { MessageBox.Show("An error occured removing the temporary Spatial Edit Extent Layer "+e.Message, "EXCEPTION", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new HandledException(e); } }