public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = HttpContext.Current.Response;
            HttpResponseCancellationToken cancellationToken = new HttpResponseCancellationToken(response);
            NameValueCollection           requestParameters = context.Request.QueryString;

            try
            {
                Filename = requestParameters["Meter"] + "_" + requestParameters["EventType"] + "_Event_" + requestParameters["eventID"] + ".csv";
                response.ClearContent();
                response.Clear();
                response.AddHeader("Content-Type", CsvContentType);
                response.AddHeader("Content-Disposition", "attachment;filename=" + Filename);
                response.BufferOutput = true;

                WriteTableToStream(requestParameters, response.OutputStream, response.Flush, cancellationToken);
            }
            catch (Exception e)
            {
                LogExceptionHandler?.Invoke(e);
                throw;
            }
            finally
            {
                response.End();
            }
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = HttpContext.Current.Response;
            HttpResponseCancellationToken cancellationToken = new HttpResponseCancellationToken(response);
            NameValueCollection           requestParameters = context.Request.QueryString;


            try
            {
                Filename = requestParameters["Meter"] + "_" + requestParameters["EventType"] + "_Event_" + requestParameters["eventID"] + ".zip";
                response.ClearContent();
                response.Clear();
                response.AddHeader("Content-Type", ContentType);
                response.AddHeader("Content-Disposition", "attachment;filename=" + Filename);
                response.BufferOutput = true;
                using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
                {
                    int      eventID   = int.Parse(requestParameters["eventID"]);
                    Event    evt       = (new TableOperations <Event>(connection)).QueryRecordWhere("ID = {0}", eventID);
                    DateTime startDate = requestParameters.AllKeys.ToList().IndexOf("startDate") >= 0 ? DateTime.Parse(requestParameters["startDate"]) : evt.StartTime;
                    DateTime endDate   = requestParameters.AllKeys.ToList().IndexOf("endDate") >= 0 ? DateTime.Parse(requestParameters["endDate"]) : evt.EndTime;
                    COMTRADEWriter.WriteResults(evt.MeterID, evt.LineID, startDate, endDate, response.OutputStream);
                }
            }

            catch (Exception e)
            {
                LogExceptionHandler?.Invoke(e);
                throw;
            }
            finally
            {
                response.End();
            }
        }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = HttpContext.Current.Response;
            HttpResponseCancellationToken cancellationToken = new HttpResponseCancellationToken(response);
            NameValueCollection           requestParameters = context.Request.QueryString;
            string   breaker  = requestParameters["breaker"];
            DateTime fromDate = DateTime.Parse(requestParameters["fromDate"]);
            DateTime toDate   = DateTime.Parse(requestParameters["toDate"]);

            try
            {
                Filename = (breaker == "0"? "AllBreakers": breaker) + "_" + fromDate.ToString("MM/dd/yyyy") + "_" + toDate.ToString("MM/dd/yyyy") + ".csv";
                response.ClearContent();
                response.Clear();
                response.AddHeader("Content-Type", CsvContentType);
                response.AddHeader("Content-Disposition", "attachment;filename=" + Filename);
                response.BufferOutput = true;

                WriteTableToStream(breaker, fromDate, toDate, response.OutputStream, response.Flush, cancellationToken);
            }
            catch (Exception e)
            {
                LogExceptionHandler?.Invoke(e);
                throw;
            }
            finally
            {
                response.End();
            }
        }
Example #4
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="IHttpHandler" /> interface.
        /// </summary>
        /// <param name="context">An <see cref="HttpContext" /> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = context.Response;
            HttpResponseCancellationToken cancellationToken = new HttpResponseCancellationToken(response);
            NameValueCollection           requestParameters = context.Request.QueryString;
            SecurityPrincipal             securityPrincipal = context.User as SecurityPrincipal;

            response.ClearContent();
            response.Clear();
            response.AddHeader("Content-Type", CsvContentType);
            response.AddHeader("Content-Disposition", "attachment;filename=" + GetModelFileName(requestParameters["ModelName"]));
            response.BufferOutput = true;

            try
            {
                CopyModelAsCsvToStream(securityPrincipal, requestParameters, response.OutputStream, response.Flush, cancellationToken);
            }
            catch (Exception ex)
            {
                LogExceptionHandler?.Invoke(ex);
                throw;
            }
            finally
            {
                response.End();
            }
        }
Example #5
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="IHttpHandler" /> interface.
        /// </summary>
        /// <param name="context">An <see cref="HttpContext" /> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = HttpContext.Current.Response;
            HttpResponseCancellationToken cancellationToken = new HttpResponseCancellationToken(response);
            NameValueCollection requestParameters = context.Request.QueryString;

            response.ClearContent();
            response.Clear();
            response.AddHeader("Content-Type", CsvContentType);
            response.AddHeader("Content-Disposition", "attachment;filename=" + GetModelFileName(requestParameters["ModelName"]));
            response.BufferOutput = true;

            try
            {
                CopyModelAsCsvToStream(requestParameters, response.OutputStream, response.Flush, cancellationToken);
            }
            catch (Exception ex)
            {
                LogExceptionHandler?.Invoke(ex);
                throw;
            }
            finally
            {
                response.End();
            }
        }