Example #1
0
        public void CreateCustomerLogo(object a, string tempFolder)
        {
            HTMLReportConfiguration currentTemplate = (HTMLReportConfiguration)a;

            System.Drawing.Image CustomerLogo = this.Base64StringToImage(currentTemplate.LogoBase64Image.ToString());
            CustomerLogo.Save(Path.Combine(tempFolder, "CustomerLogo.png"));
            HTMLReportConfiguration.EnchancingLoadedFieldsWithDataAndValidating(currentTemplate);
        }
        public void CreateCustomerLogo(object a, string tempFolder)
        {
            HTMLReportConfiguration currentTemplate = (HTMLReportConfiguration)a;

            System.Drawing.Image CustomerLogo = Ginger.General.Base64StringToImage(currentTemplate.LogoBase64Image.ToString());
            CustomerLogo.Save(tempFolder + "/CustomerLogo.png");

            Ginger.Reports.HTMLReportTemplatePage.EnchancingLoadedFieldsWithDataAndValidating(currentTemplate);
        }
Example #3
0
        private void AddDeafultReportTemplate()
        {
            HTMLReportConfiguration r = HTMLReportConfiguration.SetHTMLReportConfigurationWithDefaultValues("Default");

            r.Name      = "Default";
            r.IsDefault = true;


            WorkSpace.Instance.SolutionRepository.AddRepositoryItem(r);
        }
Example #4
0
        public void AddHTMLReport()
        {
            //Arrange
            string ReportName = "Template #1";

            //Act
            ObservableList <HTMLReportConfiguration> allReports = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>();
            HTMLReportConfiguration Report1 = (from x in allReports where x.Name == ReportName select x).SingleOrDefault();

            //Assert
            Assert.AreEqual(Report1.Name, ReportName);
        }
        public override void DuplicateTreeItem(object item)
        {
            HTMLReportConfiguration copiedItem = (HTMLReportConfiguration)CopyTreeItemWithNewName((RepositoryItemBase)item);

            //TODO: why below is needed??
            copiedItem.ID = App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().HTMLReportTemplatesSeq + 1;
            App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().HTMLReportTemplatesSeq = App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().HTMLReportTemplatesSeq + 1;
            copiedItem.IsDefault = false;
            if (copiedItem != null)
            {
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(copiedItem);
            }
        }
Example #6
0
        public override void DuplicateTreeItem(object item)
        {
            HTMLReportConfiguration copiedItem = (HTMLReportConfiguration)CopyTreeItemWithNewName((RepositoryItemBase)item);

            //TODO: why below is needed??
            copiedItem.ID        = copiedItem.SetReportTemplateSequence(true);
            copiedItem.IsDefault = false;
            if (copiedItem != null)
            {
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(copiedItem);
                WorkSpace.UserProfile.Solution.SaveSolution(true, SolutionGeneral.Solution.eSolutionItemToSave.ReportConfiguration);
            }
        }
        private void AddDeafultReportTemplate()
        {
            HTMLReportConfiguration           r = new HTMLReportConfiguration();
            HTMLReportConfigurationOperations reportConfigurationOperations = new HTMLReportConfigurationOperations(r);

            r.HTMLReportConfigurationOperations = reportConfigurationOperations;

            HTMLReportConfiguration           reportTemplate = new HTMLReportConfiguration("Default", true, reportConfigurationOperations);
            HTMLReportConfigurationOperations reportTemplateConfigurationOperations = new HTMLReportConfigurationOperations(reportTemplate);

            reportTemplate.HTMLReportConfigurationOperations = reportTemplateConfigurationOperations;

            WorkSpace.Instance.SolutionRepository.AddRepositoryItem(reportTemplate);
        }
        private void AddNewTemplateItem()
        {
            HTMLReportTemplatePage mHTMLReportTemplatePage = new HTMLReportTemplatePage();

            mHTMLReportTemplatePage.ShowAsWindow();

            HTMLReportConfiguration mHTMLReportConfiguration = mHTMLReportTemplatePage.newHTMLReportConfiguration;

            if (mHTMLReportConfiguration != null)
            {
                //HTMLGingerReportTreeItem r = new HTMLGingerReportTreeItem(mHTMLReportConfiguration);
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(mHTMLReportConfiguration);
            }
        }
Example #9
0
        public void AddHTMLReport()
        {
            //Arrange
            string ReportName         = "Template #1";
            string screenShotFileName = mTestHelper.GetTempFileName("screen1.png");

            mGingerAutomator.MainWindowPOM.TakeScreenShot(screenShotFileName);
            mTestHelper.AddTestArtifact(screenShotFileName);

            //Act
            ObservableList <HTMLReportConfiguration> allReports = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>();
            HTMLReportConfiguration Report1 = (from x in allReports where x.Name == ReportName select x).SingleOrDefault();

            //Assert
            Assert.AreEqual(Report1.Name, ReportName);
        }
Example #10
0
        //[Timeout(60000)]
        public void GenrateLastExecutionHTMLReportTest()
        {
            string     BusinessFlowReportFolder = GingerTestHelper.TestResources.GetTestResourcesFolder(@"Reports\AutomationTab_LastExecution\");
            ReportInfo RI = new ReportInfo(BusinessFlowReportFolder);
            //Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(RI);

            string templatesFolder = (ExtensionMethods.getGingerEXEFileName() + @"Reports\GingerExecutionReport\").Replace("Ginger.exe", "");
            HTMLReportConfiguration selectedHTMLReportConfiguration = HTMLReportConfiguration.SetHTMLReportConfigurationWithDefaultValues("DefaultTemplate", true);

            HTMLReportsConfiguration hTMLReportsConfiguration = new HTMLReportsConfiguration();

            string hTMLOutputFolder = @"C:\HTMLReports\";


            string report = Ginger.Reports.GingerExecutionReport.ExtensionMethods.NewFunctionCreateGingerExecutionReport(RI, false, selectedHTMLReportConfiguration, templatesFolder: templatesFolder, hTMLReportsConfiguration: hTMLReportsConfiguration, hTMLOutputFolder: hTMLOutputFolder);
        }
Example #11
0
        string jsonDumpFolder = @"c:\temp\Ginger\Dump\";                                                     // !!!!!!!!!!!!!!!!!!!temp FIXME
        void GenerateReport(BusinessFlow businessFlow)                                                       // temp remove BF from param
        {
            string     BusinessFlowReportFolder = jsonDumpFolder + "1 " + businessFlow.GetNameForFileName(); // !!!!!!!!!!!!!!!! temp remove
            ReportInfo RI = new ReportInfo(BusinessFlowReportFolder);
            //Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(RI);

            string templatesFolder = @"C:\Users\yaronwe\source\repos\Ginger\Ginger\Ginger\Reports\GingerExecutionReport\"; // !!!!!!!!!!!!!!!!!!!!!!! temp fix me
            HTMLReportConfiguration selectedHTMLReportConfiguration = HTMLReportConfiguration.SetHTMLReportConfigurationWithDefaultValues("DefaultTemplate", true);

            HTMLReportsConfiguration hTMLReportsConfiguration = new HTMLReportsConfiguration();

            string hTMLOutputFolder = @"C:\Temp\Ginger\Report"; // !!!!!!!!!!!!!!!!!!!!!!! temp fix me

            Directory.Delete(hTMLOutputFolder, true);
            Directory.CreateDirectory(hTMLOutputFolder);

            string report = Ginger.Reports.GingerExecutionReport.ExtensionMethods.NewFunctionCreateGingerExecutionReport(RI, true, selectedHTMLReportConfiguration, templatesFolder: templatesFolder, hTMLReportsConfiguration: hTMLReportsConfiguration, hTMLOutputFolder: hTMLOutputFolder);



            //ExecutionLoggerConfiguration executionLoggerConfiguration = new ExecutionLoggerConfiguration();
            //// HTMLReportsConfiguration currentConf = WorkSpace.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
            ////get logger files
            //string exec_folder = @"c:\temp\hh"; // Ginger.Run.ExecutionLogger.GetLoggerDirectory(executionLoggerConfiguration.ExecutionLoggerConfigurationExecResultsFolder + "\\" + Ginger.Run.ExecutionLogger.defaultAutomationTabLogName);string templatesFolder = @"C:\Users\yaronwe\source\repos\Ginger\Ginger\Ginger\Reports\GingerExecutionReport\";
            //string templatesFolder = @"C:\Users\yaronwe\source\repos\Ginger\Ginger\Ginger\Reports\GingerExecutionReport\";
            ////create the report
            //HTMLReportConfiguration hTMLReportConfiguration = new HTMLReportConfiguration("DefaultTemplate", true);
            //string reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.NewFunctionCreateGingerExecutionReport(new ReportInfo(exec_folder), true, hTMLReportConfiguration, templatesFolder, false, 100000);

            //if (reportsResultFolder == string.Empty)
            //{
            //    Reporter.ToUser(eUserMsgKey.AutomationTabExecResultsNotExists);
            //}
            //else
            //{
            //    foreach (string txt_file in System.IO.Directory.GetFiles(reportsResultFolder))
            //    {
            //        string fileName = Path.GetFileName(txt_file);
            //        if (fileName.Contains(".html"))
            //        {
            //            System.Diagnostics.Process.Start(reportsResultFolder);
            //            System.Diagnostics.Process.Start(reportsResultFolder + "\\" + fileName);
            //        }
            //    }
            //}
        }
        private void AddNewTemplateItem()
        {
            HTMLReportTemplatePage mHTMLReportTemplatePage = new HTMLReportTemplatePage();

            mHTMLReportTemplatePage.ShowAsWindow();

            HTMLReportConfiguration mHTMLReportConfiguration = mHTMLReportTemplatePage.newHTMLReportConfiguration;

            if (mHTMLReportConfiguration != null)
            {
                //HTMLGingerReportTreeItem r = new HTMLGingerReportTreeItem(mHTMLReportConfiguration);
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(mHTMLReportConfiguration);
            }
            else
            {
                WorkSpace.Instance.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().HTMLReportTemplatesSeq = WorkSpace.Instance.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().HTMLReportTemplatesSeq - 1;
            }
        }
Example #13
0
        public override void DuplicateTreeItem(object item)
        {
            HTMLReportConfiguration           copiedItem = (HTMLReportConfiguration)CopyTreeItemWithNewName((RepositoryItemBase)item);
            HTMLReportConfigurationOperations reportConfigurationOperations = new HTMLReportConfigurationOperations(copiedItem);

            copiedItem.HTMLReportConfigurationOperations = reportConfigurationOperations;
            if (copiedItem != null)
            {
                copiedItem.DirtyStatus = eDirtyStatus.NoTracked;
                //TODO: why below is needed??
                copiedItem.ID        = copiedItem.HTMLReportConfigurationOperations.SetReportTemplateSequence(true);
                copiedItem.IsDefault = false;
                if (copiedItem != null)
                {
                    WorkSpace.Instance.SolutionRepository.AddRepositoryItem(copiedItem);
                    WorkSpace.Instance.Solution.SolutionOperations.SaveSolution(true, SolutionGeneral.Solution.eSolutionItemToSave.ReportConfiguration);
                }
            }
        }
        /// <summary>
        /// Create summary json of the execution
        /// </summary>
        /// <param name="fileName"></param>
        public void CreateExecutionHTMLReport(string fileName)
        {
            WorkSpace.Instance.RunsetExecutor.CreateGingerExecutionReportAutomaticly();


            HTMLReportsConfiguration currentConf = WorkSpace.Instance.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
            HTMLReportConfiguration  htmlRep     = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>().Where(x => (x.IsSelected == true)).FirstOrDefault();
            //if (grdExecutionsHistory.CurrentItem == null)
            //{
            //    Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
            //    return;
            //}

            // string runSetFolder = ExecutionLogger.GetLoggerDirectory(((RunSetReport)grdExecutionsHistory.CurrentItem).LogFolder);

            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! temp
            string runSetFolder = @"C:\Users\yaronwe\source\repos\Ginger\Ginger\GingerCoreNETUnitTest\bin\Debug\netcoreapp2.2\TestResources\Solutions\CLI\ExecutionResults\Default Run Set_04082019_115742";

            string reportsResultFolder = ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(runSetFolder), false, htmlRep, null, false, currentConf.HTMLReportConfigurationMaximalFolderSize);

            if (reportsResultFolder == string.Empty)
            {
                Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
                return;
            }
            else
            {
                Process.Start(reportsResultFolder);
                Process.Start(reportsResultFolder + "\\" + "GingerExecutionReport.html");
            }


            // System.IO.File.WriteAllText(fileName, s);

            // ExtensionMethods.CreateGingerExecutionReport()
        }
 public HTMLGingerReportTreeItem(HTMLReportConfiguration htmlConfig)
 {
     HTMLReportConfiguration = htmlConfig;
 }
Example #16
0
        private List <string> PopulateMissingFieldsAndGetScreenshotsList(LiteDbRunSet liteDbRunSet, Guid executionId)
        {
            List <string> allScreenshots = new List <string>();
            //select template
            HTMLReportConfiguration _HTMLReportConfig = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>().Where(x => x.IsDefault).FirstOrDefault();

            //populate data based on level
            if (string.IsNullOrEmpty(_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()))
            {
                _HTMLReportConfig.ExecutionStatisticsCountBy = HTMLReportConfiguration.eExecutionStatisticsCountBy.Actions;
            }


            List <string> runSetEnv = new List <string>();

            liteDbRunSet.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunSet.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunSet.ChildExecutableItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

            liteDbRunSet.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunSet.ChildPassedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunSet.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

            if (liteDbRunSet.Elapsed.HasValue)
            {
                liteDbRunSet.Elapsed = Math.Round(liteDbRunSet.Elapsed.Value, 2);
            }
            foreach (LiteDbRunner liteDbRunner in liteDbRunSet.RunnersColl)
            {
                if (!runSetEnv.Contains(liteDbRunner.Environment))
                {
                    runSetEnv.Add(liteDbRunner.Environment);
                }

                liteDbRunner.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunner.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunner.ChildExecutableItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                liteDbRunner.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunner.ChildPassedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunner.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                if (liteDbRunner.Elapsed.HasValue)
                {
                    liteDbRunner.Elapsed = Math.Round(liteDbRunner.Elapsed.Value, 2);
                }
                else
                {
                    liteDbRunner.Elapsed = 0;
                }
                foreach (LiteDbBusinessFlow liteDbBusinessFlow in liteDbRunner.BusinessFlowsColl)
                {
                    liteDbBusinessFlow.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbBusinessFlow.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbBusinessFlow.ChildExecutableItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                    liteDbBusinessFlow.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbBusinessFlow.ChildPassedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbBusinessFlow.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                    if (liteDbBusinessFlow.Elapsed.HasValue)
                    {
                        liteDbBusinessFlow.Elapsed = Math.Round(liteDbBusinessFlow.Elapsed.Value, 2);
                    }
                    else
                    {
                        liteDbBusinessFlow.Elapsed = 0;
                    }

                    foreach (LiteDbActivityGroup liteDbActivityGroup in liteDbBusinessFlow.ActivitiesGroupsColl)
                    {
                        foreach (LiteDbActivity liteDbActivity in liteDbActivityGroup.ActivitiesColl)
                        {
                            liteDbActivity.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbActivity.ChildExecutedItemsCount, liteDbActivity.ChildExecutableItemsCount));

                            liteDbActivity.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbActivity.ChildPassedItemsCount, liteDbActivity.ChildExecutedItemsCount));


                            if (liteDbActivity.Elapsed.HasValue)
                            {
                                liteDbActivity.Elapsed = Math.Round(liteDbActivity.Elapsed.Value / 1000, 4);
                            }
                            else
                            {
                                liteDbActivity.Elapsed = 0;
                            }
                            foreach (LiteDbAction liteDbAction in liteDbActivity.ActionsColl)
                            {
                                List <string> newScreenShotsList = new List <string>();
                                if (liteDbAction.Elapsed.HasValue)
                                {
                                    liteDbAction.Elapsed = Math.Round(liteDbAction.Elapsed.Value / 1000, 4);
                                }
                                else
                                {
                                    liteDbAction.Elapsed = 0;
                                }
                                if ((!string.IsNullOrEmpty(liteDbAction.ExInfo)) && liteDbAction.ExInfo[liteDbAction.ExInfo.Length - 1] == '-')
                                {
                                    liteDbAction.ExInfo = liteDbAction.ExInfo.Remove(liteDbAction.ExInfo.Length - 1);
                                }

                                foreach (string screenshot in liteDbAction.ScreenShots)
                                {
                                    allScreenshots.Add(screenshot);
                                    string newScreenshotPath = executionId.ToString() + "/" + Path.GetFileName(screenshot);

                                    newScreenShotsList.Add(newScreenshotPath);
                                }
                                liteDbAction.ScreenShots = newScreenShotsList;
                            }
                        }
                    }
                }
            }

            if (runSetEnv.Count > 0)
            {
                liteDbRunSet.Environment = string.Join(",", runSetEnv);
            }
            return(allScreenshots);
        }
        //TODO move it to utils class
        // Create test class

        private void PopulateMissingFields(LiteDbRunSet liteDbRunSet, string clientAppPath)
        {
            //select template
            HTMLReportConfiguration _HTMLReportConfig = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>().Where(x => (x.IsDefault == true)).FirstOrDefault();

            //populate data based on level
            if (string.IsNullOrEmpty(_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()))
            {
                _HTMLReportConfig.ExecutionStatisticsCountBy = HTMLReportConfiguration.eExecutionStatisticsCountBy.Actions;
            }

            string        imageFolderPath = Path.Combine(clientAppPath, "assets", "screenshots");
            List <string> runSetEnv       = new List <string>();

            liteDbRunSet.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunSet.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunSet.ChildExecutableItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

            liteDbRunSet.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunSet.ChildPassedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunSet.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

            if (liteDbRunSet.Elapsed.HasValue)
            {
                liteDbRunSet.Elapsed = Math.Round(liteDbRunSet.Elapsed.Value, 2);
            }
            foreach (LiteDbRunner liteDbRunner in liteDbRunSet.RunnersColl)
            {
                if (!runSetEnv.Contains(liteDbRunner.Environment))
                {
                    runSetEnv.Add(liteDbRunner.Environment);
                }

                liteDbRunner.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunner.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunner.ChildExecutableItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                liteDbRunner.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbRunner.ChildPassedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbRunner.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                if (liteDbRunner.Elapsed.HasValue)
                {
                    liteDbRunner.Elapsed = Math.Round(liteDbRunner.Elapsed.Value, 2);
                }
                else
                {
                    liteDbRunner.Elapsed = 0;
                }
                foreach (LiteDbBusinessFlow liteDbBusinessFlow in liteDbRunner.BusinessFlowsColl)
                {
                    liteDbBusinessFlow.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbBusinessFlow.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbBusinessFlow.ChildExecutableItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                    liteDbBusinessFlow.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbBusinessFlow.ChildPassedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()], liteDbBusinessFlow.ChildExecutedItemsCount[_HTMLReportConfig.ExecutionStatisticsCountBy.ToString()]));

                    if (liteDbBusinessFlow.Elapsed.HasValue)
                    {
                        liteDbBusinessFlow.Elapsed = Math.Round(liteDbBusinessFlow.Elapsed.Value, 2);
                    }
                    else
                    {
                        liteDbBusinessFlow.Elapsed = 0;
                    }
                    foreach (LiteDbActivity liteDbActivity in liteDbBusinessFlow.ActivitiesColl)
                    {
                        liteDbActivity.ExecutionRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbActivity.ChildExecutedItemsCount, liteDbActivity.ChildExecutableItemsCount));

                        liteDbActivity.PassRate = string.Format("{0:F1}", CalculateExecutionOrPassRate(liteDbActivity.ChildPassedItemsCount, liteDbActivity.ChildExecutedItemsCount));


                        if (liteDbActivity.Elapsed.HasValue)
                        {
                            liteDbActivity.Elapsed = Math.Round(liteDbActivity.Elapsed.Value / 1000, 4);
                        }
                        else
                        {
                            liteDbActivity.Elapsed = 0;
                        }
                        foreach (LiteDbAction liteDbAction in liteDbActivity.ActionsColl)
                        {
                            List <string> newScreenShotsList = new List <string>();
                            if (liteDbAction.Elapsed.HasValue)
                            {
                                liteDbAction.Elapsed = Math.Round(liteDbAction.Elapsed.Value / 1000, 4);
                            }
                            else
                            {
                                liteDbAction.Elapsed = 0;
                            }
                            if ((!string.IsNullOrEmpty(liteDbAction.ExInfo)) && liteDbAction.ExInfo[liteDbAction.ExInfo.Length - 1] == '-')
                            {
                                liteDbAction.ExInfo = liteDbAction.ExInfo.Remove(liteDbAction.ExInfo.Length - 1);
                            }
                            foreach (string screenshot in liteDbAction.ScreenShots)
                            {
                                string fileName          = Path.GetFileName(screenshot);
                                string newScreenshotPath = Path.Combine(imageFolderPath, fileName);
                                if (File.Exists(screenshot))
                                {
                                    System.IO.File.Copy(screenshot, newScreenshotPath, true); //TODO - Replace with the real location under Ginger installation
                                    newScreenShotsList.Add(fileName);
                                }
                            }
                            liteDbAction.ScreenShots = newScreenShotsList;
                        }
                    }
                }
            }

            if (runSetEnv.Count > 0)
            {
                liteDbRunSet.Environment = string.Join(",", runSetEnv);
            }
        }
Example #18
0
        private void AddDeafultReportTemplate()
        {
            HTMLReportConfiguration r = new HTMLReportConfiguration("Default", true);

            WorkSpace.Instance.SolutionRepository.AddRepositoryItem(r);
        }
Example #19
0
 public abstract string CalculateExecutionJsonData(LiteDBFolder.LiteDbRunSet liteDbRunSet, HTMLReportConfiguration reportTemplate);
Example #20
0
        public override string CalculateExecutionJsonData(LiteDbRunSet liteDbRunSet, HTMLReportConfiguration reportTemplate)
        {
            CentralExecutionLoggerHelper centralExecutionLogger = new CentralExecutionLoggerHelper();
            AccountReportRunSet          accountReportRunSet    = centralExecutionLogger.MapDataToAccountReportObject(liteDbRunSet);
            string json = JsonConvert.SerializeObject(accountReportRunSet, Formatting.Indented);

            JObject runSetObject = JObject.Parse(json);

            #region Generate JSON

            //Remove Fields from json which are not selected
            foreach (HTMLReportConfigFieldToSelect runsetFieldToRemove in reportTemplate.RunSetSourceFieldsToSelect.Where(x => !x.IsSelected))
            {
                runSetObject.Property(GetFieldToRemove(runsetFieldToRemove.FieldKey)).Remove();
            }

            //RunnersCollection
            HTMLReportConfigFieldToSelect runnerField = reportTemplate.RunSetSourceFieldsToSelect.Where(x => x.IsSelected && x.FieldKey == "RunnersColl").FirstOrDefault();
            if (runnerField != null)
            {
                if (reportTemplate.GingerRunnerSourceFieldsToSelect.Select(x => x.IsSelected).ToList().Count > 0)
                {
                    JArray runnerArray = (JArray)runSetObject[runnerField.FieldKey];
                    foreach (JObject jRunnerObject in runnerArray)
                    {
                        foreach (HTMLReportConfigFieldToSelect runnerFieldToRemove in reportTemplate.GingerRunnerSourceFieldsToSelect.Where(x => !x.IsSelected))
                        {
                            jRunnerObject.Property(GetFieldToRemove(runnerFieldToRemove.FieldKey)).Remove();
                        }
                        //BusinessFlowsCollection
                        HTMLReportConfigFieldToSelect bfField = reportTemplate.GingerRunnerSourceFieldsToSelect.Where(x => x.IsSelected && x.FieldKey == "BusinessFlowsColl").FirstOrDefault();
                        if (bfField != null)
                        {
                            if (reportTemplate.BusinessFlowSourceFieldsToSelect.Select(x => x.IsSelected).ToList().Count > 0)
                            {
                                JArray bfArray = (JArray)jRunnerObject[bfField.FieldKey];
                                foreach (JObject jBFObject in bfArray)
                                {
                                    foreach (HTMLReportConfigFieldToSelect bfFieldToRemove in reportTemplate.BusinessFlowSourceFieldsToSelect.Where(x => !x.IsSelected))
                                    {
                                        jBFObject.Property(GetFieldToRemove(bfFieldToRemove.FieldKey)).Remove();
                                    }
                                    //ActivityGroupsCollection
                                    HTMLReportConfigFieldToSelect activityGroupField = reportTemplate.BusinessFlowSourceFieldsToSelect.Where(x => x.IsSelected && x.FieldKey == "ActivitiesGroupsColl").FirstOrDefault();
                                    if (activityGroupField != null)
                                    {
                                        if (reportTemplate.ActivityGroupSourceFieldsToSelect.Select(x => x.IsSelected).ToList().Count > 0)
                                        {
                                            JArray activityGroupArray = (JArray)jBFObject[activityGroupField.FieldKey];
                                            foreach (JObject jActivityGroupObject in activityGroupArray)
                                            {
                                                foreach (HTMLReportConfigFieldToSelect activityGroupFieldToRemove in reportTemplate.ActivityGroupSourceFieldsToSelect.Where(x => !x.IsSelected))
                                                {
                                                    jActivityGroupObject.Property(GetFieldToRemove(activityGroupFieldToRemove.FieldKey)).Remove();
                                                }
                                                //ActivitiesCollection
                                                HTMLReportConfigFieldToSelect activityFieldCheck = reportTemplate.ActivityGroupSourceFieldsToSelect.Where(x => x.IsSelected && x.FieldKey == "ActivitiesColl").FirstOrDefault();
                                                if (activityFieldCheck != null)
                                                {
                                                    if (reportTemplate.ActivitySourceFieldsToSelect.Select(x => x.IsSelected).ToList().Count > 0)
                                                    {
                                                        JArray activityArray = (JArray)jActivityGroupObject[activityFieldCheck.FieldKey];
                                                        foreach (JObject jActivityObject in activityArray)
                                                        {
                                                            //Calculate ErrorDetails And add it to Activity Level
                                                            StringBuilder errorDetailsNew = new StringBuilder();
                                                            string        errorDetails    = null;
                                                            JArray        actionsArray    = (JArray)jActivityObject["ActionsColl"];
                                                            foreach (JObject jActionObject in actionsArray)
                                                            {
                                                                if (!string.IsNullOrEmpty(jActionObject.Property("Error").Value.ToString()) && !string.IsNullOrEmpty(errorDetailsNew.ToString()))
                                                                {
                                                                    errorDetailsNew.Append(",");
                                                                    errorDetailsNew.Append(jActionObject.Property("Error").Value.ToString());
                                                                }
                                                                else
                                                                {
                                                                    errorDetailsNew.Append(jActionObject.Property("Error").Value.ToString());
                                                                }
                                                            }
                                                            if (string.IsNullOrEmpty(errorDetailsNew.ToString()))
                                                            {
                                                                errorDetails = "NA";
                                                            }
                                                            else
                                                            {
                                                                errorDetails = errorDetailsNew.ToString();
                                                            }
                                                            jActivityObject.Add("ErrorDetails", errorDetails);

                                                            foreach (HTMLReportConfigFieldToSelect activityFieldToRemove in reportTemplate.ActivitySourceFieldsToSelect.Where(x => !x.IsSelected))
                                                            {
                                                                jActivityObject.Property(GetFieldToRemove(activityFieldToRemove.FieldKey)).Remove();
                                                            }
                                                            //ActionsColl
                                                            HTMLReportConfigFieldToSelect actionField = reportTemplate.ActivitySourceFieldsToSelect.Where(x => x.IsSelected && x.FieldKey == "ActionsColl").FirstOrDefault();
                                                            if (actionField != null)
                                                            {
                                                                if (reportTemplate.ActionSourceFieldsToSelect.Select(x => x.IsSelected).ToList().Count > 0)
                                                                {
                                                                    JArray actionArray = (JArray)jActivityObject[actionField.FieldKey];
                                                                    foreach (JObject jActionObject in actionArray)
                                                                    {
                                                                        foreach (HTMLReportConfigFieldToSelect actionFieldToRemove in reportTemplate.ActionSourceFieldsToSelect.Where(x => !x.IsSelected))
                                                                        {
                                                                            jActionObject.Property(GetFieldToRemove(actionFieldToRemove.FieldKey)).Remove();
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            return(runSetObject.ToString(Formatting.Indented));
        }
 public override string CalculateExecutionJsonData(LiteDBFolder.LiteDbRunSet liteDbRunSet, HTMLReportConfiguration reportTemplate)
 {
     throw new NotImplementedException();
 }