Added booking class and phonebook sync logic

This commit is contained in:
Neil Dorin
2017-09-26 09:17:47 -06:00
parent 26907acb56
commit a2d42dc77b
3 changed files with 287 additions and 2 deletions

View File

@@ -135,6 +135,7 @@
<Compile Include="SetTopBox\IRSetTopBoxBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Streaming\Roku.cs" />
<Compile Include="VideoCodec\CiscoCodec\BookingsDataClasses.cs" />
<Compile Include="VideoCodec\CiscoCodec\CiscoCodec.cs" />
<Compile Include="VideoCodec\CiscoCodec\CiscoCodecPropertiesConfig.cs" />
<Compile Include="VideoCodec\CiscoCodec\PhonebookDataClasses.cs" />

View File

@@ -0,0 +1,229 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCodecBookings
{
public class TotalRows
{
public string Value { get; set; }
}
public class ResultInfo
{
public TotalRows TotalRows { get; set; }
}
public class LastUpdated
{
public DateTime Value { get; set; }
}
public class Id
{
public string Value { get; set; }
}
public class Title
{
public string Value { get; set; }
}
public class Agenda
{
public string Value { get; set; }
}
public class Privacy
{
public string Value { get; set; }
}
public class FirstName
{
public string Value { get; set; }
}
public class LastName
{
public string Value { get; set; }
}
public class Email
{
public string Value { get; set; }
}
public class Id2
{
public string Value { get; set; }
}
public class Organizer
{
public FirstName FirstName { get; set; }
public LastName LastName { get; set; }
public Email Email { get; set; }
public Id2 Id { get; set; }
}
public class StartTime
{
public DateTime Value { get; set; }
}
public class StartTimeBuffer
{
public string Value { get; set; }
}
public class EndTime
{
public DateTime Value { get; set; }
}
public class EndTimeBuffer
{
public string Value { get; set; }
}
public class Time
{
public StartTime StartTime { get; set; }
public StartTimeBuffer StartTimeBuffer { get; set; }
public EndTime EndTime { get; set; }
public EndTimeBuffer EndTimeBuffer { get; set; }
}
public class MaximumMeetingExtension
{
public string Value { get; set; }
}
public class MeetingExtensionAvailability
{
public string Value { get; set; }
}
public class BookingStatus
{
public string Value { get; set; }
}
public class BookingStatusMessage
{
public string Value { get; set; }
}
public class Enabled
{
public string Value { get; set; }
}
public class Url
{
public string Value { get; set; }
}
public class MeetingNumber
{
public string Value { get; set; }
}
public class Password
{
public string Value { get; set; }
}
public class HostKey
{
public string Value { get; set; }
}
public class DialInNumbers
{
}
public class Webex
{
public Enabled Enabled { get; set; }
public Url Url { get; set; }
public MeetingNumber MeetingNumber { get; set; }
public Password Password { get; set; }
public HostKey HostKey { get; set; }
public DialInNumbers DialInNumbers { get; set; }
}
public class Encryption
{
public string Value { get; set; }
}
public class Role
{
public string Value { get; set; }
}
public class Recording
{
public string Value { get; set; }
}
public class Calls
{
}
public class ConnectMode
{
public string Value { get; set; }
}
public class DialInfo
{
public Calls Calls { get; set; }
public ConnectMode ConnectMode { get; set; }
}
public class Booking
{
public string id { get; set; }
public Id Id { get; set; }
public Title Title { get; set; }
public Agenda Agenda { get; set; }
public Privacy Privacy { get; set; }
public Organizer Organizer { get; set; }
public Time Time { get; set; }
public MaximumMeetingExtension MaximumMeetingExtension { get; set; }
public MeetingExtensionAvailability MeetingExtensionAvailability { get; set; }
public BookingStatus BookingStatus { get; set; }
public BookingStatusMessage BookingStatusMessage { get; set; }
public Webex Webex { get; set; }
public Encryption Encryption { get; set; }
public Role Role { get; set; }
public Recording Recording { get; set; }
public DialInfo DialInfo { get; set; }
}
public class BookingsListResult
{
public string status { get; set; }
public ResultInfo ResultInfo { get; set; }
public LastUpdated LastUpdated { get; set; }
public List<Booking> Booking { get; set; }
}
public class CommandResponse
{
public BookingsListResult BookingsListResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
}
}

View File

@@ -143,6 +143,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
private CodecSyncState SyncState;
private CodecPhonebookSyncState PhonebookSyncState;
private StringBuilder JsonMessage;
private bool JsonFeedbackMessageIsIncoming;
@@ -181,7 +183,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
PhonebookMode = props.PhonebookMode;
SyncState = new CodecSyncState(key + "--sync");
SyncState = new CodecSyncState(key + "--Sync");
PhonebookSyncState = new CodecPhonebookSyncState(key + "--PhonebookSync");
SyncState.InitialSyncCompleted += new EventHandler<EventArgs>(SyncState_InitialSyncCompleted);
@@ -284,7 +288,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
if (!e.Client.IsConnected)
{
SyncState.CodecDisconnected();
PhonebookSyncState.CodecDisconnected();
}
}
/// <summary>
@@ -507,6 +514,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
JsonConvert.PopulateObject(response, CodecPhonebook);
if (!PhonebookSyncState.InitialPhonebookMessageWasReceived)
{
PhonebookSyncState.InitialPhonebookMessageReceived();
PhonebookSyncState.SetPhonebookHasFolders(CodecPhonebook.CommandResponse.PhonebookSearchResult.Folder.Count > 0);
}
Directory = CiscoCodecPhonebook.ConvertCiscoPhonebookToGeneric(CodecPhonebook.CommandResponse.PhonebookSearchResult);
if (Debug.Level > 1)
@@ -514,6 +528,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
//Print phonebook contents
}
}
else if (response.IndexOf("\"BookingsListResult\":{") > -1)
{
var codecBookings = new CiscoCodecBookings.RootObject();
JsonConvert.PopulateObject(response, codecBookings);
// Do something with this data....
}
}
@@ -578,7 +600,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
private void GetPhonebook()
{
// Get Phonebook (determine local/corporate from config, and set results limit)
// Get Phonebook Folders (determine local/corporate from config, and set results limit)
SendText(string.Format("xCommand Phonebook Search PhonebookType: {0} ContactType: Folder Limit: {1}", PhonebookMode, PhonebookResultsLimit));
}
@@ -834,4 +856,37 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
InitialSyncComplete = false;
}
}
public class CodecPhonebookSyncState : IKeyed
{
public string Key { get; private set; }
public bool InitialPhonebookMessageWasReceived { get; private set; }
public bool PhonebookHasFolders { get; private set; }
public CodecPhonebookSyncState(string key)
{
Key = key;
CodecDisconnected();
}
public void InitialPhonebookMessageReceived()
{
InitialPhonebookMessageWasReceived = true;
}
public void SetPhonebookHasFolders(bool value)
{
PhonebookHasFolders = value;
}
public void CodecDisconnected()
{
InitialPhonebookMessageWasReceived = false;
PhonebookHasFolders = false;
}
}
}