diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 0c3778c8..8b7940ff 100644 Binary files a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo and b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo differ diff --git a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo index 58baeaf5..86c06b9f 100644 Binary files a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo and b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo differ diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo index 64d5ed77..e063b4ea 100644 Binary files a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo and b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo differ diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index a9808e15..381d83b1 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -40,7 +40,7 @@ namespace PepperDash.Essentials }, "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); - //GoWithLoad(); + GoWithLoad(); } /// diff --git a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs index 29fc2643..041b5a88 100644 --- a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs +++ b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs @@ -47,6 +47,11 @@ namespace PepperDash.Essentials.Fusion bool GuidFileExists; + bool IsRegisteredForSchedulePushNotifications = false; + + // Default poll time is 5 min unless overridden by config value + int SchedulePollInterval = 300000; + List StaticAssets; //ScheduleResponseEvent NextMeeting; @@ -263,22 +268,40 @@ namespace PepperDash.Essentials.Fusion { if (args.DeviceOnLine) { + CrestronEnvironment.Sleep(200); + // Send Push Notification Action request: string requestID = "InitialPushRequest"; - string actionRequest = - string.Format("{0}{1}", requestID, RoomGuid) + - "RegisterPushModel" + - "" + - "" + - "" + - "" + - "" + - "'"; + string actionRequest = + string.Format("\n{0}\n", requestID) + + "RegisterPushModel\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + //"\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n"; - Debug.Console(1, this, "Sending Fusion ScheduleQuery: \n{0}", actionRequest); + Debug.Console(1, this, "Sending Fusion ActionRequest: \n{0}", actionRequest); FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest; } @@ -373,6 +396,27 @@ namespace PepperDash.Essentials.Fusion { try { + ActionResponse actionResponse = new ActionResponse(); + + TextReader reader = new StringReader(args.Sig.StringValue); + + actionResponse = CrestronXMLSerialization.DeSerializeObject(reader); + + if (actionResponse.RequestID == "InitialPushRequest") + { + var tempParam = actionResponse.Parameters.FirstOrDefault(p => p.ID.Equals("Registered")); + + if (tempParam != null) + { + if (tempParam.Value = 1) + IsRegisteredForSchedulePushNotifications = true; + else + { + IsRegisteredForSchedulePushNotifications = false; + } + } + } + } catch (Exception e) @@ -397,61 +441,58 @@ namespace PepperDash.Essentials.Fusion message.LoadXml(args.Sig.StringValue); - if (message.FirstChild.Name == "ScheduleResponse") + var scheuldResponse = message["ScheduleRespones"]; + + if (scheuldResponse != null) { - foreach (XmlElement element in message.FirstChild.ChildNodes) + // Check for push notification + if (scheuldResponse["RequestID"].InnerText == "RVRequest") { - if (element.Name == "RequestID") + var action = scheuldResponse["Action"]; + + if (action.InnerText.IndexOf("RequestSchedule") > -1) { - scheduleResponse.RequestID = element.InnerText; + RequestFullRoomSchedule("PushScheduleRefresh"); } - else if (element.Name == "RoomID") - { - scheduleResponse.RoomID = element.InnerText; - } - else if (element.Name == "RoomName") - { - scheduleResponse.RoomName = element.InnerText; - } - else if (element.Name == "Event") - { - Debug.Console(1, this, "Event Found:\n{0}", element.OuterXml); - - XmlReader reader = new XmlReader(element.OuterXml); - - Event tempEvent = new Event(); - - tempEvent = CrestronXMLSerialization.DeSerializeObject(reader); - - scheduleResponse.Events.Add(tempEvent); - } - } - } - - //XmlReader reader = new XmlReader(args.Sig.StringValue); - - //scheduleResponse = CrestronXMLSerialization.DeSerializeObject(reader); - - //Debug.Console(1, this, "ScheduleResponse DeSerialization Successful for Room: '{0}'", scheduleResponse.RoomName); - - if (scheduleResponse.Events.Count > 0) - { - Debug.Console(1, this, "Meetings Count: {0}\n", scheduleResponse.Events.Count); - - foreach (Event e in scheduleResponse.Events) + else // Not a push notification { - Debug.Console(1, this, "Subject: {0}", e.Subject); - Debug.Console(1, this, "MeetingID: {0}", e.MeetingID); - Debug.Console(1, this, "Start Time: {0}", e.dtStart); - Debug.Console(1, this, "End Time: {0}\n", e.dtEnd); - var duration = e.dtEnd.Subtract(e.dtStart); - Debug.Console(1, this, "Duration: {0} minutes", duration.Minutes); + + foreach (XmlElement element in message.FirstChild.ChildNodes) + { + if (element.Name == "RequestID") + { + scheduleResponse.RequestID = element.InnerText; + } + else if (element.Name == "RoomID") + { + scheduleResponse.RoomID = element.InnerText; + } + else if (element.Name == "RoomName") + { + scheduleResponse.RoomName = element.InnerText; + } + else if (element.Name == "Event") + { + Debug.Console(1, this, "Event Found:\n{0}", element.OuterXml); + + XmlReader reader = new XmlReader(element.OuterXml); + + Event tempEvent = new Event(); + + tempEvent = CrestronXMLSerialization.DeSerializeObject(reader); + + scheduleResponse.Events.Add(tempEvent); + } + + } } } CurrentSchedule = scheduleResponse; + PrintTodaysSchedule(); + } catch (Exception e) { @@ -460,6 +501,25 @@ namespace PepperDash.Essentials.Fusion } } + void PrintTodaysSchedule() + { + if (CurrentSchedule.Events.Count > 0) + { + Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name); + + foreach (Event e in CurrentSchedule.Events) + { + Debug.Console(1, this, "Subject: {0}", e.Subject); + Debug.Console(1, this, "Organizer: {0}", e.Organizer); + Debug.Console(1, this, "MeetingID: {0}", e.MeetingID); + Debug.Console(1, this, "Start Time: {0}", e.dtStart); + Debug.Console(1, this, "End Time: {0}", e.dtEnd); + var duration = e.dtEnd.Subtract(e.dtStart); + Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes); + } + } + } + void SetUpSources() { // Sources @@ -936,6 +996,17 @@ namespace PepperDash.Essentials.Fusion } } + //[XmlRoot(ElementName = "ActionResponse")] + public class ActionResponse + { + //[XmlElement(ElementName = "RequestID")] + public string RequestID { get; set; } + //[XmlElement(ElementName = "ActionID")] + public string ActionID { get; set; } + //[XmlElement(ElementName = "Parameters")] + public List Parameters { get; set; } + } + //[XmlRoot(ElementName = "Parameter")] public class Parameter { @@ -1020,6 +1091,93 @@ namespace PepperDash.Essentials.Fusion public string HaveAttendees { get; set; } //[XmlElement(ElementName = "HaveResources")] public string HaveResources { get; set; } + + /// + /// Gets the duration of the meeting + /// + public string DurationInMinutes + { + get + { + string duration; + + var timeSpan = dtEnd.Subtract(dtStart); + int hours = timeSpan.Hours; + double minutes = timeSpan.Minutes; + double roundedMinutes = Math.Round(minutes); + if(hours > 0) + { + duration = string.Format("{0} hours {1} minutes", hours, roundedMinutes); + } + else + { + duration = string.Format("{0} minutes", roundedMinutes); + } + + return duration; + } + } + + /// + /// Gets the remaining time in the meeting. Returns null if the meeting is not currently in progress. + /// + public string RemainingTime + { + get + { + var now = DateTime.Now; + + string remainingTime; + + if (GetInProgress()) + { + var timeSpan = dtEnd.Subtract(now); + int hours = timeSpan.Hours; + double minutes = timeSpan.Minutes; + double roundedMinutes = Math.Round(minutes); + if (hours > 0) + { + remainingTime = string.Format("{0} hours {1} minutes", hours, roundedMinutes); + } + else + { + remainingTime = string.Format("{0} minutes", roundedMinutes); + } + + return remainingTime; + } + else + return null; + } + + } + + /// + /// Indicates that the meeting is in progress + /// + public bool isInProgress + { + get + { + return GetInProgress(); + } + } + + /// + /// Determines if the meeting is in progress + /// + /// Returns true if in progress + bool GetInProgress() + { + var now = DateTime.Now; + + if (now > dtStart && now < dtEnd) + { + return true; + } + else + return false; + } } //[XmlRoot(ElementName = "Resources")] diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index d3ee2011..f1d15bf4 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ