From b929113ea61c8f6ee0ebf9458e756e1a0c200867 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 2 Oct 2017 16:24:36 -0600 Subject: [PATCH] Added mechanism for Meetings list to notify UI layer of meeting events --- .../Codec/iHasCallHistory.cs | 107 ++---------------- .../Codec/iHasScheduleAwareness.cs | 77 ++++++++++++- .../Essentials Devices Common.csproj | 1 + .../CiscoCodec/CallHistoryDataClasses.cs | 97 ++++++++++++++++ .../VideoCodec/CiscoCodec/CiscoCodec.cs | 2 - 5 files changed, 179 insertions(+), 105 deletions(-) create mode 100644 Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs diff --git a/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs b/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs index c8b645a9..de26d3dc 100644 --- a/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs +++ b/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs @@ -5,6 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using PepperDash.Essentials.Devices.Common.VideoCodec; namespace PepperDash.Essentials.Devices.Common.Codec { @@ -15,7 +16,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec void RemoveCallHistoryEntry(CodecCallHistory.CallHistoryEntry entry); } - public enum eCodecOccurrenctType + public enum eCodecOccurrenceType { Unknown = 0, Placed, @@ -28,7 +29,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec /// public class CodecCallHistory { - event EventHandler RecentCallsListHasChanged; + public event EventHandler RecentCallsListHasChanged; public List RecentCalls { get; private set; } @@ -78,7 +79,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec public class CallHistoryEntry : CodecActiveCallItem { public DateTime StartTime { get; set; } - public eCodecOccurrenctType OccurenceType { get; set; } + public eCodecOccurrenceType OccurenceType { get; set; } public string OccurrenceHistoryId { get; set; } } @@ -115,117 +116,27 @@ namespace PepperDash.Essentials.Devices.Common.Codec /// Takes the Cisco occurence type and converts it to the matching enum /// /// Entry { get; set; } - public ResultInfo ResultInfo { get; set; } - } - - public class CommandResponse - { - public CallHistoryRecentsResult CallHistoryRecentsResult { get; set; } - } - - public class RootObject - { - public CommandResponse CommandResponse { get; set; } - } - } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs b/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs index 7edbec1c..45164f4f 100644 --- a/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs +++ b/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs @@ -6,6 +6,15 @@ using Crestron.SimplSharp; namespace PepperDash.Essentials.Devices.Common.Codec { + public enum eMeetingEventChangeType + { + Unkown = 0, + MeetingStartWarning, + MeetingStart, + MeetingEndWarning, + MeetingEnd + } + public interface IHasScheduleAwareness { CodecScheduleAwareness CodecSchedule { get; } @@ -13,11 +22,52 @@ namespace PepperDash.Essentials.Devices.Common.Codec public class CodecScheduleAwareness { + public event EventHandler MeetingEventChange; + + public event EventHandler MeetingsListHasChanged; + public List Meetings { get; set; } + private CTimer ScheduleChecker; + public CodecScheduleAwareness() { Meetings = new List(); + + ScheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000); + } + + private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting) + { + var handler = MeetingEventChange; + if (handler != null) + { + handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting }); + } + } + + private void CheckSchedule(object o) + { + // Iterate the meeting list and check if any meeting need to do anythingk + + foreach (Meeting m in Meetings) + { + eMeetingEventChangeType changeType = eMeetingEventChangeType.Unkown; + + if (m.TimeToMeetingStart.TotalMinutes == m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to start + changeType = eMeetingEventChangeType.MeetingStartWarning; + else if (m.TimeToMeetingStart.TotalMinutes == 0) // Meeting Start + changeType = eMeetingEventChangeType.MeetingStart; + else if (m.TimeToMeetingEnd.TotalMinutes == m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to end + changeType = eMeetingEventChangeType.MeetingEndWarning; + else if (m.TimeToMeetingEnd.TotalMinutes == 0) // Meeting has ended + changeType = eMeetingEventChangeType.MeetingEnd; + + if(changeType != eMeetingEventChangeType.Unkown) + OnMeetingChange(changeType, m); + } + + } } @@ -26,10 +76,25 @@ namespace PepperDash.Essentials.Devices.Common.Codec /// public class Meeting { + public TimeSpan MeetingWarningMinutes = TimeSpan.FromMinutes(5); + public string Id { get; set; } public string Organizer { get; set; } public string Title { get; set; } public string Agenda { get; set; } + public TimeSpan TimeToMeetingStart { + get + { + return StartTime - DateTime.Now; + } + } + public TimeSpan TimeToMeetingEnd + { + get + { + return EndTime - DateTime.Now; + } + } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public TimeSpan Duration @@ -44,12 +109,8 @@ namespace PepperDash.Essentials.Devices.Common.Codec { get { - var timeToMeetingStart = StartTime - DateTime.Now; - - var timetoMeetingEnd = DateTime.Now - EndTime; - // Meeting is joinable from 5 minutes before start until 5 minutes before end - if (timeToMeetingStart.Minutes <= 5 && timetoMeetingEnd.Minutes >= 5) + if (TimeToMeetingStart.TotalMinutes <= MeetingWarningMinutes.TotalMinutes && TimeToMeetingEnd.TotalMinutes >= MeetingWarningMinutes.TotalMinutes) return true; else return false; @@ -58,4 +119,10 @@ namespace PepperDash.Essentials.Devices.Common.Codec public string ConferenceNumberToDial { get; set; } public string ConferencePassword { get; set; } } + + public class MeetingEventArgs : EventArgs + { + public eMeetingEventChangeType ChangeType { get; set; } + public Meeting Meeting { get; set; } + } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index 348bbe0d..ac091ca2 100644 --- a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -139,6 +139,7 @@ + diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs new file mode 100644 index 00000000..c5749b7a --- /dev/null +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + public class CiscoCallHistory + { + public class CallbackNumber + { + public string Value { get; set; } + } + + public class DisplayName + { + public string Value { get; set; } + } + + public class LastOccurrenceStartTime + { + public DateTime Value { get; set; } + } + + public class LastOccurrenceDaysAgo + { + public string Value { get; set; } + } + + public class LastOccurrenceHistoryId + { + public string Value { get; set; } + } + + public class OccurrenceType + { + public string Value { get; set; } + } + + public class IsAcknowledged + { + public string Value { get; set; } + } + + public class OccurrenceCount + { + public string Value { get; set; } + } + + public class Entry + { + public string id { get; set; } + public CallbackNumber CallbackNumber { get; set; } + public DisplayName DisplayName { get; set; } + public LastOccurrenceStartTime LastOccurrenceStartTime { get; set; } + public LastOccurrenceDaysAgo LastOccurrenceDaysAgo { get; set; } + public LastOccurrenceHistoryId LastOccurrenceHistoryId { get; set; } + public OccurrenceType OccurrenceType { get; set; } + public IsAcknowledged IsAcknowledged { get; set; } + public OccurrenceCount OccurrenceCount { get; set; } + } + + public class Offset + { + public string Value { get; set; } + } + + public class Limit + { + public string Value { get; set; } + } + + public class ResultInfo + { + public Offset Offset { get; set; } + public Limit Limit { get; set; } + } + + public class CallHistoryRecentsResult + { + public string status { get; set; } + public List Entry { get; set; } + public ResultInfo ResultInfo { get; set; } + } + + public class CommandResponse + { + public CallHistoryRecentsResult CallHistoryRecentsResult { get; set; } + } + + public class RootObject + { + public CommandResponse CommandResponse { get; set; } + } + } +} \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs index c9b6d7b2..6fd2ed96 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs @@ -22,8 +22,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public class CiscoCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectory, IHasScheduleAwareness { - public event EventHandler UpcomingMeetingWarning; - public event EventHandler DirectoryResultReturned; public IBasicCommunication Communication { get; private set; }