public List <Voznja> SortingUser([FromBody] KorisnikSort k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml"); List <Vozac> lv = xml.ReadDrivers(ss); List <Voznja> listaDrives = k.Drivess; List <Voznja> sortiranaVoznja = new List <Voznja>(); if (k.PoCemu == 0) { sortiranaVoznja = listaDrives.OrderByDescending(o => o.Kom.Ocena).ToList(); } else if (k.PoCemu == 1) { sortiranaVoznja = listaDrives.OrderByDescending(o => DateTime.Parse(o.DatumIVremePorudzbine)).ToList(); } else if (k.PoCemu == 2) { Point np = new Point(); foreach (Vozac v in lv) { if (v.KorisnickoIme == k.Username) { np.X = Double.Parse(v.Lok.Xkoordinate); np.Y = Double.Parse(v.Lok.Ykoordinate); break; } } NajkracaUdaljenost nu = new NajkracaUdaljenost(); sortiranaVoznja = nu.OrderByDistanceZaVoz(listaDrives, np); } return(sortiranaVoznja); }
public List <string> AddDriveDispecer([FromBody] VoznjaPomocna k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml"); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Voznje.xml"); string ss2 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml"); List <Dispecer> users = xml.ReadDispecer(ss); List <Voznja> drives = xml.ReadDrives(ss1); List <Vozac> vozaci = xml.ReadDrivers(ss2); bool g = true; Korisnik c = new Dispecer(); Voznja drive = new Voznja(); List <Tuple <Point, string> > prosledi = new List <Tuple <Point, string> >(); foreach (Vozac v in vozaci) { if (!v.Zauzet && v.Auto.TA == (Enums.TipAutomobila) int.Parse(k.tipAuta) && !v.Blokiran) { Point pos = new Point(Double.Parse(v.Lok.Xkoordinate), Double.Parse(v.Lok.Ykoordinate)); prosledi.Add(new Tuple <Point, string>(pos, v.KorisnickoIme)); } } NajkracaUdaljenost nk = new NajkracaUdaljenost(); List <string> ret = new List <string>(); if (!prosledi.Any()) { foreach (Dispecer u in users) { if (u.KorisnickoIme == k.korisnicko) { c = u; Adresa a = new Adresa(k.Street); Lokacija l = new Lokacija(k.XCoord, k.YCoord, a); drive.Mus = new Musterija(); drive.LokacijaZaDolazak = l; if (k.tipAuta != "") { drive.TipAuta = (Enums.TipAutomobila) int.Parse(k.tipAuta); } drive.Iznos = 0; drive.Kom = new Komentar(); drive.DatumIVremePorudzbine = String.Format("{0:F}", DateTime.Now);; drive.Odrediste = new Lokacija(); drive.Disp = (Dispecer)c; drive.Stat = Enums.StatusVoznje.Kreirana_NaCekanju; drive.Voz = new Vozac(); break; } } drives.Add(drive); xml.WriteDrives(drives, ss1); } else { ret = nk.OrderByDistance(prosledi, new Point(Double.Parse(k.XCoord), Double.Parse(k.YCoord))); } return(ret); }
public List <string> ObradiVoznju([FromBody] VozacevKomentar k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Voznje.xml"); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml"); string ss2 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml"); List <Voznja> lista = xml.ReadDrives(ss); List <Vozac> lv = xml.ReadDrivers(ss1); List <Dispecer> dispi = xml.ReadDispecer(ss2); Dispecer dispecer = new Dispecer(); Vozac vozacsl = new Vozac(); Voznja voznja = new Voznja(); List <Tuple <Point, string> > prosledi = new List <Tuple <Point, string> >(); foreach (Vozac v in lv) { if (!v.Zauzet && v.Auto.TA == k.Voz.TipAuta && !v.Blokiran) { Point pos = new Point(Double.Parse(v.Lok.Xkoordinate), Double.Parse(v.Lok.Ykoordinate)); prosledi.Add(new Tuple <Point, string>(pos, v.KorisnickoIme)); } } NajkracaUdaljenost nk = new NajkracaUdaljenost(); List <string> ret = new List <string>(); if (!prosledi.Any()) { return(new List <string>()); } else { ret = nk.OrderByDistance(prosledi, new Point(Double.Parse(k.Voz.LokacijaZaDolazak.Xkoordinate), Double.Parse(k.Voz.LokacijaZaDolazak.Ykoordinate))); } return(ret); }