/// <summary> /// This method is used to add the actions /// </summary> /// <param name="addNewActivity"></param> public void ConvertBusinessFlowLegacyActions(BusinessFlowToConvert businessFlowToConvert, bool addNewActivity, ObservableList <ConvertableActionDetails> actionsToBeConverted, ObservableList <ConvertableTargetApplicationDetails> convertableTargetApplications, bool convertToPOMAction = false, ObservableList <Guid> selectedPOMObjectName = null) { try { int activityIndex = 0; businessFlowToConvert.ConvertedActionsCount = 0; for (; activityIndex < businessFlowToConvert.BusinessFlow.Activities.Count(); activityIndex++) { if (!mStopConversion) { if (businessFlowToConvert.TotalProcessingActionsCount > 0) { Activity activity = businessFlowToConvert.BusinessFlow.Activities[activityIndex]; if (activity != null && activity.Active && activity.SelectedForConversion && activity.Acts.OfType <IObsoleteAction>().ToList().Count > 0) { businessFlowToConvert.BusinessFlow.StartDirtyTracking(); Activity currentActivity = GetCurrentWorkingActivity(businessFlowToConvert.BusinessFlow, addNewActivity, ref activityIndex, activity); ConvertSelectedActionsFromActivity(businessFlowToConvert, actionsToBeConverted, addNewActivity, convertToPOMAction, selectedPOMObjectName, currentActivity); currentActivity.TargetApplication = convertableTargetApplications.Where(x => x.SourceTargetApplicationName == activity.TargetApplication).Select(x => x.TargetTargetApplicationName).FirstOrDefault(); } } } else { businessFlowToConvert.ConversionStatus = eConversionStatus.Stopped; break; } } if (businessFlowToConvert.ConvertedActionsCount == 0) { businessFlowToConvert.ConversionStatus = eConversionStatus.NA; businessFlowToConvert.SaveStatus = eConversionSaveStatus.NA; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to convert action", ex); } }
/// <summary> /// This method is used to convert the selected actions from the activity /// </summary> /// <param name="addNewActivity"></param> /// <param name="actionsToBeConverted"></param> /// <param name="convertToPOMAction"></param> /// <param name="selectedPOMObjectName"></param> /// <param name="currentActivity"></param> private void ConvertSelectedActionsFromActivity(BusinessFlowToConvert businessFlowToConvert, ObservableList <ConvertableActionDetails> actionsToBeConverted, bool addNewActivity, bool convertToPOMAction, ObservableList <Guid> selectedPOMObjectName, Activity currentActivity) { int actionIndex = 0; for (; actionIndex < currentActivity.Acts.Count(); actionIndex++) { Act act = (Act)currentActivity.Acts[actionIndex]; if (!mStopConversion) { try { ePlatformType activityPlatform = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == currentActivity.TargetApplication select x.Platform).FirstOrDefault(); if (act.Active && act is IObsoleteAction && (((IObsoleteAction)act).IsObsoleteForPlatform(activityPlatform)) && actionsToBeConverted.Where(a => a.SourceActionType == act.GetType() && a.Selected && a.TargetActionType == ((IObsoleteAction)act).TargetAction()).FirstOrDefault() != null) { // get the index of the action that is being converted int selectedActIndex = currentActivity.Acts.IndexOf(act); // convert the old action Act newAct = ((IObsoleteAction)act).GetNewAction(); if (newAct != null) { newAct.Platform = ((IObsoleteAction)act).GetTargetPlatform(); newAct.Description = newAct.Description;// string.Format("New - {0}", newAct.Description); if (convertToPOMAction && newAct.GetType().Name == ActUIElementClassName) { bool isFound = false; foreach (Guid pomOj in selectedPOMObjectName) { if (!isFound) { newAct = GetMappedElementFromPOMForAction(newAct, pomOj, ref isFound); } else if (isFound) { break; } } } currentActivity.Acts.Insert(selectedActIndex + 1, newAct); // set obsolete action in the activity as inactive act.Active = false; if (addNewActivity) { currentActivity.Acts.Remove(act); } businessFlowToConvert.ConvertedActionsCount++; } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to convert action", ex); } } else { break; } } }