internal static Customer FromXml(XmlElement element) { var paymentconditions = new List <Paymentcondition>(); XmlNodeList elemListPaymentconditions = element.GetElementsByTagName("paymentcondition"); for (int i = 0; i < elemListPaymentconditions.Count; i++) { if (elemListPaymentconditions[i].SelectInnerText("discountdays") != null) { var paymentcondition = new Paymentcondition { Discountdays = int.Parse(elemListPaymentconditions[i].SelectInnerText("discountdays")), Discountpercentage = decimal.Parse(elemListPaymentconditions[i].SelectInnerText("discountpercentage")) }; paymentconditions.Add(paymentcondition); } } var lines = new List <Line>(); XmlNodeList elemListLine = element.GetElementsByTagName("line"); for (int i = 0; i < elemListLine.Count; i++) { if (elemListLine[i] != null) { var line = new Line { Office = elemListLine[i].SelectInnerText("office"), Dimension1 = elemListLine[i].SelectInnerText("dimension1"), Dimension2 = elemListLine[i].SelectInnerText("dimension2"), Dimension3 = elemListLine[i].SelectInnerText("dimension3"), Ratio = decimal.Parse(elemListLine[i].SelectInnerText("ratio")), Vatcode = elemListLine[i].SelectInnerText("vatcode"), Description = elemListLine[i].SelectInnerText("description") }; lines.Add(line); } } var addresses = new List <Address>(); XmlNodeList listAddress = element.GetElementsByTagName("address"); for (int i = 0; i < listAddress.Count; i++) { if (listAddress[i].FirstChild.InnerText != listAddress[i].SelectInnerText("field2")) { if (listAddress[i].SelectInnerText("name") != null) { var a = listAddress[i]; var addres = new Address { Name = a.SelectInnerText("name"), Country = a.SelectInnerText("country"), CountryName = a.SelectSingleNode("//country/@name")?.Value, City = a.SelectInnerText("city"), Postcode = a.SelectInnerText("postcode"), Telephone = a.SelectInnerText("telephone"), Telefax = a.SelectInnerText("telefax"), Email = a.SelectInnerText("email"), Contact = a.SelectInnerText("contact"), Field1 = a.SelectInnerText("field1"), Field2 = a.SelectInnerText("field2"), Field3 = a.SelectInnerText("field3"), Field4 = a.SelectInnerText("field4"), Field5 = a.SelectInnerText("field5"), Field6 = a.SelectInnerText("field6") }; addresses.Add(addres); } } } var banks = new List <Bank>(); XmlNodeList listBanks = element.GetElementsByTagName("bank"); for (int i = 0; i < listBanks.Count; i++) { if (listBanks[i] != null) { var b = listBanks[i]; var bank = new Bank { Ascription = b.SelectInnerText("ascription"), Accountnumber = b.SelectInnerText("accountnumber"), Address = new Address { Field2 = b.SelectInnerText("address/field2"), Field3 = b.SelectInnerText("address/field3") }, Bankname = b.SelectInnerText("bankname"), Biccode = b.SelectInnerText("biccode"), City = b.SelectInnerText("city"), Country = b.SelectInnerText("country"), Iban = b.SelectInnerText("iban"), Natbiccode = b.SelectInnerText("natbiccode"), Postcode = b.SelectInnerText("postcode"), State = b.SelectInnerText("state") }; banks.Add(bank); } } var postingrules = new List <Postingrule>(); XmlNodeList listPost = element.GetElementsByTagName("postingrule"); for (int i = 0; i < listPost.Count; i++) { if (listPost[i] != null) { var p = listPost[i]; var postingrule = new Postingrule { Currency = p.SelectInnerText("currency"), Amount = p.SelectInnerText("amount"), Description = p.SelectInnerText("description"), Lines = new Lines { Line = lines } }; postingrules.Add(postingrule); } } bool inuse = false; Behaviour behaviour = Behaviour.Normal; Subanalyse subanalyse = Subanalyse.False; bool payAvailable = false; bool ebilling = false; CollectionSchema collectionSchema = CollectionSchema.Core; bool vatObligatory = false; SendReminder sendReminder = SendReminder.False; bool blocked = false; bool freetext1 = false; Type type = NotImplemented.Relations.Type.Purchase; bool Fixed = false; MatchType matchType = MatchType.Notmatchable; if (element.SelectInnerText("inuse") == "true") { inuse = true; } if (element.SelectInnerText("behaviour") == Behaviour.System.ToString()) { behaviour = Behaviour.System; } if (element.SelectInnerText("behaviour") == Behaviour.Template.ToString()) { behaviour = Behaviour.Template; } if (element.SelectInnerText("financials/subanalyse") == Subanalyse.Maybe.ToString()) { subanalyse = Subanalyse.Maybe; } if (element.SelectInnerText("financials/subanalyse") == Subanalyse.True.ToString()) { subanalyse = Subanalyse.True; } if (element.SelectInnerText("financials/payavailable") == "true") { payAvailable = true; } if (element.SelectInnerText("financials/ebilling") == "true") { ebilling = true; } if (element.SelectInnerText("financials/collectionschema") == CollectionSchema.B2B.ToString()) { collectionSchema = CollectionSchema.B2B; } if (element.SelectInnerText("financials/vatobligatory") == "true") { vatObligatory = true; } if (element.SelectInnerText("creditmanagement/sendreminder") == SendReminder.True.ToString()) { sendReminder = SendReminder.True; } if (element.SelectInnerText("creditmanagement/sendreminder") == SendReminder.Email.ToString()) { sendReminder = SendReminder.Email; } if (element.SelectInnerText("creditmanagement/blocked") == "true") { blocked = true; } if (element.SelectInnerText("creditmanagement/freetext1") == "true") { freetext1 = true; } if (element.SelectSingleNode("//financials/vatcode/@type")?.Value == NotImplemented.Relations.Type.Sales.ToString().ToLower()) { type = NotImplemented.Relations.Type.Sales; } if (element.SelectSingleNode("//financials/vatcode/@fixed")?.Value == "true") { Fixed = true; } if (element.SelectInnerText("financials/matchtype") == MatchType.Matchable.ToString().ToLower()) { matchType = MatchType.Matchable; } return(new Customer { Office = element.SelectInnerText("office"), Type = element.SelectInnerText("type"), Code = element.SelectInnerText("code"), Uid = element.SelectInnerText("uid"), Name = element.SelectInnerText("name"), Shortname = element.SelectInnerText("shortname"), Inuse = inuse, Behaviour = behaviour, Touched = int.Parse(element.SelectInnerText("touched")), Beginperiod = int.Parse(element.SelectInnerText("beginperiod")), Beginyear = int.Parse(element.SelectInnerText("beginyear")), Endperiod = int.Parse(element.SelectInnerText("endperiod")), Endyear = int.Parse(element.SelectInnerText("endyear")), Website = element.SelectInnerText("website"), Cocnumber = element.SelectInnerText("cocnumber"), Vatnumber = element.SelectInnerText("vatnumber"), Editdimensionname = element.SelectInnerText("editdimensionname"), Financials = new Financials { Matchtype = matchType, Accounttype = element.SelectInnerText("financials/accounttype"), Subanalyse = subanalyse, Duedays = int.Parse(element.SelectInnerText("financials/duedays")), Level = int.Parse(element.SelectInnerText("financials/level")), Payavailable = payAvailable, Paycode = element.SelectInnerText("financials/paycode"), Ebilling = ebilling, Ebillmail = element.SelectInnerText("financials/ebillmail"), Substitutionlevel = int.Parse(element.SelectInnerText("financials/substitutionlevel")), Substitutewith = element.SelectInnerText("financials/substitutewith"), Relationsreference = element.SelectInnerText("financials/relationsreference"), Vattype = element.SelectInnerText("financials/vattype"), Vatcode = new VatCode { Name = element.SelectSingleNode("//financials/vatcode/@name")?.Value, Shortname = element.SelectSingleNode("//financials/vatcode/@shortname")?.Value, Type = type, Fixed = Fixed, }, Vatobligatory = vatObligatory, Performancetype = element.SelectInnerText("financials/performancetype"), Collectmandate = new Collectmandate { Id = element.SelectInnerText("financials/collectmandate/id"), Signaturedate = element.SelectInnerText("financials/collectmandate/signaturedate"), Firstrundate = element.SelectInnerText("financials/collectmandate/firstrundate") }, Collectionschema = collectionSchema }, Creditmanagement = new Creditmanagement { Responsibleuser = element.SelectInnerText("creditmanagement/responsibleuser"), Basecreditlimit = float.Parse(element.SelectInnerText("creditmanagement/basecreditlimit")), Sendreminder = sendReminder, Reminderemail = element.SelectInnerText("creditmanagement/remindermail"), Blocked = blocked, Freetext1 = freetext1, Freetext2 = element.SelectInnerText("creditmanagement/freetext2"), Freetext3 = element.SelectInnerText("creditmanagement/freetext3"), Comment = element.SelectInnerText("creditmanagement/comment") }, Invoicing = new Invoicing { Discountarticle = element.SelectInnerText("invoicing/discountarticle") }, Addresses = new Addresses { Address = addresses }, Banks = new Banks { Bank = banks }, Groups = new Groups { Group = element.SelectInnerText("groups/group") }, Postingrules = new Postingrules { Postingrule = postingrules }, Paymentconditions = new Paymentconditions { Paymentcondition = paymentconditions } }); }
internal static Supplier FromXml(XmlElement element) { var addresses = new List <Address>(); XmlNodeList elemListAddresses = element.GetElementsByTagName("address"); for (int i = 0; i < elemListAddresses.Count; i++) { if (!elemListAddresses[i].SelectInnerText("name").Equals(null) || !elemListAddresses[i].SelectInnerText("name").Equals("") || elemListAddresses[i].SelectInnerText("name") != null || elemListAddresses[i].SelectInnerText("name") != "") { var address = new Address { Name = elemListAddresses[i].SelectInnerText("name"), Country = elemListAddresses[i].SelectInnerText("country"), City = elemListAddresses[i].SelectInnerText("city"), Postcode = elemListAddresses[i].SelectInnerText("postcode"), Telephone = elemListAddresses[i].SelectInnerText("telephone"), Telefax = elemListAddresses[i].SelectInnerText("telefax"), Email = elemListAddresses[i].SelectInnerText("email"), Contact = elemListAddresses[i].SelectInnerText("contact"), Field1 = elemListAddresses[i].SelectInnerText("field1"), Field2 = elemListAddresses[i].SelectInnerText("field2"), Field3 = elemListAddresses[i].SelectInnerText("field3"), Field4 = elemListAddresses[i].SelectInnerText("field4"), Field5 = elemListAddresses[i].SelectInnerText("field5"), Field6 = elemListAddresses[i].SelectInnerText("field6"), }; addresses.Add(address); } } var banks = new List <Bank>(); XmlNodeList elemListBanks = element.GetElementsByTagName("bank"); for (int i = 0; i < elemListBanks.Count; i++) { if (!elemListBanks[i].SelectInnerText("ascription").Equals(null) || !elemListBanks[i].SelectInnerText("ascription").Equals("") || elemListBanks[i].SelectInnerText("ascription") != null || elemListBanks[i].SelectInnerText("ascription") != "") { var bank = new Bank { Ascription = elemListBanks[i].SelectInnerText("ascription"), Accountnumber = elemListBanks[i].SelectInnerText("accountnumber"), Address = new Address { Field2 = elemListBanks[i].SelectInnerText("address/field2"), Field3 = elemListBanks[i].SelectInnerText("address/field3") }, Bankname = elemListBanks[i].SelectInnerText("bankname"), Biccode = elemListBanks[i].SelectInnerText("biccode"), City = elemListBanks[i].SelectInnerText("city"), Country = elemListBanks[i].SelectInnerText("country"), Iban = elemListBanks[i].SelectInnerText("iban"), Natbiccode = elemListBanks[i].SelectInnerText("natbiccode"), Postcode = elemListBanks[i].SelectInnerText("postcode"), State = elemListBanks[i].SelectInnerText("state") }; banks.Add(bank); } } var paymentconditions = new List <Paymentcondition>(); XmlNodeList elemListPaymentconditions = element.GetElementsByTagName("paymentcondition"); for (int i = 0; i < elemListPaymentconditions.Count; i++) { if (!elemListPaymentconditions[i].SelectInnerText("discountdays").Equals(null) || !elemListPaymentconditions[i].SelectInnerText("discountdays").Equals("") || elemListPaymentconditions[i].SelectInnerText("discountdays") != null || elemListPaymentconditions[i].SelectInnerText("discountdays") != "") { var paymentcondition = new Paymentcondition { Discountdays = elemListPaymentconditions[i].SelectInnerText("discountdays"), Discountpercentage = elemListPaymentconditions[i].SelectInnerText("discountpercentage") }; paymentconditions.Add(paymentcondition); } } var lines = new List <Line>(); XmlNodeList elemListLine = element.GetElementsByTagName("line"); for (int i = 0; i < elemListLine.Count; i++) { if (!elemListLine[i].Equals(null) || elemListLine[i] != null || !elemListLine[i].SelectInnerText("office").Equals("") || elemListLine[i].SelectInnerText("office") != "") { var line = new Line { Office = elemListLine[i].SelectInnerText("office"), Dimension1 = elemListLine[i].SelectInnerText("dimension1"), Dimension2 = elemListLine[i].SelectInnerText("dimension2"), Dimension3 = elemListLine[i].SelectInnerText("dimension3"), Ratio = elemListLine[i].SelectInnerText("ratio"), Vatcode = elemListLine[i].SelectInnerText("vatcode"), Description = elemListLine[i].SelectInnerText("description") }; lines.Add(line); } } var postingrules = new List <Postingrule>(); XmlNodeList elemListPostingrules = element.GetElementsByTagName("postingrule"); for (int i = 0; i < elemListPostingrules.Count; i++) { if (!elemListPostingrules[i].Equals(null) || elemListPostingrules[i] != null || !elemListPostingrules[i].SelectInnerText("currency").Equals("") || elemListPostingrules[i].SelectInnerText("currency") != "") { var postingrule = new Postingrule { Currency = elemListPostingrules[i].SelectInnerText("currency"), Amount = elemListPostingrules[i].SelectInnerText("amount"), Description = elemListPostingrules[i].SelectInnerText("description"), lines = new Lines { Line = lines } }; postingrules.Add(postingrule); } } return(new Supplier { Office = element.SelectInnerText("office"), Type = element.SelectInnerText("type"), Code = element.SelectInnerText("code"), Uid = element.SelectInnerText("uid"), Name = element.SelectInnerText("name"), Shortname = element.SelectInnerText("shortname"), Inuse = element.SelectInnerText("inuse"), Behaviour = element.SelectInnerText("behaviour"), Touched = element.SelectInnerText("touched"), Beginperiod = element.SelectInnerText("beginperiod"), Beginyear = element.SelectInnerText("beginyear"), Endperiod = element.SelectInnerText("endperiod"), Endyear = element.SelectInnerText("endyear"), Website = element.SelectInnerText("website"), Cocnumber = element.SelectInnerText("cocnumber"), Vatnumber = element.SelectInnerText("vatnumber"), Editdimensionname = element.SelectInnerText("editdimensionname"), financials = new Financials { Matchtype = element.SelectInnerText("financials/matchtype"), Accounttype = element.SelectInnerText("financials/accounttype"), Subanalyse = element.SelectInnerText("financials/subanalyse"), Duedays = element.SelectInnerText("financials/duedays"), Level = element.SelectInnerText("financials/level"), Payavailable = element.SelectInnerText("financials/payavailable"), Meansofpayment = element.SelectInnerText("financials/meansofpayment"), Paycode = element.SelectInnerText("financials/paycode"), Ebilling = element.SelectInnerText("financials/ebilling"), Ebillmail = element.SelectInnerText("financials/ebillmail"), Substitutionlevel = element.SelectInnerText("financials/substitutionleven"), Substitutewith = element.SelectInnerText("financials/substitutewtith"), Relationsreference = element.SelectInnerText("financials/relationsreference"), Vattype = element.SelectInnerText("financials/vattype"), Vatcode = element.SelectInnerText("financials/vatcode"), Vatobligatory = element.SelectInnerText("financials/vatobligatory"), Performancetype = element.SelectInnerText("financials/performancetype"), Collectmandate = new Collectmandate { Id = element.SelectInnerText("financials/collectmandate/id"), Signaturedate = element.SelectInnerText("financials/collectmandate/signaturedate"), Firstrundate = element.SelectInnerText("financials/collectmandate/firstrundate") }, Collectionschema = element.SelectInnerText("financials/collectionschema"), Childvalidations = new Childvalidations { Childvalidation = element.SelectInnerText("financials/childvalidations/childvalidation") } }, addresses = new Addresses { Address = addresses }, groups = new Groups { Group = element.SelectInnerText("groups/group") }, banks = new Banks { Bank = banks }, paymentconditions = new Paymentconditions { Paymentcondition = paymentconditions }, postingrules = new Postingrules { Postingrule = postingrules } }); }