public async Task AddLogAsync(IOperationLog log)
        {
            var logEntity = OperationLogEntity.Create(log, _dateService.Now());

            using (var conn = new SqlConnection(_connectionString))
            {
                await conn.ExecuteAsync(
                    $"insert into {_tableName} ({GetColumns}) values ({GetFields})", logEntity);
            }
        }
예제 #2
0
        protected void WirteOperationRecord(string tableName, string type, string desc, string details)
        {
            IApplicationContext ctx = ContextRegistry.GetContext();

            log.Create();
            log.logType             = "GUID";
            log.operationType       = type.ToString();
            log.operationTable      = tableName;
            log.operationDesc       = desc;
            log.logDetails          = details;
            log.operationModuleGuid = "0";
            log.logLevel            = "INFO";
            (ctx.GetObject("OperationLogApp") as IOperationLogApp).SubmitFormAsync(log, "");
        }
예제 #3
0
        public async Task <ActionResult> CheckLogin(LoginInputDto loginInput)
        {
            log.operationType = "SELECT";
            log.operationDesc = "查询";
            var ajaxObj = new AjaxResult();

            try
            {
                var entity = await accountApp.CheckLoginAsync(loginInput);

                entity.LoginIPAddress     = Net.Ip;
                entity.LoginIPAddressName = Net.GetLocation(entity.LoginIPAddress);
                entity.LoginTime          = DateTime.Now;
                entity.LoginToken         = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                OperatorProvider.Provider.AddCurrent(entity);
                log.logDetails    = "登录成功";
                log.creatorUserId = entity.UserId;
                ajaxObj.state     = ResultType.success.ToString();
            }
            catch (ProgramLogicException ex)
            {
                ajaxObj.state     = ResultType.error.ToString();
                ajaxObj.message   = (new { message = ex.Message.ToString(), errorCode = LoginResultType.loginFail }).ToJson();
                log.creatorUserId = "游客";
                log.logDetails    = ex.Message.ToString();
                LogFactory.GetLogger(typeof(LoginController)).Info(log);
            }
            catch (Exception ex)
            {
                ajaxObj.state   = ResultType.error.ToString();
                ajaxObj.message = (new { message = ex.Message.ToString(), errorCode = LoginResultType.loginFail }).ToJson();
                log.logDetails  = ex.Message.ToString();
                log.logType     = "ERROR";
                log.logLevel    = "ERROR";
            }
            finally
            {
                log.Create();
                await logApp.SubmitFormAsync(log, "");
            }
            return(Content(ajaxObj.ToJson()));
        }
 public async Task AddLogAsync(IOperationLog logEntity)
 {
     var entity = OperationLogEntity.Create(logEntity);
     await _tableStorage.InsertAndGenerateRowKeyAsTimeAsync(entity, DateTime.UtcNow);
 }