예제 #1
0
        /// <summary>
        ///     Removes the automatic value (i.e ArcFM Auto Updater) to the field 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 IMMField 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);
        }
예제 #2
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");
            }
        }
예제 #3
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));
        }
예제 #4
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="visible">if set to <c>true</c> if the field is visible.</param>
        /// <exception cref="System.ArgumentNullException">fieldName</exception>
        /// <exception cref="ArgumentNullException">fieldName</exception>
        public static void ChangeVisibility(this IMMField source, bool visible)
        {
            if (source == null)
            {
                return;
            }

            var list = source as ID8List;

            if (list == null)
            {
                return;
            }

            // There are multiple settings per field, thus only change the visibility setting.
            foreach (IMMSimpleSetting simple in list.AsEnumerable().OfType <IMMSimpleSetting>().Where(o => o.SettingType == mmFieldSettingType.mmFSVisible))
            {
                simple.SettingValue = visible;
            }

            // Update the custom settings (i.e. ArcInfo, etc).
            foreach (ID8ListItem custom in list.AsEnumerable().Where(o => o.ItemType == mmd8ItemType.mmitCustomSetting))
            {
                IMMSimpleSetting simple = custom as IMMSimpleSetting;
                if (simple != null && simple.SettingType == mmFieldSettingType.mmFSVisible)
                {
                    var index = simple.DisplayOrder;

                    // Remove custom setting
                    var containedBy = custom.ContainedBy;
                    list.Remove(custom);

                    MMSimpleSetting setting = new MMSimpleSettingClass();
                    setting.ContainedBy = containedBy;

                    ((IMMSimpleSetting)setting).SettingType  = mmFieldSettingType.mmFSVisible;
                    ((IMMSimpleSetting)setting).SettingValue = visible;

                    // Replace with simple setting
                    list.AddSorted(setting, index);
                }
            }
        }
예제 #5
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));
        }
예제 #6
0
        /// <summary>
        ///     Adds the automatic value (i.e ArcFM Auto Updater) to the field 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 IMMField 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);
        }
예제 #7
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 IMMField 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 (var value in values.OfType <IMMAutoValue>().Where(o => o.AutoGenID != null && o.EditEvent == editEvent))
            {
                if (value.AutoGenID.Value == null)
                {
                    continue;
                }

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

            return(null);
        }