コード例 #1
0
        public FileResult Download()
        {
            if (0 == 1)
            {
                MemoryStream ms = new MemoryStream();

                byte[] ba;
                using (StreamWriter writer = new StreamWriter(ms))
                {
                    writer.WriteLine("hi");
                    writer.Flush();
                    ba          = new byte[ms.Length];
                    ms.Position = 0;
                    ms.Read(ba, 0, (int)ms.Length);
                }

                return(File(ba, "application/txt", "AGOLCatResults.txt"));
            }
            else
            {
                if (this.Session["myModel"] != null)
                {
                    AGOLCat.Models.AGOLCatalogModel pModel = this.Session["myModel"] as AGOLCat.Models.AGOLCatalogModel;

                    MemoryStream ms = new MemoryStream();

                    byte[] ba;
                    using (StreamWriter writer = new StreamWriter(ms))
                    {
                        writeReportHeader(writer);

                        int iCounter = 0;
                        foreach (AGOLCat.Models.Result r in pModel.AGOLCatalogItems)
                        {
                            writeReportRecord(writer, r);
                            iCounter++;

                            System.Diagnostics.Debug.WriteLine("writing record " + iCounter.ToString());
                        }

                        writer.Flush();
                        ba          = new byte[ms.Length];
                        ms.Position = 0;
                        ms.Read(ba, 0, (int)ms.Length);
                    }

                    return(File(ba, "application/txt", "AGOLCatResults.csv"));
                }
            }

            return(null);
        }
コード例 #2
0
        public ActionResult Refresh(string userName, string password, string org, string query, bool bIncludeThumbnails, bool bIncludeSize)
        {
            AGOLCat.Models.AGOLCatalogModel pModel = myModel;// new AGOLCat.Models.AGOLCatalogModel();
            pModel.userName           = userName;
            pModel.password           = password;
            pModel.org                = org;
            pModel.bIncludeThumbnails = bIncludeThumbnails;
            pModel.bIncludeSize       = bIncludeSize;
            pModel.query              = query;

            this.myModel = pModel;
            this.Session.Add("myModel", pModel);
            ViewBag.myModel = pModel;

            return(View("AGOLCat", pModel));
        }