我可以通过 API 删除 Acumatica 中的文件吗?

六月乙

我通过从 API 调用操作在 Acumatica 中创建一个文件,以便我可以在我的应用程序中检索该文件。

完成后是否可以通过 API 删除文件?我宁愿不让它弄乱我的 Acumatica 数据库。

如果做不到这一点,是否有推荐的清理这些文件的方法?

六月乙

找到了如何从 Acumatica 中删除文件以及如何保存现有文件的新版本的示例!下面的实现保存了一个新版本,但注释掉了删除方法。因为我将它构建到我的报告生成过程中,所以我以后不会通过 API 删除报告,但是很容易将删除转换为可由 API 调用的操作。

private IEnumerable ExportReport(PXAdapter adapter, string reportID, Dictionary<String, String> parameters)
    {
        //Press save if the SO is not completed 
        if (Base.Document.Current.Completed == false)
        {
            Base.Save.Press();
        }

        PX.SM.FileInfo file = null;
        using (Report report = PXReportTools.LoadReport(reportID, null))
        {
            if (report == null)
            {
                throw new Exception("Unable to access Acumatica report writer for specified report : " + reportID);
            }

            PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
            ReportNode reportNode = ReportProcessor.ProcessReport(report);
            IRenderFilter renderFilter = ReportProcessor.GetRenderer(ReportProcessor.FilterPdf);

            //Generate the PDF
            byte[] data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterPdf).First();
            file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

            //Save the PDF to the SO
            UploadFileMaintenance graph = new UploadFileMaintenance();

            //Check to see if a file with this name already exists                
            Guid[] files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
            foreach (Guid fileID in files)
            {
                FileInfo existingFile = graph.GetFileWithNoData(fileID);
                if (existingFile.Name == reportNode.ExportFileName + ".pdf")
                {
                    //If we later decide we want to delete previous versions instead of saving them, this can be changed to 
                    //UploadFileMaintenance.DeleteFile(existingFile.UID);
                    //But in the meantime, for history purposes, set the UID of the new file to that of the existing file so we can save it as a new version.
                    file.UID = existingFile.UID;
                }
            }

            //Save the file with the setting to create a new version if one already exists based on the UID                          
            graph.SaveFile(file, FileExistsAction.CreateVersion);  
            //Save the note attribute so we can find it again.              
            PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);
        }

        //Return the info on the file
        return adapter.Get();
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

当我的最低API为21时,可以在Android中删除可绘制的文件夹吗?

我可以在Python中异步删除文件吗?

我可以删除迁移目录中的django迁移文件吗

我可以通过病毒删除删除留在桌面上的空白文件吗?

iso文件可以从liveusb中删除吗?

可以通过 API 以编程方式从用户的 Gmail 收件箱中删除电子邮件吗?

我可以通过某种方式删除动画吗?

我可以删除日志文件吗?

我可以删除.hgtags文件吗?

我可以阻止自己删除文件吗?

我可以删除Ktorrent * .dnd文件吗?

我可以通过这种方式安全地删除文件吗?

从Acumatica删除报告

Acumatica 自定义:我可以使用反射获取缓存中字段的值吗?

我们可以通过编程方式删除“反应选择”中的选定选项吗?

我可以通过 HTTP DELETE 请求消息删除路径中的所有数据吗?

我可以删除awk中的字段吗?

我可以从Debian中删除GUI吗?

我可以在反应中删除道具吗

我可以通过API禁用YouTube实时聊天吗?

我可以通过Azure API管理运行SignalR集线器吗?

我可以通过代码启动Chrome扩展程序API吗?

我可以通过编程调用任何Eclipse重构API吗?

通过 api,我可以强制用户登录 reddit 吗?

我可以通过API使用uglifyjs美化javascript吗?

我可以通过ruby REST API调用创建方法吗?

我可以通过 JMeter 访问私有 api 吗

我可以从maildir cur文件夹中删除或移动邮件文件吗?

我可以选择性地删除.cabal文件中的`ghc-options'特定文件吗?