override public void Execute() { Signer signer = SignerBuilder.NewSignerWithEmail(email1) .WithFirstName("Patty") .WithLastName("Galant") .Build(); HostUid = signer.Id; StartDateTime = DateTime.UtcNow.AddDays(7); VirtualRoom VirtualRoom = VirtualRoomBuilder.NewVirtualRoom() .WithHostUid(HostUid) .WithVideo(true) .WithVideoRecording(true) .WithStartDateTime(StartDateTime) .Build(); DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName) .DescribedAs("Description") .WithSigner(signer) .WithDocument(DocumentBuilder.NewDocumentNamed("Document") .WithId("DocumentId") .FromStream(fileStream1, DocumentType.PDF)) .Build(); packageId = ossClient.CreatePackageOneStep(superDuperPackage); retrievedPackage = ossClient.GetPackage(packageId); OssClient.VirtualRoomService.SetVirtualRoom(packageId, VirtualRoom); VirtualRoomAfterUpdate = OssClient.VirtualRoomService.GetVirtualRoom(packageId); }
public bool CellsAreInTheSameRoom(CellLocation l1, CellLocation l2) { VirtualRoom room1 = null, room2 = null; foreach (VirtualRoom room in this.rooms) { if (room.containsLocation(l1)) { room1 = room; // Debug.Log ("ROOM 1: " + room1); break; } } foreach (VirtualRoom room in this.rooms) { if (room.containsLocation(l2)) { room2 = room; // Debug.Log ("ROOM 2: " + room2); break; } } // if (room1 == room2) Debug.Log ("SAME ROOM!"); // else Debug.Log ("NOT SAME!"); return(room1 == room2); }
private bool CheckSkipDoorToCorridor(VirtualMap map, VirtualRoom r, CellLocation end_floor_loc) { // Note that 'dont skip' takes precedence! //Debug.Log(r + " to " + end_floor_loc); // At default, we do not skip bool skip = false; // Already connected: we should skip it skip = r.IsConnectedToCorridor(); //Debug.Log("Connected already? " + skip); // If 3 walls, we instead do not skip it skip = skip && !map.IsDeadEnd(end_floor_loc, alsoConsiderDoors: true); /*if (r.leftCorner.x == 9 && r.leftCorner.y == 3) * { * Debug.Log(r + " to " + end_floor_loc); * Debug.Log("3 walls? " + map.IsDeadEnd(end_floor_loc, alsoConsiderDoors: true)); * }*/ // If 4 walls, we instead do not skip it skip = skip && !map.IsSurroundedByWalls(end_floor_loc); //Debug.Log("4 walls? " + map.IsSurroundedByWalls(end_floor_loc)); // We do not skip if we request more doors skip = skip && !(DungeonGenerator.Random.Instance.Next(0, 100) < doorsDensityModifier); //Debug.Log("More doors? " + moreDoors); return(skip); }
/******************** * Door creation ********************/ // Create doors for a given room public void CreateDoors_Post(VirtualMap map, VirtualRoom r) { List <CellLocation> borderFloors = new List <CellLocation> (); // Examine borderFloors, create a list of border floors for (int i = 0; i < r.Width; i++) { for (int j = 0; j < r.Height; j++) { if (i == 0 || j == 0 || i == r.Width - 1 || j == r.Height - 1) { CellLocation l = new CellLocation(r.leftCorner.x + 2 * i, r.leftCorner.y + 2 * j); borderFloors.Add(l); } } } // Create doors close to the borders, where wall passages are CellLocation target_passage; foreach (CellLocation l in borderFloors) { foreach (VirtualMap.DirectionType dir in map.directions) { target_passage = map.GetNeighbourCellLocation(l, dir); if (map.GetCell(target_passage).IsWall()) { CheckDoorCreation(map, r, l, dir); } } } }
private VirtualRoom buildSdkVirtualRoom() { VirtualRoom result = new VirtualRoom(); result.Video = true; result.VideoRecording = true; result.StartDatetime = DateTime.Now; result.HostUid = "hostUid"; return(result); }
public VirtualRoom Build() { VirtualRoom result = new VirtualRoom(); result.Video = video; result.VideoRecording = videoRecording; result.StartDatetime = startDatetime; result.HostUid = hostUid; return(result); }
public IActionResult SaveRoom(string json, int tzOffset, int lang = 1) { VirtualRoom room = null; if (json != null && json.Length > 0) { room = JsonConvert.DeserializeObject <VirtualRoom>(json); } return(Json(ScheduleDB.SaveRoom(room, tzOffset, lang, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)))); }
private void PickRandomRoomLocation(VirtualMap map, VirtualRoom r) { // Pick a random valid Location List <CellLocation> locations = new List <CellLocation>(map.floorCells); do { int index = DungeonGenerator.Random.Instance.Next(0, locations.Count - 1); CellLocation l = locations[index]; r.leftCorner = l; locations.Remove(l); } while (locations.Count > 0 && !IsRoomLocationValid(map, r)); }
public bool IsAlreadyConnectedToARoomAt(CellLocation l, VirtualMap virtualMap) { foreach (int index in this.connectedRoomsIds) { VirtualRoom r = virtualMap.GetRoom(index); Debug.Log("CHECK: " + index); if (r.containsLocation(l)) { // Debug.Log("Room " + this + " is already connected to room " + r); return(true); } } return(false); }
public ActionResult Edit(VirtualRoom model) { var room = Db.VirtualRooms.SingleOrDefault(x => x.Id == model.Id); room.Name = model.Name; room.Description = model.Description; room.AccessUrl = model.AccessUrl; room.TokenName = model.TokenName; room.Token = model.Token; Db.SaveChanges(); return(RedirectToAction("Index")); }
public int maxCorridorWidth = 2; // [1,2] // bool ONE_DOOR_PER_CORRIDOR = true; override protected void GenerateWithAlgorithm(VirtualMap map, VirtualMap vmapBelow) { // Start full of rocks map.ResetToRocks(); //return; // Pick the cell to start from CellLocation starting_location = default(CellLocation); if (vmapBelow != null) { starting_location = vmapBelow.end; } else { starting_location = CellLocation.INVALID; } //Debug.Log(starting_location); // We start our tree with the full dungeon bounds (only counting FLOOR cells) BSPTree tree = new BSPTree(); tree.root = new BSPTreeNode(0, 0, map.ActualWidth, map.ActualHeight); // Pick a random initial direction BSPSplitDirection splitDir = (BSPSplitDirection)DungeonGenerator.Random.Instance.Next(0, (int)BSPSplitDirection.MAX - 1); // Start the algorithm List <BSPTreeNode> leafNodes = new List <BSPTreeNode>(); SplitNode(tree.root, splitDir, splitRange, nSplits, leafNodes); // Create the rooms RoomGenerator roomGenerator = new RoomGenerator(); map.rooms = new List <VirtualRoom>(); foreach (BSPTreeNode node in leafNodes) { VirtualRoom room = CreateRoom(map, roomGenerator, node, starting_location); if (room != null) { room.sequentialId = map.rooms.Count; map.rooms.Add(room); } } // Create the corridors LinkCorridors(tree.root, map, 0); }
// Control if we can open a door in the given direction. Open it if possible private void CreateDoor(VirtualMap map, VirtualRoom r, RoomGenerator roomGenerator, CellLocation start_floor_loc, CellLocation end_floor_loc, VirtualMap.DirectionType direction) { CellLocation passage = map.GetNeighbourCellLocation(start_floor_loc, direction); // We check whether we are connecting to another room if (map.IsRoomFloor(end_floor_loc)) { // Room-to-room door roomGenerator.OpenRoomDoor(map, r, start_floor_loc, end_floor_loc, passage, direction); } else { // Room-to-corridor door roomGenerator.OpenCorridorDoor(map, r, start_floor_loc, end_floor_loc, passage, direction); } }
public bool IsRoomLocationValid(VirtualMap map, VirtualRoom r) { // A room starting_location is valid if it is in bounds for (int i = 0; i < r.Width; i++) { for (int j = 0; j < r.Height; j++) { CellLocation l = new CellLocation(r.leftCorner.x + 2 * i, r.leftCorner.y + 2 * j); if (!map.floorCells.Contains(l))// || map.visitedCells.Contains (l)) { return(false); } } } return(true); }
/******************** * Door Creation NEW ********************/ public void OpenRoomDoor(VirtualMap map, VirtualRoom room, CellLocation start_floor_loc, CellLocation end_floor_loc, CellLocation passage_loc, VirtualMap.DirectionType direction) { //Debug.Log(room); // We update both this and the connected room foreach (VirtualRoom tr in map.rooms) { if (tr.containsLocation(end_floor_loc)) { tr.AddDoorToAnotherRoom(passage_loc); room.AddDoorToAnotherRoom(passage_loc); tr.ConnectRoom(room); room.ConnectRoom(tr); break; } } OpenDoor(map, start_floor_loc, end_floor_loc, passage_loc, direction); }
public void BuildTest() { DateTime startDateTime = DateTime.Now; VirtualRoomBuilder builder = VirtualRoomBuilder.NewVirtualRoom() .WithVideo(true) .WithVideoRecording(true) .WithStartDateTime(startDateTime) .WithHostUid("hostUid"); VirtualRoom result = builder.Build(); Assert.IsNotNull(result); Assert.AreEqual(result.Video, true); Assert.AreEqual(result.VideoRecording, true); Assert.AreEqual(result.StartDatetime, startDateTime); Assert.AreEqual(result.HostUid, "hostUid"); }
public void CreateRooms(VirtualMap map) { RoomGenerator roomGenerator = new RoomGenerator(); int roomNumber = DungeonGenerator.Random.Instance.Next(minRooms, maxRooms); // Ensure that the total area is compatible CheckDimensions(map); map.rooms = new List <VirtualRoom>(); for (int n = 0; n < roomNumber; n++) { VirtualRoom room = CreateRoom(map, roomGenerator); if (room != null) { room.sequentialId = map.rooms.Count; map.rooms.Add(room); } } }
private VirtualRoom CreateRoom(VirtualMap map, RoomGenerator roomGenerator) { int width = DungeonGenerator.Random.Instance.Next(minRoomWidth, maxRoomWidth); int height = DungeonGenerator.Random.Instance.Next(minRoomHeight, maxRoomHeight); VirtualRoom r = new VirtualRoom(width, height, new CellLocation(0, 0)); PickBestRoomLocation(map, r); // PickRandomLocation(map,r); VirtualRoom room = roomGenerator.CreateRoom(map, width, height, r); if (room != null) { CreateDoors(map, room, roomGenerator); } return(room); }
// Control if we can open a door in the given direction. Open it if possible private bool CheckDoorCreation(VirtualMap map, VirtualRoom r, CellLocation start_floor_loc, VirtualMap.DirectionType direction) { bool result = false; CellLocation end_floor_loc = map.GetTargetLocation(start_floor_loc, direction); CellLocation passage = map.GetNeighbourCellLocation(start_floor_loc, direction); // We get the ending floor and check its validity if (end_floor_loc.isValid() && !map.GetCell(end_floor_loc).IsRock()) { // We check whether we are connecting to another room if (map.roomCells.Contains(end_floor_loc)) { // Check if we skip creating the door if (DungeonGenerator.Random.Instance.Next(0, 100) > doorsDensityModifier && // We do not skip if we request more doors than needed r.IsAlreadyConnectedToARoomAt(end_floor_loc, map)) // We skip if we are already connected { return(result); } OpenRoomDoor(map, r, start_floor_loc, end_floor_loc, passage, direction); } else { // We need one door for each corridor segment that has been separated out by this room // To do that, we also create a door if the ending floor is a dead end, effectively getting rid of the dead end // Also, we create if the ending floor is a rock (i.e. 4 walls), which can happen if this room blocks out single floor cells! // We check if we need to skip if (CheckSkipDoorToCorridor(map, r, end_floor_loc)) { return(result); } // Debug.Log("Room " + r + " CREATING TO " + passage); OpenCorridorDoor(map, r, start_floor_loc, end_floor_loc, passage, direction); } result = true; } return(result); }
public ActionResult Create(VirtualRoom model) { var member = GetMyMembership(); var room = new VirtualRoom { Owner = member, Name = model.Name, Description = model.Description, AccessUrl = model.AccessUrl, TokenName = model.TokenName, Token = model.Token, ParticipientsOnly = true }; Db.VirtualRooms.Add(room); Db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Update Virtual Room for account. /// </summary> /// <param name="VirtualRoom">VirtualRoom.</param> public void SetVirtualRoom(PackageId packageId, VirtualRoom VirtualRoom) { String path = template.UrlFor(UrlTemplate.VIRTUAL_ROOM_CONFIG_PATH) .Replace("{packageId}", packageId.Id) .Build(); VirtualRoomConverter converter = new VirtualRoomConverter(VirtualRoom); String VirtualRoomJson = JsonConvert.SerializeObject(converter.ToAPIVirtualRoom()); try { restClient.Put(path, VirtualRoomJson); } catch (OssServerException e) { throw new OssServerException("Could not update VirtualRoom" + " Exception: " + e.Message, e.ServerError, e); } catch (Exception e) { throw new OssException("Could not update VirtualRoom" + " Exception: " + e.Message, e); } }
void AlignVirtualAndPhysicalSpace(VirtualRoom vr) { Transform floorPlan = MiniMap.Instance.transform.Find("FloorPlan"); // rotate Vector3[] corners = physicalRoom.RoomCorners(); Vector3 ph_rotation = ((corners[1] - corners[0]) + (corners[2] - corners[3])); Vector3[] vcorners = vr.RoomCorners(); Vector3 vr_rotation = ((vcorners[1] - vcorners[0]) + (vcorners[2] - vcorners[3])); floorPlan.Rotate(Quaternion.FromToRotation(vr_rotation, ph_rotation).eulerAngles); if (vr.betterRotated) { floorPlan.Rotate(Quaternion.AngleAxis(180, Vector3.up).eulerAngles); } // translate floorPlan.position -= vr.Transform.position; floorPlan.position += physicalRoom.RoomCorners()[(!vr.betterRotated) ? 0 : 2]; MiniMap.Instance.Activate(); }
void Update() { if (this.state == State.Inactive && analyzer.state == MeshAnalyzer.State.Finished) { this.state = State.InProgress; VirtualRoom vr = IdentifyRoom(); AlignVirtualAndPhysicalSpace(vr); ScanManager.Instance.hideSurfaceMesh(); ScanProgress.Instance.tts.StartSpeaking(vr.IdentifyMessage); } if (showVirtualProbes) { foreach (VirtualRoom vr in virtualRooms) { vr.DrawProbes(); } } if (showPhysicalProbes && physicalRoom != null) { physicalRoom.DrawProbes(); } }
/* This method checks how good the virtual room matches the physical one. * It checks the room twice. The second time 180deg rotated to find out the orientation. * */ public float CalculateDifference(VirtualRoom virtualRoom) { // check room dimensions first float diff = this.dimensions.magnitude - virtualRoom.dimensions.magnitude; if (Mathf.Abs(diff) > 0.5f) { return(float.MaxValue); } // check the footprint float diffNormal = WallDifference(this.Footprint, virtualRoom.Footprint); float diffRotated = WallDifference(this.Footprint, virtualRoom.FootprintRotated); if (diffRotated < diffNormal) { virtualRoom.betterRotated = true; } float bestFootprintDiff = Mathf.Min(diffNormal, diffRotated); return(bestFootprintDiff); }
public static ICollection <Event> SaveRoom(VirtualRoom room, int tzOffset, int lang = 1, string conStr = "") { if (room != null) { using (SqlConnection connection = new SqlConnection(conStr)) { DataTable dtParticipants = new DataTable(); if (room.Participants != null && room.Participants.Count > 0) { dtParticipants.Columns.Add("Id", typeof(long)); room.Participants.ToList().ForEach(p => { DataRow row = dtParticipants.NewRow(); row["Id"] = p.UserId; dtParticipants.Rows.Add(row); }); } SqlCommand cmd = new SqlCommand("sp_ManageRooms", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter { ParameterName = "@Participants", TypeName = "udt_BigIdList", SqlDbType = SqlDbType.Structured, Value = dtParticipants }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Mode", SqlDbType = SqlDbType.VarChar, Value = "Save" }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Title", SqlDbType = SqlDbType.NVarChar, Value = room.Title }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Host", SqlDbType = SqlDbType.BigInt, Value = room.Host }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@DueDate", SqlDbType = SqlDbType.DateTime, Value = room.DueDate }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@TimeZoneOffset", SqlDbType = SqlDbType.DateTime, Value = tzOffset }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Duration", SqlDbType = SqlDbType.Int, Value = room.Duration }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@MaterialId", SqlDbType = SqlDbType.Int, Value = room.Material.SysId }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@IsPaid", SqlDbType = SqlDbType.Bit, Value = room.Paid }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Active", SqlDbType = SqlDbType.Bit, Value = room.Active }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Cancelled", SqlDbType = SqlDbType.Bit, Value = room.Cancelled }); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { IDictionary <long, Event> rooms = new Dictionary <long, Event>(); while (reader.Read()) { long id = Convert.ToInt64(reader["Id"]); if (!rooms.Keys.Contains(id)) { Event rm = new VirtualRoom { Id = id, RoomId = Convert.ToInt64(reader["RoomId"]), Title = reader["Title"].ToString(), Host = new User { UserId = Convert.ToInt64(reader["Host"]), FirstName = reader["FirstName"].ToString(), LastName = reader["LastName"].ToString(), Email = reader["Email"].ToString(), Gender = Convert.ToBoolean(reader["Gender"]), Role = new Role { Id = Convert.ToInt16(reader["HRoleId"]), Name = reader["HRoleName"].ToString(), Display = reader["HRoleDisplay"].ToString(), Description = reader["Description"] != DBNull.Value ? reader["Description"].ToString() : null } }, DueDate = Convert.ToDateTime(reader["DueDate"]), Material = new Material(reader), Duration = Convert.ToInt32(reader["Duration"]), Active = Convert.ToBoolean(reader["Active"]), Cancelled = Convert.ToBoolean(reader["Cancelled"]), Running = Convert.ToBoolean(reader["Running"]), Paid = Convert.ToBoolean(reader["IsPaid"]), Password = reader["Password"] != DBNull.Value ? reader["Password"].ToString() : null, Participants = new List <User>(), DateStarted = reader["DateStarted"] != DBNull.Value ? Convert.ToDateTime(reader["DateStarted"]) : default(DateTime?), DateEnded = reader["DateEnded"] != DBNull.Value ? Convert.ToDateTime(reader["DateEnded"]) : default(DateTime?) }; if (reader["ParticipantId"] != DBNull.Value) { rm.Participants.Add(new User { UserId = Convert.ToInt64(reader["ParticipantId"]), FirstName = reader["PFName"].ToString(), LastName = reader["PLName"].ToString(), Email = reader["PEmail"].ToString(), Gender = Convert.ToBoolean(reader["PGender"]), Role = new Role { Id = Convert.ToInt16(reader["PRoleId"]), Name = reader["PRoleName"].ToString(), Display = reader["PRoleDisplay"].ToString(), Description = null } }); } rooms.Add(id, rm); } } return(rooms.Values); } } } return(new Event[0]); }
private void PickBestRoomLocation(VirtualMap map, VirtualRoom r) {//, int roomNumber){ // Traverse all floor cells checking for the best position for a room int best_score = 1000000; int current_score; List <CellLocation> best_locations = new List <CellLocation>(); List <CellLocation> locations = new List <CellLocation>(map.floorCells); foreach (CellLocation map_l in locations) { r.leftCorner = map_l; if (IsRoomLocationValid(map, r)) { current_score = 0; // Lower is better for (int i = 0; i < r.Width; i++) { for (int j = 0; j < r.Height; j++) { CellLocation possible_room_l = new CellLocation(r.leftCorner.x + 2 * i, r.leftCorner.y + 2 * j); // Debug.Log("Possible room l: " + possible_room_l); // Corridor vicinity: good if (map.IsSurroundedByWalls(possible_room_l) && map.HasAdjacentFloor(possible_room_l)) { current_score += 1; } bool corridorOverlap = map.IsFloor(possible_room_l); // Corridor overlap: bad (at default) if (!forceRoomTransversal && corridorOverlap) { current_score += 3; } // or good if we want the room in the middle! else if (forceRoomTransversal && !corridorOverlap) { current_score += 3; } // Room overlap: very very bad if (map.IsRoomFloor(possible_room_l)) { current_score += 100; } // If multi-storey, the first room should be placed above another room! // if (roomNumber == 0 && !belowMap.isRoomFloor(possible_room_l)) current_score += 5; // TODO: may be more efficient to exit now if the score is already low enough! } } if (current_score == 0) { continue; // Zero is not a valid score, as it means the room is isolated } if (current_score == best_score) { best_locations.Add(map_l); } else if (current_score < best_score) { best_score = current_score; best_locations.Clear(); best_locations.Add(map_l); } } } if (best_locations.Count == 0) { r.leftCorner = new CellLocation(-1, -1); } else { r.leftCorner = best_locations[DungeonGenerator.Random.Instance.Next(0, best_locations.Count - 1)]; } }
/******************** * Door creation ********************/ public void CreateDoors(VirtualMap map, VirtualRoom r, RoomGenerator roomGenerator) { // Create a list of border floors (close to the borders of the room) List <CellLocation> borderFloors = new List <CellLocation>(); for (int i = 0; i < r.Width; i++) { for (int j = 0; j < r.Height; j++) { if (i == 0 || j == 0 || i == r.Width - 1 || j == r.Height - 1) { CellLocation l = new CellLocation(r.leftCorner.x + 2 * i, r.leftCorner.y + 2 * j); borderFloors.Add(l); } } } // For each border floor, check if we are connecting to something on the other side List <CellLocation> outsideBorderFloors = new List <CellLocation>(); List <CellLocation> insideBorderFloors = new List <CellLocation>(); List <VirtualMap.DirectionType> borderDirections = new List <VirtualMap.DirectionType>(); CellLocation target_passage; CellLocation target_floor; foreach (CellLocation l in borderFloors) { foreach (VirtualMap.DirectionType dir in map.directions) { target_passage = map.GetNeighbourCellLocation(l, dir); target_floor = map.GetTargetLocation(l, dir); if (!map.LocationIsOutsideBounds(target_floor) && map.GetCell(target_passage).IsWall() && !map.IsSurroundedByWalls(target_floor)) { outsideBorderFloors.Add(target_floor); insideBorderFloors.Add(l); borderDirections.Add(dir); } } } // We now create a door for each outside border floor, making sure to avoid re-creating doors if the floors are already connected List <CellLocation> unremovedFloors = new List <CellLocation>(outsideBorderFloors); for (int i = 0; i < outsideBorderFloors.Count; i++) { CellLocation l = outsideBorderFloors[i]; // If not already removed (but we may not skip if we request more doors than needed) if (unremovedFloors.Contains(l) || DungeonGenerator.Random.Instance.Next(0, 100) < doorsDensityModifier) { CreateDoor(map, r, roomGenerator, insideBorderFloors[i], l, borderDirections[i]); unremovedFloors.Remove(l); // We also remove the other connected cells for (int j = unremovedFloors.Count - 1; j >= 0; j--) { CellLocation other_l = unremovedFloors[j]; bool existsPath = map.ExistsPathBetweenLocations(l, other_l); if (existsPath) { unremovedFloors.Remove(other_l); } } } } }
public static DataList <Event> ScheduledTo(long participant, int tzOffset, int lang = 1, string conStr = "") { IDictionary <long, Event> rooms = new Dictionary <long, Event>(); using (SqlConnection connection = new SqlConnection(conStr)) { SqlCommand cmd = new SqlCommand("sp_ManageRooms", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Mode", Value = "get" }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@ParticipantId", Value = participant }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@TimeZoneOffset", Value = tzOffset }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@LanguageId", Value = lang }); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { long id = Convert.ToInt64(reader["Id"]); if (!rooms.Keys.Contains(id)) { Event rm = new VirtualRoom { Id = id, RoomId = Convert.ToInt64(reader["RoomId"]), Title = reader["Title"].ToString(), Description = reader["Description"] != DBNull.Value ? reader["Description"].ToString() : null, Host = new User { UserId = Convert.ToInt64(reader["Host"]), FirstName = reader["FirstName"].ToString(), LastName = reader["LastName"].ToString() }, DueDate = Convert.ToDateTime(reader["DueDate"]), Material = new Material(reader), Duration = Convert.ToInt32(reader["Duration"]), Active = Convert.ToBoolean(reader["Active"]), Cancelled = Convert.ToBoolean(reader["Cancelled"]), Paid = Convert.ToBoolean(reader["IsPaid"]), Password = reader["Password"] != DBNull.Value ? reader["Password"].ToString() : null, DateStarted = reader["DateStarted"] != DBNull.Value ? Convert.ToDateTime(reader["DateStarted"]) : default(DateTime?), DateEnded = reader["DateEnded"] != DBNull.Value ? Convert.ToDateTime(reader["DateEnded"]) : default(DateTime?) }; rooms.Add(id, rm); } } } connection.Close(); } return(new DataList <Event>(rooms.Values)); }
public void ConnectRoom(VirtualRoom otherRoom) { this.connectedRoomsIds.Add(otherRoom.sequentialId); }
public void OpenCorridorDoor(VirtualMap map, VirtualRoom room, CellLocation start_floor_loc, CellLocation end_floor_loc, CellLocation passage_loc, VirtualMap.DirectionType direction) { room.corridorExit++; room.corridorDoors.Add(passage_loc); OpenDoor(map, start_floor_loc, end_floor_loc, passage_loc, direction); }
public static DataList <Event> Room(long id, int tzOffset, int lang = 1, string conStr = "") { IDictionary <long, Event> events = new Dictionary <long, Event>(); using (SqlConnection connection = new SqlConnection(conStr)) { try { SqlCommand cmd = new SqlCommand("sp_ManageRooms", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Mode", Value = "getFull" }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Id", Value = id }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@TimeZoneOffset", Value = tzOffset }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@LanguageId", Value = lang }); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { long eventId = Convert.ToInt64(reader["Id"]); if (events.Keys.Contains(eventId) && reader["ParticipantId"] != DBNull.Value) { long userId = Convert.ToInt64(reader["ParticipantId"]); events[eventId].Participants.Add(new User { UserId = userId, FirstName = reader["PFirstName"] != DBNull.Value ? reader["PFirstName"].ToString() : null, LastName = reader["PLastName"] != DBNull.Value ? reader["PLastName"].ToString() : null, Email = reader["PEmail"] != DBNull.Value ? reader["PEmail"].ToString() : null, Online = Convert.ToBoolean(reader["Online"]), Phone = reader["PPhone"] != DBNull.Value ? reader["PPhone"].ToString() : null, Gender = Convert.ToBoolean(reader["PGender"]), MiniPic = reader["PMiniPicture"] != DBNull.Value ? reader["PMiniPicture"].ToString() : null, Role = new Role { Id = Convert.ToInt16(reader["PRoleId"]), Name = reader["PRName"] != DBNull.Value ? reader["PRName"].ToString() : null, Display = reader["PRDisplay"] != DBNull.Value ? reader["PRDisplay"].ToString() : null, } }); if (Convert.ToBoolean(reader["Joined"])) { events[eventId].Joined.Add(userId); } } else { Event room = new VirtualRoom { Id = eventId, RoomId = Convert.ToInt64(reader["RoomId"]), Title = reader["Title"].ToString(), Description = reader["Description"] != DBNull.Value ? reader["Description"].ToString() : "", Host = new User { UserId = Convert.ToInt64(reader["Host"]) }, DueDate = Convert.ToDateTime(reader["DueDate"]), Material = new Material(reader), UsesMathTools = Convert.ToBoolean(reader["UsesMathTools"]), Duration = Convert.ToInt32(reader["Duration"]), Active = Convert.ToBoolean(reader["Active"]), Running = Convert.ToBoolean(reader["Running"]), StartsWithoutHost = Convert.ToBoolean(reader["StartsWithoutHost"]), Cancelled = Convert.ToBoolean(reader["Cancelled"]), Paid = Convert.ToBoolean(reader["IsPaid"]), Password = reader["Password"] != DBNull.Value ? reader["Password"].ToString() : null, Participants = new List <User>(), Joined = new List <long>(), DateStarted = reader["DateStarted"] != DBNull.Value ? Convert.ToDateTime(reader["DateStarted"]) : default(DateTime?), DateEnded = reader["DateEnded"] != DBNull.Value ? Convert.ToDateTime(reader["DateEnded"]) : default(DateTime?) }; if (reader["ParticipantId"] != DBNull.Value) { long userId = Convert.ToInt64(reader["ParticipantId"]); room.Participants.Add(new User { UserId = userId, FirstName = reader["PFirstName"] != DBNull.Value ? reader["PFirstName"].ToString() : null, LastName = reader["PLastName"] != DBNull.Value ? reader["PLastName"].ToString() : null, Email = reader["PEmail"] != DBNull.Value ? reader["PEmail"].ToString() : null, Online = Convert.ToBoolean(reader["Online"]), Phone = reader["PPhone"] != DBNull.Value ? reader["PPhone"].ToString() : null, Gender = Convert.ToBoolean(reader["PGender"]), MiniPic = reader["PMiniPicture"] != DBNull.Value ? reader["PMiniPicture"].ToString() : null, Role = new Role { Id = Convert.ToInt16(reader["PRoleId"]), Name = reader["PRName"] != DBNull.Value ? reader["PRName"].ToString() : null, Display = reader["PRDisplay"] != DBNull.Value ? reader["PRDisplay"].ToString() : null, } }); if (Convert.ToBoolean(reader["Joined"])) { room.Joined.Add(userId); } } events.Add(eventId, room); } } } connection.Close(); }catch (Exception ex) { Console.WriteLine(ex.Message);//dummy code } } return(new DataList <Event>(events.Values)); }