/// <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"]; IRelationshipClass relClass = utilities.OpenRelationshipClass(value); if (relClass != null) { IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; configTopLevel.Workspace = utilities.GetWorkspace(value); IGPMultiValue onCreate = (IGPMultiValue)parameters["in_create"]; IGPMultiValue onDelete = (IGPMultiValue)parameters["in_delete"]; var uids = new Dictionary <mmEditEvent, IEnumerable <IUID> >(); uids.Add(mmEditEvent.mmEventRelationshipCreated, onCreate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID)); uids.Add(mmEditEvent.mmEventRelationshipDeleted, onDelete.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID)); // Update the list to have these UIDs. ID8List list = (ID8List)configTopLevel.GetRelationshipClass(relClass); base.Add(uids, list, messages); // Commit the changes to the database. configTopLevel.SaveRelationshipClasstoDB(relClass); // Success. parameters["out_results"].SetAsText("true"); } else { // Failure. parameters["out_results"].SetAsText("false"); } }
/// <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); }
/// <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); } }
/// <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> /// 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"); } }
public void IMMConfigTopLevel_ChangeVisibility_ArgumentNullException_Table() { IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); configTopLevel.ChangeVisibility(null, false, "OBJECTID"); }
public void IMMConfigTopLevel_ChangeVisibility_ArgumentNullException_FieldName() { IFeatureClass testClass = base.GetTestClass(); Assert.IsNotNull(testClass); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); configTopLevel.ChangeVisibility(testClass, false, null); }
public void IMMConfigTopLevel_GetAutoValues_NotNull() { IFeatureClass testClass = base.GetTestClass(); Assert.IsNotNull(testClass); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); var list = configTopLevel.GetAutoValues(testClass, mmEditEvent.mmEventFeatureCreate); Assert.IsTrue(list.Count > 0); }
/// <summary> /// Pre validates the given set of values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> /// <param name="utilities"> /// The utilities object that provides access to the properties and methods of a geoprocessing /// objects. /// </param> protected override void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities) { IGPValue value = utilities.UnpackGPValue(parameters["in_table"]); if (!value.IsEmpty()) { IObjectClass table = utilities.OpenTable(value); if (table != null) { // Populate the subtype parameter with the subtypes from the table and ensure the it's editable. IGPParameterEdit3 subtypeParameter = (IGPParameterEdit3)parameters["in_subtype"]; subtypeParameter.Domain = this.GetSubtypes(table); // Populate the auto updater values for the object class for the specific subtype. IGPValue subtype = utilities.UnpackGPValue(subtypeParameter); if (!subtype.IsEmpty()) { var subtypeCode = subtype.Cast(-1); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; configTopLevel.Workspace = utilities.GetWorkspace(value); var values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureCreate); IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_create"]; parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureUpdate); parameter = (IGPParameterEdit3)parameters["in_update"]; parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureDelete); parameter = (IGPParameterEdit3)parameters["in_delete"]; parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventBeforeFeatureSplit); parameter = (IGPParameterEdit3)parameters["in_before"]; parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureSplit); parameter = (IGPParameterEdit3)parameters["in_split"]; parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventAfterFeatureSplit); parameter = (IGPParameterEdit3)parameters["in_after"]; parameter.Domain = base.CreateDomain <IMMSpecialAUStrategyEx>(values[subtypeCode]); } } } }
/// <summary> /// Get the value of field that has been configured to be the primary display field. /// </summary> /// <param name="source">The source.</param> /// <returns> /// Returns a <see cref="IField" /> representing the field for the primary display. /// </returns> public static IField GetPrimaryDisplayField(this IObjectClass source) { if (source == null) { return(null); } IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; if (configTopLevel == null) { return(null); } return(configTopLevel.GetPrimaryDisplayField(source)); }
public void IMMConfigTopLevel_ChangeVisibility() { IFeatureClass testClass = base.GetTestClass(); Assert.IsNotNull(testClass); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); ISubtypes subtypes = (ISubtypes)testClass; IMMFieldManager fieldManager = testClass.GetFieldManager(subtypes.DefaultSubtypeCode); IMMFieldAdapter fieldAdapter = fieldManager.FieldByName(testClass.OIDFieldName); configTopLevel.ChangeVisibility(testClass, subtypes.DefaultSubtypeCode, false, testClass.OIDFieldName); Assert.IsFalse(fieldAdapter.Visible); }
/// <summary> /// Pre validates the given set of values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> /// <param name="utilities"> /// The utilities object that provides access to the properties and methods of a geoprocessing /// objects. /// </param> protected override void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities) { IGPValue value = utilities.UnpackGPValue(parameters["in_table"]); if (!value.IsEmpty()) { IObjectClass table = utilities.OpenTable(value); if (table != null) { IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_field"]; parameter.Domain = base.GetFields(table); string fieldName = utilities.UnpackGPValue(parameter).GetAsText(); parameter = (IGPParameterEdit3)parameters["in_subtype"]; parameter.Domain = base.GetSubtypes(table); IGPValue subtype = utilities.UnpackGPValue(parameter); if (!subtype.IsEmpty()) { if (!string.IsNullOrEmpty(fieldName)) { var subtypeCode = subtype.Cast(-1); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; configTopLevel.Workspace = utilities.GetWorkspace(value); var values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureCreate, fieldName); parameter = (IGPParameterEdit3)parameters["in_create"]; parameter.Domain = base.CreateDomain <IMMAttrAUStrategy>(values[subtypeCode][fieldName]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureUpdate, fieldName); parameter = (IGPParameterEdit3)parameters["in_update"]; parameter.Domain = base.CreateDomain <IMMAttrAUStrategy>(values[subtypeCode][fieldName]); values = configTopLevel.GetAutoValues(table, mmEditEvent.mmEventFeatureDelete, fieldName); parameter = (IGPParameterEdit3)parameters["in_delete"]; parameter.Domain = base.CreateDomain <IMMAttrAUStrategy>(values[subtypeCode][fieldName]); } } } } }
/// <summary> /// Pre validates the given set of values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> /// <param name="utilities"> /// The utilities object that provides access to the properties and methods of a geoprocessing /// objects. /// </param> protected override void UpdateParameters(Dictionary <string, IGPParameter> parameters, IGPEnvironmentManager environmentManager, IGPUtilities2 utilities) { IGPValue value = utilities.UnpackGPValue(parameters["in_table"]); if (!value.IsEmpty()) { IRelationshipClass relClass = utilities.OpenRelationshipClass(value); if (relClass != null) { IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; configTopLevel.Workspace = utilities.GetWorkspace(value); var values = configTopLevel.GetAutoValues(relClass, mmEditEvent.mmEventRelationshipCreated); IGPParameterEdit3 parameter = (IGPParameterEdit3)parameters["in_create"]; parameter.Domain = base.CreateDomain <IMMRelationshipAUStrategy>(values); values = configTopLevel.GetAutoValues(relClass, mmEditEvent.mmEventRelationshipDeleted); parameter = (IGPParameterEdit3)parameters["in_delete"]; parameter.Domain = base.CreateDomain <IMMRelationshipAUStrategy>(values); } } }
/// <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); }
/// <summary> /// Refresh the cached ArcFM properties (such as the model names and AU properties). /// </summary> /// <param name="source">The application reference.</param> public static void FlushCache(this IApplication source) { if (source == null) { return; } IMMConfigTopLevel ctl = ConfigTopLevel.Instance; ctl.Workspace = null; var au = (IMMAutoUpdater3)AutoUpdaterModeReverter.Instance; au.FlushCache(); var ext = (IExtension)ModelNameManager.Instance; ext.Shutdown(); object application = source; ext.Startup(ref application); }
/// <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); }
/// <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); }