// This is NOT up to date with the latest definition files, just how they were created in the first place //private void GenerateSampleDefinition( string definitionFilename ) //{ // var hotelTypeH = new HotelType // { // Name = "H", // TotalNumberFloors = 10, // NumberVipFloors = 2, // NumberRoomsPerRegularFloor = 20, // NumberRoomsPerVipFloor = 10, // IncludeConferenceRoom = true, // IncludeGym = true // }; // var hotelTypeL = new HotelType // { // Name = "L", // TotalNumberFloors = 10, // NumberVipFloors = 2, // NumberRoomsPerRegularFloor = 15, // NumberRoomsPerVipFloor = 8, // IncludeConferenceRoom = true, // IncludeGym = true // }; // var hotelTypeSH = new HotelType // { // Name = "SH", // TotalNumberFloors = 5, // NumberVipFloors = 1, // NumberRoomsPerRegularFloor = 10, // NumberRoomsPerVipFloor = 4, // IncludeConferenceRoom = true, // IncludeGym = true // }; // var hotelTypeSL = new HotelType // { // Name = "SL", // TotalNumberFloors = 5, // NumberVipFloors = 1, // NumberRoomsPerRegularFloor = 10, // NumberRoomsPerVipFloor = 4, // IncludeConferenceRoom = true, // IncludeGym = true // }; // var hotelTypes = new List<HotelType> { hotelTypeH, hotelTypeL, hotelTypeSH, hotelTypeSL }; // var brands = new List<Brand>(); // for ( int i = 0; i < 4; i++ ) // { // var hotels = new List<Hotel>(); // switch ( i ) // { // case 0: // { // hotels.Add( CreateHotel( hotelTypeH, 1, "Employee", true ) ); // hotels.Add( CreateHotel( hotelTypeL, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSH, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSH, 2, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSL, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSL, 2, null, AllDevices ) ); // break; // } // case 1: // { // hotels.Add( CreateHotel( hotelTypeSH, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSH, 2, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSL, 1, null, AllDevices ) ); // break; // } // case 2: // { // hotels.Add( CreateHotel( hotelTypeSH, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSL, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSL, 2, null, AllDevices ) ); // break; // } // case 3: // { // hotels.Add( CreateHotel( hotelTypeSH, 1, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSH, 2, null, AllDevices ) ); // hotels.Add( CreateHotel( hotelTypeSL, 1, null, AllDevices ) ); // break; // } // } // var brand = new Brand // { // Name = $"Brand {i + 1}", // Hotels = hotels // }; // brands.Add( brand ); // } // var site = new Site // { // HotelTypes = hotelTypes, // Brands = brands // }; // string siteJson = JsonConvert.SerializeObject( site, Formatting.Indented ); // using ( StreamWriter definitionFile = new StreamWriter( definitionFilename ) ) // { // definitionFile.Write( siteJson ); // } //} private Hotel CreateHotel(HotelType hotelType, int hotelIndex, string regularFloorEmployeeUser, bool addDevices) { return(new Hotel { Name = $"Hotel {hotelType.Name} {hotelIndex}", Type = hotelType.Name, RegularFloorEmployeeUser = regularFloorEmployeeUser, AddDevices = addDevices }); }
private void GenerateSampleDefinition(string definitionFilename) { var hotelTypeH = new HotelType { Name = "H", TotalNumberFloors = 10, NumberVipFloors = 2, NumberRoomsPerRegularFloor = 20, NumberRoomsPerVipFloor = 10, IncludeConferenceRoom = true, IncludeGym = true }; var hotelTypeL = new HotelType { Name = "L", TotalNumberFloors = 10, NumberVipFloors = 2, NumberRoomsPerRegularFloor = 15, NumberRoomsPerVipFloor = 8, IncludeConferenceRoom = true, IncludeGym = true }; var hotelTypeSH = new HotelType { Name = "SH", TotalNumberFloors = 5, NumberVipFloors = 1, NumberRoomsPerRegularFloor = 10, NumberRoomsPerVipFloor = 4, IncludeConferenceRoom = true, IncludeGym = true }; var hotelTypeSL = new HotelType { Name = "SL", TotalNumberFloors = 5, NumberVipFloors = 1, NumberRoomsPerRegularFloor = 10, NumberRoomsPerVipFloor = 4, IncludeConferenceRoom = true, IncludeGym = true }; var hotelTypes = new List <HotelType> { hotelTypeH, hotelTypeL, hotelTypeSH, hotelTypeSL }; var brands = new List <Brand>(); for (int i = 0; i < 4; i++) { var hotels = new List <Hotel>(); switch (i) { case 0: { hotels.Add(CreateHotel(hotelTypeH, 1, "Employee", true)); hotels.Add(CreateHotel(hotelTypeL, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSH, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSH, 2, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSL, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSL, 2, null, AllDevices)); break; } case 1: { hotels.Add(CreateHotel(hotelTypeSH, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSH, 2, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSL, 1, null, AllDevices)); break; } case 2: { hotels.Add(CreateHotel(hotelTypeSH, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSL, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSL, 2, null, AllDevices)); break; } case 3: { hotels.Add(CreateHotel(hotelTypeSH, 1, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSH, 2, null, AllDevices)); hotels.Add(CreateHotel(hotelTypeSL, 1, null, AllDevices)); break; } } var brand = new Brand { Name = $"Brand {i + 1}", Hotels = hotels }; brands.Add(brand); } var site = new Site { HotelTypes = hotelTypes, Brands = brands }; string siteJson = JsonConvert.SerializeObject(site, Formatting.Indented); using (StreamWriter definitionFile = new StreamWriter(definitionFilename)) { definitionFile.Write(siteJson); } }
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}"); }
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}"); }