Beispiel #1
0
        /// <summary>
        ///     Changes the field visibility to the specified <paramref name="visible" /> value for the fields
        ///     that match the field name.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="visible">if set to <c>true</c> if the field is visible.</param>
        /// <exception cref="ArgumentNullException">fieldName</exception>
        public static void ChangeVisibility(this IMMSubtype source, string fieldName, bool visible)
        {
            if (source == null)
            {
                return;
            }
            if (fieldName == null)
            {
                throw new ArgumentNullException("fieldName");
            }

            var list = source as ID8List;

            if (list == null)
            {
                return;
            }

            var field = list.AsEnumerable().OfType <IMMField>().FirstOrDefault(o => o.FieldName == fieldName);

            if (field == null)
            {
                return;
            }

            field.ChangeVisibility(visible);
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        /// <summary>
        ///     Changes the field visibility to the specified <paramref name="visible" /> value for the fields
        ///     that match the field name.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="visible">if set to <c>true</c> if the field is visible.</param>
        /// <exception cref="System.NullReferenceException">
        ///     source
        ///     or
        ///     fieldName
        /// </exception>
        public static void ChangeVisibility(this IMMFeatureClass source, string fieldName, bool visible)
        {
            if (source == null)
            {
                throw new NullReferenceException("source");
            }
            if (fieldName == null)
            {
                throw new NullReferenceException("fieldName");
            }

            ID8List list = source as ID8List;

            if (list == null)
            {
                return;
            }

            IMMSubtype all = source.GetSubtype(ConfigTopLevelExtensions.ALL_SUBTYPES);

            if (all != null)
            {
                all.ChangeVisibility(fieldName, visible);
            }

            foreach (var subtype in list.AsEnumerable().OfType <IMMSubtype>())
            {
                subtype.ChangeVisibility(fieldName, visible);
            }
        }
Beispiel #6
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     value = parameters["in_table"];
            IObjectClass table = utilities.OpenTable(value);

            if (table != null)
            {
                IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance;
                configTopLevel.Workspace = utilities.GetWorkspace(value);

                // Load all of the subtypes when the user specified "All" or "-1".
                int subtype      = parameters["in_subtype"].Cast(-1);
                var subtypeCodes = new List <int>(new[] { subtype });
                if (subtype == -1)
                {
                    ISubtypes subtypes = (ISubtypes)table;
                    subtypeCodes.AddRange(subtypes.Subtypes.AsEnumerable().Select(o => o.Key));
                }

                IGPMultiValue onCreate = (IGPMultiValue)parameters["in_create"];
                IGPMultiValue onUpdate = (IGPMultiValue)parameters["in_update"];
                IGPMultiValue onDelete = (IGPMultiValue)parameters["in_delete"];

                // Load the "Attribute" AUs.
                var uids = new Dictionary <mmEditEvent, IEnumerable <IUID> >();
                uids.Add(mmEditEvent.mmEventFeatureCreate, onCreate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventFeatureUpdate, onUpdate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));
                uids.Add(mmEditEvent.mmEventFeatureDelete, onDelete.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID));

                IGPValue field = parameters["in_field"];
                int      index = table.FindField(field.GetAsText());

                // Enumerate through all of the subtypes making changes.
                foreach (var subtypeCode in subtypeCodes)
                {
                    // Load the configurations for the table and subtype.
                    IMMSubtype mmsubtype = configTopLevel.GetSubtypeByID(table, subtypeCode, false);

                    // Load the field configurations.
                    IMMField mmfield = null;
                    mmsubtype.GetField(index, ref mmfield);

                    // Update the list to have these UIDs removed.
                    ID8List list = (ID8List)mmfield;
                    base.Remove(uids, list, messages);
                }

                // Commit the changes to the database.
                configTopLevel.SaveFeatureClassToDB(table);

                // Success.
                parameters["out_results"].SetAsText("true");
            }
            else
            {
                // Failure.
                parameters["out_results"].SetAsText("false");
            }
        }
Beispiel #7
0
        /// <summary>
        ///     Gets all of the automatic values (i.e. ArcFM Auto Updaters) that have been configured for the subtype.
        /// </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>
        public static IEnumerable <IMMAutoValue> GetAutoValues(this IMMSubtype source, mmEditEvent editEvent)
        {
            var list = source 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));
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
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));
        }
Beispiel #11
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);
        }