/// <summary> /// Deletes selected tasks. /// </summary> protected void DeleteSelected(object parameter) { List <String> list = parameter as List <String>; if (list == null) { return; } CanceledString = GetString("Tasks.DeletionCanceled"); eventCode = "DELETESELECTEDTASKS"; try { AddLog(GetString("Synchronization.DeletingTasks")); list.Sort(); foreach (string synchronizationIdString in list) { int synchronizationId = ValidationHelper.GetInteger(synchronizationIdString, 0); if (synchronizationId > 0) { IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { IntegrationTaskInfo task = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID); if (task != null) { DeleteSynchronization(synchronizationId, task.TaskTitle); } } } } CurrentInfo = GetString("tasks.deletionok"); AddLog(CurrentInfo); } catch (ThreadAbortException ex) { if (CMSThread.Stopped(ex)) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.DeletionFailed"); AddErrorLog(CurrentError); } } catch (Exception ex) { CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } }
protected void gridElem_OnAction(string actionName, object actionArgument) { int synchronizationId = ValidationHelper.GetInteger(actionArgument, 0); switch (actionName.ToLowerInvariant()) { case "delete": // Delete synchronization IntegrationSynchronizationInfoProvider.DeleteIntegrationSynchronizationInfo(synchronizationId); break; case "run": // Get synchronization IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { // Get connector and task IntegrationConnectorInfo connectorInfo = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(synchronization.SynchronizationConnectorID); IntegrationTaskInfo taskInfo = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID); if ((connectorInfo != null) && (taskInfo != null)) { // Get connector instance BaseIntegrationConnector connector = IntegrationHelper.GetConnector(connectorInfo.ConnectorName) as BaseIntegrationConnector; if (connector != null) { // Process the task if (TasksAreInbound) { // Always try to process the task when requested from UI taskInfo.TaskProcessType = IntegrationProcessTypeEnum.Default; connector.ProcessExternalTask(taskInfo); } else { connector.ProcessInternalTask(taskInfo); } } } } break; } }
/// <summary> /// Synchronization of selected items. /// </summary> /// <param name="parameter">List of selected items</param> public void SynchronizeSelected(object parameter) { List <String> list = parameter as List <String>; if (list == null) { return; } StringBuilder result = new StringBuilder(); eventCode = "SYNCSELECTEDTASKS"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); list.Sort(); foreach (string taskIdString in list) { // Get synchronization int synchronizationId = ValidationHelper.GetInteger(taskIdString, 0); IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { result.Append(ProcessSynchronization(synchronization.SynchronizationConnectorID, synchronization.SynchronizationTaskID)); } } // Log possible error if (!String.IsNullOrEmpty(result.ToString())) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); AddLog(CurrentInfo); } } catch (ThreadAbortException ex) { if (CMSThread.Stopped(ex)) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, result.ToString()); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } }
/// <summary> /// Deletes selected tasks. /// </summary> protected void DeleteSelected(object parameter) { ArrayList list = parameter as ArrayList; if (list == null) { return; } CanceledString = GetString("Tasks.DeletionCanceled"); eventCode = "DELETESELECTEDTASKS"; try { AddLog(GetString("Synchronization.DeletingTasks")); list.Sort(); foreach (string synchronizationIdString in list) { int synchronizationId = ValidationHelper.GetInteger(synchronizationIdString, 0); if (synchronizationId > 0) { IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { IntegrationTaskInfo task = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID); if (task != null) { DeleteSynchronization(synchronizationId, task.TaskTitle); } } } } CurrentInfo = GetString("Tasks.DeleteOK"); AddLog(CurrentInfo); } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state == CMSThread.ABORT_REASON_STOP) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.DeletionFailed"); AddErrorLog(CurrentError); } } catch (Exception ex) { CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }