Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            InitializeHelper.Init();
            var reportFullPath = Path.Combine(DFPub.GetCurrentPhysicalFolder(), string.Format("temp\\{0}", Guid.NewGuid().ToString()));
            var folder         = Path.GetDirectoryName(reportFullPath);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            // 删除以前的文件
            OldFileProcessor.DeleteOldFile(folder, 4);

            // 客户端下载显示的文件名
            var fileName = Path.GetFileName(reportFullPath);

            // 判断是不是从数据库中下载文件
            var FileId           = Request["fileid"];
            var DownloadFileName = Request["DownloadFileName"];

            if (!string.IsNullOrWhiteSpace(FileId))
            {
                using (var db = Pub.DB)
                {
                    var file   = db.Query <XDSW_T_FILE>("select * from XDSW_T_FILE where FileId=@FileId", new { FileId = FileId }).FirstOrDefault();
                    var stream = StreamHelper.ToStream(file.FileData);
                    StreamHelper.SaveStream(stream, reportFullPath);
                    fileName = file.FileName;
                }
            }

            // 判断是否是下载工作流模型
            var ModelId = Request["ModelId"];

            if (!string.IsNullOrWhiteSpace(ModelId))
            {
                var entity = WFDA.Instance.ModelSaveToLocal(ModelId, reportFullPath);
                fileName = string.Format("{0}.dat", entity.Model.ModelName);
            }
            if (!string.IsNullOrWhiteSpace(DownloadFileName))
            {
                reportFullPath = DownloadFileName;
                var str = DownloadFileName.Split('\\');
                fileName = str[str.Length - 1];// D:\Ceprei\myproject\sumin\sourcecode\DynamicForm\kindeditor\attached\pdf\\20190723\20190723160214_4592.pdf
            }

            //以字符流的形式下载文件
            FileStream fs = new FileStream(reportFullPath, FileMode.Open);

            byte[] bytes = new byte[(int)fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            Response.ContentType = "application/octet-stream";
            //通知浏览器下载文件而不是打开
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
        }
Esempio n. 2
0
 protected override void OnLoad(EventArgs e)
 {
     InitializeHelper.Init();
     //var message = string.Empty;
     //var user = Util.GetCurrentUser().UserId;
     //var formName = string.Format("{0}", Request["DF_FORMNAME"]);
     //if (formName.IndexOf("Form_XDSW_M_LOCK") < 0 && !CheckSystemStatus(user, ref message))
     //{
     //    Response.Write(message);
     //    Response.End();
     //}
     base.OnLoad(e);
 }
        public void ProcessRequest(HttpContext context)
        {
            InitializeHelper.Init();
            var dict        = DFPub.GetDFDictionary(context.Request);
            var action      = dict["action"].ToLower();
            var contentType = context.Request.ContentType;

            if (string.IsNullOrWhiteSpace(contentType))
            {
                contentType = "application/json;charset=utf-8";
            }
            context.Response.ContentType = contentType;
            switch (action)
            {
            case "queryform":
                if (dict.Data.ContainsKey(DFPub.DF_DATAGRID_EXPORT))
                {
                    var vm = QueryForm(dict);
                    if (vm.hasError)
                    {
                        m_log.Error(vm.error);
                    }
                    context.Response.Write(JsonSerializeHelper.SerializeObject(new DataGridVM()
                    {
                        data = DFPub.PhysicalToRelative(vm.data.ToString())
                    }));
                }
                else
                {
                    context.Response.Write(JsonSerializeHelper.SerializeObject(QueryForm(dict)));
                }
                break;

            case "deleteform":
                context.Response.Write(JsonSerializeHelper.SerializeObject(DeleteForm(dict)));
                break;

            case "clientreport":
                context.Response.Write(JsonSerializeHelper.SerializeObject(ClientReport(dict)));
                break;

            case "querylist":
                context.Response.Write(JsonSerializeHelper.SerializeObject(QueryList(dict)));
                break;

            case "saveparameter":
                context.Response.Write(JsonSerializeHelper.SerializeObject(SaveParameter(context, dict)));
                break;

            case "uploadfile":
                context.Response.Write(JsonSerializeHelper.SerializeObject(UploadFile(context, dict)));
                break;

            case "deleteuploadfile":
                context.Response.Write(JsonSerializeHelper.SerializeObject(DeleteUploadFile(context, dict)));
                break;

            //case "kanban":
            //    context.Response.Write(JsonSerializeHelper.SerializeObject(Kanban(context)));
            //    break;
            default:
                context.Response.Write(JsonSerializeHelper.SerializeObject(ExecuteMethod(dict["action"], dict)));
                break;
            }
        }
Esempio n. 4
0
 protected void Application_Start(object sender, EventArgs e)
 {
     InitializeHelper.Init();
 }