How to convert an item to List ?

Hello,

I'm working with ARAS for few years now. I'm sending AML queries and receiving ITEMS back. Every case requires a new method of deciphering the data using getProperty or getPropertyItem calls. 

Is there any way to convert any item to array or list?

Regards

OCohen 

Parents
  • Hi Ocohen,

    could you explain your use case a little more, please? Do you want to convert an Item (collection) to an object of type List<Item>, where each member is an Item with item count 1 (although I'm not sure this would yield much of a benefit)? Or a single item to a List of some other type? Or am I misunderstanding your question?

    It would also help to know what you want to achieve by this conversion, i.e. what you want to make easier with it.

    Cheers,

    C

Reply
  • Hi Ocohen,

    could you explain your use case a little more, please? Do you want to convert an Item (collection) to an object of type List<Item>, where each member is an Item with item count 1 (although I'm not sure this would yield much of a benefit)? Or a single item to a List of some other type? Or am I misunderstanding your question?

    It would also help to know what you want to achieve by this conversion, i.e. what you want to make easier with it.

    Cheers,

    C

Children
  • Hello,

    Thank you for the propt response.

    I am implementing a data verification and measurement subsystem.

    We implemented data delivery system from the PLM to out ERP. The data verification subsystem checks the Part BOM table agains the ERP BOM table to identify delivery issues.

    The measurement subsystem is a sort of BI, that collects data from the ARAS as well as from the ERP and other data bases, manipulates them and create data for statistical processes.

    The other applications does not use XML or similar protocols. As I had to  manipulate data from all of them, I select List<string[]> as the basis object structure; I convert data from all the DBs into this object type and manipulate it. Then I'm preparing the output data from thse objects.

    The following is an example of converting method, which is used widely; however, thre are instances that this method doesn't work, and I have specialized methods.

    The header input parameter is a list of the fields read from the PLM, serving as the columns names of the output table

    private List<string[]> itemToList(Item results, string[] header, out string err)
    {
    err = "";
    List<string[]> localClassList = new List<string[]>();
    // Convert the data received from the PLM into List <string[]>
    int resultsRowsCount = results.getItemCount();
    List<string> distinct = new List<string>();
    for (int rowPtr = 0; rowPtr < resultsRowsCount; rowPtr++)
    {
    Item itemTemp = results.getItemByIndex(rowPtr); // Exception will be caught in higher level
    if (itemTemp != null)
    {
    List<string> strArray = new List<string>();
    // Convert the data item by item according to the field names packed in HEADER.
    for (int i = 0; i < header.Length; i++)
    {
    string[] headerParts = header[i].Split('|');
    if (headerParts.Length == 1)
    strArray.Add(itemTemp.getProperty(header[i].Trim(), ""));
    else
    {
    Item it = itemTemp.getPropertyItem(headerParts[0]);
    if (it != null)
    strArray.Add(it.getProperty(headerParts[1].Trim(), ""));
    }
    }
    if (!distinct.Contains(strArray[0]))
    {
    distinct.Add(strArray[0]);
    localClassList.Add(strArray.ToArray());
    }
    }
    }
    return localClassList;
    }