public List <Drive> SortingUser([FromBody] UserSort k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drivers.xml"); List <Driver> listaDrivers = xml.ReadDrivers(ss); List <Drive> listaDrives = k.Driv;//xml.ReadDrives(ss); List <Drive> listaDrives1 = new List <Drive>(); if (k.PoCemu == 0) { listaDrives1 = listaDrives.OrderByDescending(o => o.Comment.Rating).ToList(); } else if (k.PoCemu == 1) { listaDrives1 = listaDrives.OrderByDescending(o => DateTime.Parse(o.DataAndTime)).ToList(); } else if (k.PoCemu == 2) { Point po = new Point(); foreach (Driver driv in listaDrivers) { if (driv.UserName == k.Username) { po.X = Double.Parse(driv.Location.X); po.Y = Double.Parse(driv.Location.Y); } } ClosestDistance cd = new ClosestDistance(); listaDrives1 = cd.OrderByDistanceForDrivers(listaDrives, po); } return(listaDrives1); }
public PlayerControl GetTarget(bool Active) { var Infected = ZombieRole.INSTANCE.Infected; PlayerTools.CalculateClosest(PlayerControl.LocalPlayer, out var ClosestPlayer, out var ClosestDistance, SomePlayer => !Infected.Contains(SomePlayer.PlayerId)); return(Active && ClosestDistance.IsInKillRange() ? ClosestPlayer : null); }
public List <string> ProcessDrive([FromBody] KomentarVozacPrenos k) { Drive por = new Drive(); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drives.xml"); string drv = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drivers.xml"); string adm = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Admins.xml"); List <Dispatcher> dispatchers = xml.ReadDispatcher(adm); List <Drive> drives = xml.ReadDrives(ss1); List <Driver> drivers = xml.ReadDrivers(drv); ClosestDistance cd = new ClosestDistance(); Driver driver = new Driver(); Dispatcher dispacer = new Dispatcher(); List <Tuple <Point, string> > proslediListu = new List <Tuple <Point, string> >(); foreach (Driver d in drivers) { if (!d.Blocked && !d.Zauzet && (d.Car.CarType == k.voz.CarType)) { Point poi = new Point(); poi.X = Double.Parse(d.Location.X); poi.Y = Double.Parse(d.Location.Y); proslediListu.Add(new Tuple <Point, string>(poi, d.UserName)); } } List <string> najblizi = new List <string>(); if (proslediListu.Any()) { Point ip = new Point(); ip.X = Double.Parse(k.voz.Arrival.X); ip.Y = Double.Parse(k.voz.Arrival.Y); najblizi = cd.OrderByDistance(proslediListu, ip); } return(najblizi); }
public List <string> AddDriveDispatcher([FromBody] DriveR k) { ClosestDistance closest = new ClosestDistance(); string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Users.xml"); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drives.xml"); string adm = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Admins.xml"); string drv = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drivers.xml"); List <Dispatcher> users = xml.ReadDispatcher(adm); List <Drive> drives = xml.ReadDrives(ss1); List <Driver> drivers = xml.ReadDrivers(drv); User c = new Dispatcher(); Drive drive = new Drive(); List <Tuple <Point, string> > proslediListu = new List <Tuple <Point, string> >(); foreach (Driver d in drivers) { if (!d.Blocked && !d.Zauzet && (d.Car.CarType == (Enums.CarType) int.Parse(k.tipAuta))) { Point poi = new Point(); poi.X = Double.Parse(d.Location.X); poi.Y = Double.Parse(d.Location.Y); proslediListu.Add(new Tuple <Point, string>(poi, d.UserName)); } } List <string> najblizi = new List <string>(); if (!proslediListu.Any()) { foreach (Dispatcher u in users) { if (u.UserName == k.korisnicko) { c = u; Address a = new Address(k.Street); Location l = new Location(k.XCoord, k.YCoord, a); drive.Customer = new Customer(); drive.Arrival = l; if (k.tipAuta != "") { drive.CarType = (Enums.CarType) int.Parse(k.tipAuta); } drive.Amount = 0; drive.Comment = new Comment(); drive.DataAndTime = String.Format("{0:F}", DateTime.Now); drive.Destination = new Location(); drive.Dispatcher = (Dispatcher)c; drive.Driver = new Driver(); drive.Status = Enums.DriveStatus.Created_Waiting; break; } } drives.Add(drive); xml.WriteDrives(drives, ss1); } else { Point ip = new Point(); ip.X = Double.Parse(k.XCoord); ip.Y = Double.Parse(k.YCoord); najblizi = closest.OrderByDistance(proslediListu, ip); } return(najblizi); }