Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Acumatica批量上传库存商品图片_Acumatica - Fatal编程技术网

Acumatica批量上传库存商品图片

Acumatica批量上传库存商品图片,acumatica,Acumatica,我们有一份Acumatica的库存物品清单,现在想上传他们的照片。 有没有办法将库存物品的图片批量上传到Acumatica云平台? 感谢我建议将图像批量上传到库存或非库存项目,使用内置的合同API,我创建了以下示例代码项目,该项目将使用6.1版或更高版本中内置的“Default-6.00.001”端点 namespace MassInventoryItemImageUpload { class Program { static void Main(string[]

我们有一份Acumatica的库存物品清单,现在想上传他们的照片。 有没有办法将库存物品的图片批量上传到Acumatica云平台?
感谢

我建议将图像批量上传到库存或非库存项目,使用内置的合同API,我创建了以下示例代码项目,该项目将使用6.1版或更高版本中内置的“Default-6.00.001”端点

namespace MassInventoryItemImageUpload
{
    class Program
    {
        static void Main(string[] args)
        {
            //List of inventory Item CD's and associated file to upload.
            List<Tuple<string, string>> itemsToUpdate = new List<Tuple<string, string>>() { new Tuple<string, string>("InventoryItemCD", @"fileUrl") };

            Console.WriteLine("Updateing : " + itemsToUpdate.Count + " Inventory Items, press enter to begin");
            Console.ReadLine();

            AcumaticaProcessor processor = new AcumaticaProcessor();
            processor.Login();
            processor.UploadImages(itemsToUpdate);

            Console.WriteLine("Updates complete, press enter to exit program");
            Console.ReadLine();
        }
    }

    public class AcumaticaProcessor
    {
        DefaultSoapClient client = new DefaultSoapClient();

        public void Login()
        {
            client.Login("username", "password", "Company", "branch", null);
        }

        public void UploadImages(List<Tuple<string, string>> updateItems)
        {
            //Foreach Inventory Item in the list we are going to upload a files
            foreach(Tuple<string,string> updateItem in updateItems)
            {
                UploadImage(updateItem);
            }
        }

        private void UploadImage(Tuple<string, string> updateItem)
        {
            try
            {
                //Finds the StockItem with the given InventoryCD
                StockItem itemToUpdate = new StockItem()
                {
                    InventoryID = new StringSearch() { Value = updateItem.Item1 }
                };
                itemToUpdate = client.Get(itemToUpdate) as StockItem;

                //Updates found StockItem to include associated files
                client.PutFiles(itemToUpdate, FileData(updateItem.Item2));
            }
            catch(Exception e)
            {

            }
        }

        //Creates Acumatica File object from filestream and return File[] for uplaod 
        private Acumatica.File[] FileData(string url)
        {
            byte[] fileData;
            using (FileStream file = System.IO.File.Open(url, System.IO.FileMode.Open))
            {
                fileData = new byte[file.Length];
                file.Read(fileData, 0, fileData.Length);
            }
            return new Acumatica.File[1] { new Acumatica.File() { Name = url.Substring(url.LastIndexOf('\\') + 1), Content = fileData } };
        } 
    }
}
命名空间MassInventoryItemImageUpload
{
班级计划
{
静态void Main(字符串[]参数)
{
//要上载的库存项目CD和相关文件的列表。
List itemsToUpdate=new List(){new Tuple(“InventoryItemCD”,“fileUrl”)};
Console.WriteLine(“更新:+itemsToUpdate.Count+”库存项目,按enter键开始”);
Console.ReadLine();
AcumaticProcessor处理器=新AcumaticProcessor();
processor.Login();
处理器。上传图像(itemsToUpdate);
Console.WriteLine(“更新完成,按enter退出程序”);
Console.ReadLine();
}
}
公共类Acumatic处理器
{
DefaultSoapClient=新的DefaultSoapClient();
公共无效登录()
{
客户端登录(“用户名”、“密码”、“公司”、“分公司”,空);
}
公共无效上载图像(列表更新项)
{
//对于列表中的每个库存项目,我们将上载一个文件
foreach(updateItems中的元组updateItem)
{
上传图像(updateItem);
}
}
私有void上载映像(Tuple updateItem)
{
尝试
{
//查找具有给定InventoryCD的StockItem
StockItemToUpdate=新的StockItem()
{
InventoryID=new StringSearch(){Value=updateItem.Item1}
};
itemToUpdate=client.Get(itemToUpdate)作为StockItem;
//更新找到的StockItem以包括关联的文件
PutFiles(itemToUpdate,FileData(updateItem.Item2));
}
捕获(例外e)
{
}
}
//从filestream创建Acumatica文件对象,并为uplaod返回文件[]
私有Acumatica.File[]文件数据(字符串url)
{
字节[]文件数据;
使用(FileStream file=System.IO.file.Open(url,System.IO.FileMode.Open))
{
fileData=新字节[file.Length];
读取(fileData,0,fileData.Length);
}
返回新的Acumatica.File[1]{new Acumatica.File(){Name=url.Substring(url.LastIndexOf('\\'))+1),Content=fileData};
} 
}
}


其他文档:

我建议将图像大规模上传到库存或非库存项目,使用内置的合同API,我创建了以下示例代码项目,该项目将使用版本6.1或更高版本中内置的“Default-6.00.001”端点

namespace MassInventoryItemImageUpload
{
    class Program
    {
        static void Main(string[] args)
        {
            //List of inventory Item CD's and associated file to upload.
            List<Tuple<string, string>> itemsToUpdate = new List<Tuple<string, string>>() { new Tuple<string, string>("InventoryItemCD", @"fileUrl") };

            Console.WriteLine("Updateing : " + itemsToUpdate.Count + " Inventory Items, press enter to begin");
            Console.ReadLine();

            AcumaticaProcessor processor = new AcumaticaProcessor();
            processor.Login();
            processor.UploadImages(itemsToUpdate);

            Console.WriteLine("Updates complete, press enter to exit program");
            Console.ReadLine();
        }
    }

    public class AcumaticaProcessor
    {
        DefaultSoapClient client = new DefaultSoapClient();

        public void Login()
        {
            client.Login("username", "password", "Company", "branch", null);
        }

        public void UploadImages(List<Tuple<string, string>> updateItems)
        {
            //Foreach Inventory Item in the list we are going to upload a files
            foreach(Tuple<string,string> updateItem in updateItems)
            {
                UploadImage(updateItem);
            }
        }

        private void UploadImage(Tuple<string, string> updateItem)
        {
            try
            {
                //Finds the StockItem with the given InventoryCD
                StockItem itemToUpdate = new StockItem()
                {
                    InventoryID = new StringSearch() { Value = updateItem.Item1 }
                };
                itemToUpdate = client.Get(itemToUpdate) as StockItem;

                //Updates found StockItem to include associated files
                client.PutFiles(itemToUpdate, FileData(updateItem.Item2));
            }
            catch(Exception e)
            {

            }
        }

        //Creates Acumatica File object from filestream and return File[] for uplaod 
        private Acumatica.File[] FileData(string url)
        {
            byte[] fileData;
            using (FileStream file = System.IO.File.Open(url, System.IO.FileMode.Open))
            {
                fileData = new byte[file.Length];
                file.Read(fileData, 0, fileData.Length);
            }
            return new Acumatica.File[1] { new Acumatica.File() { Name = url.Substring(url.LastIndexOf('\\') + 1), Content = fileData } };
        } 
    }
}
命名空间MassInventoryItemImageUpload
{
班级计划
{
静态void Main(字符串[]参数)
{
//要上载的库存项目CD和相关文件的列表。
List itemsToUpdate=new List(){new Tuple(“InventoryItemCD”,“fileUrl”)};
Console.WriteLine(“更新:+itemsToUpdate.Count+”库存项目,按enter键开始”);
Console.ReadLine();
AcumaticProcessor处理器=新AcumaticProcessor();
processor.Login();
处理器。上传图像(itemsToUpdate);
Console.WriteLine(“更新完成,按enter退出程序”);
Console.ReadLine();
}
}
公共类Acumatic处理器
{
DefaultSoapClient=新的DefaultSoapClient();
公共无效登录()
{
客户端登录(“用户名”、“密码”、“公司”、“分公司”,空);
}
公共无效上载图像(列表更新项)
{
//对于列表中的每个库存项目,我们将上载一个文件
foreach(updateItems中的元组updateItem)
{
上传图像(updateItem);
}
}
私有void上载映像(Tuple updateItem)
{
尝试
{
//查找具有给定InventoryCD的StockItem
StockItemToUpdate=新的StockItem()
{
InventoryID=new StringSearch(){Value=updateItem.Item1}
};
itemToUpdate=client.Get(itemToUpdate)作为StockItem;
//更新找到的StockItem以包括关联的文件
PutFiles(itemToUpdate,FileData(updateItem.Item2));
}
捕获(例外e)
{
}
}
//从filestream创建Acumatica文件对象,并为uplaod返回文件[]
私有Acumatica.File[]文件数据(字符串url)
{
字节[]文件数据;
使用(FileStream file=System.IO.file.Open(url,System.IO.FileMode.Open))
{
fileData=新字节[file.Length];
读取(fileData,0,fileData.Length);
}
返回新的Acumatica.File[1]{new Acumatica.File(){Name=url.Substring(url.LastIndexOf('\\'))+1),Content=fileData};
} 
}
}

其他文件: