Example #1
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPValue      field      = parameters["in_field"];
            IObjectClass  table      = utilities.OpenTable(parameters["in_table"]);
            IGPMultiValue modelNames = (IGPMultiValue)parameters["in_field_model_names"];

            if (!field.IsEmpty() && modelNames.Count > 0)
            {
                var fieldName = field.GetAsText();
                int index     = table.FindField(fieldName);

                foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText()))
                {
                    messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Removing the {0} field model name from the {1} field.", modelName, fieldName);

                    ModelNameManager.Instance.RemoveFieldModelName(table, table.Fields.Field[index], modelName);
                }

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Example #2
0
        /// <summary>
        ///     Finds the <see cref="IField" /> that has been assigned the <paramref name="modelName" /> that is within the
        ///     specified <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class to check for model names</param>
        /// <param name="modelName">The field model name.</param>
        /// <param name="throwException">
        ///     if set to <c>true</c> if an exception should be thrown when the model name is not
        ///     assigned.
        /// </param>
        /// <returns>
        ///     Returns the  <see cref="ESRI.ArcGIS.Geodatabase.IField" /> that has been assigned the model name.
        /// </returns>
        /// <exception cref="ArgumentNullException">modelName</exception>
        /// <exception cref="MissingFieldModelNameException"></exception>
        public static IField GetField(this IObjectClass source, string modelName, bool throwException)
        {
            if (source == null)
            {
                return(null);
            }
            if (modelName == null)
            {
                throw new ArgumentNullException("modelName");
            }

            if (ModelNameManager.Instance.CanReadModelNames(source))
            {
                IField field = ModelNameManager.Instance.FieldFromModelName(source, modelName);

                if (field == null && throwException)
                {
                    throw new MissingFieldModelNameException(source, modelName);
                }

                return(field);
            }

            return(null);
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="FieldLookupSubtypeDomain"/> class.
            /// </summary>
            /// <param name="objectClass">The object class.</param>
            /// <param name="fieldIndex">Index of the field.</param>
            public FieldLookupSubtypeDomain([NotNull] IObjectClass objectClass, int fieldIndex)
                : base(fieldIndex)
            {
                Assert.ArgumentNotNull(objectClass, nameof(objectClass));

                IField field = objectClass.Fields.Field[fieldIndex];

                var classSubtypes = (ISubtypes)objectClass;

                _subtypeFieldIndex = classSubtypes.SubtypeFieldIndex;

                IList <Subtype> subtypes = DatasetUtils.GetSubtypes(objectClass);

                foreach (Subtype subtype in subtypes)
                {
                    ICodedValueDomain domain =
                        (ICodedValueDomain)classSubtypes.Domain[subtype.Code, field.Name]
                        ??
                        (ICodedValueDomain)field.Domain;

                    Dictionary <object, string> namesByValue = GetCodedValueMap(domain);

                    _displayValueMap.Add(subtype.Code, namesByValue);
                }

                // get default domain values
                _nameByValueDefaultDomain = GetCodedValueMap(
                    (ICodedValueDomain)field.Domain);
            }
Example #4
0
        private static string GetCompareFieldsString([NotNull] IObjectClass objectClass,
                                                     [NotNull] IEnumerable <int> fieldIndexes)
        {
            var sb = new StringBuilder();

            IFields fields = objectClass.Fields;

            foreach (int fieldIndex in fieldIndexes)
            {
                IField field = fields.Field[fieldIndex];

                string token = GetFieldNameToken(field);

                if (sb.Length == 0)
                {
                    sb.Append(token);
                }
                else
                {
                    sb.AppendFormat(", {0}", token);
                }
            }

            return(sb.ToString());
        }
Example #5
0
 /// <summary>
 ///     Removes the specified type.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="type">The type.</param>
 public void Remove(IObjectClass source, Type type)
 {
     foreach (var entry in source.GetSubtypes())
     {
         this.Remove(source.ObjectClassID, entry.Key, type);
     }
 }
Example #6
0
        } // doWork method

        protected void RegisterWithGeodatabase(
            IObjectClass objectClass,
            String oidFieldName)
        {
            if (oidFieldName == "")
            {
                oidFieldName = "OBJECTID";
            }
            // Attempt to acquire an exclusive schema lock for the object class.
            ISchemaLock schemaLock = (ISchemaLock)objectClass;

            try {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                // If this point is reached, the exclusive lock was acquired. We can cast the object
                // class to IClassSchemaEdit and call RegisterAsObjectClass.
                IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)objectClass;
                classSchemaEdit.RegisterAsObjectClass(oidFieldName, "");
            }
            catch (COMException comExc) {
                // Re-throw the exception.
                throw comExc;
            }
            finally {
                // Reset the lock on the object class to a shared lock.
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        } // RegisterWithGeodatabase method
Example #7
0
        /// <summary>
        ///     Executes the geoprocessing function using the given array of parameter values.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="trackCancel">The track cancel.</param>
        /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param>
        /// <param name="messages">The messages that are reported to the user.</param>
        /// <param name="utilities">
        ///     The utilities object that provides access to the properties and methods of a geoprocessing
        ///     objects.
        /// </param>
        protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities)
        {
            IGPMultiValue tables     = (IGPMultiValue)parameters["in_tables"];
            IGPMultiValue modelNames = (IGPMultiValue)parameters["in_class_model_names"];
            int           addedCount = 0;

            if (tables.Count > 0 && modelNames.Count > 0)
            {
                foreach (var table in tables.AsEnumerable())
                {
                    IObjectClass dataElement = utilities.OpenTable(table);

                    foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText()))
                    {
                        messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Adding the {0} class model name to the {1} table.", modelName, dataElement.AliasName);

                        ModelNameManager.Instance.AddClassModelName(dataElement, modelName);
                        addedCount++;
                    }
                }
            }

            if (addedCount == tables.Count)
            {
                // Success
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Example #8
0
        /// <summary>
        ///     Get the value of field that has been configured to be the primary display field.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The object class.</param>
        /// <returns>
        ///     Returns a <see cref="IField" /> representing the field for the primary display.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">table</exception>
        public static IField GetPrimaryDisplayField(this IMMConfigTopLevel source, IObjectClass table)
        {
            if (source == null)
            {
                return(null);
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            var featureClass = source.GetFeatureClassOnly(table);

            if (featureClass == null)
            {
                return(null);
            }

            int index = table.Fields.FindField(featureClass.PriDisplayField);

            if (index == -1)
            {
                return(null);
            }

            IField field = table.Fields.Field[index];

            return(field);
        }
Example #9
0
        private bool method_2(IObjectClass iobjectClass_1)
        {
            bool flag;

            try
            {
                IEnumSchemaLockInfo info;
                (iobjectClass_1 as ISchemaLock).GetCurrentSchemaLocks(out info);
                info.Reset();
                for (ISchemaLockInfo info2 = info.Next(); info2 != null; info2 = info.Next())
                {
                    if (info2.SchemaLockType == esriSchemaLock.esriExclusiveSchemaLock)
                    {
                        goto Label_0041;
                    }
                }
                return(true);

Label_0041:
                flag = false;
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Example #10
0
        public override void OnClick()
        {
            frmObjectClass _frmObjectClass = new frmObjectClass()
            {
                UseType = enumUseType.enumUTObjectClass
            };
            IObjectClass objectClass = null;

            if (((IGxSelection)_context.GxSelection).FirstObject is IGxDatabase)
            {
                GxCatalogCommon.ConnectGDB(((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase);
                if ((((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace == null)
                {
                    return;
                }
                _frmObjectClass.Dataset = (((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace;
                if (_frmObjectClass.ShowDialog() == DialogResult.OK)
                {
                    objectClass = _frmObjectClass.ObjectClass;
                }
            }
            if (objectClass != null)
            {
                ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
            }
        }
Example #11
0
 private void method_1(IVersionedTable iversionedTable_0, IVersionedTable iversionedTable_1, string string_0,
                       string string_1, esriDifferenceType esriDifferenceType_0, string string_2, bool bool_2, IList ilist_0)
 {
     try
     {
         int          num;
         IRow         row;
         IQueryFilter queryFilter = new QueryFilterClass();
         IObjectClass class2      = iversionedTable_0 as IObjectClass;
         queryFilter.SubFields = class2.OIDFieldName;
         IDifferenceCursor cursor = iversionedTable_0.Differences(iversionedTable_1 as ITable,
                                                                  esriDifferenceType_0, queryFilter);
         cursor.Next(out num, out row);
         while (num != -1)
         {
             if (bool_2)
             {
                 this.method_2(num, esriDifferenceType_0, string_1, string_0, string_2, ilist_0);
             }
             else
             {
                 this.method_2(num, esriDifferenceType_0, string_0, string_1, string_2, ilist_0);
             }
             cursor.Next(out num, out row);
         }
     }
     catch
     {
     }
 }
Example #12
0
        /// <summary>
        ///     Changes the field visibility to the specified <paramref name="visible" /> value for all subtypes in the specified
        ///     <paramref name="table" /> object class
        ///     that match the field name.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The object class.</param>
        /// <param name="visible">if set to <c>true</c> if the field is visible.</param>
        /// <param name="fieldNames">The field names.</param>
        /// <exception cref="ArgumentNullException">
        ///     fieldNames
        ///     or
        ///     table
        /// </exception>
        public static void ChangeVisibility(this IMMConfigTopLevel source, IObjectClass table, bool visible, params string[] fieldNames)
        {
            if (source == null)
            {
                return;
            }
            if (fieldNames == null)
            {
                throw new ArgumentNullException("fieldNames");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            // Change the hidden subtype of -1, which represents all subtypes.
            source.ChangeVisibility(table, ALL_SUBTYPES, visible, fieldNames);

            ISubtypes         subtypes     = (ISubtypes)table;
            IEnumerable <int> subtypeCodes = subtypes.HasSubtype ? subtypes.Subtypes.AsEnumerable().Select(o => o.Key) : new[] { subtypes.DefaultSubtypeCode };

            // Change the individual subtypes.
            foreach (var subtypeCode in subtypeCodes)
            {
                source.ChangeVisibility(table, subtypeCode, visible, fieldNames);
            }
        }
Example #13
0
        protected override void Configure(IConfiguration config)
        {
            IObjectClass itemClass = config.ObjectClass(typeof(MultiDeleteTestCase.Item));

            itemClass.CascadeOnDelete(true);
            itemClass.CascadeOnUpdate(true);
        }
        /// <exception cref="System.Exception"></exception>
        public virtual void TestRemoveArrayField()
        {
            RemoveArrayFieldTestCase.DataBefore dataA = new RemoveArrayFieldTestCase.DataBefore
                                                            ("a", true, new object[] { "X" });
            RemoveArrayFieldTestCase.DataBefore dataB = new RemoveArrayFieldTestCase.DataBefore
                                                            ("b", false, new object[0]);
            Store(dataA);
            Store(dataB);
            IObjectClass oc = Fixture().Config().ObjectClass(typeof(RemoveArrayFieldTestCase.DataBefore
                                                                    ));

            // we must use ReflectPlatform here as the string must include
            // the assembly name in .net
            oc.Rename(CrossPlatformServices.FullyQualifiedName(typeof(RemoveArrayFieldTestCase.DataAfter
                                                                      )));
            Reopen();
            IQuery query = NewQuery(typeof(RemoveArrayFieldTestCase.DataAfter));

            query.Descend("name").Constrain("a");
            IObjectSet result = query.Execute();

            Assert.AreEqual(1, result.Count);
            RemoveArrayFieldTestCase.DataAfter data = (RemoveArrayFieldTestCase.DataAfter)result
                                                      .Next();
            Assert.AreEqual(dataA.name, data.name);
            Assert.AreEqual(dataA.status, data.status);
        }
Example #15
0
        /// <summary>
        /// Creates relationship classes between the Broadcast feature class and the Voyage and Vessel tables.
        /// </summary>
        /// <param name="pWorkspace">FileGeodatabase workspace.</param>
        public void CreateRelationshipClass(IWorkspace pWorkspace)
        {
            try
            {
                if (!(IsArcInfoLicense()))
                {
                    return;
                }

                IFeatureWorkspace pFWS = (IFeatureWorkspace)pWorkspace;

                // Creating a relationship class without an intermediate table.
                IObjectClass pOriginClass = (IObjectClass)pFWS.OpenFeatureClass("Broadcast");
                IObjectClass pVesselClass = (IObjectClass)pFWS.OpenTable("Vessel");
                IObjectClass pVoyageClass = (IObjectClass)pFWS.OpenTable("Voyage");

                IRelationshipClass pVesselRClass = pFWS.CreateRelationshipClass("BroadcastHasVessel", pOriginClass, pVesselClass, "Vessel",
                                                                                "Broadcast", esriRelCardinality.esriRelCardinalityOneToOne, esriRelNotification.esriRelNotificationBoth, false,
                                                                                false, null, "MMSI", "", "MMSI", "");

                IRelationshipClass pVoyageRClass = pFWS.CreateRelationshipClass("BroadcastHasVoyage", pOriginClass, pVoyageClass, "Voyage",
                                                                                "Broadcast", esriRelCardinality.esriRelCardinalityOneToOne, esriRelNotification.esriRelNotificationBoth, false,
                                                                                false, null, "VoyageID", "", "VoyageID", "");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #16
0
        public static void HarvestAttributes([NotNull] ObjectDataset objectDataset,
                                             [CanBeNull] IAttributeConfigurator configurator,
                                             [NotNull] IObjectClass objectClass)
        {
            Assert.ArgumentNotNull(objectClass, nameof(objectClass));

            objectDataset.ClearAttributeMaps();

            IList <IField> fields = DatasetUtils.GetFields(objectClass);

            for (var fieldIndex = 0; fieldIndex < fields.Count; fieldIndex++)
            {
                AddOrUpdateAttribute(objectDataset, fields[fieldIndex], fieldIndex);
            }

            if (configurator != null)
            {
                configurator.Configure(objectDataset, objectClass);

                // Clear _attributesByRole cache
                objectDataset.ClearAttributeMaps();
            }

            DeleteAttributesNotInList(objectDataset, fields);

            objectDataset.ClearAttributeMaps();
        }
        /// <exception cref="System.Exception"></exception>
        private void AssertNoAccidentalDeletes(bool cascadeOnUpdate, bool cascadeOnDelete
                                               )
        {
            DeleteAll(typeof(CascadeOnDeleteTestCase.Holder));
            DeleteAll(typeof(CascadeOnDeleteTestCase.Item));
            IObjectClass oc = Fixture().Config().ObjectClass(typeof(CascadeOnDeleteTestCase.Holder
                                                                    ));

            oc.CascadeOnDelete(cascadeOnDelete);
            oc.CascadeOnUpdate(cascadeOnUpdate);
            Reopen();
            CascadeOnDeleteTestCase.Item   item   = new CascadeOnDeleteTestCase.Item();
            CascadeOnDeleteTestCase.Holder holder = new CascadeOnDeleteTestCase.Holder();
            holder.items = new CascadeOnDeleteTestCase.Item[] { item };
            Db().Store(holder);
            Db().Commit();
            holder.items[0].item = "abrakadabra";
            Db().Store(holder);
            if (!cascadeOnDelete && !cascadeOnUpdate)
            {
                // the only case, where we don't cascade
                Db().Store(holder.items[0]);
            }
            Assert.AreEqual(1, CountOccurences(typeof(CascadeOnDeleteTestCase.Item)));
            Db().Commit();
            Assert.AreEqual(1, CountOccurences(typeof(CascadeOnDeleteTestCase.Item)));
        }
        // Сохранить результат в базе данных

        public bool Store(int k)
        {
            MyEntityContext ctx = Application.Context;

            PrepareClusters(k);

            ctx.ObjectClasss.ToList().ForEach(ctx.DeleteObject);
            ctx.SaveChanges();

            foreach (var cl in Cidx.Select((c, i) => new { c, i }))
            {
                IObjectClass c = ctx.ObjectClasss.Create();
                c.Cluster = cl.c;
                IObject ob = input[cl.i];
                c.Object = ob;
                Console.WriteLine("ob:" + ob.GUID + "->" + cl.c + "[" + cl.i + "]");
            }

            ctx.SaveChanges();

            ctx.ClassNames.ToList().ForEach(ctx.DeleteObject);

            for (int i = 0; i < k; i++) // Заготовки имен кластеров.
            {
                IClassName cn = ctx.ClassNames.Create();
                cn.Name    = i.ToString();
                cn.Cluster = i;
            }

            ctx.SaveChanges();

            return(true);
        }
        public bool IsFeatureClassLockable(IFeatureClass checkFeatureClass)
        {
            IObjectClass objectClass = checkFeatureClass as IObjectClass;

            if (objectClass == null)
            {
                return(false);
            }

            ISchemaLock schemaLock = (ISchemaLock)objectClass;

            if (schemaLock == null)
            {
                return(false);
            }

            // Get an enumerator over the current schema locks.
            IEnumSchemaLockInfo enumSchemaLockInfo = null;

            schemaLock.GetCurrentSchemaLocks(out enumSchemaLockInfo);

            // Iterate through the locks.
            ISchemaLockInfo schemaLockInfo = null;
            int             lockCount      = 0;

            while ((schemaLockInfo = enumSchemaLockInfo.Next()) != null)
            {
                lockCount++;
                Trace.WriteLine(string.Format("{0} : {1} : {2}", schemaLockInfo.TableName,
                                              schemaLockInfo.UserName, schemaLockInfo.SchemaLockType));
            }

            // Note: 1 sharedLock for this process is normal, so we test for > 1 lock
            return(lockCount < 2);
        }
Example #20
0
        public void InsertFeatures(IObjectClass oc, IRowBufferCollection rows)
        {
            if (oc == null || rows == null || rows.Count == 0)
            {
                return;
            }
            IFdeCursor cursor = null;

            try
            {
                oc.FeatureDataSet.DataSource.StartEditing();
                cursor = oc.Insert();
                for (int i = 0; i < rows.Count; ++i)
                {
                    IRowBuffer row = rows.Get(i);
                    cursor.InsertRow(row);
                    int oid = cursor.LastInsertId;
                    row.SetValue(0, oid);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    oc.FeatureDataSet.DataSource.StopEditing(true);
                }
                //Marshal.ReleaseComObject(cursor);
            }
        }
Example #21
0
        /// <summary>
        ///     Changes the field visibility to the specified <paramref name="visible" /> value for the subtype in the specified
        ///     <paramref name="table" /> object class
        ///     that match the field name.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The object class.</param>
        /// <param name="subtypeCode">The subtype code.</param>
        /// <param name="visible">if set to <c>true</c> if the field is visible.</param>
        /// <param name="fieldNames">The field names.</param>
        /// <exception cref="ArgumentNullException">
        ///     fieldNames
        ///     or
        ///     table
        /// </exception>
        public static void ChangeVisibility(this IMMConfigTopLevel source, IObjectClass table, int subtypeCode, bool visible, params string[] fieldNames)
        {
            if (source == null)
            {
                return;
            }
            if (fieldNames == null)
            {
                throw new ArgumentNullException("fieldNames");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            IMMSubtype subtype = source.GetSubtypeByID(table, subtypeCode, false);

            if (subtype == null)
            {
                return;
            }

            foreach (var fieldName in fieldNames)
            {
                subtype.ChangeVisibility(fieldName, visible);
            }
        }
Example #22
0
        /// <summary>
        ///     Gets a dictionary of the fields that are assigned the <paramref name="modelNames" /> organized by the model name
        ///     followed by the field indexes.
        ///     specified <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class</param>
        /// <param name="modelNames">The model names.</param>
        /// <returns>
        ///     Returns the  <see cref="Dictionary{Key, Value}" /> representing the field model name for the field indexes.
        /// </returns>
        /// <exception cref="ArgumentNullException">modelNames</exception>
        public static Dictionary <string, List <int> > GetFieldIndexes(this IObjectClass source, params string[] modelNames)
        {
            if (source == null)
            {
                return(null);
            }
            if (modelNames == null)
            {
                throw new ArgumentNullException("modelNames");
            }

            Dictionary <string, List <int> > indexes = new Dictionary <string, List <int> >(StringComparer.Create(CultureInfo.CurrentCulture, true));

            foreach (var modelName in modelNames)
            {
                var list = new List <int>();

                if (indexes.ContainsKey(modelName))
                {
                    list = indexes[modelName];
                }
                else
                {
                    indexes.Add(modelName, list);
                }

                list.AddRange(source.GetFields(modelName).Select(field => source.FindField(field.Name)));
            }

            return(indexes);
        }
Example #23
0
        public static string GetDisplayValue([NotNull] IObject obj)
        {
            Assert.ArgumentNotNull(obj, nameof(obj));

            var className = "Unknown class";
            var id        = "no ID";

            IObjectClass objectClass = obj.Class;

            if (objectClass != null)
            {
                string aliasName = DatasetUtils.GetAliasName(objectClass);
                if (aliasName.Length > 0)
                {
                    className = aliasName;
                }
                else
                {
                    var dataset = objectClass as IDataset;
                    if (dataset != null)
                    {
                        className = dataset.Name;
                    }
                }
            }

            if (obj.HasOID)
            {
                id = obj.OID.ToString(CultureInfo.CurrentCulture);
            }

            return(string.Format("{0} - ID: {1}", className, id));
        }
Example #24
0
        private bool DeleteFacClassReg(FacClassReg reg)
        {
            try
            {
                IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(false);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass");
                if (oc == null)
                {
                    return(false);
                }

                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = string.Format("FacClassCode = '{0}'", reg.FacClassCode);
                oc.Delete(filter);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public void WireFabricTableEditEvents()
        {
            if (_objectClassEventList == null)
            {
                _objectClassEventList = new List <ESRI.ArcGIS.Geodatabase.IObjectClassEvents_Event>();
            }

            //create event handler for each fabric class in the edit workspace
            try
            {
                _objectClassEventList.Clear();
                for (int i = 0; i < _fabricObjectClassIds.Count; i++)
                {
                    IObjectClass pObjClass = (IObjectClass)_fabricObjectClasses.get_Element(i);
                    //Create event handler.
                    ESRI.ArcGIS.Geodatabase.IObjectClassEvents_Event ev = (ESRI.ArcGIS.Geodatabase.IObjectClassEvents_Event)pObjClass;
                    ev.OnChange += new ESRI.ArcGIS.Geodatabase.IObjectClassEvents_OnChangeEventHandler(FabricRowChange);
                    ev.OnChange += new ESRI.ArcGIS.Geodatabase.IObjectClassEvents_OnChangeEventHandler(FabricGeometryRowChange);
                    //ev.OnCreate += new ESRI.ArcGIS.Geodatabase.IObjectClassEvents_OnCreateEventHandler(FabricRowCreate);
                    _objectClassEventList.Add(ev);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " in Wire Fabric Events");
            }
        }
Example #26
0
        /// <summary>
        /// Sets a join based on the specified relationship class and join type.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="foreignClass">The join.</param>
        /// <param name="layerKeyField">Name of the layer field.</param>
        /// <param name="foreignKeyField">Name of the join field.</param>
        /// <param name="cardinality">The cardinality.</param>
        /// <param name="joinType">Type of the join.</param>
        /// <returns>
        /// Returns a <see cref="IRelQueryTable" /> represents the table and feature join.
        /// </returns>
        public static IRelQueryTable Add(this IFeatureLayer source, IObjectClass foreignClass, string layerKeyField, string foreignKeyField, esriRelCardinality cardinality, esriJoinType joinType)
        {
            IRelQueryTable     result;
            IRelationshipClass relClass;
            var table = ((IDisplayTable)source).DisplayTable as IRelQueryTable;

            if (table != null)
            {
                result   = source.Add(table, foreignClass, string.Format("{0}.{1}", ((IDataset)source.FeatureClass).Name, layerKeyField), foreignKeyField, cardinality, joinType);
                relClass = result.RelationshipClass;
            }
            else
            {
                var layer = (IFeatureClass)((IDisplayTable)source).DisplayTable;
                relClass = layer.Join(foreignClass, layerKeyField, foreignKeyField, cardinality, null);

                var factory = new RelQueryTableFactoryClass();
                result = factory.Open(relClass, true, null, null, "", true, joinType == esriJoinType.esriLeftInnerJoin);
            }

            IDisplayRelationshipClass display = (IDisplayRelationshipClass)source;

            display.DisplayRelationshipClass(relClass, joinType);

            return(result);
        }
Example #27
0
        public static string GetDefaultRowFormat([NotNull] IObjectClass objectClass,
                                                 bool includeClassAlias = false)
        {
            Assert.ArgumentNotNull(objectClass, nameof(objectClass));

            int subtypeFieldIndex = DatasetUtils.GetSubtypeFieldIndex(objectClass);

            var sb = new StringBuilder();

            if (includeClassAlias)
            {
                sb.AppendFormat("{0} - ", DatasetUtils.GetAliasName(objectClass));
            }

            if (subtypeFieldIndex >= 0)
            {
                string subtypeFieldName =
                    objectClass.Fields.Field[subtypeFieldIndex].Name;
                sb.AppendFormat("{{{0}}} - ", subtypeFieldName);
            }

            string displayField = StringUtils.IsNotEmpty(objectClass.OIDFieldName)
                                                      ? objectClass.OIDFieldName
                                                      : SelectDisplayField(objectClass);

            if (displayField != null)
            {
                sb.AppendFormat("{{{0}}}", displayField);
            }

            return(sb.ToString());
        }
Example #28
0
        public static void HarvestObjectTypes([NotNull] ObjectDataset objectDataset,
                                              [NotNull] IObjectClass objectClass)
        {
            Assert.ArgumentNotNull(objectClass, nameof(objectClass));

            IList <Subtype> subtypes = DatasetUtils.GetSubtypes(objectClass);

            if (subtypes.Count > 0)
            {
                for (var subtypeIndex = 0;
                     subtypeIndex < subtypes.Count;
                     subtypeIndex++)
                {
                    Subtype subtype = subtypes[subtypeIndex];

                    AddOrUpdateObjectType(objectDataset, subtype, subtypeIndex, subtypes);
                }
            }
            else
            {
                var subtype = new Subtype(0, "<default>");

                AddOrUpdateObjectType(objectDataset, subtype, 0, subtypes);

                subtypes.Add(subtype);
            }

            DeleteObjectTypesNotInList(objectDataset, subtypes);
        }
Example #29
0
        public static bool TryGetNameField([NotNull] IObjectClass objectClass,
                                           out string fieldName)
        {
            Assert.ArgumentNotNull(objectClass, nameof(objectClass));

            return(TryGetNameField(DatasetUtils.GetFields(objectClass), out fieldName));
        }
Example #30
0
        /// <summary>
        /// Register the newly created table with the Geodatabase.
        /// </summary>
        /// <param name="pTable"></param>
        /// <param name="oidFieldName"></param>
        private static void RegisterWithGeodatabase(ITable pTable, string oidFieldName)
        {
            if (!(IsArcInfoLicense()))
            {
                return;
            }

            IObjectClass oc = (IObjectClass)pTable;

            if (oidFieldName == "")
            {
                oidFieldName = "OBJECTID";
            }
            // Attempt to acquire an exclusive schema lock for the object class.
            ISchemaLock schemaLock = (ISchemaLock)oc;

            try
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                // If this point is reached, the exclusive lock was acquired. We can cast the object
                // class to IClassSchemaEdit and call RegisterAsObjectClass.
                IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)oc;
                classSchemaEdit.RegisterAsObjectClass(oidFieldName, "");
            }
            catch (COMException comExc)
            {
                // Re-throw the exception.
                throw comExc;
            }
            finally
            {
                // Reset the lock on the object class to a shared lock.
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        } // method RegisterWithGeodatabase
Example #31
0
        private void ProcessObjectClass(WorkspaceInfo wsInfo, IObjectClass objClass)
        {
            IJTXGDBHistoryChanges gdbHistoryChanges = new JTXGDBHistoryChangesClass();
            DateTime now = (DateTime)((IDatabaseConnectionInfo2) wsInfo.workspace).ConnectionCurrentDateTime;
            IJTXChangeSet changeSet = gdbHistoryChanges.GetChanges(m_database, wsInfo.workspaceID, objClass, wsInfo.lastProcessed, now);
            wsInfo.lastProcessed = now;

            if(changeSet.Count > 0)
            {
                m_database.LogMessage(5, 2000, "Changes found");
            }

            IJTXSpatialNotificationManager snMan = m_database.SpatialNotificationManager;
            bool bHasMatches;
            IJTXChangeRuleMatchSet matches = snMan.EvaluateSet(null, changeSet, out bHasMatches);

            if (bHasMatches)
            {
                m_database.LogMessage(5, 2000, "Matches found");
                snMan.Notify(matches);
            }

        }
Example #32
0
 IEnumRelationshipClass IRelationshipClassCollection.FindRelationshipClasses(IObjectClass ObjectClass, esriRelRole role)
 {
     return ((IRelationshipClassCollection)featureLayer).FindRelationshipClasses(ObjectClass, role);
 }
Example #33
0
 public IRelationshipClass CreateRelationshipClass(string relClassName, IObjectClass OriginClass, IObjectClass DestinationClass, string forwardLabel, string backwardLabel, esriRelCardinality Cardinality, esriRelNotification Notification, bool IsComposite, bool IsAttributed, IFields relAttrFields, string OriginPrimaryKey, string destPrimaryKey, string OriginForeignKey, string destForeignKey)
 {
     // I don't think this needs to be implemented for now.
     throw new NotImplementedException();
 }
 public void IClassSchemaEdit_Example(IObjectClass objectClass) 
 {        
   //This function shows how you can use the IClassSchemaEdit   
   //interface to alter the COM class extension for an object class.    
   //cast for the IClassSchemaEdit      
   IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)objectClass;
     //set and exclusive lock on the class     
   ISchemaLock schemaLock = (ISchemaLock)objectClass;  
   schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
     ESRI.ArcGIS.esriSystem.UID classUID = new ESRI.ArcGIS.esriSystem.UIDClass();
   //GUID for the C# project.
     classUID.Value = "{65a43962-8cc0-49c0-bfa3-015d0ff8350e}";
     classSchemaEdit.AlterClassExtensionCLSID(classUID, null);    
   //release the exclusive lock     
   schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);  
 }
		/// <summary>
		/// Supplies the page with the object(s) to be edited.
		/// </summary>
		/// <param name="objects">The object(s) this page applies to.</param>
		void IComPropertyPage.SetObjects(ISet objects)
		{
			if (objects == null || objects.Count != 1)
				return;

			// Store the provided object class in a member variable.
			objects.Reset();
			object providedObject = objects.Next();
			objectClass = providedObject as IObjectClass;
			if (objectClass != null)
			{
				// Get the object class' extension.
				timestampClassExtension = objectClass.Extension as TimestampClassExtension;
			}
		}