private void HandleActualRequest(HttpListenerContext context) { string matchUrl = context.Request.Url.AbsolutePath.Trim().ToLower(); Match match = FilesMatcher.Match(matchUrl); if (match.Success) { string recordNumber = match.Groups["record"].Value; string filePath = null; try { using (var trimService = new TrimAttachmentRetriever(trimServer, trimDatasetId)) { filePath = trimService.GetTrimAttachmentPath(long.Parse(recordNumber)); if (filePath == null) { context.SetStatusToNotFound(); return; } context.WriteEmbeddedFile(filePath, trimService.FileName, trimService.MimeType); } } finally { if (filePath != null) { File.Delete(filePath); } } } else { string lastUpdateString = context.Request.QueryString.Get("from"); DateTime lastUpdated; if (!DateTime.TryParseExact(lastUpdateString, LastUpdateFormat, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out lastUpdated)) { lastUpdated = DateTime.MinValue; } using (var trimService = new TrimRecordsRetriever(trimServer, trimDatasetId)) { var records = trimService.RetrieveRecords(lastUpdated).ToList(); context.Write(JsonConvert.SerializeObject(new { Records = records, FromDate = trimService.LastRecordUpdatedDate == null ? null : trimService.LastRecordUpdatedDate.Value.ToString(LastUpdateFormat) })); } context.Response.ContentType = "application/json"; } context.Response.StatusCode = 200; context.Response.StatusDescription = "OK"; }
public override void Respond(HttpListenerContext context) { context.WriteEmbeddedFile(Settings.WebDir,"favicon.ico"); }
public override void Respond(HttpListenerContext context) { var docPath = context.Request.Url.LocalPath.Replace("/raven/", ""); context.WriteEmbeddedFile(Settings.WebDir, docPath); }