コード例 #1
0
        protected override void Init()
        {
            base.Init();

            /* Cerco un file di configurazione dei bookable items nel fileSystem,
             * se lo trovo carico i bookable items  contenuti
             */

            /* Bookable Items HardCoded */
            StringBuilder br = new StringBuilder();

            br.AppendLine("<Items>");
            br.AppendLine("  <Item>");
            br.AppendLine("    <Class>CSB_Project.src.model.Item.ItemFactory+BasicParser</Class>");
            br.AppendLine("    <Identifier>MyItem100</Identifier>");
            br.AppendLine("    <Name>OmbrelloneSemplice</Name>");
            br.AppendLine("    <Description>MyItemDesc</Description>");
            br.AppendLine("    <Price>10</Price>");
            br.AppendLine("  </Item>");
            br.AppendLine("  <Item>");
            br.AppendLine("    <Class>CSB_Project.src.model.Item.ItemFactory+CategorizableParser</Class>");
            br.AppendLine("    <Identifier>MyItemCustomizable</Identifier>");
            br.AppendLine("    <Name>OmberllonePaglia</Name>");
            br.AppendLine("    <Description>MyItemDesc</Description>");
            br.AppendLine("    <Price>10</Price>");
            br.AppendLine("    <Category>");
            br.AppendLine("      <Path>\\ROOT\\materiali\\testa</Path>");
            br.AppendLine("      <Name>paglia</Name>");
            br.AppendLine("      <Description>paglia molto buona</Description>");
            br.AppendLine("      <Price>10</Price>");
            br.AppendLine("    </Category>");
            br.AppendLine("    <Category>");
            br.AppendLine("      <Path>\\ROOT\\materiali\\staffa</Path>");
            br.AppendLine("      <Name>legno</Name>");
            br.AppendLine("      <Description>legno</Description>");
            br.AppendLine("      <Price>0</Price>");
            br.AppendLine("    </Category>");
            br.AppendLine("  </Item>");
            br.AppendLine("</Items>");
            XmlDocument xml = new XmlDocument();

            xml.LoadXml(br.ToString());
            XmlElement root = xml.DocumentElement;

            Console.WriteLine("Root -> " + root.Name + ":" + root.Value);
            XmlNodeList xnl = root.SelectNodes("/Items/Item");

            Console.WriteLine("Item Count -> " + xnl.Count);
            try
            {
                for (int i = 0; i < xnl.Count; i++)
                {
                    IItem it = ItemFactory.CreateItem(xnl.Item(i));
                    Console.WriteLine("Name " + it.Identifier);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Errore \n " + e);
            }


            IItem ombrelloneBase = ItemFactory.Items.Where(item => item.Identifier.Equals("MyItem100")).FirstOrDefault();
            ICategorizableItem ombrellonePaglia = ItemFactory.Items.OfType <ICategorizableItem>().Where(item => item.Identifier.Equals("MyItemCustomizable")).FirstOrDefault();

            StructureCoordinator structCoord = CoordinatorManager.Instance.CoordinatorOfType <StructureCoordinator>();
            Sector settoreBase = structCoord.GetSectorIn("Stabilimento Bologna Via Mario Longhena", "Spiaggia", "Settore base");
            Sector settoreVip  = structCoord.GetSectorIn("Stabilimento Bologna Via Mario Longhena", "Spiaggia", "Settore vip");

            if (ombrelloneBase == null)
            {
                Console.WriteLine("ombrellone base null");
            }
            else if (ombrelloneBase == null)
            {
                Console.WriteLine("ombrellone vip null");
            }
            else
            {
                for (int row = 1; row <= settoreBase.Rows; row++)
                {
                    for (int col = 1; col <= settoreBase.Columns; col++)
                    {
                        IBookableItem item = new SectorBookableItem(ombrelloneBase, new Position(row, col), settoreBase);
                        _bookableItems.Add(item);
                    }
                }
                for (int row = 1; row <= settoreVip.Rows; row++)
                {
                    for (int col = 1; col <= settoreVip.Columns; col++)
                    {
                        IBookableItem item = new SectorBookableItem(ombrellonePaglia, new Position(row, col), settoreVip);
                        _bookableItems.Add(item);
                    }
                }
            }
        }
コード例 #2
0
        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);
        }