Guest User

Untitled

a guest
Jan 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.ServiceModel.Description;
  6. using System.Text;
  7. using Tutorial.AIF.CreateItem.EcoResProductServices;
  8. using Tutorial.AIF.CreateItem.InventItemServices;
  9.  
  10. namespace Tutorial.AIF.CreateItem
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. try
  17. {
  18. ItemServiceCreateRequest request = new ItemServiceCreateRequest();
  19. ItemServiceClient client = new ItemServiceClient();
  20.  
  21. EcoResProductServiceCreateRequest prodRequest = new EcoResProductServiceCreateRequest();
  22. EcoResProductServiceClient prodClient = new EcoResProductServiceClient();
  23.  
  24. ReqItemTableServiceCreateRequest reqItemRequest = new ReqItemTableServiceCreateRequest();
  25. ReqItemTableServiceClient reqItemClient = new ReqItemTableServiceClient();
  26.  
  27. reqItemRequest.CallContext = new InventItemServices.CallContext();
  28. reqItemRequest.CallContext.Company = "CAD";
  29. reqItemRequest.CallContext.Language = "en-us";
  30. reqItemRequest.CallContext.MessageId = Guid.NewGuid().ToString();
  31.  
  32. prodRequest.CallContext = new EcoResProductServices.CallContext();
  33. prodRequest.CallContext.Language = "en-us";
  34. prodRequest.CallContext.Company = "CAD";
  35. prodRequest.CallContext.MessageId = Guid.NewGuid().ToString();
  36.  
  37. request.CallContext = new Tutorial.AIF.CreateItem.InventItemServices.CallContext();
  38. request.CallContext.Language = "en-us";
  39. request.CallContext.Company = "CAD";
  40. request.CallContext.MessageId = Guid.NewGuid().ToString();
  41.  
  42. AxdEntity_Product_EcoResProduct[] ecoResProduct = new AxdEntity_Product_EcoResProduct[1];
  43. ecoResProduct[0] = new AxdEntity_Product_EcoResDistinctProduct();
  44. ecoResProduct[0].ProductType = AxdEnum_EcoResProductType.Item;
  45. ecoResProduct[0].SearchName = "68727900121";
  46. ecoResProduct[0].DisplayProductNumber = "ITEM002";
  47.  
  48. AxdEntity_Translation prodTranslation = new AxdEntity_Translation();
  49. prodTranslation.Name = "ITEM002";
  50. prodTranslation.LanguageId = "en-us";
  51.  
  52. ecoResProduct[0].Translation = new[] { prodTranslation };
  53.  
  54.  
  55. AxdEntity_Identifier identifier = new AxdEntity_Identifier();
  56. identifier.ProductNumber = "68727900121";
  57.  
  58. ecoResProduct[0].Identifier = new AxdEntity_Identifier[1];
  59. ecoResProduct[0].Identifier[0] = identifier;
  60.  
  61.  
  62. AxdEcoResProduct product = new AxdEcoResProduct();
  63. product.Product = ecoResProduct;
  64.  
  65. prodClient.Open();
  66. Tutorial.AIF.CreateItem.EcoResProductServices.EntityKey[] keys = prodClient.create(prodRequest.CallContext, product);
  67. prodClient.Close();
  68.  
  69. AxdEntity_InventTable[] inventTable = new AxdEntity_InventTable[1];
  70. inventTable[0] = new AxdEntity_InventTable();
  71. inventTable[0].ItemId = "ITEM002";
  72. inventTable[0].NameAlias = "ITEMNAMEALIAS";
  73. inventTable[0].Product = "ITEM002";
  74. //inventTable[0].Product = keys[0].KeyData[0].Value.Trim();
  75.  
  76. inventTable[0].StorageDimensionGroup = new[] { new AxdEntity_StorageDimensionGroup { StorageDimensionGroup = "DEF", ItemId = inventTable[0].ItemId } };
  77. inventTable[0].TrackingDimensionGroup = new[] { new AxdEntity_TrackingDimensionGroup { TrackingDimensionGroup = "DEF", ItemId = inventTable[0].ItemId } };
  78. inventTable[0].InventModelGroupItem = new[] { new AxdEntity_InventModelGroupItem { ModelGroupId = "DEF", ItemId = inventTable[0].ItemId } };
  79. inventTable[0].InventItemGroupItem = new[] { new AxdEntity_InventItemGroupItem { ItemGroupId = "ALL", ItemId = inventTable[0].ItemId } };
  80.  
  81. //if you want to insert reqItemTable (item coverage settings) you need to create a service for that
  82.  
  83. //INVENTDIMID
  84. inventTable[0].InventItemPurchSetup = new[] {
  85. new AxdEntity_InventItemPurchSetup {
  86. //HERE WE WILL ADD ORDER SPECIFIC SETTINGS FOR THIS PARTICULAR ITEM
  87. ItemId = inventTable[0].ItemId,
  88. InventDimPurchSetup = new AxdEntity_InventDimPurchSetup[] {
  89. new AxdEntity_InventDimPurchSetup() {
  90. InventDimId = "AllBlank"
  91. }
  92. },
  93. DefaultInventDimPurchSetup = new [] {
  94. new AxdEntity_DefaultInventDimPurchSetup() {
  95. InventDimId = "AllBlank",
  96. InventSiteId = "MTL-01"
  97. }
  98. }
  99. },
  100. //HERE WE WILL ADD SITE SPECIFIC SETTINGS FOR THIS PARTICULAR ITEM
  101. new AxdEntity_InventItemPurchSetup {
  102. ItemId = inventTable[0].ItemId,
  103. InventDimPurchSetup = new AxdEntity_InventDimPurchSetup[] {
  104. new AxdEntity_InventDimPurchSetup() {
  105. InventSiteId = "MTL-01"
  106. }
  107. },
  108. DefaultInventDimPurchSetup = new [] {
  109. new AxdEntity_DefaultInventDimPurchSetup() {
  110. InventLocationId = "01"
  111. }
  112. }
  113. },
  114. };
  115.  
  116.  
  117. inventTable[0].InventItemSalesSetup = new[] {
  118. new AxdEntity_InventItemSalesSetup {
  119. ItemId = inventTable[0].ItemId,
  120. InventDimSalesSetup = new AxdEntity_InventDimSalesSetup[] {
  121. new AxdEntity_InventDimSalesSetup() {
  122. InventDimId = "AllBlank"
  123. }
  124. },
  125. DefaultInventDimSalesSetup = new [] {
  126. new AxdEntity_DefaultInventDimSalesSetup() {
  127. InventDimId = "AllBlank",
  128. InventSiteId = "MTL-01"
  129. }
  130. }
  131.  
  132. },
  133. new AxdEntity_InventItemSalesSetup {
  134. ItemId = inventTable[0].ItemId,
  135. InventDimSalesSetup = new AxdEntity_InventDimSalesSetup[] {
  136. new AxdEntity_InventDimSalesSetup() {
  137. InventSiteId = "MTL-01"
  138. }
  139. },
  140. DefaultInventDimSalesSetup = new [] {
  141. new AxdEntity_DefaultInventDimSalesSetup() {
  142. InventLocationId = "01"
  143. }
  144. }
  145.  
  146. }
  147. };
  148.  
  149. inventTable[0].InventItemInventSetup = new[] {
  150. new AxdEntity_InventItemInventSetup {
  151. ItemId = inventTable[0].ItemId,
  152. InventDimInventSetup = new AxdEntity_InventDimInventSetup[] {
  153. new AxdEntity_InventDimInventSetup() {
  154. InventDimId = "AllBlank"
  155. }
  156. },
  157. DefaultInventDimInventSetup = new [] {
  158. new AxdEntity_DefaultInventDimInventSetup() {
  159. InventDimId = "AllBlank",
  160. InventSiteId = "MTL-01"
  161. }
  162. }
  163.  
  164. },
  165. new AxdEntity_InventItemInventSetup {
  166. ItemId = inventTable[0].ItemId,
  167. InventDimInventSetup = new AxdEntity_InventDimInventSetup[] {
  168. new AxdEntity_InventDimInventSetup() {
  169. InventSiteId = "MTL-01"
  170. }
  171. },
  172. DefaultInventDimInventSetup = new [] {
  173. new AxdEntity_DefaultInventDimInventSetup() {
  174. InventLocationId = "01"
  175. }
  176. }
  177.  
  178. }
  179. };
  180.  
  181.  
  182. AxdItem items = new AxdItem();
  183. items.InventTable = inventTable;
  184.  
  185. client.Open();
  186. client.create(request.CallContext, items);
  187. client.Close();
  188. }
  189. catch (Exception e)
  190. {
  191. Console.WriteLine(e.Message);
  192. Console.Read();
  193. }
  194.  
  195.  
  196. }
  197. }
  198. }
Add Comment
Please, Sign In to add comment