Exemple #1
0
        public virtual void Render(string format, PCAxis.Query.SavedQuery query, PCAxis.Paxiom.PXModel model, bool safe, string fileExtension, string mimeType)
        {
            if (!safe)
            {
                model.Meta.Notes.Add(new Note(LocalizationManager.GetLocalizedString("PxWebSavedQueryUnsafeMessage"), NoteType.Table, true));
            }
            var info = PCAxis.Web.Controls.CommandBar.Plugin.CommandBarPluginManager.GetFileType(format);

            PCAxis.Web.Core.ISerializerCreator creator = Activator.CreateInstance(Type.GetType(info.Creator)) as PCAxis.Web.Core.ISerializerCreator;

            if (!mimeType.Contains("json")) // json always use UTF8
            {
                HttpContext.Current.Response.Charset = model.Meta.CodePage;
            }

            HttpContext.Current.Response.ContentType = mimeType;
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + model.Meta.Matrix + "." + fileExtension);

            var serializer = creator.Create(format);

            using (MemoryStream ms = new MemoryStream())
            {
                serializer.Serialize(model, ms);
                ms.Position = 0;
                ms.WriteTo(HttpContext.Current.Response.OutputStream);
            }
        }
Exemple #2
0
        private void SerializeResult(PCAxis.Query.SavedQuery sq, PXModel model, HttpContext context)
        {
            var info = PCAxis.Web.Controls.CommandBar.Plugin.CommandBarPluginManager.GetFileType(sq.Output.Type);

            PCAxis.Web.Core.ISerializerCreator creator = Activator.CreateInstance(Type.GetType(info.Creator)) as PCAxis.Web.Core.ISerializerCreator;

            context.Response.ContentType = info.MimeType;
            context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + model.Meta.Matrix + "." + info.FileExtension);

            var serializer = creator.Create(sq.Output.Type);

            using (MemoryStream ms = new MemoryStream())
            {
                serializer.Serialize(model, ms);
                ms.Position = 0;
                ms.WriteTo(context.Response.OutputStream);
            }
        }