public IActionResult Requests() { var xmlPath = $"{_hostingEnvironment.WebRootPath}/xml/requests.xml"; var logs = XmlService.Deserialize <RequestLogs>(xmlPath) ?? new RequestLogs { Logs = new List <RequestLog>() }; return(View(logs.Logs)); }
public async Task <IActionResult> Index(IFormFile imageFile) { if (imageFile != null && imageFile.Length > 0) { var filePath = $"{_hostingEnvironment.WebRootPath}/uploads/[{DateTime.UtcNow:yyyy-dd-M--HH-mm-ss}]{imageFile.FileName}"; using (var fileStream = new FileStream(filePath, FileMode.Create)) { await imageFile.CopyToAsync(fileStream); } } var dir = new DirectoryInfo($"{_hostingEnvironment.WebRootPath}/uploads/"); var filesToRemove = dir.GetFiles().OrderByDescending(entry => entry.CreationTime).Skip(3); foreach (var file in filesToRemove) { file.Delete(); } var requestLog = new RequestLog { TimeStamp = DateTime.UtcNow, Headers = Request.Headers.Select(entry => new HeaderLog { Name = entry.Key, Value = entry.Value }).ToList(), }; using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8, true, 1024, true)) { requestLog.Body = await reader.ReadToEndAsync(); } var xmlPath = $"{_hostingEnvironment.WebRootPath}/xml/requests.xml"; var logs = XmlService.Deserialize <RequestLogs>(xmlPath) ?? new RequestLogs { Logs = new List <RequestLog>() }; logs.Logs = logs.Logs.OrderByDescending(entry => entry.TimeStamp).Take(5).ToList(); logs.Logs.Add(requestLog); XmlService.Serialize(xmlPath, logs); return(Ok()); }
public List<MappedFieldModel> GetMappedFields(string uuid) { var service = new XmlService(); var folder = GetImportSettingsFolder(); var content = folder.CreateQuery().FirstOrDefault(a => a.UUID == uuid); var mappedFields = content.GetValue<string>("MappedFields"); if (string.IsNullOrEmpty(mappedFields)) return new List<MappedFieldModel>(); var data = service.Deserialize<List<MappedFieldModel>>(mappedFields); return data; }