public async void ProcessRequest(HttpContext context) { //validate query parameters QueryParams queryParams; try { queryParams = new QueryParams(context.Request); } catch { context.Response.StatusCode = 400; //bad request return; } //convert query parameters to entities var ctx = new DiscCtx(ConfigManager.ConnStr); var reportParams = queryParams.Materialize(ctx); if (reportParams == null) { context.Response.StatusCode = 400; return; } var screenshotClient = new ReportingPhotonClient(); var reportingTasks = screenshotClient.StartReportingActivities(reportParams.Topic, reportParams.Discussion, reportParams.Session); var complexReportTask = reportingTasks.Item2; //compute and set report parameters var report = new Report { QueryParams = queryParams, ReportParams = reportParams, Participants = Helpers.ParticipantsTuples(reportParams.Topic, reportParams.Session), ComplexReport = await complexReportTask, ReportUrl = context.Request.Url.ToString(), BaseUrl = Helpers.BaseUrl(context.Request) }; var screenshotTask = reportingTasks.Item1; report.ReceiveScreenshots(await screenshotTask, context); var cleanupTimer = new Timer(10 * 60 * 1000); //10 minutes cleanupTimer.Elapsed += (sender, args) => { cleanupTimer.Dispose(); report.Dispose(); screenshotClient.Dispose(); }; cleanupTimer.Start(); context.Response.Write(report.TransformText()); }
public async void ProcessRequest(HttpContext context) { //validate query parameters QueryParams queryParams; try { queryParams = new QueryParams(context.Request); } catch { context.Response.StatusCode = 400; //bad request return; } //convert query parameters to entities var ctx = new DiscCtx(ConfigManager.ConnStr); var reportParams = queryParams.Materialize(ctx); if (reportParams == null) { context.Response.StatusCode = 400; return; } var screenshotClient = new ReportingPhotonClient(); var reportingTasks = screenshotClient.StartReportingActivities(reportParams.Topic, reportParams.Discussion, reportParams.Session); var complexReportTask = reportingTasks.Item2; //compute and set report parameters var report = new Report { QueryParams = queryParams, ReportParams = reportParams, Participants = Helpers.ParticipantsTuples(reportParams.Topic, reportParams.Session), ComplexReport = await complexReportTask, ReportUrl = context.Request.Url.ToString(), BaseUrl = Helpers.BaseUrl(context.Request) }; var screenshotTask = reportingTasks.Item1; report.ReceiveScreenshots(await screenshotTask, context); var cleanupTimer = new Timer(10*60*1000); //10 minutes cleanupTimer.Elapsed += (sender, args) => { cleanupTimer.Dispose(); report.Dispose(); screenshotClient.Dispose(); }; cleanupTimer.Start(); context.Response.Write(report.TransformText()); }
private void CleanupTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) { _cleanupTimer.Elapsed -= CleanupTimerOnElapsed; if (_report != null) { _report.Dispose(); _report = null; } if (_screenshotClient != null) { _screenshotClient.Dispose(); _screenshotClient = null; } if (_ctx != null) { _ctx.Dispose(); _ctx = null; } _cleanupTimer.Dispose(); _cleanupTimer = null; }