Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 300.43 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. string leadingZero = null;
  46. string mutiplyTousend = null;
  47. string removeSeparator = null;
  48.  
  49.  
  50. Item someFinishedGood = inn.newItem("Part", "get");
  51. // someFinishedGood.setAttribute("where", "[Part].classification='Finished good' AND [Part].state='Released'");
  52. someFinishedGood.setAttribute("where", "[Part].mrn_plm_is_labeled ='1' OR [Part].state='Released' AND [Part].classification='Finished good'");
  53. //someFinishedGood.setAttribute("where", "[Part].state='Released'");
  54. someFinishedGood = someFinishedGood.apply();
  55.  
  56. int countOfFinishedGoods = someFinishedGood.getItemCount();
  57. List<Item> allNeededFinishedGoods = new List<Item>();
  58.  
  59. for(int ib = 0; ib < countOfFinishedGoods; ib++)
  60. {
  61. Item ourFG = someFinishedGood.getItemByIndex(ib);
  62. allNeededFinishedGoods.Add(ourFG);
  63. }
  64.  
  65. int fdf = allNeededFinishedGoods.Count();
  66.  
  67. Item variable = inn.newItem("Variable", "get");
  68. variable.setProperty("name", "MRN_PLM_DialogueExport");
  69. variable = variable.apply();
  70.  
  71. string filePath = variable.getProperty("value", "");
  72.  
  73. //int countOfPartsNeeded = someFinishedGood.getItemCount();
  74.  
  75. string fileParthNameIdent = filePath + "\\" + "IDENT6.txt";
  76. string fileParthNameMesure = filePath + "\\" + "MESURE.txt";
  77.  
  78. StreamWriter id = new StreamWriter(fileParthNameIdent);
  79. StreamWriter me = new StreamWriter(fileParthNameMesure);
  80.  
  81. List<Item> IDENT6_LIST = new List<Item>();
  82. List<Item> MEASURE_LIST = new List<Item>();
  83.  
  84. //int positionx = Convert.ToInt32(x.getProperty("mrn_plm_exportposition", "0"));
  85.  
  86. for(int ia = 0; ia < count; ia++)
  87. {
  88. Item rel = someRelationships.getItemByIndex(ia);
  89. string relEvent = rel.getProperty("mrn_plm_triggering_event");
  90.  
  91. //exportPosition = Convert.ToInt32(rel.getProperty("mrn_plm_exportposition"));
  92. if(relEvent == "IDENT6")
  93. {
  94. IDENT6_LIST.Add(rel);
  95. }
  96. else if(relEvent == "MESURE")
  97. {
  98. MEASURE_LIST.Add(rel);
  99. }
  100. }
  101.  
  102. int identCount = IDENT6_LIST.Count;
  103. int measureCount = MEASURE_LIST.Count;
  104.  
  105. List<KeyValuePair<int, string>> ident6Cont = new List<KeyValuePair<int, string>>();
  106. List<KeyValuePair<int, string>> measureCont = new List<KeyValuePair<int, string>>();
  107.  
  108. foreach(var entry in IDENT6_LIST)
  109. {
  110.  
  111. ident6Cont.Add(new KeyValuePair<int, string>(Convert.ToInt32(entry.getProperty("mrn_plm_exportposition", "")),entry.getProperty("mrn_plm_priority", "")));
  112.  
  113. //ident6Cont.Add(currentPair);
  114. }
  115.  
  116. foreach(var entry in MEASURE_LIST)
  117. {
  118.  
  119. measureCont.Add(new KeyValuePair<int, string>(Convert.ToInt32(entry.getProperty("mrn_plm_exportposition", "")),entry.getProperty("mrn_plm_priority", "")));
  120.  
  121. //ident6Cont.Add(currentPair);
  122. }
  123.  
  124.  
  125. ident6Cont = ident6Cont.OrderBy(x =>x.Key)
  126. //.ThenBy(x =>x.Value)
  127. .ToList();
  128.  
  129. measureCont = measureCont.OrderBy(x => x.Key).ToList();
  130.  
  131. List<Item> IDENT6_LISTReal = new List<Item>();
  132. List<Item> MEASURE_LISTReal = new List<Item>();
  133.  
  134. foreach(var entry in ident6Cont)
  135. {
  136. int currPos = entry.Key;
  137. string currPosString = currPos.ToString();
  138. string currPriority = entry.Value;
  139.  
  140. foreach(var el in IDENT6_LIST)
  141. {
  142. string currIDENT6Pos = el.getProperty("mrn_plm_exportposition", "");
  143. string currIDENT6Priority = el.getProperty("mrn_plm_priority", "");
  144. if(currIDENT6Pos == currPosString && currPriority == currIDENT6Priority)
  145. {
  146. IDENT6_LISTReal.Add(el);
  147. break;
  148. }
  149. }
  150. }
  151.  
  152. foreach(var entry in measureCont)
  153. {
  154. int currPos = entry.Key;
  155. string currPosString = currPos.ToString();
  156. string currPriority = entry.Value;
  157.  
  158. foreach(var el in MEASURE_LIST)
  159. {
  160. string currMEASUREPos = el.getProperty("mrn_plm_exportposition", "");
  161. string currMEASUREPriority = el.getProperty("mrn_plm_priority", "");
  162. if(currMEASUREPos == currPosString && currPriority == currMEASUREPriority)
  163. {
  164. MEASURE_LISTReal.Add(el);
  165. break;
  166. }
  167. }
  168. }
  169.  
  170. Item last = null;
  171. Item lastMeasure = null;
  172.  
  173. if(identCount > 0)
  174. {
  175. last = IDENT6_LISTReal.Last();
  176. }
  177. if(measureCount > 0){
  178. lastMeasure = MEASURE_LISTReal.Last();
  179. }
  180.  
  181. //System.Diagnostics.Debugger.Break();
  182. System.Diagnostics.Debugger.Break();
  183. string wantedProperty = null;
  184. try
  185. {
  186. foreach(Item finishedGood in allNeededFinishedGoods)
  187. {
  188. bool flag = false;
  189. string priorityString = "";
  190. wantedProperty = "";
  191. foreach(Item itemItm in IDENT6_LISTReal)
  192. {
  193. itemType = itemItm.getProperty("mrn_plm_item_type", "");
  194. infoType = itemItm.getProperty("mrn_plm_info_type", "");
  195. information = itemItm.getProperty("mrn_plm_information", "");
  196. defaultValue = itemItm.getProperty("mrn_plm_defaut_value", "");
  197. itemInformation = itemItm.getProperty("mrn_plm_item_information", "");
  198. exportPosition = itemItm.getProperty("mrn_plm_exportposition", "");
  199. startPosition = itemItm.getProperty("mrn_plm_start_position", "");
  200. length = itemItm.getProperty("mrn_plm_length", "");
  201. usage = itemItm.getProperty("mrn_plm_usage_doc", "");
  202. priority = itemItm.getProperty("mrn_plm_priority", "");
  203. leadingZero = itemItm.getProperty("mrn_plm_leading0", "");
  204. mutiplyTousend = itemItm.getProperty("mrn_plm_multiply1000", "");
  205. removeSeparator = itemItm.getProperty("mrn_plm_remove_separator", "");
  206. string value = null;
  207. string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
  208. string productLabItemId = finishedGood.getProperty("mrn_plm_product_label_item", "");
  209.  
  210. if(exportPosition == "40")
  211. {
  212. string s= "sa";
  213. }
  214.  
  215. string valueCopy;
  216. var nextItem = 0;
  217.  
  218. 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"))
  219. {
  220.  
  221. if(infoType == "DateTime-YYMMDDhhmm")
  222. {
  223. DateTime dt = DateTime.Now;;
  224. if (information == "Today") {dt = DateTime.Now;}
  225. if (information == "Yesterday") {dt = dt.AddDays(-1);}
  226. if (information == "Tomorrow") {dt = dt.AddDays(1);}
  227. value = dt.ToString("yyMMddHHmm");
  228. for(int f = 0; f < int.Parse(length); f++)
  229. {
  230. if(defaultValue == "") defaultValue = " ";
  231. if(value == "") value = defaultValue;
  232. if(value == null || f >= value.Length)
  233. {
  234. wantedProperty += " ";
  235. continue;
  236. }
  237. wantedProperty += value[f];
  238. }
  239. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  240. {
  241. System.Diagnostics.Debugger.Break();
  242. id.Close();
  243. me.Close();
  244.  
  245. return inn.newError("Please Look at the table");
  246. }
  247. }
  248. else if(infoType == "Date-MM/DD/YYYY")
  249. {
  250.  
  251. DateTime dte = DateTime.Now;
  252. if (information == "Today") {dte = DateTime.Now;}
  253. if (information == "Yesterday") {dte = dte.AddDays(-1);}
  254. if (information == "Tomorrow") {dte = dte.AddDays(1);}
  255. value = dte.ToString(@"MM\/dd\/yyyy");
  256. for(int f = 0; f < int.Parse(length); f++)
  257. {
  258. if(defaultValue == "") defaultValue = " ";
  259. if(value == "") value = defaultValue;
  260. if(value == null || f >= value.Length)
  261. {
  262. wantedProperty += " ";
  263. continue;
  264. }
  265. wantedProperty += value[f];
  266. }
  267. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  268. {
  269. System.Diagnostics.Debugger.Break();
  270. id.Close();
  271. me.Close();
  272.  
  273. return inn.newError("Please Look at the table");
  274. }
  275. }
  276. }
  277.  
  278. else if(itemType == "Item")
  279. {
  280. int d = wantedProperty.Length;
  281. switch(infoType)
  282. {
  283. case "Property":
  284. if(information != "")
  285. value = finishedGood.getProperty(information, "");
  286. else value = defaultValue;
  287. valueCopy = value;
  288.  
  289. if(value == "C0000669")
  290. {
  291. id.Close();
  292. me.Close();
  293.  
  294. System.Diagnostics.Debugger.Break();
  295. }
  296.  
  297. nextItem = 0;
  298.  
  299. if(priority == "Preminary")
  300. {
  301. if(value != "")
  302. {
  303. flag = true;
  304. priorityString = value;
  305. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  306.  
  307. //if(nextItem >= 2 && priority == "Preminary") break;
  308. }
  309. else
  310. {
  311. flag = true;
  312. continue;
  313.  
  314. }
  315. }
  316. else if(priority == "Alternative")
  317. {
  318. if(flag == false)
  319. {
  320. if(priorityString != "")
  321. {
  322. flag = false;
  323. priorityString = "";
  324. break;
  325. }
  326. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  327. id.Close();
  328. me.Close();
  329. continue;
  330. }
  331.  
  332. if(priorityString != "")
  333. {
  334. flag = false;
  335. priorityString = "";
  336. if (itemItm.Equals(last))
  337. {
  338.  
  339. id.Write(wantedProperty);
  340. id.Write("*");
  341. id.WriteLine();
  342. continue;
  343. }
  344. continue;
  345. }
  346. }
  347. //MultiplyTousend
  348. if(mutiplyTousend == "1")
  349. {
  350. if(valueCopy != "")
  351. {
  352. decimal decimalValue = decimal.Parse(value);
  353. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  354. }
  355. }
  356. //RemoveSeparator
  357. if(removeSeparator == "1"){
  358. if(valueCopy != "")
  359. {
  360. Item properties = inn.getItemByKeyedName("Property", information);
  361.  
  362. bool isDecimal = false;
  363. foreach (char c in value)
  364. if (c == '.')
  365. {
  366. isDecimal = true;
  367. break;
  368. }
  369.  
  370. if(isDecimal)
  371. {
  372. string scaleStr = properties.getProperty("scale", "");
  373. int scale = int.Parse(scaleStr);
  374. int tousendMultiple = 1;
  375. for(int k = 0; k < scale; k++)
  376. tousendMultiple *= 10;
  377. decimal decimalValue = decimal.Parse(value);
  378. decimalValue *= tousendMultiple;
  379. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  380. value.ToString();
  381. value = resultValue;
  382. }
  383. }
  384. }
  385. //Leading Zero
  386. if(leadingZero == "1") {
  387. if(valueCopy != "")
  388. {
  389.  
  390. bool isDecimal = false;
  391. foreach (char c in value)
  392. if (c == '.')
  393. {
  394. isDecimal = true;
  395. break;
  396. }
  397.  
  398. if(isDecimal)
  399. {
  400. if(mutiplyTousend == "1")
  401. {
  402. Item properties = inn.getItemByKeyedName("Property", information);
  403.  
  404. string scaleStr = properties.getProperty("scale", "");
  405. int scale = int.Parse(scaleStr);
  406. int tousendMultiple = 1;
  407. for(int k = 0; k < scale; k++)
  408. tousendMultiple *= 10;
  409. decimal decimalValue = decimal.Parse(value);
  410. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  411. value = currValue.ToString();
  412. }
  413. }
  414. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  415. value = value.ToString();
  416. if(possitionsForZeros < int.Parse(length))
  417. {
  418. string zeros = "";
  419. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  420.  
  421. value = zeros + value;
  422. }
  423. }
  424. }
  425.  
  426. for(int s = 0; s < int.Parse(length); s++)
  427. {
  428. if(defaultValue == "") defaultValue = " ";
  429. if(value == "") value = defaultValue;
  430. if(value == null || s >= value.Length)
  431. {
  432. wantedProperty += " ";
  433. continue;
  434. }
  435. wantedProperty += value[s];
  436. }
  437.  
  438. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  439. {
  440. System.Diagnostics.Debugger.Break();
  441. id.Close();
  442. me.Close();
  443. return inn.newError("Please Look at the table");
  444. }
  445. break;
  446. case "ItemPropertyItem":
  447. Item thisItem = null;
  448. if(information != "")
  449. {
  450. string myItemId = finishedGood.getProperty(information, "");
  451. if(myItemId != "")
  452. {
  453. try
  454. {
  455. if(information == "mrn_plm_pim_product")
  456. {
  457. thisItem = inn.getItemById("MRN_Item", myItemId);
  458. }
  459. else if(information == "mrn_plm_label_item" || information == "mrn_plm_product_label_item")
  460. {
  461. thisItem = inn.newItem("mrn_plm_labeling_item", myItemId);
  462. }
  463. else thisItem = inn.newItem("Part", myItemId);
  464. //thisItem = inn.getItemById(information, myItemId);
  465. }
  466. catch(Exception) {inn.newError("The is no Item type with this name!");}
  467. value = thisItem.getProperty(itemInformation , "");
  468. }
  469. else value = "";
  470.  
  471. nextItem = 0;
  472.  
  473. if(value ==null)
  474. {
  475. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  476. }
  477.  
  478. if(nextItem >= 2 && priority == "Preminary") break;
  479.  
  480. valueCopy = value;
  481.  
  482. if(priority == "Preminary") {
  483. if(value != "")
  484. {
  485. flag = true;
  486. priorityString = value;
  487. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  488.  
  489. //if(nextItem >= 2 && priority == "Preminary") break;
  490. }
  491. else
  492. {
  493. flag = true;
  494. continue;
  495.  
  496. }
  497. }
  498. else if(priority == "Alternative"){
  499. if(flag == false)
  500. {
  501. if(priorityString != "")
  502. {
  503. flag = false;
  504. priorityString = "";
  505. break;
  506. }
  507. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  508. id.Close();
  509. me.Close();
  510. continue;
  511. }
  512.  
  513. if(priorityString != "")
  514. {
  515. flag = false;
  516. priorityString = "";
  517. if (itemItm.Equals(last))
  518. {
  519. id.Write(wantedProperty);
  520. id.Write("*");
  521. id.WriteLine();
  522. continue;
  523. }
  524. continue;
  525. }
  526. }
  527.  
  528. //MultiplyTousend
  529. if(mutiplyTousend == "1")
  530. {
  531. if(valueCopy != "")
  532. {
  533. decimal decimalValue = decimal.Parse(value);
  534. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  535. }
  536. }
  537. //RemoveSeparator
  538. if(removeSeparator == "1"){
  539. if(valueCopy != "")
  540. {
  541. Item properties = inn.getItemByKeyedName("Property", information);
  542.  
  543. bool isDecimal = false;
  544. foreach (char c in value)
  545. if (c == '.')
  546. {
  547. isDecimal = true;
  548. break;
  549. }
  550.  
  551. if(isDecimal)
  552. {
  553. string scaleStr = properties.getProperty("scale", "");
  554. int scale = int.Parse(scaleStr);
  555. int tousendMultiple = 1;
  556. for(int k = 0; k < scale; k++)
  557. tousendMultiple *= 10;
  558. decimal decimalValue = decimal.Parse(value);
  559. decimalValue *= tousendMultiple;
  560. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  561. value.ToString();
  562. value = resultValue;
  563. }
  564. }
  565. }
  566. //Leading Zero
  567. if(leadingZero == "1")
  568. {
  569. if(valueCopy != "")
  570. {
  571.  
  572. bool isDecimal = false;
  573. foreach (char c in value)
  574. if (c == '.')
  575. {
  576. isDecimal = true;
  577. break;
  578. }
  579.  
  580. if(isDecimal)
  581. {
  582. if(mutiplyTousend == "1")
  583. {
  584. Item properties = inn.getItemByKeyedName("Property", information);
  585.  
  586. string scaleStr = properties.getProperty("scale", "");
  587. int scale = int.Parse(scaleStr);
  588. int tousendMultiple = 1;
  589. for(int k = 0; k < scale; k++)
  590. tousendMultiple *= 10;
  591. decimal decimalValue = decimal.Parse(value);
  592. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  593. value = currValue.ToString();
  594. }
  595. }
  596. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  597. value = value.ToString();
  598. if(possitionsForZeros < int.Parse(length))
  599. {
  600. string zeros = "";
  601. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  602.  
  603. value = zeros + value;
  604. }
  605. }
  606. }
  607. for(int s = 0; s < int.Parse(length); s++)
  608. {
  609. if(defaultValue == "") defaultValue = " ";
  610. if(value == "") value = defaultValue;
  611. if(value == null || s >= value.Length)
  612. {
  613. wantedProperty += " ";
  614. continue;
  615. }
  616. wantedProperty += value[s];
  617. }
  618. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length)){
  619. System.Diagnostics.Debugger.Break();
  620. id.Close();
  621. me.Close();
  622.  
  623. return inn.newError("Please Look at the table");
  624. }
  625. }
  626. else
  627. {
  628. value = "";
  629. for(int s = 0; s < int.Parse(length); s++)
  630. {
  631. if(defaultValue == "") defaultValue = " ";
  632. if(value == "") value = defaultValue;
  633. if(value == null || s >= value.Length)
  634. {
  635. wantedProperty += " ";
  636. continue;
  637. }
  638. wantedProperty += value[s];
  639. }
  640. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  641. {
  642. System.Diagnostics.Debugger.Break();
  643. id.Close();
  644. me.Close();
  645.  
  646. return inn.newError("Please Look at the table");
  647. }
  648. }
  649. break;
  650. }
  651. }
  652.  
  653. else if(itemType == "Generic Label Item")
  654. {
  655. switch(infoType)
  656. {
  657. case "Property":
  658. if(information == "" || labItemId == "")
  659. {
  660. value = defaultValue;
  661. }
  662. else if(labItemId != "")
  663. {
  664. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  665. value = ourLabItem.getProperty(information);
  666. }
  667.  
  668. nextItem = 0;
  669.  
  670. if(value ==null)
  671. {
  672. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  673. }
  674.  
  675. if(nextItem >= 2 && priority == "Preminary") break;
  676.  
  677. valueCopy = value;
  678.  
  679. if(priority == "Preminary") {
  680. if(value != "")
  681. {
  682. flag = true;
  683. priorityString = value;
  684. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  685.  
  686. //if(nextItem >= 2 && priority == "Preminary") break;
  687. }
  688. else
  689. {
  690. flag = true;
  691. continue;
  692.  
  693. }
  694. }
  695. else if(priority == "Alternative"){
  696. if(flag == false)
  697. {
  698. if(priorityString != "")
  699. {
  700. flag = false;
  701. priorityString = "";
  702. break;
  703. }
  704. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  705. id.Close();
  706. me.Close();
  707. continue;
  708. }
  709.  
  710. if(priorityString != "")
  711. {
  712. flag = false;
  713. priorityString = "";
  714. if (itemItm.Equals(last))
  715. {
  716.  
  717. id.Write(wantedProperty);
  718. id.Write("*");
  719. id.WriteLine();
  720. continue;
  721. }
  722. continue;
  723. }
  724. }
  725.  
  726. //MultiplyTousend
  727. if(mutiplyTousend == "1") {
  728. if(valueCopy != "")
  729. {
  730. decimal decimalValue = decimal.Parse(value);
  731. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  732. }
  733. }
  734. //RemoveSeparator
  735. if(removeSeparator == "1"){
  736. if(valueCopy != "")
  737. {
  738. Item properties = inn.getItemByKeyedName("Property", information);
  739.  
  740. bool isDecimal = false;
  741. foreach (char c in value)
  742. if (c == '.')
  743. {
  744. isDecimal = true;
  745. break;
  746. }
  747.  
  748. if(isDecimal)
  749. {
  750. string scaleStr = properties.getProperty("scale", "");
  751. int scale = int.Parse(scaleStr);
  752. int tousendMultiple = 1;
  753. for(int k = 0; k < scale; k++)
  754. tousendMultiple *= 10;
  755. decimal decimalValue = decimal.Parse(value);
  756. decimalValue *= tousendMultiple;
  757. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  758. value.ToString();
  759. value = resultValue;
  760. }
  761. }
  762. }
  763. //Leading Zero
  764. if(leadingZero == "1") {
  765. if(valueCopy != "")
  766. {
  767.  
  768. bool isDecimal = false;
  769. foreach (char c in value)
  770. if (c == '.')
  771. {
  772. isDecimal = true;
  773. break;
  774. }
  775.  
  776. if(isDecimal)
  777. {
  778. if(mutiplyTousend == "1")
  779. {
  780. Item properties = inn.getItemByKeyedName("Property", information);
  781.  
  782. string scaleStr = properties.getProperty("scale", "");
  783. int scale = int.Parse(scaleStr);
  784. int tousendMultiple = 1;
  785. for(int k = 0; k < scale; k++)
  786. tousendMultiple *= 10;
  787. decimal decimalValue = decimal.Parse(value);
  788. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  789. value = currValue.ToString();
  790. }
  791. }
  792. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  793. value = value.ToString();
  794. if(possitionsForZeros < int.Parse(length))
  795. {
  796. string zeros = "";
  797. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  798.  
  799. value = zeros + value;
  800. }
  801. }
  802. }
  803.  
  804. for(int s = 0; s < int.Parse(length); s++)
  805. {
  806. if(defaultValue == "") defaultValue = " ";
  807. if(value == "") value = defaultValue;
  808. if(value == null || s >= value.Length)
  809. {
  810. wantedProperty += " ";
  811. continue;
  812. }
  813. wantedProperty += value[s];
  814. }
  815. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  816. {
  817. System.Diagnostics.Debugger.Break();
  818. id.Close();
  819. me.Close();
  820.  
  821. return inn.newError("Please Look at the table");
  822. }
  823. break;
  824. case "RelatedProperty":
  825. if(labItemId != "")
  826. {
  827. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  828.  
  829. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  830. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  831. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  832. int getRelsCount = getRels.getItemCount();
  833. for(int sk = 0; sk < getRelsCount; sk++)
  834. {
  835. Item currentProperty = getRels.getItemByIndex(sk);
  836. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  837. if(information == currProperty)
  838. {
  839. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  840. {
  841. value = currentProperty.getProperty("mrn_plm_label_value");
  842. break;
  843. }
  844. }
  845. else continue;
  846. }
  847. if(value == null) value = "";
  848. }
  849. else value = "";
  850.  
  851. nextItem = 0;
  852.  
  853. if(value ==null)
  854. {
  855. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  856. }
  857.  
  858. if(nextItem >= 2 && priority == "Preminary") break;
  859.  
  860. valueCopy = value;
  861.  
  862. if(priority == "Preminary") {
  863. if(value != "")
  864. {
  865. flag = true;
  866. priorityString = value;
  867. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  868.  
  869. //if(nextItem >= 2 && priority == "Preminary") break;
  870. }
  871. else
  872. {
  873. flag = true;
  874. continue;
  875.  
  876. }
  877. }
  878. else if(priority == "Alternative"){
  879. if(flag == false)
  880. {
  881. if(priorityString != "")
  882. {
  883. flag = false;
  884. priorityString = "";
  885. break;
  886. }
  887. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  888. id.Close();
  889. me.Close();
  890. continue;
  891. }
  892.  
  893. if(priorityString != "")
  894. {
  895. flag = false;
  896. priorityString = "";
  897. if (itemItm.Equals(last))
  898. {
  899.  
  900. id.Write(wantedProperty);
  901. id.Write("*");
  902. id.WriteLine();
  903. continue;
  904. }
  905. continue;
  906. }
  907. }
  908.  
  909. //MultiplyTousend
  910. if(mutiplyTousend == "1") {
  911. if(valueCopy != "")
  912. {
  913. decimal decimalValue = decimal.Parse(value);
  914. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  915. }
  916. }
  917. //RemoveSeparator
  918. if(removeSeparator == "1"){
  919. if(valueCopy != "")
  920. {
  921. Item properties = inn.getItemByKeyedName("Property", information);
  922.  
  923. bool isDecimal = false;
  924. foreach (char c in value)
  925. if (c == '.')
  926. {
  927. isDecimal = true;
  928. break;
  929. }
  930.  
  931. if(isDecimal)
  932. {
  933. string scaleStr = properties.getProperty("scale", "");
  934. int scale = int.Parse(scaleStr);
  935. int tousendMultiple = 1;
  936. for(int k = 0; k < scale; k++)
  937. tousendMultiple *= 10;
  938. decimal decimalValue = decimal.Parse(value);
  939. decimalValue *= tousendMultiple;
  940. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  941. value.ToString();
  942. value = resultValue;
  943. }
  944. }
  945. }
  946. //Leading Zero
  947. if(leadingZero == "1") {
  948. if(valueCopy != "")
  949. {
  950.  
  951. bool isDecimal = false;
  952. foreach (char c in value)
  953. if (c == '.')
  954. {
  955. isDecimal = true;
  956. break;
  957. }
  958.  
  959. if(isDecimal)
  960. {
  961. if(mutiplyTousend == "1")
  962. {
  963. Item properties = inn.getItemByKeyedName("Property", information);
  964.  
  965. string scaleStr = properties.getProperty("scale", "");
  966. int scale = int.Parse(scaleStr);
  967. int tousendMultiple = 1;
  968. for(int k = 0; k < scale; k++)
  969. tousendMultiple *= 10;
  970. decimal decimalValue = decimal.Parse(value);
  971. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  972. value = currValue.ToString();
  973. }
  974. }
  975. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  976. value = value.ToString();
  977. if(possitionsForZeros < int.Parse(length))
  978. {
  979. string zeros = "";
  980. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  981.  
  982. value = zeros + value;
  983. }
  984. }
  985. }
  986.  
  987. for(int s = 0; s < int.Parse(length); s++)
  988. {
  989. if(defaultValue == "") defaultValue = " ";
  990. if(value == "") value = defaultValue;
  991. if(value == null || s >= value.Length)
  992. {
  993. wantedProperty += " ";
  994. continue;
  995. }
  996. wantedProperty += value[s];
  997. }
  998. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  999. {
  1000. System.Diagnostics.Debugger.Break();
  1001. id.Close();
  1002. me.Close();
  1003.  
  1004. return inn.newError("Please Look at the table");
  1005. }
  1006.  
  1007. break;
  1008. case "ItemPropertyItem":
  1009.  
  1010. Item myStockPart = null;
  1011. string myStockPartId = "";
  1012. string cItem = finishedGood.getProperty("mrn_plm_label_item", "");
  1013. Item ssd = null;
  1014. if(cItem != "")
  1015. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  1016.  
  1017. if(ssd != null && information != "")
  1018. myStockPartId = ssd.getProperty(information, "");
  1019.  
  1020. if(myStockPartId != "")
  1021. {
  1022. myStockPart = inn.getItemById("Part", myStockPartId);
  1023. value = myStockPart.getProperty(itemInformation, "");
  1024. }
  1025.  
  1026. else value = "";
  1027.  
  1028. nextItem = 0;
  1029.  
  1030. if(value ==null)
  1031. {
  1032. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1033. }
  1034.  
  1035. if(nextItem >= 2 && priority == "Preminary") break;
  1036.  
  1037. valueCopy = value;
  1038.  
  1039. if(priority == "Preminary") {
  1040. if(value != "")
  1041. {
  1042. flag = true;
  1043. priorityString = value;
  1044. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1045.  
  1046. //if(nextItem >= 2 && priority == "Preminary") break;
  1047. }
  1048. else
  1049. {
  1050. flag = true;
  1051. continue;
  1052.  
  1053. }
  1054. }
  1055. else if(priority == "Alternative"){
  1056. if(flag == false)
  1057. {
  1058. if(priorityString != "")
  1059. {
  1060. flag = false;
  1061. priorityString = "";
  1062. break;
  1063. }
  1064. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  1065. id.Close();
  1066. me.Close();
  1067. continue;
  1068. }
  1069.  
  1070. if(priorityString != "")
  1071. {
  1072. flag = false;
  1073. priorityString = "";
  1074. if (itemItm.Equals(last))
  1075. {
  1076.  
  1077. id.Write(wantedProperty);
  1078. id.Write("*");
  1079. id.WriteLine();
  1080. continue;
  1081. }
  1082. continue;
  1083. }
  1084. }
  1085.  
  1086. //MultiplyTousend
  1087. if(mutiplyTousend == "1") {
  1088. if(valueCopy != "")
  1089. {
  1090. decimal decimalValue = decimal.Parse(value);
  1091. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  1092. }
  1093. }
  1094. //RemoveSeparator
  1095. if(removeSeparator == "1"){
  1096. if(valueCopy != "")
  1097. {
  1098. Item properties = inn.getItemByKeyedName("Property", information);
  1099.  
  1100. bool isDecimal = false;
  1101. foreach (char c in value)
  1102. if (c == '.')
  1103. {
  1104. isDecimal = true;
  1105. break;
  1106. }
  1107.  
  1108. if(isDecimal)
  1109. {
  1110. string scaleStr = properties.getProperty("scale", "");
  1111. int scale = int.Parse(scaleStr);
  1112. int tousendMultiple = 1;
  1113. for(int k = 0; k < scale; k++)
  1114. tousendMultiple *= 10;
  1115. decimal decimalValue = decimal.Parse(value);
  1116. decimalValue *= tousendMultiple;
  1117. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  1118. value.ToString();
  1119. value = resultValue;
  1120. }
  1121. }
  1122. }
  1123. //Leading Zero
  1124. if(leadingZero == "1") {
  1125. if(valueCopy != "")
  1126. {
  1127.  
  1128. bool isDecimal = false;
  1129. foreach (char c in value)
  1130. if (c == '.')
  1131. {
  1132. isDecimal = true;
  1133. break;
  1134. }
  1135.  
  1136. if(isDecimal)
  1137. {
  1138. if(mutiplyTousend == "1")
  1139. {
  1140. Item properties = inn.getItemByKeyedName("Property", information);
  1141.  
  1142. string scaleStr = properties.getProperty("scale", "");
  1143. int scale = int.Parse(scaleStr);
  1144. int tousendMultiple = 1;
  1145. for(int k = 0; k < scale; k++)
  1146. tousendMultiple *= 10;
  1147. decimal decimalValue = decimal.Parse(value);
  1148. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  1149. value = currValue.ToString();
  1150. }
  1151. }
  1152. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  1153. value = value.ToString();
  1154. if(possitionsForZeros < int.Parse(length))
  1155. {
  1156. string zeros = "";
  1157. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  1158.  
  1159. value = zeros + value;
  1160. }
  1161. }
  1162. }
  1163.  
  1164. for(int s = 0; s < int.Parse(length); s++)
  1165. {
  1166. if(defaultValue == "") defaultValue = " ";
  1167. if(value == "") value = defaultValue;
  1168. if(value == null || s >= value.Length)
  1169. {
  1170. wantedProperty += " ";
  1171. continue;
  1172. }
  1173. wantedProperty += value[s];
  1174. }
  1175. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1176. {
  1177. System.Diagnostics.Debugger.Break();
  1178. id.Close();
  1179. me.Close();
  1180.  
  1181. return inn.newError("Please Look at the table");
  1182. }
  1183. break;
  1184. case "Document":
  1185.  
  1186. if(labItemId != "")
  1187. {
  1188. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  1189.  
  1190. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  1191. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  1192.  
  1193. int docRelCount = docRelationships.getItemCount();
  1194.  
  1195. for(int f = 0; f < docRelCount; f++)
  1196. {
  1197. Item currDoc = docRelationships.getItemByIndex(f);
  1198. Item doc = currDoc.getRelatedItem();
  1199. var docUsage = currDoc.getProperty("mrn_plm_usage");
  1200.  
  1201. if(docUsage == usage)
  1202. {
  1203. value = doc.getProperty(information, "");
  1204. break;
  1205. }
  1206. }
  1207.  
  1208. nextItem = 0;
  1209.  
  1210. if(value ==null)
  1211. {
  1212. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1213. }
  1214.  
  1215. if(nextItem >= 2 && priority == "Preminary") break;
  1216. //else value = "";
  1217.  
  1218. nextItem = 0;
  1219.  
  1220. // if(value ==null)
  1221. // {
  1222. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1223. // }
  1224.  
  1225. valueCopy = value;
  1226.  
  1227.  
  1228. if(priority == "Preminary") {
  1229. if(value != "")
  1230. {
  1231. flag = true;
  1232. priorityString = value;
  1233. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1234.  
  1235. //if(nextItem >= 2 && priority == "Preminary") break;
  1236. }
  1237. else
  1238. {
  1239. flag = true;
  1240. continue;
  1241.  
  1242. }
  1243. }
  1244. else if(priority == "Alternative"){
  1245. if(flag == false)
  1246. {
  1247. if(priorityString != "")
  1248. {
  1249. flag = false;
  1250. priorityString = "";
  1251. break;
  1252. }
  1253. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  1254. id.Close();
  1255. me.Close();
  1256. continue;
  1257. }
  1258.  
  1259. if(priorityString != "")
  1260. {
  1261. flag = false;
  1262. priorityString = "";
  1263. if (itemItm.Equals(last))
  1264. {
  1265.  
  1266. id.Write(wantedProperty);
  1267. id.Write("*");
  1268. id.WriteLine();
  1269. continue;
  1270. }
  1271. continue;
  1272. }
  1273. }
  1274.  
  1275. //MultiplyTousend
  1276. if(mutiplyTousend == "1") {
  1277. if(valueCopy != "")
  1278. {
  1279. decimal decimalValue = decimal.Parse(value);
  1280. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  1281. }
  1282. }
  1283. //RemoveSeparator
  1284. if(removeSeparator == "1"){
  1285. if(valueCopy != "")
  1286. {
  1287. Item properties = inn.getItemByKeyedName("Property", information);
  1288.  
  1289. bool isDecimal = false;
  1290. foreach (char c in value)
  1291. if (c == '.')
  1292. {
  1293. isDecimal = true;
  1294. break;
  1295. }
  1296.  
  1297. if(isDecimal)
  1298. {
  1299. string scaleStr = properties.getProperty("scale", "");
  1300. int scale = int.Parse(scaleStr);
  1301. int tousendMultiple = 1;
  1302. for(int k = 0; k < scale; k++)
  1303. tousendMultiple *= 10;
  1304. decimal decimalValue = decimal.Parse(value);
  1305. decimalValue *= tousendMultiple;
  1306. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  1307. value.ToString();
  1308. value = resultValue;
  1309. }
  1310. }
  1311. }
  1312. //Leading Zero
  1313. if(leadingZero == "1") {
  1314. if(valueCopy != "")
  1315. {
  1316.  
  1317. bool isDecimal = false;
  1318. foreach (char c in value)
  1319. if (c == '.')
  1320. {
  1321. isDecimal = true;
  1322. break;
  1323. }
  1324.  
  1325. if(isDecimal)
  1326. {
  1327. if(mutiplyTousend == "1")
  1328. {
  1329. Item properties = inn.getItemByKeyedName("Property", information);
  1330.  
  1331. string scaleStr = properties.getProperty("scale", "");
  1332. int scale = int.Parse(scaleStr);
  1333. int tousendMultiple = 1;
  1334. for(int k = 0; k < scale; k++)
  1335. tousendMultiple *= 10;
  1336. decimal decimalValue = decimal.Parse(value);
  1337. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  1338. value = currValue.ToString();
  1339. }
  1340. }
  1341. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  1342. value = value.ToString();
  1343. if(possitionsForZeros < int.Parse(length))
  1344. {
  1345. string zeros = "";
  1346. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  1347.  
  1348. value = zeros + value;
  1349. }
  1350. }
  1351. }
  1352.  
  1353. for(int s = 0; s < int.Parse(length); s++)
  1354. {
  1355. if(defaultValue == "") defaultValue = " ";
  1356. if(value == "") value = defaultValue;
  1357. if(value == null || s >= value.Length)
  1358. {
  1359. wantedProperty += " ";
  1360. continue;
  1361. }
  1362. wantedProperty += value[s];
  1363. }
  1364. if(wantedProperty.Length + 1 != int.Parse(startPosition) +int.Parse(length))
  1365. {
  1366. return inn.newError("Please Look at the table");
  1367. }
  1368. }
  1369.  
  1370. else
  1371. {
  1372. value = "";
  1373. for(int s = 0; s < int.Parse(length); s++)
  1374. {
  1375. if(defaultValue == "") defaultValue = " ";
  1376. if(value == "") value = defaultValue;
  1377. if(value == null || s >= value.Length)
  1378. {
  1379. wantedProperty += " ";
  1380. continue;
  1381. }
  1382. wantedProperty += value[s];
  1383. }
  1384. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1385. {
  1386. System.Diagnostics.Debugger.Break();
  1387. id.Close();
  1388. me.Close();
  1389.  
  1390. return inn.newError("Please Look at the table");
  1391. }
  1392. }
  1393.  
  1394. break;
  1395. }
  1396. }
  1397.  
  1398. else if(itemType == "Product Label Item")
  1399. {
  1400. switch(infoType)
  1401. {
  1402. case "Property":
  1403.  
  1404. if(information == "" || productLabItemId == "")
  1405. {
  1406. value = defaultValue;
  1407. }
  1408.  
  1409. if(productLabItemId != "")
  1410. {
  1411. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  1412. value = ourLabItem.getProperty(information, "");
  1413. }
  1414.  
  1415. nextItem = 0;
  1416.  
  1417. if(value ==null)
  1418. {
  1419. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1420. }
  1421.  
  1422. if(nextItem >= 2 && priority == "Preminary") break;
  1423.  
  1424. valueCopy = value;
  1425.  
  1426. if(priority == "Preminary") {
  1427. if(value != "")
  1428. {
  1429. flag = true;
  1430. priorityString = value;
  1431. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1432.  
  1433. //if(nextItem >= 2 && priority == "Preminary") break;
  1434. }
  1435. else
  1436. {
  1437. flag = true;
  1438. continue;
  1439.  
  1440. }
  1441. }
  1442. else if(priority == "Alternative"){
  1443. if(flag == false)
  1444. {
  1445. if(priorityString != "")
  1446. {
  1447. flag = false;
  1448. priorityString = "";
  1449. break;
  1450. }
  1451. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  1452. id.Close();
  1453. me.Close();
  1454. continue;
  1455. }
  1456.  
  1457. if(priorityString != "")
  1458. {
  1459. flag = false;
  1460. priorityString = "";
  1461. if (itemItm.Equals(last))
  1462. {
  1463.  
  1464. id.Write(wantedProperty);
  1465. id.Write("*");
  1466. id.WriteLine();
  1467. continue;
  1468. }
  1469. continue;
  1470. }
  1471. }
  1472.  
  1473. //MultiplyTousend
  1474. if(mutiplyTousend == "1") {
  1475. if(valueCopy != "")
  1476. {
  1477. decimal decimalValue = decimal.Parse(value);
  1478. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  1479. }
  1480. }
  1481. //RemoveSeparator
  1482. if(removeSeparator == "1"){
  1483. if(valueCopy != "")
  1484. {
  1485. Item properties = inn.getItemByKeyedName("Property", information);
  1486.  
  1487. bool isDecimal = false;
  1488. foreach (char c in value)
  1489. if (c == '.')
  1490. {
  1491. isDecimal = true;
  1492. break;
  1493. }
  1494.  
  1495. if(isDecimal)
  1496. {
  1497. string scaleStr = properties.getProperty("scale", "");
  1498. int scale = int.Parse(scaleStr);
  1499. int tousendMultiple = 1;
  1500. for(int k = 0; k < scale; k++)
  1501. tousendMultiple *= 10;
  1502. decimal decimalValue = decimal.Parse(value);
  1503. decimalValue *= tousendMultiple;
  1504. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  1505. value.ToString();
  1506. value = resultValue;
  1507. }
  1508. }
  1509. }
  1510. //Leading Zero
  1511. if(leadingZero == "1") {
  1512. if(valueCopy != "")
  1513. {
  1514.  
  1515. bool isDecimal = false;
  1516. foreach (char c in value)
  1517. if (c == '.')
  1518. {
  1519. isDecimal = true;
  1520. break;
  1521. }
  1522.  
  1523. if(isDecimal)
  1524. {
  1525. if(mutiplyTousend == "1")
  1526. {
  1527. Item properties = inn.getItemByKeyedName("Property", information);
  1528.  
  1529. string scaleStr = properties.getProperty("scale", "");
  1530. int scale = int.Parse(scaleStr);
  1531. int tousendMultiple = 1;
  1532. for(int k = 0; k < scale; k++)
  1533. tousendMultiple *= 10;
  1534. decimal decimalValue = decimal.Parse(value);
  1535. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  1536. value = currValue.ToString();
  1537. }
  1538. }
  1539. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  1540. value = value.ToString();
  1541. if(possitionsForZeros < int.Parse(length))
  1542. {
  1543. string zeros = "";
  1544. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  1545.  
  1546. value = zeros + value;
  1547. }
  1548. }
  1549. }
  1550.  
  1551. for(int s = 0; s < int.Parse(length); s++)
  1552. {
  1553. if(defaultValue == "") defaultValue = " ";
  1554. if(value == "") value = defaultValue;
  1555. if(value == null || s >= value.Length)
  1556. {
  1557. wantedProperty += " ";
  1558. continue;
  1559. }
  1560. wantedProperty += value[s];
  1561. }
  1562. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1563. {
  1564. System.Diagnostics.Debugger.Break();
  1565. id.Close();
  1566. me.Close();
  1567.  
  1568. return inn.newError("Please Look at the table");
  1569. }
  1570. break;
  1571. case "RelatedProperty":
  1572.  
  1573. if(productLabItemId != "")
  1574. {
  1575. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  1576.  
  1577. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  1578. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  1579. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  1580. int getRelsCount = getRels.getItemCount();
  1581. for(int sk = 0; sk < getRelsCount; sk++)
  1582. {
  1583. Item currentProperty = getRels.getItemByIndex(sk);
  1584. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  1585. if(information == currProperty)
  1586. {
  1587. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  1588. {
  1589. value = currentProperty.getProperty("mrn_plm_label_value");
  1590. break;
  1591. }
  1592. }
  1593. }
  1594. if(value == null) value = "";
  1595. }
  1596. else value = "";
  1597.  
  1598. nextItem = 0;
  1599.  
  1600. if(value ==null)
  1601. {
  1602. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1603. }
  1604.  
  1605. if(nextItem >= 2 && priority == "Preminary") break;
  1606.  
  1607. valueCopy = value;
  1608. if(priority == "Preminary") {
  1609. if(value != "")
  1610. {
  1611. flag = true;
  1612. priorityString = value;
  1613. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1614.  
  1615. //if(nextItem >= 2 && priority == "Preminary") break;
  1616. }
  1617. else
  1618. {
  1619. flag = true;
  1620. continue;
  1621.  
  1622. }
  1623. }
  1624. else if(priority == "Alternative"){
  1625. if(flag == false)
  1626. {
  1627. if(priorityString != "")
  1628. {
  1629. flag = false;
  1630. priorityString = "";
  1631. break;
  1632. }
  1633. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  1634. id.Close();
  1635. me.Close();
  1636. continue;
  1637. }
  1638.  
  1639. if(priorityString != "")
  1640. {
  1641. flag = false;
  1642. priorityString = "";
  1643. if (itemItm.Equals(last))
  1644. {
  1645.  
  1646. id.Write(wantedProperty);
  1647. id.Write("*");
  1648. id.WriteLine();
  1649. continue;
  1650. }
  1651. continue;
  1652. }
  1653. }
  1654.  
  1655. //MultiplyTousend
  1656. if(mutiplyTousend == "1") {
  1657. if(valueCopy != "")
  1658. {
  1659. decimal decimalValue = decimal.Parse(value);
  1660. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  1661. }
  1662. }
  1663. //RemoveSeparator
  1664. if(removeSeparator == "1"){
  1665. if(valueCopy != "")
  1666. {
  1667. Item properties = inn.getItemByKeyedName("Property", information);
  1668.  
  1669. bool isDecimal = false;
  1670. foreach (char c in value)
  1671. if (c == '.')
  1672. {
  1673. isDecimal = true;
  1674. break;
  1675. }
  1676.  
  1677. if(isDecimal)
  1678. {
  1679. string scaleStr = properties.getProperty("scale", "");
  1680. int scale = int.Parse(scaleStr);
  1681. int tousendMultiple = 1;
  1682. for(int k = 0; k < scale; k++)
  1683. tousendMultiple *= 10;
  1684. decimal decimalValue = decimal.Parse(value);
  1685. decimalValue *= tousendMultiple;
  1686. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  1687. value.ToString();
  1688. value = resultValue;
  1689. }
  1690. }
  1691. }
  1692. //Leading Zero
  1693. if(leadingZero == "1") {
  1694. if(valueCopy != "")
  1695. {
  1696.  
  1697. bool isDecimal = false;
  1698. foreach (char c in value)
  1699. if (c == '.')
  1700. {
  1701. isDecimal = true;
  1702. break;
  1703. }
  1704.  
  1705. if(isDecimal)
  1706. {
  1707. if(mutiplyTousend == "1")
  1708. {
  1709. Item properties = inn.getItemByKeyedName("Property", information);
  1710.  
  1711. string scaleStr = properties.getProperty("scale", "");
  1712. int scale = int.Parse(scaleStr);
  1713. int tousendMultiple = 1;
  1714. for(int k = 0; k < scale; k++)
  1715. tousendMultiple *= 10;
  1716. decimal decimalValue = decimal.Parse(value);
  1717. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  1718. value = currValue.ToString();
  1719. }
  1720. }
  1721. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  1722. value = value.ToString();
  1723. if(possitionsForZeros < int.Parse(length))
  1724. {
  1725. string zeros = "";
  1726. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  1727.  
  1728. value = zeros + value;
  1729. }
  1730. }
  1731. }
  1732.  
  1733. for(int s = 0; s < int.Parse(length); s++)
  1734. {
  1735. if(defaultValue == "") defaultValue = " ";
  1736. if(value == "") value = defaultValue;
  1737. if(value == null || s >= value.Length)
  1738. {
  1739. wantedProperty += " ";
  1740. continue;
  1741. }
  1742. wantedProperty += value[s];
  1743. }
  1744. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1745. {
  1746. System.Diagnostics.Debugger.Break();
  1747. id.Close();
  1748. me.Close();
  1749.  
  1750. return inn.newError("Please Look at the table");
  1751. }
  1752.  
  1753. break;
  1754. case "ItemPropertyItem":
  1755. Item myStockPart = null;
  1756. string myStockPartId = null;
  1757. string cItem = finishedGood.getProperty("mrn_plm_product_label_item", "");
  1758. Item ssd = null;
  1759. if(cItem != "")
  1760. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  1761.  
  1762. if(ssd != null && information != "")
  1763. myStockPartId = ssd.getProperty(information, "");
  1764.  
  1765. if(myStockPartId != "")
  1766. {
  1767. myStockPart = inn.getItemById("Part", myStockPartId);
  1768. value = myStockPart.getProperty(itemInformation, "");
  1769. }
  1770.  
  1771. else value = "";
  1772.  
  1773.  
  1774. nextItem = 0;
  1775.  
  1776. if(value ==null)
  1777. {
  1778. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1779. }
  1780.  
  1781. if(nextItem >= 2 && priority == "Preminary") break;
  1782.  
  1783.  
  1784. valueCopy = value;
  1785.  
  1786. if(priority == "Preminary") {
  1787. if(value != "")
  1788. {
  1789. flag = true;
  1790. priorityString = value;
  1791. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1792.  
  1793. //if(nextItem >= 2 && priority == "Preminary") break;
  1794. }
  1795. else
  1796. {
  1797. flag = true;
  1798. continue;
  1799.  
  1800. }
  1801. }
  1802. else if(priority == "Alternative"){
  1803. if(flag == false)
  1804. {
  1805. if(priorityString != "")
  1806. {
  1807. flag = false;
  1808. priorityString = "";
  1809. break;
  1810. }
  1811. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  1812. id.Close();
  1813. me.Close();
  1814. continue;
  1815. }
  1816.  
  1817. if(priorityString != "")
  1818. {
  1819. flag = false;
  1820. priorityString = "";
  1821. if (itemItm.Equals(last))
  1822. {
  1823.  
  1824. id.Write(wantedProperty);
  1825. id.Write("*");
  1826. id.WriteLine();
  1827. continue;
  1828. }
  1829. continue;
  1830. }
  1831. }
  1832.  
  1833. //MultiplyTousend
  1834. if(mutiplyTousend == "1") {
  1835. if(valueCopy != "")
  1836. {
  1837. decimal decimalValue = decimal.Parse(value);
  1838. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  1839. }
  1840. }
  1841. //RemoveSeparator
  1842. if(removeSeparator == "1"){
  1843. if(valueCopy != "")
  1844. {
  1845. Item properties = inn.getItemByKeyedName("Property", information);
  1846.  
  1847. bool isDecimal = false;
  1848. foreach (char c in value)
  1849. if (c == '.')
  1850. {
  1851. isDecimal = true;
  1852. break;
  1853. }
  1854.  
  1855. if(isDecimal)
  1856. {
  1857. string scaleStr = properties.getProperty("scale", "");
  1858. int scale = int.Parse(scaleStr);
  1859. int tousendMultiple = 1;
  1860. for(int k = 0; k < scale; k++)
  1861. tousendMultiple *= 10;
  1862. decimal decimalValue = decimal.Parse(value);
  1863. decimalValue *= tousendMultiple;
  1864. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  1865. value.ToString();
  1866. value = resultValue;
  1867. }
  1868. }
  1869. }
  1870. //Leading Zero
  1871. if(leadingZero == "1") {
  1872. if(valueCopy != "")
  1873. {
  1874.  
  1875. bool isDecimal = false;
  1876. foreach (char c in value)
  1877. if (c == '.')
  1878. {
  1879. isDecimal = true;
  1880. break;
  1881. }
  1882.  
  1883. if(isDecimal)
  1884. {
  1885. if(mutiplyTousend == "1")
  1886. {
  1887. Item properties = inn.getItemByKeyedName("Property", information);
  1888.  
  1889. string scaleStr = properties.getProperty("scale", "");
  1890. int scale = int.Parse(scaleStr);
  1891. int tousendMultiple = 1;
  1892. for(int k = 0; k < scale; k++)
  1893. tousendMultiple *= 10;
  1894. decimal decimalValue = decimal.Parse(value);
  1895. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  1896. value = currValue.ToString();
  1897. }
  1898. }
  1899. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  1900. value = value.ToString();
  1901. if(possitionsForZeros < int.Parse(length))
  1902. {
  1903. string zeros = "";
  1904. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  1905.  
  1906. value = zeros + value;
  1907. }
  1908. }
  1909. }
  1910.  
  1911. for(int s = 0; s < int.Parse(length); s++)
  1912. {
  1913. if(defaultValue == "") defaultValue = " ";
  1914. if(value == "") value = defaultValue;
  1915. if(value == null || s >= value.Length)
  1916. {
  1917. wantedProperty += " ";
  1918. continue;
  1919. }
  1920. wantedProperty += value[s];
  1921. }
  1922. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  1923. {
  1924. System.Diagnostics.Debugger.Break();
  1925. id.Close();
  1926. me.Close();
  1927.  
  1928. return inn.newError("Please Look at the table");
  1929. }
  1930. break;
  1931. case "Document":
  1932. if(productLabItemId != "")
  1933. {
  1934. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  1935.  
  1936. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  1937. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  1938.  
  1939. int docRelCount = docRelationships.getItemCount();
  1940.  
  1941. for(int f = 0; f < docRelCount; f++)
  1942. {
  1943. Item currDoc = docRelationships.getItemByIndex(f);
  1944. Item doc = currDoc.getRelatedItem();
  1945. Item docOne = doc.getRelatedItem();
  1946. var docUsage = currDoc.getProperty("mrn_plm_usage");
  1947.  
  1948. if(docUsage == usage)
  1949. {
  1950. string ourID = currDoc.getProperty("related_id");
  1951. Item currentItem = inn.getItemById("Document" ,ourID);
  1952. if(currentItem != null)
  1953. value = currentItem.getProperty(information, "");
  1954. break;
  1955. }
  1956. }
  1957.  
  1958. nextItem = 0;
  1959.  
  1960. if(value ==null)
  1961. {
  1962. nextItem = IDENT6_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  1963. }
  1964.  
  1965. if(nextItem >= 2 && priority == "Preminary") break;
  1966. //else value = "";
  1967.  
  1968. valueCopy = value;
  1969.  
  1970. if(priority == "Preminary") {
  1971. if(value != "")
  1972. {
  1973. flag = true;
  1974. priorityString = value;
  1975. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  1976.  
  1977. //if(nextItem >= 2 && priority == "Preminary") break;
  1978. }
  1979. else
  1980. {
  1981. flag = true;
  1982. continue;
  1983.  
  1984. }
  1985. }
  1986. else if(priority == "Alternative"){
  1987. if(flag == false)
  1988. {
  1989. if(priorityString != "")
  1990. {
  1991. flag = false;
  1992. priorityString = "";
  1993. break;
  1994. }
  1995. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  1996. id.Close();
  1997. me.Close();
  1998. continue;
  1999. }
  2000.  
  2001. if(priorityString != "")
  2002. {
  2003. flag = false;
  2004. priorityString = "";
  2005. continue;
  2006. }
  2007. }
  2008.  
  2009. //MultiplyTousend
  2010. if(mutiplyTousend == "1") {
  2011. if(valueCopy != "")
  2012. {
  2013. decimal decimalValue = decimal.Parse(value);
  2014. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  2015. }
  2016. }
  2017. //RemoveSeparator
  2018. if(removeSeparator == "1"){
  2019. if(valueCopy != "")
  2020. {
  2021. Item properties = inn.getItemByKeyedName("Property", information);
  2022.  
  2023. bool isDecimal = false;
  2024. foreach (char c in value)
  2025. if (c == '.')
  2026. {
  2027. isDecimal = true;
  2028. break;
  2029. }
  2030.  
  2031. if(isDecimal)
  2032. {
  2033. string scaleStr = properties.getProperty("scale", "");
  2034. int scale = int.Parse(scaleStr);
  2035. int tousendMultiple = 1;
  2036. for(int k = 0; k < scale; k++)
  2037. tousendMultiple *= 10;
  2038. decimal decimalValue = decimal.Parse(value);
  2039. decimalValue *= tousendMultiple;
  2040. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  2041. value.ToString();
  2042. value = resultValue;
  2043. }
  2044. }
  2045. }
  2046. //Leading Zero
  2047. if(leadingZero == "1") {
  2048. if(valueCopy != "")
  2049. {
  2050.  
  2051. bool isDecimal = false;
  2052. foreach (char c in value)
  2053. if (c == '.')
  2054. {
  2055. isDecimal = true;
  2056. break;
  2057. }
  2058.  
  2059. if(isDecimal)
  2060. {
  2061. if(mutiplyTousend == "1")
  2062. {
  2063. Item properties = inn.getItemByKeyedName("Property", information);
  2064.  
  2065. string scaleStr = properties.getProperty("scale", "");
  2066. int scale = int.Parse(scaleStr);
  2067. int tousendMultiple = 1;
  2068. for(int k = 0; k < scale; k++)
  2069. tousendMultiple *= 10;
  2070. decimal decimalValue = decimal.Parse(value);
  2071. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  2072. value = currValue.ToString();
  2073. }
  2074. }
  2075. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  2076. value = value.ToString();
  2077. if(possitionsForZeros < int.Parse(length))
  2078. {
  2079. string zeros = "";
  2080. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  2081.  
  2082. value = zeros + value;
  2083. }
  2084. }
  2085. }
  2086.  
  2087. for(int s = 0; s < int.Parse(length); s++)
  2088. {
  2089. if(defaultValue == "") defaultValue = " ";
  2090. if(value == "") value = defaultValue;
  2091. if(value == null || s >= value.Length)
  2092. {
  2093. wantedProperty += " ";
  2094. continue;
  2095. }
  2096. wantedProperty += value[s];
  2097. }
  2098. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  2099. {
  2100. System.Diagnostics.Debugger.Break();
  2101. id.Close();
  2102. me.Close();
  2103.  
  2104. return inn.newError("Please Look at the table");
  2105. }
  2106. }
  2107.  
  2108. else
  2109. {
  2110. value = " ";
  2111. for(int s = 0; s < int.Parse(length); s++)
  2112. {
  2113. if(defaultValue == "") defaultValue = " ";
  2114. if(value == "") value = defaultValue;
  2115. if(value == null || s >= value.Length)
  2116. {
  2117. wantedProperty += " ";
  2118. continue;
  2119. }
  2120. wantedProperty += value[s];
  2121. }
  2122. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  2123. {
  2124. System.Diagnostics.Debugger.Break();
  2125. id.Close();
  2126. me.Close();
  2127.  
  2128. return inn.newError("Please Look at the table");
  2129. }
  2130. }
  2131.  
  2132. break;
  2133. }
  2134. }
  2135.  
  2136. else if(itemType == "Certification")
  2137. {
  2138.  
  2139. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  2140. //Item pim = null;
  2141. if(pimId != "")
  2142. {
  2143. switch(infoType)
  2144. {
  2145. case "Property":
  2146. Item relationshipsDocs = inn.newItem("MRN_Item_Document", "get");
  2147. relationshipsDocs.setAttribute ("where", "[MRN_Item_Document].source_id='" + pimId + "'");
  2148. relationshipsDocs = relationshipsDocs.apply();
  2149.  
  2150. int countRelationships = relationshipsDocs.getItemCount();
  2151.  
  2152. for(int f = 0; f < countRelationships; f++)
  2153. {
  2154. Item currDoc = relationshipsDocs.getItemByIndex(f);
  2155. var docUsage = currDoc.getProperty("mrn_plm_usage");
  2156. Item doc = currDoc.getRelatedItem();
  2157.  
  2158. if(docUsage == usage)
  2159. {
  2160. value = doc.getProperty(information, "");
  2161. break;
  2162. }
  2163. }
  2164.  
  2165. break;
  2166. }
  2167. }
  2168. else value = "";
  2169.  
  2170. nextItem = 0;
  2171.  
  2172. if(value ==null)
  2173. {
  2174. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2175. }
  2176.  
  2177. if(nextItem >= 2 && priority == "Preminary") break;
  2178.  
  2179. valueCopy = value;
  2180.  
  2181. if(priority == "Preminary") {
  2182. if(value != "")
  2183. {
  2184. flag = true;
  2185. priorityString = value;
  2186. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2187.  
  2188. //if(nextItem >= 2 && priority == "Preminary") break;
  2189. }
  2190. else
  2191. {
  2192. flag = true;
  2193. continue;
  2194.  
  2195. }
  2196. }
  2197. else if(priority == "Alternative"){
  2198. if(flag == false)
  2199. {
  2200. if(priorityString != "")
  2201. {
  2202. flag = false;
  2203. priorityString = "";
  2204. break;
  2205. }
  2206. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  2207. id.Close();
  2208. me.Close();
  2209. continue;
  2210. }
  2211.  
  2212. if(priorityString != "")
  2213. {
  2214. flag = false;
  2215. priorityString = "";
  2216. if (itemItm.Equals(last))
  2217. {
  2218.  
  2219. id.Write(wantedProperty);
  2220. id.Write("*");
  2221. id.WriteLine();
  2222. continue;
  2223. }
  2224. continue;
  2225. }
  2226. }
  2227. //MultiplyTousend
  2228. if(mutiplyTousend == "1") {
  2229. if(valueCopy != "")
  2230. {
  2231. decimal decimalValue = decimal.Parse(value);
  2232. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  2233. }
  2234. }
  2235. //RemoveSeparator
  2236. if(removeSeparator == "1"){
  2237. if(valueCopy != "")
  2238. {
  2239. Item properties = inn.getItemByKeyedName("Property", information);
  2240.  
  2241. bool isDecimal = false;
  2242. foreach (char c in value)
  2243. if (c == '.')
  2244. {
  2245. isDecimal = true;
  2246. break;
  2247. }
  2248.  
  2249. if(isDecimal)
  2250. {
  2251. string scaleStr = properties.getProperty("scale", "");
  2252. int scale = int.Parse(scaleStr);
  2253. int tousendMultiple = 1;
  2254. for(int k = 0; k < scale; k++)
  2255. tousendMultiple *= 10;
  2256. decimal decimalValue = decimal.Parse(value);
  2257. decimalValue *= tousendMultiple;
  2258. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  2259. value.ToString();
  2260. value = resultValue;
  2261. }
  2262. }
  2263. }
  2264. //Leading Zero
  2265. if(leadingZero == "1") {
  2266. if(valueCopy != "")
  2267. {
  2268.  
  2269. bool isDecimal = false;
  2270. foreach (char c in value)
  2271. if (c == '.')
  2272. {
  2273. isDecimal = true;
  2274. break;
  2275. }
  2276.  
  2277. if(isDecimal)
  2278. {
  2279. if(mutiplyTousend == "1")
  2280. {
  2281. Item properties = inn.getItemByKeyedName("Property", information);
  2282.  
  2283. string scaleStr = properties.getProperty("scale", "");
  2284. int scale = int.Parse(scaleStr);
  2285. int tousendMultiple = 1;
  2286. for(int k = 0; k < scale; k++)
  2287. tousendMultiple *= 10;
  2288. decimal decimalValue = decimal.Parse(value);
  2289. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  2290. value = currValue.ToString();
  2291. }
  2292. }
  2293. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  2294. value = value.ToString();
  2295. if(possitionsForZeros < int.Parse(length))
  2296. {
  2297. string zeros = "";
  2298. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  2299.  
  2300. value = zeros + value;
  2301. }
  2302. }
  2303. }
  2304.  
  2305. for(int s = 0; s < int.Parse(length); s++)
  2306. {
  2307. if(defaultValue == "") defaultValue = " ";
  2308. if(value == "") value = defaultValue;
  2309. if(value == null || s >= value.Length)
  2310. {
  2311. wantedProperty += " ";
  2312. continue;
  2313. }
  2314. wantedProperty += value[s];
  2315. }
  2316.  
  2317. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  2318. {
  2319. System.Diagnostics.Debugger.Break();
  2320. id.Close();
  2321. me.Close();
  2322.  
  2323. return inn.newError("Please Look at the table");
  2324. }
  2325. }
  2326.  
  2327. else if(itemType == "Constitution")
  2328. {
  2329. switch(infoType)
  2330. {
  2331. case "Property":
  2332. string partConstId = finishedGood.getProperty("mrn_plm_constitution");
  2333.  
  2334. Item someXProps = inn.newItem("xPropertyDefinition", "get");
  2335. someXProps.setProperty("name", information);
  2336. someXProps = someXProps.apply();
  2337. try
  2338. {
  2339. string res = someXProps.getProperty("name");
  2340.  
  2341. string sql = @"SELECT [" + res + "] FROM [xp].[XPROPERTYVALUES] WHERE item_id='" + partConstId + "'";
  2342. Item sqlResult = inn.applySQL(sql);
  2343. value = sqlResult.getProperty(res);
  2344. }
  2345.  
  2346. catch(Exception){value = "";}
  2347.  
  2348. nextItem = 0;
  2349.  
  2350. if(value ==null)
  2351. {
  2352. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2353. }
  2354.  
  2355. if(nextItem >= 2 && priority == "Preminary") break;
  2356.  
  2357. valueCopy = value;
  2358.  
  2359. if(priority == "Preminary") {
  2360. if(value != "")
  2361. {
  2362. flag = true;
  2363. priorityString = value;
  2364. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2365.  
  2366. //if(nextItem >= 2 && priority == "Preminary") break;
  2367. }
  2368. else
  2369. {
  2370. flag = true;
  2371. continue;
  2372.  
  2373. }
  2374. }
  2375. else if(priority == "Alternative"){
  2376. if(flag == false)
  2377. {
  2378. if(priorityString != "")
  2379. {
  2380. flag = false;
  2381. priorityString = "";
  2382. break;
  2383. }
  2384. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  2385. id.Close();
  2386. me.Close();
  2387. continue;
  2388. }
  2389.  
  2390. if(priorityString != "")
  2391. {
  2392. flag = false;
  2393. priorityString = "";
  2394. if (itemItm.Equals(last))
  2395. {
  2396.  
  2397. id.Write(wantedProperty);
  2398. id.Write("*");
  2399. id.WriteLine();
  2400. continue;
  2401. }
  2402. continue;
  2403. }
  2404. }
  2405.  
  2406. //MultiplyTousend
  2407. if(mutiplyTousend == "1") {
  2408. if(valueCopy != "")
  2409. {
  2410. decimal decimalValue = decimal.Parse(value);
  2411. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  2412. }
  2413. }
  2414. //RemoveSeparator
  2415. if(removeSeparator == "1"){
  2416. if(valueCopy != "")
  2417. {
  2418. Item properties = inn.getItemByKeyedName("Property", information);
  2419.  
  2420. bool isDecimal = false;
  2421. foreach (char c in value)
  2422. if (c == '.')
  2423. {
  2424. isDecimal = true;
  2425. break;
  2426. }
  2427.  
  2428. if(isDecimal)
  2429. {
  2430. string scaleStr = properties.getProperty("scale", "");
  2431. int scale = int.Parse(scaleStr);
  2432. int tousendMultiple = 1;
  2433. for(int k = 0; k < scale; k++)
  2434. tousendMultiple *= 10;
  2435. decimal decimalValue = decimal.Parse(value);
  2436. decimalValue *= tousendMultiple;
  2437. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  2438. value.ToString();
  2439. value = resultValue;
  2440. }
  2441. }
  2442. }
  2443. //Leading Zero
  2444. if(leadingZero == "1") {
  2445. if(valueCopy != "")
  2446. {
  2447.  
  2448. bool isDecimal = false;
  2449. foreach (char c in value)
  2450. if (c == '.')
  2451. {
  2452. isDecimal = true;
  2453. break;
  2454. }
  2455.  
  2456. if(isDecimal)
  2457. {
  2458. if(mutiplyTousend == "1")
  2459. {
  2460. Item properties = inn.getItemByKeyedName("Property", information);
  2461.  
  2462. string scaleStr = properties.getProperty("scale", "");
  2463. int scale = int.Parse(scaleStr);
  2464. int tousendMultiple = 1;
  2465. for(int k = 0; k < scale; k++)
  2466. tousendMultiple *= 10;
  2467. decimal decimalValue = decimal.Parse(value);
  2468. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  2469. value = currValue.ToString();
  2470. }
  2471. }
  2472. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  2473. value = value.ToString();
  2474. if(possitionsForZeros < int.Parse(length))
  2475. {
  2476. string zeros = "";
  2477. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  2478.  
  2479. value = zeros + value;
  2480. }
  2481. }
  2482. }
  2483.  
  2484. for(int s = 0; s < int.Parse(length); s++) {
  2485. if(defaultValue == "") defaultValue = " ";
  2486. if(value == "") value = defaultValue;
  2487. if(value == null || s >= value.Length)
  2488. {
  2489. wantedProperty += " ";
  2490. continue;
  2491. }
  2492. wantedProperty += value[s];
  2493. }
  2494. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length)) {
  2495. System.Diagnostics.Debugger.Break();
  2496. id.Close();
  2497. me.Close();
  2498.  
  2499. return inn.newError("Please Look at the table");
  2500. }
  2501. break;
  2502. }
  2503. }
  2504.  
  2505. else if(itemType == "R35")
  2506. {
  2507. Item r35Item = null;
  2508. string r35 = finishedGood.getProperty("mrn_plm_r35", "");
  2509.  
  2510. if(r35 != "")
  2511. {
  2512. r35Item = inn.getItemById("Part", r35);
  2513. }
  2514.  
  2515. switch(infoType)
  2516. {
  2517. case "Property":
  2518. if(r35Item != null)
  2519. value = r35Item.getProperty(information, "");
  2520. else value = "";
  2521.  
  2522. nextItem = 0;
  2523.  
  2524. if(value ==null)
  2525. {
  2526. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2527. }
  2528.  
  2529. if(nextItem >= 2 && priority == "Preminary") break;
  2530.  
  2531. valueCopy = value;
  2532.  
  2533. if(priority == "Preminary") {
  2534. if(value != "")
  2535. {
  2536. flag = true;
  2537. priorityString = value;
  2538. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2539.  
  2540. //if(nextItem >= 2 && priority == "Preminary") break;
  2541. }
  2542. else
  2543. {
  2544. flag = true;
  2545. continue;
  2546.  
  2547. }
  2548. }
  2549. else if(priority == "Alternative"){
  2550. if(flag == false)
  2551. {
  2552. if(priorityString != "")
  2553. {
  2554. flag = false;
  2555. priorityString = "";
  2556. break;
  2557. }
  2558. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  2559. id.Close();
  2560. me.Close();
  2561. continue;
  2562. }
  2563.  
  2564. if(priorityString != "")
  2565. {
  2566. flag = false;
  2567. priorityString = "";
  2568. if (itemItm.Equals(last))
  2569. {
  2570.  
  2571. id.Write(wantedProperty);
  2572. id.Write("*");
  2573. id.WriteLine();
  2574. continue;
  2575. }
  2576. continue;
  2577. }
  2578. }
  2579.  
  2580. //MultiplyTousend
  2581. if(mutiplyTousend == "1") {
  2582. if(valueCopy != "")
  2583. {
  2584. decimal decimalValue = decimal.Parse(value);
  2585. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  2586. }
  2587. }
  2588. //RemoveSeparator
  2589. if(removeSeparator == "1"){
  2590. if(valueCopy != "")
  2591. {
  2592. Item properties = inn.getItemByKeyedName("Property", information);
  2593.  
  2594. bool isDecimal = false;
  2595. foreach (char c in value)
  2596. if (c == '.')
  2597. {
  2598. isDecimal = true;
  2599. break;
  2600. }
  2601.  
  2602. if(isDecimal)
  2603. {
  2604. string scaleStr = properties.getProperty("scale", "");
  2605. int scale = int.Parse(scaleStr);
  2606. int tousendMultiple = 1;
  2607. for(int k = 0; k < scale; k++)
  2608. tousendMultiple *= 10;
  2609. decimal decimalValue = decimal.Parse(value);
  2610. decimalValue *= tousendMultiple;
  2611. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  2612. value.ToString();
  2613. value = resultValue;
  2614. }
  2615. }
  2616. }
  2617. //Leading Zero
  2618. if(leadingZero == "1") {
  2619. if(valueCopy != "")
  2620. {
  2621.  
  2622. bool isDecimal = false;
  2623. foreach (char c in value)
  2624. if (c == '.')
  2625. {
  2626. isDecimal = true;
  2627. break;
  2628. }
  2629.  
  2630. if(isDecimal)
  2631. {
  2632. if(mutiplyTousend == "1")
  2633. {
  2634. Item properties = inn.getItemByKeyedName("Property", information);
  2635.  
  2636. string scaleStr = properties.getProperty("scale", "");
  2637. int scale = int.Parse(scaleStr);
  2638. int tousendMultiple = 1;
  2639. for(int k = 0; k < scale; k++)
  2640. tousendMultiple *= 10;
  2641. decimal decimalValue = decimal.Parse(value);
  2642. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  2643. value = currValue.ToString();
  2644. }
  2645. }
  2646. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  2647. value = value.ToString();
  2648. if(possitionsForZeros < int.Parse(length))
  2649. {
  2650. string zeros = "";
  2651. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  2652.  
  2653. value = zeros + value;
  2654. }
  2655. }
  2656. }
  2657.  
  2658. for(int s = 0; s < int.Parse(length); s++)
  2659. {
  2660. if(defaultValue == "") defaultValue = " ";
  2661. if(value == "") value = defaultValue;
  2662. if(value == null || s >= value.Length)
  2663. {
  2664. wantedProperty += " ";
  2665. continue;
  2666. }
  2667. wantedProperty += value[s];
  2668. }
  2669. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  2670. {
  2671. System.Diagnostics.Debugger.Break();
  2672. id.Close();
  2673. me.Close();
  2674.  
  2675. return inn.newError("Please Look at the table");
  2676. }
  2677. break;
  2678.  
  2679. case "ItemPropertyItem":
  2680. string myStockPartId = null;
  2681. Item myStockPart = null;
  2682.  
  2683. if(r35Item != null)
  2684. {
  2685. myStockPartId = r35Item.getProperty(information, "");
  2686.  
  2687. if(myStockPartId != "")
  2688. myStockPart = inn.getItemById("Part", myStockPartId);
  2689. }
  2690. if(myStockPart != null)
  2691. {
  2692. value = myStockPart.getProperty(itemInformation, "");
  2693. //return inn.newError("There is stock Item");
  2694. }
  2695. else value = "";
  2696.  
  2697. nextItem = 0;
  2698.  
  2699. if(value ==null)
  2700. {
  2701. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2702. }
  2703.  
  2704. if(nextItem >= 2 && priority == "Preminary") break;
  2705.  
  2706. valueCopy = value;
  2707.  
  2708. if(priority == "Preminary") {
  2709. if(value != "")
  2710. {
  2711. flag = true;
  2712. priorityString = value;
  2713. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2714.  
  2715. //if(nextItem >= 2 && priority == "Preminary") break;
  2716. }
  2717. else
  2718. {
  2719. flag = true;
  2720. continue;
  2721.  
  2722. }
  2723. }
  2724. else if(priority == "Alternative"){
  2725. if(flag == false)
  2726. {
  2727. if(priorityString != "")
  2728. {
  2729. flag = false;
  2730. priorityString = "";
  2731. break;
  2732. }
  2733. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  2734. id.Close();
  2735. me.Close();
  2736. continue;
  2737. }
  2738.  
  2739. if(priorityString != "")
  2740. {
  2741. flag = false;
  2742. priorityString = "";
  2743. if (itemItm.Equals(last))
  2744. {
  2745.  
  2746. id.Write(wantedProperty);
  2747. id.Write("*");
  2748. id.WriteLine();
  2749. continue;
  2750. }
  2751. continue;
  2752. }
  2753. }
  2754.  
  2755. //MultiplyTousend
  2756. if(mutiplyTousend == "1") {
  2757. if(valueCopy != "")
  2758. {
  2759. decimal decimalValue = decimal.Parse(value);
  2760. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  2761. }
  2762. }
  2763. //RemoveSeparator
  2764. if(removeSeparator == "1"){
  2765. if(valueCopy != "")
  2766. {
  2767. Item properties = inn.getItemByKeyedName("Property", information);
  2768.  
  2769. bool isDecimal = false;
  2770. foreach (char c in value)
  2771. if (c == '.')
  2772. {
  2773. isDecimal = true;
  2774. break;
  2775. }
  2776.  
  2777. if(isDecimal)
  2778. {
  2779. string scaleStr = properties.getProperty("scale", "");
  2780. int scale = int.Parse(scaleStr);
  2781. int tousendMultiple = 1;
  2782. for(int k = 0; k < scale; k++)
  2783. tousendMultiple *= 10;
  2784. decimal decimalValue = decimal.Parse(value);
  2785. decimalValue *= tousendMultiple;
  2786. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  2787. value.ToString();
  2788. value = resultValue;
  2789. }
  2790. }
  2791. }
  2792. //Leading Zero
  2793. if(leadingZero == "1") {
  2794. if(valueCopy != "")
  2795. {
  2796.  
  2797. bool isDecimal = false;
  2798. foreach (char c in value)
  2799. if (c == '.')
  2800. {
  2801. isDecimal = true;
  2802. break;
  2803. }
  2804.  
  2805. if(isDecimal)
  2806. {
  2807. if(mutiplyTousend == "1")
  2808. {
  2809. Item properties = inn.getItemByKeyedName("Property", information);
  2810.  
  2811. string scaleStr = properties.getProperty("scale", "");
  2812. int scale = int.Parse(scaleStr);
  2813. int tousendMultiple = 1;
  2814. for(int k = 0; k < scale; k++)
  2815. tousendMultiple *= 10;
  2816. decimal decimalValue = decimal.Parse(value);
  2817. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  2818. value = currValue.ToString();
  2819. }
  2820. }
  2821. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  2822. value = value.ToString();
  2823. if(possitionsForZeros < int.Parse(length))
  2824. {
  2825. string zeros = "";
  2826. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  2827.  
  2828. value = zeros + value;
  2829. }
  2830. }
  2831. }
  2832.  
  2833. for(int s = 0; s < int.Parse(length); s++)
  2834. {
  2835. if(defaultValue == "") defaultValue = " ";
  2836. if(value == "") value = defaultValue;
  2837. if(value == null || s >= value.Length)
  2838. {
  2839. wantedProperty += " ";
  2840. continue;
  2841. }
  2842. wantedProperty += value[s];
  2843. }
  2844. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  2845. {
  2846. System.Diagnostics.Debugger.Break();
  2847. id.Close();
  2848. me.Close();
  2849.  
  2850. return inn.newError("Please Look at the table");
  2851. }
  2852. break;
  2853. }
  2854. }
  2855.  
  2856. else if(itemType == "MSL")
  2857. {
  2858. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  2859. Item pim = null;
  2860. Item msl = null;
  2861. if(pimId != "")
  2862. {
  2863. pim = inn.getItemById("MRN_Item", pimId);
  2864.  
  2865. string mslId = pim.getProperty("mrn_parent_msl", "");
  2866.  
  2867. if(mslId != "")
  2868. msl = inn.getItemById("MRN_Item", mslId);
  2869. }
  2870.  
  2871. switch(infoType)
  2872. {
  2873. case "Property":
  2874. if(msl != null)
  2875. value = msl.getProperty(information, "");
  2876. else value = "";
  2877.  
  2878. nextItem = 0;
  2879.  
  2880. if(value ==null)
  2881. {
  2882. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2883. }
  2884.  
  2885. if(nextItem >= 2 && priority == "Preminary") break;
  2886.  
  2887. valueCopy = value;
  2888.  
  2889. if(priority == "Preminary") {
  2890. if(value != "")
  2891. {
  2892. flag = true;
  2893. priorityString = value;
  2894. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  2895.  
  2896. //if(nextItem >= 2 && priority == "Preminary") break;
  2897. }
  2898. else
  2899. {
  2900. flag = true;
  2901. continue;
  2902.  
  2903. }
  2904. }
  2905. else if(priority == "Alternative"){
  2906. if(flag == false)
  2907. {
  2908. if(priorityString != "")
  2909. {
  2910. flag = false;
  2911. priorityString = "";
  2912. break;
  2913. }
  2914. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  2915. id.Close();
  2916. me.Close();
  2917. continue;
  2918. }
  2919.  
  2920. if(priorityString != "")
  2921. {
  2922. flag = false;
  2923. priorityString = "";
  2924. if (itemItm.Equals(last))
  2925. {
  2926.  
  2927. id.Write(wantedProperty);
  2928. id.Write("*");
  2929. id.WriteLine();
  2930. continue;
  2931. }
  2932. continue;
  2933. }
  2934. }
  2935. //MultiplyTousend
  2936. if(mutiplyTousend == "1") {
  2937. if(valueCopy != "")
  2938. {
  2939. decimal decimalValue = decimal.Parse(value);
  2940. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  2941. }
  2942. }
  2943. //RemoveSeparator
  2944. if(removeSeparator == "1"){
  2945. if(valueCopy != "")
  2946. {
  2947. Item properties = inn.getItemByKeyedName("Property", information);
  2948.  
  2949. bool isDecimal = false;
  2950. foreach (char c in value)
  2951. if (c == '.')
  2952. {
  2953. isDecimal = true;
  2954. break;
  2955. }
  2956.  
  2957. if(isDecimal)
  2958. {
  2959. string scaleStr = properties.getProperty("scale", "");
  2960. int scale = int.Parse(scaleStr);
  2961. int tousendMultiple = 1;
  2962. for(int k = 0; k < scale; k++)
  2963. tousendMultiple *= 10;
  2964. decimal decimalValue = decimal.Parse(value);
  2965. decimalValue *= tousendMultiple;
  2966. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  2967. value.ToString();
  2968. value = resultValue;
  2969. }
  2970. }
  2971. }
  2972. //Leading Zero
  2973. if(leadingZero == "1") {
  2974. if(valueCopy != "")
  2975. {
  2976.  
  2977. bool isDecimal = false;
  2978. foreach (char c in value)
  2979. if (c == '.')
  2980. {
  2981. isDecimal = true;
  2982. break;
  2983. }
  2984.  
  2985. if(isDecimal)
  2986. {
  2987. if(mutiplyTousend == "1")
  2988. {
  2989. Item properties = inn.getItemByKeyedName("Property", information);
  2990.  
  2991. string scaleStr = properties.getProperty("scale", "");
  2992. int scale = int.Parse(scaleStr);
  2993. int tousendMultiple = 1;
  2994. for(int k = 0; k < scale; k++)
  2995. tousendMultiple *= 10;
  2996. decimal decimalValue = decimal.Parse(value);
  2997. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  2998. value = currValue.ToString();
  2999. }
  3000. }
  3001. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  3002. value = value.ToString();
  3003. if(possitionsForZeros < int.Parse(length))
  3004. {
  3005. string zeros = "";
  3006. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  3007.  
  3008. value = zeros + value;
  3009. }
  3010. }
  3011. }
  3012.  
  3013. for(int s = 0; s < int.Parse(length); s++)
  3014. {
  3015. if(defaultValue == "") defaultValue = " ";
  3016. if(value == "") value = defaultValue;
  3017. if(value == null || s >= value.Length)
  3018. {
  3019. wantedProperty += " ";
  3020. continue;
  3021. }
  3022. wantedProperty += value[s];
  3023. }
  3024. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3025. {
  3026. System.Diagnostics.Debugger.Break();
  3027. id.Close();
  3028. me.Close();
  3029.  
  3030. return inn.newError("Please Look at the table");
  3031. }
  3032. break;
  3033. }
  3034. }
  3035.  
  3036. else if(itemType == "Frame")
  3037. {
  3038. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  3039. Item pim = null;
  3040. Item frame = null;
  3041. if(pimId != "")
  3042. {
  3043. pim = inn.getItemById("MRN_Item", pimId);
  3044.  
  3045. string frameId = pim.getProperty("mrn_frame", "");
  3046.  
  3047. if(frameId != "")
  3048. frame = inn.getItemById("MRN_Item", frameId);
  3049. }
  3050.  
  3051. switch(infoType)
  3052. {
  3053. case "Property":
  3054. if(frame != null)
  3055. value = frame.getProperty(information, "");
  3056. else value = "";
  3057.  
  3058. nextItem = 0;
  3059.  
  3060. if(value ==null)
  3061. {
  3062. nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  3063. }
  3064.  
  3065. if(nextItem >= 2 && priority == "Preminary") break;
  3066.  
  3067. valueCopy = value;
  3068.  
  3069. if(priority == "Preminary") {
  3070. if(value != "")
  3071. {
  3072. flag = true;
  3073. priorityString = value;
  3074. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  3075.  
  3076. //if(nextItem >= 2 && priority == "Preminary") break;
  3077. }
  3078. else
  3079. {
  3080. flag = true;
  3081. continue;
  3082.  
  3083. }
  3084. }
  3085. else if(priority == "Alternative"){
  3086. if(flag == false)
  3087. {
  3088. if(priorityString != "")
  3089. {
  3090. flag = false;
  3091. priorityString = "";
  3092. break;
  3093. }
  3094. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  3095. id.Close();
  3096. me.Close();
  3097. continue;
  3098. }
  3099.  
  3100. if(priorityString != "")
  3101. {
  3102. flag = false;
  3103. priorityString = "";
  3104. if (itemItm.Equals(last))
  3105. {
  3106.  
  3107. id.Write(wantedProperty);
  3108. id.Write("*");
  3109. id.WriteLine();
  3110. continue;
  3111. }
  3112. continue;
  3113. }
  3114. }
  3115. //MultiplyTousend
  3116. if(mutiplyTousend == "1") {
  3117. if(valueCopy != "")
  3118. {
  3119. decimal decimalValue = decimal.Parse(value);
  3120. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  3121. }
  3122. }
  3123. //RemoveSeparator
  3124. if(removeSeparator == "1"){
  3125. if(valueCopy != "")
  3126. {
  3127. Item properties = inn.getItemByKeyedName("Property", information);
  3128.  
  3129. bool isDecimal = false;
  3130. foreach (char c in value)
  3131. if (c == '.')
  3132. {
  3133. isDecimal = true;
  3134. break;
  3135. }
  3136.  
  3137. if(isDecimal)
  3138. {
  3139. string scaleStr = properties.getProperty("scale", "");
  3140. int scale = int.Parse(scaleStr);
  3141. int tousendMultiple = 1;
  3142. for(int k = 0; k < scale; k++)
  3143. tousendMultiple *= 10;
  3144. decimal decimalValue = decimal.Parse(value);
  3145. decimalValue *= tousendMultiple;
  3146. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  3147. value.ToString();
  3148. value = resultValue;
  3149. }
  3150. }
  3151. }
  3152. //Leading Zero
  3153. if(leadingZero == "1") {
  3154. if(valueCopy != "")
  3155. {
  3156.  
  3157. bool isDecimal = false;
  3158. foreach (char c in value)
  3159. if (c == '.')
  3160. {
  3161. isDecimal = true;
  3162. break;
  3163. }
  3164.  
  3165. if(isDecimal)
  3166. {
  3167. if(mutiplyTousend == "1")
  3168. {
  3169. Item properties = inn.getItemByKeyedName("Property", information);
  3170.  
  3171. string scaleStr = properties.getProperty("scale", "");
  3172. int scale = int.Parse(scaleStr);
  3173. int tousendMultiple = 1;
  3174. for(int k = 0; k < scale; k++)
  3175. tousendMultiple *= 10;
  3176. decimal decimalValue = decimal.Parse(value);
  3177. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  3178. value = currValue.ToString();
  3179. }
  3180. }
  3181. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  3182. value = value.ToString();
  3183. if(possitionsForZeros < int.Parse(length))
  3184. {
  3185. string zeros = "";
  3186. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  3187.  
  3188. value = zeros + value;
  3189. }
  3190. }
  3191. }
  3192.  
  3193. for(int s = 0; s < int.Parse(length); s++)
  3194. {
  3195. if(defaultValue == "") defaultValue = " ";
  3196. if(value == "") value = defaultValue;
  3197. if(value == null || s >= value.Length)
  3198. {
  3199. wantedProperty += " ";
  3200. continue;
  3201. }
  3202. wantedProperty += value[s];
  3203. }
  3204. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3205. {
  3206. System.Diagnostics.Debugger.Break();
  3207. id.Close();
  3208. me.Close();
  3209.  
  3210. return inn.newError("Please Look at the table");
  3211. }
  3212. break;
  3213. }
  3214. }
  3215.  
  3216.  
  3217. if (itemItm.Equals(last))
  3218. {
  3219.  
  3220. id.Write(wantedProperty);
  3221. id.Write("*");
  3222. id.WriteLine();
  3223. }
  3224. }
  3225.  
  3226. wantedProperty = "";
  3227. foreach(Item itemItM in MEASURE_LISTReal)
  3228. {
  3229. itemType = itemItM.getProperty("mrn_plm_item_type");
  3230. infoType = itemItM.getProperty("mrn_plm_info_type");
  3231. information = itemItM.getProperty("mrn_plm_information");
  3232. defaultValue = itemItM.getProperty("mrn_plm_defaut_value");
  3233. itemInformation = itemItM.getProperty("mrn_plm_item_information");
  3234. startPosition = itemItM.getProperty("mrn_plm_start_position");
  3235. length = itemItM.getProperty("mrn_plm_length");
  3236. usage = itemItM.getProperty("mrn_plm_usage_doc", "");
  3237. priority = itemItM.getProperty("mrn_plm_priority", "");
  3238. leadingZero = itemItM.getProperty("mrn_plm_leading0", "");
  3239. mutiplyTousend = itemItM.getProperty("mrn_plm_multiply1000", "");
  3240. removeSeparator = itemItM.getProperty("mrn_plm_remove_separator", "");
  3241. string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
  3242. string productLabItemId = finishedGood.getProperty("mrn_plm_product_label_item", "");
  3243. string value = null;
  3244. string valueCopy;
  3245.  
  3246. var nextItem = 0;
  3247.  
  3248. 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"))
  3249. {
  3250. if(infoType == "DateTime-YYMMDDhhmm")
  3251. {
  3252. DateTime dt = DateTime.Now;;
  3253. if (information == "Today") {dt = DateTime.Now;}
  3254. if (information == "Yesterday") {dt = dt.AddDays(-1);}
  3255. if (information == "Tomorrow") {dt = dt.AddDays(1);}
  3256. value = dt.ToString("yyMMddHHmm");
  3257. for(int f = 0; f < int.Parse(length); f++)
  3258. {
  3259. if(defaultValue == "") defaultValue = " ";
  3260. if(value == "") value = defaultValue;
  3261. if(value == null || f >= value.Length)
  3262. {
  3263. wantedProperty += " ";
  3264. continue;
  3265. }
  3266. wantedProperty += value[f];
  3267. }
  3268. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3269. {
  3270. System.Diagnostics.Debugger.Break();
  3271. id.Close();
  3272. me.Close();
  3273.  
  3274. return inn.newError("Please Look at the table");
  3275. }
  3276. }
  3277. else if(infoType == "Date-MM/DD/YYYY")
  3278. {
  3279. DateTime dte = DateTime.Now;
  3280. if (information == "Today") {dte = DateTime.Now;}
  3281. if (information == "Yesterday") {dte = dte.AddDays(-1);}
  3282. if (information == "Tomorrow") {dte = dte.AddDays(1);}
  3283. value = dte.ToString(@"MM\/dd\/yyyy");
  3284. for(int f = 0; f < int.Parse(length); f++)
  3285. {
  3286. if(defaultValue == "") defaultValue = " ";
  3287. if(value == "") value = defaultValue;
  3288. if(value == null || f >= value.Length)
  3289. {
  3290. wantedProperty += " ";
  3291. continue;
  3292. }
  3293. wantedProperty += value[f];
  3294. }
  3295. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3296. {
  3297. System.Diagnostics.Debugger.Break();
  3298. id.Close();
  3299. me.Close();
  3300.  
  3301. return inn.newError("Please Look at the table");
  3302. }
  3303. }
  3304. }
  3305.  
  3306. else if(itemType == "Item")
  3307. {
  3308. int d = wantedProperty.Length;
  3309. switch(infoType)
  3310. {
  3311. case "Property":
  3312. if(information != "")
  3313. value = finishedGood.getProperty(information, "");
  3314. else value = defaultValue;
  3315.  
  3316. nextItem = 0;
  3317.  
  3318. if(value ==null)
  3319. {
  3320. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  3321. }
  3322.  
  3323. if(nextItem >= 2 && priority == "Preminary") break;
  3324.  
  3325. valueCopy = value;
  3326.  
  3327. if(priority == "Preminary") {
  3328. if(value != "")
  3329. {
  3330. flag = true;
  3331. priorityString = value;
  3332. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  3333.  
  3334. //if(nextItem >= 2 && priority == "Preminary") break;
  3335. }
  3336. else
  3337. {
  3338. flag = true;
  3339. continue;
  3340.  
  3341. }
  3342. }
  3343. else if(priority == "Alternative"){
  3344. if(flag == false)
  3345. {
  3346. if(priorityString != "")
  3347. {
  3348. flag = false;
  3349. priorityString = "";
  3350. break;
  3351. }
  3352. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  3353. id.Close();
  3354. me.Close();
  3355. continue;
  3356. }
  3357.  
  3358. if(priorityString != "")
  3359. {
  3360. flag = false;
  3361. priorityString = "";
  3362. continue;
  3363. }
  3364. }
  3365.  
  3366. //MultiplyTousend
  3367. if(mutiplyTousend == "1") {
  3368. if(valueCopy != "")
  3369. {
  3370. decimal decimalValue = decimal.Parse(value);
  3371. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  3372. }
  3373. }
  3374. //RemoveSeparator
  3375. if(removeSeparator == "1"){
  3376. if(valueCopy != "")
  3377. {
  3378. Item properties = inn.getItemByKeyedName("Property", information);
  3379.  
  3380. bool isDecimal = false;
  3381. foreach (char c in value)
  3382. if (c == '.')
  3383. {
  3384. isDecimal = true;
  3385. break;
  3386. }
  3387.  
  3388. if(isDecimal)
  3389. {
  3390. string scaleStr = properties.getProperty("scale", "");
  3391. int scale = int.Parse(scaleStr);
  3392. int tousendMultiple = 1;
  3393. for(int k = 0; k < scale; k++)
  3394. tousendMultiple *= 10;
  3395. decimal decimalValue = decimal.Parse(value);
  3396. decimalValue *= tousendMultiple;
  3397. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  3398. value.ToString();
  3399. value = resultValue;
  3400. }
  3401. }
  3402. }
  3403. //Leading Zero
  3404. if(leadingZero == "1") {
  3405. if(valueCopy != "")
  3406. {
  3407.  
  3408. bool isDecimal = false;
  3409. foreach (char c in value)
  3410. if (c == '.')
  3411. {
  3412. isDecimal = true;
  3413. break;
  3414. }
  3415.  
  3416. if(isDecimal)
  3417. {
  3418. if(mutiplyTousend == "1")
  3419. {
  3420. Item properties = inn.getItemByKeyedName("Property", information);
  3421.  
  3422. string scaleStr = properties.getProperty("scale", "");
  3423. int scale = int.Parse(scaleStr);
  3424. int tousendMultiple = 1;
  3425. for(int k = 0; k < scale; k++)
  3426. tousendMultiple *= 10;
  3427. decimal decimalValue = decimal.Parse(value);
  3428. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  3429. value = currValue.ToString();
  3430. }
  3431. }
  3432. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  3433. value = value.ToString();
  3434. if(possitionsForZeros < int.Parse(length))
  3435. {
  3436. string zeros = "";
  3437. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  3438.  
  3439. value = zeros + value;
  3440. }
  3441. }
  3442. }
  3443.  
  3444. for(int s = 0; s < int.Parse(length); s++)
  3445. {
  3446. if(defaultValue == "") defaultValue = " ";
  3447. if(value == "") value = defaultValue;
  3448. if(value == null || s >= value.Length)
  3449. {
  3450. wantedProperty += " ";
  3451. continue;
  3452. }
  3453. wantedProperty += value[s];
  3454. }
  3455.  
  3456. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3457. {
  3458. System.Diagnostics.Debugger.Break();
  3459. id.Close();
  3460. me.Close();
  3461.  
  3462. return inn.newError("Please Look at the table");
  3463. }
  3464. break;
  3465. case "ItemPropertyItem ":
  3466. Item thisItem = null;
  3467. if(information != "")
  3468. {
  3469. string myItemId = finishedGood.getProperty(information, "");
  3470. if(myItemId != "")
  3471. {
  3472. try
  3473. {
  3474. if(information == "mrn_plm_pim_product")
  3475. {
  3476. thisItem = inn.getItemById("MRN_Item", myItemId);
  3477. }
  3478. else if(information == "mrn_plm_label_item" || information == "mrn_plm_product_label_item")
  3479. {
  3480. thisItem = inn.newItem("mrn_plm_labeling_item", myItemId);
  3481. }
  3482. else thisItem = inn.newItem("Part", myItemId);
  3483. //thisItem = inn.getItemById(information, myItemId);
  3484. }
  3485. catch(Exception) {inn.newError("The is no Item type with this name!");}
  3486. value = thisItem.getProperty(itemInformation , "");
  3487. }
  3488. else value = "";
  3489.  
  3490. nextItem = 0;
  3491.  
  3492. if(value ==null)
  3493. {
  3494. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  3495. }
  3496.  
  3497. //if(nextItem >= 2 && priority == "Preminary") break;
  3498.  
  3499. valueCopy = value;
  3500.  
  3501. if(priority == "Preminary") {
  3502. if(value != "")
  3503. {
  3504. flag = true;
  3505. priorityString = value;
  3506. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  3507.  
  3508. //if(nextItem >= 2 && priority == "Preminary") break;
  3509. }
  3510. else
  3511. {
  3512. flag = true;
  3513. continue;
  3514.  
  3515. }
  3516. }
  3517. else if(priority == "Alternative"){
  3518. if(flag == false)
  3519. {
  3520. if(priorityString != "")
  3521. {
  3522. flag = false;
  3523. priorityString = "";
  3524. break;
  3525. }
  3526. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  3527. id.Close();
  3528. me.Close();
  3529. continue;
  3530. }
  3531.  
  3532. if(priorityString != "")
  3533. {
  3534. flag = false;
  3535. priorityString = "";
  3536. continue;
  3537. }
  3538. }
  3539.  
  3540. //MultiplyTousend
  3541. if(mutiplyTousend == "1") {
  3542. if(valueCopy != "")
  3543. {
  3544. decimal decimalValue = decimal.Parse(value);
  3545. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  3546. }
  3547. }
  3548. //RemoveSeparator
  3549. if(removeSeparator == "1"){
  3550. if(valueCopy != "")
  3551. {
  3552. Item properties = inn.getItemByKeyedName("Property", information);
  3553.  
  3554. bool isDecimal = false;
  3555. foreach (char c in value)
  3556. if (c == '.')
  3557. {
  3558. isDecimal = true;
  3559. break;
  3560. }
  3561.  
  3562. if(isDecimal)
  3563. {
  3564. string scaleStr = properties.getProperty("scale", "");
  3565. int scale = int.Parse(scaleStr);
  3566. int tousendMultiple = 1;
  3567. for(int k = 0; k < scale; k++)
  3568. tousendMultiple *= 10;
  3569. decimal decimalValue = decimal.Parse(value);
  3570. decimalValue *= tousendMultiple;
  3571. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  3572. value.ToString();
  3573. value = resultValue;
  3574. }
  3575. }
  3576. }
  3577. //Leading Zero
  3578. if(leadingZero == "1") {
  3579. if(valueCopy != "")
  3580. {
  3581.  
  3582. bool isDecimal = false;
  3583. foreach (char c in value)
  3584. if (c == '.')
  3585. {
  3586. isDecimal = true;
  3587. break;
  3588. }
  3589.  
  3590. if(isDecimal)
  3591. {
  3592. if(mutiplyTousend == "1")
  3593. {
  3594. Item properties = inn.getItemByKeyedName("Property", information);
  3595.  
  3596. string scaleStr = properties.getProperty("scale", "");
  3597. int scale = int.Parse(scaleStr);
  3598. int tousendMultiple = 1;
  3599. for(int k = 0; k < scale; k++)
  3600. tousendMultiple *= 10;
  3601. decimal decimalValue = decimal.Parse(value);
  3602. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  3603. value = currValue.ToString();
  3604. }
  3605. }
  3606. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  3607. value = value.ToString();
  3608. if(possitionsForZeros < int.Parse(length))
  3609. {
  3610. string zeros = "";
  3611. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  3612.  
  3613. value = zeros + value;
  3614. }
  3615. }
  3616. }
  3617.  
  3618. for(int s = 0; s < int.Parse(length); s++)
  3619. {
  3620. if(defaultValue == "") defaultValue = " ";
  3621. if(value == "") value = defaultValue;
  3622. if(value == null || s >= value.Length)
  3623. {
  3624. wantedProperty += " ";
  3625. continue;
  3626. }
  3627. wantedProperty += value[s];
  3628. }
  3629. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3630. {
  3631. System.Diagnostics.Debugger.Break();
  3632. id.Close();
  3633. me.Close();
  3634.  
  3635. return inn.newError("Please Look at the table");
  3636. }
  3637. }
  3638. else
  3639. {
  3640. value = "";
  3641. for(int s = 0; s < int.Parse(length); s++)
  3642. {
  3643. if(defaultValue == "") defaultValue = " ";
  3644. if(value == "") value = defaultValue;
  3645. if(value == null || s >= value.Length)
  3646. {
  3647. wantedProperty += " ";
  3648. continue;
  3649. }
  3650. wantedProperty += value[s];
  3651. }
  3652. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3653. {
  3654. System.Diagnostics.Debugger.Break();
  3655. id.Close();
  3656. me.Close();
  3657.  
  3658. return inn.newError("Please Look at the table");
  3659. }
  3660. }
  3661. break;
  3662. }
  3663. }
  3664.  
  3665. else if(itemType == "Generic Label Item")
  3666. {
  3667. switch(infoType)
  3668. {
  3669. case "Property":
  3670. if(information == "" || labItemId == "")
  3671. {
  3672. value = defaultValue;
  3673. }
  3674. else if(labItemId != "")
  3675. {
  3676. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  3677. Item doc = ourLabItem.getRelatedItem();
  3678.  
  3679. value = ourLabItem.getProperty(information);
  3680. }
  3681.  
  3682. nextItem = 0;
  3683.  
  3684. if(value ==null)
  3685. {
  3686. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  3687. }
  3688.  
  3689. if(nextItem >= 2 && priority == "Preminary") break;
  3690.  
  3691. valueCopy = value;
  3692.  
  3693. if(priority == "Preminary") {
  3694. if(value != "")
  3695. {
  3696. flag = true;
  3697. priorityString = value;
  3698. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  3699.  
  3700. //if(nextItem >= 2 && priority == "Preminary") break;
  3701. }
  3702. else
  3703. {
  3704. flag = true;
  3705. continue;
  3706.  
  3707. }
  3708. }
  3709. else if(priority == "Alternative"){
  3710. if(flag == false)
  3711. {
  3712. if(priorityString != "")
  3713. {
  3714. flag = false;
  3715. priorityString = "";
  3716. break;
  3717. }
  3718. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  3719. id.Close();
  3720. me.Close();
  3721. continue;
  3722. }
  3723.  
  3724. if(priorityString != "")
  3725. {
  3726. flag = false;
  3727. priorityString = "";
  3728. continue;
  3729. }
  3730. }
  3731.  
  3732. //MultiplyTousend
  3733. if(mutiplyTousend == "1") {
  3734. if(valueCopy != "")
  3735. {
  3736. decimal decimalValue = decimal.Parse(value);
  3737. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  3738. }
  3739. }
  3740. //RemoveSeparator
  3741. if(removeSeparator == "1"){
  3742. if(valueCopy != "")
  3743. {
  3744. Item properties = inn.getItemByKeyedName("Property", information);
  3745.  
  3746. bool isDecimal = false;
  3747. foreach (char c in value)
  3748. if (c == '.')
  3749. {
  3750. isDecimal = true;
  3751. break;
  3752. }
  3753.  
  3754. if(isDecimal)
  3755. {
  3756. string scaleStr = properties.getProperty("scale", "");
  3757. int scale = int.Parse(scaleStr);
  3758. int tousendMultiple = 1;
  3759. for(int k = 0; k < scale; k++)
  3760. tousendMultiple *= 10;
  3761. decimal decimalValue = decimal.Parse(value);
  3762. decimalValue *= tousendMultiple;
  3763. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  3764. value.ToString();
  3765. value = resultValue;
  3766. }
  3767. }
  3768. }
  3769. //Leading Zero
  3770. if(leadingZero == "1") {
  3771. if(valueCopy != "")
  3772. {
  3773.  
  3774. bool isDecimal = false;
  3775. foreach (char c in value)
  3776. if (c == '.')
  3777. {
  3778. isDecimal = true;
  3779. break;
  3780. }
  3781.  
  3782. if(isDecimal)
  3783. {
  3784. if(mutiplyTousend == "1")
  3785. {
  3786. Item properties = inn.getItemByKeyedName("Property", information);
  3787.  
  3788. string scaleStr = properties.getProperty("scale", "");
  3789. int scale = int.Parse(scaleStr);
  3790. int tousendMultiple = 1;
  3791. for(int k = 0; k < scale; k++)
  3792. tousendMultiple *= 10;
  3793. decimal decimalValue = decimal.Parse(value);
  3794. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  3795. value = currValue.ToString();
  3796. }
  3797. }
  3798. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  3799. value = value.ToString();
  3800. if(possitionsForZeros < int.Parse(length))
  3801. {
  3802. string zeros = "";
  3803. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  3804.  
  3805. value = zeros + value;
  3806. }
  3807. }
  3808. }
  3809.  
  3810. for(int s = 0; s < int.Parse(length); s++)
  3811. {
  3812. if(defaultValue == "") defaultValue = " ";
  3813. if(value == "") value = defaultValue;
  3814. if(value == null || s >= value.Length)
  3815. {
  3816. wantedProperty += " ";
  3817. continue;
  3818. }
  3819. wantedProperty += value[s];
  3820. }
  3821. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3822. {
  3823. System.Diagnostics.Debugger.Break();
  3824. id.Close();
  3825. me.Close();
  3826.  
  3827. return inn.newError("Please Look at the table");
  3828. }
  3829. break;
  3830. case "RelatedProperty":
  3831. if(labItemId != "")
  3832. {
  3833. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  3834.  
  3835. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  3836. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  3837. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  3838. int getRelsCount = getRels.getItemCount();
  3839. for(int sk = 0; sk < getRelsCount; sk++)
  3840. {
  3841. Item currentProperty = getRels.getItemByIndex(sk);
  3842. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  3843. if(information == currProperty)
  3844. {
  3845. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  3846. {
  3847. value = currentProperty.getProperty("mrn_plm_label_value");
  3848. break;
  3849. }
  3850. }
  3851. else continue;
  3852. }
  3853. if(value == null) value = "";
  3854. }
  3855. else value = "";
  3856.  
  3857. nextItem = 0;
  3858.  
  3859. if(value ==null)
  3860. {
  3861. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  3862. }
  3863.  
  3864. if(nextItem >= 2 && priority == "Preminary") break;
  3865.  
  3866. valueCopy = value;
  3867.  
  3868. if(priority == "Preminary") {
  3869. if(value != "")
  3870. {
  3871. flag = true;
  3872. priorityString = value;
  3873. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  3874.  
  3875. //if(nextItem >= 2 && priority == "Preminary") break;
  3876. }
  3877. else
  3878. {
  3879. flag = true;
  3880. continue;
  3881.  
  3882. }
  3883. }
  3884. else if(priority == "Alternative"){
  3885. if(flag == false)
  3886. {
  3887. if(priorityString != "")
  3888. {
  3889. flag = false;
  3890. priorityString = "";
  3891. break;
  3892. }
  3893. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  3894. id.Close();
  3895. me.Close();
  3896. continue;
  3897. }
  3898.  
  3899. if(priorityString != "")
  3900. {
  3901. flag = false;
  3902. priorityString = "";
  3903. continue;
  3904. }
  3905. }
  3906.  
  3907. //MultiplyTousend
  3908. if(mutiplyTousend == "1") {
  3909. if(valueCopy != "")
  3910. {
  3911. decimal decimalValue = decimal.Parse(value);
  3912. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  3913. }
  3914. }
  3915. //RemoveSeparator
  3916. if(removeSeparator == "1"){
  3917. if(valueCopy != "")
  3918. {
  3919. Item properties = inn.getItemByKeyedName("Property", information);
  3920.  
  3921. bool isDecimal = false;
  3922. foreach (char c in value)
  3923. if (c == '.')
  3924. {
  3925. isDecimal = true;
  3926. break;
  3927. }
  3928.  
  3929. if(isDecimal)
  3930. {
  3931. string scaleStr = properties.getProperty("scale", "");
  3932. int scale = int.Parse(scaleStr);
  3933. int tousendMultiple = 1;
  3934. for(int k = 0; k < scale; k++)
  3935. tousendMultiple *= 10;
  3936. decimal decimalValue = decimal.Parse(value);
  3937. decimalValue *= tousendMultiple;
  3938. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  3939. value.ToString();
  3940. value = resultValue;
  3941. }
  3942. }
  3943. }
  3944. //Leading Zero
  3945. if(leadingZero == "1") {
  3946. if(valueCopy != "")
  3947. {
  3948.  
  3949. bool isDecimal = false;
  3950. foreach (char c in value)
  3951. if (c == '.')
  3952. {
  3953. isDecimal = true;
  3954. break;
  3955. }
  3956.  
  3957. if(isDecimal)
  3958. {
  3959. if(mutiplyTousend == "1")
  3960. {
  3961. Item properties = inn.getItemByKeyedName("Property", information);
  3962.  
  3963. string scaleStr = properties.getProperty("scale", "");
  3964. int scale = int.Parse(scaleStr);
  3965. int tousendMultiple = 1;
  3966. for(int k = 0; k < scale; k++)
  3967. tousendMultiple *= 10;
  3968. decimal decimalValue = decimal.Parse(value);
  3969. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  3970. value = currValue.ToString();
  3971. }
  3972. }
  3973. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  3974. value = value.ToString();
  3975. if(possitionsForZeros < int.Parse(length))
  3976. {
  3977. string zeros = "";
  3978. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  3979.  
  3980. value = zeros + value;
  3981. }
  3982. }
  3983. }
  3984.  
  3985. for(int s = 0; s < int.Parse(length); s++)
  3986. {
  3987. if(defaultValue == "") defaultValue = " ";
  3988. if(value == "") value = defaultValue;
  3989. if(value == null || s >= value.Length)
  3990. {
  3991. wantedProperty += " ";
  3992. continue;
  3993. }
  3994. wantedProperty += value[s];
  3995. }
  3996. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  3997. {
  3998. System.Diagnostics.Debugger.Break();
  3999. id.Close();
  4000. me.Close();
  4001.  
  4002. return inn.newError("Please Look at the table");
  4003. }
  4004.  
  4005. break;
  4006. case "ItemPropertyItem":
  4007.  
  4008. Item myStockPart = null;
  4009. string myStockPartId = null;
  4010. string cItem = finishedGood.getProperty("mrn_plm_label_item", "");
  4011. Item ssd = null;
  4012. if(cItem != "")
  4013. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  4014.  
  4015. if(ssd != null && information != "")
  4016. myStockPartId = ssd.getProperty(information, "");
  4017.  
  4018. if(myStockPartId != "")
  4019. {
  4020. myStockPart = inn.getItemById("Part", myStockPartId);
  4021. value = myStockPart.getProperty(itemInformation, "");
  4022. }
  4023.  
  4024. else value = "";
  4025.  
  4026. nextItem = 0;
  4027.  
  4028. if(value ==null)
  4029. {
  4030. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  4031. }
  4032.  
  4033. valueCopy = value;
  4034.  
  4035. if(priority == "Preminary") {
  4036. if(value != "")
  4037. {
  4038. flag = true;
  4039. priorityString = value;
  4040. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  4041.  
  4042. //if(nextItem >= 2 && priority == "Preminary") break;
  4043. }
  4044. else
  4045. {
  4046. flag = true;
  4047. continue;
  4048.  
  4049. }
  4050. }
  4051. else if(priority == "Alternative"){
  4052. if(flag == false)
  4053. {
  4054. if(priorityString != "")
  4055. {
  4056. flag = false;
  4057. priorityString = "";
  4058. break;
  4059. }
  4060. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  4061. id.Close();
  4062. me.Close();
  4063. continue;
  4064. }
  4065.  
  4066. if(priorityString != "")
  4067. {
  4068. flag = false;
  4069. priorityString = "";
  4070. continue;
  4071. }
  4072. }
  4073.  
  4074. //MultiplyTousend
  4075. if(mutiplyTousend == "1") {
  4076. if(valueCopy != "")
  4077. {
  4078. decimal decimalValue = decimal.Parse(value);
  4079. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  4080. }
  4081. }
  4082. //RemoveSeparator
  4083. if(removeSeparator == "1"){
  4084. if(valueCopy != "")
  4085. {
  4086. Item properties = inn.getItemByKeyedName("Property", information);
  4087.  
  4088. bool isDecimal = false;
  4089. foreach (char c in value)
  4090. if (c == '.')
  4091. {
  4092. isDecimal = true;
  4093. break;
  4094. }
  4095.  
  4096. if(isDecimal)
  4097. {
  4098. string scaleStr = properties.getProperty("scale", "");
  4099. int scale = int.Parse(scaleStr);
  4100. int tousendMultiple = 1;
  4101. for(int k = 0; k < scale; k++)
  4102. tousendMultiple *= 10;
  4103. decimal decimalValue = decimal.Parse(value);
  4104. decimalValue *= tousendMultiple;
  4105. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  4106. value.ToString();
  4107. value = resultValue;
  4108. }
  4109. }
  4110. }
  4111. //Leading Zero
  4112. if(leadingZero == "1") {
  4113. if(valueCopy != "")
  4114. {
  4115.  
  4116. bool isDecimal = false;
  4117. foreach (char c in value)
  4118. if (c == '.')
  4119. {
  4120. isDecimal = true;
  4121. break;
  4122. }
  4123.  
  4124. if(isDecimal)
  4125. {
  4126. if(mutiplyTousend == "1")
  4127. {
  4128. Item properties = inn.getItemByKeyedName("Property", information);
  4129.  
  4130. string scaleStr = properties.getProperty("scale", "");
  4131. int scale = int.Parse(scaleStr);
  4132. int tousendMultiple = 1;
  4133. for(int k = 0; k < scale; k++)
  4134. tousendMultiple *= 10;
  4135. decimal decimalValue = decimal.Parse(value);
  4136. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  4137. value = currValue.ToString();
  4138. }
  4139. }
  4140. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  4141. value = value.ToString();
  4142. if(possitionsForZeros < int.Parse(length))
  4143. {
  4144. string zeros = "";
  4145. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  4146.  
  4147. value = zeros + value;
  4148. }
  4149. }
  4150. }
  4151.  
  4152.  
  4153. for(int s = 0; s < int.Parse(length); s++)
  4154. {
  4155. if(defaultValue == "") defaultValue = " ";
  4156. if(value == "") value = defaultValue;
  4157. if(value == null || s >= value.Length)
  4158. {
  4159. wantedProperty += " ";
  4160. continue;
  4161. }
  4162. wantedProperty += value[s];
  4163. }
  4164. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  4165. {
  4166. System.Diagnostics.Debugger.Break();
  4167. id.Close();
  4168. me.Close();
  4169.  
  4170. return inn.newError("Please Look at the table");
  4171. }
  4172. break;
  4173. case "Document":
  4174.  
  4175. if(labItemId != "")
  4176. {
  4177. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
  4178.  
  4179. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  4180. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  4181.  
  4182. int docRelCount = docRelationships.getItemCount();
  4183.  
  4184. for(int f = 0; f < docRelCount; f++)
  4185. {
  4186. Item currDoc = docRelationships.getItemByIndex(f);
  4187. var docUsage = currDoc.getProperty("mrn_plm_usage");
  4188. Item doc = currDoc.getRelatedItem();
  4189. if(docUsage == usage)
  4190. {
  4191. value = doc.getProperty(information, "");
  4192. break;
  4193. }
  4194. }
  4195.  
  4196. nextItem = 0;
  4197.  
  4198. if(value ==null)
  4199. {
  4200. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  4201. }
  4202.  
  4203. if(nextItem >= 2 && priority == "Preminary") break;
  4204. //else value = "";
  4205.  
  4206. valueCopy = value;
  4207.  
  4208. if(priority == "Preminary") {
  4209. if(value != "")
  4210. {
  4211. flag = true;
  4212. priorityString = value;
  4213. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  4214.  
  4215. //if(nextItem >= 2 && priority == "Preminary") break;
  4216. }
  4217. else
  4218. {
  4219. flag = true;
  4220. continue;
  4221.  
  4222. }
  4223. }
  4224. else if(priority == "Alternative"){
  4225. if(flag == false)
  4226. {
  4227. if(priorityString != "")
  4228. {
  4229. flag = false;
  4230. priorityString = "";
  4231. break;
  4232. }
  4233. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  4234. id.Close();
  4235. me.Close();
  4236. continue;
  4237. }
  4238.  
  4239. if(priorityString != "")
  4240. {
  4241. flag = false;
  4242. priorityString = "";
  4243. continue;
  4244. }
  4245. }
  4246.  
  4247. //MultiplyTousend
  4248. if(mutiplyTousend == "1") {
  4249. if(valueCopy != "")
  4250. {
  4251. decimal decimalValue = decimal.Parse(value);
  4252. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  4253. }
  4254. }
  4255. //RemoveSeparator
  4256. if(removeSeparator == "1"){
  4257. if(valueCopy != "")
  4258. {
  4259. Item properties = inn.getItemByKeyedName("Property", information);
  4260.  
  4261. bool isDecimal = false;
  4262. foreach (char c in value)
  4263. if (c == '.')
  4264. {
  4265. isDecimal = true;
  4266. break;
  4267. }
  4268.  
  4269. if(isDecimal)
  4270. {
  4271. string scaleStr = properties.getProperty("scale", "");
  4272. int scale = int.Parse(scaleStr);
  4273. int tousendMultiple = 1;
  4274. for(int k = 0; k < scale; k++)
  4275. tousendMultiple *= 10;
  4276. decimal decimalValue = decimal.Parse(value);
  4277. decimalValue *= tousendMultiple;
  4278. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  4279. value.ToString();
  4280. value = resultValue;
  4281. }
  4282. }
  4283. }
  4284. //Leading Zero
  4285. if(leadingZero == "1") {
  4286. if(valueCopy != "")
  4287. {
  4288.  
  4289. bool isDecimal = false;
  4290. foreach (char c in value)
  4291. if (c == '.')
  4292. {
  4293. isDecimal = true;
  4294. break;
  4295. }
  4296.  
  4297. if(isDecimal)
  4298. {
  4299. if(mutiplyTousend == "1")
  4300. {
  4301. Item properties = inn.getItemByKeyedName("Property", information);
  4302.  
  4303. string scaleStr = properties.getProperty("scale", "");
  4304. int scale = int.Parse(scaleStr);
  4305. int tousendMultiple = 1;
  4306. for(int k = 0; k < scale; k++)
  4307. tousendMultiple *= 10;
  4308. decimal decimalValue = decimal.Parse(value);
  4309. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  4310. value = currValue.ToString();
  4311. }
  4312. }
  4313. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  4314. value = value.ToString();
  4315. if(possitionsForZeros < int.Parse(length))
  4316. {
  4317. string zeros = "";
  4318. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  4319.  
  4320. value = zeros + value;
  4321. }
  4322. }
  4323. }
  4324.  
  4325. for(int s = 0; s < int.Parse(length); s++)
  4326. {
  4327. if(defaultValue == "") defaultValue = " ";
  4328. if(value == "") value = defaultValue;
  4329. if(value == null || s >= value.Length)
  4330. {
  4331. wantedProperty += " ";
  4332. continue;
  4333. }
  4334. wantedProperty += value[s];
  4335. }
  4336. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  4337. {
  4338. System.Diagnostics.Debugger.Break();
  4339. id.Close();
  4340. me.Close();
  4341.  
  4342. return inn.newError("Please Look at the table");
  4343. }
  4344. }
  4345.  
  4346. else
  4347. {
  4348. value = "";
  4349. for(int s = 0; s < int.Parse(length); s++)
  4350. {
  4351. if(defaultValue == "") defaultValue = " ";
  4352. if(value == "") value = defaultValue;
  4353. if(value == null || s >= value.Length)
  4354. {
  4355. wantedProperty += " ";
  4356. continue;
  4357. }
  4358. wantedProperty += value[s];
  4359. }
  4360. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  4361. {
  4362. System.Diagnostics.Debugger.Break();
  4363. id.Close();
  4364. me.Close();
  4365.  
  4366. return inn.newError("Please Look at the table");
  4367. }
  4368. }
  4369.  
  4370. break;
  4371. }
  4372. }
  4373.  
  4374. else if(itemType == "Product Label Item")
  4375. {
  4376. switch(infoType)
  4377. {
  4378. case "Property":
  4379.  
  4380. if(productLabItemId != "")
  4381. {
  4382. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  4383. value = ourLabItem.getProperty(information, "");
  4384. }
  4385.  
  4386. else value = "";
  4387.  
  4388. nextItem = 0;
  4389.  
  4390. if(value ==null)
  4391. {
  4392. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  4393. }
  4394.  
  4395. if(nextItem >= 2 && priority == "Preminary") break;
  4396.  
  4397. valueCopy = value;
  4398.  
  4399. if(priority == "Preminary") {
  4400. if(value != "")
  4401. {
  4402. flag = true;
  4403. priorityString = value;
  4404. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  4405.  
  4406. //if(nextItem >= 2 && priority == "Preminary") break;
  4407. }
  4408. else
  4409. {
  4410. flag = true;
  4411. continue;
  4412.  
  4413. }
  4414. }
  4415. else if(priority == "Alternative"){
  4416. if(flag == false)
  4417. {
  4418. if(priorityString != "")
  4419. {
  4420. flag = false;
  4421. priorityString = "";
  4422. break;
  4423. }
  4424. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  4425. id.Close();
  4426. me.Close();
  4427. continue;
  4428. }
  4429.  
  4430. if(priorityString != "")
  4431. {
  4432. flag = false;
  4433. priorityString = "";
  4434. continue;
  4435. }
  4436. }
  4437.  
  4438. //MultiplyTousend
  4439. if(mutiplyTousend == "1") {
  4440. if(valueCopy != "")
  4441. {
  4442. decimal decimalValue = decimal.Parse(value);
  4443. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  4444. }
  4445. }
  4446. //RemoveSeparator
  4447. if(removeSeparator == "1"){
  4448. if(valueCopy != "")
  4449. {
  4450. Item properties = inn.getItemByKeyedName("Property", information);
  4451.  
  4452. bool isDecimal = false;
  4453. foreach (char c in value)
  4454. if (c == '.')
  4455. {
  4456. isDecimal = true;
  4457. break;
  4458. }
  4459.  
  4460. if(isDecimal)
  4461. {
  4462. string scaleStr = properties.getProperty("scale", "");
  4463. int scale = int.Parse(scaleStr);
  4464. int tousendMultiple = 1;
  4465. for(int k = 0; k < scale; k++)
  4466. tousendMultiple *= 10;
  4467. decimal decimalValue = decimal.Parse(value);
  4468. decimalValue *= tousendMultiple;
  4469. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  4470. value.ToString();
  4471. value = resultValue;
  4472. }
  4473. }
  4474. }
  4475. //Leading Zero
  4476. if(leadingZero == "1") {
  4477. if(valueCopy != "")
  4478. {
  4479.  
  4480. bool isDecimal = false;
  4481. foreach (char c in value)
  4482. if (c == '.')
  4483. {
  4484. isDecimal = true;
  4485. break;
  4486. }
  4487.  
  4488. if(isDecimal)
  4489. {
  4490. if(mutiplyTousend == "1")
  4491. {
  4492. Item properties = inn.getItemByKeyedName("Property", information);
  4493.  
  4494. string scaleStr = properties.getProperty("scale", "");
  4495. int scale = int.Parse(scaleStr);
  4496. int tousendMultiple = 1;
  4497. for(int k = 0; k < scale; k++)
  4498. tousendMultiple *= 10;
  4499. decimal decimalValue = decimal.Parse(value);
  4500. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  4501. value = currValue.ToString();
  4502. }
  4503. }
  4504. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  4505. value = value.ToString();
  4506. if(possitionsForZeros < int.Parse(length))
  4507. {
  4508. string zeros = "";
  4509. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  4510.  
  4511. value = zeros + value;
  4512. }
  4513. }
  4514. }
  4515.  
  4516. for(int s = 0; s < int.Parse(length); s++)
  4517. {
  4518. if(defaultValue == "") defaultValue = " ";
  4519. if(value == "") value = defaultValue;
  4520. if(value == null || s >= value.Length)
  4521. {
  4522. wantedProperty += " ";
  4523. continue;
  4524. }
  4525. wantedProperty += value[s];
  4526. }
  4527. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  4528. {
  4529. System.Diagnostics.Debugger.Break();
  4530. id.Close();
  4531. me.Close();
  4532.  
  4533. return inn.newError("Please Look at the table");
  4534. }
  4535. break;
  4536. case "RelatedProperty":
  4537.  
  4538. if(productLabItemId != "")
  4539. {
  4540. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  4541.  
  4542. ourLabItem.fetchRelationships("mrn_plm_label_item_property");
  4543. Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
  4544. //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
  4545. int getRelsCount = getRels.getItemCount();
  4546. for(int sk = 0; sk < getRelsCount; sk++)
  4547. {
  4548. Item currentProperty = getRels.getItemByIndex(sk);
  4549. string currProperty = currentProperty.getProperty("mrn_plm_label_name");
  4550. if(information == currProperty)
  4551. {
  4552. if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
  4553. {
  4554. value = currentProperty.getProperty("mrn_plm_label_value");
  4555. break;
  4556. }
  4557. }
  4558. }
  4559. }
  4560. else value = "";
  4561.  
  4562. nextItem = 0;
  4563.  
  4564. if(value ==null)
  4565. {
  4566. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  4567. }
  4568.  
  4569. if(nextItem >= 2 && priority == "Preminary") break;
  4570.  
  4571. valueCopy = value;
  4572.  
  4573. if(priority == "Preminary") {
  4574. if(value != "")
  4575. {
  4576. flag = true;
  4577. priorityString = value;
  4578. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  4579.  
  4580. //if(nextItem >= 2 && priority == "Preminary") break;
  4581. }
  4582. else
  4583. {
  4584. flag = true;
  4585. continue;
  4586.  
  4587. }
  4588. }
  4589. else if(priority == "Alternative"){
  4590. if(flag == false)
  4591. {
  4592. if(priorityString != "")
  4593. {
  4594. flag = false;
  4595. priorityString = "";
  4596. break;
  4597. }
  4598. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  4599. id.Close();
  4600. me.Close();
  4601. continue;
  4602. }
  4603.  
  4604. if(priorityString != "")
  4605. {
  4606. flag = false;
  4607. priorityString = "";
  4608. continue;
  4609. }
  4610. }
  4611.  
  4612. //MultiplyTousend
  4613. if(mutiplyTousend == "1") {
  4614. if(valueCopy != "")
  4615. {
  4616. decimal decimalValue = decimal.Parse(value);
  4617. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  4618. }
  4619. }
  4620. //RemoveSeparator
  4621. if(removeSeparator == "1"){
  4622. if(valueCopy != "")
  4623. {
  4624. Item properties = inn.getItemByKeyedName("Property", information);
  4625.  
  4626. bool isDecimal = false;
  4627. foreach (char c in value)
  4628. if (c == '.')
  4629. {
  4630. isDecimal = true;
  4631. break;
  4632. }
  4633.  
  4634. if(isDecimal)
  4635. {
  4636. string scaleStr = properties.getProperty("scale", "");
  4637. int scale = int.Parse(scaleStr);
  4638. int tousendMultiple = 1;
  4639. for(int k = 0; k < scale; k++)
  4640. tousendMultiple *= 10;
  4641. decimal decimalValue = decimal.Parse(value);
  4642. decimalValue *= tousendMultiple;
  4643. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  4644. value.ToString();
  4645. value = resultValue;
  4646. }
  4647. }
  4648. }
  4649. //Leading Zero
  4650. if(leadingZero == "1") {
  4651. if(valueCopy != "")
  4652. {
  4653.  
  4654. bool isDecimal = false;
  4655. foreach (char c in value)
  4656. if (c == '.')
  4657. {
  4658. isDecimal = true;
  4659. break;
  4660. }
  4661.  
  4662. if(isDecimal)
  4663. {
  4664. if(mutiplyTousend == "1")
  4665. {
  4666. Item properties = inn.getItemByKeyedName("Property", information);
  4667.  
  4668. string scaleStr = properties.getProperty("scale", "");
  4669. int scale = int.Parse(scaleStr);
  4670. int tousendMultiple = 1;
  4671. for(int k = 0; k < scale; k++)
  4672. tousendMultiple *= 10;
  4673. decimal decimalValue = decimal.Parse(value);
  4674. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  4675. value = currValue.ToString();
  4676. }
  4677. }
  4678. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  4679. value = value.ToString();
  4680. if(possitionsForZeros < int.Parse(length))
  4681. {
  4682. string zeros = "";
  4683. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  4684.  
  4685. value = zeros + value;
  4686. }
  4687. }
  4688. }
  4689.  
  4690. for(int s = 0; s < int.Parse(length); s++)
  4691. {
  4692. if(defaultValue == "") defaultValue = " ";
  4693. if(value == "") value = defaultValue;
  4694. if(value == null || s >= value.Length)
  4695. {
  4696. wantedProperty += " ";
  4697. continue;
  4698. }
  4699. wantedProperty += value[s];
  4700. }
  4701. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  4702. {
  4703. System.Diagnostics.Debugger.Break();
  4704. id.Close();
  4705. me.Close();
  4706.  
  4707. return inn.newError("Please Look at the table");
  4708. }
  4709.  
  4710. break;
  4711. case "ItemPropertyItem":
  4712. Item myStockPart = null;
  4713. string myStockPartId = null;
  4714. string cItem = finishedGood.getProperty("mrn_plm_product_label_item", "");
  4715. Item ssd = null;
  4716. if(cItem != "")
  4717. ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
  4718.  
  4719. if(ssd != null)
  4720. myStockPartId = ssd.getProperty(information);
  4721.  
  4722. if(myStockPartId != null)
  4723. {
  4724. myStockPart = inn.getItemById("Part", myStockPartId);
  4725. value = myStockPart.getProperty(itemInformation, "");
  4726. }
  4727.  
  4728. else value = "";
  4729.  
  4730. nextItem = 0;
  4731.  
  4732. if(value ==null)
  4733. {
  4734. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  4735. }
  4736.  
  4737. if(nextItem >= 2 && priority == "Preminary") break;
  4738.  
  4739. valueCopy = value;
  4740.  
  4741. if(priority == "Preminary") {
  4742. if(value != "")
  4743. {
  4744. flag = true;
  4745. priorityString = value;
  4746. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  4747.  
  4748. //if(nextItem >= 2 && priority == "Preminary") break;
  4749. }
  4750. else
  4751. {
  4752. flag = true;
  4753. continue;
  4754.  
  4755. }
  4756. }
  4757. else if(priority == "Alternative"){
  4758. if(flag == false)
  4759. {
  4760. if(priorityString != "")
  4761. {
  4762. flag = false;
  4763. priorityString = "";
  4764. break;
  4765. }
  4766. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  4767. id.Close();
  4768. me.Close();
  4769. continue;
  4770. }
  4771.  
  4772. if(priorityString != "")
  4773. {
  4774. flag = false;
  4775. priorityString = "";
  4776. continue;
  4777. }
  4778. }
  4779.  
  4780. //MultiplyTousend
  4781. if(mutiplyTousend == "1") {
  4782. if(valueCopy != "")
  4783. {
  4784. decimal decimalValue = decimal.Parse(value);
  4785. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  4786. }
  4787. }
  4788. //RemoveSeparator
  4789. if(removeSeparator == "1"){
  4790. if(valueCopy != "")
  4791. {
  4792. Item properties = inn.getItemByKeyedName("Property", information);
  4793.  
  4794. bool isDecimal = false;
  4795. foreach (char c in value)
  4796. if (c == '.')
  4797. {
  4798. isDecimal = true;
  4799. break;
  4800. }
  4801.  
  4802. if(isDecimal)
  4803. {
  4804. string scaleStr = properties.getProperty("scale", "");
  4805. int scale = int.Parse(scaleStr);
  4806. int tousendMultiple = 1;
  4807. for(int k = 0; k < scale; k++)
  4808. tousendMultiple *= 10;
  4809. decimal decimalValue = decimal.Parse(value);
  4810. decimalValue *= tousendMultiple;
  4811. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  4812. value.ToString();
  4813. value = resultValue;
  4814. }
  4815. }
  4816. }
  4817. //Leading Zero
  4818. if(leadingZero == "1") {
  4819. if(valueCopy != "")
  4820. {
  4821.  
  4822. bool isDecimal = false;
  4823. foreach (char c in value)
  4824. if (c == '.')
  4825. {
  4826. isDecimal = true;
  4827. break;
  4828. }
  4829.  
  4830. if(isDecimal)
  4831. {
  4832. if(mutiplyTousend == "1")
  4833. {
  4834. Item properties = inn.getItemByKeyedName("Property", information);
  4835.  
  4836. string scaleStr = properties.getProperty("scale", "");
  4837. int scale = int.Parse(scaleStr);
  4838. int tousendMultiple = 1;
  4839. for(int k = 0; k < scale; k++)
  4840. tousendMultiple *= 10;
  4841. decimal decimalValue = decimal.Parse(value);
  4842. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  4843. value = currValue.ToString();
  4844. }
  4845. }
  4846. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  4847. value = value.ToString();
  4848. if(possitionsForZeros < int.Parse(length))
  4849. {
  4850. string zeros = "";
  4851. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  4852.  
  4853. value = zeros + value;
  4854. }
  4855. }
  4856. }
  4857.  
  4858. for(int s = 0; s < int.Parse(length); s++)
  4859. {
  4860. if(defaultValue == "") defaultValue = " ";
  4861. if(value == "") value = defaultValue;
  4862. if(value == null || s >= value.Length)
  4863. {
  4864. wantedProperty += " ";
  4865. continue;
  4866. }
  4867. wantedProperty += value[s];
  4868. }
  4869. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  4870. {
  4871. System.Diagnostics.Debugger.Break();
  4872. id.Close();
  4873. me.Close();
  4874.  
  4875. return inn.newError("Please Look at the table");
  4876. }
  4877. break;
  4878. case "Document":
  4879. if(productLabItemId != "")
  4880. {
  4881. Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
  4882.  
  4883. ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
  4884. Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
  4885.  
  4886. int docRelCount = docRelationships.getItemCount();
  4887.  
  4888. for(int f = 0; f < docRelCount; f++)
  4889. {
  4890. Item currDoc = docRelationships.getItemByIndex(f);
  4891. Item doc = currDoc.getRelatedItem();
  4892. Item docOne = doc.getRelatedItem();
  4893. var docUsage = currDoc.getProperty("mrn_plm_usage");
  4894.  
  4895. if(docUsage == usage)
  4896. {
  4897. string ourID = currDoc.getProperty("related_id");
  4898. Item currentItem = inn.getItemById("Document" ,ourID);
  4899. if(currentItem != null)
  4900. value = currentItem.getProperty(information, "");
  4901. break;
  4902. }
  4903. }
  4904.  
  4905. nextItem = 0;
  4906.  
  4907. if(value ==null)
  4908. {
  4909. nextItem = IDENT6_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  4910. }
  4911.  
  4912. if(nextItem >= 2 && priority == "Preminary") break;
  4913. //else value = "";
  4914.  
  4915. valueCopy = value;
  4916.  
  4917. if(priority == "Preminary") {
  4918. if(value != "")
  4919. {
  4920. flag = true;
  4921. priorityString = value;
  4922. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  4923.  
  4924. //if(nextItem >= 2 && priority == "Preminary") break;
  4925. }
  4926. else
  4927. {
  4928. flag = true;
  4929. continue;
  4930.  
  4931. }
  4932. }
  4933. else if(priority == "Alternative"){
  4934. if(flag == false)
  4935. {
  4936. if(priorityString != "")
  4937. {
  4938. flag = false;
  4939. priorityString = "";
  4940. break;
  4941. }
  4942. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  4943. id.Close();
  4944. me.Close();
  4945. continue;
  4946. }
  4947.  
  4948. if(priorityString != "")
  4949. {
  4950. flag = false;
  4951. priorityString = "";
  4952. continue;
  4953. }
  4954. }
  4955.  
  4956. //MultiplyTousend
  4957. if(mutiplyTousend == "1") {
  4958. if(valueCopy != "")
  4959. {
  4960. decimal decimalValue = decimal.Parse(value);
  4961. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  4962. }
  4963. }
  4964. //RemoveSeparator
  4965. if(removeSeparator == "1"){
  4966. if(valueCopy != "")
  4967. {
  4968. Item properties = inn.getItemByKeyedName("Property", information);
  4969.  
  4970. bool isDecimal = false;
  4971. foreach (char c in value)
  4972. if (c == '.')
  4973. {
  4974. isDecimal = true;
  4975. break;
  4976. }
  4977.  
  4978. if(isDecimal)
  4979. {
  4980. string scaleStr = properties.getProperty("scale", "");
  4981. int scale = int.Parse(scaleStr);
  4982. int tousendMultiple = 1;
  4983. for(int k = 0; k < scale; k++)
  4984. tousendMultiple *= 10;
  4985. decimal decimalValue = decimal.Parse(value);
  4986. decimalValue *= tousendMultiple;
  4987. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  4988. value.ToString();
  4989. value = resultValue;
  4990. }
  4991. }
  4992. }
  4993. //Leading Zero
  4994. if(leadingZero == "1") {
  4995. if(valueCopy != "")
  4996. {
  4997.  
  4998. bool isDecimal = false;
  4999. foreach (char c in value)
  5000. if (c == '.')
  5001. {
  5002. isDecimal = true;
  5003. break;
  5004. }
  5005.  
  5006. if(isDecimal)
  5007. {
  5008. if(mutiplyTousend == "1")
  5009. {
  5010. Item properties = inn.getItemByKeyedName("Property", information);
  5011.  
  5012. string scaleStr = properties.getProperty("scale", "");
  5013. int scale = int.Parse(scaleStr);
  5014. int tousendMultiple = 1;
  5015. for(int k = 0; k < scale; k++)
  5016. tousendMultiple *= 10;
  5017. decimal decimalValue = decimal.Parse(value);
  5018. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  5019. value = currValue.ToString();
  5020. }
  5021. }
  5022. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  5023. value = value.ToString();
  5024. if(possitionsForZeros < int.Parse(length))
  5025. {
  5026. string zeros = "";
  5027. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  5028.  
  5029. value = zeros + value;
  5030. }
  5031. }
  5032. }
  5033.  
  5034. for(int s = 0; s < int.Parse(length); s++)
  5035. {
  5036. if(defaultValue == "") defaultValue = " ";
  5037. if(value == "") value = defaultValue;
  5038. if(value == null || s >= value.Length)
  5039. {
  5040. wantedProperty += " ";
  5041. continue;
  5042. }
  5043. wantedProperty += value[s];
  5044. }
  5045. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5046. {
  5047. System.Diagnostics.Debugger.Break();
  5048. id.Close();
  5049. me.Close();
  5050.  
  5051. return inn.newError("Please Look at the table");
  5052. }
  5053. }
  5054.  
  5055. else
  5056. {
  5057. value = " ";
  5058. for(int s = 0; s < int.Parse(length); s++)
  5059. {
  5060. if(defaultValue == "") defaultValue = " ";
  5061. if(value == "") value = defaultValue;
  5062. if(value == null || s >= value.Length)
  5063. {
  5064. wantedProperty += " ";
  5065. continue;
  5066. }
  5067. wantedProperty += value[s];
  5068. }
  5069. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5070. {
  5071. System.Diagnostics.Debugger.Break();
  5072. id.Close();
  5073. me.Close();
  5074.  
  5075. return inn.newError("Please Look at the table");
  5076. }
  5077. }
  5078.  
  5079. break;
  5080. }
  5081. }
  5082.  
  5083. else if(itemType == "Certification")
  5084. {
  5085.  
  5086. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  5087. //Item pim = null;
  5088. if(pimId != "")
  5089. {
  5090. switch(infoType)
  5091. {
  5092. case "Property":
  5093. Item relationshipsDocs = inn.newItem("MRN_Item_Document", "get");
  5094. relationshipsDocs.setAttribute ("where", "[MRN_Item_Document].source_id='" + pimId + "'");
  5095. relationshipsDocs = relationshipsDocs.apply();
  5096.  
  5097. int countRelationships = relationshipsDocs.getItemCount();
  5098.  
  5099. for(int f = 0; f < countRelationships; f++)
  5100. {
  5101. Item currDoc = relationshipsDocs.getItemByIndex(f);
  5102. var docUsage = currDoc.getProperty("mrn_plm_usage");
  5103. Item doc = currDoc.getRelatedItem();
  5104.  
  5105. if(docUsage == usage)
  5106. {
  5107. value = doc.getProperty(information, "");
  5108. break;
  5109. }
  5110. }
  5111.  
  5112. break;
  5113. }
  5114. }
  5115. else value = "";
  5116.  
  5117. nextItem = 0;
  5118.  
  5119. if(value ==null)
  5120. {
  5121. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  5122. }
  5123.  
  5124. if(nextItem >= 2 && priority == "Preminary") break;
  5125. //else value = "";
  5126.  
  5127. valueCopy = value;
  5128.  
  5129. if(priority == "Preminary") {
  5130. if(value != "")
  5131. {
  5132. flag = true;
  5133. priorityString = value;
  5134. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  5135.  
  5136. //if(nextItem >= 2 && priority == "Preminary") break;
  5137. }
  5138. else
  5139. {
  5140. flag = true;
  5141. continue;
  5142.  
  5143. }
  5144. }
  5145. else if(priority == "Alternative"){
  5146. if(flag == false)
  5147. {
  5148. if(priorityString != "")
  5149. {
  5150. flag = false;
  5151. priorityString = "";
  5152. break;
  5153. }
  5154. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  5155. id.Close();
  5156. me.Close();
  5157. continue;
  5158. }
  5159.  
  5160. if(priorityString != "")
  5161. {
  5162. flag = false;
  5163. priorityString = "";
  5164. continue;
  5165. }
  5166. }
  5167.  
  5168. //MultiplyTousend
  5169. if(mutiplyTousend == "1") {
  5170. if(valueCopy != "")
  5171. {
  5172. decimal decimalValue = decimal.Parse(value);
  5173. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  5174. }
  5175. }
  5176. //RemoveSeparator
  5177. if(removeSeparator == "1"){
  5178. if(valueCopy != "")
  5179. {
  5180. Item properties = inn.getItemByKeyedName("Property", information);
  5181.  
  5182. bool isDecimal = false;
  5183. foreach (char c in value)
  5184. if (c == '.')
  5185. {
  5186. isDecimal = true;
  5187. break;
  5188. }
  5189.  
  5190. if(isDecimal)
  5191. {
  5192. string scaleStr = properties.getProperty("scale", "");
  5193. int scale = int.Parse(scaleStr);
  5194. int tousendMultiple = 1;
  5195. for(int k = 0; k < scale; k++)
  5196. tousendMultiple *= 10;
  5197. decimal decimalValue = decimal.Parse(value);
  5198. decimalValue *= tousendMultiple;
  5199. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  5200. value.ToString();
  5201. value = resultValue;
  5202. }
  5203. }
  5204. }
  5205. //Leading Zero
  5206. if(leadingZero == "1") {
  5207. if(valueCopy != "")
  5208. {
  5209.  
  5210. bool isDecimal = false;
  5211. foreach (char c in value)
  5212. if (c == '.')
  5213. {
  5214. isDecimal = true;
  5215. break;
  5216. }
  5217.  
  5218. if(isDecimal)
  5219. {
  5220. if(mutiplyTousend == "1")
  5221. {
  5222. Item properties = inn.getItemByKeyedName("Property", information);
  5223.  
  5224. string scaleStr = properties.getProperty("scale", "");
  5225. int scale = int.Parse(scaleStr);
  5226. int tousendMultiple = 1;
  5227. for(int k = 0; k < scale; k++)
  5228. tousendMultiple *= 10;
  5229. decimal decimalValue = decimal.Parse(value);
  5230. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  5231. value = currValue.ToString();
  5232. }
  5233. }
  5234. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  5235. value = value.ToString();
  5236. if(possitionsForZeros < int.Parse(length))
  5237. {
  5238. string zeros = "";
  5239. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  5240.  
  5241. value = zeros + value;
  5242. }
  5243. }
  5244. }
  5245.  
  5246. for(int s = 0; s < int.Parse(length); s++)
  5247. {
  5248. if(defaultValue == "") defaultValue = " ";
  5249. if(value == "") value = defaultValue;
  5250. if(value == null || s >= value.Length)
  5251. {
  5252. wantedProperty += " ";
  5253. continue;
  5254. }
  5255. wantedProperty += value[s];
  5256. }
  5257.  
  5258. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5259. {
  5260. System.Diagnostics.Debugger.Break();
  5261. id.Close();
  5262. me.Close();
  5263.  
  5264. return inn.newError("Please Look at the table");
  5265. }
  5266. }
  5267.  
  5268. else if(itemType == "Constitution")
  5269. {
  5270. switch(infoType)
  5271. {
  5272. case "Property":
  5273. string partConstId = finishedGood.getProperty("mrn_plm_constitution");
  5274.  
  5275. Item someXProps = inn.newItem("xPropertyDefinition", "get");
  5276. someXProps.setProperty("name", information);
  5277. someXProps = someXProps.apply();
  5278. try
  5279. {
  5280. string res = someXProps.getProperty("name");
  5281.  
  5282. string sql = @"SELECT [" + res + "] FROM [xp].[XPROPERTYVALUES] WHERE item_id='" + partConstId + "'";
  5283. Item sqlResult = inn.applySQL(sql);
  5284. value = sqlResult.getProperty(res);
  5285. }
  5286.  
  5287. catch(Exception){value = "";}
  5288.  
  5289. nextItem = 0;
  5290.  
  5291. if(value ==null)
  5292. {
  5293. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  5294. }
  5295.  
  5296. if(nextItem >= 2 && priority == "Preminary") break;
  5297.  
  5298. valueCopy = value;
  5299.  
  5300. if(priority == "Preminary") {
  5301. if(value != "")
  5302. {
  5303. flag = true;
  5304. priorityString = value;
  5305. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  5306.  
  5307. //if(nextItem >= 2 && priority == "Preminary") break;
  5308. }
  5309. else
  5310. {
  5311. flag = true;
  5312. continue;
  5313.  
  5314. }
  5315. }
  5316. else if(priority == "Alternative"){
  5317. if(flag == false)
  5318. {
  5319. if(priorityString != "")
  5320. {
  5321. flag = false;
  5322. priorityString = "";
  5323. break;
  5324. }
  5325. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  5326. id.Close();
  5327. me.Close();
  5328. continue;
  5329. }
  5330.  
  5331. if(priorityString != "")
  5332. {
  5333. flag = false;
  5334. priorityString = "";
  5335. continue;
  5336. }
  5337. }
  5338.  
  5339. //MultiplyTousend
  5340. if(mutiplyTousend == "1") {
  5341. if(valueCopy != "")
  5342. {
  5343. decimal decimalValue = decimal.Parse(value);
  5344. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  5345. }
  5346. }
  5347. //RemoveSeparator
  5348. if(removeSeparator == "1"){
  5349. if(valueCopy != "")
  5350. {
  5351. Item properties = inn.getItemByKeyedName("Property", information);
  5352.  
  5353. bool isDecimal = false;
  5354. foreach (char c in value)
  5355. if (c == '.')
  5356. {
  5357. isDecimal = true;
  5358. break;
  5359. }
  5360.  
  5361. if(isDecimal)
  5362. {
  5363. string scaleStr = properties.getProperty("scale", "");
  5364. int scale = int.Parse(scaleStr);
  5365. int tousendMultiple = 1;
  5366. for(int k = 0; k < scale; k++)
  5367. tousendMultiple *= 10;
  5368. decimal decimalValue = decimal.Parse(value);
  5369. decimalValue *= tousendMultiple;
  5370. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  5371. value.ToString();
  5372. value = resultValue;
  5373. }
  5374. }
  5375. }
  5376. //Leading Zero
  5377. if(leadingZero == "1") {
  5378. if(valueCopy != "")
  5379. {
  5380.  
  5381. bool isDecimal = false;
  5382. foreach (char c in value)
  5383. if (c == '.')
  5384. {
  5385. isDecimal = true;
  5386. break;
  5387. }
  5388.  
  5389. if(isDecimal)
  5390. {
  5391. if(mutiplyTousend == "1")
  5392. {
  5393. Item properties = inn.getItemByKeyedName("Property", information);
  5394.  
  5395. string scaleStr = properties.getProperty("scale", "");
  5396. int scale = int.Parse(scaleStr);
  5397. int tousendMultiple = 1;
  5398. for(int k = 0; k < scale; k++)
  5399. tousendMultiple *= 10;
  5400. decimal decimalValue = decimal.Parse(value);
  5401. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  5402. value = currValue.ToString();
  5403. }
  5404. }
  5405. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  5406. value = value.ToString();
  5407. if(possitionsForZeros < int.Parse(length))
  5408. {
  5409. string zeros = "";
  5410. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  5411.  
  5412. value = zeros + value;
  5413. }
  5414. }
  5415. }
  5416.  
  5417.  
  5418. for(int s = 0; s < int.Parse(length); s++)
  5419. {
  5420. if(defaultValue == "") defaultValue = " ";
  5421. if(value == "") value = defaultValue;
  5422. if(value == null || s >= value.Length)
  5423. {
  5424. wantedProperty += " ";
  5425. continue;
  5426. }
  5427. wantedProperty += value[s];
  5428. }
  5429. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5430. {
  5431. System.Diagnostics.Debugger.Break();
  5432. id.Close();
  5433. me.Close();
  5434.  
  5435. return inn.newError("Please Look at the table");
  5436. }
  5437. break;
  5438. }
  5439. }
  5440.  
  5441. else if(itemType == "R35")
  5442. {
  5443. Item r35Item = null;
  5444. string r35 = finishedGood.getProperty("mrn_plm_r35", "");
  5445.  
  5446. if(r35 != "")
  5447. {
  5448. r35Item = inn.getItemById("Part", r35);
  5449. }
  5450.  
  5451. switch(infoType)
  5452. {
  5453. case "Property":
  5454.  
  5455. if(r35Item != null)
  5456. value = r35Item.getProperty(information, "");
  5457. else value = "";
  5458.  
  5459. nextItem = 0;
  5460.  
  5461. if(value ==null)
  5462. {
  5463. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  5464. }
  5465.  
  5466. if(nextItem >= 2 && priority == "Preminary") break;
  5467.  
  5468. valueCopy = value;
  5469.  
  5470. if(priority == "Preminary") {
  5471. if(value != "")
  5472. {
  5473. flag = true;
  5474. priorityString = value;
  5475. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  5476.  
  5477. //if(nextItem >= 2 && priority == "Preminary") break;
  5478. }
  5479. else
  5480. {
  5481. flag = true;
  5482. continue;
  5483.  
  5484. }
  5485. }
  5486. else if(priority == "Alternative"){
  5487. if(flag == false)
  5488. {
  5489. if(priorityString != "")
  5490. {
  5491. flag = false;
  5492. priorityString = "";
  5493. break;
  5494. }
  5495. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  5496. id.Close();
  5497. me.Close();
  5498. continue;
  5499. }
  5500.  
  5501. if(priorityString != "")
  5502. {
  5503. flag = false;
  5504. priorityString = "";
  5505. continue;
  5506. }
  5507. }
  5508.  
  5509. //MultiplyTousend
  5510. if(mutiplyTousend == "1") {
  5511. if(valueCopy != "")
  5512. {
  5513. decimal decimalValue = decimal.Parse(value);
  5514. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  5515. }
  5516. }
  5517. //RemoveSeparator
  5518. if(removeSeparator == "1"){
  5519. if(valueCopy != "")
  5520. {
  5521. Item properties = inn.getItemByKeyedName("Property", information);
  5522.  
  5523. bool isDecimal = false;
  5524. foreach (char c in value)
  5525. if (c == '.')
  5526. {
  5527. isDecimal = true;
  5528. break;
  5529. }
  5530.  
  5531. if(isDecimal)
  5532. {
  5533. string scaleStr = properties.getProperty("scale", "");
  5534. int scale = int.Parse(scaleStr);
  5535. int tousendMultiple = 1;
  5536. for(int k = 0; k < scale; k++)
  5537. tousendMultiple *= 10;
  5538. decimal decimalValue = decimal.Parse(value);
  5539. decimalValue *= tousendMultiple;
  5540. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  5541. value.ToString();
  5542. value = resultValue;
  5543. }
  5544. }
  5545. }
  5546. //Leading Zero
  5547. if(leadingZero == "1") {
  5548. if(valueCopy != "")
  5549. {
  5550.  
  5551. bool isDecimal = false;
  5552. foreach (char c in value)
  5553. if (c == '.')
  5554. {
  5555. isDecimal = true;
  5556. break;
  5557. }
  5558.  
  5559. if(isDecimal)
  5560. {
  5561. if(mutiplyTousend == "1")
  5562. {
  5563. Item properties = inn.getItemByKeyedName("Property", information);
  5564.  
  5565. string scaleStr = properties.getProperty("scale", "");
  5566. int scale = int.Parse(scaleStr);
  5567. int tousendMultiple = 1;
  5568. for(int k = 0; k < scale; k++)
  5569. tousendMultiple *= 10;
  5570. decimal decimalValue = decimal.Parse(value);
  5571. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  5572. value = currValue.ToString();
  5573. }
  5574. }
  5575. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  5576. value = value.ToString();
  5577. if(possitionsForZeros < int.Parse(length))
  5578. {
  5579. string zeros = "";
  5580. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  5581.  
  5582. value = zeros + value;
  5583. }
  5584. }
  5585. }
  5586.  
  5587. for(int s = 0; s < int.Parse(length); s++)
  5588. {
  5589. if(defaultValue == "") defaultValue = " ";
  5590. if(value == "") value = defaultValue;
  5591. if(value == null || s >= value.Length)
  5592. {
  5593. wantedProperty += " ";
  5594. continue;
  5595. }
  5596. wantedProperty += value[s];
  5597. }
  5598. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5599. {
  5600. System.Diagnostics.Debugger.Break();
  5601. id.Close();
  5602. me.Close();
  5603.  
  5604. return inn.newError("Please Look at the table");
  5605. }
  5606. break;
  5607.  
  5608. case "ItemPropertyItem":
  5609. string myStockPartId = null;
  5610. Item myStockPart = null;
  5611.  
  5612. if(r35Item != null)
  5613. {
  5614. myStockPartId = r35Item.getProperty(information, "");
  5615.  
  5616. if(myStockPartId != "")
  5617. myStockPart = inn.getItemById("Part", myStockPartId);
  5618. }
  5619. if(myStockPart != null)
  5620. {
  5621. value = myStockPart.getProperty(itemInformation, "");
  5622. //return inn.newError("There is stock Item");
  5623. }
  5624. else value = "";
  5625.  
  5626. nextItem = 0;
  5627.  
  5628. if(value ==null)
  5629. {
  5630. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty ("mrn_plm_priority") == "Alternative").Count();
  5631. }
  5632.  
  5633. if(nextItem >= 2 && priority == "Preminary") break;
  5634.  
  5635. valueCopy = value;
  5636.  
  5637. if(priority == "Preminary") {
  5638. if(value != "")
  5639. {
  5640. flag = true;
  5641. priorityString = value;
  5642. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  5643.  
  5644. //if(nextItem >= 2 && priority == "Preminary") break;
  5645. }
  5646. else
  5647. {
  5648. flag = true;
  5649. continue;
  5650.  
  5651. }
  5652. }
  5653. else if(priority == "Alternative"){
  5654. if(flag == false)
  5655. {
  5656. if(priorityString != "")
  5657. {
  5658. flag = false;
  5659. priorityString = "";
  5660. break;
  5661. }
  5662. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  5663. id.Close();
  5664. me.Close();
  5665. continue;
  5666. }
  5667.  
  5668. if(priorityString != "")
  5669. {
  5670. flag = false;
  5671. priorityString = "";
  5672. continue;
  5673. }
  5674. }
  5675.  
  5676. //MultiplyTousend
  5677. if(mutiplyTousend == "1") {
  5678. if(valueCopy != "")
  5679. {
  5680. decimal decimalValue = decimal.Parse(value);
  5681. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  5682. }
  5683. }
  5684. //RemoveSeparator
  5685. if(removeSeparator == "1"){
  5686. if(valueCopy != "")
  5687. {
  5688. Item properties = inn.getItemByKeyedName("Property", information);
  5689.  
  5690. bool isDecimal = false;
  5691. foreach (char c in value)
  5692. if (c == '.')
  5693. {
  5694. isDecimal = true;
  5695. break;
  5696. }
  5697.  
  5698. if(isDecimal)
  5699. {
  5700. string scaleStr = properties.getProperty("scale", "");
  5701. int scale = int.Parse(scaleStr);
  5702. int tousendMultiple = 1;
  5703. for(int k = 0; k < scale; k++)
  5704. tousendMultiple *= 10;
  5705. decimal decimalValue = decimal.Parse(value);
  5706. decimalValue *= tousendMultiple;
  5707. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  5708. value.ToString();
  5709. value = resultValue;
  5710. }
  5711. }
  5712. }
  5713. //Leading Zero
  5714. if(leadingZero == "1") {
  5715. if(valueCopy != "")
  5716. {
  5717.  
  5718. bool isDecimal = false;
  5719. foreach (char c in value)
  5720. if (c == '.')
  5721. {
  5722. isDecimal = true;
  5723. break;
  5724. }
  5725.  
  5726. if(isDecimal)
  5727. {
  5728. if(mutiplyTousend == "1")
  5729. {
  5730. Item properties = inn.getItemByKeyedName("Property", information);
  5731.  
  5732. string scaleStr = properties.getProperty("scale", "");
  5733. int scale = int.Parse(scaleStr);
  5734. int tousendMultiple = 1;
  5735. for(int k = 0; k < scale; k++)
  5736. tousendMultiple *= 10;
  5737. decimal decimalValue = decimal.Parse(value);
  5738. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  5739. value = currValue.ToString();
  5740. }
  5741. }
  5742. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  5743. value = value.ToString();
  5744. if(possitionsForZeros < int.Parse(length))
  5745. {
  5746. string zeros = "";
  5747. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  5748.  
  5749. value = zeros + value;
  5750. }
  5751. }
  5752. }
  5753.  
  5754. for(int s = 0; s < int.Parse(length); s++)
  5755. {
  5756. if(defaultValue == "") defaultValue = " ";
  5757. if(value == "") value = defaultValue;
  5758. if(value == null || s >= value.Length)
  5759. {
  5760. wantedProperty += " ";
  5761. continue;
  5762. }
  5763. wantedProperty += value[s];
  5764. }
  5765. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5766. {
  5767. System.Diagnostics.Debugger.Break();
  5768. id.Close();
  5769. me.Close();
  5770.  
  5771. return inn.newError("Please Look at the table");
  5772. }
  5773. break;
  5774. }
  5775. }
  5776.  
  5777. else if(itemType == "MSL")
  5778. {
  5779. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  5780. Item pim = null;
  5781. Item msl = null;
  5782. if(pimId != "")
  5783. {
  5784. pim = inn.getItemById("MRN_Item", pimId);
  5785.  
  5786. string mslId = pim.getProperty("mrn_parent_msl", "");
  5787.  
  5788. if(mslId != "")
  5789. msl = inn.getItemById("MRN_Item", mslId);
  5790. }
  5791.  
  5792. switch(infoType)
  5793. {
  5794. case "Property":
  5795. if(msl != null)
  5796. value = msl.getProperty(information, "");
  5797. else
  5798. value = "";
  5799.  
  5800. nextItem = 0;
  5801.  
  5802. if(value ==null)
  5803. {
  5804. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  5805. }
  5806.  
  5807. if(nextItem >= 2 && priority == "Preminary") break;
  5808.  
  5809. valueCopy = value;
  5810.  
  5811. if(priority == "Preminary") {
  5812. if(value != "")
  5813. {
  5814. flag = true;
  5815. priorityString = value;
  5816. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  5817.  
  5818. //if(nextItem >= 2 && priority == "Preminary") break;
  5819. }
  5820. else
  5821. {
  5822. flag = true;
  5823. continue;
  5824.  
  5825. }
  5826. }
  5827. else if(priority == "Alternative"){
  5828. if(flag == false)
  5829. {
  5830. if(priorityString != "")
  5831. {
  5832. flag = false;
  5833. priorityString = "";
  5834. break;
  5835. }
  5836. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  5837. id.Close();
  5838. me.Close();
  5839. continue;
  5840. }
  5841.  
  5842. if(priorityString != "")
  5843. {
  5844. flag = false;
  5845. priorityString = "";
  5846. continue;
  5847. }
  5848. }
  5849.  
  5850. //MultiplyTousend
  5851. if(mutiplyTousend == "1") {
  5852. if(valueCopy != "")
  5853. {
  5854. decimal decimalValue = decimal.Parse(value);
  5855. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  5856. }
  5857. }
  5858. //RemoveSeparator
  5859. if(removeSeparator == "1"){
  5860. if(valueCopy != "")
  5861. {
  5862. Item properties = inn.getItemByKeyedName("Property", information);
  5863.  
  5864. bool isDecimal = false;
  5865. foreach (char c in value)
  5866. if (c == '.')
  5867. {
  5868. isDecimal = true;
  5869. break;
  5870. }
  5871.  
  5872. if(isDecimal)
  5873. {
  5874. string scaleStr = properties.getProperty("scale", "");
  5875. int scale = int.Parse(scaleStr);
  5876. int tousendMultiple = 1;
  5877. for(int k = 0; k < scale; k++)
  5878. tousendMultiple *= 10;
  5879. decimal decimalValue = decimal.Parse(value);
  5880. decimalValue *= tousendMultiple;
  5881. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  5882. value.ToString();
  5883. value = resultValue;
  5884. }
  5885. }
  5886. }
  5887. //Leading Zero
  5888. if(leadingZero == "1") {
  5889. if(valueCopy != "")
  5890. {
  5891.  
  5892. bool isDecimal = false;
  5893. foreach (char c in value)
  5894. if (c == '.')
  5895. {
  5896. isDecimal = true;
  5897. break;
  5898. }
  5899.  
  5900. if(isDecimal)
  5901. {
  5902. if(mutiplyTousend == "1")
  5903. {
  5904. Item properties = inn.getItemByKeyedName("Property", information);
  5905.  
  5906. string scaleStr = properties.getProperty("scale", "");
  5907. int scale = int.Parse(scaleStr);
  5908. int tousendMultiple = 1;
  5909. for(int k = 0; k < scale; k++)
  5910. tousendMultiple *= 10;
  5911. decimal decimalValue = decimal.Parse(value);
  5912. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  5913. value = currValue.ToString();
  5914. }
  5915. }
  5916. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  5917. value = value.ToString();
  5918. if(possitionsForZeros < int.Parse(length))
  5919. {
  5920. string zeros = "";
  5921. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  5922.  
  5923. value = zeros + value;
  5924. }
  5925. }
  5926. }
  5927.  
  5928. for(int s = 0; s < int.Parse(length); s++)
  5929. {
  5930. if(defaultValue == "") defaultValue = " ";
  5931. if(value == "") value = defaultValue;
  5932. if(value == null || s >= value.Length)
  5933. {
  5934. wantedProperty += " ";
  5935. continue;
  5936. }
  5937. wantedProperty += value[s];
  5938. }
  5939. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  5940. {
  5941. System.Diagnostics.Debugger.Break();
  5942. id.Close();
  5943. me.Close();
  5944.  
  5945. return inn.newError("Please Look at the table");
  5946. }
  5947. break;
  5948. }
  5949. }
  5950.  
  5951. else if(itemType == "Frame")
  5952. {
  5953. string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
  5954. Item pim = null;
  5955. Item frame = null;
  5956. if(pimId != "")
  5957. {
  5958. pim = inn.getItemById("MRN_Item", pimId);
  5959.  
  5960. string frameId = pim.getProperty("mrn_frame", "");
  5961.  
  5962. if(frameId != "")
  5963. frame = inn.getItemById("MRN_Item", frameId);
  5964. }
  5965.  
  5966. switch(infoType)
  5967. {
  5968. case "Property":
  5969. if(frame != null)
  5970. value = frame.getProperty(information, "");
  5971. else value = "";
  5972.  
  5973. nextItem = 0;
  5974.  
  5975. if(value ==null)
  5976. {
  5977. nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
  5978. }
  5979.  
  5980. if(nextItem >= 2 && priority == "Preminary") break;
  5981.  
  5982. valueCopy = value;
  5983.  
  5984. if(priority == "Preminary") {
  5985. if(value != "")
  5986. {
  5987. flag = true;
  5988. priorityString = value;
  5989. // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
  5990.  
  5991. //if(nextItem >= 2 && priority == "Preminary") break;
  5992. }
  5993. else
  5994. {
  5995. flag = true;
  5996. continue;
  5997.  
  5998. }
  5999. }
  6000. else if(priority == "Alternative"){
  6001. if(flag == false)
  6002. {
  6003. if(priorityString != "")
  6004. {
  6005. flag = false;
  6006. priorityString = "";
  6007. break;
  6008. }
  6009. return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
  6010. id.Close();
  6011. me.Close();
  6012. continue;
  6013. }
  6014.  
  6015. if(priorityString != "")
  6016. {
  6017. flag = false;
  6018. priorityString = "";
  6019. continue;
  6020. }
  6021. }
  6022.  
  6023. //MultiplyTousend
  6024. if(mutiplyTousend == "1") {
  6025. if(valueCopy != "")
  6026. {
  6027. decimal decimalValue = decimal.Parse(value);
  6028. value = Decimal.ToInt32((decimalValue * 1000)).ToString();
  6029. }
  6030. }
  6031. //RemoveSeparator
  6032. if(removeSeparator == "1"){
  6033. if(valueCopy != "")
  6034. {
  6035. Item properties = inn.getItemByKeyedName("Property", information);
  6036.  
  6037. bool isDecimal = false;
  6038. foreach (char c in value)
  6039. if (c == '.')
  6040. {
  6041. isDecimal = true;
  6042. break;
  6043. }
  6044.  
  6045. if(isDecimal)
  6046. {
  6047. string scaleStr = properties.getProperty("scale", "");
  6048. int scale = int.Parse(scaleStr);
  6049. int tousendMultiple = 1;
  6050. for(int k = 0; k < scale; k++)
  6051. tousendMultiple *= 10;
  6052. decimal decimalValue = decimal.Parse(value);
  6053. decimalValue *= tousendMultiple;
  6054. string resultValue = Decimal.ToInt32(decimalValue).ToString();
  6055. value.ToString();
  6056. value = resultValue;
  6057. }
  6058. }
  6059. }
  6060. //Leading Zero
  6061. if(leadingZero == "1") {
  6062. if(valueCopy != "")
  6063. {
  6064.  
  6065. bool isDecimal = false;
  6066. foreach (char c in value)
  6067. if (c == '.')
  6068. {
  6069. isDecimal = true;
  6070. break;
  6071. }
  6072.  
  6073. if(isDecimal)
  6074. {
  6075. if(mutiplyTousend == "1")
  6076. {
  6077. Item properties = inn.getItemByKeyedName("Property", information);
  6078.  
  6079. string scaleStr = properties.getProperty("scale", "");
  6080. int scale = int.Parse(scaleStr);
  6081. int tousendMultiple = 1;
  6082. for(int k = 0; k < scale; k++)
  6083. tousendMultiple *= 10;
  6084. decimal decimalValue = decimal.Parse(value);
  6085. int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
  6086. value = currValue.ToString();
  6087. }
  6088. }
  6089. int possitionsForZeros = int.Parse(length) - value.ToString().Length;
  6090. value = value.ToString();
  6091. if(possitionsForZeros < int.Parse(length))
  6092. {
  6093. string zeros = "";
  6094. for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
  6095.  
  6096. value = zeros + value;
  6097. }
  6098. }
  6099. }
  6100.  
  6101. for(int s = 0; s < int.Parse(length); s++)
  6102. {
  6103. if(defaultValue == "") defaultValue = " ";
  6104. if(value == "") value = defaultValue;
  6105. if(value == null || s >= value.Length)
  6106. {
  6107. wantedProperty += " ";
  6108. continue;
  6109. }
  6110. wantedProperty += value[s];
  6111. }
  6112. if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
  6113. {
  6114. System.Diagnostics.Debugger.Break();
  6115. id.Close();
  6116. me.Close();
  6117.  
  6118. return inn.newError("Please Look at the table");
  6119. }
  6120. break;
  6121. }
  6122. }
  6123.  
  6124.  
  6125. if (itemItM.Equals(lastMeasure))
  6126. {
  6127. me.Write(wantedProperty);
  6128. me.WriteLine();
  6129. }
  6130. }
  6131. }
  6132.  
  6133. id.Close();
  6134. me.Close();
  6135. }
  6136. catch(Exception c)
  6137. {
  6138. id.Close();
  6139. me.Close();
  6140. }
  6141.  
  6142. return this;
  6143. }
  6144.  
  6145. class CompareItem : IComparer<Item>
  6146. {
  6147. public int Compare(Item x, Item y)
  6148. {
  6149. // CompareTo() method
  6150. int positionx = Convert.ToInt32(x.getProperty("mrn_plm_exportposition", "0"));
  6151. int positiony = Convert.ToInt32(y.getProperty("mrn_plm_exportposition", "0"));
  6152.  
  6153. return positionx.CompareTo(positiony);
  6154.  
  6155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement