コード例 #1
0
        internal int LogResult(int runExecutionId, int batchId, int scenarioId, int testId, int stepId,
                               string description, int status, string outOfFlow, int projectId, int projectPageId)
        {
            try
            {
                int      result;
                string   batchName       = string.Empty;
                string   scenarioName    = string.Empty;
                string   testName        = string.Empty;
                string   stepName        = string.Empty;
                string   projectName     = string.Empty;
                string   projectPageName = string.Empty;
                DateTime occurred        = DateTime.Now.ToUniversalTime();
                using (var adapterLogresult = new TestResultsTableAdapter())
                {
                    result = adapterLogresult.Insert(runExecutionId, batchId, scenarioId, testId, stepId, description,
                                                     status, outOfFlow, projectId, projectPageId, occurred);
                }

                using (var adapterBatch = new BatchesTableAdapter())
                {
                    if (batchId != 0)
                    {
                        batchName = adapterBatch.GetBatchName(batchId);
                    }
                    else
                    {
                        batchName = Constants.LogNothing;
                    }
                }

                using (var adapterScenario = new ScenarioTableAdapter())
                {
                    if (scenarioId != 0)
                    {
                        scenarioName = adapterScenario.GetScenarioName(scenarioId);
                    }
                    else
                    {
                        scenarioName = Constants.LogNothing;
                    }
                }

                using (var adapterTest = new TestTableAdapter())
                {
                    if (testId != 0)
                    {
                        testName = adapterTest.GetTestName(testId);
                    }
                    else
                    {
                        testName = Constants.LogNothing;
                    }
                }

                using (var adapterGuiMap = new GuiMapTableAdapter())
                {
                    if (stepId != 0)
                    {
                        stepName = adapterGuiMap.GetGuiMapName(stepId).Trim();
                    }
                    else
                    {
                        stepName = Constants.LogNothing;
                    }
                }

                using (var adapterProject = new ProjectsTableAdapter())
                {
                    if (projectId != 0)
                    {
                        projectName = adapterProject.GetProjectName(projectId);
                    }
                    else
                    {
                        projectName = Constants.LogNothing;
                    }
                }

                using (var adapterProjectPage = new GuiProjectPageTableAdapter())
                {
                    if (projectPageId != 0)
                    {
                        projectPageName = adapterProjectPage.GetProjectPageName(projectPageId);
                    }
                    else
                    {
                        projectPageName = Constants.LogNothing;
                    }
                }


                string logString = String.Format("{0}={1}\t{2}={3}\t{4}={5}\t{6}={7}\t{8}={9}\t{10}=( {11} )\t{12}={13}\t{14}={15}",
                                                 Constants.LogExecutionId, runExecutionId,
                                                 Constants.LogBatchName, batchName,
                                                 Constants.LogScenarioName, scenarioName,
                                                 Constants.LogTestName, testName,
                                                 Constants.LogStepName, stepName,
                                                 Constants.LogDescription, description,
                                                 Constants.LogProjectName, projectName,
                                                 Constants.LogProjectPageName, projectPageName);
                if (status == Constants.Passed)
                {
                    Logger.Passed(logString);
                }
                if (status == Constants.Done)
                {
                    Logger.Done(logString);
                }
                if (status == Constants.Failed)
                {
                    Logger.Failed(logString);
                }

                return(result);
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);
                return(0);
            }
        }