private async void LoadExecutionsHistoryData()
        {
            grdExecutionsHistory.Visibility = Visibility.Collapsed;
            Loading.Visibility = Visibility.Visible;
            mExecutionsHistoryList.Clear();
            await Task.Run(() => {
                if (App.UserProfile.Solution != null && App.UserProfile.Solution.ExecutionLoggerConfigurationSetList != null && App.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Count > 0)
                {
                    mRunSetExecsRootFolder = ExecutionLogger.GetLoggerDirectory(App.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().ExecutionLoggerConfigurationExecResultsFolder);

                    //pull all RunSets JSON files from it
                    string[] runSetsfiles = Directory.GetFiles(mRunSetExecsRootFolder, "RunSet.txt", SearchOption.AllDirectories);
                    foreach (string runSetFile in runSetsfiles)
                    {
                        try
                        {
                            RunSetReport runSetReport = (RunSetReport)ExecutionLogger.LoadObjFromJSonFile(runSetFile, typeof(RunSetReport));
                            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);
                            }
                        }
                        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;
        }
Beispiel #2
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      = folder + @"\RunSet.txt";
                    ReportInfoRootObject = (RunSetReport)ExecutionLogger.LoadObjFromJSonFile(curFileWithPath, typeof(RunSetReport));
                    ((RunSetReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.RunSetLevel;
                    break;

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

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

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

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

                default:
                    ReportInfoRootObject = null;
                    return;
                }
            }
            catch { }
        }