public 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;
            }
            
            //compute and set report parameters 
            var report = new SourcesReport
                {
                    ReportParams = reportParams,
                };

           context.Response.Write(report.TransformText());
        }
示例#2
0
        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());
        }
示例#3
0
        public 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            
            _ctx = new DiscCtx(ConfigManager.ConnStr);
            var reportParams = queryParams.Materialize(_ctx);
            if (reportParams == null)
            {
                context.Response.StatusCode = 400;
                return;
            }

            _screenshotClient = new ReportingPhotonClient();
            var reportingTasks = _screenshotClient.StartReportingActivities(
                reportParams.Topic,
                reportParams.Discussion,
                reportParams.Session,
                _ctx);

            //blocking wait
            //var r1 = reportingTasks.ScreenshotsTask.Result;  
            //var r2 = reportingTasks.ReportTask.Result;  

            //compute and set report parameters 
            _report = new Report
            {
                QueryParams = queryParams,
                ReportParams = reportParams,
                Participants = Helpers.ParticipantsTuples(reportParams.Topic, reportParams.Session),
                ComplexReport = reportingTasks.ReportTask.Result,
                ReportUrl = context.Request.Url.ToString(),
                BaseUrl = Helpers.BaseUrl(context.Request)
            };

            _report.ReceiveScreenshots(reportingTasks.ScreenshotsTask.Result, context);

            _cleanupTimer = new Timer(5 * 60 * 1000); //5 minutes
            _cleanupTimer.Elapsed += CleanupTimerOnElapsed;
            _cleanupTimer.Start();

            context.Response.Write(_report.TransformText());
        }
示例#4
0
 public static string GetBackground(QueryParams parameters, DiscCtx ctx)
 {          
     var discId = parameters.DiscussionId;
     var disc = ctx.Discussion.Single(d0 => d0.Id == discId);
     return disc.HtmlBackground;
 }