Ejemplo n.º 1
0
        public static LoggingTime PerformanceTimeStart(
            string domainName,
            string layerName,
            string className,
            string methodName,
            Guid?userId = null
            )
        {
            var log = new LoggingTime();

            log.DomainName = domainName;
            log.LayerName  = layerName;
            log.ClassName  = className;
            log.MethodName = methodName;

            if (userId != null)
            {
                log.UserId = ( Guid )userId;
            }

            log.StopWatch = new Stopwatch();
            log.StopWatch.Start();

            return(log);
        }
Ejemplo n.º 2
0
        public static LoggingTime PerformanceTimeStart(
            string commandName
            )
        {
            var log = new LoggingTime();

            log.MethodName = commandName;
            log.StopWatch  = new Stopwatch();
            log.StopWatch.Start();

            return(log);
        }
Ejemplo n.º 3
0
        private void TryCall(
            string systemName,
            string testArea,
            string url
            )
        {
            var    client = new WebClient();
            string html   = string.Empty;
            WebHeaderCollection headers = null;

            var test = new CrudeDefaultTestContract();

            test.DefaultTestId = Guid.NewGuid();
            test.SystemName    = systemName;
            test.TestArea      = testArea;
            test.TestSubArea   = " ";
            test.TestAddress   = url;
            test.DateTime      = DateTime.UtcNow;
            test.UserId        = DefaultUserId;

            var testRun = new CrudeDefaultTestRunContract();

            testRun.DefaultTestId = test.DefaultTestId;
            testRun.DateTime      = DateTime.UtcNow;
            testRun.UserId        = DefaultUserId;

            try {
                testRun.StartDateTime = DateTime.UtcNow;

                // download page
                var time = LoggingTime.PerformanceTimeStart("tryCall");
                html = client.DownloadString(url);
                time.PerformanceTimeStop();

                testRun.ElapsedMilliseconds = ( int )time.StopWatch.ElapsedMilliseconds;
                testRun.EndDateTime         = DateTime.UtcNow;

                headers        = client.ResponseHeaders;
                testRun.Result = headers.ToString();

                testRun.DefaultTestRunResultRcd = DefaultTestRunResultRef.OK;
            } catch (WebException ex) {
                testRun.DefaultTestRunResultRcd = DefaultTestRunResultRef.WebException;
                testRun.Result = "Status: " + ex.Status + ", Response: " + ex.Response + " : " + url;
                Error(ex);
            } catch (Exception ex) {
                testRun.DefaultTestRunResultRcd = DefaultTestRunResultRef.Exception;
                testRun.Result = "Message: " + ex.Message + " : " + url;
                Error(ex);
            }

            // truncate result
            if (testRun.Result.Length > 240)
            {
                testRun.Result = testRun.Result.Substring(0, 240);
            }

            try {
                //new CrudeDefaultTestServiceClient().Insert(test);
                //new CrudeDefaultTestRunServiceClient().Insert(testRun);

                var defaultTest = new DefaultTestServiceClient();
                defaultTest.AddTestRun(
                    test.SystemName, test.TestArea, test.TestSubArea, test.TestAddress,
                    testRun.StartDateTime, testRun.EndDateTime, testRun.ElapsedMilliseconds, testRun.DefaultTestRunResultRcd,
                    testRun.Result, testRun.UserId
                    );
            } catch (Exception ex) {
                Error(ex);
            }

            Log(systemName, testArea, testRun.DefaultTestRunResultRcd);
        }