【问题标题】:Saving a file in FILES将文件保存在 FILES 中
【发布时间】:2021-03-18 11:56:33
【问题描述】:

我想通过单击“保存文件”操作将生成的文本文件保存在 Acumatica 页面的“文件”部分。这是我当前生成文本文件的代码:

    string[] lines = { fileLine1, fileLine2, fileLine3 };
    File.WriteAllLines(path, lines);

这只是在我机器上的指定路径中生成一个文本文件。

批量支付屏幕截图

Batch Payments Screen

任何帮助将不胜感激。

【问题讨论】:

    标签: c# acumatica acumatica-kb


    【解决方案1】:

    我会尝试类似下面的“消息”是一个字符串。

                    using (MemoryStream stream = new MemoryStream())
                    {
                        stream.Write(Encoding.UTF8.GetBytes(message), 0, message.Length);
    
                        string path = "MyFile.txt"; 
                        PX.SM.FileInfo info = new PX.SM.FileInfo(path, null, stream.ToArray());
    
                        //Attach file to Doc
                        info.Comment = "message generated on " + DateTime.Now.ToShortDateString();
                        UploadFileMaintenance upload = PXGraph.CreateInstance<UploadFileMaintenance>();
    
                        //Save file to acumatica
                        if (upload.SaveFile(info, FileExistsAction.CreateVersion))
                        {
                            //Create connection to the Batch
                            PXNoteAttribute.SetFileNotes(mysetup.connection.Cache, conn, info.UID.Value);
                            
                        }
    
                    }
    

    【讨论】:

    • 到目前为止一切看起来都不错,但我只是不明白你在 'PXNoteAttribute.SetFileNotes(mysetup.connection.Cache, conn, info.UID.Value); 中的 'conn' 是什么意思'。能否请您详细说明。
    • Conn 是 mysetup.connection.cache 中包含的类型的对象
    • 感谢@Patrick Chen 的帮助,帮我搞定了。
    猜你喜欢
    • 2014-01-19
    • 2021-07-04
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 2019-10-18
    • 2020-03-15
    • 1970-01-01
    相关资源
    最近更新 更多