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();
- string assas = someExportDefinitions.getID();
- 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;
- Item someFinishedGood = inn.newItem("Part", "get");
- someFinishedGood.setAttribute("where", "[Part].classification='Finished good' AND [Part].state='Released'");
- //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>();
- 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;
- CompareItem comp = new CompareItem();
- IDENT6_LIST.Sort(comp);
- MEASURE_LIST.Sort(comp);
- allNeededFinishedGoods.Sort(comp);
- Item last = null;
- Item lastMeasure = null;
- if(identCount > 0)
- {
- last = IDENT6_LIST.Last();
- }
- if(measureCount > 0){
- lastMeasure = MEASURE_LIST.Last();
- }
- System.Diagnostics.Debugger.Break();
- string wantedProperty = null;
- foreach(Item finishedGood in allNeededFinishedGoods)
- {
- wantedProperty = "";
- foreach(Item itemItm in IDENT6_LIST)
- {
- 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", "");
- string value = null;
- string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
- if((itemType == "Item" || itemType == "Generic Label Item" || itemType == "Product Label Item" || itemType == "R35" || itemType == "MSL" || itemType == "Frame" || itemType == "Certificatio") && (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))
- {
- 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))
- {
- return inn.newError("Please Look at the table");
- }
- }
- }
- else if(itemType == "Item")
- {
- int d = wantedProperty.Length;
- switch(infoType)
- {
- case "Property":
- value = finishedGood.getProperty(information, "");
- 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");
- }
- break;
- }
- }
- else if(itemType == "Generic Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- value = ourLabItem.getProperty(information);
- }
- 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))
- {
- 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)
- myStockPartId = ssd.getProperty(information);
- if(myStockPartId != null)
- {
- myStockPart = inn.getItemById("Part", myStockPartId);
- value = myStockPart.getProperty(itemInformation, "");
- }
- 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))
- {
- 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");
- if(docUsage == usage)
- {
- value = currDoc.getProperty(information);
- break;
- }
- }
- var 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 = "";
- 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))
- {
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Product Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- value = ourLabItem.getProperty(information, "");
- }
- 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))
- {
- 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 = "";
- 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");
- }
- 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");
- if(docUsage == usage)
- {
- value = currDoc.getProperty(information);
- break;
- }
- }
- var 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 = "";
- 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))
- {
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- 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 ex){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");
- }
- break;
- }
- }
- else if(itemType == "R35")
- {
- Item r35Item = null;
- string r35 = finishedGood.getProperty("mrn_plm_r35", "");
- if(r35 != "")
- {
- r35Item = inn.getItemById("mrn_plm_labeling_item", r35);
- }
- switch(infoType)
- {
- case "Property":
- if(r35Item != null)
- value = r35Item.getProperty(information, "");
- 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))
- {
- 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 = "";
- 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");
- }
- 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 = "";
- 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");
- }
- 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 = "";
- 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");
- }
- break;
- }
- }
- if (itemItm.Equals(last))
- {
- System.Diagnostics.Debugger.Break();
- id.Write(wantedProperty);
- id.Write("*");
- id.WriteLine();
- }
- }
- wantedProperty = "";
- foreach(Item itemItM in MEASURE_LIST)
- {
- 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", "");
- string labItemId = finishedGood.getProperty("mrn_plm_label_item", "");
- string value = null;
- if((itemType == "Item" || itemType == "Generic Label Item" || itemType == "Product Label Item" || itemType == "R35" || itemType == "MSL" || itemType == "Frame" || itemType == "Certificatio") && (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))
- {
- 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))
- {
- return inn.newError("Please Look at the table");
- }
- }
- }
- else if(itemType == "Item")
- {
- if(infoType == "Property")
- {
- value = finishedGood.getProperty(information, "");
- 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 if(itemType == "Generic Label Item")
- {
- switch(infoType)
- {
- case "Property":
- value = finishedGood.getProperty(information, "");
- 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");
- }
- break;
- case "ItemPropertyItem":
- value = "";
- Item myStockPart = null;
- string myStockPartId = null;
- string cItem = finishedGood.getPropertyItem("mrn_plm_label_item").getID();
- Item ssd = inn.getItemById("mrn_plm_labeling_item", cItem);
- myStockPartId = ssd.getProperty(information);
- myStockPart = inn.getItemById("Part", myStockPartId);
- if(myStockPartId == null)
- {
- return inn.newError("There is stock Item");
- }
- value = myStockPart.getProperty(itemInformation, "");
- 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");
- }
- 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");
- if(docUsage == usage)
- {
- value = currDoc.getProperty(information);
- break;
- }
- }
- var 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 = "";
- 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))
- {
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- else if(itemType == "Product Label Item")
- {
- switch(infoType)
- {
- case "Property":
- if(labItemId != "")
- {
- Item ourLabItem = inn.getItemById("mrn_plm_labeling_item", labItemId);
- value = ourLabItem.getProperty(information, "");
- }
- 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))
- {
- 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 = "";
- //if(myStockPartId == ""null"") break;
- // value = myStockPart.getProperty(itemInformation, "");
- 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");
- }
- 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");
- if(docUsage == usage)
- {
- value = currDoc.getProperty(information);
- break;
- }
- }
- var 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 = "";
- 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))
- {
- return inn.newError("Please Look at the table");
- }
- }
- break;
- }
- }
- 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 ex){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");
- }
- break;
- }
- }
- else if(itemType == "R35")
- {
- Item r35Item = null;
- string r35 = finishedGood.getProperty("mrn_plm_r35", "");
- if(r35 != "")
- {
- r35Item = inn.getItemById("mrn_plm_labeling_item", r35);
- }
- switch(infoType)
- {
- case "Property":
- if(r35Item != null)
- value = r35Item.getProperty(information, "");
- 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))
- {
- 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 = "";
- 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");
- }
- 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 = "";
- 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");
- }
- 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 = "";
- 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");
- }
- break;
- }
- }
- if (itemItM.Equals(lastMeasure))
- {
- System.Diagnostics.Debugger.Break();
- me.Write(wantedProperty);
- me.WriteLine();
- }
- }
- }
- 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