public void ProcessRequest(HttpContext context)
        {
            string fileName = Path.Combine(
                ConfigurationManager.AppSettings["DashboardRoot"],
                context.Request.Params["Dashboard"],
                "Definition.xml"
                );

            // Create a new database core for the session.
            DatabaseCore.Core core = new DatabaseCore.Core(
                ConfigurationManager.AppSettings["DatabaseProvider"],
                string.Format(ConfigurationManager.AppSettings["ConnectionString"], "iheartmedia"),
                ConfigurationManager.AppSettings["DatabaseProviderUserManagement"],
                string.Format(ConfigurationManager.AppSettings["ConnectionString"], "iheartmedia"),
                new string[0]
                );

            Dashboard dashboard = new Dashboard(fileName, core);

            dashboard.Parse();

            if (context.Request.Params["Export"] == "True")
            {
                /*context.Response.ContentType = "application/vnd.ms-excel;charset=utf-8";
                 * context.Response.AddHeader("Content-Disposition", "attachment;filename = ExcelFile.xls");
                 * context.Response.ContentEncoding = Encoding.UTF8;
                 * context.Response.Write(dashboard.Render());
                 * context.Response.End();
                 * return;*/

                //DashboardExporter exporter = new DashboardExporterExcel(dashboard);
                DashboardExporter exporter = new DashboardExporterPdf(dashboard);

                string test = exporter.Export(HttpUtility.UrlDecode(context.Request.Params["Html"]), Path.Combine(
                                                  HttpContext.Current.Request.PhysicalApplicationPath,
                                                  "Temp",
                                                  Guid.NewGuid() + exporter.Extension
                                                  ));

                WriteFileToResponse(
                    test,
                    dashboard.Document.DocumentElement.Attributes["Name"].Value + exporter.Extension,
                    exporter.MimeType,
                    true
                    );
                return;
            }

            StringBuilder result = new StringBuilder();


            context.Response.Write(dashboard.Render(false));
            context.Response.ContentType = "text/html";

            result.Clear();
        }
        public void ProcessRequest(HttpContext context)
        {
            if (!Global.IdUser.HasValue)
            {
                //throw new Exception("Not authenticated.");
                if (!Authenticate(context))
                {
                    context.Response.Write(File.ReadAllText(Path.Combine(
                                                                context.Request.PhysicalApplicationPath,
                                                                "App_Data",
                                                                "Templates",
                                                                "DashboardLogin.html"
                                                                )));

                    return;
                }
            }

            string fileName = Path.Combine(
                context.Request.PhysicalApplicationPath,
                "Fileadmin",
                "Dashboards",
                Global.Core.ClientName,
                context.Request.Params["Dashboard"],
                "Definition.xml"
                );

            if (!File.Exists(fileName))
            {
                throw new Exception(string.Format(
                                        "Dashboard with the name '{0}' does not exist.",
                                        context.Request.Params["Dashboard"]
                                        ));
            }

            Dashboard dashboard;

            dashboard = new Dashboard(fileName, Global.Core);

            dashboard.Parse();

            if (context.Request.Params["Export"] == "True")
            {
                dashboard.Render(true);
                DashboardExporter     exporter     = null;
                DashboardExportFormat exportFormat = DashboardExportFormat.Excel;

                if (context.Request.Params["Format"] != null)
                {
                    exportFormat = (DashboardExportFormat)Enum.Parse(
                        typeof(DashboardExportFormat),
                        context.Request.Params["Format"]
                        );
                }
                else
                {
                    exportFormat = dashboard.Settings.ExportFormat;
                }

                switch (dashboard.Settings.ExportFormat)
                {
                case DashboardExportFormat.Excel:
                    exporter = new DashboardExporterExcel(dashboard);
                    break;

                case DashboardExportFormat.Pdf:
                    exporter = new DashboardExporterPdf(dashboard);
                    break;

                default:
                    throw new Exception("Undefined export interface.");
                    break;
                }

                string test = exporter.Export(HttpUtility.UrlDecode(context.Request.Params["Html"]), Path.Combine(
                                                  HttpContext.Current.Request.PhysicalApplicationPath,
                                                  "Fileadmin",
                                                  "Temp",
                                                  Guid.NewGuid() + exporter.Extension
                                                  ));

                if (dashboard.Properties[DashboardCore.Classes.DashboardPropertyType.ExportTitle] == "")
                {
                    dashboard.Properties[DashboardCore.Classes.DashboardPropertyType.ExportTitle] =
                        dashboard.Properties[DashboardCore.Classes.DashboardPropertyType.Title];
                }

                WriteFileToResponse(
                    test,
                    dashboard.Properties[DashboardCore.Classes.DashboardPropertyType.ExportTitle].Replace(",", "") + exporter.Extension,//dashboard.Properties[DashboardCore.Classes.DashboardPropertyType.ExportTitle] + exporter.Extension,
                    exporter.MimeType,
                    true
                    );
                return;
            }

            if (context.Request.Params["RenderMode"] == "DataUpdate")
            {
                context.Response.Write(dashboard.RenderDataUpdate());
                context.Response.ContentType = "text/html";
                return;
            }

            bool bodyOnly = false;

            if (context.Request.Params["BodyOnly"] != null)
            {
                bodyOnly = bool.Parse(context.Request.Params["BodyOnly"]);
            }

            context.Response.Write(dashboard.Render(bodyOnly));
            context.Response.ContentType = "text/html";
        }