/// <summary> /// Raises the BeforeActionItemExecution event. /// </summary> /// <param name="eventArgs"></param> protected void OnBeforeActionItemExecution(CheckForPendingChangesEventArgs eventArgs) { EventHandler <CheckForPendingChangesEventArgs> handler = BeforeActionItemExecution; if (handler != null) { handler(this, eventArgs); } }
/// <summary> /// Executes the Action Item. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">TriggerEventArgs</param> public void Execute(object sender, TriggerEventArgs e) { try { // Validate if there are pending changes in the interaction unit // which contains the action item. CheckForPendingChangesEventArgs eventArg = new CheckForPendingChangesEventArgs(); OnBeforeExecute(eventArg); if (eventArg.Cancel) { return; } ContextRequiredEventArgs contextEventArgs = new ContextRequiredEventArgs(); OnContextRequired(contextEventArgs); SelectedInstancesRequiredEventArgs lSelectedInstancesEventArgs = new SelectedInstancesRequiredEventArgs(); OnSelectedInstancesRequired(lSelectedInstancesEventArgs); ExchangeInfoAction lExchangeInfoAction = null; if (this.IsNavigationalFilter) { lExchangeInfoAction = new ExchangeInfoAction(ClassIUName, IUName, NavigationalFilteringIdentity, lSelectedInstancesEventArgs.SelectedInstances, contextEventArgs.Context); } else { lExchangeInfoAction = new ExchangeInfoAction(ClassIUName, IUName, lSelectedInstancesEventArgs.SelectedInstances, contextEventArgs.Context); } // Set default order criteria lExchangeInfoAction.DefaultOrderCriteria = DefaultOrderCriteria; // Raise the event Launching Scenario. LaunchingScenarioEventArgs lLaunchScenarioArgs = new LaunchingScenarioEventArgs(lExchangeInfoAction); OnLaunchingScenario(lLaunchScenarioArgs); // Launch scenario. ScenarioManager.LaunchActionScenario(lExchangeInfoAction, this); } catch (Exception err) { ScenarioManager.LaunchErrorScenario(err); } }
/// <summary> /// Raises the BeforeExecute event. /// </summary> /// <param name="eventArgs"></param> protected void OnBeforeExecute(CheckForPendingChangesEventArgs eventArgs) { EventHandler<CheckForPendingChangesEventArgs> handler = BeforeExecute; if (handler != null) { handler(this, eventArgs); } }
/// <summary> /// Executes the Action Item. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">TriggerEventArgs</param> public void Execute(object sender, TriggerEventArgs e) { try { // Validate if there are pending changes in the interaction unit // which contains the action item. CheckForPendingChangesEventArgs eventArg = new CheckForPendingChangesEventArgs(); OnBeforeExecute(eventArg); if (eventArg.Cancel) { return; } ContextRequiredEventArgs contextEventArgs = new ContextRequiredEventArgs(); OnContextRequired(contextEventArgs); SelectedInstancesRequiredEventArgs lSelectedInstancesEventArgs = new SelectedInstancesRequiredEventArgs(); OnSelectedInstancesRequired(lSelectedInstancesEventArgs); ExchangeInfoAction lExchangeInfoAction = null; if (this.IsNavigationalFilter) { lExchangeInfoAction = new ExchangeInfoAction(ClassIUName, IUName, NavigationalFilteringIdentity, lSelectedInstancesEventArgs.SelectedInstances, contextEventArgs.Context); } else { lExchangeInfoAction = new ExchangeInfoAction(ClassIUName, IUName, lSelectedInstancesEventArgs.SelectedInstances, contextEventArgs.Context); } // Set default order criteria lExchangeInfoAction.DefaultOrderCriteria = DefaultOrderCriteria; // Raise the event Launching Scenario. LaunchingScenarioEventArgs lLaunchScenarioArgs = new LaunchingScenarioEventArgs(lExchangeInfoAction); OnLaunchingScenario(lLaunchScenarioArgs); // Launch scenario. ScenarioManager.LaunchActionScenario(lExchangeInfoAction, this); } catch (Exception err) { ScenarioManager.LaunchErrorScenario(err); } }
/// <summary> /// Executes the service, including multiexecution. /// </summary> /// <param name="isInboundArgumentsValidationRequired">Indicates when is required to validate the inbound arguments.</param> /// <returns>True if the service has been executed successfully or False in the other cases.</returns> private bool ExecuteService(bool isInboundArgumentsValidationRequired) { if (isInboundArgumentsValidationRequired) { // Not Null inbound argument checking. if (!CheckNullAndFormatArgumentValues()) { return false; } } UpdateContext(); // When it is an associated service, validate if there are pending changes in the // interaction unit which contains the service. CheckForPendingChangesEventArgs eventArg = new CheckForPendingChangesEventArgs(); OnBeforeExecute(eventArg); if (eventArg.Cancel) { return false; } Context.ExecutedService = true; int lNumOidsTotal = 0; DataTable report = new DataTable(); List<IUContextArgumentInfo> lMultiSelectionList = new List<IUContextArgumentInfo>(); Dictionary<string, IUContextArgumentInfo> lNoMultiSelectionList = new Dictionary<string, IUContextArgumentInfo>(StringComparer.CurrentCultureIgnoreCase); Dictionary<string, KeyValuePair<string, string>> lInboundArgumentsAlias = new Dictionary<string, KeyValuePair<string, string>>(); Dictionary<string, KeyValuePair<string, string>> lOutboundArgumentsAlias = new Dictionary<string, KeyValuePair<string, string>>(); // Separate in two list the Multi Selection and non Multi Selection foreach (ArgumentController lArgument in InputFields) { ArgumentOVController lInboundArgumentOV = lArgument as ArgumentOVController; if (lInboundArgumentOV != null) { // For multiexecution, in order to store the Alias of the inbound arguments. lInboundArgumentsAlias.Add(lInboundArgumentOV.Name, new KeyValuePair<string, string>(lInboundArgumentOV.IdXML, lInboundArgumentOV.Alias)); } List<Oid> listOidsArgumentValue = lArgument.Value as List<Oid>; if (listOidsArgumentValue != null && listOidsArgumentValue.Count > 1) { if (lNumOidsTotal == 0) { lNumOidsTotal = listOidsArgumentValue.Count; } else { lNumOidsTotal = lNumOidsTotal * listOidsArgumentValue.Count; } if (lInboundArgumentOV != null && lInboundArgumentOV.AlternateKeyName != string.Empty) { foreach (Oid lOid in listOidsArgumentValue) { // Indicate that each Oid of the list is going to use the Alternative Key of the inbound argument. lOid.AlternateKeyName = lInboundArgumentOV.AlternateKeyName; } } lMultiSelectionList.Add(new IUContextArgumentInfo(lArgument.Name, listOidsArgumentValue, false, null)); } else { lNoMultiSelectionList[lArgument.Name] = new IUContextArgumentInfo(lArgument.Name, lArgument.Value, false, null); } } // No Multiexecution has to be processed. Execute the service only one time. if (lNumOidsTotal == 0) { Exception logicException = ExecuteServiceChekingSCDRetry(); // Show error scenario, only if no State Change Detection error. if (logicException != null) { ResponseException lResponseException = logicException as ResponseException; if (lResponseException == null || !lResponseException.Number.Equals(48)) { ScenarioManager.LaunchErrorScenario(logicException); } return false; } // Every time a service is executed successfully, reset Agent connected ExtraInfo. Logic.Agent.ExtraInfo = null; this.Context.ClearOVExtraInfo(); // Clear ExtraInfo of Oids selected previously. return true; } // Multiple instances selected. // Store the Alias and the IdXML of the outbound arguments for multilanguage feature. foreach (ArgumentController lOutboundArgument in OutputFields) { lOutboundArgumentsAlias.Add(lOutboundArgument.Name, new KeyValuePair<string, string>(lOutboundArgument.IdXML, lOutboundArgument.Alias)); } // Show the Cancel Window ShowCancelWindow(); // Number of times that the service has been executed. int lNumProcessed = 0; // Flags for the Cancel or Ignore Errors. Only for multiselection bool lCancel = false; bool lIgnoreError = false; bool someErrors = ExecuteServiceForMultiSelection(lMultiSelectionList, lNoMultiSelectionList, ref lNumOidsTotal, ref lNumProcessed, ref lCancel, ref lIgnoreError, ref report, lInboundArgumentsAlias); HideCancelWindow(); if (someErrors) { // Show error message to the user ScenarioManager.LaunchMultiExecutionReportScenario(report, Alias, lInboundArgumentsAlias, lOutboundArgumentsAlias); Context.ExecutedService = false; return false; } // Check if the report must be shown to the final user if (OutputFields.Count > 0) { ScenarioManager.LaunchMultiExecutionReportScenario(report, Alias, lInboundArgumentsAlias, lOutboundArgumentsAlias); } // Every time a service is executed successfully, reset Agent connected ExtraInfo. Logic.Agent.ExtraInfo = null; // Clear ExtraInfo of Oids selected previously. this.Context.ClearOVExtraInfo(); return true; }
/// <summary> /// Handles the Action Item BeforeActionItemExecution Event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleActionItemBeforeActionItemExecution(object sender, CheckForPendingChangesEventArgs e) { // Propagate the Event OnBeforeActionItemExecution(e); }
/// <summary> /// Handles the CheckForPendingChanges event in the Master. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleMasterCheckForPendingChanges(object sender, CheckForPendingChangesEventArgs e) { e.Cancel = !CheckPendingChanges(false, false); }
/// <summary> /// Handles the Action Item BeforeActionItemExecution Event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleActionItemBeforeActionItemExecution(object sender, CheckForPendingChangesEventArgs e) { // Propagate the Event OnBeforeActionItemExecution(e); }
/// <summary> /// Handles the CheckForPendingChanges event in the Master. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleMasterCheckForPendingChanges(object sender, CheckForPendingChangesEventArgs e) { e.Cancel = !CheckPendingChanges(false, false); }
/// <summary> /// Raises the CheckForPendingChangesEventArgs event /// </summary> /// <param name="eventArgs"></param> protected void OnCheckForPendingChangesEventArgs(CheckForPendingChangesEventArgs eventArgs) { EventHandler<CheckForPendingChangesEventArgs> handler = CheckForPendingChanges; if (handler != null) { handler(this, eventArgs); } }
/// <summary> /// Check if there is any change pending in the Display Set viewer or in the Associated Service IU. /// </summary> /// <param name="searchChangesInThisDS">Indicates if the current DisplaySet has to be checked for pending changes.</param> /// <param name="searchChangesInAssociatedSIU">Indicates if the Associated Service IU has to be checked for pending changes.</param> /// <returns>Returns False if the user wants to cancel the action.</returns> public bool CheckPendingChanges(bool searchChangesInThisDS, bool searchChangesInAssociatedSIU) { CheckForPendingChangesEventArgs eventArgs = new CheckForPendingChangesEventArgs(); OnCheckForPendingChangesEventArgs(eventArgs); if (eventArgs.Cancel) { return false; } bool result = true; if (!searchChangesInThisDS && !searchChangesInAssociatedSIU) { return true; } // Check in associated SIU. if (searchChangesInAssociatedSIU && AssociatedServiceController != null && AssociatedServiceController.PendingChanges) { string message = CultureManager.TranslateString(LanguageConstantKeys.L_PENDINGCHANGES, LanguageConstantValues.L_PENDINGCHANGES); // Show message in order to ask about to continue or cancel the pending subjects. if (MessageBox.Show(message, Alias, MessageBoxButtons.YesNo) == DialogResult.No) { result = false; } // No pending changes or user doesn't want to execute associated Service IU. if (result) { AssociatedServiceController.PendingChanges = false; } return result; } // No pending changes in Display Set, or user doesn't want to save them. if (searchChangesInThisDS && DisplaySet.PendingChanges) { string message = CultureManager.TranslateString(LanguageConstantKeys.L_PENDINGCHANGES, LanguageConstantValues.L_PENDINGCHANGES); if (MessageBox.Show(message, Alias, MessageBoxButtons.YesNo) == DialogResult.No) { result = false; } // No pending changes or user doesn't want to save them. if (result) { DisplaySet.PendingChanges = false; } } return result; }
/// <summary> /// Handles the BeforeExecute event from the associated service. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleAssociatedServiceControllerBeforeExecute(object sender, CheckForPendingChangesEventArgs e) { ProcessAssociatedServiceControllerBeforeExecute(sender, e); }
/// <summary> /// Handles the BeforeActionItemExecution event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleActionBeforeActionItemExecution(object sender, CheckForPendingChangesEventArgs e) { ProcessBeforeActionExecution(e); }
/// <summary> /// Actions related with the before action execution. /// </summary> /// <param name="e"></param> protected virtual void ProcessBeforeActionExecution(CheckForPendingChangesEventArgs e) { e.Cancel = !CheckPendingChanges(true, true); }
/// <summary> /// Actions related with the BeforeExecute event from the associated service /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void ProcessAssociatedServiceControllerBeforeExecute(object sender, CheckForPendingChangesEventArgs e) { e.Cancel = !CheckPendingChanges(true, false); }