Example #1
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="context"></param>
        public void Download(HttpContext context)
        {
            if (!RequestProxry.VerifyLogin(context))
            {
                return;
            }

            string url      = context.Request["url"];
            string filePath = AppDomain.CurrentDomain.BaseDirectory + url;

            if (!File.Exists(filePath))
            {
                context.Response.Write("资源不存在");
                return;
            }

            string fileName = Regex.Match(url, "(\\\\|/)(([^\\\\/]+)\\.(.+))$").Groups[2].Value;

            context.Response.AppendHeader("Content-Type", "");
            context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);

            const int bufferSize = 100;

            byte[] buffer   = new byte[bufferSize];
            int    readSize = -1;

            using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                while (readSize != 0)
                {
                    readSize = fs.Read(buffer, 0, bufferSize);
                    context.Response.BinaryWrite(buffer);
                }
            }
        }
Example #2
0
 public void Export_ProcessExport(HttpContext context)
 {
     if (!RequestProxry.VerifyLogin(context))
     {
         return;
     }
     ExportHandle.ProcessExport(context);
 }
Example #3
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string Export_Setup(HttpContext context)
        {
            if (!RequestProxry.VerifyLogin(context))
            {
                return(null);
            }

            TemplatePage page = Cms.Plugins.GetPage <Main>("mg/export_setup.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("export", new { setup = ExportHandle.Setup(context.Request["portal"]) });
            return(page.ToString());
        }
Example #4
0
        public string Export_Import(HttpContext context)
        {
            if (!RequestProxry.VerifyLogin(context))
            {
                return(null);
            }

            TemplatePage page = Cms.Plugins.GetPage <Main>("admin/export_import.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("case", new { json = new object() });
            return(page.ToString());
        }