0

我想知道是否可以在 Web 服务 API 中检索特定属性?我IN202500.AttributesAttributes.Value在导出时尝试过,但列出了库存的所有属性。我还注意到属性在 Inventory 表中作为 [AttributeName]_Attributes 保存在表中,有什么方法可以检索它吗?

这是我正在使用的代码(期望它会检索属性)

IN202500Content IN202500 = context.IN202500GetSchema();
context.IN202500Clear();

Command[] oCmd = new Command[] {
                      IN202500.StockItemSummary.ServiceCommands.EveryInventoryID,
                      IN202500.StockItemSummary.InventoryID,
                      IN202500.StockItemSummary.Description, 
                      IN202500.StockItemSummary.ItemStatus, 
                      IN202500.GeneralSettingsItemDefaults.ItemClass, 
                      IN202500.GeneralSettingsItemDefaults.LotSerialClass,
                      new Field  {  
                          ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName,
                          FieldName = "BARCODE_Attributes"}, 
                      new Field  {  
                          ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName, 
                          FieldName = "DfltReceiptLocationID"},   
                      new Field  {  
                          ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName, 
                          FieldName = "LastModifiedDateTime"}   
                      };

Filter[] oFilter = new Filter[] {
                      new Filter 
                      {
                          Field = new Field {
                              ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName,
                              FieldName = "LastModifiedDateTime"},
                          Condition = FilterCondition.Greater,
                          Value = SyncDate
                       }
                    };

String[][] sReturn = context.IN202500Export(oCmd, oFilter, 0, true, false);

但是返回的属性字段是一个空字符串。谢谢,G

4

2 回答 2

1

您可以利用添加到屏幕主视图的动态字段来检索特定属性值。这些字段不会显示在 WSDL 模式中,因此您必须创建一个 Field 对象并将其传递给 Export 函数。

我通过显示本地对象/本地字段名称列从导出场景中查找字段名称和对象名称。生成的导出调用如下所示:

        var result = screen.Export(new IN202500.Command[] { 
            new IN202500.Value() { LinkedCommand = schema.StockItemSummary.InventoryID, Value = "Z730P00073"},
            schema.StockItemSummary.InventoryID,
            schema.StockItemSummary.Description,
            new IN202500.Field { FieldName = "COLOR_Attributes", ObjectName = "Item"},
            new IN202500.Field { FieldName = "HWMAN_Attributes", ObjectName = "Item"},
        }, null, 0, true, true);

此代码将检索特定库存项目 (Z730P00073) 的两个属性值(COLOR 和 HWMAN 属性)。结果变量包含一个二维数组,如果您需要帮助从数组中获取结果,请告诉我。

于 2015-01-26T14:37:16.967 回答
0

此示例显示如何添加项目并设置属性和图像:

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

        Random rnd = new Random();  
        string inventoryID = "CPU0000" + rnd.Next(100).ToString();
        context.IN202500Clear();            
        IN202500result = context.IN202500Submit(
            new Command[] 
            {
                IN202500.Actions.Insert,
                new Value { Value = inventoryID, LinkedCommand = IN202500.StockItemSummary.InventoryID },
                new Value { Value = inventoryID, LinkedCommand = IN202500.StockItemSummary.Description },
                new Value { Value = "CPU", LinkedCommand = IN202500.GeneralSettingsItemDefaults.ItemClass, Commit = true },
                new Value { Value = "TAXABLE", LinkedCommand = IN202500.GeneralSettingsItemDefaults.TaxCategory, Commit = true },                    
                //attributes - pairs 
                new Value { Value = "FREQUENCY", LinkedCommand = IN202500.AttributesAttributes.Attribute },
                new Value { Value = "1400", LinkedCommand = IN202500.AttributesAttributes.Value, Commit = true },
                new Value { Value = "CORE", LinkedCommand = IN202500.AttributesAttributes.Attribute },
                new Value { Value = "2 CORES", LinkedCommand = IN202500.AttributesAttributes.Value, Commit = true },
                new Value { Value = "INTGRAPH", LinkedCommand = IN202500.AttributesAttributes.Attribute },
                new Value { Value = "True", LinkedCommand = IN202500.AttributesAttributes.Value, Commit = true },
                //image
                new Value { Value = Convert.ToBase64String(filedata), FieldName = "1.jpg", LinkedCommand = IN202500.StockItemSummary.ServiceCommands.Attachment }, //uploads
                new Value { Value = "1.jpg", LinkedCommand = IN202500.Attributes.ImageUrl }, //sets as an item picture
                IN202500.Actions.Save,
                //return the result
                IN202500.StockItemSummary.InventoryID
        });
于 2015-01-23T18:13:54.513 回答