mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
Added generic codec directory interface and cisco specific phonebook classes for deserialization
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.Codec
|
||||
{
|
||||
public interface iHasDirectory
|
||||
{
|
||||
CodecDirectory Directory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches the directory and returns a result
|
||||
/// </summary>
|
||||
/// <param name="searchString"></param>
|
||||
/// <param name="key"></param>
|
||||
void SearchDirectory(string searchString, string key);
|
||||
}
|
||||
|
||||
public class CodecDirectory
|
||||
{
|
||||
public List<DirectoryFolder> Folders {get; private set;}
|
||||
|
||||
public List<DirectoryContact> Contacts { get; private set; }
|
||||
|
||||
public int Offset { get; private set; }
|
||||
|
||||
public int Limit { get; private set; }
|
||||
|
||||
public CodecDirectory()
|
||||
{
|
||||
Folders = new List<DirectoryFolder>();
|
||||
Contacts = new List<DirectoryContact>();
|
||||
}
|
||||
}
|
||||
|
||||
public class DirectoryFolder
|
||||
{
|
||||
public List<DirectoryContact> Contacts { get; set; }
|
||||
public string FolderId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DirectoryFolder ParentFolder { get; set; }
|
||||
|
||||
public DirectoryFolder()
|
||||
{
|
||||
Contacts = new List<DirectoryContact>();
|
||||
ParentFolder = new DirectoryFolder();
|
||||
}
|
||||
}
|
||||
|
||||
public class DirectoryContact
|
||||
{
|
||||
public string ContactId { get; set; }
|
||||
public DirectoryFolder Folder { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Title { get; set; }
|
||||
public List<ContactMethod> ContactMethods { get; set; }
|
||||
}
|
||||
|
||||
public class ContactMethod
|
||||
{
|
||||
public string ContactMethodId { get; set; }
|
||||
public string Number { get; set; }
|
||||
public eContactMethodDevice Device { get; set; }
|
||||
public eContactMethodCallType CallType { get; set; }
|
||||
}
|
||||
|
||||
public enum eContactMethodDevice
|
||||
{
|
||||
Unknown = 0,
|
||||
Mobile,
|
||||
Other,
|
||||
Telephone,
|
||||
Video
|
||||
}
|
||||
|
||||
public enum eContactMethodCallType
|
||||
{
|
||||
Unknown = 0,
|
||||
Audio,
|
||||
Video
|
||||
}
|
||||
|
||||
public class DirectorySearchResultEventArgs : EventArgs
|
||||
{
|
||||
public CodecDirectory Directory { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,7 @@
|
||||
<Compile Include="Codec\iHasCallFavorites.cs" />
|
||||
<Compile Include="Codec\iHasCallHistory.cs" />
|
||||
<Compile Include="Codec\iHasDialer.cs" />
|
||||
<Compile Include="Codec\iHasDirectory.cs" />
|
||||
<Compile Include="Crestron\Gateways\CenRfgwController.cs" />
|
||||
<Compile Include="Display\ComTcpDisplayBase.cs" />
|
||||
<Compile Include="Display\SamsungMDCDisplay.cs" />
|
||||
@@ -136,6 +137,7 @@
|
||||
<Compile Include="Streaming\Roku.cs" />
|
||||
<Compile Include="VideoCodec\CiscoCodec\CiscoCodec.cs" />
|
||||
<Compile Include="VideoCodec\CiscoCodec\CiscoCodecPropertiesConfig.cs" />
|
||||
<Compile Include="VideoCodec\CiscoCodec\PhonebookDataClasses.cs" />
|
||||
<Compile Include="VideoCodec\CiscoCodec\xConfiguration.cs" />
|
||||
<Compile Include="VideoCodec\CiscoCodec\xEvent.cs" />
|
||||
<Compile Include="VideoCodec\CiscoCodec\HttpApiServer.cs" />
|
||||
|
||||
@@ -43,10 +43,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
private CiscoCodecStatus.RootObject CodecStatus;
|
||||
|
||||
private CiscoCodecPhonebook.RootObject CodecPhonebook;
|
||||
|
||||
public CodecCallHistory CallHistory { get; private set; }
|
||||
|
||||
public CodecCallFavorites CallFavorites { get; private set; }
|
||||
|
||||
public CodecDirectory Directory { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets and returns the scaled volume of the codec
|
||||
/// </summary>
|
||||
@@ -170,7 +174,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
}
|
||||
else
|
||||
{
|
||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 2000, 120000, 300000, "xStatus SystemUnit Software Version\r");
|
||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "xStatus SystemUnit Software Version\r");
|
||||
}
|
||||
|
||||
DeviceManager.AddDevice(CommunicationMonitor);
|
||||
@@ -191,11 +195,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
CodecConfiguration = new CiscoCodecConfiguration.RootObject();
|
||||
CodecStatus = new CiscoCodecStatus.RootObject();
|
||||
CodecPhonebook = new CiscoCodecPhonebook.RootObject();
|
||||
|
||||
CallHistory = new CodecCallHistory();
|
||||
|
||||
CallFavorites = new CodecCallFavorites();
|
||||
CallFavorites.Favorites = props.Favorites;
|
||||
|
||||
Directory = new CodecDirectory();
|
||||
|
||||
//Set Feedback Actions
|
||||
CodecStatus.Status.Audio.Volume.ValueChangedAction = VolumeLevelFeedback.FireUpdate;
|
||||
@@ -207,22 +214,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
CodecStatus.Status.Cameras.SpeakerTrack.Status.ValueChangedAction = SpeakerTrackIsOnFeedback.FireUpdate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires when initial codec sync is completed. Used to then send commands to get call history, phonebook, bookings, etc.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void SyncState_InitialSyncCompleted(object sender, EventArgs e)
|
||||
{
|
||||
GetCallHistory();
|
||||
|
||||
// Get bookings for the day
|
||||
//SendText("xCommand Bookings List Days: 1 DayOffset: 0");
|
||||
|
||||
// Get Phonebook (determine local/corporate from config, and set results limit)
|
||||
SendText(string.Format("xCommand Phonebook Search PhonebookType: {0} ContactType: Folder Limit: {1}", PhonebookMode, PhonebookResultsLimit));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the HTTP feedback server and syncronizes state of codec
|
||||
/// </summary>
|
||||
@@ -261,6 +252,21 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires when initial codec sync is completed. Used to then send commands to get call history, phonebook, bookings, etc.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void SyncState_InitialSyncCompleted(object sender, EventArgs e)
|
||||
{
|
||||
GetCallHistory();
|
||||
|
||||
// Get bookings for the day
|
||||
//SendText("xCommand Bookings List Days: 1 DayOffset: 0");
|
||||
|
||||
GetPhonebook();
|
||||
}
|
||||
|
||||
public void SetCommDebug(string s)
|
||||
{
|
||||
if (s == "1")
|
||||
@@ -491,14 +497,25 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
JsonConvert.PopulateObject(response, codecCallHistory);
|
||||
|
||||
CallHistory.ConvertCiscoCallHistoryToGeneric(codecCallHistory.CommandResponse.CallHistoryRecentsResult.Entry);
|
||||
CallHistory.ConvertCiscoCallHistoryToGeneric(codecCallHistory.CommandResponse.CallHistoryRecentsResult.Entry);
|
||||
}
|
||||
else if (response.IndexOf("\"CallHistoryDeleteEntryResult\":{") > -1)
|
||||
{
|
||||
GetCallHistory();
|
||||
}
|
||||
else if (response.IndexOf("\"PhonebookSearchResult\":{") > -1)
|
||||
{
|
||||
JsonConvert.PopulateObject(response, CodecPhonebook);
|
||||
|
||||
}
|
||||
Directory = CiscoCodecPhonebook.ConvertCiscoPhonebookToGeneric(CodecPhonebook.CommandResponse.PhonebookSearchResult);
|
||||
|
||||
if (Debug.Level > 1)
|
||||
{
|
||||
//Print phonebook contents
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -559,6 +576,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
SendText("xCommand CallHistory Recents Limit: 20 Order: OccurrenceTime");
|
||||
}
|
||||
|
||||
private void GetPhonebook()
|
||||
{
|
||||
// Get Phonebook (determine local/corporate from config, and set results limit)
|
||||
SendText(string.Format("xCommand Phonebook Search PhonebookType: {0} ContactType: Folder Limit: {1}", PhonebookMode, PhonebookResultsLimit));
|
||||
}
|
||||
|
||||
public override void Dial(string s)
|
||||
{
|
||||
SendText(string.Format("xCommand Dial Number: \"{0}\"", s));
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Devices.Common.Codec;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
{
|
||||
public class CiscoCodecPhonebook
|
||||
{
|
||||
public class Offset
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class Limit
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class TotalRows
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class ResultInfo
|
||||
{
|
||||
public Offset Offset { get; set; }
|
||||
public Limit Limit { get; set; }
|
||||
public TotalRows TotalRows { get; set; }
|
||||
}
|
||||
|
||||
public class LocalId
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class FolderId
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class ParentFolderId
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class Name
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class Folder
|
||||
{
|
||||
public string id { get; set; }
|
||||
public LocalId LocalId { get; set; }
|
||||
public FolderId FolderId { get; set; }
|
||||
public Name Name { get; set; }
|
||||
public ParentFolderId ParentFolderId { get; set; }
|
||||
}
|
||||
|
||||
public class Name2
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class ContactId
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class FolderId2
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class Title
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class ContactMethodId
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class Number
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class Device
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class CallType
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class ContactMethod
|
||||
{
|
||||
public string id { get; set; }
|
||||
public ContactMethodId ContactMethodId { get; set; }
|
||||
public Number Number { get; set; }
|
||||
public Device Device { get; set; }
|
||||
public CallType CallType { get; set; }
|
||||
}
|
||||
|
||||
public class Contact
|
||||
{
|
||||
public string id { get; set; }
|
||||
public Name2 Name { get; set; }
|
||||
public ContactId ContactId { get; set; }
|
||||
public FolderId2 FolderId { get; set; }
|
||||
public Title Title { get; set; }
|
||||
public List<ContactMethod> ContactMethod { get; set; }
|
||||
}
|
||||
|
||||
public class PhonebookSearchResult
|
||||
{
|
||||
public string status { get; set; }
|
||||
public ResultInfo ResultInfo { get; set; }
|
||||
public List<Folder> Folder { get; set; }
|
||||
public List<Contact> Contact { get; set; }
|
||||
|
||||
public PhonebookSearchResult()
|
||||
{
|
||||
Folder = new List<Folder>();
|
||||
Contact = new List<Contact>();
|
||||
ResultInfo = new ResultInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandResponse
|
||||
{
|
||||
public PhonebookSearchResult PhonebookSearchResult { get; set; }
|
||||
}
|
||||
|
||||
public class RootObject
|
||||
{
|
||||
public CommandResponse CommandResponse { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts data returned from a cisco codec to the generic Directory format.
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public static CodecDirectory ConvertCiscoPhonebookToGeneric(PhonebookSearchResult result)
|
||||
{
|
||||
var directory = new Codec.CodecDirectory();
|
||||
|
||||
if (result.Folder.Count > 0)
|
||||
{
|
||||
foreach (Folder f in result.Folder)
|
||||
{
|
||||
var folder = new DirectoryFolder();
|
||||
|
||||
folder.Name = f.Name.Value;
|
||||
folder.FolderId = f.FolderId.Value;
|
||||
|
||||
if (f.ParentFolderId != null)
|
||||
{
|
||||
|
||||
folder.ParentFolder = directory.Folders.FirstOrDefault(fld => fld.FolderId.Equals(f.ParentFolderId.Value));
|
||||
}
|
||||
|
||||
directory.Folders.Add(folder);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.Contact.Count > 0)
|
||||
{
|
||||
foreach (Contact c in result.Contact)
|
||||
{
|
||||
var contact = new DirectoryContact();
|
||||
|
||||
contact.Name = c.Name.Value;
|
||||
contact.ContactId = c.ContactId.Value;
|
||||
contact.Title = c.Title.Value;
|
||||
|
||||
// Go find the folder to which this contact belongs and store it
|
||||
if(!string.IsNullOrEmpty(c.FolderId.Value))
|
||||
{
|
||||
contact.Folder = directory.Folders.FirstOrDefault(f => f.FolderId.Equals(c.FolderId.Value));
|
||||
}
|
||||
|
||||
foreach (ContactMethod m in c.ContactMethod)
|
||||
{
|
||||
eContactMethodCallType callType = eContactMethodCallType.Unknown;
|
||||
if(m.CallType != null)
|
||||
{
|
||||
if(m.CallType.Value.ToLower() == "audio")
|
||||
callType = eContactMethodCallType.Audio;
|
||||
else if (m.CallType.Value.ToLower() == "video")
|
||||
callType = eContactMethodCallType.Video;
|
||||
}
|
||||
|
||||
eContactMethodDevice device = eContactMethodDevice.Unknown;
|
||||
|
||||
if (m.Device.Value.ToLower() == "mobile")
|
||||
device = eContactMethodDevice.Mobile;
|
||||
else if (m.Device.Value.ToLower() == "telephone")
|
||||
device = eContactMethodDevice.Telephone;
|
||||
else if (m.Device.Value.ToLower() == "video")
|
||||
device = eContactMethodDevice.Video;
|
||||
else if (m.Device.Value.ToLower() == "other")
|
||||
device = eContactMethodDevice.Other;
|
||||
|
||||
contact.ContactMethods.Add(new PepperDash.Essentials.Devices.Common.Codec.ContactMethod()
|
||||
{
|
||||
Number = m.Number.Value,
|
||||
ContactMethodId = m.ContactMethodId.Value,
|
||||
CallType = callType,
|
||||
Device = device
|
||||
});
|
||||
}
|
||||
directory.Contacts.Add(contact);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,8 +29,8 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public override void InitializeSystem()
|
||||
{
|
||||
CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file",
|
||||
ConsoleAccessLevelEnum.AccessOperator);
|
||||
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
//CrestronConsole.AddNewConsoleCommand(s => TearDown(), "ungo", "Unloads configuration file",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(s =>
|
||||
@@ -40,7 +40,7 @@ namespace PepperDash.Essentials
|
||||
},
|
||||
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
//GoWithLoad();
|
||||
GoWithLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user