Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 70.01 KB | None | 0 0
  1. //
  2.  
  3. // Name: MRN_PLM_DialogChange
  4.  
  5. // Description: Retreive all Parts with classification Finished Good as well the last ExportDefinition from MRN_PLM_ExportDefinition, that is enabled and with target system: Dialoge. Get the information to be extracted fromn the ExportDefinition. Generate two files according of the triggering event in the Reletionship: IDENT6 and Measure. According of the relationships and the itemType, InfoType, Information,DafaultValue, ItemInformaton, ExportPosition, StartPosition and Length, as well Usage(for Document in Labaling Item) and Prioryty(list with two values: Priminary and Alternative).The method will be run from the Scheduler.
  6.  
  7. // Called by: Executed by the Scheduler
  8.  
  9. // <02-Dec-2019> - Kostadin Markov - code for Mersen
  10.  
  11. //======================================================================I
  12.  
  13. Innovator inn = this.getInnovator();
  14.  
  15. System.Diagnostics.Debugger.Break();
  16.  
  17. Item someExportDefinitions = inn.newItem("MRN_PLM_ExportDefinition", "get");
  18. someExportDefinitions.setProperty("mrn_plm_target_system", "DIALOGUE");
  19. someExportDefinitions.setProperty("mrn_plm_is_enabled", "1");
  20. someExportDefinitions = someExportDefinitions.apply();
  21. try
  22. {
  23. string assas = someExportDefinitions.getID();
  24. }
  25. catch
  26. {
  27. return inn.newError("There is no enabled Export Definitions!");
  28. }
  29.  
  30. someExportDefinitions.fetchRelationships("MRN_PLM_ExportDefinitionRel");
  31. Item someRelationships = someExportDefinitions.getRelationships("MRN_PLM_ExportDefinitionRel");
  32. int count = someRelationships.getItemCount();
  33.  
  34. //string triggeringEvent = null;
  35. string itemType = null;
  36. string infoType = null;
  37. string information = null;
  38. string defaultValue = null;
  39. string itemInformation = null;
  40. //string exportPosition = null;
  41. string startPosition = null;
  42. string length = null;
  43. string usage = null;
  44. string priority = null;
  45.  
  46.  
  47. Item someFinishedGood = inn.newItem("Part", "get");
  48. someFinishedGood.setAttribute("where", "[Part].classification='Finished good' AND [Part].state='Released'");
  49. //someFinishedGood.setAttribute("where", "[Part].state='Released'");
  50. someFinishedGood = someFinishedGood.apply();
  51.  
  52. int countOfFinishedGoods = someFinishedGood.getItemCount();
  53. List<Item> allNeededFinishedGoods = new List<Item>();
  54.  
  55. for(int ib = 0; ib < countOfFinishedGoods; ib++)
  56. {
  57. Item ourFG = someFinishedGood.getItemByIndex(ib);
  58. allNeededFinishedGoods.Add(ourFG);
  59. }
  60.  
  61. int fdf = allNeededFinishedGoods.Count();
  62.  
  63. Item variable = inn.newItem("Variable", "get");
  64. variable.setProperty("name", "MRN_PLM_DialogueExport");
  65. variable = variable.apply();
  66.  
  67. string filePath = variable.getProperty("value", "");
  68.  
  69. //int countOfPartsNeeded = someFinishedGood.getItemCount();
  70.  
  71. string fileParthNameIdent = filePath + "\\" + "IDENT6.txt";
  72. string fileParthNameMesure = filePath + "\\" + "MESURE.txt";
  73.  
  74. StreamWriter id = new StreamWriter(fileParthNameIdent);
  75. StreamWriter me = new StreamWriter(fileParthNameMesure);
  76.  
  77. List<Item> IDENT6_LIST = new List<Item>();
  78. List<Item> MEASURE_LIST = new List<Item>();
  79.  
  80. for(int ia = 0; ia < count; ia++)
  81. {
  82. Item rel = someRelationships.getItemByIndex(ia);
  83. string relEvent = rel.getProperty("mrn_plm_triggering_event");
  84.  
  85. //exportPosition = Convert.ToInt32(rel.getProperty("mrn_plm_exportposition"));
  86. if(relEvent == "IDENT6")
  87. {
  88. IDENT6_LIST.Add(rel);
  89. }
  90. else if(relEvent == "MESURE")
  91. {
  92. MEASURE_LIST.Add(rel);
  93. }
  94. }
  95.  
  96. int identCount = IDENT6_LIST.Count;
  97. int measureCount = MEASURE_LIST.Count;
  98.  
  99. CompareItem comp = new CompareItem();
  100. IDENT6_LIST.Sort(comp);
  101. MEASURE_LIST.Sort(comp);
  102. allNeededFinishedGoods.Sort(comp);
  103.  
  104. Item last = null;
  105. Item lastMeasure = null;
  106.  
  107. if(identCount > 0)
  108. {
  109. last = IDENT6_LIST.Last();
  110. }
  111. if(measureCount > 0){
  112. lastMeasure = MEASURE_LIST.Last();
  113. }
  114.  
  115. System.Diagnostics.Debugger.Break();
  116.  
  117. string wantedProperty = null;
  118. foreach(Item finishedGood in allNeededFinishedGoods)
  119. {
  120. System.Diagnostics.Debugger.Break();
  121.  
  122. wantedProperty = "";
  123. foreach(Item itemItm in IDENT6_LIST)
  124. {
  125. itemType = itemItm.getProperty("mrn_plm_item_type", "");
  126. infoType = itemItm.getProperty("mrn_plm_info_type", "");
  127. information = itemItm.getProperty("mrn_plm_information", "");
  128. defaultValue = itemItm.getProperty("mrn_plm_defaut_value", "");
  129. itemInformation = itemItm.getProperty("mrn_plm_item_information", "");
  130. //exportPosition = itemItm.getProperty("mrn_plm_exportposition");
  131. startPosition = itemItm.getProperty("mrn_plm_start_position", "");
  132. length = itemItm.getProperty("mrn_plm_length", "");
  133. usage = itemItm.getProperty("mrn_plm_usage_doc", "");
  134. priority = itemItm.getProperty("mrn_plm_priority", "");
  135. string value = null;
  136. string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
  137. string productLabItemId = finishedGood.getProperty("mrn_plm_product_label_item", "");
  138.  
  139. if((itemType == "Item" || itemType == "Generic Label Item" || itemType == "Product Label Item" || itemType == "R35" || itemType == "MSL" || itemType == "Frame" || itemType == "Certification") && (infoType == "DateTime-YYMMDDhhmm" || infoType == "Date-MM/DD/YYYY"))
  140. {
  141.  
  142. if(infoType == "DateTime-YYMMDDhhmm")
  143. {
  144. DateTime dt = DateTime.Now;;
  145. if (information == "Today") {dt = DateTime.Now;}
  146. if (information == "Yesterday") {dt = dt.AddDays(-1);}
  147. if (information == "Tomorrow") {dt = dt.AddDays(1);}
  148. value = dt.ToString("yyMMddHHmm");
  149. for(int f = 0; f < int.Parse(length); f++)
  150. {
  151. if(defaultValue == "") defaultValue = " ";
  152. if(value == "") value = defaultValue;
  153. if(value == null || f >= value.Length)
  154. {
  155. wantedProperty += " ";
  156. continue;
  157. }
  158. wantedProperty += value[f];
  159. }
  160. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  161. {
  162.  
  163. return inn.newError("Please Look at the table");
  164. }
  165. }
  166. else if(infoType == "Date-MM/DD/YYYY")
  167. {
  168.  
  169. DateTime dte = DateTime.Now;
  170. if (information == "Today") {dte = DateTime.Now;}
  171. if (information == "Yesterday") {dte = dte.AddDays(-1);}
  172. if (information == "Tomorrow") {dte = dte.AddDays(1);}
  173. value = dte.ToString(@"MM\/dd\/yyyy");
  174. for(int f = 0; f < int.Parse(length); f++)
  175. {
  176. if(defaultValue == "") defaultValue = " ";
  177. if(value == "") value = defaultValue;
  178. if(value == null || f >= value.Length)
  179. {
  180. wantedProperty += " ";
  181. continue;
  182. }
  183. wantedProperty += value[f];
  184. }
  185. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  186. {
  187.  
  188. return inn.newError("Please Look at the table");
  189. }
  190. }
  191. }
  192. else if(itemType == "Item")
  193. {
  194. int d = wantedProperty.Length;
  195. switch(infoType)
  196. {
  197. case "Property":
  198. value = finishedGood.getProperty(information, "");
  199. for(int s = 0; s < int.Parse(length); s++)
  200. {
  201. if(defaultValue == "") defaultValue = " ";
  202. if(value == "") value = defaultValue;
  203. if(value == null || s >= value.Length)
  204. {
  205. wantedProperty += " ";
  206. continue;
  207. }
  208. wantedProperty += value[s];
  209. }
  210.  
  211. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  212. {
  213.  
  214. return inn.newError("Please Look at the table");
  215. }
  216. break;
  217. }
  218. }
  219.  
  220. else if(itemType == "Generic Label Item")
  221. {
  222.  
  223. switch(infoType)
  224. {
  225. case "Property":
  226. if(labItemId != "")
  227. {
  228. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  229. value = ourLabItem.getProperty(information);
  230. }
  231. else value = " ";
  232. for(int s = 0; s < int.Parse(length); s++)
  233. {
  234. if(defaultValue == "") defaultValue = " ";
  235. if(value == "") value = defaultValue;
  236. if(value == null || s >= value.Length)
  237. {
  238. wantedProperty += " ";
  239. continue;
  240. }
  241. wantedProperty += value[s];
  242. }
  243. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  244. {
  245. return inn.newError("Please Look at the table");
  246. }
  247. break;
  248. case "RelatedProperty":
  249. System.Diagnostics.Debugger.Break();
  250.  
  251. if(labItemId != "")
  252. {
  253. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  254.  
  255. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  256. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  257. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  258. int getRelsCount = getRels.getItemCount();
  259. for(int sk = 0; sk < getRelsCount; sk++)
  260. {
  261. Item currentProperty = getRels.getItemByIndex(sk);
  262. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  263. if(information == currProperty)
  264. {
  265. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  266. {
  267. value = currentProperty.getProperty("mrn_plm_label_value");
  268. break;
  269. }
  270. }
  271. }
  272. }
  273. else value = "";
  274.  
  275. for(int s = 0; s < int.Parse(length); s++)
  276. {
  277. if(defaultValue == "") defaultValue = " ";
  278. if(value == "") value = defaultValue;
  279. if(value == null || s >= value.Length)
  280. {
  281. wantedProperty += " ";
  282. continue;
  283. }
  284. wantedProperty += value[s];
  285. }
  286. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  287. {
  288. return inn.newError("Please Look at the table");
  289. }
  290.  
  291. break;
  292. case "ItemPropertyItem":
  293. Item myStockPart = null;
  294. string myStockPartId = null;
  295. string cItem = finishedGood.getProperty("mrn_plm_label_item", "");
  296. Item ssd = null;
  297. if(cItem != "")
  298. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  299.  
  300. if(ssd != null)
  301. myStockPartId = ssd.getProperty(information);
  302.  
  303. if(myStockPartId != null)
  304. {
  305. myStockPart = inn.getItemById("Part", myStockPartId);
  306. value = myStockPart.getProperty(itemInformation, "");
  307. }
  308.  
  309. else value = "";
  310.  
  311. for(int s = 0; s < int.Parse(length); s++)
  312. {
  313. if(defaultValue == "") defaultValue = " ";
  314. if(value == "") value = defaultValue;
  315. if(value == null || s >= value.Length)
  316. {
  317. wantedProperty += " ";
  318. continue;
  319. }
  320. wantedProperty += value[s];
  321. }
  322. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  323. {
  324. return inn.newError("Please Look at the table");
  325. }
  326. break;
  327. case "Document":
  328.  
  329. if(labItemId != "")
  330. {
  331. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  332.  
  333. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  334. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  335.  
  336. int docRelCount = docRelationships.getItemCount();
  337.  
  338. for(int f = 0; f < docRelCount; f++)
  339. {
  340. Item currDoc = docRelationships.getItemByIndex(f);
  341. var docUsage = currDoc.getProperty("mrn_plm_usage");
  342. if(docUsage == usage)
  343. {
  344. value = currDoc.getProperty(information);
  345. break;
  346. }
  347. }
  348.  
  349. var nextItem = 0;
  350.  
  351. if(value ==null)
  352. {
  353. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  354. }
  355.  
  356. if(nextItem >= 2 && priority == "Preminary") break;
  357. //else value = "";
  358.  
  359. for(int s = 0; s < int.Parse(length); s++)
  360. {
  361. if(defaultValue == "") defaultValue = " ";
  362. if(value == "") value = defaultValue;
  363. if(value == null || s >= value.Length)
  364. {
  365. wantedProperty += " ";
  366. continue;
  367. }
  368. wantedProperty += value[s];
  369. }
  370. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  371. {
  372. return inn.newError("Please Look at the table");
  373. }
  374. }
  375.  
  376. else
  377. {
  378. value = " ";
  379. for(int s = 0; s < int.Parse(length); s++)
  380. {
  381. if(defaultValue == "") defaultValue = " ";
  382. if(value == "") value = defaultValue;
  383. if(value == null || s >= value.Length)
  384. {
  385. wantedProperty += " ";
  386. continue;
  387. }
  388. wantedProperty += value[s];
  389. }
  390. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  391. {
  392. return inn.newError("Please Look at the table");
  393. }
  394. }
  395.  
  396. break;
  397. }
  398. }
  399.  
  400. else if(itemType == "Product Label Item")
  401. {
  402. switch(infoType)
  403. {
  404. case "Property":
  405. if(productLabItemId != "")
  406. {
  407. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  408. value = ourLabItem.getProperty(information, "");
  409. }
  410.  
  411. else value = " ";
  412. for(int s = 0; s < int.Parse(length); s++)
  413. {
  414. if(defaultValue == "") defaultValue = " ";
  415. if(value == "") value = defaultValue;
  416. if(value == null || s >= value.Length)
  417. {
  418. wantedProperty += " ";
  419. continue;
  420. }
  421. wantedProperty += value[s];
  422. }
  423. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  424. {
  425. return inn.newError("Please Look at the table");
  426. }
  427. break;
  428. case "RelatedProperty":
  429. System.Diagnostics.Debugger.Break();
  430.  
  431. if(productLabItemId != "")
  432. {
  433. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  434.  
  435. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  436. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  437. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  438. int getRelsCount = getRels.getItemCount();
  439. for(int sk = 0; sk < getRelsCount; sk++)
  440. {
  441. Item currentProperty = getRels.getItemByIndex(sk);
  442. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  443. if(information == currProperty)
  444. {
  445. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  446. {
  447. value = currentProperty.getProperty("mrn_plm_label_value");
  448. break;
  449. }
  450. }
  451. }
  452. }
  453. else value = "";
  454.  
  455. for(int s = 0; s < int.Parse(length); s++)
  456. {
  457. if(defaultValue == "") defaultValue = " ";
  458. if(value == "") value = defaultValue;
  459. if(value == null || s >= value.Length)
  460. {
  461. wantedProperty += " ";
  462. continue;
  463. }
  464. wantedProperty += value[s];
  465. }
  466. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  467. {
  468. return inn.newError("Please Look at the table");
  469. }
  470.  
  471. break;
  472. case "ItemPropertyItem":
  473. Item myStockPart = null;
  474. string myStockPartId = null;
  475. string cItem = finishedGood.getProperty("mrn_plm_product_label_item", "");
  476. Item ssd = null;
  477. if(cItem != "")
  478. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  479.  
  480. if(ssd != null)
  481. myStockPartId = ssd.getProperty(information);
  482.  
  483. if(myStockPartId != null)
  484. {
  485. myStockPart = inn.getItemById("Part", myStockPartId);
  486. value = myStockPart.getProperty(itemInformation, "");
  487. }
  488.  
  489. else value = "";
  490.  
  491. for(int s = 0; s < int.Parse(length); s++)
  492. {
  493. if(defaultValue == "") defaultValue = " ";
  494. if(value == "") value = defaultValue;
  495. if(value == null || s >= value.Length)
  496. {
  497. wantedProperty += " ";
  498. continue;
  499. }
  500. wantedProperty += value[s];
  501. }
  502. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  503. {
  504. return inn.newError("Please Look at the table");
  505. }
  506. break;
  507. case "Document":
  508.  
  509. if(labItemId != "")
  510. {
  511. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  512.  
  513. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  514. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  515.  
  516. int docRelCount = docRelationships.getItemCount();
  517.  
  518. for(int f = 0; f < docRelCount; f++)
  519. {
  520. Item currDoc = docRelationships.getItemByIndex(f);
  521. var docUsage = currDoc.getProperty("mrn_plm_usage");
  522. if(docUsage == usage)
  523. {
  524. value = currDoc.getProperty(information);
  525. break;
  526. }
  527. }
  528.  
  529. var nextItem = 0;
  530.  
  531. if(value == null)
  532. {
  533. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  534. }
  535.  
  536. if(nextItem >= 2 && priority == "Preminary") break;
  537. //else value = "";
  538.  
  539. for(int s = 0; s < int.Parse(length); s++)
  540. {
  541. if(defaultValue == "") defaultValue = " ";
  542. if(value == "") value = defaultValue;
  543. if(value == null || s >= value.Length)
  544. {
  545. wantedProperty += " ";
  546. continue;
  547. }
  548. wantedProperty += value[s];
  549. }
  550. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  551. {
  552. return inn.newError("Please Look at the table");
  553. }
  554. }
  555.  
  556. else
  557. {
  558. value = " ";
  559. for(int s = 0; s < int.Parse(length); s++)
  560. {
  561. if(defaultValue == "") defaultValue = " ";
  562. if(value == "") value = defaultValue;
  563. if(value == null || s >= value.Length)
  564. {
  565. wantedProperty += " ";
  566. continue;
  567. }
  568. wantedProperty += value[s];
  569. }
  570. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  571. {
  572. return inn.newError("Please Look at the table");
  573. }
  574. }
  575.  
  576. break;
  577. }
  578. }
  579.  
  580. else if(itemType == "Certification")
  581. {
  582. System.Diagnostics.Debugger.Break();
  583.  
  584. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  585. //Item pim = null;
  586. if(pimId != "")
  587. {
  588. switch(infoType)
  589. {
  590. case "Property":
  591. /*
  592. pim = inn.getItemById("MRN_Item", pimId);
  593.  
  594. pim.fetchRelationships("MRN_PLM_Poly_CAD_Document");
  595.  
  596. var relationshipsDocs = pim.getRelationships("MRN_PLM_Poly_CAD_Document");
  597. */
  598. Item relationshipsDocs = inn.newItem("MRN_Item_Document", "get");
  599. relationshipsDocs.setAttribute ("where", "[MRN_Item_Document].source_id='" + pimId + "'");
  600. relationshipsDocs = relationshipsDocs.apply();
  601.  
  602. int countRelationships = relationshipsDocs.getItemCount();
  603.  
  604. for(int f = 0; f < countRelationships; f++)
  605. {
  606. Item currDoc = relationshipsDocs.getItemByIndex(f);
  607. var docUsage = currDoc.getProperty("mrn_plm_usage");
  608. if(docUsage == usage)
  609. {
  610. value = currDoc.getProperty(information, "");
  611. break;
  612. }
  613. }
  614. break;
  615. }
  616. }
  617. else value = "";
  618. for(int s = 0; s < int.Parse(length); s++)
  619. {
  620. if(defaultValue == "") defaultValue = " ";
  621. if(value == "") value = defaultValue;
  622. if(value == null || s >= value.Length)
  623. {
  624. wantedProperty += " ";
  625. continue;
  626. }
  627. wantedProperty += value[s];
  628. }
  629. System.Diagnostics.Debugger.Break();
  630.  
  631. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  632. {
  633. return inn.newError("Please Look at the table");
  634. }
  635. }
  636.  
  637. else if(itemType == "Constitution")
  638. {
  639. switch(infoType)
  640. {
  641. case "Property":
  642. string partConstId = finishedGood.getProperty("mrn_plm_constitution");
  643.  
  644. Item someXProps = inn.newItem("xPropertyDefinition", "get");
  645. someXProps.setProperty("name", information);
  646. someXProps = someXProps.apply();
  647. try
  648. {
  649. string res = someXProps.getProperty("name");
  650.  
  651. string sql = @"SELECT [" + res + "] FROM [xp].[XPROPERTYVALUES] WHERE item_id='" + partConstId + "'";
  652. Item sqlResult = inn.applySQL(sql);
  653. value = sqlResult.getProperty(res);
  654. }
  655.  
  656. catch(Exception){value = "";}
  657.  
  658.  
  659. for(int s = 0; s < int.Parse(length); s++)
  660. {
  661. if(defaultValue == "") defaultValue = " ";
  662. if(value == "") value = defaultValue;
  663. if(value == null || s >= value.Length)
  664. {
  665. wantedProperty += " ";
  666. continue;
  667. }
  668. wantedProperty += value[s];
  669. }
  670. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  671. {
  672. return inn.newError("Please Look at the table");
  673. }
  674. break;
  675. }
  676. }
  677.  
  678. else if(itemType == "R35")
  679. {
  680. Item r35Item = null;
  681. string r35 = finishedGood.getProperty("mrn_plm_r35", "");
  682.  
  683. if(r35 != "")
  684. {
  685. r35Item = inn.getItemById("mrn_plm_labeling_item", r35);
  686. }
  687.  
  688. switch(infoType)
  689. {
  690. case "Property":
  691. if(r35Item != null)
  692. value = r35Item.getProperty(information, "");
  693. else value = "";
  694. for(int s = 0; s < int.Parse(length); s++)
  695. {
  696. if(defaultValue == "") defaultValue = " ";
  697. if(value == "") value = defaultValue;
  698. if(value == null || s >= value.Length)
  699. {
  700. wantedProperty += " ";
  701. continue;
  702. }
  703. wantedProperty += value[s];
  704. }
  705. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  706. {
  707. return inn.newError("Please Look at the table");
  708. }
  709. break;
  710.  
  711. case "ItemPropertyItem":
  712. string myStockPartId = null;
  713. Item myStockPart = null;
  714.  
  715. if(r35Item != null)
  716. {
  717. myStockPartId = r35Item.getProperty(information, "");
  718.  
  719. if(myStockPartId != "")
  720. myStockPart = inn.getItemById("Part", myStockPartId);
  721. }
  722. if(myStockPart != null)
  723. {
  724. value = myStockPart.getProperty(itemInformation, "");
  725. //return inn.newError("There is stock Item");
  726. }
  727. else value = "";
  728.  
  729. for(int s = 0; s < int.Parse(length); s++)
  730. {
  731. if(defaultValue == "") defaultValue = " ";
  732. if(value == "") value = defaultValue;
  733. if(value == null || s >= value.Length)
  734. {
  735. wantedProperty += " ";
  736. continue;
  737. }
  738. wantedProperty += value[s];
  739. }
  740. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  741. {
  742. return inn.newError("Please Look at the table");
  743. }
  744. break;
  745. }
  746. }
  747.  
  748. else if(itemType == "MSL")
  749. {
  750. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  751. Item pim = null;
  752. Item msl = null;
  753. if(pimId != "")
  754. {
  755. pim = inn.getItemById("MRN_Item", pimId);
  756.  
  757. string mslId = pim.getProperty("mrn_parent_msl", "");
  758.  
  759. if(mslId != "")
  760. msl = inn.getItemById("MRN_Item", mslId);
  761. }
  762.  
  763. switch(infoType)
  764. {
  765. case "Property":
  766. if(msl != null)
  767. value = msl.getProperty(information, "");
  768. else value = "";
  769. for(int s = 0; s < int.Parse(length); s++)
  770. {
  771. if(defaultValue == "") defaultValue = " ";
  772. if(value == "") value = defaultValue;
  773. if(value == null || s >= value.Length)
  774. {
  775. wantedProperty += " ";
  776. continue;
  777. }
  778. wantedProperty += value[s];
  779. }
  780. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  781. {
  782. return inn.newError("Please Look at the table");
  783. }
  784. break;
  785. }
  786. }
  787.  
  788. else if(itemType == "Frame")
  789. {
  790. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  791. Item pim = null;
  792. Item frame = null;
  793. if(pimId != "")
  794. {
  795. pim = inn.getItemById("MRN_Item", pimId);
  796.  
  797. string frameId = pim.getProperty("mrn_frame", "");
  798.  
  799. if(frameId != "")
  800. frame = inn.getItemById("MRN_Item", frameId);
  801. }
  802.  
  803. switch(infoType)
  804. {
  805. case "Property":
  806. if(frame != null)
  807. value = frame.getProperty(information, "");
  808. else value = "";
  809. for(int s = 0; s < int.Parse(length); s++)
  810. {
  811. if(defaultValue == "") defaultValue = " ";
  812. if(value == "") value = defaultValue;
  813. if(value == null || s >= value.Length)
  814. {
  815. wantedProperty += " ";
  816. continue;
  817. }
  818. wantedProperty += value[s];
  819. }
  820. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  821. {
  822. return inn.newError("Please Look at the table");
  823. }
  824. break;
  825. }
  826. }
  827. System.Diagnostics.Debugger.Break();
  828.  
  829.  
  830. if (itemItm.Equals(last))
  831. {
  832. System.Diagnostics.Debugger.Break();
  833.  
  834. id.Write(wantedProperty);
  835. id.Write("*");
  836. id.WriteLine();
  837. }
  838. }
  839.  
  840. wantedProperty = "";
  841. foreach(Item itemItM in MEASURE_LIST)
  842. {
  843. itemType = itemItM.getProperty("mrn_plm_item_type");
  844. infoType = itemItM.getProperty("mrn_plm_info_type");
  845. information = itemItM.getProperty("mrn_plm_information");
  846. defaultValue = itemItM.getProperty("mrn_plm_defaut_value");
  847. itemInformation = itemItM.getProperty("mrn_plm_item_information");
  848. startPosition = itemItM.getProperty("mrn_plm_start_position");
  849. length = itemItM.getProperty("mrn_plm_length");
  850. usage = itemItM.getProperty("mrn_plm_usage_doc", "");
  851. priority = itemItM.getProperty("mrn_plm_priority", "");
  852. string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
  853. string productLabItemId = finishedGood.getProperty("mrn_plm_product_label_item", "");
  854. string value = null;
  855.  
  856.  
  857. if((itemType == "Item" || itemType == "Generic Label Item" || itemType == "Product Label Item" || itemType == "R35" || itemType == "MSL" || itemType == "Frame" || itemType == "Certification") && (infoType == "DateTime-YYMMDDhhmm" || infoType == "Date-MM/DD/YYYY"))
  858. {
  859. if(infoType == "DateTime-YYMMDDhhmm")
  860. {
  861. DateTime dt = DateTime.Now;;
  862. if (information == "Today") {dt = DateTime.Now;}
  863. if (information == "Yesterday") {dt = dt.AddDays(-1);}
  864. if (information == "Tomorrow") {dt = dt.AddDays(1);}
  865. value = dt.ToString("yyMMddHHmm");
  866. for(int f = 0; f < int.Parse(length); f++)
  867. {
  868. if(defaultValue == "") defaultValue = " ";
  869. if(value == "") value = defaultValue;
  870. if(value == null || f >= value.Length)
  871. {
  872. wantedProperty += " ";
  873. continue;
  874. }
  875. wantedProperty += value[f];
  876. }
  877. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  878. {
  879. return inn.newError("Please Look at the table");
  880. }
  881. }
  882. else if(infoType == "Date-MM/DD/YYYY")
  883. {
  884. DateTime dte = DateTime.Now;
  885. if (information == "Today") {dte = DateTime.Now;}
  886. if (information == "Yesterday") {dte = dte.AddDays(-1);}
  887. if (information == "Tomorrow") {dte = dte.AddDays(1);}
  888. value = dte.ToString(@"MM\/dd\/yyyy");
  889. for(int f = 0; f < int.Parse(length); f++)
  890. {
  891. if(defaultValue == "") defaultValue = " ";
  892. if(value == "") value = defaultValue;
  893. if(value == null || f >= value.Length)
  894. {
  895. wantedProperty += " ";
  896. continue;
  897. }
  898. wantedProperty += value[f];
  899. }
  900. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  901. {
  902. return inn.newError("Please Look at the table");
  903. }
  904. }
  905. }
  906.  
  907. else if(itemType == "Item")
  908. {
  909.  
  910. if(infoType == "Property")
  911. {
  912. value = finishedGood.getProperty(information, "");
  913. for(int s = 0; s < int.Parse(length); s++)
  914. {
  915. if(defaultValue == "") defaultValue = " ";
  916. if(value == "") value = defaultValue;
  917. if(value == null || s >= value.Length)
  918. {
  919. wantedProperty += " ";
  920. continue;
  921. }
  922. wantedProperty += value[s];
  923. }
  924. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  925. {
  926. return inn.newError("Please Look at the table");
  927. }
  928. }
  929. }
  930.  
  931. else if(itemType == "Generic Label Item")
  932. {
  933. switch(infoType)
  934. {
  935. case "Property":
  936. value = finishedGood.getProperty(information, "");
  937. for(int s = 0; s < int.Parse(length); s++)
  938. {
  939. if(defaultValue == "") defaultValue = " ";
  940. if(value == "") value = defaultValue;
  941. if(value == null || s >= value.Length)
  942. {
  943. wantedProperty += " ";
  944. continue;
  945. }
  946. wantedProperty += value[s];
  947. }
  948. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  949. {
  950. return inn.newError("Please Look at the table");
  951. }
  952. break;
  953. case "RelatedProperty":
  954. System.Diagnostics.Debugger.Break();
  955.  
  956. if(labItemId != "")
  957. {
  958. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  959.  
  960. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  961. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  962. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  963. int getRelsCount = getRels.getItemCount();
  964. for(int sk = 0; sk < getRelsCount; sk++)
  965. {
  966. Item currentProperty = getRels.getItemByIndex(sk);
  967. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  968. if(information == currProperty)
  969. {
  970. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  971. {
  972. value = currentProperty.getProperty("mrn_plm_label_value");
  973. break;
  974. }
  975. }
  976. }
  977. }
  978. else value = "";
  979.  
  980. for(int s = 0; s < int.Parse(length); s++)
  981. {
  982. if(defaultValue == "") defaultValue = " ";
  983. if(value == "") value = defaultValue;
  984. if(value == null || s >= value.Length)
  985. {
  986. wantedProperty += " ";
  987. continue;
  988. }
  989. wantedProperty += value[s];
  990. }
  991. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  992. {
  993. return inn.newError("Please Look at the table");
  994. }
  995.  
  996. break;
  997. case "ItemPropertyItem":
  998. value = "";
  999. Item myStockPart = null;
  1000. string myStockPartId = null;
  1001. string cItem = finishedGood.getPropertyItem("mrn_plm_label_item").getID();
  1002. Item ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  1003.  
  1004. myStockPartId = ssd.getProperty(information);
  1005.  
  1006. myStockPart = inn.getItemById("Part", myStockPartId);
  1007.  
  1008. if(myStockPartId == null)
  1009. {
  1010. return inn.newError("There is stock Item");
  1011. }
  1012.  
  1013. value = myStockPart.getProperty(itemInformation, "");
  1014.  
  1015. for(int s = 0; s < int.Parse(length); s++)
  1016. {
  1017. if(defaultValue == "") defaultValue = " ";
  1018. if(value == "") value = defaultValue;
  1019. if(value == null || s >= value.Length)
  1020. {
  1021. wantedProperty += " ";
  1022. continue;
  1023. }
  1024. wantedProperty += value[s];
  1025. }
  1026. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1027. {
  1028. return inn.newError("Please Look at the table");
  1029. }
  1030. break;
  1031. case "Document":
  1032.  
  1033. if(labItemId != "")
  1034. {
  1035. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  1036.  
  1037. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  1038. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  1039.  
  1040. int docRelCount = docRelationships.getItemCount();
  1041.  
  1042. for(int f = 0; f < docRelCount; f++)
  1043. {
  1044. Item currDoc = docRelationships.getItemByIndex(f);
  1045. var docUsage = currDoc.getProperty("mrn_plm_usage");
  1046. if(docUsage == usage)
  1047. {
  1048. value = currDoc.getProperty(information);
  1049. break;
  1050. }
  1051. }
  1052.  
  1053. var nextItem = 0;
  1054.  
  1055. if(value ==null)
  1056. {
  1057. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1058. }
  1059.  
  1060. if(nextItem >= 2 && priority == "Preminary") break;
  1061. //else value = "";
  1062.  
  1063. for(int s = 0; s < int.Parse(length); s++)
  1064. {
  1065. if(defaultValue == "") defaultValue = " ";
  1066. if(value == "") value = defaultValue;
  1067. if(value == null || s >= value.Length)
  1068. {
  1069. wantedProperty += " ";
  1070. continue;
  1071. }
  1072. wantedProperty += value[s];
  1073. }
  1074. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1075. {
  1076. return inn.newError("Please Look at the table");
  1077. }
  1078. }
  1079.  
  1080. else
  1081. {
  1082. value = " ";
  1083. for(int s = 0; s < int.Parse(length); s++)
  1084. {
  1085. if(defaultValue == "") defaultValue = " ";
  1086. if(value == "") value = defaultValue;
  1087. if(value == null || s >= value.Length)
  1088. {
  1089. wantedProperty += " ";
  1090. continue;
  1091. }
  1092. wantedProperty += value[s];
  1093. }
  1094. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1095. {
  1096. return inn.newError("Please Look at the table");
  1097. }
  1098. }
  1099.  
  1100. break;
  1101. }
  1102. }
  1103.  
  1104. else if(itemType == "Product Label Item")
  1105. {
  1106. switch(infoType)
  1107. {
  1108. case "Property":
  1109. if(productLabItemId != "")
  1110. {
  1111. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  1112. value = ourLabItem.getProperty(information, "");
  1113. }
  1114.  
  1115. else value = " ";
  1116. for(int s = 0; s < int.Parse(length); s++)
  1117. {
  1118. if(defaultValue == "") defaultValue = " ";
  1119. if(value == "") value = defaultValue;
  1120. if(value == null || s >= value.Length)
  1121. {
  1122. wantedProperty += " ";
  1123. continue;
  1124. }
  1125. wantedProperty += value[s];
  1126. }
  1127. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1128. {
  1129. return inn.newError("Please Look at the table");
  1130. }
  1131. break;
  1132. case "RelatedProperty":
  1133. System.Diagnostics.Debugger.Break();
  1134.  
  1135. if(productLabItemId != "")
  1136. {
  1137. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  1138.  
  1139. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  1140. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  1141. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  1142. int getRelsCount = getRels.getItemCount();
  1143. for(int sk = 0; sk < getRelsCount; sk++)
  1144. {
  1145. Item currentProperty = getRels.getItemByIndex(sk);
  1146. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  1147. if(information == currProperty)
  1148. {
  1149. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  1150. {
  1151. value = currentProperty.getProperty("mrn_plm_label_value");
  1152. break;
  1153. }
  1154. }
  1155. }
  1156. }
  1157. else value = "";
  1158.  
  1159. for(int s = 0; s < int.Parse(length); s++)
  1160. {
  1161. if(defaultValue == "") defaultValue = " ";
  1162. if(value == "") value = defaultValue;
  1163. if(value == null || s >= value.Length)
  1164. {
  1165. wantedProperty += " ";
  1166. continue;
  1167. }
  1168. wantedProperty += value[s];
  1169. }
  1170. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1171. {
  1172. return inn.newError("Please Look at the table");
  1173. }
  1174.  
  1175. break;
  1176. case "ItemPropertyItem":
  1177. Item myStockPart = null;
  1178. string myStockPartId = null;
  1179. string cItem = finishedGood.getProperty("mrn_plm_product_label_item", "");
  1180. Item ssd = null;
  1181. if(cItem != "")
  1182. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  1183.  
  1184. if(ssd != null)
  1185. myStockPartId = ssd.getProperty(information);
  1186.  
  1187. if(myStockPartId != null)
  1188. {
  1189. myStockPart = inn.getItemById("Part", myStockPartId);
  1190. value = myStockPart.getProperty(itemInformation, "");
  1191. }
  1192.  
  1193. else value = "";
  1194. //if(myStockPartId == ""null"") break;
  1195.  
  1196. // value = myStockPart.getProperty(itemInformation, "");
  1197.  
  1198. for(int s = 0; s < int.Parse(length); s++)
  1199. {
  1200. if(defaultValue == "") defaultValue = " ";
  1201. if(value == "") value = defaultValue;
  1202. if(value == null || s >= value.Length)
  1203. {
  1204. wantedProperty += " ";
  1205. continue;
  1206. }
  1207. wantedProperty += value[s];
  1208. }
  1209. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1210. {
  1211. return inn.newError("Please Look at the table");
  1212. }
  1213. break;
  1214. case "Document":
  1215.  
  1216. if(labItemId != "")
  1217. {
  1218. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  1219.  
  1220. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  1221. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  1222.  
  1223. int docRelCount = docRelationships.getItemCount();
  1224.  
  1225. for(int f = 0; f < docRelCount; f++)
  1226. {
  1227. Item currDoc = docRelationships.getItemByIndex(f);
  1228. var docUsage = currDoc.getProperty("mrn_plm_usage");
  1229. if(docUsage == usage)
  1230. {
  1231. value = currDoc.getProperty(information);
  1232. break;
  1233. }
  1234. }
  1235.  
  1236. var nextItem = 0;
  1237.  
  1238. if(value ==null)
  1239. {
  1240. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1241. }
  1242.  
  1243. if(nextItem >= 2 && priority == "Preminary") break;
  1244. //else value = "";
  1245.  
  1246. for(int s = 0; s < int.Parse(length); s++)
  1247. {
  1248. if(defaultValue == "") defaultValue = " ";
  1249. if(value == "") value = defaultValue;
  1250. if(value == null || s >= value.Length)
  1251. {
  1252. wantedProperty += " ";
  1253. continue;
  1254. }
  1255. wantedProperty += value[s];
  1256. }
  1257. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1258. {
  1259. return inn.newError("Please Look at the table");
  1260. }
  1261. }
  1262.  
  1263. else
  1264. {
  1265. value = " ";
  1266. for(int s = 0; s < int.Parse(length); s++)
  1267. {
  1268. if(defaultValue == "") defaultValue = " ";
  1269. if(value == "") value = defaultValue;
  1270. if(value == null || s >= value.Length)
  1271. {
  1272. wantedProperty += " ";
  1273. continue;
  1274. }
  1275. wantedProperty += value[s];
  1276. }
  1277. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1278. {
  1279. return inn.newError("Please Look at the table");
  1280. }
  1281. }
  1282.  
  1283. break;
  1284. }
  1285. }
  1286.  
  1287. else if(itemType == "Certification")
  1288. {
  1289. System.Diagnostics.Debugger.Break();
  1290.  
  1291. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  1292. //Item pim = null;
  1293. if(pimId != "")
  1294. {
  1295. switch(infoType)
  1296. {
  1297. case "Property":
  1298. Item relationshipsDocs = inn.newItem("MRN_Item_Document", "get");
  1299. relationshipsDocs.setAttribute ("where", "[MRN_Item_Document].source_id='" + pimId + "'");
  1300. relationshipsDocs = relationshipsDocs.apply();
  1301.  
  1302. int countRelationships = relationshipsDocs.getItemCount();
  1303.  
  1304. for(int f = 0; f < countRelationships; f++)
  1305. {
  1306. Item currDoc = relationshipsDocs.getItemByIndex(f);
  1307. var docUsage = currDoc.getProperty("mrn_plm_usage");
  1308. if(docUsage == usage)
  1309. {
  1310. value = currDoc.getProperty(information, "");
  1311. break;
  1312. }
  1313. }
  1314. break;
  1315. }
  1316. }
  1317. else value = "";
  1318. for(int s = 0; s < int.Parse(length); s++)
  1319. {
  1320. if(defaultValue == "") defaultValue = " ";
  1321. if(value == "") value = defaultValue;
  1322. if(value == null || s >= value.Length)
  1323. {
  1324. wantedProperty += " ";
  1325. continue;
  1326. }
  1327. wantedProperty += value[s];
  1328. }
  1329. System.Diagnostics.Debugger.Break();
  1330.  
  1331. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1332. {
  1333. return inn.newError("Please Look at the table");
  1334. }
  1335. }
  1336.  
  1337. else if(itemType == "Constitution")
  1338. {
  1339. switch(infoType)
  1340. {
  1341. case "Property":
  1342. string partConstId = finishedGood.getProperty("mrn_plm_constitution");
  1343.  
  1344. Item someXProps = inn.newItem("xPropertyDefinition", "get");
  1345. someXProps.setProperty("name", information);
  1346. someXProps = someXProps.apply();
  1347. try
  1348. {
  1349. string res = someXProps.getProperty("name");
  1350.  
  1351. string sql = @"SELECT [" + res + "] FROM [xp].[XPROPERTYVALUES] WHERE item_id='" + partConstId + "'";
  1352. Item sqlResult = inn.applySQL(sql);
  1353. value = sqlResult.getProperty(res);
  1354. }
  1355.  
  1356. catch(Exception){value = "";}
  1357.  
  1358.  
  1359. for(int s = 0; s < int.Parse(length); s++)
  1360. {
  1361. if(defaultValue == "") defaultValue = " ";
  1362. if(value == "") value = defaultValue;
  1363. if(value == null || s >= value.Length)
  1364. {
  1365. wantedProperty += " ";
  1366. continue;
  1367. }
  1368. wantedProperty += value[s];
  1369. }
  1370. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1371. {
  1372. return inn.newError("Please Look at the table");
  1373. }
  1374. break;
  1375. }
  1376. }
  1377.  
  1378. else if(itemType == "R35")
  1379. {
  1380. Item r35Item = null;
  1381. string r35 = finishedGood.getProperty("mrn_plm_r35", "");
  1382.  
  1383. if(r35 != "")
  1384. {
  1385. r35Item = inn.getItemById("mrn_plm_labeling_item", r35);
  1386. }
  1387.  
  1388. switch(infoType)
  1389. {
  1390. case "Property":
  1391.  
  1392. if(r35Item != null)
  1393. value = r35Item.getProperty(information, "");
  1394. else value = "";
  1395. for(int s = 0; s < int.Parse(length); s++)
  1396. {
  1397. if(defaultValue == "") defaultValue = " ";
  1398. if(value == "") value = defaultValue;
  1399. if(value == null || s >= value.Length)
  1400. {
  1401. wantedProperty += " ";
  1402. continue;
  1403. }
  1404. wantedProperty += value[s];
  1405. }
  1406. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1407. {
  1408. return inn.newError("Please Look at the table");
  1409. }
  1410. break;
  1411.  
  1412. case "ItemPropertyItem":
  1413. string myStockPartId = null;
  1414. Item myStockPart = null;
  1415.  
  1416. if(r35Item != null)
  1417. {
  1418. myStockPartId = r35Item.getProperty(information, "");
  1419.  
  1420. if(myStockPartId != "")
  1421. myStockPart = inn.getItemById("Part", myStockPartId);
  1422. }
  1423. if(myStockPart != null)
  1424. {
  1425. value = myStockPart.getProperty(itemInformation, "");
  1426. //return inn.newError("There is stock Item");
  1427. }
  1428. else value = "";
  1429.  
  1430. for(int s = 0; s < int.Parse(length); s++)
  1431. {
  1432. if(defaultValue == "") defaultValue = " ";
  1433. if(value == "") value = defaultValue;
  1434. if(value == null || s >= value.Length)
  1435. {
  1436. wantedProperty += " ";
  1437. continue;
  1438. }
  1439. wantedProperty += value[s];
  1440. }
  1441. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1442. {
  1443. return inn.newError("Please Look at the table");
  1444. }
  1445. break;
  1446. }
  1447. }
  1448.  
  1449. else if(itemType == "MSL")
  1450. {
  1451. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  1452. Item pim = null;
  1453. Item msl = null;
  1454. if(pimId != "")
  1455. {
  1456. pim = inn.getItemById("MRN_Item", pimId);
  1457.  
  1458. string mslId = pim.getProperty("mrn_parent_msl", "");
  1459.  
  1460. if(mslId != "")
  1461. msl = inn.getItemById("MRN_Item", mslId);
  1462. }
  1463.  
  1464. switch(infoType)
  1465. {
  1466. case "Property":
  1467. if(msl != null)
  1468. value = msl.getProperty(information, "");
  1469. else
  1470. value = "";
  1471. for(int s = 0; s < int.Parse(length); s++)
  1472. {
  1473. if(defaultValue == "") defaultValue = " ";
  1474. if(value == "") value = defaultValue;
  1475. if(value == null || s >= value.Length)
  1476. {
  1477. wantedProperty += " ";
  1478. continue;
  1479. }
  1480. wantedProperty += value[s];
  1481. }
  1482. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1483. {
  1484. return inn.newError("Please Look at the table");
  1485. }
  1486. break;
  1487. }
  1488. }
  1489.  
  1490. else if(itemType == "Frame")
  1491. {
  1492. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  1493. Item pim = null;
  1494. Item frame = null;
  1495. if(pimId != "")
  1496. {
  1497. pim = inn.getItemById("MRN_Item", pimId);
  1498.  
  1499. string frameId = pim.getProperty("mrn_frame", "");
  1500.  
  1501. if(frameId != "")
  1502. frame = inn.getItemById("MRN_Item", frameId);
  1503. }
  1504.  
  1505. switch(infoType)
  1506. {
  1507. case "Property":
  1508. if(frame != null)
  1509. value = frame.getProperty(information, "");
  1510. else value = "";
  1511. for(int s = 0; s < int.Parse(length); s++)
  1512. {
  1513. if(defaultValue == "") defaultValue = " ";
  1514. if(value == "") value = defaultValue;
  1515. if(value == null || s >= value.Length)
  1516. {
  1517. wantedProperty += " ";
  1518. continue;
  1519. }
  1520. wantedProperty += value[s];
  1521. }
  1522. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1523. {
  1524. return inn.newError("Please Look at the table");
  1525. }
  1526. break;
  1527. }
  1528. }
  1529.  
  1530. System.Diagnostics.Debugger.Break();
  1531.  
  1532. if (itemItM.Equals(lastMeasure))
  1533. {
  1534. System.Diagnostics.Debugger.Break();
  1535. me.Write(wantedProperty);
  1536. me.WriteLine();
  1537. }
  1538. }
  1539. }
  1540. id.Close();
  1541. me.Close();
  1542.  
  1543. return this;
  1544. }
  1545.  
  1546. class CompareItem : IComparer<Item>
  1547. {
  1548. public int Compare(Item x, Item y)
  1549. {
  1550. // CompareTo() method
  1551. int positionx = Convert.ToInt32(x.getProperty("mrn_plm_exportposition", "0"));
  1552. int positiony = Convert.ToInt32(y.getProperty("mrn_plm_exportposition", "0"));
  1553.  
  1554. return positionx.CompareTo(positiony);
  1555.  
  1556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement