Example #1
0
        /// <summary>
        ///     Executes the specified special AU for the ESRI Object.
        /// </summary>
        /// <param name="pObject">The esri object.</param>
        /// <param name="mode">The AU mode.</param>
        /// <param name="eEvent">The edit event.</param>
        public virtual void Execute(IObject pObject, mmAutoUpdaterMode mode, mmEditEvent eEvent)
        {
            try
            {
                if (InoperableAutoUpdaters.Instance.Contains(pObject.Class.ObjectClassID, ((IRowSubtypes)pObject).SubtypeCode, this.GetType()))
                {
                    return;
                }

                if (this.CanExecute(mode))
                {
                    this.InternalExecute(pObject, mode, eEvent);
                }
            }
            catch (COMException e)
            {
                // If the MM_E_CANCELEDIT error is thrown, let it out.
                switch (e.ErrorCode)
                {
                case (int)mmErrorCodes.MM_E_CANCELEDIT:
                    throw;

                default:
                    this.LogException(e);
                    break;
                }
            }
            catch (Exception e)
            {
                this.LogException(e);
            }
        }
Example #2
0
        /// <summary>
        ///     Removes the automatic value (i.e ArcFM Auto Updater) to the subtype source for the specified event.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <param name="guid">The unique identifier.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> if the value was removed; otherwise <C>false</C>
        /// </returns>
        /// <exception cref="ArgumentNullException">guid</exception>
        public static bool RemoveAutoValue(this IMMSubtype source, mmEditEvent editEvent, Guid guid)
        {
            if (source == null)
            {
                return(false);
            }
            if (guid == Guid.Empty)
            {
                throw new ArgumentNullException("guid");
            }

            var list = source as ID8List;

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

            IMMAutoValue item = source.GetAutoValue(editEvent, guid);

            if (item != null)
            {
                list.Remove((ID8ListItem)item);
            }

            return(true);
        }
Example #3
0
        /// <summary>
        ///     Executes the specified relationship AU.
        /// </summary>
        /// <param name="pRelationship">The relationship.</param>
        /// <param name="mode">The AU mode.</param>
        /// <param name="eEvent">The edit event.</param>
        public void Execute(IRelationship pRelationship, mmAutoUpdaterMode mode, mmEditEvent eEvent)
        {
            try
            {
                if (InoperableAutoUpdaters.Instance.Contains(pRelationship.RelationshipClass.RelationshipClassID, -1, this.GetType()))
                {
                    return;
                }

                if (this.CanExecute(mode))
                {
                    this.InternalExecute(pRelationship, mode, eEvent);
                }
            }
            catch (COMException e)
            {
                // If the MM_E_CANCELEDIT error is thrown, let it out.
                if (e.ErrorCode == (int)mmErrorCodes.MM_E_CANCELEDIT)
                {
                    throw;
                }

                this.WriteError(e);
            }
            catch (Exception e)
            {
                this.WriteError(e);
            }
        }
Example #4
0
        /// <summary>
        ///     Gets whether the specified AU is enabled.
        /// </summary>
        /// <param name="pRelClass">The relationship class.</param>
        /// <param name="eEvent">The edit event.</param>
        /// <returns><c>true</c> if this AutoUpdater is enabled; otherwise <c>false</c></returns>
        public bool get_Enabled(IRelationshipClass pRelClass, mmEditEvent eEvent)
        {
            try
            {
                if (pRelClass == null)
                {
                    return(false);
                }

                return(this.InternalEnabled(pRelClass, pRelClass.OriginClass, pRelClass.DestinationClass, eEvent));
            }
            catch (Exception e)
            {
                if (MinerRuntimeEnvironment.IsUserInterfaceSupported)
                {
                    Log.Error("Error Enabling Relationship AU " + Name, e);
                }
                else
                {
                    Log.Error(e);
                }
            }

            return(false);
        }
Example #5
0
        /// <summary>
        ///     Implementation of Auto Updater Enabled method for derived classes.
        /// </summary>
        /// <param name="objectClass">The object class.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <returns>
        ///     <c>true</c> if the AutoUpdater should be enabled; otherwise <c>false</c>
        /// </returns>
        /// <remarks>
        ///     This method will be called from IMMSpecialAUStrategy::get_Enabled
        ///     and is wrapped within the exception handling for that method.
        /// </remarks>
        protected override bool InternalEnabled(IObjectClass objectClass, mmEditEvent editEvent)
        {
            if (editEvent != mmEditEvent.mmEventFeatureCreate)
            {
                return(false);
            }

            return(objectClass.IsAssignedFieldModelName(_FieldModelName));
        }
Example #6
0
        /// <summary>
        ///     Gets all of the automatic values (i.e. ArcFM Auto Updaters) that have been configured for the specified field
        /// </summary>
        /// <param name="source">The object representing the specific subtype being analyzed.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{IMMAutoValue}" /> objects that have been assigned to the field.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">table</exception>
        /// <exception cref="System.IndexOutOfRangeException"></exception>
        public static IEnumerable <IMMAutoValue> GetAutoValues(this IMMField source, mmEditEvent editEvent)
        {
            if (source == null)
            {
                return(null);
            }

            var list = source as ID8List;

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

            var values = list.Where(i => i.ItemType == mmd8ItemType.mmitAutoValue, 0).Select(o => o.Value);

            return(values.OfType <IMMAutoValue>().Where(o => o.AutoGenID != null && o.EditEvent == editEvent));
        }
Example #7
0
        /// <summary>
        ///     Gets whether the auto updater is enabled given the object class and edit event.
        /// </summary>
        /// <param name="pObjectClass">The object class.</param>
        /// <param name="eEvent">The edit event.</param>
        /// <returns><c>true</c> if enabled; otherwise <c>false</c>.</returns>
        public virtual bool get_Enabled(IObjectClass pObjectClass, mmEditEvent eEvent)
        {
            try
            {
                return(this.InternalEnabled(pObjectClass, eEvent));
            }
            catch (Exception e)
            {
                if (MinerRuntimeEnvironment.IsUserInterfaceSupported)
                {
                    Log.Error("Error Enabling Special AU " + Name, e);
                }
                else
                {
                    Log.Error(e);
                }
            }

            return(false);
        }
Example #8
0
        /// <summary>
        ///     Adds the automatic value (i.e ArcFM Auto Updater) to the subtype source for the specified event.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <param name="guid">The unique identifier.</param>
        /// <returns>
        ///     Returns a <see cref="IMMAutoValue" /> representing the value that was added; otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">guid</exception>
        public static IMMAutoValue AddAutoValue(this IMMSubtype source, mmEditEvent editEvent, Guid guid)
        {
            if (source == null)
            {
                return(null);
            }
            if (guid == Guid.Empty)
            {
                throw new ArgumentNullException("guid");
            }

            var list = source as ID8List;

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

            var item = source.GetAutoValue(editEvent, guid);

            if (item != null)
            {
                return(item);
            }

            UID uid = new UIDClass();

            uid.Value = guid.ToString("B");

            item = new MMAutoValueClass
            {
                AutoGenID = uid,
                EditEvent = editEvent
            };

            list.Add((ID8ListItem)item);

            return(item);
        }
Example #9
0
        /// <summary>
        ///     Gets the automatic value (i.e. ArcFM Auto Updater) for the specified <paramref name="editEvent" /> and
        ///     <paramref name="guid" />.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <param name="guid">The unique identifier.</param>
        /// <returns>
        ///     Returns a <see cref="IMMAutoValue" /> representing the automatic value; otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">guid</exception>
        public static IMMAutoValue GetAutoValue(this IMMSubtype source, mmEditEvent editEvent, Guid guid)
        {
            if (source == null)
            {
                return(null);
            }
            if (guid == Guid.Empty)
            {
                throw new ArgumentNullException("guid");
            }

            ID8List list = source as ID8List;

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

            var values = list.Where(i => i.ItemType == mmd8ItemType.mmitAutoValue, 0).Select(o => o.Value);

            foreach (IMMAutoValue autoValue in values.OfType <IMMAutoValue>().Where(o => o.AutoGenID != null && o.EditEvent == editEvent))
            {
                if (autoValue.AutoGenID.Value == null)
                {
                    continue;
                }

                string autoGenID = autoValue.AutoGenID.Value.ToString();
                if (string.Equals(autoGenID, guid.ToString("B"), StringComparison.InvariantCultureIgnoreCase))
                {
                    return(autoValue);
                }
            }

            return(null);
        }
Example #10
0
        /// <summary>
        ///     Gets all of the automatic values (i.e. ArcFM Auto Updaters) that have been configured for the specified
        ///     <paramref name="editEvent" /> the <paramref name="relationshipClass" /> relationship class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="relationshipClass">The relationship class.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{IMMAutoValue}" /> representing the automatic values for the specified event and
        ///     object class.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">table</exception>
        public static IEnumerable <IMMAutoValue> GetAutoValues(this IMMConfigTopLevel source, IRelationshipClass relationshipClass, mmEditEvent editEvent)
        {
            if (source == null)
            {
                return(null);
            }
            if (relationshipClass == null)
            {
                throw new ArgumentNullException("relationshipClass");
            }

            IEnumerable <IMMAutoValue> list = new List <IMMAutoValue>();

            IMMRelationshipClass relationship = source.GetRelationshipClass(relationshipClass);

            if (relationship.HasAutoUpdater)
            {
                list = relationship.GetAutoValues(editEvent);
            }

            return(list);
        }
Example #11
0
        /// <summary>
        ///     Gets all of the automatic values (i.e. ArcFM Auto Updaters) that have been configured for the specified
        ///     <paramref name="editEvent" /> for all subtypes
        ///     of the <paramref name="table" /> object class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The table.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <returns>
        ///     Returns a <see cref="Dictionary{Key, Value}" /> representing the automatic values for the specified event and
        ///     object class.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">table</exception>
        public static Dictionary <IMMSubtype, IEnumerable <IMMAutoValue> > GetAutoValues(this IMMConfigTopLevel source, IObjectClass table, mmEditEvent editEvent)
        {
            if (source == null)
            {
                return(null);
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            Dictionary <IMMSubtype, IEnumerable <IMMAutoValue> > list = new Dictionary <IMMSubtype, IEnumerable <IMMAutoValue> >();

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

            if (subtype != null)
            {
                list.Add(subtype, subtype.GetAutoValues(editEvent));
            }

            ISubtypes subtypes = (ISubtypes)table;

            if (subtypes.HasSubtype)
            {
                IEnumerable <int> subtypeCodes = subtypes.Subtypes.AsEnumerable().Select(o => o.Key).OrderBy(o => o);
                foreach (var subtypeCode in subtypeCodes)
                {
                    subtype = source.GetSubtypeByID(table, subtypeCode, false);
                    if (subtype == null)
                    {
                        continue;
                    }

                    list.Add(subtype, subtype.GetAutoValues(editEvent));
                }
            }

            return(list);
        }
Example #12
0
        /// <summary>
        ///     Gets all of the field ArcFM Auto Updaters that have been configured for the specified
        ///     <paramref name="editEvent" /> on the <paramref name="table" /> object class for specified fields.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The object class.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <param name="fieldNames">The field names.</param>
        /// <returns>
        ///     Returns a <see cref="Dictionary{Key, Value}" /> representing the automatic values for the subtypes and the
        ///     individual fields.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     fieldNames
        ///     or
        ///     table
        /// </exception>
        public static Dictionary <int, Dictionary <string, IEnumerable <IMMAutoValue> > > GetAutoValues(this IMMConfigTopLevel source, IObjectClass table, mmEditEvent editEvent, params string[] fieldNames)
        {
            if (source == null)
            {
                return(null);
            }
            if (fieldNames == null)
            {
                throw new ArgumentNullException("fieldNames");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            Dictionary <int, Dictionary <string, IEnumerable <IMMAutoValue> > > list = new Dictionary <int, Dictionary <string, IEnumerable <IMMAutoValue> > >();

            var values = source.GetAutoValues(table, ALL_SUBTYPES, editEvent, fieldNames);

            list.Add(ALL_SUBTYPES, values);

            ISubtypes subtypes = (ISubtypes)table;

            if (subtypes.HasSubtype)
            {
                IEnumerable <int> subtypeCodes = subtypes.Subtypes.AsEnumerable().Select(o => o.Key).OrderBy(o => o);
                foreach (var subtypeCode in subtypeCodes)
                {
                    values = source.GetAutoValues(table, subtypeCode, editEvent, fieldNames);
                    list.Add(subtypeCode, values);
                }
            }

            return(list);
        }
Example #13
0
        /// <summary>
        /// Gets all of the field ArcFM Auto Updaters that have been configured for the specified
        /// <paramref name="editEvent" /> on the <paramref name="table" /> object class for specified fields.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The object class.</param>
        /// <param name="subtypeCode">The subtype code.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <param name="fieldNames">The field names.</param>
        /// <returns>
        /// Returns a <see cref="Dictionary{Key, Value}" /> representing the automatic values for the subtypes and the
        /// individual fields.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// fieldNames
        /// or
        /// table
        /// </exception>
        /// <exception cref="ArgumentNullException">fieldNames
        /// or
        /// table</exception>
        public static Dictionary <string, IEnumerable <IMMAutoValue> > GetAutoValues(this IMMConfigTopLevel source, IObjectClass table, int subtypeCode, mmEditEvent editEvent, params string[] fieldNames)
        {
            if (source == null)
            {
                return(null);
            }
            if (fieldNames == null)
            {
                throw new ArgumentNullException("fieldNames");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            Dictionary <string, IEnumerable <IMMAutoValue> > list = new Dictionary <string, IEnumerable <IMMAutoValue> >();

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

            if (subtype != null)
            {
                foreach (var fieldName in fieldNames)
                {
                    int index  = table.FindField(fieldName);
                    var values = subtype.GetAutoValues(index, editEvent);
                    list.Add(fieldName, values);
                }
            }

            return(list);
        }
Example #14
0
 /// <summary>
 ///     Implementation of enabled method for derived classes.
 /// </summary>
 /// <param name="objectClass">The object class.</param>
 /// <param name="editEvent">The edit event.</param>
 /// <returns>
 ///     <c>true</c> if the AutoUpdater should be enabled; otherwise <c>false</c>
 /// </returns>
 /// <remarks>
 ///     This method will be called from IMMSpecialAUStrategy::get_Enabled
 ///     and is wrapped within the exception handling for that method.
 /// </remarks>
 protected abstract bool InternalEnabled(IObjectClass objectClass, mmEditEvent editEvent);
Example #15
0
 /// <summary>
 ///     Implementation of Auto Updater Execute Ex method for derived classes.
 /// </summary>
 /// <param name="obj">The object that triggered the Auto Updater.</param>
 /// <param name="mode">The auto updater mode.</param>
 /// <param name="editEvent">The edit event.</param>
 /// <remarks>
 ///     This method will be called from IMMSpecialAUStrategy::ExecuteEx
 ///     and is wrapped within the exception handling for that method.
 /// </remarks>
 protected abstract void InternalExecute(IObject obj, mmAutoUpdaterMode mode, mmEditEvent editEvent);
Example #16
0
 /// <summary>
 ///     Implementation of enabled method for derived classes.
 /// </summary>
 /// <param name="relClass">The relationship class.</param>
 /// <param name="originClass">The origin class.</param>
 /// <param name="destClass">The destination class.</param>
 /// <param name="editEvent">The edit event.</param>
 /// <returns><c>true</c> if this AutoUpdater is enabled; otherwise <c>false</c></returns>
 /// <remarks>
 ///     This method will be called from IMMRelationshipAUStrategyEx::get_Enabled
 ///     and is wrapped within the exception handling for that method.
 /// </remarks>
 protected abstract bool InternalEnabled(IRelationshipClass relClass, IObjectClass originClass, IObjectClass destClass, mmEditEvent editEvent);
 /// <summary>
 ///     Implementation of execute method for derived classes.
 /// </summary>
 /// <param name="relationship">The relationship.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="editEvent">The edit event.</param>
 /// <remarks>
 ///     This method will be called from IMMRelationshipAUStrategy::Execute
 ///     and is wrapped within the exception handling for that method.
 /// </remarks>
 protected override void InternalExecute(IRelationship relationship, mmAutoUpdaterMode mode, mmEditEvent editEvent)
 {
     foreach (IMMRelationshipAUStrategy item in this.Items)
     {
         item.Execute(relationship, mode, editEvent);
     }
 }
Example #18
0
 /// <summary>
 ///     Implementation of execute method for derived classes.
 /// </summary>
 /// <param name="relationship">The relationship.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="editEvent">The edit event.</param>
 /// <remarks>
 ///     This method will be called from IMMRelationshipAUStrategy::Execute
 ///     and is wrapped within the exception handling for that method.
 /// </remarks>
 protected abstract void InternalExecute(IRelationship relationship, mmAutoUpdaterMode mode, mmEditEvent editEvent);
Example #19
0
        /// <summary>
        ///     Implementation of Auto Updater Execute Ex method for derived classes.
        /// </summary>
        /// <param name="obj">The object that triggered the Auto Udpater.</param>
        /// <param name="eAUMode">The auto updater mode.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <exception cref="NotSupportedException">
        ///     The sequence generator is only supported on an ORACLE workspace (remote
        ///     geodatabase).
        /// </exception>
        /// <exception cref="ArgumentNullException">obj;@The field model name is not assigned on the object.</exception>
        /// <remarks>
        ///     This method will be called from IMMSpecialAUStrategy::ExecuteEx
        ///     and is wrapped within the exception handling for that method.
        /// </remarks>
        protected override void InternalExecute(IObject obj, mmAutoUpdaterMode eAUMode, mmEditEvent editEvent)
        {
            if (obj == null)
            {
                return;
            }

            IDataset   dataset   = (IDataset)obj.Class;
            IWorkspace workspace = dataset.Workspace;

            if (workspace.IsDBMS(DBMS.Oracle))
            {
                throw new NotSupportedException("The sequence generator is only supported on an ORACLE workspace (remote geodatabase).");
            }

            string fieldName = obj.Class.GetFieldName(_FieldModelName);

            if (string.IsNullOrEmpty(fieldName))
            {
                throw new ArgumentNullException("obj", @"The field model name is not assigned on the object.");
            }

            // Create a queryDef from the feature workspace
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
            IQueryDef         queryDef         = featureWorkspace.CreateQueryDef();

            // Set the query def to point to the sequence
            queryDef.SubFields = _SequenceName + ".NEXTVAL";
            queryDef.Tables    = "SYS.DUAL";

            // Define a cursor and row, for destroy in finally
            using (ComReleaser cr = new ComReleaser())
            {
                // Fill the cursor via the query def
                ICursor cursor = queryDef.Evaluate();
                cr.ManageLifetime(cursor);

                // Now get the row from the cursor
                IRow row = cursor.NextRow();
                if (row == null)
                {
                    return;
                }

                // Store the formatted value if it's configured.
                int    val            = TypeCast.Cast(row.get_Value(0), -1);
                string formattedValue = this.Format(val, obj);

                int pos = obj.Class.FindField(fieldName);
                obj.set_Value(pos, formattedValue);
            }
        }
Example #20
0
        /// <summary>
        ///     Gets all of the automatic values (i.e. ArcFM Auto Updaters) that have been configured for the specified
        ///     <paramref name="index" />
        /// </summary>
        /// <param name="source">The object representing the specific subtype being analyzed.</param>
        /// <param name="index">The index of the field.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{IMMAutoValue}" /> objects that have been assigned to the field.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">table</exception>
        /// <exception cref="System.IndexOutOfRangeException"></exception>
        public static IEnumerable <IMMAutoValue> GetAutoValues(this IMMSubtype source, int index, mmEditEvent editEvent)
        {
            if (source == null)
            {
                return(null);
            }

            IMMField field = null;

            source.GetField(index, ref field);

            var list = field as ID8List;

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

            var values = list.Where(i => i.ItemType == mmd8ItemType.mmitAutoValue).Select(o => o.Value);

            return(values.OfType <IMMAutoValue>().Where(o => o.EditEvent == editEvent));
        }
        /// <summary>
        ///     Implementation of enabled method for derived classes.
        /// </summary>
        /// <param name="relClass">The relelationship class.</param>
        /// <param name="originClass">The origin class.</param>
        /// <param name="destClass">The destination class.</param>
        /// <param name="editEvent">The edit event.</param>
        /// <returns>
        ///     <c>true</c> if this AutoUpdater is enabled; otherwise <c>false</c>
        /// </returns>
        /// <remarks>
        ///     This method will be called from IMMRelationshipAUStrategyEx::get_Enabled
        ///     and is wrapped within the exception handling for that method.
        /// </remarks>
        protected override bool InternalEnabled(IRelationshipClass relClass, IObjectClass originClass, IObjectClass destClass, mmEditEvent editEvent)
        {
            foreach (IMMRelationshipAUStrategy item in this.Items)
            {
                if (!item.get_Enabled(relClass, editEvent))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #22
0
 /// <summary>
 ///     Caches the edit event and increments the busy counter for the monitor.
 /// </summary>
 /// <param name="editEvent">The edit event.</param>
 /// <param name="flag">if set to <c>true</c> if the overriden event effects the termination process.</param>
 public void Set(mmEditEvent editEvent, bool flag = false)
 {
     _Overrides.Push(editEvent);
     _Continues.Push(flag);
 }