工作流收信箱批量下载附件二开示例

第一步:在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 (!Direct工作流收信箱批量下载附件二开示例
第一步:在BOS设计器找到收信箱元数据WF_MessageBill,拓展之后,添加批量下载菜单:第二步:在拓展的元数据的表单插件中,挂上插件,插件...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



