public cVehicle(string pNazivSkupine, string pTypeID, string pTRR, List <cType> pTypes, int pNumberOfExistsingCars = 0) { //pNazivSKupine ne treba kak paramtere-> prek key-a za prijavo id==serijskastevilka string lNule = ""; switch (pNumberOfExistsingCars.ToString().Length) { case 1: lNule = "0000"; break; case 2: lNule = "000"; break; case 3: lNule = "00"; break; case 4: lNule = "0"; break; default: break; } cType lType = pTypes.Find(x => x.Id == pTypeID); if (lType != null) { serijskaStevilka = pNazivSkupine + "_" + lType.Name + "_" + "_" + lNule + (pNumberOfExistsingCars + 1).ToString(); } else { throw new Exception("Tip vozila ne obstaja pri dodajanju"); } type = lType; personID = pTRR; }
public static void LoadTypesFromXML(ref List <cType> pTypes) { if (pTypes != null) { if (pTypes.Count > 0) { return; } } if (pTypes == null) { pTypes = new List <cType>(); } string lPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; lPath += "\\Files\\joined_vtypes.add.xml"; if (File.Exists(lPath)) { XmlDocument lDoc = new XmlDocument(); lDoc.Load(lPath); int lID_Addon = 1; foreach (XmlNode lNode in lDoc.DocumentElement.ChildNodes) { if (lNode.OuterXml.Contains("private")) { foreach (XmlElement lElement in lNode) { cType lType; string lNameStrr = lElement.OuterXml; lNameStrr = Regex.Split(Regex.Split(lNameStrr, "id=\"")[1], "\"")[0]; if (lNameStrr.Contains("passenger5")) { lType = new cType(lNameStrr, "Taxi"); } else if (lNameStrr.Contains("passenger3")) { lType = new cType(lNameStrr, "Share-a-Car"); } else { lType = new cType(lNameStrr, "OsebnoVozilo" + lID_Addon); lID_Addon++; } pTypes.Add(lType); } } else if (lNode.OuterXml.Contains("ignoring")) { continue; } else { string lNameStrr = lNode.OuterXml; lNameStrr = Regex.Split(Regex.Split(lNameStrr, "id=\"")[1], "\"")[0]; pTypes.Add(new cType(lNameStrr, lNameStrr)); } } } else { cNonServiceLogic.ThrowNapaka(new StackTrace().GetFrame(1).GetMethod().Name, "Ne obstaja datoteka!"); } }