Esempio n. 1
0
        public MetaFile GetMetaFile()
        {
            // Execute the report and save the memory stream and
            // the mimetype on cache
            string cacheid = GetCacheId();
            // Check if there is a metafile
            MetaFile    meta     = (MetaFile)Page.Cache[cacheid + "MetaFile"];
            PrintOutNet prdriver = (PrintOutNet)Page.Cache[cacheid + "PrintOut"];

            if (prdriver == null)
            {
                meta = null;
            }
            if (meta == null)
            {
                Report rp = (Report)Page.Cache[cacheid + "Report"];
                if (rp == null)
                {
                    string filename = ReportFileName;
                    if (filename != "")
                    {
                        rp = new Report();
                        // Async execution
                        rp.AsyncExecution = AsyncExecution;
                        rp.AsyncPriority  = AsyncPriority;
                        ReportReader reader = new ReportReader(rp);
                        reader.LoadFromFile(Page.Server.MapPath(filename));
                        meta                 = rp.MetaFile;
                        meta.ForwardOnly     = false;
                        prdriver             = new PrintOutNet();
                        prdriver.OptimizeWMF = WMFOptimization.Gdiplus;
                        Page.Cache.Insert(cacheid + "Report", rp, null,
                                          DateTime.Now.AddMinutes(30), TimeSpan.Zero);
                        Page.Cache.Insert(cacheid + "MetaFile", meta, null,
                                          DateTime.Now.AddMinutes(30), TimeSpan.Zero);
                        Page.Cache.Insert(cacheid + "PrintOut", prdriver, null,
                                          DateTime.Now.AddMinutes(30), TimeSpan.Zero);
                        // Assign parameters to the report here
                        rp.BeginPrint(prdriver);
                    }
                }
            }
            return(meta);
        }