private void SetBfobjects(Context context, eExecutedFrom executedFrom) { var bf = context.BusinessFlow; bf.Activities.ToList().ForEach(activity => this.MapActivityToLiteDb(activity, context, executedFrom)); bf.ActivitiesGroups.ToList().ForEach(acg => this.MapAcgToLiteDb(acg, bf)); }
private string[] PomElementGUID;// => mAct.ElementLocateValue.ToString().Split('_'); public POMExecutionUtils(Act act, string elementLocateValue) { mAct = act; var context = Context.GetAsContext(mAct.Context); ExecutedFrom = context.ExecutedFrom; PomElementGUID = elementLocateValue.ToString().Split('_'); }
// TODO: remove the need for env - get it from notify event !!!!!! public ExecutionLoggerManager(Context context, eExecutedFrom executedFrom = eExecutedFrom.Run) { mContext = context; mJsonSerializer = new Newtonsoft.Json.JsonSerializer(); mJsonSerializer.NullValueHandling = NullValueHandling.Ignore; ExecutedFrom = executedFrom; if (WorkSpace.Instance != null && WorkSpace.Instance.Solution != null && WorkSpace.Instance.Solution.LoggerConfigurations.SelectedDataRepositoryMethod == ExecutionLoggerConfiguration.DataRepositoryMethod.LiteDB) { mExecutionLogger = new LiteDBRepository(); } else { mExecutionLogger = new TextFileRepository(); } executionLoggerHelper = new ExecutionLoggerHelper(); }
private object MapActivityToLiteDb(Activity activity, Context context, eExecutedFrom executedFrom) { LiteDbActivity AR = new LiteDbActivity(); context.BusinessFlow.CurrentActivity = activity; context.Runner.CalculateActivityFinalStatus(activity); AR.SetReportData(GetActivityReportData(activity, context, false)); AR.ActivityGroupName = activity.ActivitiesGroupID; AR.Seq = ++this.activitySeq; actionSeq = 0; if (activity.LiteDbId != null && ExecutionLoggerManager.RunSetReport != null && ExecutionLoggerManager.RunSetReport.RunSetExecutionStatus == Execution.eRunStatus.Automated) // missing Executed from { AR._id = activity.LiteDbId; var ARToUpdate = liteDbManager.GetActivitiesLiteData().IncludeAll().Find(x => x._id == AR._id).ToList(); if (ARToUpdate.Count > 0) { foreach (var action in (ARToUpdate[0] as LiteDbActivity).ActionsColl) { if (liteDbActionList.Any(ac => ac._id == action._id)) { liteDbActionList.RemoveAll(x => x._id == action._id); } } liteDbActionList.AddRange((ARToUpdate[0] as LiteDbActivity).ActionsColl); } } activity.Acts.ToList().ForEach(action => this.MapActionToLiteDb((GingerCore.Actions.Act)action, context, executedFrom)); AR.ActionsColl.AddRange(liteDbActionList); AR.ChildExecutableItemsCount = activity.Acts.Count(x => x.Active == true); AR.ChildExecutedItemsCount = activity.Acts.Count(x => x.Status == eRunStatus.Passed || x.Status == eRunStatus.Failed || x.Status == eRunStatus.FailIgnored); AR.ChildPassedItemsCount = activity.Acts.Count(x => x.Status == eRunStatus.Passed); liteDbActivityList.Add(AR); SaveObjToReporsitory(AR, liteDbManager.NameInDb <LiteDbActivity>()); liteDbActionList.Clear(); if (ExecutionLoggerManager.RunSetReport != null && ExecutionLoggerManager.RunSetReport.RunSetExecutionStatus == Execution.eRunStatus.Automated) { activity.LiteDbId = AR._id; } return(AR); }
public bool DeleteDocumentByLiteDbRunSet(LiteDbRunSet liteDbRunSet, eExecutedFrom executedFrom = eExecutedFrom.Run) { bool result = true; var runSetLiteColl = GetCollection <LiteDbRunSet>(NameInDb <LiteDbRunSet>()); var runnerssLiteColl = GetCollection <LiteDbRunner>(NameInDb <LiteDbRunner>()); foreach (LiteDbRunner ldbRunner in liteDbRunSet.RunnersColl) { var businessFlowsLiteColl = GetCollection <LiteDbBusinessFlow>(NameInDb <LiteDbBusinessFlow>()); foreach (LiteDbBusinessFlow ldbBF in ldbRunner.BusinessFlowsColl) { var activitiesLiteColl = GetCollection <LiteDbActivity>(NameInDb <LiteDbActivity>()); var activitiesGroupsLiteColl = GetCollection <LiteDbActivityGroup>(NameInDb <LiteDbActivityGroup>()); foreach (LiteDbActivityGroup ldbAG in ldbBF.ActivitiesGroupsColl) { activitiesGroupsLiteColl.Delete(ldbAG._id); } foreach (LiteDbActivity ldbActivity in ldbBF.ActivitiesColl) { var actionsLiteColl = GetCollection <LiteDbAction>(NameInDb <LiteDbAction>()); foreach (LiteDbAction ldbAction in ldbActivity.ActionsColl) { actionsLiteColl.Delete(ldbAction._id); } activitiesLiteColl.Delete(ldbActivity._id); } businessFlowsLiteColl.Delete(ldbBF._id); } if (executedFrom == eExecutedFrom.Run) { runnerssLiteColl.Delete(ldbRunner._id); } } if (executedFrom == eExecutedFrom.Run) { runSetLiteColl.Delete(liteDbRunSet._id); } return(result); }
private object MapActionToLiteDb(GingerCore.Actions.Act action, Context context, eExecutedFrom executedFrom) { bool isActExsits = false; string executionLogFolder = executionLoggerHelper.GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder); LiteDbAction liteDbAction = new LiteDbAction(); liteDbAction.SetReportData(GetActionReportData(action, context, executedFrom)); liteDbAction.Seq = ++this.actionSeq; liteDbAction.Wait = action.Wait; liteDbAction.TimeOut = action.Timeout; if (action.LiteDbId != null && executedFrom == eExecutedFrom.Automation) { liteDbAction._id = action.LiteDbId; } // Save screenShots int screenShotCountPerAction = 0; for (var s = 0; s < action.ScreenShots.Count; s++) { try { screenShotCountPerAction++; string imagesFolderName = Path.Combine(executionLogFolder, "LiteDBImages"); if (!System.IO.Directory.Exists(imagesFolderName)) { System.IO.Directory.CreateDirectory(imagesFolderName); } if (executedFrom == Amdocs.Ginger.Common.eExecutedFrom.Automation) { System.IO.File.Copy(action.ScreenShots[s], imagesFolderName + @"\ScreenShot_" + liteDbAction.GUID + "_" + liteDbAction.StartTimeStamp.ToString("hhmmss") + "_" + screenShotCountPerAction.ToString() + ".png", true); } else { System.IO.File.Move(action.ScreenShots[s], imagesFolderName + @"\ScreenShot_" + liteDbAction.GUID + "_" + liteDbAction.StartTimeStamp.ToString("hhmmss") + "_" + screenShotCountPerAction.ToString() + ".png"); action.ScreenShots[s] = imagesFolderName + @"\ScreenShot_" + liteDbAction.GUID + "_" + liteDbAction.StartTimeStamp.ToString("hhmmss") + "_" + screenShotCountPerAction.ToString() + ".png"; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to move screen shot of the action:'" + action.Description + "' to the Execution Logger folder", ex); screenShotCountPerAction--; } } liteDbAction.ScreenShots = action.ScreenShots.ToList(); isActExsits = liteDbActionList.Any(x => x.GUID == liteDbAction.GUID); if (isActExsits) { liteDbActionList.RemoveAll(x => x.GUID == liteDbAction.GUID); } liteDbActionList.Add(liteDbAction); SaveObjToReporsitory(liteDbAction, liteDbManager.NameInDb <LiteDbAction>()); if (executedFrom == eExecutedFrom.Automation) { action.LiteDbId = liteDbAction._id; } return(liteDbAction); }
private object MapActionToLiteDb(GingerCore.Actions.Act action, Context context, eExecutedFrom executedFrom) { bool isActExsits = false; LiteDbAction liteDbAction = new LiteDbAction(); liteDbAction.SetReportData(GetActionReportData(action, context, executedFrom)); liteDbAction.Seq = ++this.actionSeq; liteDbAction.Wait = action.Wait; liteDbAction.TimeOut = action.Timeout; if (action.LiteDbId != null && executedFrom == eExecutedFrom.Automation) { liteDbAction._id = action.LiteDbId; } //change the paths to Defect suggestion list var defectSuggestion = WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList.FirstOrDefault(z => z.FailedActionGuid == action.Guid); if (defectSuggestion != null) { defectSuggestion.ScreenshotFileNames = action.ScreenShots.ToList(); } liteDbAction.ScreenShots = action.ScreenShots.ToList(); isActExsits = liteDbActionList.Any(x => x.GUID == liteDbAction.GUID); if (isActExsits) { liteDbActionList.RemoveAll(x => x.GUID == liteDbAction.GUID); } liteDbActionList.Add(liteDbAction); SaveObjToReporsitory(liteDbAction, liteDbManager.NameInDb <LiteDbAction>()); if (executedFrom == eExecutedFrom.Automation) { action.LiteDbId = liteDbAction._id; } return(liteDbAction); }