public Int32 FindPlace() { int max = 0; for (Int32 i = 0; i < Places.Count; i++) { if (!Places.Contains(i)) { Places.Add(i); return(i); } if (max < i) { max = i; } } if (max < Capasity) { Places.Add(max); return(max); } else { throw new ArgumentException("Parking if out of free space"); } }
public Car GetCar(Int32 i) { if (Places.Contains(i)) { Places.Remove(i); TimeSpan time = DateTime.Now.Subtract(Time[i]); int t = Convert.ToInt32(time.TotalSeconds) / 3600; if (t == 0) { Console.WriteLine("You have to pay 10$"); } else { Console.WriteLine($"You have to pay {t + 10}$"); } Car car = Cars[i]; Time.Remove(i); Cars.Remove(i); return(car); } else { throw new Exception("There is no car with this number"); } }
public IEnumerable <ICityRoad> GetRoadsFrom(ICityPlace cityPlace) { if (!Places.Contains(cityPlace)) { throw new ArgumentException("Местоположение не принадлжеит городу."); } return(Roads .Where(x => x.FirstPlace == cityPlace || x.SecondPlace == cityPlace) .Distinct()); }
public void AddPlace(Place placeToAdd) { if (Places.Any(x => x.Id.Equals(placeToAdd.Id))) { throw new ArgumentException($"Id: {placeToAdd.Id} cannot be the same for two places"); } if (Places.Contains(placeToAdd)) { throw new ArgumentException($"You already add {placeToAdd}"); } Places.Add(placeToAdd); }
static void SetOnlineStatus(string _guid) // TODO { foreach (Timers item in Maps.MapsGroup.TIMERS) { if (_guid == item.m_Guid) { if (Processes.Contains(item.m_Process) || Places.Contains(item.m_PlacePath) || Sites.Contains(item.m_Site)) { return; } item.waitTime = DateTime.UtcNow.AddSeconds(item.secToWait).ToLocalTime().ToShortTimeString(); item.m_Status = "waitonline"; item.waitOnline_timer.Start(); if (item.doc == MMUtils.ActiveDocument) { item.refresh = true; // for refreshIndicator_timer } } } }
public static string CheckInternetAndProcess( string _guid, string _storage, string _process, string _site, string _placepath, string _cause) { // For cloud storages if (_process != "") { if (CloudProcessLaunched(_process, _storage)) { if (Processes.Contains(_process)) { Processes.Remove(_process); if (_cause != "publish") { SetOnlineStatus(_guid); } } } else { if (Processes.Contains(_process)) { if (_cause == "publish") { return("processfail"); } else { return(""); // не дергаться, потому что как было, так и есть } } else { Processes.Add(_process); if (_cause != "publish") { SetOfflineStatus(_guid, "process"); } return("processfail"); } } } // For cloud and network if (_placepath != "") { if (System.IO.Directory.Exists(_placepath)) { if (Places.Contains(_placepath)) { Places.Remove(_placepath); if (_cause != "publish") { SetOnlineStatus(_guid); } } } else { if (Places.Contains(_placepath)) { if (_cause == "publish") { return("processfail"); } else { return(""); // не дергаться, потому что как было, так и есть } } else { Places.Add(_placepath); if (_cause != "publish") { SetOfflineStatus(_guid, "place"); } return("placefail"); } } } // For cloud storages if (_site == "") // todo! { if (InternetConnection(_site)) { if (Sites.Contains(_site)) { Sites.Remove(_site); if (_cause != "publish") { SetOnlineStatus(_guid); } } } else { if (Sites.Contains(_site)) { if (_cause == "publish") { return("processfail"); } else { return(""); // не дергаться, потому что как было, так и есть } } else { Sites.Add(_site); if (_cause != "publish") { SetOfflineStatus(_guid, "site"); } return("sitefail"); } } } return(""); }
public bool Contains(PlaceOfInterest place) { return(Places.Contains(place)); }