Example #1
0
 public abstract Task <bool> SendExecutionLogToCentralDBAsync(LiteDB.ObjectId runsetId, Guid executionId, eDeleteLocalDataOnPublish deleteLocalData);
 public override async Task <bool> SendExecutionLogToCentralDBAsync(LiteDB.ObjectId runsetId, Guid executionId, eDeleteLocalDataOnPublish deleteLocalData)
 {
     throw new NotImplementedException();
 }
Example #3
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);
        }