Example #1
0
        public void Execute(IJobExecutionContext context)
        {
            lock (_lock)
            {
                if (_shuttingDown)
                {
                    return;
                }

                try
                {
                    if (isFirstStartService)
                    {
                        LotteryEngine.Init();
                        isFirstStartService = false;
                        LogDbHelper.LogInfo(string.Format("{0}彩种定时执行任务Job开始(First Start)", _LotteryType),
                                            GetType().FullName + "=>Start", OperationType.Job);
                        _dataUpdateContainer.Execute();
                    }
                    else
                    {
                        if (DateTime.Now > NextLotteryTime ||
                            NextLotteryTime - DateTime.Now < TimeSpan.FromSeconds(_lotteryUpdateConfig.Interval * 3))
                        {
                            _dataUpdateContainer.Execute();
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogDbHelper.LogFatal(ex, GetType() + "Execute", OperationType.Job);
                }
            }
        }
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            var exception = actionExecutedContext.Exception;

            //全局异常捕获,记录未被捕获的异常
            LogDbHelper.LogFatal(exception,
                                 actionExecutedContext.Request.RequestUri.OriginalString + "=>" + actionExecutedContext.Request.Method,
                                 OperationType.Exception
                                 );

            actionExecutedContext.Response =
                actionExecutedContext.Request.CreateResponse(HttpStatusCode.InternalServerError, ResponseUtils.ErrorResult <object>(exception));

            base.OnException(actionExecutedContext);
        }
Example #3
0
 protected virtual void WriteData <TEntity>(Func <TEntity, ValidationResult> func, TEntity entity)
     where TEntity : BaseEntity
 {
     BeginTransaction();
     ValidationResult.Add(func(entity));
     if (ValidationResult.IsValid)
     {
         if (!Commit())
         {
             throw new LSException("数据保存失败,Data:" + entity.ToJsonString() + ",Action:" + GetType().FullName + "=>" + func.Method.Name);
         }
         if (!ValidationResult.IsSet(LsConstant.AuditLogKey) || !ValidationResult.GetData <bool>(LsConstant.AuditLogKey))
         {
             LogDbHelper.LogInfo("数据保存成功.Data:" + entity.ToJsonString(), GetType().FullName + "=>" + func.Method.Name);
         }
     }
     else
     {
         LogDbHelper.LogFatal("数据保存失败,原因:" + ValidationResult.Errors.ToJsonString(), GetType().FullName + "=>" + func.Method.Name);
     }
 }