protected BaseLogModel GetLogModel(string sqlcommand) { BaseLogModel baseLogModel = new BaseLogModel() { Type = 5, ServiceName = _logOptions.ServiceName, Content = sqlcommand }; return(baseLogModel); }
public static List <BaseLogModel> CreateBaseLog(BaseLogModel baseLog) { using (IDbConnection cnn = new MySqlConnection(LoadConnectionString())) { cnn.Execute("INSERT INTO baselog(OperationID, StoreID, CreatedDate, UserID) " + "VALUES (@OperationID, @StoreID, @CreatedDate, @UserID)", baseLog); var output = cnn.Query <BaseLogModel>("SELECT * FROM baselog ORDER BY BaseLogID DESC LIMIT 1", new DynamicParameters()); return(output.ToList()); } }
public async Task Invoke(DownstreamContext context) { //保存请求的信息 BaseLogModel logModel = new BaseLogModel() { Type = 1, Content = GetLogConent(context.HttpContext), ServiceName = _logOptions.ServiceName }; _log.Info <BaseLogModel>(logModel); await _next(context); }
private void btnCreateBaseLog_Click(object sender, EventArgs e) { BaseLogModel bl = new BaseLogModel( operationID, Properties.Settings.Default.StoreID, DateTime.Now, Properties.Settings.Default.UserID ); currentBaseLog = SqliteDataAccess.CreateBaseLog(bl); baseLogs = SqliteDataAccess.LoadBaseLogs(operationID); dgvBaseLog.DataSource = baseLogs; RunOperation(currentBaseLog[0].BaseLogID); }
public async Task Invoke(DownstreamContext context) { await _next.Invoke(context); if (context.IsError) { //保存请求的信息 BaseLogModel logModel = new BaseLogModel() { Type = 1, Content = $"{context.ToErrorString()} errors found in {MiddlewareName}. Setting error response for request path:{context.HttpContext.Request.Path}, request method: {context.HttpContext.Request.Method}" }; _log.Error(logModel); SetErrorResponse(context.HttpContext, context.Errors); } else { //Logger.LogDebug("no pipeline errors, setting and returning completed response"); await _responder.SetResponseOnHttpContext(context.HttpContext, context.DownstreamResponse); } }
/// <summary> /// 返回错误格式 /// </summary> /// <param name="context"></param> /// <param name="statusCode"></param> /// <param name="msg"></param> /// <returns></returns> private Task HandleExceptionAsync(HttpContext context, int statusCode, string msg) { ErrorResultModel errorModel = new ErrorResultModel() { Message = msg, Code = statusCode, RequestUri = context.Request.GetAbsoluteUri() }; BaseLogModel logModel = new BaseLogModel() { ServiceName = _logOptions.ServiceName, Type = 4, Content = msg }; //增加到日志 _log.Info <BaseLogModel>(logModel); var result = JsonConvert.SerializeObject(new { error = errorModel }); context.Response.ContentType = "application/json;charset=utf-8"; return(context.Response.WriteAsync(result)); }