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); }