Exemple #1
0
        /// <summary>
        /// Prints the results of a step execution
        /// </summary>
        /// <returns>return a flag to indicate success or error</returns>
        public int Print(LogObject log)
        {
            DateTime occurred = DateTime.Now.ToUniversalTime();
            int      result   = -1;

            string dateFromUnixTime = ConvertFromUnixTimestamp(log.ExecutionID).ToString("dd/MM/yyyy_HH:mm:ss");

            dateFromUnixTime = dateFromUnixTime.Replace(" ", "_");

            switch (log.StatusTag)
            {
            case ResultStatus.INFO: ClientLogger logger = new ClientLogger();
                logger.Description = log.Description;
                logger.StatusTag   = log.StatusTag;
                logger.printLog(log.StatusTag);
                insertToDB(log);
                break;

            case ResultStatus.ERROR: ClientLogger loggerError = new ClientLogger();
                loggerError.Description        = log.Description + " - " + log.StepName;
                loggerError.StatusTag          = log.StatusTag;
                loggerError.ExecutionID        = log.ExecutionID;
                loggerError.BatchName          = log.BatchName;
                loggerError.BatchStatus        = log.BatchStatus;
                loggerError.ScnearioName       = log.ScnearioName;
                loggerError.ScenarioStatus     = log.ScenarioStatus;
                loggerError.TestName           = log.TestName;
                loggerError.SnapShot           = log.Snapshot;
                loggerError.TestStatus         = log.TestStatus;
                loggerError.StepName           = log.StepName;
                loggerError.StepStatus         = log.StepStatus;
                loggerError.ProjectName        = log.ProjectName;
                loggerError.ProjectPageName    = log.ProjectPageName;
                loggerError.ExecutionTimeStamp = dateFromUnixTime;
                loggerError.Browser            = log.Browser;
                loggerError.printLog(log.StatusTag);
                insertToDB(log);
                break;


            case ResultStatus.FAILED: ClientLogger loggerFailed = new ClientLogger();
                loggerFailed.Description        = log.Description;
                loggerFailed.StatusTag          = log.StatusTag;
                loggerFailed.ExecutionID        = log.ExecutionID;
                loggerFailed.BatchName          = log.BatchName;
                loggerFailed.BatchStatus        = log.BatchStatus;
                loggerFailed.ScnearioName       = log.ScnearioName;
                loggerFailed.ScenarioStatus     = log.ScenarioStatus;
                loggerFailed.TestName           = log.TestName;
                loggerFailed.TestStatus         = log.TestStatus;
                loggerFailed.SnapShot           = log.Snapshot;
                loggerFailed.StepName           = log.StepName;
                loggerFailed.StepStatus         = log.StepStatus;
                loggerFailed.ProjectName        = log.ProjectName;
                loggerFailed.ProjectPageName    = log.ProjectPageName;
                loggerFailed.ExecutionTimeStamp = dateFromUnixTime;
                loggerFailed.Browser            = log.Browser;
                loggerFailed.printLog(log.StatusTag);
                insertToDB(log);
                break;

            case ResultStatus.PASSED: ClientLogger loggerPassed = new ClientLogger();
                loggerPassed.Description        = log.Description;
                loggerPassed.StatusTag          = log.StatusTag;
                loggerPassed.ExecutionID        = log.ExecutionID;
                loggerPassed.BatchName          = log.BatchName;
                loggerPassed.BatchStatus        = log.BatchStatus;
                loggerPassed.ScnearioName       = log.ScnearioName;
                loggerPassed.ScenarioStatus     = log.ScenarioStatus;
                loggerPassed.TestName           = log.TestName;
                loggerPassed.TestStatus         = log.TestStatus;
                loggerPassed.StepName           = log.StepName;
                loggerPassed.StepStatus         = log.StepStatus;
                loggerPassed.ProjectName        = log.ProjectName;
                loggerPassed.ProjectPageName    = log.ProjectPageName;
                loggerPassed.ExecutionTimeStamp = dateFromUnixTime;
                loggerPassed.Browser            = log.Browser;
                loggerPassed.printLog(log.StatusTag);
                insertToDB(log);
                break;

            case ResultStatus.DONE: ClientLogger loggerDone = new ClientLogger();
                loggerDone.Description        = log.Description;
                loggerDone.StatusTag          = log.StatusTag;
                loggerDone.ExecutionID        = log.ExecutionID;
                loggerDone.BatchName          = log.BatchName;
                loggerDone.BatchStatus        = log.BatchStatus;
                loggerDone.ScnearioName       = log.ScnearioName;
                loggerDone.ScenarioStatus     = log.ScenarioStatus;
                loggerDone.TestName           = log.TestName;
                loggerDone.TestStatus         = log.TestStatus;
                loggerDone.StepName           = log.StepName;
                loggerDone.StepStatus         = log.StepStatus;
                loggerDone.ProjectName        = log.ProjectName;
                loggerDone.ProjectPageName    = log.ProjectPageName;
                loggerDone.ExecutionTimeStamp = dateFromUnixTime;
                loggerDone.Browser            = log.Browser;
                loggerDone.printLog(log.StatusTag);
                insertToDB(log);
                break;

            case ResultStatus.DEBUG: ClientLogger loggerDebug = new ClientLogger();
                loggerDebug.Description        = log.Description;
                loggerDebug.StatusTag          = log.StatusTag;
                loggerDebug.ExecutionID        = log.ExecutionID;
                loggerDebug.BatchName          = log.BatchName;
                loggerDebug.BatchStatus        = log.BatchStatus;
                loggerDebug.ScnearioName       = log.ScnearioName;
                loggerDebug.ScenarioStatus     = log.ScenarioStatus;
                loggerDebug.TestName           = log.TestName;
                loggerDebug.TestStatus         = log.TestStatus;
                loggerDebug.StepName           = log.StepName;
                loggerDebug.StepStatus         = log.StepStatus;
                loggerDebug.ProjectName        = log.ProjectName;
                loggerDebug.ProjectPageName    = log.ProjectPageName;
                loggerDebug.ExecutionTimeStamp = dateFromUnixTime;
                loggerDebug.Browser            = log.Browser;
                loggerDebug.printLog(log.StatusTag);
                insertToDB(log);
                break;


            default: ClientLogger defaultLog = new ClientLogger();
                defaultLog.Description  = "No status code on log event.";
                defaultLog.StatusTag    = 5;
                defaultLog.ScnearioName = log.ScnearioName;
                defaultLog.printLog(5);
                break;
            }


            return(result);
        }