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