/// <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); } }
/// <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); }
/// <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"); } }
/// <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); }