/// <summary>
        /// Validates the modified rows values. Not Null and datatype
        /// </summary>
        /// <param name="modifiedRows"></param>
        /// <returns></returns>
        private bool ValidateModifiedRows(DataTable modifiedRows)
        {
            // Error datatable
            DataTable errorReport = new DataTable();
            // Column for the OID
            string instanceColumnsName = CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentAlias;

            errorReport.Columns.Add(instanceColumnsName);
            // Column for the error message
            string lReportMessage = CultureManager.TranslateString(LanguageConstantKeys.L_MULTIEXE_EXECUTION, LanguageConstantValues.L_MULTIEXE_EXECUTION);

            errorReport.Columns.Add(lReportMessage);

            // Not null and Datatype validation
            foreach (DataRow rowValues in modifiedRows.Rows)
            {
                Oid instanceOID = Adaptor.ServerConnection.GetOid(modifiedRows, rowValues);
                foreach (DisplaySetServiceArgumentInfo argumentInfo in CurrentDisplaySet.ServiceInfo.ArgumentDisplaySetPairs.Values)
                {
                    object value = rowValues[argumentInfo.DSElementName];

                    // Null validation
                    if (value.GetType() == typeof(System.DBNull))
                    {
                        if (!argumentInfo.AllowsNull)
                        {
                            // Add a nuw row in the error datatable
                            DataRow  newReportRow   = errorReport.NewRow();
                            string   nameInScenario = argumentInfo.Alias;
                            object[] lArgs          = new object[1];
                            lArgs[0] = nameInScenario;
                            string lErrorMessage = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_VALIDATION_NECESARY, LanguageConstantValues.L_VALIDATION_NECESARY, lArgs);
                            newReportRow[lReportMessage]      = lErrorMessage;
                            newReportRow[instanceColumnsName] = UtilFunctions.OidFieldsToString(instanceOID, ' ');
                            errorReport.Rows.Add(newReportRow);
                        }
                    }
                    else
                    {
                        // Data type validation
                        if (!DefaultFormats.CheckDataType(value.ToString(), argumentInfo.DataType, false))
                        {
                            // Add a nuw row in the error datatable
                            DataRow  newReportRow = errorReport.NewRow();
                            string   lMask        = DefaultFormats.GetHelpMask(argumentInfo.DataType, string.Empty);
                            object[] lArgs        = new object[1];
                            lArgs[0] = lMask;
                            string lErrorMessage = argumentInfo.Alias + ":  ";
                            lErrorMessage += CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_VALIDATION_INVALID_FORMAT_MASK, LanguageConstantValues.L_VALIDATION_INVALID_FORMAT_MASK, lArgs);
                            newReportRow[lReportMessage]      = lErrorMessage;
                            newReportRow[instanceColumnsName] = UtilFunctions.OidFieldsToString(instanceOID, ' ');
                            errorReport.Rows.Add(newReportRow);
                        }
                    }
                }
            }

            // If errors have been found, show them
            if (errorReport.Rows.Count > 0)
            {
                // Show error message to the user
                ScenarioManager.LaunchMultiExecutionReportScenario(errorReport, CurrentDisplaySet.ServiceInfo.ServiceAlias, null, null);
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Process the Display Service execute event
        /// </summary>
        protected virtual void ProcessExecuteServiceTriggered(object sender, TriggerEventArgs e)
        {
            // Before executing the DisplaySet Service it is needed to check for pending changes in associated Service IU.
            IUQueryController queryController = Parent as IUQueryController;

            if (queryController != null && !queryController.CheckPendingChanges(false, true))
            {
                return;
            }
            if (CurrentDisplaySet.ServiceInfo == null)
            {
                return;
            }

            // Gets modified rows from the viewer
            DataTable modifiedRows = Viewer.GetModifiedRows();

            if (modifiedRows == null)
            {
                return;
            }

            // Validate the modified data
            if (!ValidateModifiedRows(modifiedRows))
            {
                return;
            }

            // Error datatable
            DataTable errorReport = new DataTable();
            // Column for the OID
            string instanceColumnsName = CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentAlias;

            errorReport.Columns.Add(instanceColumnsName);
            // Column for the error message
            string lReportMessage = CultureManager.TranslateString(LanguageConstantKeys.L_MULTIEXE_EXECUTION, LanguageConstantValues.L_MULTIEXE_EXECUTION);

            errorReport.Columns.Add(lReportMessage);

            IUServiceContext lServiceContext = null;

            // For every modified row do...
            foreach (DataRow rowValues in modifiedRows.Rows)
            {
                // Create new IUServiceContext.
                lServiceContext = new IUServiceContext(null, CurrentDisplaySet.ServiceInfo.ClassServiceName, CurrentDisplaySet.ServiceInfo.ServiceName, null);
                // Add argunment this to the service context.
                List <Oid> instanceOIDs = new List <Oid>();
                Oid        instanceOID  = Adaptor.ServerConnection.GetOid(modifiedRows, rowValues);
                instanceOIDs.Add(instanceOID);
                lServiceContext.InputFields.Add(CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentName, new IUContextArgumentInfo(CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentName, instanceOIDs, true, null));

                // Fill the collections for the other inbound arguments.
                foreach (DisplaySetServiceArgumentInfo argumentInfo in CurrentDisplaySet.ServiceInfo.ArgumentDisplaySetPairs.Values)
                {
                    object value = rowValues[argumentInfo.DSElementName];
                    if (value.GetType() == typeof(System.DBNull))
                    {
                        value = null;
                    }
                    //Add input arguments with context.
                    lServiceContext.InputFields.Add(argumentInfo.Name, new IUContextArgumentInfo(argumentInfo.Name, value, true, null));
                }
                try
                {
                    // Execute service.
                    Logic.ExecuteService(lServiceContext);
                }
                catch (Exception exc)
                {
                    string lAlternateKeyName = CurrentDisplaySet.ServiceInfo.SelectedInstanceArgumentAlternateKeyName;
                    if (lAlternateKeyName != string.Empty)
                    {
                        instanceOID = Logic.GetAlternateKeyFromOid(instanceOID, lAlternateKeyName);
                    }

                    // Add a new row in the error datatable.
                    DataRow newReportRow = errorReport.NewRow();
                    newReportRow[lReportMessage]      = exc.Message;
                    newReportRow[instanceColumnsName] = UtilFunctions.OidFieldsToString(instanceOID, ' ');
                    errorReport.Rows.Add(newReportRow);
                }
            }

            // If errors have been found, show them
            if (errorReport.Rows.Count > 0)
            {
                // Show error message to the user
                ScenarioManager.LaunchMultiExecutionReportScenario(errorReport, CurrentDisplaySet.ServiceInfo.ServiceAlias, null, null);
            }

            // Remove the Pending changes mark
            PendingChanges = false;

            // Refresh the data
            OnExecuteCommand(new ExecuteCommandRefreshEventArgs(null));
        }