public void ClearHandler(Object obj, EventArgs e) { _baseTrackingDevice = null; _associateTrackingDeviceButton.Enabled = true; _trackingDeviceLabel.Text = ""; _itemsPrenotation.Clear(); _itemPrenotationListView.Clear(); _packets.Clear(); _packetListView.Clear(); _bundles.Clear(); _bundleListView.Clear(); _createButton.Enabled = false; _clearButton.Enabled = false; _desc = null; }
public UsageService(DateTime when, ITrackingDevice who, IUsable type) { if (when == null) { throw new ArgumentException("when is not valid"); } _when = when; if (who == null) { throw new ArgumentException("who is not valid"); } _who = who; if (type == null) { throw new ArgumentException("type is not valid"); } _type = type; }
public void ReleaseTrackingDevice(ITrackingDevice td) { #region Precondizioni. if (td == null) { throw new ArgumentNullException("td null"); } if (_availables.Contains(td)) { throw new InvalidOperationException("Il device è già disponibile all'uso"); } if (!_booked.ContainsKey(td)) { throw new InvalidOperationException("Il device non è associata a nessuna prenotazione"); } #endregion _booked.Remove(td); _availables.Enqueue(td); }
public void RemoveTrackingDevice(ITrackingDevice badTd) { #region Precondizioni if (!_availables.Contains(badTd)) { throw new InvalidOperationException("Il tracking device non è presente nella coda delle disponibili"); } if (_notAvailables.Contains(badTd)) { throw new InvalidOperationException("Il tracking device è già stato rimosso"); } #endregion IEnumerable <ITrackingDevice> goodTd = from currentTd in _availables where currentTd != badTd select currentTd; _availables = new Queue <ITrackingDevice>(goodTd); _notAvailables.Add(badTd); }
public void AddTrackingDevice(ITrackingDevice trackingDevice, AssociationDescriptor associationDescriptor) { #region Precondizioni if (trackingDevice == null) { throw new ArgumentNullException("tracking device null"); } if (associationDescriptor == null) { throw new ArgumentNullException("association Descriptor null"); } if (!PrenotationDate.Contains(associationDescriptor.DateRange)) { throw new Exception("date range not valid"); } #endregion _tdAssociations.Add(trackingDevice, associationDescriptor); OnPrenotatitionChangedHandler(this, new PrenotationEventArgs(this)); }
public void AddTrackingDeviceButtonHandler(Object obj, EventArgs e) { DateRange range = new DateRange(_fromDateTimePicker.Value, _toDateTimePicker.Value); using (StringDialog sd = new StringDialog("Nome da associare a prenotazione base: ")) { if (sd.ShowDialog() == DialogResult.OK) { string name = sd.Response; if (name != null) { _desc = new AssociationDescriptor(range, name); } } else { return; } } if (_desc == null) { _desc = new AssociationDescriptor(range, "Base"); } try { _baseTrackingDevice = _tdCoord.Next; }catch (Exception exception) { MessageBox.Show("Non è possibile recuperare un tracking device. Chiedi allo staff"); _view.Close(); return; } _trackingDeviceLabel.Text = _desc.InformationString + " -> " + _baseTrackingDevice.Id; _associateTrackingDeviceButton.Enabled = false; if (CanCreate()) { _createButton.Enabled = true; } _clearButton.Enabled = true; }
public void AddTrackingDevice(ITrackingDevice td) { #region Precondizioni if (td == null) { throw new ArgumentNullException("td null"); } if (_availables.Contains(td)) { throw new InvalidOperationException("td è già presente nel sistema"); } if (_booked.Keys.Contains(td)) { throw new InvalidOperationException("td è già presente nel sistema"); } if (_notAvailables.Contains(td)) { throw new InvalidOperationException("td è già presente nel sistema"); } #endregion _availables.Enqueue(td); }
public IEnumerable <IUsage> FilterCard(ITrackingDevice card) { return(_usages.Where(usage => usage.Who.Id == card.Id)); }
public UsageMock(DateTime when, ITrackingDevice who, IUsable type) { _when = when; _who = who ?? throw new ArgumentNullException("who null"); _type = type ?? throw new ArgumentNullException("type null"); }
protected override void Init() { base.Init(); /* Cerco un file di configurazione delle prenotation nel fileSystem, * se lo trovo carico le prenotation contenute */ /* Prenotations HardCoded */ StructureCoordinator sectorCoord = CoordinatorManager.Instance.CoordinatorOfType <StructureCoordinator>(); Sector mySector = sectorCoord.GetSectorIn("Stabilimento Bologna Via Mario Longhena", "Spiaggia", "Settore base"); Sector mySectorVip = sectorCoord.GetSectorIn("Stabilimento Bologna Via Mario Longhena", "Spiaggia", "Settore vip"); BookingCoordinator bookCoord = CoordinatorManager.Instance.CoordinatorOfType <BookingCoordinator>(); IBookableItem myBookableItem = bookCoord.GetBookableItem(mySector, new Position(1, 3)); IBookableItem myBookableItemVip = bookCoord.GetBookableItem(mySectorVip, new Position(1, 1)); DateRange myRange1 = new DateRange(30); DateRange myRange2 = new DateRange(new DateTime(2017, 08, 10), new DateTime(2017, 08, 15)); ICustomizableItemPrenotation myIItemPrenotation1 = new CustomizableItemPrenotation(myRange1, myBookableItem); ICustomizableItemPrenotation myIItemPrenotation2 = new CustomizableItemPrenotation(myRange2, myBookableItemVip); IItemCoordinator itemCoord = CoordinatorManager.Instance.CoordinatorOfType <IItemCoordinator>(); IItem lettino = itemCoord.GetAssociableItemOf(myBookableItem.BaseItem).First(); myIItemPrenotation1.AddPlugin(lettino, myRange1); myIItemPrenotation1.AddPlugin(lettino, new DateRange(myRange1.StartDate, myRange1.EndDate.AddDays(-2))); IItem lettinoVip = itemCoord.GetAssociableItemOf(myBookableItemVip.BaseItem).First(); IItem lettinoBase = itemCoord.GetAssociableItemOf(myBookableItemVip.BaseItem).ElementAt(1); myIItemPrenotation2.AddPlugin(lettinoVip, myRange2); myIItemPrenotation2.AddPlugin(lettinoBase, myRange2); myIItemPrenotation2.AddPlugin(lettinoBase, myRange2); myIItemPrenotation2.AddPlugin(lettinoBase, myRange2); myIItemPrenotation2.AddPlugin(lettinoBase, myRange2); List <ICustomizableItemPrenotation> myItems = new List <ICustomizableItemPrenotation>(); myItems.Add(myIItemPrenotation1); List <ICustomizableItemPrenotation> myItems2 = new List <ICustomizableItemPrenotation>(); myItems2.Add(myIItemPrenotation2); ITrackingDeviceCoordinator tdCoord = CoordinatorManager.Instance.CoordinatorOfType <TrackingDeviceCoordinator>(); ITrackingDevice myCard = tdCoord.Next; IUserCoordinator userCoord = CoordinatorManager.Instance.CoordinatorOfType <UserCoordinator>(); ICustomer client = userCoord.Customers.Where(c => c.FiscalCode.Equals("CC3")).First(); CustomizableServizablePrenotation myPrenotation = new CustomizableServizablePrenotation(client, myRange1, myItems, myCard, new AssociationDescriptor(myRange1, "CardBase")); tdCoord.LockTrackingDevice(myPrenotation); ITrackingDevice myCard2 = tdCoord.Next; CustomizableServizablePrenotation myPrenotation2 = new CustomizableServizablePrenotation(client, myRange2, myItems2, myCard2, new AssociationDescriptor(myRange2, "CardBase")); tdCoord.LockTrackingDevice(myPrenotation2); ServiceCoordinator serviceCoord = CoordinatorManager.Instance.CoordinatorOfType <ServiceCoordinator>(); myPrenotation.AddPacket(serviceCoord.Packets.ElementAt(0)); myPrenotation.AddBundle(serviceCoord.Bundles.ElementAt(0)); _prenotations.Add(myPrenotation); _prenotations.Add(myPrenotation2); }
public CustomizableServizablePrenotation(ICustomer client, DateRange rangeData, IEnumerable <IItemPrenotation> items, ITrackingDevice baseTrackingDevice, AssociationDescriptor tdDesc, IEnumerable <IBundle> bundles) : this(client, rangeData, items, baseTrackingDevice, tdDesc, null, bundles) { }
public CustomizableServizablePrenotation(ICustomer client, DateRange prenotationDate, IEnumerable <IItemPrenotation> items, ITrackingDevice baseTrackingDevice, AssociationDescriptor tdDesc, IEnumerable <IPacket> packets = null, IEnumerable <IBundle> bundles = null) { #region Precondizioni if (prenotationDate == null) { throw new ArgumentNullException("range data null"); } if (client == null) { throw new ArgumentNullException("client null"); } if (items == null) { throw new ArgumentNullException("items null"); } if (baseTrackingDevice == null) { throw new ArgumentNullException("baseTrackingDevice null"); } if (tdDesc == null) { throw new ArgumentNullException("tdDesc null"); } if (!tdDesc.DateRange.Equals(prenotationDate)) { throw new InvalidOperationException("Il tracking device base deve essere +" + "associato per tutta la prenotazione"); } #endregion _client = client; _prenotationDate = prenotationDate; _bookedItems = items.ToList(); _packetsPurchases = new List <IPacketPurchase>(); List <IPacket> packetList = new List <IPacket>(); foreach (IPacket packet in packets ?? new IPacket[0]) { if (!CanAdd(packet)) { throw new InvalidOperationException("packet not valid"); } DateTime start = prenotationDate.StartDate > packet.Availability.StartDate ? prenotationDate.StartDate : packet.Availability.StartDate; _packetsPurchases.Add(new PacketPurchase(start, packet)); } _bundles = new HashSet <IBundle>(); _tdAssociations = new Dictionary <ITrackingDevice, AssociationDescriptor>(); AddTrackingDevice(baseTrackingDevice, tdDesc); foreach (IBundle bundle in bundles ?? new IBundle[0]) { if (!CanAdd(bundle)) { throw new InvalidOperationException("bundle not valid"); } _bundles.Add(bundle); } foreach (IItemPrenotation ip in _bookedItems) { if (!CanAdd(ip)) { throw new InvalidOperationException("item prenotation not valid"); } } // Verifico che gli item comprano interamente la prenotazione // per ogni giorno ci deve essere almeno un item if (!IsIstantiable(_bookedItems)) { throw new InvalidOperationException("gli item non comprono interamente la prenotazione"); } }