工作流收信箱批量下载附件二开示例
第一步:在BOS设计器找到收信箱元数据WF_MessageBill,拓展之后,添加批量下载菜单:
第二步:在拓展的元数据的表单插件中,挂上插件,插件代码示例如下:
using ICSharpCode.SharpZipLib.Zip; using Kingdee.BOS.Core; using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Util;
private string _temppath; public override void BarItemClick(Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e) { base.BarItemClick(e); if (e.BarItemKey.EqualsIgnoreCase("FBatchDownload")) { Download(); } } private void Download() { var attachment = this.Model.GetValue("FFileUpdate"); var array = SerializatonUtil.DeserializeFromBase64<JSON.JSONArray>(attachment.ToString()); //待压缩临时文件夹路径。 _temppath = HttpContext.Current.Server.MapPath(KeyConst.TEMPFILEPATH); string tempZipDirPath = Path.Combine(_temppath, Guid.NewGuid().ToString()); Directory.CreateDirectory(tempZipDirPath); foreach (var ar in array) { string serverFileName = Convert.ToString(((JSON.JSONObject)ar)["ServerFileName"]); var fileContenObject = ((JSON.JSONObject)ar)["FileContent"]; string tempZipFilePath = Path.Combine(tempZipDirPath, serverFileName); DownloadFileFromDatabase(tempZipFilePath, (Byte[])fileContenObject); } CheckAndCompresseFile(tempZipDirPath); } private void DownloadFileFromDatabase(string tempZipFilePath, Byte[] fileContenObject) { using (FileStream fs = new FileStream(tempZipFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.Read)) using (BinaryWriter bw = new BinaryWriter(fs)) { bw.Write(fileContenObject); } } private void CheckAndCompresseFile(string tempZipDirPath) { DirectoryInfo dirInfo = new DirectoryInfo(tempZipDirPath); if (dirInfo.GetFiles().Length <= 0) { return; } var _zipfilename = string.Format("Attachment_{0}.zip", Guid.NewGuid()); string zipfilepath = Path.Combine(_temppath, _zipfilename); CreateZipFile(tempZipDirPath, zipfilepath); ShowZipDownLoadForm(zipfilepath); } private void CreateZipFile(string sourceDirectory, string zipFilePath) { if (!Directory.Exists(sourceDirectory)) { return; } ZipOutputStream stream = null; try { stream = new ZipOutputStream(File.Create(zipFilePath)); stream.SetLevel(0); // 压缩级别 0-9 byte[] buffer = new byte[4096]; //缓冲区大小 string[] filenames = Directory.GetFiles(sourceDirectory, "*.*", SearchOption.AllDirectories); foreach (string file in filenames) { ZipEntry entry = new ZipEntry(file.Replace(sourceDirectory, "").TrimStart('\\')); entry.DateTime = DateTime.Now; stream.PutNextEntry(entry); using (FileStream fs = File.OpenRead(file)) { int sourceBytes; do { sourceBytes = fs.Read(buffer, 0, buffer.Length); stream.Write(buffer, 0, sourceBytes); } while (sourceBytes > 0); } } } finally { if (stream != null) { stream.Finish(); stream.Close(); } } } private void ShowZipDownLoadForm(string zipfilepath) { string downloadUrl = PathUtils.ConvertPhysicalPathToDownloadUrl(this.Context, zipfilepath); ViewCommonAction.ShowWebURL(this.View, downloadUrl); this.View.SendDynamicFormAction(this.View); }
工作流收信箱批量下载附件二开示例
第一步:在BOS设计器找到收信箱元数据WF_MessageBill,拓展之后,添加批量下载菜单:第二步:在拓展的元数据的表单插件中,挂上插件,插件...
点击下载文档
本文2024-09-23 04:20:20发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164668.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
- 鼎捷EAI整合規範文件V3.1.07 (集團).pdf
- 鼎捷OpenAPI應用場景說明_基礎資料.pdf
- 鼎捷OpenAPI應用場景說明_財務管理.pdf
- 鼎捷T100 API設計器使用手冊T100 APIDesigner(V1.0).docx
- 鼎新e-GoB2雲端ERP B2 線上課程E6-2應付票據整批郵寄 領取.pdf
- 鼎新e-GoB2雲端ERP B2 線上課程A4使用者建立權限設定.pdf
- 鼎新e-GoB2雲端ERP B2 線上課程C3會計開帳與會計傳票.pdf
- 鼎新e-GoB2雲端ERP B2 線上課程E6-1應付票據.pdf
- 鼎新e-GoB2雲端ERP B2 線上課程A5-1進銷存參數設定(初階篇).pdf
- 鼎新e-GoB2雲端ERP B2 線上課程D2帳款開帳與票據開帳.pdf
热门文章