Ejemplo n.º 1
0
        private void DeleteSelectedExecutionResults(object sender, System.Windows.RoutedEventArgs e)
        {
            if ((Reporter.ToUser(eUserMsgKey.ExecutionsResultsToDelete)) == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
            {
                foreach (RunSetReport runSetReport in grdExecutionsHistory.Grid.SelectedItems)
                {
                    if (runSetReport.DataRepMethod == ExecutionLoggerConfiguration.DataRepositoryMethod.LiteDB)
                    {
                        LiteDbManager       dbManager  = new LiteDbManager(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder);
                        var                 result     = dbManager.GetRunSetLiteData();
                        List <LiteDbRunSet> filterData = null;
                        filterData = result.IncludeAll().Find(a => a._id.ToString() == runSetReport.GUID).ToList();

                        LiteDbConnector dbConnector = new LiteDbConnector(Path.Combine(mRunSetExecsRootFolder, "GingerExecutionResults.db"));
                        dbConnector.DeleteDocumentByLiteDbRunSet(filterData[0]);
                        break;
                    }
                    string runSetFolder = executionLoggerHelper.GetLoggerDirectory(runSetReport.LogFolder);

                    var fi = new DirectoryInfo(runSetFolder);
                    CleanDirectory(fi.FullName);
                    fi.Delete();
                }

                if (grdExecutionsHistory.Grid.SelectedItems.Count > 0)
                {
                    LoadExecutionsHistoryData();
                }
            }
        }
Ejemplo n.º 2
0
        private void DeleteExecutionReports(System.Collections.IList runSetReports)
        {
            foreach (RunSetReport runSetReport in runSetReports)
            {
                if (runSetReport.DataRepMethod == ExecutionLoggerConfiguration.DataRepositoryMethod.LiteDB)
                {
                    LiteDbManager       dbManager  = new LiteDbManager(executionLoggerHelper.GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
                    var                 result     = dbManager.GetRunSetLiteData();
                    List <LiteDbRunSet> filterData = null;
                    filterData = result.IncludeAll().Find(a => a._id.ToString() == runSetReport.GUID).ToList();

                    LiteDbConnector dbConnector = new LiteDbConnector(Path.Combine(mRunSetExecsRootFolder, "GingerExecutionResults.db"));
                    dbConnector.DeleteDocumentByLiteDbRunSet(filterData[0]);
                }
                else
                {
                    string runSetFolder = executionLoggerHelper.GetLoggerDirectory(runSetReport.LogFolder);

                    var fi = new DirectoryInfo(runSetFolder);
                    CleanDirectory(fi.FullName);
                    fi.Delete();
                }
            }

            if (grdExecutionsHistory.Grid.SelectedItems.Count > 0)
            {
                LoadExecutionsHistoryData();
            }
        }
Ejemplo n.º 3
0
        // TODO: Make this function to just generate the report folder !!!
        public LiteDbRunSet RunNewHtmlReport(string runSetGuid = null, WebReportFilter openObject = null, bool shouldDisplayReport = true)
        {
            LiteDbRunSet lightDbRunSet = new LiteDbRunSet();
            bool         response      = false;

            try
            {
                string clientAppFolderPath = Path.Combine(WorkSpace.Instance.LocalUserApplicationDataFolderPath, "Reports", "Ginger-Web-Client");
                if (!Directory.Exists(clientAppFolderPath))
                {
                    return(lightDbRunSet);
                }
                DeleteFoldersData(Path.Combine(clientAppFolderPath, "assets", "Execution_Data"));
                DeleteFoldersData(Path.Combine(clientAppFolderPath, "assets", "screenshots"));
                LiteDbManager dbManager = new LiteDbManager(new ExecutionLoggerHelper().GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
                lightDbRunSet = dbManager.GetLatestExecutionRunsetData(runSetGuid);
                PopulateMissingFields(lightDbRunSet, clientAppFolderPath);
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(lightDbRunSet);
                response = RunClientApp(json, clientAppFolderPath, openObject, shouldDisplayReport);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "RunNewHtmlReport,error :" + ex.ToString());
            }
            return(lightDbRunSet);
        }
Ejemplo n.º 4
0
        // TODO: Make this function to just generate the report folder !!!
        public LiteDbRunSet RunNewHtmlReport(string reportResultsFolderPath = "", string runSetGuid = null, WebReportFilter openObject = null, bool shouldDisplayReport = true)
        {
            //Copy folder to reportResultsFolderPath or Execution logger
            string reportsResultFolder = string.Empty;

            if (!string.IsNullOrEmpty(reportResultsFolderPath))
            {
                reportsResultFolder = reportResultsFolderPath;
            }
            else
            {
                HTMLReportsConfiguration currentConf = WorkSpace.Instance.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
                reportsResultFolder = Path.Combine(ExtensionMethods.GetReportDirectory(currentConf.HTMLReportsFolder), "Reports", "Ginger-Web-Client");
            }
            try
            {
                string clientAppFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Reports", "Ginger-Web-Client");
                Reporter.ToLog(eLogLevel.INFO, "Copying web report folder from: " + clientAppFolderPath);

                Reporter.ToLog(eLogLevel.INFO, "Copying web report folder to: " + reportsResultFolder);
                if (Directory.Exists(clientAppFolderPath))
                {
                    string rootFolder = Path.Combine(reportsResultFolder);
                    if (Directory.Exists(rootFolder))
                    {
                        IoHandler.Instance.TryFolderDelete(rootFolder);
                    }
                    IoHandler.Instance.CopyFolderRec(clientAppFolderPath, reportsResultFolder, true);
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Check WebReportFolder Error: " + ex.Message, ex);
            }

            //get exeution data and replace
            LiteDbRunSet lightDbRunSet = new LiteDbRunSet();
            bool         response      = false;

            try
            {
                if (!Directory.Exists(reportsResultFolder))
                {
                    return(lightDbRunSet);
                }
                IoHandler.Instance.DeleteFoldersData(Path.Combine(reportsResultFolder, "assets", "Execution_Data"));
                IoHandler.Instance.DeleteFoldersData(Path.Combine(reportsResultFolder, "assets", "screenshots"));
                LiteDbManager dbManager = new LiteDbManager(new ExecutionLoggerHelper().GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
                lightDbRunSet = dbManager.GetLatestExecutionRunsetData(runSetGuid);
                PopulateMissingFields(lightDbRunSet, reportsResultFolder);
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(lightDbRunSet);
                response = RunClientApp(json, reportsResultFolder, openObject, shouldDisplayReport);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "RunNewHtmlReport,error :" + ex.ToString());
            }
            return(lightDbRunSet);
        }
Ejemplo n.º 5
0
        public void FindAllTest()
        {
            string        connectionString = "demo.txt";
            LiteDbManager target           = new LiteDbManager(connectionString, "demo");
            var           result           = target.FindAll <Demo>();

            Assert.True(result.Count > 0);
        }
        public void PopulateDatabases()
        {
            Setup();
            LiteDbManager.BeginTransaction();

            Insert_X_Objects(StartingSize, ObjectPadding, "PopulateDatabase");

            LiteDbManager.Commit();
            LiteDbManager.CloseDatabase();
        }
        public static void Insert_X_Objects(int X, int ObjectPadding = 0, string runName = "Insert_X_Objects")
        {
            Parallel.For(0, X, i =>
            {
                var obj = GetRandomObject(ObjectPadding);
                LiteDbManager.Write(obj, runName);
                BagOfObjects.Add(obj);
            });

            while (LiteDbManager.HasElements())
            {
                Thread.Sleep(1);
            }
        }
Ejemplo n.º 8
0
        public override async Task <bool> SendExecutionLogToCentralDBAsync(LiteDB.ObjectId runsetId, Guid executionId, eDeleteLocalDataOnPublish deleteLocalData)
        {
            //Get the latest execution details from LiteDB
            LiteDbManager dbManager      = new LiteDbManager(new ExecutionLoggerHelper().GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
            LiteDbRunSet  liteDbRunSet   = dbManager.GetLatestExecutionRunsetData(runsetId?.ToString());
            List <string> screenshotList = PopulateMissingFieldsAndGetScreenshotsList(liteDbRunSet, executionId);

            CentralExecutionLoggerHelper centralExecutionLogger = new CentralExecutionLoggerHelper(WorkSpace.Instance.Solution.LoggerConfigurations.CentralLoggerEndPointUrl);

            //Map the data to AccountReportRunset Object
            AccountReportRunSet accountReportRunSet = centralExecutionLogger.MapDataToAccountReportObject(liteDbRunSet);

            accountReportRunSet.ExecutionId = executionId;


            //Publish the Data and screenshots to Central DB
            await centralExecutionLogger.SendRunsetExecutionDataToCentralDBAsync(accountReportRunSet);

            await centralExecutionLogger.SendScreenShotsToCentralDBAsync(executionId, screenshotList);


            //Delete local data if configured
            if (deleteLocalData == eDeleteLocalDataOnPublish.Yes)
            {
                try
                {
                    dbManager.DeleteDocumentByLiteDbRunSet(liteDbRunSet);
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Error when deleting local LiteDB data after Publis", ex);
                }


                foreach (string screenshot in screenshotList)
                {
                    try
                    {
                        File.Delete(screenshot);
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.DEBUG, "Deleting screenshots after published to central db", ex);
                    }
                }
            }


            return(true);
        }
Ejemplo n.º 9
0
        public void InsertTest()
        {
            var demo = new Demo {
                Id = Guid.NewGuid().ToString("n"), Name = "测试"
            };
            string        connectionString = "demo.txt";
            LiteDbManager target           = new LiteDbManager(connectionString, "demo");
            BsonValue     inserted         = target.Insert <Demo>(demo);

            Assert.NotNull(inserted);

            var result = target.FindAll <Demo>();

            Assert.True(result.Count > 0);
        }
Ejemplo n.º 10
0
        private void GenerateBFReport(BusinessFlow bf)
        {
            try
            {
                LiteDbManager dbManager = new LiteDbManager(WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
                var           result    = dbManager.GetRunSetLiteData();

                List <LiteDbRunSet> filterData = dbManager.FilterCollection(result, Query.All());

                LiteDbRunSet runSetLast = filterData.Last();
                //runSetLast._id = new ObjectId();

                LiteDbRunner runnerFilter = runSetLast.RunnersColl.Find(r => r.GUID.ToString() == mRunner.Guid.ToString());
                //runnerFilter._id = new ObjectId();
                //runSetLast.RunnersColl = new List<LiteDbRunner>() { runnerFilter };

                LiteDbBusinessFlow bfFilter = runnerFilter.BusinessFlowsColl.Find(b => b.GUID.ToString() == bf.Guid.ToString() && b.StartTimeStamp.ToString() == bf.StartTimeStamp.ToLocalTime().ToString());
                if (bfFilter == null)
                {
                    Reporter.ToUser(eUserMsgKey.BFNotExistInDB);
                    return;
                }
                //runnerFilter.RunStatus = bfFilter.RunStatus;
                //runSetLast.RunStatus = runnerFilter.RunStatus;
                //runnerFilter.BusinessFlowsColl = new List<LiteDbBusinessFlow>() { bfFilter };

                //dbManager.WriteToLiteDb(dbManager.NameInDb<LiteDbRunner>(), new List<LiteDbReportBase>() { runnerFilter });
                //dbManager.WriteToLiteDb(dbManager.NameInDb<LiteDbRunSet>(), new List<LiteDbReportBase>() { runSetLast });


                WebReportGenerator webReporterRunner = new WebReportGenerator();
                webReporterRunner.RunNewHtmlReport(string.Empty, runSetLast._id.ToString(), new WebReportFilter()
                {
                    Guid = bfFilter.GUID.ToString()
                });

                //var newRSData = dbManager.GetRunSetLiteData();
                //newRSData.Delete(runSetLast._id);
                //var newRunnerData = dbManager.GetRunnerLiteData();
                //newRunnerData.Delete(runnerFilter._id);
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 11
0
        // private int runsetSeq = 0;

        public LiteDBRepository()
        {
            liteDbManager = new LiteDbManager(executionLoggerHelper.GetLoggerDirectory(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder));
        }
Ejemplo n.º 12
0
        public void WriteToLiteDbFromObject()
        {
            LiteDbManager dbManager = new LiteDbManager();

            dbManager.WriteToLiteDb();
        }
 public void IterationSetup()
 {
     Setup();
     LiteDbManager.BeginTransaction();
 }
 public void IterationCleanup()
 {
     LiteDbManager.CloseDatabase();
 }
 public void GlobalCleanup()
 {
     Setup();
     LiteDbManager.Destroy();
 }
 private void Setup()
 {
     LiteDbManager.Setup(filename: $"AsaBenchmark_{Shards}.litedb");
 }