C# 如何使用acumatica web服务在acumatica屏幕中上载文档

C# 如何使用acumatica web服务在acumatica屏幕中上载文档,c#,acumatica,C#,Acumatica,我不熟悉使用acumatica web服务。是否可以将特定屏幕中的文档/文件作为附件(如业务帐户附件)上传 例如,在我们手动添加的屏幕下方 我找到了解决方案,并发布帖子帮助任何人。 要上传任何文件,我们必须将该文件转换为字节,并提交转换文件的字节 //Get bytes of file byte[] filedata; using(System.IO.FileStream file = Sy

我不熟悉使用acumatica web服务。是否可以将特定屏幕中的文档/文件作为附件(如业务帐户附件)上传

例如,在我们手动添加的屏幕下方


我找到了解决方案,并发布帖子帮助任何人。 要上传任何文件,我们必须将该文件转换为字节,并提交转换文件的字节

             //Get bytes of file

             byte[] filedata;
             using(System.IO.FileStream file =
             System.IO.File.Open(@"D:\Test.pdf",System.IO.FileMode.Open)) 
             {
                 filedata = new byte[file.Length];
                 file.Read(filedata,0,filedata.Length);
             }

            //   Import Data Now to Business Account

                BAccount.CR303000ImportResult[] lstObjContent = context.CR303000Import
               (
                new BAccount.Command[]
               {
                 // Must Pass BusinessAccount in which we want to update or add data
                 new BAccount.Value { Value="XXXXXX",LinkedCommand=objContent.AccountSummary.BusinessAccount},
                 new BAccount.Value { Value="TestValue123",LinkedCommand=objContent.AccountSetup.CurrentMethod},
                 new BAccount.Value { FieldName="NameOfFileWithExtension",LinkedCommand=objContent.AccountSummary.ServiceCommands.Attachment},
                 objContent.Actions.Save
                },null,new string[][] { new string[] { Convert.ToBase64String(filedata) },new string[] { Convert.ToBase64String(filedata) },}
                 ,false,false,true
            );

我找到了解决方案,并发布了帮助任何人的帖子。 要上传任何文件,我们必须将该文件转换为字节,并提交转换文件的字节

             //Get bytes of file

             byte[] filedata;
             using(System.IO.FileStream file =
             System.IO.File.Open(@"D:\Test.pdf",System.IO.FileMode.Open)) 
             {
                 filedata = new byte[file.Length];
                 file.Read(filedata,0,filedata.Length);
             }

            //   Import Data Now to Business Account

                BAccount.CR303000ImportResult[] lstObjContent = context.CR303000Import
               (
                new BAccount.Command[]
               {
                 // Must Pass BusinessAccount in which we want to update or add data
                 new BAccount.Value { Value="XXXXXX",LinkedCommand=objContent.AccountSummary.BusinessAccount},
                 new BAccount.Value { Value="TestValue123",LinkedCommand=objContent.AccountSetup.CurrentMethod},
                 new BAccount.Value { FieldName="NameOfFileWithExtension",LinkedCommand=objContent.AccountSummary.ServiceCommands.Attachment},
                 objContent.Actions.Save
                },null,new string[][] { new string[] { Convert.ToBase64String(filedata) },new string[] { Convert.ToBase64String(filedata) },}
                 ,false,false,true
            );

甚至下面的代码也可以工作。已在版本18R1中验证

 var content = _context.CR306000GetSchema(); _context.CR306000Clear();

 var commands = new List();

 ReqParameter(content, ref commands);

 commands.Add(content.Actions.Save);

 commands.Add(content.CaseSummary.CaseID);

 var orderResults = _context.CR306000Submit(commands.ToArray());

 private static void ReqParameter(CR306000Content content, ref List<Command> cmds)
    {
        if (cmds == null) throw new ArgumentNullException("cmds");        

        byte[] filedata= null;            
        Uri uri = new Uri("https://acmdev.baccahq.com/Icons/login_bg5.jpg");  // change the required url of the data that has to be fetched 

        if (uri.IsFile)
        {
            string filename = System.IO.Path.GetFileName(uri.LocalPath);
            filedata = System.Text.Encoding.UTF8.GetBytes(uri.LocalPath);
        }
        if (filedata == null)
        {
            WebClient wc = new WebClient();
            filedata = wc.DownloadData(uri);
        }

        cmds = new List<Command>
        {

            //Case Header Details
            new Value { Value="<NEW>",LinkedCommand = content.CaseSummary.CaseID},
            new Value { Value="L41",LinkedCommand = content.CaseSummary.ClassID},
            new Value { Value="ABCSTUDIOS",LinkedCommand = content.CaseSummary.BusinessAccount, Commit = true},          
            new Value { Value="Test subject created from envelop call 11C",LinkedCommand = content.CaseSummary.Subject},           

            // body of the case 
            new Value{Value= "Body of the content for created through envelop call 11B", LinkedCommand = content.Details.Description},


            //Attaching a file
            new Value
            {
                Value = Convert.ToBase64String(filedata),   // byte data that is passed to through envelop 
                FieldName = "Test.jpg",
                LinkedCommand =
            content.CaseSummary.ServiceCommands.Attachment
            },


         };
    }
var content=\u context.CR306000GetSchema()_CR306000Clear();
var命令=新列表();
REQ参数(内容、ref命令);
commands.Add(content.Actions.Save);
commands.Add(content.casesummmary.CaseID);
var orderResults=_context.CR306000Submit(commands.ToArray());
专用静态void ReqParameter(CR306000内容,参考列表cmds)
{
如果(cmds==null)抛出新的ArgumentNullException(“cmds”);
字节[]filedata=null;
Uri=新的Uri(“https://acmdev.baccahq.com/Icons/login_bg5.jpg“”;//更改必须提取的数据的所需url
if(uri.IsFile)
{
字符串filename=System.IO.Path.GetFileName(uri.LocalPath);
filedata=System.Text.Encoding.UTF8.GetBytes(uri.LocalPath);
}
if(filedata==null)
{
WebClient wc=新的WebClient();
filedata=wc.DownloadData(uri);
}
cmds=新列表
{
//案例标题详细信息
新值{Value=”“,LinkedCommand=content.caseSummmary.CaseID},
新值{Value=“L41”,LinkedCommand=content.CaseSummary.ClassID},
新值{Value=“ABCSTUDIOS”,LinkedCommand=content.casesummmary.BusinessAccount,Commit=true},
新值{Value=“从信封调用11C创建的测试主题”,LinkedCommand=content.casesummmary.subject},
//案情
新值{Value=“通过信封调用11B创建的内容体”,LinkedCommand=content.Details.Description},
//附加文件
新价值
{
Value=Convert.ToBase64String(filedata),//通过信封传递到的字节数据
FieldName=“Test.jpg”,
链接命令=
content.casesummmary.servicecondmands.Attachment
},
};
}

即使下面的代码也可以工作。已在版本18R1中验证

 var content = _context.CR306000GetSchema(); _context.CR306000Clear();

 var commands = new List();

 ReqParameter(content, ref commands);

 commands.Add(content.Actions.Save);

 commands.Add(content.CaseSummary.CaseID);

 var orderResults = _context.CR306000Submit(commands.ToArray());

 private static void ReqParameter(CR306000Content content, ref List<Command> cmds)
    {
        if (cmds == null) throw new ArgumentNullException("cmds");        

        byte[] filedata= null;            
        Uri uri = new Uri("https://acmdev.baccahq.com/Icons/login_bg5.jpg");  // change the required url of the data that has to be fetched 

        if (uri.IsFile)
        {
            string filename = System.IO.Path.GetFileName(uri.LocalPath);
            filedata = System.Text.Encoding.UTF8.GetBytes(uri.LocalPath);
        }
        if (filedata == null)
        {
            WebClient wc = new WebClient();
            filedata = wc.DownloadData(uri);
        }

        cmds = new List<Command>
        {

            //Case Header Details
            new Value { Value="<NEW>",LinkedCommand = content.CaseSummary.CaseID},
            new Value { Value="L41",LinkedCommand = content.CaseSummary.ClassID},
            new Value { Value="ABCSTUDIOS",LinkedCommand = content.CaseSummary.BusinessAccount, Commit = true},          
            new Value { Value="Test subject created from envelop call 11C",LinkedCommand = content.CaseSummary.Subject},           

            // body of the case 
            new Value{Value= "Body of the content for created through envelop call 11B", LinkedCommand = content.Details.Description},


            //Attaching a file
            new Value
            {
                Value = Convert.ToBase64String(filedata),   // byte data that is passed to through envelop 
                FieldName = "Test.jpg",
                LinkedCommand =
            content.CaseSummary.ServiceCommands.Attachment
            },


         };
    }
var content=\u context.CR306000GetSchema()_CR306000Clear();
var命令=新列表();
REQ参数(内容、ref命令);
commands.Add(content.Actions.Save);
commands.Add(content.casesummmary.CaseID);
var orderResults=_context.CR306000Submit(commands.ToArray());
专用静态void ReqParameter(CR306000内容,参考列表cmds)
{
如果(cmds==null)抛出新的ArgumentNullException(“cmds”);
字节[]filedata=null;
Uri=新的Uri(“https://acmdev.baccahq.com/Icons/login_bg5.jpg“”;//更改必须提取的数据的所需url
if(uri.IsFile)
{
字符串filename=System.IO.Path.GetFileName(uri.LocalPath);
filedata=System.Text.Encoding.UTF8.GetBytes(uri.LocalPath);
}
if(filedata==null)
{
WebClient wc=新的WebClient();
filedata=wc.DownloadData(uri);
}
cmds=新列表
{
//案例标题详细信息
新值{Value=”“,LinkedCommand=content.caseSummmary.CaseID},
新值{Value=“L41”,LinkedCommand=content.CaseSummary.ClassID},
新值{Value=“ABCSTUDIOS”,LinkedCommand=content.casesummmary.BusinessAccount,Commit=true},
新值{Value=“从信封调用11C创建的测试主题”,LinkedCommand=content.casesummmary.subject},
//案情
新值{Value=“通过信封调用11B创建的内容体”,LinkedCommand=content.Details.Description},
//附加文件
新价值
{
Value=Convert.ToBase64String(filedata),//通过信封传递到的字节数据
FieldName=“Test.jpg”,
链接命令=
content.casesummmary.servicecondmands.Attachment
},
};
}

您使用的是基于屏幕的API还是基于联系人的API?基于屏幕的API但我使用附件命令解决了问题并将文件转换为BASE64您使用的是基于屏幕的API还是基于联系人的API?基于屏幕的API但我使用附件命令解决了问题并将文件转换为BASE64您能告诉我如何使用rest API上载文件吗文件使用RESTAPI。