示例#1
0
        public void BusinessflowReportTest()
        {
            string BusinessFlowReportFile = GingerTestHelper.TestResources.GetTestResourcesFile(@"Reports\BusinessFlow.txt");

            try
            {
                BusinessFlowReport BFR = (BusinessFlowReport)JsonLib.LoadObjFromJSonFile(BusinessFlowReportFile, typeof(BusinessFlowReport));
                Assert.AreEqual("Failed", BFR.RunStatus);
                Assert.AreEqual(float.Parse("36.279", CultureInfo.InvariantCulture), BFR.ElapsedSecs.Value);
            }

            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }
示例#2
0
        public void ActivityReportTest()
        {
            string ActivityReportFile = GingerTestHelper.TestResources.GetTestResourcesFile(@"Reports\Activity.txt");

            try
            {
                ActivityReport AR = (ActivityReport)JsonLib.LoadObjFromJSonFile(ActivityReportFile, typeof(ActivityReport));
                Assert.AreEqual("Passed", AR.RunStatus);
                Assert.AreEqual(2044, AR.Elapsed);
            }

            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }
示例#3
0
        // Use it when we have data from disk which ws saved by ExecutionLogger
        public ReportInfo(string folder)    // this is only that should stayed after discussion !!!
        {
            // in received folder looking for json file with specific name (file should be single txt file in folder - if no - not proceed with deserialization)
            int    txtFilesInDirectoryCount = 0;
            string txtFileName = string.Empty;
            string fileName    = string.Empty;

            foreach (string txt_file in System.IO.Directory.GetFiles(folder))
            {
                fileName = Path.GetFileName(txt_file);
                if (fileName.Contains(".txt") && (fileName != "ActivityGroups.txt"))     // !!!!!!!!!!!!!!!!!!!!!!!!
                {
                    txtFilesInDirectoryCount++;
                    txtFileName = fileName;
                }
            }
            if ((txtFilesInDirectoryCount == 0) || (txtFilesInDirectoryCount > 1))
            {
                return;
            }

            // setting ReportInfoRootObject and ReportInfoLevel according to jason that folder pointing on
            string curFileWithPath = String.Empty;

            try
            {
                switch (txtFileName)
                {
                case "RunSet.txt":
                    curFileWithPath      = Path.Combine(folder, "RunSet.txt");
                    ReportInfoRootObject = (RunSetReport)JsonLib.LoadObjFromJSonFile(curFileWithPath, typeof(RunSetReport));
                    ((RunSetReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.RunSetLevel;
                    break;

                case "Ginger.txt":
                    curFileWithPath      = folder + @"\Ginger.txt";
                    ReportInfoRootObject = (GingerReport)JsonLib.LoadObjFromJSonFile(curFileWithPath, typeof(GingerReport));
                    ((GingerReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.GingerLevel;
                    break;

                case "BusinessFlow.txt":
                    curFileWithPath      = folder + @"\BusinessFlow.txt";
                    ReportInfoRootObject = (BusinessFlowReport)JsonLib.LoadObjFromJSonFile(curFileWithPath, typeof(BusinessFlowReport));
                    ((BusinessFlowReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.BussinesFlowLevel;
                    break;

                case "Activity.txt":
                    curFileWithPath      = folder + @"\Activity.txt";
                    ReportInfoRootObject = (ActivityReport)JsonLib.LoadObjFromJSonFile(curFileWithPath, typeof(ActivityReport));
                    ((ActivityReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.ActivityLevel;
                    break;

                case "Action.txt":
                    curFileWithPath      = folder + @"\Action.txt";
                    ReportInfoRootObject = (ActionReport)JsonLib.LoadObjFromJSonFile(curFileWithPath, typeof(ActionReport));
                    ((ActionReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.ActionLevel;
                    break;

                default:
                    ReportInfoRootObject = null;
                    return;
                }
            }
            catch (Exception EC)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to Deserialize report Json file type", EC);
            }
        }
示例#4
0
        private async void LoadExecutionsHistoryData()
        {
            grdExecutionsHistory.Visibility = Visibility.Collapsed;
            Loading.Visibility = Visibility.Visible;
            mExecutionsHistoryList.Clear();
            await Task.Run(() => {
                if (WorkSpace.Instance.Solution != null && WorkSpace.Instance.Solution.LoggerConfigurations != null)
                {
                    mRunSetExecsRootFolder = executionLoggerHelper.GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder);
                    //pull all RunSets JSON files from it
                    string[] runSetsfiles = Directory.GetFiles(mRunSetExecsRootFolder, "RunSet.txt", SearchOption.AllDirectories);
                    try
                    {
                        foreach (string runSetFile in runSetsfiles)
                        {
                            RunSetReport runSetReport  = (RunSetReport)JsonLib.LoadObjFromJSonFile(runSetFile, typeof(RunSetReport));
                            runSetReport.DataRepMethod = ExecutionLoggerConfiguration.DataRepositoryMethod.TextFile;
                            runSetReport.LogFolder     = System.IO.Path.GetDirectoryName(runSetFile);
                            if (mExecutionHistoryLevel == eExecutionHistoryLevel.SpecificRunSet)
                            {
                                //filer the run sets by GUID
                                if (RunsetConfig != null && string.IsNullOrEmpty(runSetReport.GUID) == false)
                                {
                                    Guid runSetReportGuid = Guid.Empty;
                                    Guid.TryParse(runSetReport.GUID, out runSetReportGuid);
                                    if (RunsetConfig.Guid.Equals(runSetReportGuid))
                                    {
                                        mExecutionsHistoryList.Add(runSetReport);
                                    }
                                }
                            }
                            else
                            {
                                mExecutionsHistoryList.Add(runSetReport);
                            }
                        }
                        LiteDbConnector dbConnector = new LiteDbConnector(Path.Combine(mRunSetExecsRootFolder, "GingerExecutionResults.db"));
                        var rsLiteColl = dbConnector.GetCollection <LiteDbRunSet>(NameInDb <LiteDbRunSet>());

                        var runSetDataColl = rsLiteColl.FindAll();
                        foreach (var runSet in runSetDataColl)
                        {
                            RunSetReport runSetReport  = new RunSetReport();
                            runSetReport.DataRepMethod = ExecutionLoggerConfiguration.DataRepositoryMethod.LiteDB;
                            runSetReport.SetLiteDBData(runSet);
                            mExecutionsHistoryList.Add(runSetReport);
                        }
                    }
                    catch { }
                }
            });

            ObservableList <RunSetReport> executionsHistoryListSortedByDate = new ObservableList <RunSetReport>();

            foreach (RunSetReport runSetReport in mExecutionsHistoryList.OrderByDescending(item => item.StartTimeStamp))
            {
                runSetReport.StartTimeStamp = runSetReport.StartTimeStamp.ToLocalTime();
                runSetReport.EndTimeStamp   = runSetReport.EndTimeStamp.ToLocalTime();
                executionsHistoryListSortedByDate.Add(runSetReport);
            }

            grdExecutionsHistory.DataSourceList = executionsHistoryListSortedByDate;
            grdExecutionsHistory.Visibility     = Visibility.Visible;
            Loading.Visibility = Visibility.Collapsed;
        }
示例#5
0
 public static object LoadObjFromJSonFile(string FileName, Type t)
 {
     return(JsonLib.LoadObjFromJSonFile(FileName, t, mJsonSerializer));
 }