Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Name: MRN_PLM_DialogChange
- // 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.
- // Called by: Executed by the Scheduler
- // <02-Dec-2019> - Kostadin Markov - code for Mersen
- //======================================================================I
- Innovator inn = this.getInnovator();
- //System.Diagnostics.Debugger.Break();
- Item someExportDefinitions = inn.newItem("MRN_PLM_ExportDefinition", "get");
- someExportDefinitions.setProperty("mrn_plm_target_system", "DIALOGUE");
- someExportDefinitions.setProperty("mrn_plm_is_enabled", "1");
- someExportDefinitions = someExportDefinitions.apply();
- try
- {
- string assas = someExportDefinitions.getID();
- }
- catch
- {
- return inn.newError("There is no enabled Export Definitions!");
- }
- someExportDefinitions.fetchRelationships("MRN_PLM_ExportDefinitionRel");
- Item someRelationships = someExportDefinitions.getRelationships("MRN_PLM_ExportDefinitionRel");
- int count = someRelationships.getItemCount();
- //string triggeringEvent = null;
- string itemType = null;
- string infoType = null;
- string information = null;
- string defaultValue = null;
- string itemInformation = null;
- string exportPosition = null;
- string startPosition = null;
- string length = null;
- string usage = null;
- string priority = null;
- string leadingZero = null;
- string mutiplyTousend = null;
- string removeSeparator = null;
- Item someFinishedGood = inn.newItem("Part", "get");
- // someFinishedGood.setAttribute("where", "[Part].classification='Finished good' AND [Part].state='Released'");
- someFinishedGood.setAttribute("where", "[Part].mrn_plm_is_labeled ='1' OR [Part].state='Released' AND [Part].classification='Finished good'");
- //someFinishedGood.setAttribute("where", "[Part].state='Released'");
- someFinishedGood = someFinishedGood.apply();
- int countOfFinishedGoods = someFinishedGood.getItemCount();
- List<Item> allNeededFinishedGoods = new List<Item>();
- for(int ib = 0; ib < countOfFinishedGoods; ib++)
- {
- Item ourFG = someFinishedGood.getItemByIndex(ib);
- allNeededFinishedGoods.Add(ourFG);
- }
- int fdf = allNeededFinishedGoods.Count();
- Item variable = inn.newItem("Variable", "get");
- variable.setProperty("name", "MRN_PLM_DialogueExport");
- variable = variable.apply();
- string filePath = variable.getProperty("value", "");
- //int countOfPartsNeeded = someFinishedGood.getItemCount();
- string fileParthNameIdent = filePath + "\\" + "IDENT6.txt";
- string fileParthNameMesure = filePath + "\\" + "MESURE.txt";
- StreamWriter id = new StreamWriter(fileParthNameIdent);
- StreamWriter me = new StreamWriter(fileParthNameMesure);
- List<Item> IDENT6_LIST = new List<Item>();
- List<Item> MEASURE_LIST = new List<Item>();
- //int positionx = Convert.ToInt32(x.getProperty("mrn_plm_exportposition", "0"));
- for(int ia = 0; ia < count; ia++)
- {
- Item rel = someRelationships.getItemByIndex(ia);
- string relEvent = rel.getProperty("mrn_plm_triggering_event");
- //exportPosition = Convert.ToInt32(rel.getProperty("mrn_plm_exportposition"));
- if(relEvent == "IDENT6")
- {
- IDENT6_LIST.Add(rel);
- }
- else if(relEvent == "MESURE")
- {
- MEASURE_LIST.Add(rel);
- }
- }
- int identCount = IDENT6_LIST.Count;
- int measureCount = MEASURE_LIST.Count;
- List<KeyValuePair<int, string>> ident6Cont = new List<KeyValuePair<int, string>>();
- List<KeyValuePair<int, string>> measureCont = new List<KeyValuePair<int, string>>();
- foreach(var entry in IDENT6_LIST)
- {
- ident6Cont.Add(new KeyValuePair<int, string>(Convert.ToInt32(entry.getProperty("mrn_plm_exportposition", "")),entry.getProperty("mrn_plm_priority", "")));
- //ident6Cont.Add(currentPair);
- }
- foreach(var entry in MEASURE_LIST)
- {
- measureCont.Add(new KeyValuePair<int, string>(Convert.ToInt32(entry.getProperty("mrn_plm_exportposition", "")),entry.getProperty("mrn_plm_priority", "")));
- //ident6Cont.Add(currentPair);
- }
- ident6Cont = ident6Cont.OrderBy(x =>x.Key)
- //.ThenBy(x =>x.Value)
- .ToList();
- measureCont = measureCont.OrderBy(x => x.Key).ToList();
- List<Item> IDENT6_LISTReal = new List<Item>();
- List<Item> MEASURE_LISTReal = new List<Item>();
- foreach(var entry in ident6Cont)
- {
- int currPos = entry.Key;
- string currPosString = currPos.ToString();
- string currPriority = entry.Value;
- foreach(var el in IDENT6_LIST)
- {
- string currIDENT6Pos = el.getProperty("mrn_plm_exportposition", "");
- string currIDENT6Priority = el.getProperty("mrn_plm_priority", "");
- if(currIDENT6Pos == currPosString && currPriority == currIDENT6Priority)
- {
- IDENT6_LISTReal.Add(el);
- break;
- }
- }
- }
- foreach(var entry in measureCont)
- {
- int currPos = entry.Key;
- string currPosString = currPos.ToString();
- string currPriority = entry.Value;
- foreach(var el in MEASURE_LIST)
- {
- string currMEASUREPos = el.getProperty("mrn_plm_exportposition", "");
- string currMEASUREPriority = el.getProperty("mrn_plm_priority", "");
- if(currMEASUREPos == currPosString && currPriority == currMEASUREPriority)
- {
- MEASURE_LISTReal.Add(el);
- break;
- }
- }
- }
- Item last = null;
- Item lastMeasure = null;
- if(identCount > 0)
- {
- last = IDENT6_LISTReal.Last();
- }
- if(measureCount > 0){
- lastMeasure = MEASURE_LISTReal.Last();
- }
- //System.Diagnostics.Debugger.Break();
- System.Diagnostics.Debugger.Break();
- string wantedProperty = null;
- try
- {
- foreach(Item finishedGood in allNeededFinishedGoods)
- {
- bool flag = false;
- string priorityString = "";
- wantedProperty = "";
- foreach(Item itemItm in IDENT6_LISTReal)
- {
- itemType = itemItm.getProperty("mrn_plm_item_type", "");
- infoType = itemItm.getProperty("mrn_plm_info_type", "");
- information = itemItm.getProperty("mrn_plm_information", "");
- defaultValue = itemItm.getProperty("mrn_plm_defaut_value", "");
- itemInformation = itemItm.getProperty("mrn_plm_item_information", "");
- exportPosition = itemItm.getProperty("mrn_plm_exportposition", "");
- startPosition = itemItm.getProperty("mrn_plm_start_position", "");
- length = itemItm.getProperty("mrn_plm_length", "");
- usage = itemItm.getProperty("mrn_plm_usage_doc", "");
- priority = itemItm.getProperty("mrn_plm_priority", "");
- leadingZero = itemItm.getProperty("mrn_plm_leading0", "");
- mutiplyTousend = itemItm.getProperty("mrn_plm_multiply1000", "");
- removeSeparator = itemItm.getProperty("mrn_plm_remove_separator", "");
- string value = null;
- string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
- string productLabItemId = finishedGood.getProperty("mrn_plm_product_label_item", "");
- if(exportPosition == "40")
- {
- string s= "sa";
- }
- string valueCopy;
- var nextItem = 0;
- 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"))
- {
- if(infoType == "DateTime-YYMMDDhhmm")
- {
- DateTime dt = DateTime.Now;;
- if (information == "Today") {dt = DateTime.Now;}
- if (information == "Yesterday") {dt = dt.AddDays(-1);}
- if (information == "Tomorrow") {dt = dt.AddDays(1);}
- value = dt.ToString("yyMMddHHmm");
- for(int f = 0; f < int.Parse(length); f++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || f >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[f];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else if(infoType == "Date-MM/DD/YYYY")
- {
- DateTime dte = DateTime.Now;
- if (information == "Today") {dte = DateTime.Now;}
- if (information == "Yesterday") {dte = dte.AddDays(-1);}
- if (information == "Tomorrow") {dte = dte.AddDays(1);}
- value = dte.ToString(@"MM\/dd\/yyyy");
- for(int f = 0; f < int.Parse(length); f++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || f >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[f];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- }
- else if(itemType == "Item")
- {
- int d = wantedProperty.Length;
- switch(infoType)
- {
- case "Property":
- if(information != "")
- value = finishedGood.getProperty(information, "");
- else value = defaultValue;
- valueCopy = value;
- if(value == "C0000669")
- {
- id.Close();
- me.Close();
- System.Diagnostics.Debugger.Break();
- }
- nextItem = 0;
- if(priority == "Preminary")
- {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative")
- {
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1")
- {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- Item thisItem = null;
- if(information != "")
- {
- string myItemId = finishedGood.getProperty(information, "");
- if(myItemId != "")
- {
- try
- {
- if(information == "mrn_plm_pim_product")
- {
- thisItem = inn.getItemById("MRN_Item", myItemId);
- }
- else if(information == "mrn_plm_label_item" || information == "mrn_plm_product_label_item")
- {
- thisItem = inn.newItem("mrn_plm_labeling_item", myItemId);
- }
- else thisItem = inn.newItem("Part", myItemId);
- //thisItem = inn.getItemById(information, myItemId);
- }
- catch(Exception) {inn.newError("The is no Item type with this name!");}
- value = thisItem.getProperty(itemInformation , "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1")
- {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1")
- {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length)){
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else
- {
- value = "";
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Generic Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(information == "" || labItemId == "")
- {
- value = defaultValue;
- }
- else if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- value = ourLabItem.getProperty(information);
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "RelatedProperty":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_property");
- Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
- //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
- int getRelsCount = getRels.getItemCount();
- for(int sk = 0; sk < getRelsCount; sk++)
- {
- Item currentProperty = getRels.getItemByIndex(sk);
- string currProperty = currentProperty.getProperty("mrn_plm_label_name");
- if(information == currProperty)
- {
- if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
- {
- value = currentProperty.getProperty("mrn_plm_label_value");
- break;
- }
- }
- else continue;
- }
- if(value == null) value = "";
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- Item myStockPart = null;
- string myStockPartId = "";
- string cItem = finishedGood.getProperty("mrn_plm_label_item", "");
- Item ssd = null;
- if(cItem != "")
- ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
- if(ssd != null && information != "")
- myStockPartId = ssd.getProperty(information, "");
- if(myStockPartId != "")
- {
- myStockPart = inn.getItemById("Part", myStockPartId);
- value = myStockPart.getProperty(itemInformation, "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "Document":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
- Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
- int docRelCount = docRelationships.getItemCount();
- for(int f = 0; f < docRelCount; f++)
- {
- Item currDoc = docRelationships.getItemByIndex(f);
- Item doc = currDoc.getRelatedItem();
- var docUsage = currDoc.getProperty("mrn_plm_usage");
- if(docUsage == usage)
- {
- value = doc.getProperty(information, "");
- break;
- }
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- //else value = "";
- nextItem = 0;
- // if(value ==null)
- // {
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- // }
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) +int.Parse(length))
- {
- return inn.newError("Please Look at the table");
- }
- }
- else
- {
- value = "";
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Product Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(information == "" || productLabItemId == "")
- {
- value = defaultValue;
- }
- if(productLabItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
- value = ourLabItem.getProperty(information, "");
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "RelatedProperty":
- if(productLabItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_property");
- Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
- //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
- int getRelsCount = getRels.getItemCount();
- for(int sk = 0; sk < getRelsCount; sk++)
- {
- Item currentProperty = getRels.getItemByIndex(sk);
- string currProperty = currentProperty.getProperty("mrn_plm_label_name");
- if(information == currProperty)
- {
- if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
- {
- value = currentProperty.getProperty("mrn_plm_label_value");
- break;
- }
- }
- }
- if(value == null) value = "";
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- Item myStockPart = null;
- string myStockPartId = null;
- string cItem = finishedGood.getProperty("mrn_plm_product_label_item", "");
- Item ssd = null;
- if(cItem != "")
- ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
- if(ssd != null && information != "")
- myStockPartId = ssd.getProperty(information, "");
- if(myStockPartId != "")
- {
- myStockPart = inn.getItemById("Part", myStockPartId);
- value = myStockPart.getProperty(itemInformation, "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "Document":
- if(productLabItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
- Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
- int docRelCount = docRelationships.getItemCount();
- for(int f = 0; f < docRelCount; f++)
- {
- Item currDoc = docRelationships.getItemByIndex(f);
- Item doc = currDoc.getRelatedItem();
- Item docOne = doc.getRelatedItem();
- var docUsage = currDoc.getProperty("mrn_plm_usage");
- if(docUsage == usage)
- {
- string ourID = currDoc.getProperty("related_id");
- Item currentItem = inn.getItemById("Document" ,ourID);
- if(currentItem != null)
- value = currentItem.getProperty(information, "");
- break;
- }
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- //else value = "";
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else
- {
- value = " ";
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Certification")
- {
- string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
- //Item pim = null;
- if(pimId != "")
- {
- switch(infoType)
- {
- case "Property":
- Item relationshipsDocs = inn.newItem("MRN_Item_Document", "get");
- relationshipsDocs.setAttribute ("where", "[MRN_Item_Document].source_id='" + pimId + "'");
- relationshipsDocs = relationshipsDocs.apply();
- int countRelationships = relationshipsDocs.getItemCount();
- for(int f = 0; f < countRelationships; f++)
- {
- Item currDoc = relationshipsDocs.getItemByIndex(f);
- var docUsage = currDoc.getProperty("mrn_plm_usage");
- Item doc = currDoc.getRelatedItem();
- if(docUsage == usage)
- {
- value = doc.getProperty(information, "");
- break;
- }
- }
- break;
- }
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else if(itemType == "Constitution")
- {
- switch(infoType)
- {
- case "Property":
- string partConstId = finishedGood.getProperty("mrn_plm_constitution");
- Item someXProps = inn.newItem("xPropertyDefinition", "get");
- someXProps.setProperty("name", information);
- someXProps = someXProps.apply();
- try
- {
- string res = someXProps.getProperty("name");
- string sql = @"SELECT [" + res + "] FROM [xp].[XPROPERTYVALUES] WHERE item_id='" + partConstId + "'";
- Item sqlResult = inn.applySQL(sql);
- value = sqlResult.getProperty(res);
- }
- catch(Exception){value = "";}
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++) {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length)) {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- else if(itemType == "R35")
- {
- Item r35Item = null;
- string r35 = finishedGood.getProperty("mrn_plm_r35", "");
- if(r35 != "")
- {
- r35Item = inn.getItemById("Part", r35);
- }
- switch(infoType)
- {
- case "Property":
- if(r35Item != null)
- value = r35Item.getProperty(information, "");
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- string myStockPartId = null;
- Item myStockPart = null;
- if(r35Item != null)
- {
- myStockPartId = r35Item.getProperty(information, "");
- if(myStockPartId != "")
- myStockPart = inn.getItemById("Part", myStockPartId);
- }
- if(myStockPart != null)
- {
- value = myStockPart.getProperty(itemInformation, "");
- //return inn.newError("There is stock Item");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- else if(itemType == "MSL")
- {
- string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
- Item pim = null;
- Item msl = null;
- if(pimId != "")
- {
- pim = inn.getItemById("MRN_Item", pimId);
- string mslId = pim.getProperty("mrn_parent_msl", "");
- if(mslId != "")
- msl = inn.getItemById("MRN_Item", mslId);
- }
- switch(infoType)
- {
- case "Property":
- if(msl != null)
- value = msl.getProperty(information, "");
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- else if(itemType == "Frame")
- {
- string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
- Item pim = null;
- Item frame = null;
- if(pimId != "")
- {
- pim = inn.getItemById("MRN_Item", pimId);
- string frameId = pim.getProperty("mrn_frame", "");
- if(frameId != "")
- frame = inn.getItemById("MRN_Item", frameId);
- }
- switch(infoType)
- {
- case "Property":
- if(frame != null)
- value = frame.getProperty(information, "");
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- continue;
- }
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- if (itemItm.Equals(last))
- {
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- }
- }
- wantedProperty = "";
- foreach(Item itemItM in MEASURE_LISTReal)
- {
- itemType = itemItM.getProperty("mrn_plm_item_type");
- infoType = itemItM.getProperty("mrn_plm_info_type");
- information = itemItM.getProperty("mrn_plm_information");
- defaultValue = itemItM.getProperty("mrn_plm_defaut_value");
- itemInformation = itemItM.getProperty("mrn_plm_item_information");
- startPosition = itemItM.getProperty("mrn_plm_start_position");
- length = itemItM.getProperty("mrn_plm_length");
- usage = itemItM.getProperty("mrn_plm_usage_doc", "");
- priority = itemItM.getProperty("mrn_plm_priority", "");
- leadingZero = itemItM.getProperty("mrn_plm_leading0", "");
- mutiplyTousend = itemItM.getProperty("mrn_plm_multiply1000", "");
- removeSeparator = itemItM.getProperty("mrn_plm_remove_separator", "");
- string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
- string productLabItemId = finishedGood.getProperty("mrn_plm_product_label_item", "");
- string value = null;
- string valueCopy;
- var nextItem = 0;
- 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"))
- {
- if(infoType == "DateTime-YYMMDDhhmm")
- {
- DateTime dt = DateTime.Now;;
- if (information == "Today") {dt = DateTime.Now;}
- if (information == "Yesterday") {dt = dt.AddDays(-1);}
- if (information == "Tomorrow") {dt = dt.AddDays(1);}
- value = dt.ToString("yyMMddHHmm");
- for(int f = 0; f < int.Parse(length); f++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || f >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[f];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else if(infoType == "Date-MM/DD/YYYY")
- {
- DateTime dte = DateTime.Now;
- if (information == "Today") {dte = DateTime.Now;}
- if (information == "Yesterday") {dte = dte.AddDays(-1);}
- if (information == "Tomorrow") {dte = dte.AddDays(1);}
- value = dte.ToString(@"MM\/dd\/yyyy");
- for(int f = 0; f < int.Parse(length); f++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || f >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[f];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- }
- else if(itemType == "Item")
- {
- int d = wantedProperty.Length;
- switch(infoType)
- {
- case "Property":
- if(information != "")
- value = finishedGood.getProperty(information, "");
- else value = defaultValue;
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem ":
- Item thisItem = null;
- if(information != "")
- {
- string myItemId = finishedGood.getProperty(information, "");
- if(myItemId != "")
- {
- try
- {
- if(information == "mrn_plm_pim_product")
- {
- thisItem = inn.getItemById("MRN_Item", myItemId);
- }
- else if(information == "mrn_plm_label_item" || information == "mrn_plm_product_label_item")
- {
- thisItem = inn.newItem("mrn_plm_labeling_item", myItemId);
- }
- else thisItem = inn.newItem("Part", myItemId);
- //thisItem = inn.getItemById(information, myItemId);
- }
- catch(Exception) {inn.newError("The is no Item type with this name!");}
- value = thisItem.getProperty(itemInformation , "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- //if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else
- {
- value = "";
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Generic Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(information == "" || labItemId == "")
- {
- value = defaultValue;
- }
- else if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- Item doc = ourLabItem.getRelatedItem();
- value = ourLabItem.getProperty(information);
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "RelatedProperty":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_property");
- Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
- //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
- int getRelsCount = getRels.getItemCount();
- for(int sk = 0; sk < getRelsCount; sk++)
- {
- Item currentProperty = getRels.getItemByIndex(sk);
- string currProperty = currentProperty.getProperty("mrn_plm_label_name");
- if(information == currProperty)
- {
- if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
- {
- value = currentProperty.getProperty("mrn_plm_label_value");
- break;
- }
- }
- else continue;
- }
- if(value == null) value = "";
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- Item myStockPart = null;
- string myStockPartId = null;
- string cItem = finishedGood.getProperty("mrn_plm_label_item", "");
- Item ssd = null;
- if(cItem != "")
- ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
- if(ssd != null && information != "")
- myStockPartId = ssd.getProperty(information, "");
- if(myStockPartId != "")
- {
- myStockPart = inn.getItemById("Part", myStockPartId);
- value = myStockPart.getProperty(itemInformation, "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "Document":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
- Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
- int docRelCount = docRelationships.getItemCount();
- for(int f = 0; f < docRelCount; f++)
- {
- Item currDoc = docRelationships.getItemByIndex(f);
- var docUsage = currDoc.getProperty("mrn_plm_usage");
- Item doc = currDoc.getRelatedItem();
- if(docUsage == usage)
- {
- value = doc.getProperty(information, "");
- break;
- }
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- //else value = "";
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else
- {
- value = "";
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Product Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(productLabItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
- value = ourLabItem.getProperty(information, "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "RelatedProperty":
- if(productLabItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_property");
- Item getRels = ourLabItem.getRelationships("mrn_plm_label_item_property");
- //getRels.setAttribute("where", "[mrn_plm_label_item_property].mrn_propertysource='PLMLabelItem'");
- int getRelsCount = getRels.getItemCount();
- for(int sk = 0; sk < getRelsCount; sk++)
- {
- Item currentProperty = getRels.getItemByIndex(sk);
- string currProperty = currentProperty.getProperty("mrn_plm_label_name");
- if(information == currProperty)
- {
- if(currentProperty.getProperty("mrn_propertysource") == "PLMLabelItem");
- {
- value = currentProperty.getProperty("mrn_plm_label_value");
- break;
- }
- }
- }
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- Item myStockPart = null;
- string myStockPartId = null;
- string cItem = finishedGood.getProperty("mrn_plm_product_label_item", "");
- Item ssd = null;
- if(cItem != "")
- ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
- if(ssd != null)
- myStockPartId = ssd.getProperty(information);
- if(myStockPartId != null)
- {
- myStockPart = inn.getItemById("Part", myStockPartId);
- value = myStockPart.getProperty(itemInformation, "");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "Document":
- if(productLabItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", productLabItemId);
- ourLabItem.fetchRelationships("mrn_plm_label_item_doc");
- Item docRelationships = ourLabItem.getRelationships("mrn_plm_label_item_doc");
- int docRelCount = docRelationships.getItemCount();
- for(int f = 0; f < docRelCount; f++)
- {
- Item currDoc = docRelationships.getItemByIndex(f);
- Item doc = currDoc.getRelatedItem();
- Item docOne = doc.getRelatedItem();
- var docUsage = currDoc.getProperty("mrn_plm_usage");
- if(docUsage == usage)
- {
- string ourID = currDoc.getProperty("related_id");
- Item currentItem = inn.getItemById("Document" ,ourID);
- if(currentItem != null)
- value = currentItem.getProperty(information, "");
- break;
- }
- }
- nextItem = 0;
- if(value ==null)
- {
- nextItem = IDENT6_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- //else value = "";
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else
- {
- value = " ";
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Certification")
- {
- string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
- //Item pim = null;
- if(pimId != "")
- {
- switch(infoType)
- {
- case "Property":
- Item relationshipsDocs = inn.newItem("MRN_Item_Document", "get");
- relationshipsDocs.setAttribute ("where", "[MRN_Item_Document].source_id='" + pimId + "'");
- relationshipsDocs = relationshipsDocs.apply();
- int countRelationships = relationshipsDocs.getItemCount();
- for(int f = 0; f < countRelationships; f++)
- {
- Item currDoc = relationshipsDocs.getItemByIndex(f);
- var docUsage = currDoc.getProperty("mrn_plm_usage");
- Item doc = currDoc.getRelatedItem();
- if(docUsage == usage)
- {
- value = doc.getProperty(information, "");
- break;
- }
- }
- break;
- }
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- //else value = "";
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- }
- else if(itemType == "Constitution")
- {
- switch(infoType)
- {
- case "Property":
- string partConstId = finishedGood.getProperty("mrn_plm_constitution");
- Item someXProps = inn.newItem("xPropertyDefinition", "get");
- someXProps.setProperty("name", information);
- someXProps = someXProps.apply();
- try
- {
- string res = someXProps.getProperty("name");
- string sql = @"SELECT [" + res + "] FROM [xp].[XPROPERTYVALUES] WHERE item_id='" + partConstId + "'";
- Item sqlResult = inn.applySQL(sql);
- value = sqlResult.getProperty(res);
- }
- catch(Exception){value = "";}
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- else if(itemType == "R35")
- {
- Item r35Item = null;
- string r35 = finishedGood.getProperty("mrn_plm_r35", "");
- if(r35 != "")
- {
- r35Item = inn.getItemById("Part", r35);
- }
- switch(infoType)
- {
- case "Property":
- if(r35Item != null)
- value = r35Item.getProperty(information, "");
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- case "ItemPropertyItem":
- string myStockPartId = null;
- Item myStockPart = null;
- if(r35Item != null)
- {
- myStockPartId = r35Item.getProperty(information, "");
- if(myStockPartId != "")
- myStockPart = inn.getItemById("Part", myStockPartId);
- }
- if(myStockPart != null)
- {
- value = myStockPart.getProperty(itemInformation, "");
- //return inn.newError("There is stock Item");
- }
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty ("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- else if(itemType == "MSL")
- {
- string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
- Item pim = null;
- Item msl = null;
- if(pimId != "")
- {
- pim = inn.getItemById("MRN_Item", pimId);
- string mslId = pim.getProperty("mrn_parent_msl", "");
- if(mslId != "")
- msl = inn.getItemById("MRN_Item", mslId);
- }
- switch(infoType)
- {
- case "Property":
- if(msl != null)
- value = msl.getProperty(information, "");
- else
- value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- else if(itemType == "Frame")
- {
- string pimId = finishedGood.getProperty("mrn_plm_pim_product", "");
- Item pim = null;
- Item frame = null;
- if(pimId != "")
- {
- pim = inn.getItemById("MRN_Item", pimId);
- string frameId = pim.getProperty("mrn_frame", "");
- if(frameId != "")
- frame = inn.getItemById("MRN_Item", frameId);
- }
- switch(infoType)
- {
- case "Property":
- if(frame != null)
- value = frame.getProperty(information, "");
- else value = "";
- nextItem = 0;
- if(value ==null)
- {
- nextItem = MEASURE_LIST.Select(itM => itM.getProperty("mrn_plm_start_position") == startPosition && itM.getProperty("mrn_plm_priority") == "Alternative").Count();
- }
- if(nextItem >= 2 && priority == "Preminary") break;
- valueCopy = value;
- if(priority == "Preminary") {
- if(value != "")
- {
- flag = true;
- priorityString = value;
- // nextItem = IDENT6_LIST.Select(itm => itm.getProperty("mrn_plm_start_position") == startPosition && itm.getProperty("mrn_plm_priority") == "Alternative").Count();
- //if(nextItem >= 2 && priority == "Preminary") break;
- }
- else
- {
- flag = true;
- continue;
- }
- }
- else if(priority == "Alternative"){
- if(flag == false)
- {
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- break;
- }
- return inn.newError("Please Look at the table, can not use Priority2, whenn the previos row in the ExportDefinition is not Priority1");
- id.Close();
- me.Close();
- continue;
- }
- if(priorityString != "")
- {
- flag = false;
- priorityString = "";
- continue;
- }
- }
- //MultiplyTousend
- if(mutiplyTousend == "1") {
- if(valueCopy != "")
- {
- decimal decimalValue = decimal.Parse(value);
- value = Decimal.ToInt32((decimalValue * 1000)).ToString();
- }
- }
- //RemoveSeparator
- if(removeSeparator == "1"){
- if(valueCopy != "")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- decimalValue *= tousendMultiple;
- string resultValue = Decimal.ToInt32(decimalValue).ToString();
- value.ToString();
- value = resultValue;
- }
- }
- }
- //Leading Zero
- if(leadingZero == "1") {
- if(valueCopy != "")
- {
- bool isDecimal = false;
- foreach (char c in value)
- if (c == '.')
- {
- isDecimal = true;
- break;
- }
- if(isDecimal)
- {
- if(mutiplyTousend == "1")
- {
- Item properties = inn.getItemByKeyedName("Property", information);
- string scaleStr = properties.getProperty("scale", "");
- int scale = int.Parse(scaleStr);
- int tousendMultiple = 1;
- for(int k = 0; k < scale; k++)
- tousendMultiple *= 10;
- decimal decimalValue = decimal.Parse(value);
- int currValue = Decimal.ToInt32(decimalValue * tousendMultiple);
- value = currValue.ToString();
- }
- }
- int possitionsForZeros = int.Parse(length) - value.ToString().Length;
- value = value.ToString();
- if(possitionsForZeros < int.Parse(length))
- {
- string zeros = "";
- for(int s = 0; s < possitionsForZeros; s++) zeros += "0";
- value = zeros + value;
- }
- }
- }
- for(int s = 0; s < int.Parse(length); s++)
- {
- if(defaultValue == "") defaultValue = " ";
- if(value == "") value = defaultValue;
- if(value == null || s >= value.Length)
- {
- wantedProperty += " ";
- continue;
- }
- wantedProperty += value[s];
- }
- if(wantedProperty.Length + 1 != int.Parse(startPosition) + int.Parse(length))
- {
- System.Diagnostics.Debugger.Break();
- id.Close();
- me.Close();
- return inn.newError("Please Look at the table");
- }
- break;
- }
- }
- if (itemItM.Equals(lastMeasure))
- {
- me.Write(wantedProperty);
- me.WriteLine();
- }
- }
- }
- id.Close();
- me.Close();
- }
- catch(Exception c)
- {
- id.Close();
- me.Close();
- }
- return this;
- }
- class CompareItem : IComparer<Item>
- {
- public int Compare(Item x, Item y)
- {
- // CompareTo() method
- int positionx = Convert.ToInt32(x.getProperty("mrn_plm_exportposition", "0"));
- int positiony = Convert.ToInt32(y.getProperty("mrn_plm_exportposition", "0"));
- return positionx.CompareTo(positiony);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement