public bool RemoveEvent(BoxItem box, EventType eventType) { EventListItem delItem = DataList.FirstOrDefault(eventListItem => eventListItem.Box.Identifier == box.Identifier && eventListItem.EventType == eventType); if (delItem != null) { DataList.Remove(delItem); return true; } return false; }
public EventListItem(EventType eventType, BoxItem box, DateTime time) { EventType = eventType; Box = box; Time = time; }
public void GettingThingsReady() { FutureEventList = new FutureEventList(); var currentArrival = new DateTime(2012, 12, 19, 8, 0, 0, 0); // Future Event List! All Arrivals! // First Box TimeSpan firstServiceTime = TimeSpan.FromMinutes((int) SimpleRng.GetNormal(9, 2)); var firstbox = new BoxItem(currentArrival, Priority.Normal, firstServiceTime); Guid g = Guid.NewGuid(); string guidString = Convert.ToBase64String(g.ToByteArray()); guidString = guidString.Replace("=", ""); guidString = guidString.Replace("+", ""); firstbox.Identifier = guidString; FutureEventList.PushEvent(new EventListItem(EventType.Arrival, firstbox, currentArrival)); // Special Boxes // Special Boxes Arrives every hour double allSpecialBoxes = _totalTime.TotalMinutes/60; int counter = 1; while (counter <= allSpecialBoxes) { TimeSpan arrivalTime = TimeSpan.FromMinutes(counter*60); TimeSpan serviceTime = TimeSpan.FromMinutes((int) SimpleRng.GetNormal(16, 3)); var currentBox = new BoxItem(currentArrival + arrivalTime, Priority.High, serviceTime); g = Guid.NewGuid(); guidString = Convert.ToBase64String(g.ToByteArray()); guidString = guidString.Replace("=", ""); guidString = guidString.Replace("+", ""); currentBox.Identifier = guidString; FutureEventList.PushEvent(new EventListItem(EventType.Arrival, currentBox, currentArrival + arrivalTime)); _totalTime = _totalTime.Subtract(serviceTime); counter++; } // Normal Priority Boxes! | All Arrivals! while (_totalTime.TotalMinutes > 0) { var arriveTime = (int) SimpleRng.GetNormal(14, 4); TimeSpan serviceTime = TimeSpan.FromMinutes((int) SimpleRng.GetNormal(9, 2)); currentArrival += TimeSpan.FromMinutes(arriveTime); var currentBox = new BoxItem(currentArrival, Priority.Normal, serviceTime); g = Guid.NewGuid(); guidString = Convert.ToBase64String(g.ToByteArray()); guidString = guidString.Replace("=", ""); guidString = guidString.Replace("+", ""); currentBox.Identifier = guidString; FutureEventList.PushEvent(new EventListItem(EventType.Arrival, currentBox, currentArrival)); _totalTime = _totalTime.Subtract(serviceTime); //counter = counter.Add(serviceTime); } }