<commit_before>﻿using System.Web;
using System.Web.Mvc;

namespace StackExchange.DataExplorer.Helpers
{
    internal class QueryPlanResult : ActionResult
    {
        private readonly QueryResults results;

        public QueryPlanResult(string json)
        {
            results = QueryResults.FromJson(json);
        }

        public override void ExecuteResult(ControllerContext context)
        {
            HttpResponseBase response = context.HttpContext.Response;

            string attachment = "attachment; filename=ExecutionPlan.sqlplan";

            response.Clear();
            response.ContentType = "text/xml";
            response.AddHeader("content-disposition", attachment);
            response.AddHeader("Pragma", "public");
            // TODO: This only returns the first plan
            response.Write(results.ExecutionPlans[0]);
            response.Flush();
            response.Close();
        }
    }
}<commit_msg>Workaround for caching issue when downloading execution plans.<commit_after>﻿using System.Web;
using System.Web.Mvc;

namespace StackExchange.DataExplorer.Helpers
{
    internal class QueryPlanResult : ActionResult
    {
        private readonly QueryResults results;

        public QueryPlanResult(string json)
        {
            results = QueryResults.FromJson(json);
        }

        private string PanlXml
        {
            get
            {
                // TODO: This only returns the first plan
                return this.results.ExecutionPlans.Count == 0 ? null : results.ExecutionPlans[0];
            }
        }

        public override void ExecuteResult(ControllerContext context)
        {
            HttpResponseBase response = context.HttpContext.Response;

            string attachment = "attachment; filename=ExecutionPlan.sqlplan";

            response.Clear();
            response.ContentType = "text/xml";
            response.AddHeader("content-disposition", attachment);
            response.AddHeader("Pragma", "public");
            response.Write(this.PanlXml);
            response.Flush();
            response.Close();
        }
    }
}
{'fraction_non_alphanumeric': 0.08732394366197183, 'fraction_numerical': 0.0014084507042253522, 'mean_word_length': 2.115497076023392, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2557283', 'n_tokens_mistral': 514, 'n_tokens_neox': 498, 'n_words': 112}