示例#1
0
        /// <summary>
        /// Geodatabase function: open network dataset
        /// </summary>
        /// <param name="workspace">Input workspace</param>
        /// <param name="strNDSName">Input network dataset name</param>
        /// <returns>NetworkDataset</returns>
        public INetworkDataset OpenNetworkDataset(IWorkspace workspace, string featureDatasetName, string strNDSName)
        {
            // Obtain the dataset container from the workspace
            var featureWorkspace = workspace as IFeatureWorkspace;

            ESRI.ArcGIS.Geodatabase.IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset(featureDatasetName);
            var featureDatasetExtensionContainer = featureDataset as ESRI.ArcGIS.Geodatabase.IFeatureDatasetExtensionContainer;

            ESRI.ArcGIS.Geodatabase.IFeatureDatasetExtension featureDatasetExtension = featureDatasetExtensionContainer.FindExtension(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTNetworkDataset);
            var datasetContainer3 = featureDatasetExtension as ESRI.ArcGIS.Geodatabase.IDatasetContainer3;

            // Use the container to open the network dataset.
            ESRI.ArcGIS.Geodatabase.IDataset dataset = datasetContainer3.get_DatasetByName(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTNetworkDataset, strNDSName);
            return(dataset as ESRI.ArcGIS.Geodatabase.INetworkDataset);
        }
示例#2
0
        /// <summary>
        /// Gets just the tableName part of a dataset's Name
        /// </summary>
        /// <param name="dataset">IDataset to check</param>
        /// <returns>string</returns>
        public static string ParseTableName(ESRI.ArcGIS.Geodatabase.IDataset dataset)
        {
            if (null == dataset)
            {
                throw new ArgumentNullException("dataset");
            }

            string dbName    = string.Empty;
            string tableName = string.Empty;
            string ownerName = string.Empty;

            ESRI.ArcGIS.Geodatabase.ISQLSyntax syntax = (ESRI.ArcGIS.Geodatabase.ISQLSyntax)dataset.Workspace;
            syntax.ParseTableName(dataset.Name, out dbName, out ownerName, out tableName);

            return(tableName);
        }
        public void SelectTracedSpliceClosures()
        {
            // -----------------------------------------------
            // Following section of code causes cable, splice
            // and device features to be selected on the map
            // using the IFeatureSelection & ISelectionSet
            // interfaces
            // -----------------------------------------------

            List <int> spliceOidList = new List <int>();

            // First get set of OIDs that were traced.
            foreach (IRow traceItem in this._traceResults)
            {
                ESRI.ArcGIS.Geodatabase.IDataset dataset = traceItem.Table as ESRI.ArcGIS.Geodatabase.IDataset;
                string className = GdbUtils.ParseTableName(dataset);
                if (0 == string.Compare(className, ConfigUtil.SpliceClosureFtClassName, true))
                {
                    if (traceItem.HasOID)
                    {
                        spliceOidList.Add(traceItem.OID);
                    }
                }
            }

            // Do the actual selection
            ESRI.ArcGIS.Carto.IFeatureSelection scFtSelection = _hookHelper.FindFeatureLayer(ConfigUtil.SpliceClosureFtClassName) as ESRI.ArcGIS.Carto.IFeatureSelection;
            if (scFtSelection == null)
            {
                // No selection to be made as layer not in TOC
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", ConfigUtil.SpliceClosureFtClassName + " not found.", "Layer removed from TOC?");
            }
            else
            {
                ESRI.ArcGIS.Geodatabase.ISelectionSet scSelectionSet = scFtSelection.SelectionSet;
                if (null != scSelectionSet &&
                    0 < spliceOidList.Count)
                {
                    int[] oidList = spliceOidList.ToArray();
                    scSelectionSet.AddList(spliceOidList.Count, ref oidList[0]);
                }
            }
        }
示例#4
0
        //public static FiberSpliceConnectionHelper Instance(object hook, ESRI.ArcGIS.Editor.IEditor editor)
        //{
        //    if (_instance != null)
        //    {
        //        return _instance;
        //    }
        //    else
        //    {
        //        _instance = new FiberSpliceConnectionHelper(hook, editor);
        //        return _instance;
        //    }
        //}


        /// <summary>
        /// Gets a list of cable features that are connected to the splice closure in the geometric network
        /// </summary>
        /// <param name="spliceClosure">Splice to check</param>
        /// <returns>List of IFeature</returns>
        public List <ESRI.ArcGIS.Geodatabase.IFeature> GetConnectedCables(SpliceClosureWrapper spliceClosure)
        {
            // At the time of this comment, splicable means they are connected in the
            // geometric network and the splice closure "touches" one of the ends of the cable
            List <ESRI.ArcGIS.Geodatabase.IFeature> result = new List <ESRI.ArcGIS.Geodatabase.IFeature>();

            if (null == spliceClosure)
            {
                throw new ArgumentNullException("spliceClosure");
            }

            ESRI.ArcGIS.Geometry.IRelationalOperator relOp = spliceClosure.Feature.Shape as ESRI.ArcGIS.Geometry.IRelationalOperator;
            if (relOp == null)
            {
                throw new ArgumentNullException("spliceClosure");
            }

            ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature junction = spliceClosure.Feature as ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature;
            if (null != junction)
            {
                for (int i = 0; i < junction.EdgeFeatureCount; i++)
                {
                    ESRI.ArcGIS.Geodatabase.IFeature connectedEdge = junction.get_EdgeFeature(i) as ESRI.ArcGIS.Geodatabase.IFeature;
                    ESRI.ArcGIS.Geodatabase.IDataset dataset       = connectedEdge.Class as ESRI.ArcGIS.Geodatabase.IDataset;
                    string ftClassName = GdbUtils.ParseTableName(dataset);

                    if (0 == string.Compare(ftClassName, ConfigUtil.FiberCableFtClassName, true))
                    {
                        // Test feature edge is coincident with splice closure. Cables are
                        // complex features so splice might lie half way along some cables
                        // but will not be providing any splice connectivity to them.
                        if (relOp.Touches(connectedEdge.Shape)) // only true if point at either end of a line
                        {
                            result.Add(connectedEdge);
                        }
                    }
                }
            }

            return(result);
        }
        protected override void editor_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
        {
            ESRI.ArcGIS.Geodatabase.IFeature feature = obj as ESRI.ArcGIS.Geodatabase.IFeature;
            if (null != feature && null != feature.Class)
            {
                ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)feature.Class;
                string tableName = GdbUtils.ParseTableName(dataset);

                if (ConfigUtil.IsDeviceClassName(tableName))
                {
                    if (InputPorts != Int32.MinValue && OutputPorts != Int32.MinValue)
                    {
                        try
                        {
                            ConfigureDevice(feature, InputPorts, OutputPorts, true);
                        }
                        catch (Exception ex)
                        {
                            _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Failed to configure device.", ex.Message);

                            string message = "Failed to configure device:" + System.Environment.NewLine +
                                             ex.Message;
                            MessageBox.Show(message, "Configure Device", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        AbortOperation();

                        _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Port counts are not set.", "Please specify a valid configuration of port settings.");

                        string message = "Port counts are not set." + System.Environment.NewLine +
                                         "Please specify a valid configuration of port settings.";
                        MessageBox.Show(message, "Configure Device", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
        /// <summary>
        /// Caches a string representation of the feature based on feature class, display field, and / or OID
        /// </summary>
        private void CacheToString()
        {
            string result = base.ToString();

            if (null != _feature)
            {
                string displayValue = string.Format("OID {0}", _feature.OID);
                if (-1 < _displayFieldIdx)
                {
                    object objValue = _feature.get_Value(_displayFieldIdx);
                    if (DBNull.Value != objValue)
                    {
                        displayValue = objValue.ToString();
                    }
                }

                string ftClassName = "Unknown Ft. Class";

                ESRI.ArcGIS.Geodatabase.IDataset dataset = _feature.Class as ESRI.ArcGIS.Geodatabase.IDataset;
                if (null != dataset)
                {
                    ESRI.ArcGIS.Geodatabase.ISQLSyntax syntax = dataset.Workspace as ESRI.ArcGIS.Geodatabase.ISQLSyntax;
                    if (null != syntax)
                    {
                        string dbName    = string.Empty;
                        string ownerName = string.Empty;
                        string tableName = string.Empty;
                        syntax.ParseTableName(dataset.Name, out dbName, out ownerName, out tableName);
                        ftClassName = tableName;
                    }
                }

                result = string.Format("{0} ({1})", displayValue, ftClassName);
            }

            _toString = result;
        }
        public void PopulateReport(List <ESRI.ArcGIS.Geodatabase.IRow> traceResults)
        {
            // Get the report fields that have been specificed in XML.
            Dictionary <string, List <string> > fieldsDict = ConfigUtil.FiberTraceReportFields();

            treeView1.SuspendLayout();
            treeView1.Nodes.Clear();
            TreeNode parent = null;
            int      idx    = 0;

            foreach (IRow traceItem in traceResults)
            {
                ESRI.ArcGIS.Geodatabase.IDataset dataset = traceItem.Table as ESRI.ArcGIS.Geodatabase.IDataset;
                string className = GdbUtils.ParseTableName(dataset);

                TreeNode node = new TreeNode(className);

                // If row is a feature add feature as tag with click event
                if (traceItem is IFeature)
                {
                    node.BackColor = Color.LightSeaGreen;
                    node.Tag       = traceItem as IFeature;
                }

                // If start node highlight in yellow
                if (_fiberTraceHelper.StartedOnFiber)
                {
                    if (idx == _fiberTraceHelper.StartedFiberIndex)
                    {
                        node.BackColor = Color.Yellow;
                    }
                }

                // Do attributes only if in report xml
                if (fieldsDict.ContainsKey(className))
                {
                    List <string> fields = fieldsDict[className];
                    // Build the details for the node
                    List <NameValuePair> props = GdbUtils.PropertySet(traceItem);
                    foreach (NameValuePair prop in props)
                    {
                        // show all attributes
                        if (fields.Count == 1 && (fields[0].CompareTo("*") == 0))
                        {
                            TreeNode details = new TreeNode(prop.Alias + ": " + prop.Value);
                            node.Nodes.Add(details);
                        }
                        // show selected attributes
                        else if (fields.Contains(prop.Name))
                        {
                            TreeNode details = new TreeNode(prop.Alias + ": " + prop.Value);
                            node.Nodes.Add(details);
                        }
                    }
                }

                if (parent == null)
                {
                    parent = node;
                    // This is the first node in tree
                    treeView1.Nodes.Add(node);
                }
                else
                {
                    parent.Nodes.Add(node);

                    // Indent for major items (devices and splice closures)
                    if (ConfigUtil.IsDeviceClassName(className) ||
                        (0 == string.Compare(className, ConfigUtil.SpliceClosureFtClassName, true)))
                    {
                        // This becomes new parent
                        parent = node;
                    }
                }
                idx++;
            }
            treeView1.ResumeLayout();
        }
示例#8
0
        void Events5_OnCurrentTemplateChanged(IEditTemplate editTemplate)
        {
            try
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Edit template changed.");

                if (editTemplate == null || editTemplate.Layer == null)
                {
                    return;
                }
                if (editTemplate.Layer as IFeatureLayer == null)
                {
                    return;
                }

                IFeatureLayer fLayer = editTemplate.Layer as IFeatureLayer;
                IFeatureClass fc;
                if ((fc = fLayer.FeatureClass) != null)
                {
                    ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)fc;
                    string tableName = GdbUtils.ParseTableName(dataset);

                    // -------------------------------------------------
                    // Checks for different feature types of interest.
                    // Show the appropriate dialogs for any that need it
                    // -------------------------------------------------

                    // -----------------------------
                    // Fiber
                    // -----------------------------
                    if (0 == string.Compare(ConfigUtil.FiberCableFtClassName, tableName, true))
                    {
                        // Is the current template chosen properly configured with default values...
                        // Needs number of buffer tubes and no of strands of fiber
                        if (editTemplate.get_DefaultValue(ConfigUtil.NumberOfBuffersFieldName) == null ||
                            editTemplate.get_DefaultValue(ConfigUtil.NumberOfFibersFieldName) == null)
                        {
                            IEditor3 editor = ArcMap.Editor as IEditor3;
                            editor.CurrentTemplate = null;
                            MessageBox.Show("Template item has not been configured with # Buffer Tubes or # Strands per Tube. \n\nRight click this item and change these values in the properties.\n\nCreate new template items in the 'Organize Templates' window at the top of this area.");
                        }
                        else
                        {
                            int buffers = (int)editTemplate.get_DefaultValue(ConfigUtil.NumberOfBuffersFieldName);
                            int fibers  = (int)editTemplate.get_DefaultValue(ConfigUtil.NumberOfFibersFieldName);

                            FiberCableConfiguration cf = new FiberCableConfiguration(
                                buffers,
                                fibers,
                                "",
                                "");

                            _fiberCableHelper.FiberCableConfig = cf;
                        }

                        // Enable the configuration helper
                        //_fiberCableHelper.onStartEditing();
                    }
                    else
                    {
                        //_fiberCableHelper.onStopEditing();
                    }

                    // -----------------------------
                    // Fiber Devices
                    // -----------------------------
                    if (ConfigUtil.IsDeviceClassName(tableName))
                    {
                        // Is the current template chosen properly configured with default values...
                        // Needs number of buffer tubes and no of strands of fiber
                        if (editTemplate.get_DefaultValue(ConfigUtil.InputPortsFieldName) == null ||
                            editTemplate.get_DefaultValue(ConfigUtil.OutputPortsFieldName) == null)
                        {
                            IEditor3 editor = ArcMap.Editor as IEditor3;
                            editor.CurrentTemplate = null;
                            MessageBox.Show("Template item has not been configured with # Input Ports or # Output Ports. \n\nRight click this item and change these values in the properties.\n\nCreate new template items in the 'Organize Templates' window at the top of this area.");
                        }
                        else
                        {
                            int inputPorts  = (int)editTemplate.get_DefaultValue(ConfigUtil.InputPortsFieldName);
                            int outputPorts = (int)editTemplate.get_DefaultValue(ConfigUtil.OutputPortsFieldName);

                            _fiberDeviceHelper.InputPorts  = inputPorts;
                            _fiberDeviceHelper.OutputPorts = outputPorts;
                        }

                        //_fiberDeviceHelper.onStartEditing();
                    }
                    else
                    {
                        //_fiberDeviceHelper.onStopEditing();
                    }
                }
            }
            catch (Exception ex)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Error changing edit template.", ex.ToString());
            }
        }
示例#9
0
        /// <summary>
        /// Gets all cables that are considered splicable to another cable at a given splice closure.
        /// </summary>
        /// <param name="cable">Cable to splice with</param>
        /// <param name="spliceClosure">Splice Closure to splice at</param>
        /// <returns>List of SpliceableCableWrapper</returns>
        public List <SpliceableCableWrapper> GetSpliceableCables(FiberCableWrapper cable, SpliceClosureWrapper spliceClosure)
        {
            // At the time of this comment, splicable means they are connected in the geometric network
            List <SpliceableCableWrapper> result = new List <SpliceableCableWrapper>();

            if (null == cable)
            {
                throw new ArgumentNullException("cable");
            }
            if (null == spliceClosure)
            {
                throw new ArgumentNullException("spliceClosure");
            }

            int searchOid = cable.Feature.OID;

            ESRI.ArcGIS.Geodatabase.IEdgeFeature cableFt = cable.Feature as ESRI.ArcGIS.Geodatabase.IEdgeFeature;
            ESRI.ArcGIS.Carto.IFeatureLayer      ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.FiberCableFtClassName);
            int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField);

            if (null != cableFt)
            {
                // We assume it is simple. Complex junctions are not supported for splicing cables
                ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature junction = spliceClosure.Feature as ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature;

                if (null != junction)
                {
                    bool isAFromEnd = false; // would be in the case that junction.EID == cableFt.ToJunctionEID
                    if (junction.EID == cableFt.FromJunctionEID)
                    {
                        isAFromEnd = true;
                    }
                    else if (junction.EID != cableFt.ToJunctionEID)
                    {
                        // It isn't the from or the two? It shouldn't have been passed in as if it was coincident with the cable
                        return(result);
//                        throw new InvalidOperationException("Given splice closure is not the junction for the given cable.");
                    }

                    int edgeCount = junction.EdgeFeatureCount;
                    for (int i = 0; i < edgeCount; i++)
                    {
                        ESRI.ArcGIS.Geodatabase.IEdgeFeature connectedEdge = junction.get_EdgeFeature(i);
                        ESRI.ArcGIS.Geodatabase.IFeature     feature       = (ESRI.ArcGIS.Geodatabase.IFeature)connectedEdge;
                        ESRI.ArcGIS.Geodatabase.IDataset     dataset       = feature.Class as ESRI.ArcGIS.Geodatabase.IDataset;
                        string featureClassName = GdbUtils.ParseTableName(dataset);

                        if (0 == string.Compare(featureClassName, ConfigUtil.FiberCableFtClassName) &&
                            feature.OID != searchOid)
                        {
                            if (junction.EID == connectedEdge.FromJunctionEID)
                            {
                                result.Add(new SpliceableCableWrapper(feature, true, isAFromEnd, displayIdx));
                            }
                            else if (junction.EID == connectedEdge.ToJunctionEID)
                            {
                                result.Add(new SpliceableCableWrapper(feature, false, isAFromEnd, displayIdx));
                            }
                        }
                    }
                }
            }

            return(result);
        }
示例#10
0
        public static IFeatureClass createGoogleMapsEngineCatalogFeatureClass(ref log4net.ILog log, ref GoogleMapsEngineToolsExtensionForArcGIS ext)
        {
            try
            {
                // temporary directory to store workspace
                string workspacedirectory = ext.getLocalWorkspaceDirectory().FullName;

                // add the directory to the cleanup list
                // TODO: Replace with scratch
                ext.addTemporaryDirectory(new System.IO.DirectoryInfo(workspacedirectory));

                // determine the workspace name for the geodatabase
                //string workspacefoldername = Properties.Settings.Default.extension_gdb_workspacename;
                // TODO: Use sctach workspace instead of creating a temporary one
                string workspacefoldername = "GME_Data_" + System.Guid.NewGuid().ToString().Replace("-", "");

                // define a workspace to do work
                IWorkspace workspace = null;

                // attempt to open or create the workspace
                try
                {
                    // check to see if the workspace already exists, if so, open it
                    if (System.IO.Directory.Exists(workspacedirectory + "\\" + workspacefoldername))
                    {
                        workspace = Extension.Data.GeodatabaseUtilities.openFileGeodatabaseWorkspace(ref log, workspacedirectory, workspacefoldername);
                        ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace;
                        ESRI.ArcGIS.Geodatabase.IFeatureClass     featureClass     = featureWorkspace.OpenFeatureClass(Properties.Resources.GeodatabaseUtilities_schema_FeatureClassName);
                        ESRI.ArcGIS.Geodatabase.IDataset          pdataset         = (ESRI.ArcGIS.Geodatabase.IDataset)featureClass;
                        if (pdataset.CanDelete())
                        {
                            pdataset.Delete();
                        }

                        pdataset         = null;
                        featureClass     = null;
                        featureWorkspace = null;

                        // TODO: Open instead of delete/replace
                        //if (arcgis.ext.gdb.GeodatabaseUtilities.deleteFileGeodatabaseWorkspace(workspacedirectory, workspacefoldername))
                        //workspace = arcgis.ext.gdb.GeodatabaseUtilities.createFileGeodatabaseWorkspace(workspacedirectory, workspacefoldername);
                    }
                    else
                    {
                        // workspace doesn't exist, create the workspace
                        workspace = Extension.Data.GeodatabaseUtilities.createFileGeodatabaseWorkspace(ref log, workspacedirectory, workspacefoldername);
                    }
                }
                catch (System.Exception ex)
                {
                    // unable to create the fgdb or unable to delete the fc within the fgdb
                    log.Error(ex);
                    System.Windows.Forms.MessageBox.Show("Unable to create or delete an existing feature class.");
                }

                // verify the workspace is open
                if (workspace != null)
                {
                    // create a new feature workspace to work spatially
                    IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

                    // create a spatial reference for the Google Earth Builder data (always in 4326)
                    SpatialReferenceEnvironment sRefEnvGEB = new SpatialReferenceEnvironment();
                    ISpatialReference           sGEBRef    = sRefEnvGEB.CreateGeographicCoordinateSystem(4326);

                    // for this feature class, create and determine the field
                    IFields     fields     = new FieldsClass();
                    IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
                    fieldsEdit.FieldCount_2 = 10;

                    //Create the Object ID field.
                    IField     fusrDefinedField     = new Field();
                    IFieldEdit fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_OBJECTID_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_OBJECTID_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeOID;
                    fieldsEdit.set_Field(0, fusrDefinedField);

                    //Create the CustomerId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_CustomerId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_CustomerId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(1, fusrDefinedField);

                    //Create the MapAssetId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_MapAssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(2, fusrDefinedField);

                    //Create the AssetId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(3, fusrDefinedField);

                    //Create the ParentAssetId field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_ParentAssetId_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(4, fusrDefinedField);

                    //Create the AssetType field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetType_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetType_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(5, fusrDefinedField);

                    //Create the AssetName field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetName_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetName_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(6, fusrDefinedField);

                    //Create the AssetDescription field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_AssetDescription_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(7, fusrDefinedField);

                    //Create the MapSharedWith field.
                    fusrDefinedField                 = new Field();
                    fusrDefinedFieldEdit             = (IFieldEdit)fusrDefinedField;
                    fusrDefinedFieldEdit.Name_2      = Properties.Resources.GeodatabaseUtilities_schema_MapSharedWith_Name;
                    fusrDefinedFieldEdit.AliasName_2 = Properties.Resources.GeodatabaseUtilities_schema_MapSharedWith_AliasName;
                    fusrDefinedFieldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    fieldsEdit.set_Field(8, fusrDefinedField);

                    // Create the Shape field.
                    fusrDefinedField     = new Field();
                    fusrDefinedFieldEdit = (IFieldEdit)fusrDefinedField;
                    // Set up the geometry definition for the Shape field.
                    IGeometryDef     geometryDef     = new GeometryDefClass();
                    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon;
                    // By setting the grid size to 0, you're allowing ArcGIS to determine the appropriate grid sizes for the feature class.
                    // If in a personal geodatabase, the grid size will be 1000. If in a file or ArcSDE geodatabase, the grid size
                    // will be based on the initial loading or inserting of features.
                    geometryDefEdit.GridCount_2 = 1;
                    geometryDefEdit.set_GridSize(0, 0);
                    geometryDefEdit.HasM_2 = false;
                    geometryDefEdit.HasZ_2 = false;
                    //Assign the spatial reference that was passed in, possibly from
                    //IGeodatabase.SpatialReference for the containing feature dataset.
                    geometryDefEdit.SpatialReference_2 = sGEBRef;
                    // Set standard field properties.
                    fusrDefinedFieldEdit.Name_2        = "SHAPE";
                    fusrDefinedFieldEdit.Type_2        = esriFieldType.esriFieldTypeGeometry;
                    fusrDefinedFieldEdit.GeometryDef_2 = geometryDef;
                    fusrDefinedFieldEdit.IsNullable_2  = true;
                    fusrDefinedFieldEdit.Required_2    = true;
                    fieldsEdit.set_Field(9, fusrDefinedField);

                    // Create a feature class description object to use for specifying the CLSID and EXTCLSID.
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription  ocDesc = (IObjectClassDescription)fcDesc;

                    IFeatureClass fc = featureWorkspace.CreateFeatureClass(
                        Properties.Resources.GeodatabaseUtilities_schema_FeatureClassName, // Feature Class Name
                        fields,                                                            // Feature Class Fields (defined above)
                        ocDesc.InstanceCLSID,
                        ocDesc.ClassExtensionCLSID,
                        esriFeatureType.esriFTSimple,
                        fcDesc.ShapeFieldName, // Shape Field Name
                        ""                     // Keyword Configurations
                        );

                    // return the feature class
                    return(fc);
                }
                else
                {
                    // end gracefully, maybe prompt the user that the toolbar wasn't able to create a workspcae
                    throw new Exception("Unable to open local geodatabase.");
                }
            }
            catch (System.Exception ex)
            {
                // an error occured
                log.Error(ex);

                // throw an exception
                throw new Exception("An unknown exception occured while attempting to create a local feature class.");
            }
        }