コード例 #1
0
        // Essentially this acts like a giant switchboard. It looks at the request
        // and then called the correct library to make it happen.
        public void ProcessRequest(HttpContext context)
        {
            // Handle the request
            extractCommonReportOptions(context);
            int actionType;

            Int32.TryParse(context.Request.Params["actionType"], out actionType);
            bool noError = decodeActionRequest(context, (ActionType)actionType);

            // Then send the response
            if (actionType == 6)
            {
                int queryID;
                Int32.TryParse(context.Request.Params["queryID"], out queryID);
                QueryRunner queryRunner = new QueryRunner();
                context.Response.ContentType = "text/csv";
                context.Response.AddHeader("content-disposition", "attachment; filename=data.csv");
                context.Response.Write(queryRunner.CreateCSVView(campaign, queryID));
                string deleteDownload = (string)context.Request.Params["deleteDownload"];
                if (deleteDownload == "DELETE")
                {
                    queryRunner.deleteQuery(campaign, queryID);
                }
                //context.Response.WriteFile("~/test.png");
            }
            else
            {
                context.Response.ContentType = "text/plain";
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                context.Response.Write(serializer.Serialize(ajaxResponse));
            }
        }