Esempio n. 1
0
        private void GenerateBrandProvisioningFile(Brand brand, int brandNumber, List <HotelType> hotelTypes,
                                                   string outputDirectory, ref int globalHotelNumber)
        {
            string brandFilename = Path.Combine(outputDirectory, GetBrandProvisioningFilename(brand));

            var brandSpaceDescription = new SpaceDescription
            {
                name         = brand.Name,
                description  = $"SmartHotel360 {brand.Name}",
                friendlyName = brand.Name,
                type         = "HotelBrand"
            };

            brandSpaceDescription.AddUser($"Hotel Brand {brandNumber} Manager");
            brandSpaceDescription.AddProperty(new PropertyDescription {
                name = PropertyKeyDescription.DisplayOrder, value = brandNumber.ToString()
            });

            brandSpaceDescription.AddBlob(new BlobDescription
            {
                name          = $"{brand.Name} Blob",
                type          = BlobDescription.FileBlobType,
                subtype       = BlobDescription.NoneBlobType,
                description   = "Brand image",
                filepath      = $"{ImageFolderRelativePath}/brands/brand{brandNumber}.png",
                contentType   = BlobDescription.PngContentType,
                isPrimaryBlob = true
            });

            // Create the hotels
            for (int hotelIndex = 0; hotelIndex < brand.Hotels.Count; hotelIndex++)
            {
                globalHotelNumber++;
                Hotel     hotel                 = brand.Hotels[hotelIndex];
                HotelType hotelType             = hotelTypes.First(t => t.Name == hotel.Type);
                var       hotelSpaceDescription = new SpaceDescription
                {
                    name         = hotel.Name,
                    description  = $"SmartHotel360 {hotel.Name}",
                    friendlyName = hotel.Name,
                    type         = "Hotel"
                };
                hotelSpaceDescription.AddUser($"Hotel {globalHotelNumber} Manager");

                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.DisplayOrder, value = hotelIndex.ToString()
                });

                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.MinTemperatureAlertThreshold, value = hotelType.MinTempAlertThreshold.ToString()
                });

                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.MaxTemperatureAlertThreshold, value = hotelType.MaxTempAlertThreshold.ToString()
                });

                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.Latitude, value = hotel.Latitude.ToString()
                });

                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.Longitude, value = hotel.Longitude.ToString()
                });

                hotelSpaceDescription.AddBlob(new BlobDescription
                {
                    name          = $"{brand.Name} {hotel.Name} Blob",
                    type          = BlobDescription.FileBlobType,
                    subtype       = BlobDescription.NoneBlobType,
                    description   = "Hotel image",
                    filepath      = $"{ImageFolderRelativePath}/hotels/{hotelType.Name.ToLower()}.jpg",
                    contentType   = BlobDescription.JpegContentType,
                    isPrimaryBlob = true
                });

                string brandHotelPrefix = $"{brand.Name}-{hotel.Name}-".Replace(" ", string.Empty);

                int numberRegularFloors = hotelType.TotalNumberFloors - hotelType.NumberVipFloors;

                // Create the floors
                for (int floorIndex = 0; floorIndex < hotelType.TotalNumberFloors; floorIndex++)
                {
                    bool   isVipFloor            = floorIndex >= numberRegularFloors;
                    string floorName             = $"Floor {floorIndex + 1:D02}";
                    var    floorSpaceDescription = new SpaceDescription
                    {
                        name         = floorName,
                        description  = $"Floor {floorIndex + 1}",
                        friendlyName = $"Floor {floorIndex + 1}",
                        type         = "Floor"
                    };
                    floorSpaceDescription.AddProperty(new PropertyDescription
                    {
                        name  = PropertyKeyDescription.DeviceIdPrefixName,
                        value = brandHotelPrefix
                    });

                    string imagePathSuffix = string.Empty;
                    if (isVipFloor)
                    {
                        imagePathSuffix = "vip";
                        floorSpaceDescription.subType = "VIPFloor";
                    }

                    floorSpaceDescription.AddBlob(new BlobDescription
                    {
                        name          = $"{brand.Name} {hotel.Name} {floorName} Blob",
                        type          = BlobDescription.FileBlobType,
                        subtype       = BlobDescription.NoneBlobType,
                        description   = "Floor image",
                        filepath      = $"{ImageFolderRelativePath}/floors/{hotelType.Name.ToLower()}{imagePathSuffix}.jpg",
                        contentType   = BlobDescription.JpegContentType,
                        isPrimaryBlob = true
                    });

                    floorSpaceDescription.AddBlob(new BlobDescription
                    {
                        name          = $"{brand.Name} {hotel.Name} {floorName} Floorplan Blob",
                        type          = BlobDescription.FileBlobType,
                        subtype       = BlobDescription.FloorplanFileBlobSubType,
                        description   = "Floorplan image",
                        filepath      = $"{ImageFolderRelativePath}/floorplans/{hotelType.Name.ToLower()}{imagePathSuffix}.svg",
                        contentType   = BlobDescription.SvgContentType,
                        isPrimaryBlob = false
                    });

                    if (!isVipFloor && !string.IsNullOrEmpty(hotel.RegularFloorEmployeeUser))
                    {
                        floorSpaceDescription.AddUser($"Hotel {hotelIndex + 1} {hotel.RegularFloorEmployeeUser}");
                    }

                    bool includeGymForThisFloor            = floorIndex == 0 && hotelType.IncludeGym;
                    bool includeConferenceRoomForThisFloor = floorIndex == 1 && hotelType.IncludeConferenceRoom;

                    int numberOfRooms = isVipFloor ? hotelType.NumberRoomsPerVipFloor : hotelType.NumberRoomsPerRegularFloor;
                    if (includeGymForThisFloor)
                    {
                        numberOfRooms--;
                    }
                    if (includeConferenceRoomForThisFloor)
                    {
                        numberOfRooms--;
                    }

                    // Create the rooms
                    for (int roomIndex = 0; roomIndex < numberOfRooms; roomIndex++)
                    {
                        string           roomType             = GetRoomType(roomIndex, numberOfRooms, isVipFloor);
                        SpaceDescription roomSpaceDescription = CreateRoom(100 * (floorIndex + 1) + roomIndex + 1, brandHotelPrefix,
                                                                           roomType, hotel.AddDevices);
                        floorSpaceDescription.AddSpace(roomSpaceDescription);
                    }

                    if (includeGymForThisFloor)
                    {
                        SpaceDescription roomSpaceDescription = CreateRoom(100 * (floorIndex + 1) + numberOfRooms + 1,
                                                                           brandHotelPrefix, "GymRoom", hotel.AddDevices);
                        floorSpaceDescription.AddSpace(roomSpaceDescription);
                    }

                    if (includeConferenceRoomForThisFloor)
                    {
                        SpaceDescription roomSpaceDescription = CreateRoom(100 * (floorIndex + 1) + numberOfRooms + 1,
                                                                           brandHotelPrefix, "ConferenceRoom", hotel.AddDevices);
                        floorSpaceDescription.AddSpace(roomSpaceDescription);
                    }

                    hotelSpaceDescription.AddSpace(floorSpaceDescription);
                }

                brandSpaceDescription.AddSpace(hotelSpaceDescription);
            }

            var yamlSerializer = new SerializerBuilder()
                                 .Build();
            string serializedProvisioningDescription = yamlSerializer.Serialize(brandSpaceDescription);

            File.WriteAllText(brandFilename, serializedProvisioningDescription);

            Console.WriteLine($"Successfully created brand provisioning file: {brandFilename}");
        }
Esempio n. 2
0
        private void GenerateBrandProvisioningFile(Brand brand, int brandNumber, List <HotelType> hotelTypes, ref int globalHotelNumber)
        {
            string brandFilename = GetBrandProvisioningFilename(brand);

            var brandSpaceDescription = new SpaceDescription
            {
                name         = brand.Name,
                description  = $"SmartHotel360 {brand.Name}",
                friendlyName = brand.Name,
                type         = "HotelBrand"
            };

            brandSpaceDescription.AddUser($"Hotel Brand {brandNumber} Manager");
            brandSpaceDescription.AddProperty(new PropertyDescription {
                name = PropertyKeyDescription.DisplayOrder, value = brandNumber.ToString()
            });
            brandSpaceDescription.AddProperty(new PropertyDescription
            {
                name  = PropertyKeyDescription.ImagePath,
                value = $"{imageAssetsRootPath}brands/brand{brandNumber}.jpg"
            });

            // Create the hotels
            for (int hotelIndex = 0; hotelIndex < brand.Hotels.Count; hotelIndex++)
            {
                globalHotelNumber++;
                Hotel     hotel                 = brand.Hotels[hotelIndex];
                HotelType hotelType             = hotelTypes.First(t => t.Name == hotel.Type);
                var       hotelSpaceDescription = new SpaceDescription
                {
                    name         = hotel.Name,
                    description  = $"SmartHotel360 {hotel.Name}",
                    friendlyName = hotel.Name,
                    type         = "Hotel"
                };
                hotelSpaceDescription.AddUser($"Hotel {globalHotelNumber} Manager");
                hotelSpaceDescription.AddProperty(new PropertyDescription {
                    name = PropertyKeyDescription.DisplayOrder, value = hotelIndex.ToString()
                });
                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.MinTemperatureAlertThreshold, value = hotelType.MinTempAlertThreshold.ToString()
                });
                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name = PropertyKeyDescription.MaxTemperatureAlertThreshold, value = hotelType.MaxTempAlertThreshold.ToString()
                });
                hotelSpaceDescription.AddProperty(new PropertyDescription
                {
                    name  = PropertyKeyDescription.ImagePath,
                    value = $"{imageAssetsRootPath}hotels/{hotelType.Name.ToLower()}.jpg"
                });

                string brandHotelPrefix = $"{brand.Name}-{hotel.Name}-".Replace(" ", string.Empty);

                int numberRegularFloors = hotelType.TotalNumberFloors - hotelType.NumberVipFloors;

                // Create the floors
                for (int floorIndex = 0; floorIndex < hotelType.TotalNumberFloors; floorIndex++)
                {
                    bool isVipFloor            = floorIndex >= numberRegularFloors;
                    var  floorSpaceDescription = new SpaceDescription
                    {
                        name         = $"Floor {floorIndex + 1:D02}",
                        description  = $"Floor {floorIndex + 1}",
                        friendlyName = $"Floor {floorIndex + 1}",
                        type         = "Floor"
                    };
                    floorSpaceDescription.AddProperty(new PropertyDescription
                    {
                        name  = PropertyKeyDescription.DeviceIdPrefixName,
                        value = brandHotelPrefix
                    });

                    string imagePathSuffix = string.Empty;
                    if (isVipFloor)
                    {
                        imagePathSuffix = "vip";
                        floorSpaceDescription.subType = "VIPFloor";
                    }

                    floorSpaceDescription.AddProperty(new PropertyDescription
                    {
                        name  = PropertyKeyDescription.ImagePath,
                        value = $"{imageAssetsRootPath}floors/{hotelType.Name.ToLower()}{imagePathSuffix}.jpg"
                    });

                    if (!isVipFloor && !string.IsNullOrEmpty(hotel.RegularFloorEmployeeUser))
                    {
                        floorSpaceDescription.AddUser($"Hotel {hotelIndex + 1} {hotel.RegularFloorEmployeeUser}");
                    }

                    int numberOfRooms = isVipFloor ? hotelType.NumberRoomsPerVipFloor : hotelType.NumberRoomsPerRegularFloor;
                    // Create the rooms
                    for (int roomIndex = 0; roomIndex < numberOfRooms; roomIndex++)
                    {
                        string           roomType             = GetRoomType(roomIndex, numberOfRooms, isVipFloor);
                        SpaceDescription roomSpaceDescription = CreateRoom(100 * (floorIndex + 1) + roomIndex + 1, brandHotelPrefix,
                                                                           roomType, hotel.AddDevices);
                        floorSpaceDescription.AddSpace(roomSpaceDescription);
                    }

                    if (floorIndex == 0 && hotelType.IncludeGym)
                    {
                        SpaceDescription roomSpaceDescription = CreateRoom(100 * (floorIndex + 1) + numberOfRooms + 1,
                                                                           brandHotelPrefix, "GymRoom", hotel.AddDevices);
                        floorSpaceDescription.AddSpace(roomSpaceDescription);
                    }

                    if (floorIndex == 1 && hotelType.IncludeConferenceRoom)
                    {
                        SpaceDescription roomSpaceDescription = CreateRoom(100 * (floorIndex + 1) + numberOfRooms + 1,
                                                                           brandHotelPrefix, "ConferenceRoom", hotel.AddDevices);
                        floorSpaceDescription.AddSpace(roomSpaceDescription);
                    }

                    hotelSpaceDescription.AddSpace(floorSpaceDescription);
                }

                brandSpaceDescription.AddSpace(hotelSpaceDescription);
            }

            var yamlSerializer = new SerializerBuilder()
                                 .Build();
            string serializedProvisioningDescription = yamlSerializer.Serialize(brandSpaceDescription);

            File.WriteAllText(brandFilename, serializedProvisioningDescription);

            Console.WriteLine($"Successfully created brand provisioning file: {brandFilename}");
        }