Example #1
0
        /// <summary>
        /// Traite une requête pour du contenu attaché à la page.
        /// </summary>
        /// <param name="context">Contexte HTTP.</param>
        /// <param name="requestContext">Contexte de la requête.</param>
        private static void ProcessContentRequest(HttpContext context, Context requestContext)
        {
            if (requestContext.Content.Equals("img_manager"))
            {
                string mimeType = null;
                IManagerDescription managerDescription = null;

                foreach (IManager manager in ManagerContainer.Instance.ManagerList)
                {
                    IManagerDescription description = manager.Description;
                    if (description != null && description.Image != null &&
                        description.Image.Equals(requestContext.Id))
                    {
                        managerDescription = description;
                        break;
                    }
                }

                if (managerDescription == null)
                {
                    byte[] imageData = IR.Misc_png;
                    mimeType = "image/png";
                    context.Response.ContentType = mimeType;
                    context.Response.OutputStream.Write(imageData, 0, imageData.Length);
                }
                else
                {
                    context.Response.ContentType = managerDescription.ImageMimeType;
                    byte[] img = managerDescription.ImageData;
                    context.Response.OutputStream.Write(img, 0, img.Length);
                }
            }
            else if (requestContext.Content.Equals("sparklines.png"))
            {
                context.Response.ContentType = "image/png";
                CounterDataBase counterDataBase = Analytics.Instance.GetDataBase(requestContext.Id);
                HtmlPageRenderer.ToChart(counterDataBase.HyperCube, requestContext, context.Response.OutputStream);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Example #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();
            }
        }