public void Intercept(IInvocation invocation)
 {
     try
     {
         invocation.Proceed();
         dynamic returnValue = invocation.ReturnValue;
         returnValue.ResponseCode = ((int)ResponseCode.Success).ToString("d4");
         returnValue.ResponseText = ResponseCode.Success.ToString();
         invocation.ReturnValue   = returnValue;
     }
     catch (SchedulerServiceError schedulerServiceError)
     {
         if (invocation.Method.ReturnParameter != null)
         {
             SetResponseValues(invocation, schedulerServiceError.ErrorText,
                               (int)ResponseCode.SchedulerServiceError);
         }
     }
     catch (Exception ex)
     {
         var exceptionLogInfo = new ExceptionLogInfo(LogLevel.Error);
         exceptionLogInfo.Exception  = ex;
         exceptionLogInfo.Message    = (ex.Message + " \n " + ex.StackTrace).Replace("'", string.Empty);
         exceptionLogInfo.MethodName = invocation.Method.Name;
         exceptionLogInfo.ModuleName = invocation.Method.Module.Name;
         exceptionLogInfo.FileName   = invocation.Method.ReflectedType.Assembly.FullName;
         logger.Error(_jsonSerializer.Serialize(exceptionLogInfo));
         if (invocation.Method.ReturnParameter != null)
         {
             SetResponseValues(invocation, "Exception : " + ex.Message,
                               (int)ResponseCode.UnhandledError);
         }
     }
 }
Ejemplo n.º 2
0
        public HttpResponseMessage AddAppExceptionLog([FromBody] ExceptionLogInfo exceptionInfo)
        {
            try
            {
                int _result;

                //Update AppEventLog table
                _result = trackingService.AddAppExceptionLog(exceptionInfo.ExceptionText, exceptionInfo.PageName, exceptionInfo.MethodName, exceptionInfo.UserId, exceptionInfo.SiteId, exceptionInfo.TransSql, exceptionInfo.HttpReferrer);

                if (_result != 1)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Exception log updated"));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Exception log update failed"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("SiteId", exceptionInfo.SiteId);
                ex.Data.Add("UserId", exceptionInfo.UserId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/TrackingInfo/AddAppExceptionLog");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
        public void DeleteLog(Guid sysno)
        {
            ExceptionLogInfo logInfo = new ExceptionLogInfo()
            {
                SysNo = sysno
            };

            _logRepository.Delete(logInfo);
        }
        public void Log(LogLevel logLevel, Exception exception, string format, params object[] args)
        {
            IWebHelper _webHelper = EngineContext.Current.Resolve <IWebHelper>();

            var log = new ExceptionLogInfo()
            {
                Source          = exception.Source,
                InnerException  = exception.InnerException == null ? string.Empty : exception.InnerException.Message,
                EventStackTrace = exception == null ? string.Empty : exception.StackTrace,
                EventType       = exception == null ? string.Empty : exception.GetType().FullName,
                EventDetail     = exception == null ? string.Empty : exception.Message,
                EventMessage    = args == null || args.Length == 0 ? format : string.Format(format, args),
                HostName        = _webHelper.GetCurrentHostName(),
                LogLevelName    = logLevel.ToString(),
                IpAddress       = _webHelper.GetCurrentIpAddress(),
                PageUrl         = _webHelper.GetThisPageUrl(),
                ReferrerUrl     = _webHelper.GetUrlReferrer(),
            };

            _logRepository.Insert(log);
        }
Ejemplo n.º 5
0
        int Execute(string binaryPath, string[] exampleFullNames,
                    IProgressRecorder progressRecorder, ICrossDomainLogger logger)
        {
            string scenario = (exampleFullNames == RunnableContextFinder.RunAll ? "all" : "selected");

            logger.Debug(String.Format("Start executing {0} tests locally in binary '{1}'", scenario, binaryPath));

            int count;

            try
            {
                var runnableContextFinder = new RunnableContextFinder();

                var runnableContexts = runnableContextFinder.Find(binaryPath, exampleFullNames);

                var executedExampleMapper = new ExecutedExampleMapper();

                var executionReporter = new ExecutionReporter(progressRecorder, executedExampleMapper);

                var contextExecutor = new ContextExecutor(executionReporter, logger);

                count = contextExecutor.Execute(runnableContexts);
            }
            catch (Exception ex)
            {
                // report problem and return, without letting exception cross app domain boundary

                count = 0;

                var exInfo  = new ExceptionLogInfo(ex);
                var message = String.Format("Exception thrown while executing tests locally in binary '{0}'", binaryPath);

                logger.Error(exInfo, message);
            }

            logger.Debug(String.Format("Finish executing {0} tests locally in binary '{1}'", count, binaryPath));

            return(count);
        }
        public DiscoveredExample[] Discover(string binaryPath, ICrossDomainLogger logger)
        {
            logger.Debug(String.Format("Start discovering tests locally in binary '{0}'", binaryPath));

            DiscoveredExample[] discoveredExampleArray;

            try
            {
                var exampleFinder = new ExampleFinder();

                var examples = exampleFinder.Find(binaryPath);

                var debugInfoProvider = new DebugInfoProvider(binaryPath, logger);

                var discoveredExampleMapper = new DiscoveredExampleMapper(binaryPath, debugInfoProvider);

                var discoveredExamples = examples.Select(discoveredExampleMapper.FromExample);

                discoveredExampleArray = discoveredExamples.ToArray();
            }
            catch (Exception ex)
            {
                // report problem and return, without letting exception cross app domain boundary

                discoveredExampleArray = new DiscoveredExample[0];

                var exInfo  = new ExceptionLogInfo(ex);
                var message = String.Format("Exception thrown while discovering tests locally in binary '{0}'", binaryPath);

                logger.Error(exInfo, message);
            }

            logger.Debug(String.Format("Finish discovering {0} tests locally in binary '{1}'", discoveredExampleArray.Length, binaryPath));

            return(discoveredExampleArray);
        }
Ejemplo n.º 7
0
 public static ExceptionLogVM ToVM(this ExceptionLogInfo exceptionLog)
 {
     return(AutoMapper.Mapper.Map <ExceptionLogVM>(exceptionLog));
 }