public async Task <IActionResult> PutLogEntry([FromRoute] int id, [FromBody] LogEntry logEntry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != logEntry.LogEntryId) { return(BadRequest()); } _context.Entry(logEntry).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LogEntryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Response> PostLogEntry([FromBody] LogEntryTranfer logEntryTranfer) { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido, }); } try { var logLevelID = db.LogLevels.FirstOrDefault(l => l.ShortName.Contains(logEntryTranfer.LogLevelShortName)).LogLevelId; var logCategoryID = db.LogCategories.FirstOrDefault(l => l.ParameterValue.Contains(logEntryTranfer.LogCategoryParametre)).LogCategoryId; db.Add(new LogEntry { UserName = logEntryTranfer.UserName, ApplicationName = logEntryTranfer.ApplicationName, ExceptionTrace = (logEntryTranfer.ExceptionTrace != null) ? LogEntryHelper.GetAllErrorMsq(logEntryTranfer.ExceptionTrace) : null, LogCategoryId = logCategoryID, LogLevelId = logLevelID, LogDate = DateTime.Now, MachineIP = LogNetworkHelper.GetRemoteIpClientAddress(), MachineName = LogNetworkHelper.GetClientMachineName(), Message = logEntryTranfer.Message, ObjEntityId = logEntryTranfer.EntityID }); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio, }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.Logs), ExceptionTrace = ex, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } }
public async Task <Response> PutLogCategory([FromBody] LogCategory logCategory) { if (!ModelState.IsValid) { return(new entidades.Response { IsSuccess = false, Message = "Módelo inválido", }); } db.Entry(logCategory).State = EntityState.Modified; try { var respuesta = Existe(logCategory); if (!respuesta.IsSuccess) { await db.SaveChangesAsync(); return(new entidades.Response { IsSuccess = true, Message = "Ok", }); } return(new entidades.Response { IsSuccess = false, Message = "Existe un Log Category de igual Nombre...", }); } catch (Exception ex) { return(new entidades.Response { IsSuccess = false, Message = "Existe un Log Category de igual Nombre...", }); } }
public async Task <Response> PostLogEntry([FromBody] LogEntryTranfer logEntryTranfer) { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = "MÓDELO INVÁLIDO", }); } try { var logLevelID = db.LogLevels.FirstOrDefault(l => l.ShortName.Contains(logEntryTranfer.LogLevelShortName)).LogLevelId; var logCategoryID = db.LogCategories.FirstOrDefault(l => l.ParameterValue.Contains(logEntryTranfer.LogCategoryParametre)).LogCategoryId; db.Add(new LogEntry { UserName = logEntryTranfer.UserName, ApplicationName = logEntryTranfer.ApplicationName, ExceptionTrace = (logEntryTranfer.ExceptionTrace != null) ? LogEntryHelper.GetAllErrorMsq(logEntryTranfer.ExceptionTrace) : null, LogCategoryId = logCategoryID, LogLevelId = logLevelID, LogDate = DateTime.Now, MachineIP = LogNetworkHelper.GetRemoteIpClientAddress(), MachineName = LogNetworkHelper.GetClientMachineName(), Message = logEntryTranfer.Message, ObjEntityId = logEntryTranfer.EntityID }); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = "Ok", }); } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message, }); } }
public async Task <Response> PutLogLevel([FromRoute] int id, [FromBody] LogLevel LogLevel) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var existe = Existe(LogLevel); if (existe.IsSuccess) { return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro, }); } var LogLevelActualizar = await db.LogLevels.Where(x => x.LogLevelId == id).FirstOrDefaultAsync(); if (LogLevelActualizar != null) { try { LogLevelActualizar.Description = LogLevel.Description; LogLevelActualizar.Name = LogLevel.Name; LogLevelActualizar.Code = LogLevel.Code; LogLevelActualizar.ShortName = LogLevel.ShortName; db.LogLevels.Update(LogLevelActualizar); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio, }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.Logs), ExceptionTrace = ex.Message, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } catch (Exception) { return(new Response { IsSuccess = false, Message = Mensaje.Excepcion }); } }
public async Task <Response> PutLogLevel([FromBody] LogLevel logLevel) { if (!ModelState.IsValid) { return(new entidades.Response { IsSuccess = false, Message = "Módelo inválido", }); } var respuestaLogLevel = db.LogLevels.Where(x => x.LogLevelId == logLevel.LogLevelId).FirstOrDefault(); try { if (logLevel.Code == respuestaLogLevel.Code && logLevel.Description == respuestaLogLevel.Description && logLevel.Name == respuestaLogLevel.Name && logLevel.ShortName == respuestaLogLevel.ShortName) { return(new Response { IsSuccess = true, Message = "ok", }); } if (logLevel.Code != respuestaLogLevel.Code && logLevel.Description == respuestaLogLevel.Description && logLevel.Name == respuestaLogLevel.Name && logLevel.ShortName == respuestaLogLevel.ShortName) { respuestaLogLevel.Code = logLevel.Code; db.LogLevels.Update(respuestaLogLevel); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = "Ok", Resultado = logLevel, }); } if (logLevel.Code == respuestaLogLevel.Code && logLevel.Description != respuestaLogLevel.Description && logLevel.Name == respuestaLogLevel.Name && logLevel.ShortName == respuestaLogLevel.ShortName) { respuestaLogLevel.Description = logLevel.Description; db.LogLevels.Update(respuestaLogLevel); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = "Ok", Resultado = logLevel, }); } if (logLevel.Code == respuestaLogLevel.Code && logLevel.Description == respuestaLogLevel.Description && logLevel.Name != respuestaLogLevel.Name && logLevel.ShortName == respuestaLogLevel.ShortName) { respuestaLogLevel.Name = logLevel.Name; db.LogLevels.Update(respuestaLogLevel); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = "Ok", Resultado = logLevel, }); } var respuesta = Existe(logLevel); if (!respuesta.IsSuccess) { respuestaLogLevel.Code = logLevel.Code; respuestaLogLevel.Description = logLevel.Description; respuestaLogLevel.Name = respuestaLogLevel.Name; respuestaLogLevel.ShortName = respuestaLogLevel.ShortName; db.LogLevels.Update(respuestaLogLevel); await db.SaveChangesAsync(); return(new entidades.Response { IsSuccess = true, Message = "Ok", }); } return(new entidades.Response { IsSuccess = false, Message = "Existe un Log Level de igual Nombre Corto...", }); } catch (Exception ex) { return(new entidades.Response { IsSuccess = false, Message = "Existe un Log Level de igual Nombre...", }); } }