-3

次のコードに問題があります。以前に作成したものと異なる場合にのみ、新しい pcba ノードを作成する必要があります。その変数が変わらない場合は、同じ変数で作業する必要があります。

foreach (XmlNode node in dc.DocumentElement.ChildNodes)
            {
                PCBA pcb = null;

                if (serialPCB != node.Attributes["PCBpos"].Value.ToString())
                    pcb = new PCBA();

                pcb.PCBA_Status = status;
                long number = 0;
                bool validation = false;
                if (node.Attributes != null && node.Attributes["PCBpos"] != null)
                  {
                    validation = long.TryParse(node.Attributes["PCBpos"].Value, out number);
                  }
                 //bool validation = long.TryParse(node.Attributes["PCBpos"].Value, out number);
                if (validation == true)
                {
                    pcb.PCBA_POSITION = node.Attributes["PCBpos"].Value.ToString();
                    serialPCB = node.Attributes["PCBpos"].Value.ToString();

                    if (status != "PASS")
                    {
                        List<Group> groups = new List<Group>();
                        Group group = new Group();

                        group.Group_Name = node.Attributes["COMP_NAME"].Value.ToString();
                        group.Group_Status = status;
                        group.Group_FailureCode = node.Attributes["FaultName"].Value.ToString();

                        List<Measurement> measurements = new List<Measurement>();
                        Measurement measurement = new Measurement();
                        measurement.Measurement_Name = node.Attributes["COMP_NAME"].Value.ToString();
                        measurement.Measurement_Status = status;
                        DirectoryInfo di = new DirectoryInfo(dc.DocumentElement.Attributes["LOCATION"].Value.ToString());
                        var ruta = di.GetFiles(node.Attributes["COMP_NUMBER"].Value.ToString() + "-*");
                        if (ruta.Length > 0)
                            measurement.Measurement_ImagePath = di + "\\" + ruta[0].ToString();
                        measurements.Add(measurement);
                        group.Measurements = measurements;
                        groups.Add(group);
                        pcb.Groups = groups;
                    }

                    pcbas.Add(pcb);
                }
            }
4

1 に答える 1