public void RecordLogWS(LogDto log) { var _parametrosDoMetodo = new List <SqlParameter>(); new DataBaseRepository().NonQuery("<Command here>", _parametrosDoMetodo.ToArray(), System.Data.CommandType.StoredProcedure); }
public IActionResult Delete(LogDto log) { var model = _mapper.Map <LogDto, Log>(log); _repository.Delete(model); return(new NoContentResult()); }
public void Log(LogDto logDto) { var dbConnectionString = ConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString; var dbConnection = new SqlConnection(dbConnectionString); try { dbConnection.Open(); using ( var cmd = new SqlCommand("INSERT INTO LogInfo ( Name, Surname) VALUES (@Name, @Surname)", dbConnection)) { cmd.Parameters.AddWithValue("@Name", logDto.Name); cmd.Parameters.AddWithValue("@Surname", logDto.Surname); cmd.ExecuteNonQuery(); } } catch { // ignored } finally { dbConnection.Close(); } }
public dynamic Put(string api, FormCollection body, HttpStatusCode correct = HttpStatusCode.OK) { using (var cliente = new HttpClient()) { cliente.DefaultRequestHeaders.Accept.Clear(); cliente.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", GlobalValues.TokenCanvas); cliente.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); cliente.BaseAddress = new Uri(GlobalValues.UrlCanvas); var content = new FormUrlEncodedContent(body.AllKeys.ToDictionary(x => x, p => body[p])); var request = cliente.PutAsync(api, content).Result; if (request.StatusCode == correct) { var response = request.Content.ReadAsAsync <dynamic>().Result; return(response); } else { var statusCode = Convert.ToInt32(request.StatusCode); var status = request.StatusCode.ToString(); var exception = request.Content.ReadAsStringAsync().Result; var logEntity = new LogDto { Date = DateTime.Now, Loger = api, Message = "GET " + status + ":" + statusCode, Exception = exception, Level = GlobalValues.WARNING, StatusCode = statusCode }; return(logEntity); } } }
/// <summary> /// Insert, Update ve Delete gibi kalıcı değişkliğe neden olan işlemlerin Loglarını belirleyen metodumuz. /// Bu bilgiler LogDto türünden elde edilmektedir. /// </summary> void HandleCrudOperationsLog() { var entries = Context.ChangeTracker.Entries(); var logs = new List <LogDto>(); foreach (var entry in entries) { LogDto log = new LogDto(); if (entry.State == EntityState.Added || entry.State == EntityState.Modified) { //Yapılan değişiklikte Log entity'nin sadece New property'si doludur log.New = JsonConvert.SerializeObject(GetCurrentValues(entry)); } if (entry.State == EntityState.Deleted || entry.State == EntityState.Modified) { //Yapılan değişiklikte Log entity'nin New ve Old property'si doludur log.Old = JsonConvert.SerializeObject(GetOldValues(entry)); } log.EntityName = entry.Entity.GetType().Name; log.LogDate = DateTime.Now; log.Username = "******"; logs.Add(log); } _crudLogger.LogCrudOperation(logs); }
public dynamic Post(string api, object param, HttpStatusCode correct = HttpStatusCode.OK) { using (var cliente = new HttpClient()) { cliente.DefaultRequestHeaders.Accept.Clear(); cliente.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", GlobalValues.TokenCanvas); cliente.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); cliente.BaseAddress = new Uri(GlobalValues.UrlCanvas); var request = cliente.PostAsJsonAsync(api, param).Result; if (request.StatusCode == correct) { var response = request.Content.ReadAsAsync <dynamic>().Result; return(response); } else { var statusCode = Convert.ToInt32(request.StatusCode); var status = request.StatusCode.ToString(); var exception = request.Content.ReadAsStringAsync().Result; var logEntity = new LogDto { Date = DateTime.Now, Loger = api, Message = "POST " + status + ":" + statusCode, Exception = exception, Level = GlobalValues.WARNING, StatusCode = statusCode }; return(logEntity); } } }
public void Execute(LogDto request) { var log = this.Context.Logs.Find(request.Id); if (log == null) { throw new EntityNotFoundException("log"); } if (log.IsDeleted) { throw new EntityNotFoundException("log"); } if (log.Description != request.Description) { log.Description = request.Description; } if (log.IsActive != request.IsActive) { log.IsActive = request.IsActive; } log.ModifiedAt = DateTime.Now; this.Context.SaveChanges(); }
public async Task AddAsync(LogDto logDto) { if (LogSetting.IsEnableSqlServerLog) { await _sqlLogService.InsertAsync(logDto); } }
protected async override void OnAppearing() { //Haalt alle projecten op List <ProjectDto> projects = await userServices.GetAllUserProjectsAsync(int.Parse(idUser)); ProjectDto projectDto = null; //Steekt alle projecten in ProjectList (Picker) AddProjectsToProjectList(projects); if (logId != 0) { log = await logServices.GetLogByIdAsync(logId); StartTime.Time = new TimeSpan(log.StartTime.Hour, log.StopTime.Minute, 0); EndTime.Time = new TimeSpan(log.StopTime.Hour, log.StopTime.Minute, 0); projectDto = await projectServices.GetProjectByIdAsync(log.ProjectID); LabelProject.Text = $"Project [Before: {projectDto.Name}]"; DescriptionEntry.Text = log.Description; date = log.StartTime.Date;; } }
public void Add(LogDto logDto) { if (LogSetting.IsEnableSqlServerLog) { _sqlLogService.Insert(logDto); } }
public dynamic Get(string api, HttpStatusCode correct = HttpStatusCode.OK) { using (var cliente = new HttpClient()) { cliente.DefaultRequestHeaders.Accept.Clear(); cliente.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", GlobalValues.TokenCanvas); cliente.DefaultRequestHeaders.Add("Connection", "keep-alive"); cliente.BaseAddress = new Uri(GlobalValues.UrlCanvas); var request = cliente.GetAsync(api).Result; if (request.StatusCode == correct) { var response = request.Content.ReadAsAsync <dynamic>().Result; return(response); } else { var statusCode = Convert.ToInt32(request.StatusCode); var status = request.StatusCode.ToString(); var exception = request.Content.ReadAsStringAsync().Result; var logEntity = new LogDto { Date = DateTime.Now, Loger = api, Message = "GET " + status + ":" + statusCode, Exception = exception, Level = GlobalValues.WARNING, StatusCode = statusCode }; return(logEntity); } } }
private string GetIcon(LogDto logItem) { switch (logItem.EntityType.ToLower()) { case "document": return(_contentService.GetById(logItem.NodeId).ContentType.Icon); case "media": return(_mediaService.GetById(logItem.NodeId).ContentType.Icon); case "member": return(_memberTypeService.Get(_memberService.GetById(logItem.NodeId).ContentTypeAlias).Icon); case "documenttype": return(_contentTypeService.Get(logItem.NodeId).Icon); case "mediatype": return(_mediaTypeService.Get(logItem.NodeId).Icon); case "membertype": return(_memberTypeService.Get(logItem.NodeId).Icon); case "datatype": return(_dataTypeService.GetAll(new[] { logItem.NodeId }).FirstOrDefault().Editor.Icon); case "dictionaryitem": return("icon-book-alt"); default: return("icon-newspaper"); } }
/// <summary> /// Gets a list of data from the underlying data storage. /// </summary> /// <param name="arguments">A <see cref="T:System.Web.UI.DataSourceSelectArguments"/> that is used to request operations on the data beyond basic data retrieval.</param> /// <returns> /// An <see cref="T:System.Collections.IEnumerable"/> list of data from the underlying data storage. /// </returns> protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { Options.RecordsToRetrieve = arguments.MaximumRows; Options.StartingRecord = arguments.StartRowIndex; int totalRecordsCount = 0; LogDto dto = new LogDto(); if (this.DataMode == ApplicationLogDataMode.ApplicationLog) { dto = LogManager.GetAppLog(Parameters.SourceKey, Parameters.Operation, Parameters.ObjectType, Parameters.Created, Options.StartingRecord, Options.RecordsToRetrieve, ref totalRecordsCount); } else { dto = LogManager.GetSystemLog(Parameters.Operation, Parameters.ObjectType, Parameters.Created, Options.StartingRecord, Options.RecordsToRetrieve, ref totalRecordsCount); } if (totalRecordsCount > 0) { arguments.TotalRowCount = totalRecordsCount; return(dto.ApplicationLog.Rows); } else { arguments.TotalRowCount = 0; return(null); } }
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { LogDto dto = new LogDto(); while (LogContainer.TryDequeue(out var log)) { dto.Items.Add(log); } var shouldClearCacheLogs = false;//在没有新日志、成功上传的情况下可以清本地日志缓存 if (!dto.Items.AnyX()) { shouldClearCacheLogs = true; } else { try { var channel = new Channel(address, ChannelCredentials.Insecure); var grpcClient = new Diagloger.DiaglogerClient(channel); grpcClient.PostLog(dto, new CallOptions(null, DateTime.Now.ToUniversalTime().AddSeconds(timeoutBySeconds))); shouldClearCacheLogs = true; } catch (Exception ex) { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("DiagnosticLogCenter 组件调用 Grpc 写入过程时出现错误,报错信息如下:"); Console.ForegroundColor = color; Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); if (localCacheHelper.WriteLog(dto)) { Console.WriteLine("DiagnosticLogCenter 组件已将日志缓存到本地。"); } } } if (shouldClearCacheLogs) { lock (forClearLock) { try { (var logs, var action) = localCacheHelper.PeekClearLog(); if (logs.AnyX()) { var channel = new Channel(address, ChannelCredentials.Insecure); var grpcClient = new Diagloger.DiaglogerClient(channel); foreach (var log in logs) { grpcClient.PostLog(log, new CallOptions(null, DateTime.Now.ToUniversalTime().AddSeconds(timeoutBySeconds))); } action.Invoke(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
private void DoWork() { try { //Console.WriteLine("服务开始了吗"); while (true) { List <easy_log> logs = new List <easy_log>(); for (int i = 0; i < 100; i++) { //队列中取log LogDto log = LogQueueInstance.GetLog(); if (log == null) { break; } if (log != null) { easy_log logModel = new easy_log(); logModel.log_summary = log.LogSummary; logModel.log_message = log.LogMessage; logModel.log_type = log.LogType; logModel.log_time = log.LogTime; logs.Add(logModel); } } List <cms_visit> visits = new List <cms_visit>(); for (int i = 0; i < 100; i++) { //队列中取log cms_visit visit = VisitQueueInstance.GetVisit(); if (visit == null) { break; } visits.Add(visit); } try { if (logs.Count > 0) { _freeSql.Insert(logs).ExecuteAffrows(); } if (visits.Count > 0) { _freeSql.Insert(visits).ExecuteAffrows(); } } catch (Exception ex) { _logger.LogError(ex.ToString()); } Thread.Sleep(100); } } catch (Exception ex) { _logger.LogError(ex.ToString()); } }
public LogViewModel(LogDto i) { Date = i.Date; Level = i.Level; Thread = i.Thread; Logger = i.Logger; Message = i.Message; }
public override global::System.Data.DataSet Clone() { LogDto cln = ((LogDto)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public IHttpActionResult Post(HttpRequestMessage value) { var jsonString = value.Content.ReadAsStringAsync(); string json = jsonString.Result; LogDto log = JsonConvert.DeserializeObject <LogDto>(json); this.loggerService.SaveLog(log); return(Ok()); }
/// <summary> /// Gets the log by id. /// </summary> /// <returns></returns> public static LogDto GetAppLog(int logId) { LogDto dto = null; LogAdmin admin = new LogAdmin(); admin.Load(logId); dto = admin.CurrentDto; return(dto); }
/// <summary> /// Gets the application log. /// </summary> /// <param name="source">The source.</param> /// <param name="operation">The operation.</param> /// <param name="objectType">Type of the object.</param> /// <param name="created">The created.</param> /// <param name="startingRecord">The starting record.</param> /// <param name="numberOfRecords">The number of records.</param> /// <param name="totalRecords">The total records.</param> /// <returns></returns> public static LogDto GetAppLog(string source, string operation, string objectType, DateTime created, int startingRecord, int numberOfRecords, ref int totalRecords) { LogDto dto = null; LogAdmin admin = new LogAdmin(); admin.Load(false, source, operation, objectType, created, startingRecord, numberOfRecords, ref totalRecords); dto = admin.CurrentDto; return(dto); }
private void LogEvent(LogDto log) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); var postBody = new StringContent(JsonConvert.SerializeObject(log), System.Text.Encoding.UTF8, "application/json"); client.PostAsync("https://localhost:44339/api/Log/", postBody); } }
public string Arquivar(LogDto log) { var entity = _contexto.Logs.FirstOrDefault(x => x.Id == log.Id); entity.Arquivar = true; _contexto.Logs.Update(entity); _contexto.SaveChanges(); return(MensagensErro.Arquivar); }
public async Task <ICollection <LogModel> > GetLogList(LogDto logDto) { var spec = new LogSpecification(logDto.Id, logDto.Message, logDto.Module, logDto.level, logDto.TimeStamp, logDto.UserId); var list = await _logRepository.GetAsync(spec); var mapped = ObjectMapper.Mapper.Map <ICollection <LogModel> >(list); return(mapped); }
private async Task <LogDto> LogToMongoDB(LogDto logDto) { LogDto log = new LogDto(); var logger = new LoggerMongoRepository(_msettings); log = await logger.AddLog(logDto); return(log); }
public override Task <LogReply> PostLog(LogDto request, ServerCallContext context) { logBatchService.Process(request); var result = new LogReply() { Success = true }; return(Task.FromResult(result)); }
public void SaveLog(LogDto logs) { foreach (LogEventDto logEvent in logs.Events) { log.Info(String.Format("{0}\t{1} {2}#{3} value=\"{4}\" X={5} Y={6}", UnixTimeStampToDateTime(logEvent.Time), logEvent.Event, logEvent.TagName, logEvent.Id, logEvent.Value.Length < 15 ? logEvent.Value:"", logEvent.CoordX, logEvent.CoordY)); } }
public void Execute(LogDto request) { this.Context.Logs.Add(new Log { Description = request.Description, IsActive = request.IsActive }); this.Context.SaveChanges(); }
public async Task <LogDto> SaveLogAsync(LogDto logDto) { _dbConnection.Open(); await _dbConnection.InsertAsync(logDto); var responseUserDto = await _dbConnection.GetAsync <LogDto>(logDto.Id); _dbConnection.Close(); return(responseUserDto); }
private Log MapLogDtoToDomain(LogDto logDto) { DateTime date = DateTimeOffset.FromUnixTimeSeconds(logDto.date).DateTime; return(new Log() { date = date, Message = logDto.Message }); }
private static void BuildExcel(ref ISheet worksheet, List <LogDto> logs) { //Header IRow headRow = worksheet.CreateRow(0); ICellStyle cellStyle; BuildHeaderStyle(headRow, out cellStyle); ICell headerCell = headRow.CreateCell(0); headerCell.SetCellValue("Data Log"); headerCell.SetCellType(CellType.String); headerCell.CellStyle = cellStyle; ICell headerCell1 = headRow.CreateCell(1); headerCell1.SetCellValue("Livello"); headerCell1.SetCellType(CellType.String); headerCell1.CellStyle = cellStyle; ICell headerCell2 = headRow.CreateCell(2); headerCell2.SetCellValue("Messaggio"); headerCell2.SetCellType(CellType.String); headerCell2.CellStyle = cellStyle; //row ICellStyle bodyStyle; BuildBodyStyle(headRow, out bodyStyle); for (int rownum = 0; rownum < logs.Count; rownum++) { IRow row = worksheet.CreateRow(rownum + 1); LogDto log = logs[rownum]; ICell cell = row.CreateCell(0); cell.SetCellValue(log.LogDate.ToString("dd/MM/yyyy HH:mm:ss")); cell.SetCellType(CellType.String); cell.CellStyle = bodyStyle; ICell cell1 = row.CreateCell(1); cell1.SetCellValue(log.Level); cell1.SetCellType(CellType.String); cell1.CellStyle = bodyStyle; ICell cell2 = row.CreateCell(2); cell2.SetCellValue(log.Message); cell2.SetCellType(CellType.String); cell2.CellStyle = bodyStyle; } worksheet.SetColumnWidth(0, 20 * 256); worksheet.SetColumnWidth(1, 10 * 256); worksheet.SetColumnWidth(2, 160 * 256); }