/// <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) { IGPMultiValue tables = (IGPMultiValue)parameters["in_tables"]; IGPMultiValue modelNames = (IGPMultiValue)parameters["in_class_model_names"]; int addedCount = 0; if (tables.Count > 0 && modelNames.Count > 0) { foreach (var table in tables.AsEnumerable()) { IObjectClass dataElement = utilities.OpenTable(table); foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText())) { messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Adding the {0} class model name to the {1} table.", modelName, dataElement.AliasName); ModelNameManager.Instance.AddClassModelName(dataElement, modelName); addedCount++; } } } if (addedCount == tables.Count) { // 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 field = parameters["in_field"]; IObjectClass table = utilities.OpenTable(parameters["in_table"]); IGPMultiValue modelNames = (IGPMultiValue)parameters["in_field_model_names"]; if (!field.IsEmpty() && modelNames.Count > 0) { var fieldName = field.GetAsText(); int index = table.FindField(fieldName); foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText())) { messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Removing the {0} field model name from the {1} field.", modelName, fieldName); ModelNameManager.Instance.RemoveFieldModelName(table, table.Fields.Field[index], modelName); } // Success. parameters["out_results"].SetAsText("true"); } else { // Failure. parameters["out_results"].SetAsText("false"); } }
/// <summary> /// Adds a new message to the <paramref name="source" /> of messages. /// </summary> /// <param name="source">The source.</param> /// <param name="messageType">Type of the message.</param> /// <param name="format">A composite format string.</param> /// <param name="args"> An System.Object array containing zero or more objects to format.</param> public static void Add(this IGPMessages source, esriGPMessageType messageType, string format, params object[] args) { source.Add(new GPMessageClass() { Description = string.Format(format, args), Type = messageType }); }
/// <summary>Sets a UI message for the current process</summary> private void StartTaskMessage(string message) { if (_trackCancel.Progressor != null) { _trackCancel.Progressor.Message = message; } IGPMessage msg = new GPMessageClass(); msg.Description = string.Empty; msg.Type = esriGPMessageType.esriGPMessageTypeProcessDefinition; _messages.Add(msg); IGPMessage msgStart = new GPMessageClass(); msgStart.Description = message; msgStart.Type = esriGPMessageType.esriGPMessageTypeProcessStart; _messages.Add(msgStart); _taskMessages.Add(message); }
/// <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) { IObjectClass table = utilities.OpenTable(parameters["in_table"]); IGPMultiValue modelNames = (IGPMultiValue)parameters["in_class_model_names"]; if (modelNames.Count > 0) { foreach (var modelName in modelNames.AsEnumerable().Select(o => o.GetAsText())) { messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Removing the {0} class model name.", modelName); ModelNameManager.Instance.RemoveClassModelName(table, modelName); } // Success. parameters["out_results"].SetAsText("true"); } else { // Failure. parameters["out_results"].SetAsText("false"); } }
/// <summary> /// Removes the <paramref name="uids" /> from the <paramref name="list" /> that match the event and UID. /// </summary> /// <param name="uids">The dictionary of events and UIDs.</param> /// <param name="list">The list of events and UIDs.</param> /// <param name="messages">The messages.</param> protected void Remove(Dictionary <mmEditEvent, IEnumerable <IUID> > uids, ID8List list, IGPMessages messages) { // Enumerate through the dictionary of events and UIDs. foreach (var uid in uids) { // Locate all of the "AutoValue" types. foreach (var item in list.AsEnumerable()) { if (item.ItemType == mmd8ItemType.mmitAutoValue) { IMMAutoValue autoValue = (IMMAutoValue)item; if (autoValue.AutoGenID != null && autoValue.EditEvent == uid.Key) { // When the UID is contained within the list it should be removed. if (uid.Value.Contains(autoValue.AutoGenID)) { list.Remove(item); messages.Add(esriGPMessageType.esriGPMessageTypeInformative, "Removing the {0} from the {1} event.", autoValue.AutoGenID.Value, autoValue.EditEvent); } } } } } }