예제 #1
0
        /// <summary>
        /// Traite une requête HTTP.
        /// </summary>
        /// <param name="context">Context HTTP de la requête.</param>
        public void ProcessRequest(HttpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            Context requestContext = new Context(context, null);

            if (HtmlPageRenderer.IsCounterPage(requestContext.Content))
            {
                ProcessPageRequest(context, requestContext);
            }
            else if (HtmlPageRenderer.IsExportPage(requestContext.Content))
            {
                HtmlPageRenderer.SetHeaderCsv(context.Response);
                HtmlPageHelper.ToCsv(
                    Analytics.Instance.GetDataBase(requestContext.ActionDataBase).HyperCube,
                    requestContext,
                    context.Response.Output);
            }
            else if (requestContext.Content != null)
            {
                ProcessContentRequest(context, requestContext);
            }
            else
            {
                // On ne sait pas traiter la requête
                context.Response.StatusCode = 500;
            }
        }
예제 #2
0
        /// <summary>
        /// Traite une requête HTTP.
        /// </summary>
        /// <param name="context">Context HTTP de la requête.</param>
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            Context requestContext = new Context(context, null);

            if (requestContext.Content.Equals("sparklines.png"))
            {
                context.Response.ContentType = "image/png";
                HtmlPageRenderer.ToChart(_databaseSet.GetDatabase(requestContext.Id), requestContext, context.Response.OutputStream);
            }
            else if (requestContext.Content.Equals("img_manager"))
            {
                foreach (IManagerDescription description in this.DatabaseDefinition.Values)
                {
                    if (description.Image == requestContext.Id)
                    {
                        context.Response.ContentType = description.ImageMimeType;
                        context.Response.OutputStream.Write(description.ImageData, 0, description.ImageData.Length);
                        break;
                    }
                }
            }
            else if (HtmlPageRenderer.IsExportPage(requestContext.Content))
            {
                HtmlPageRenderer.SetHeaderCsv(context.Response);
                HtmlPageHelper.ToCsv(_databaseSet.GetDatabase(requestContext.ActionDataBase), requestContext, context.Response.Output);
            }
            else
            {
                throw new NotImplementedException();
            }
        }