打开/下载文件的超链接 (Acumatica) [英] Hyperlink to open/download a File (Acumatica)

查看:33
本文介绍了打开/下载文件的超链接 (Acumatica)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法建立一个文件的超链接,该文件将打开其内容或从它所属的表中下载它?(在某种意义上,做与 AllowEdit 完全相同的事情,但改为打开/下载文件.)示例:

Is there any way to make a hyperlink to a file that will open its contents or download it from the table it belongs? (In a sense, do exactly the same thing as AllowEdit but open/download the file instead.) Example:

默认规范文件来自客户的文件:

Where the Default Specification files are from files found on the customer:

请注意,显示的是文件的注释.如果有人对如何显示文件名有任何建议,也将不胜感激.

Please note that what displays is the comment of the file. If anyone has any suggestions on how to display the file name instead, that would be appreciated as well.

推荐答案

你可以这样获取文件名:

You can get the filename like this:

UploadFileMaintenance uploadFileMaintenance = PXGraph.CreateInstance<UploadFileMaintenance>();

foreach (Guid note in PXNoteAttribute.GetFileNotes(cache, dacRecord))
{
    FileInfo file = uploadFileMaintenance.GetFileWithNoData(note);
    PXTrace.WriteInformation(file.Name);
}

要下载文件,请创建字符串类型的 DAC 字段.您可以在 FieldDefaulting 或 FieldSelecting 事件中将字符串初始化为文件名.声明一个 Action 并使用 ASPX 文件中的 LinkCommand 属性使该字段控制一个链接.

To download the file, create a DAC field of string type. You can initialize the string to the file name in the FieldDefaulting or FieldSelecting event. Declare an Action and use the LinkCommand attribute in the ASPX file to make that field control a link.

在那个 Action 事件处理程序中,您可以将浏览器重定向到文件以下载/打开它:

In that Action event handler, you can redirect the browser to the file in order to download/open it:

    UploadFileMaintenance uploadFileMaintenance = PXGraph.CreateInstance<UploadFileMaintenance>();
    Guid[] notes = PXNoteAttribute.GetFileNotes(cache, dacRecord);
    
    if (notes != null && notes.Length > 0)
    {
        FileInfo downloadFile = uploadFileMaintenance.GetFile(notes[0]);
    
        if (downloadFile != null)
        {
            throw new PXRedirectToFileException(downloadFile.UID, true);
        }
    }

这篇关于打开/下载文件的超链接 (Acumatica)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆