Exemple #1
0
 public void AddPartNesting(part_nesting pn)
 {
     list_parts_nesting.Add(pn);
 }
Exemple #2
0
        public void E(IEnumerable <XElement> elements)
        {
            // перебираем все дочерние элементы
            foreach (XElement tr in elements)
            {
                switch (Convert.ToString(tr.Name))
                {
                case  "data_order":

                    Atr(tr.Attributes(), "data_order");
                    break;

                case "list_materials":
                    //  l_m = new List<Material>();
                    break;

                case  "material":

                    m = new Material();

                    Atr(tr.Attributes(), "material");
                    l_m.Add(m);
                    break;


                case "list_parts":
                    if (tr.Parent.Name == "material")
                    {
                        L_p = new List <part>();
                    }
                    else if (tr.Parent.Name == "nesting_plan")
                    {
                        partnesting = new List <part_nesting>();
                    }
                    break;

                case  "part":
                    if (tr.Parent.Parent.Name == "material")
                    {
                        count_p = count_p + 1;
                        //  part_z = new part();
                        Atr(tr.Attributes(), "part");
                        L_p.Add(part_z);
                    }
                    else if (tr.Parent.Parent.Name == "nesting_plan")
                    {
                        pnest = new part_nesting();
                        Atr(tr.Attributes(), "part_n");
                        partnesting.Add(pnest);
                    }
                    break;

                case  "list_nesting_plans":
                    N_p = new List <nesting_plan>();
                    break;

                case "nesting_plan":
                    np = new nesting_plan();
                    Atr(tr.Attributes(), "nesting_plan");
                    N_p.Add(np);
                    break;
                }

                if (tr.HasElements)
                {
                    E(tr.Elements());
                }
            }
        }
Exemple #3
0
        public data_order D()
        {
            order.name = (string)xd.Root.Element("data_order").FirstAttribute;
            foreach (XElement elem in xd.Root.Element("data_order").Element("list_materials").Elements())
            {
                Material mat = new Material();
                foreach (XAttribute u in elem.Attributes())
                {
                    switch (Convert.ToString(u.Name))
                    {
                    case "name":
                        mat.name = (string)u;
                        break;

                    case "index":
                        mat.index = (int)u;
                        break;

                    case "type":
                        mat.type = (string)u;
                        break;

                    default:
                        break;
                    }
                }
                foreach (XElement u1 in elem.Element("list_parts").Elements())
                {
                    part part1 = new part();
                    foreach (XAttribute atr in u1.Attributes())
                    {
                        switch (Convert.ToString(atr.Name))
                        {
                        case "length":
                            part1.Length = (int)atr;
                            break;

                        case "width":
                            part1.width = (int)atr;
                            break;

                        case "thick":
                            part1.thick = (int)atr;
                            break;

                        case "quantity":
                            part1.quantitu = (int)atr;
                            break;

                        default:
                            break;
                        }
                    }
                    mat.AddItem(part1);
                }

                XElement xe = elem.Elements().First(r => r.Name == "list_nesting_plans");

                foreach (XElement u2 in xe.Elements())
                {
                    nesting_plan plan = new nesting_plan();
                    foreach (XAttribute atr in u2.Attributes())
                    {
                        switch (Convert.ToString(atr.Name))
                        {
                        case "width":
                            plan.width = (int)atr;
                            break;

                        case "length":
                            plan.length = (int)atr;
                            break;

                        case "thick":
                            plan.thick = (int)atr;
                            break;

                        case "quantity":
                            plan.quantitu = (int)atr;
                            break;

                        default:
                            break;
                        }
                    }

                    XElement list_part_n = u2.Element("list_parts");
                    foreach (XElement elem_part in list_part_n.Elements())
                    {
                        part_nesting part_n = new part_nesting();
                        foreach (XAttribute atr_p in elem_part.Attributes())
                        {
                            switch (Convert.ToString(atr_p.Name))
                            {
                            case "number":
                                part_n.Number = (int)atr_p;
                                break;

                            case "length":
                                part_n.Length = (int)atr_p;
                                break;

                            case "width":
                                part_n.width = (int)atr_p;
                                break;

                            case "x":
                                part_n.x = (int)atr_p;
                                break;

                            case "y":
                                part_n.y = (int)atr_p;
                                break;
                            }
                        }

                        plan.AddPartNesting(part_n);
                    }
                    mat.AddNesting(plan);
                }
                order.AddMat(mat);
            }
            return(order);
        }