diff --git a/.github/workflows/EssentialsPlugins-builds-caller.yml b/.github/workflows/EssentialsPlugins-builds-caller.yml new file mode 100644 index 0000000..7611bd3 --- /dev/null +++ b/.github/workflows/EssentialsPlugins-builds-caller.yml @@ -0,0 +1,30 @@ +name: Build Essentials Plugin + +on: + push: + branches-ignore: + - 'robot-docs' +jobs: + checkCommitMessage: + uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-checkCommitMessage.yml@development + secrets: inherit + call-update-readme: + uses: PepperDash/readme-automation/.github/workflows/update-readme.yml@main + secrets: inherit + needs: checkCommitMessage + with: + target-branch: ${{ github.ref_name }} + getVersion: + uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-getversion.yml@development + secrets: inherit + needs: checkCommitMessage + build-4Series: + uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-4Series-builds.yml@development + secrets: inherit + needs: getVersion + if: needs.getVersion.outputs.newVersion == 'true' + with: + newVersion: ${{ needs.getVersion.outputs.newVersion }} + version: ${{ needs.getVersion.outputs.version }} + tag: ${{ needs.getVersion.outputs.tag }} + channel: ${{ needs.getVersion.outputs.channel }} diff --git a/.github/workflows/essentialsplugins-betabuilds-caller.yml b/.github/workflows/essentialsplugins-betabuilds-caller.yml deleted file mode 100644 index 8ca618c..0000000 --- a/.github/workflows/essentialsplugins-betabuilds-caller.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Beta Build - -on: - push: - branches-ignore: - - "main" - - workflow_dispatch: - inputs: - branch: - description: 'Branch to build' - required: true - type: string - -jobs: - call-workflow: - uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-builds.yml@main - secrets: inherit - with: - branch: ${{ github.ref_name }} - default-branch: "main" - diff --git a/.github/workflows/essentialsplugins-releasebuilds-caller.yml b/.github/workflows/essentialsplugins-releasebuilds-caller.yml deleted file mode 100644 index 3b34e10..0000000 --- a/.github/workflows/essentialsplugins-releasebuilds-caller.yml +++ /dev/null @@ -1,26 +0,0 @@ - -name: Release Build - -on: - release: - types: - - released - branches: - - "main" - - workflow_dispatch: - inputs: - branch: - description: 'Branch to build' - required: true - type: string - -jobs: - call-workflow: - uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-builds.yml@main - secrets: inherit - with: - branch: ${{ github.ref_name }} - default-branch: "main" - - diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..c4bd268 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,34 @@ +{ + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "releaseRules": [ + { "scope": "force-patch", "release": "patch" }, + { "scope": "no-release", "release": false } + ] + } + ], + "@semantic-release/release-notes-generator", + ["@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/exec", + { + "verifyReleaseCmd": "echo \"newVersion=true\" >> $GITHUB_OUTPUT", + "publishCmd": "echo \"version=${nextRelease.version}\" >> $GITHUB_OUTPUT && echo \"tag=${nextRelease.gitTag}\" >> $GITHUB_OUTPUT && echo \"type=${nextRelease.type}\" >> $GITHUB_OUTPUT && echo \"channel=${nextRelease.channel}\" >> $GITHUB_OUTPUT" + } + ] + ], + "branches": [ + "main", + { + "name": "replace-me-feature-branch", + "prerelease": "replace-me-prerelease", + "channel": "replace-me-prerelease" + } + ] +} \ No newline at end of file diff --git a/DynFusionEPI/Properties/ControlSystem.cfg b/LICENSE.md similarity index 100% rename from DynFusionEPI/Properties/ControlSystem.cfg rename to LICENSE.md diff --git a/PDT.DynFusion.EPI.sln b/PDT.DynFusion.EPI.3series.sln similarity index 90% rename from PDT.DynFusion.EPI.sln rename to PDT.DynFusion.EPI.3series.sln index cfaa4c3..8d2b1aa 100644 --- a/PDT.DynFusion.EPI.sln +++ b/PDT.DynFusion.EPI.3series.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDTDynFusionEPI", "DynFusionEPI/PDTDynFusionEPI.csproj", "{9D249E47-8F95-4437-A6BB-563510287AD1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDTDynFusionEPI", "src\PDTDynFusionEPI.csproj", "{9D249E47-8F95-4437-A6BB-563510287AD1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/epi-crestron-fusion.4series.sln b/epi-crestron-fusion.4series.sln new file mode 100644 index 0000000..dca0a88 --- /dev/null +++ b/epi-crestron-fusion.4series.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "epi-crestron-fusion.4series", "src\epi-crestron-fusion.4series.csproj", "{B28AA204-985A-4730-974C-FEBA5E7894C6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B28AA204-985A-4730-974C-FEBA5E7894C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B28AA204-985A-4730-974C-FEBA5E7894C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B28AA204-985A-4730-974C-FEBA5E7894C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B28AA204-985A-4730-974C-FEBA5E7894C6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C239DD33-FA40-42F8-8B96-9689D52B2780} + EndGlobalSection +EndGlobal diff --git a/output/epi-crestron-fusion.4series.1.0.0-local.cplz b/output/epi-crestron-fusion.4series.1.0.0-local.cplz new file mode 100644 index 0000000..03cb68f --- /dev/null +++ b/output/epi-crestron-fusion.4series.1.0.0-local.cplz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b9dbe577c01739cb66f695bf0604a12f08e5a5bd5501a93cdab88f6c9632cbd +size 8316886 diff --git a/DynFusionEPI/AvailableRooms.cs b/src/AvailableRooms.cs similarity index 97% rename from DynFusionEPI/AvailableRooms.cs rename to src/AvailableRooms.cs index 2f570cd..dd6a044 100644 --- a/DynFusionEPI/AvailableRooms.cs +++ b/src/AvailableRooms.cs @@ -1,363 +1,363 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronXml; -using Crestron.SimplSharp.CrestronXml.Serialization; -using Crestron.SimplSharp.CrestronXmlLinq; -using Crestron.SimplSharpPro.Fusion; -using Crestron.SimplSharpPro; - - - -using PepperDash.Core; - -namespace DynFusion -{ - - public class Room - { - public string RoomID { get; set; } - public string RoomName { get; set; } - public string Location { get; set; } - public bool OnlineStatus { get; set; } - public double availableMinutes - { - get - { - double returnValue; - if (this.FreeBusyStatus.Contains("T")) - { - DateTime tempTime = DateTime.Parse(FreeBusyStatus); - //CrestronConsole.PrintLine(tempTime.ToString()); - if (tempTime > DateTime.Now) - { - returnValue = Math.Round(tempTime.Subtract(DateTime.Now).TotalMinutes); - } - else { returnValue = 0; } - } - - else { returnValue = 0; } - - return returnValue; - - } - } - public string FreeBusyStatus { get; set; } - - } - - - public class DynFusionScheduleAvailableRooms - { - public bool includeInAvailbleRooms; - private CTimer getAvailableRoomsTimeOut; - private bool _availableRoomStatus; - public bool AvailableRoomStatus - { - set - { - this._availableRoomStatus = value; - OnAvailableRoomsBusy(this, _availableRoomStatus); - if (_availableRoomStatus) { getAvailableRoomsTimeOut = new CTimer(getAvailableRoomsTimeout, 6000); } - else { getAvailableRoomsTimeOut.Stop(); } - } - } - // I would love to poll and have data ready to go but we think it may be too heavy a server load. JTA 2017-12-06 - // CTimer updateAvailableRooms = null; - private DynFusionDevice _DynFusion; - public List RoomList = new List(); - public List FilterList = new List(); - public delegate void AvailableRoomUpdate(object sender, List RoomList); - public event AvailableRoomUpdate OnAvailableRoomsUpdate; - public delegate void AvailableRoomsBusy(object sender, bool busyStatus); - public event AvailableRoomsBusy OnAvailableRoomsBusy; - - public DynFusionScheduleAvailableRooms(DynFusionDevice DynFusionInstance) - { - _DynFusion = DynFusionInstance; - _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(FusionRoomDataExtenderSigChange); - // I would love to poll and have data ready to go but we think it may be too heavy a server load. JTA 2017-12-06 - // updateAvailableRooms = new CTimer(GetRoomList, null, 300000, 300000); - } - - - - private void getAvailableRoomsTimeout(object unused) - { - Debug.ConsoleWithLog(DebugExtensions.Warn, "getAvailableRoomsTimeout error", 3); - this.AvailableRoomStatus = false; - } - public void sendFreeBusyStatusAvailableUntil(DateTime AvailableUntilTime) - { - // "2017-12-09T00:00:00" - _DynFusion.FusionSymbol.FreeBusyStatusToRoom.InputSig.StringValue = string.Format("{0}", AvailableUntilTime.ToString("yyyy-MM-ddTHH:mm:00")); - Debug.Console(DebugExtensions.Verbose, string.Format("Sending FreeBusyStatus {0}", AvailableUntilTime.ToString("yyyy-MM-ddTHH:mm:00"))); - } - public void sendFreeBusyStatusAvailable() - { - _DynFusion.FusionSymbol.FreeBusyStatusToRoom.InputSig.StringValue = string.Format("{0}", DateTime.Now.AddDays(5).ToString("yyyy-MM-ddT00:00:00")); - Debug.Console(DebugExtensions.Verbose, "Sending FreeBusyStatus {0}", DateTime.Now.AddDays(5).ToString("yyyy-MM-ddT00:00:00")); - } - public void sendFreeBusyStatusNotAvailable() - { - _DynFusion.FusionSymbol.FreeBusyStatusToRoom.InputSig.StringValue = string.Format("-"); - Debug.Console(2, string.Format("-")); - } - private void GetRoomList(object unused) - { - GetRoomList(); - } - public void GetRoomList() - { - try - { - if (_DynFusion.FusionSymbol.IsOnline) - { - this.AvailableRoomStatus = true; - - string fusionRoomListRequest = ""; - //TODO This needs to be implemented - // fusionRoomListRequest = String.Format("RoomListRequestLocation{0}", _DynFusion.FusionRoomInfo.roomInformation.Location); - Debug.Console(DebugExtensions.Verbose, String.Format("RoomList Request: {0}", fusionRoomListRequest)); - - _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomListQuery.StringValue = fusionRoomListRequest; - } - } - catch (Exception e) - { - Debug.Console(DebugExtensions.Verbose, String.Format("Error Requesting Room List: {0}", e.ToString())); - } - } - public void getAvailableRooms() - { - try - { - if (_DynFusion.FusionSymbol.IsOnline) - { - string messageHeader = String.Format("RoomAvailabilityRequest:{0}", Guid.NewGuid().ToString()); - string messageBody = ""; - foreach (Room r in RoomList) - { - messageBody = String.Format("{0}{1}a0s23", messageBody, r.RoomID); - } - string messageFooter = String.Format(""); - _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomAttributeQuery.StringValue = string.Format("{0}{1}{2}", messageHeader, messageBody, messageFooter); - Debug.Console(DebugExtensions.Verbose, String.Format("RequestRoomAttributeList {0}{1}{2}", messageHeader, messageBody, messageFooter)); - /* - * if (_DynFusion.FusionSchedule.isRegisteredForSchedulePushNotifications) { - schedulePushTimer.Stop(); - } - */ - } - } - catch (Exception ex) - { - Debug.Console(DebugExtensions.Verbose, String.Format("getAvailableRooms Error: {0}", ex.Message)); - Debug.ConsoleWithLog(DebugExtensions.Verbose, ex.ToString()); - } - } - void FusionRoomDataExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) - { - #region Attribute Query Response Example - /* - - RoomAvailabilityRequest:41d0c78e-a1c9-40e7-b028-c4502af2fe0a - - 56a0fc1c-ef0d-408d-a23e-702abe87dcf8 - - Online Status - a0 - 2 - Read - - - - Free Busy Status - s23 - 2017-12-11T00:00:00 - Read - - - - - 7e9a5a9a-e1dc-4214-900d-046c3c8742ee - - Online Status - a0 - 2 - Read - - - - Free Busy Status - s23 - 2017-12-10T00:00:00 - Read - - - - - 8f198937-c405-4b29-bf69-104dd732fb66 - - Online Status - a0 - 0 - Read - - - - Free Busy Status - s23 - - Read - - - - - */ - #endregion - #region Attribute Query Response - if (args.Sig == _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomAttributeResponse) - { - Debug.Console(2, String.Format("RoomAttributeResponse Args: {0}", args.Sig.StringValue)); - XmlDocument availableRoomResponseXML = new XmlDocument(); - availableRoomResponseXML.LoadXml(args.Sig.StringValue); - - var availableRoomResponse = availableRoomResponseXML["RoomAttributeListResponse"]; - Debug.Console(2, String.Format("RequestID Args: {0}", availableRoomResponse)); - if (availableRoomResponse != null) - { - // It may be more efficent to get rid of this foreach JTA 2017-12-06 - foreach (XmlElement responseElement in availableRoomResponse) - { - Debug.Console(2, String.Format("RoomAttributeListResponseElement: {0} Value: {1}", responseElement.Name, responseElement.InnerXml)); - if (responseElement.Name == "Room") - { - XmlNodeList roomIDXml = responseElement.GetElementsByTagName("RoomID"); - Debug.Console(2, String.Format("RoomID: {0}", roomIDXml.Item(0).InnerXml)); - int index = RoomList.FindIndex(x => x.RoomID == roomIDXml.Item(0).InnerXml); - - XmlNodeList roomAttributes = responseElement.GetElementsByTagName("Attribute"); - - foreach (XmlElement attributeElement in roomAttributes) - { - Debug.Console(2, String.Format("RoomAttributeListResponseRoomElement: {0} Value: {1}", attributeElement.Name, attributeElement.InnerXml)); - string attributeType = attributeElement.GetElementsByTagName("Name").Item(0).InnerXml; - string attributeValue = attributeElement.GetElementsByTagName("Value").Item(0).InnerXml; - Debug.Console(2, String.Format("RoomAttributeListResponseRoomAttribute AssetType: {0} Value: {1}", attributeType, attributeValue)); - switch (attributeType) - { - case ("Online Status"): { if (attributeValue == "2") { RoomList[index].OnlineStatus = true; } else { RoomList[index].OnlineStatus = false; } break; } - case ("Free Busy Status"): { RoomList[index].FreeBusyStatus = attributeValue; break; } - } - } - } - } - } - OnAvailableRoomsUpdate(this, RoomList); - this.AvailableRoomStatus = false; - } - - - - #endregion - - #region Room List Response Example - /* - - * - * - RoomListRequest - - 56a0fc1c-ef0d-408d-a23e-702abe87dcf8 - IMF.HQ2.SLN200.Test (Delete Post 01/01/18) - RoomLoc - Fully_Connected - - - 7e9a5a9a-e1dc-4214-900d-046c3c8742ee - IMF.HQ2.SLN200.TestRoom03 (Delete Post 01/01/18) - RoomLoc - Fully_Connected - - - 8f198937-c405-4b29-bf69-104dd732fb66 - IMF.HQ2.SLN200.TestRoom2 (Delete Post 01/01/18) - RoomLoc - Not_Connected - - - * - * - * - * - * - */ - - - #endregion - #region Room List Response - if (args.Sig == _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomListResponse) - { - Debug.Console(2, String.Format("RoomList Response: {0}", args.Sig.StringValue)); - - try - { - XmlDocument roomListResponseXML = new XmlDocument(); - - roomListResponseXML.LoadXml(args.Sig.StringValue); - - var roomListResponse = roomListResponseXML["RoomListResponse"]; - - if (roomListResponse != null) - { - - var requestID = roomListResponse["RequestID"]; - RoomList.Clear(); - if (requestID.InnerText == "RoomListRequest") - { - XmlNodeList rooms = roomListResponse.GetElementsByTagName("Room"); - foreach (XmlElement element in rooms) - { - Room roomToAdd = new Room(); - roomToAdd.RoomName = element.GetElementsByTagName("RoomName").Item(0).InnerXml; - roomToAdd.RoomID = element.GetElementsByTagName("RoomID").Item(0).InnerXml; - roomToAdd.Location = element.GetElementsByTagName("Location").Item(0).InnerXml; - RoomList.Add(roomToAdd); - Debug.Console(2, String.Format("RoomAdded Name:{0} ID:{1} Location: {2}", roomToAdd.RoomName, roomToAdd.RoomID, roomToAdd.Location)); - /* - if (element.Name == "Room") { - XmlReader reader = new XmlReader(element.OuterXml); - Debug.Console(2, String.Format("OuterXML {0}", element.OuterXml)); - Room roomListRoom = new Room(); - - roomListRoom = CrestronXMLSerialization.DeSerializeObject(reader); - Debug.Console(2, String.Format("Var is: {0}, AssetType: {1}", roomListRoom.RoomName, roomListRoom.GetType())); - - // AvailableRooms.RoomList.Add(roomAvailable); - RoomList.Add(roomListRoom); - Debug.Console(2, String.Format("Room added to RoomList")); - - //RoomAvailibility.Add(AvailableRooms); - } - */ - - } - getAvailableRooms(); - } - } - } - catch (Exception e) - { - Debug.Console(2, String.Format("Error: {0}, {1}, {2}", e.Message, e.InnerException, e.StackTrace)); - Debug.Console(2, String.Format("E: {0}", e)); - } - - //getAvailableRooms(); - } - #endregion - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronXml; +using Crestron.SimplSharp.CrestronXml.Serialization; +using Crestron.SimplSharp.CrestronXmlLinq; +using Crestron.SimplSharpPro.Fusion; +using Crestron.SimplSharpPro; + + + +using PepperDash.Core; + +namespace DynFusion +{ + + public class Room + { + public string RoomID { get; set; } + public string RoomName { get; set; } + public string Location { get; set; } + public bool OnlineStatus { get; set; } + public double availableMinutes + { + get + { + double returnValue; + if (this.FreeBusyStatus.Contains("T")) + { + DateTime tempTime = DateTime.Parse(FreeBusyStatus); + //CrestronConsole.PrintLine(tempTime.ToString()); + if (tempTime > DateTime.Now) + { + returnValue = Math.Round(tempTime.Subtract(DateTime.Now).TotalMinutes); + } + else { returnValue = 0; } + } + + else { returnValue = 0; } + + return returnValue; + + } + } + public string FreeBusyStatus { get; set; } + + } + + + public class DynFusionScheduleAvailableRooms + { + public bool includeInAvailbleRooms; + private CTimer getAvailableRoomsTimeOut; + private bool _availableRoomStatus; + public bool AvailableRoomStatus + { + set + { + this._availableRoomStatus = value; + OnAvailableRoomsBusy(this, _availableRoomStatus); + if (_availableRoomStatus) { getAvailableRoomsTimeOut = new CTimer(getAvailableRoomsTimeout, 6000); } + else { getAvailableRoomsTimeOut.Stop(); } + } + } + // I would love to poll and have data ready to go but we think it may be too heavy a server load. JTA 2017-12-06 + // CTimer updateAvailableRooms = null; + private DynFusionDevice _DynFusion; + public List RoomList = new List(); + public List FilterList = new List(); + public delegate void AvailableRoomUpdate(object sender, List RoomList); + public event AvailableRoomUpdate OnAvailableRoomsUpdate; + public delegate void AvailableRoomsBusy(object sender, bool busyStatus); + public event AvailableRoomsBusy OnAvailableRoomsBusy; + + public DynFusionScheduleAvailableRooms(DynFusionDevice DynFusionInstance) + { + _DynFusion = DynFusionInstance; + _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(FusionRoomDataExtenderSigChange); + // I would love to poll and have data ready to go but we think it may be too heavy a server load. JTA 2017-12-06 + // updateAvailableRooms = new CTimer(GetRoomList, null, 300000, 300000); + } + + + + private void getAvailableRoomsTimeout(object unused) + { + Debug.ConsoleWithLog(DebugExtensions.Warn, "getAvailableRoomsTimeout error", 3); + this.AvailableRoomStatus = false; + } + public void sendFreeBusyStatusAvailableUntil(DateTime AvailableUntilTime) + { + // "2017-12-09T00:00:00" + _DynFusion.FusionSymbol.FreeBusyStatusToRoom.InputSig.StringValue = string.Format("{0}", AvailableUntilTime.ToString("yyyy-MM-ddTHH:mm:00")); + Debug.Console(DebugExtensions.Verbose, string.Format("Sending FreeBusyStatus {0}", AvailableUntilTime.ToString("yyyy-MM-ddTHH:mm:00"))); + } + public void sendFreeBusyStatusAvailable() + { + _DynFusion.FusionSymbol.FreeBusyStatusToRoom.InputSig.StringValue = string.Format("{0}", DateTime.Now.AddDays(5).ToString("yyyy-MM-ddT00:00:00")); + Debug.Console(DebugExtensions.Verbose, "Sending FreeBusyStatus {0}", DateTime.Now.AddDays(5).ToString("yyyy-MM-ddT00:00:00")); + } + public void sendFreeBusyStatusNotAvailable() + { + _DynFusion.FusionSymbol.FreeBusyStatusToRoom.InputSig.StringValue = string.Format("-"); + Debug.Console(2, string.Format("-")); + } + private void GetRoomList(object unused) + { + GetRoomList(); + } + public void GetRoomList() + { + try + { + if (_DynFusion.FusionSymbol.IsOnline) + { + this.AvailableRoomStatus = true; + + string fusionRoomListRequest = ""; + //TODO This needs to be implemented + // fusionRoomListRequest = String.Format("RoomListRequestLocation{0}", _DynFusion.FusionRoomInfo.roomInformation.Location); + Debug.Console(DebugExtensions.Verbose, String.Format("RoomList Request: {0}", fusionRoomListRequest)); + + _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomListQuery.StringValue = fusionRoomListRequest; + } + } + catch (Exception e) + { + Debug.Console(DebugExtensions.Verbose, String.Format("Error Requesting Room List: {0}", e.ToString())); + } + } + public void getAvailableRooms() + { + try + { + if (_DynFusion.FusionSymbol.IsOnline) + { + string messageHeader = String.Format("RoomAvailabilityRequest:{0}", Guid.NewGuid().ToString()); + string messageBody = ""; + foreach (Room r in RoomList) + { + messageBody = String.Format("{0}{1}a0s23", messageBody, r.RoomID); + } + string messageFooter = String.Format(""); + _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomAttributeQuery.StringValue = string.Format("{0}{1}{2}", messageHeader, messageBody, messageFooter); + Debug.Console(DebugExtensions.Verbose, String.Format("RequestRoomAttributeList {0}{1}{2}", messageHeader, messageBody, messageFooter)); + /* + * if (_DynFusion.FusionSchedule.isRegisteredForSchedulePushNotifications) { + schedulePushTimer.Stop(); + } + */ + } + } + catch (Exception ex) + { + Debug.Console(DebugExtensions.Verbose, String.Format("getAvailableRooms Error: {0}", ex.Message)); + Debug.ConsoleWithLog(DebugExtensions.Verbose, ex.ToString()); + } + } + void FusionRoomDataExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) + { + #region Attribute Query Response Example + /* + + RoomAvailabilityRequest:41d0c78e-a1c9-40e7-b028-c4502af2fe0a + + 56a0fc1c-ef0d-408d-a23e-702abe87dcf8 + + Online Status + a0 + 2 + Read + + + + Free Busy Status + s23 + 2017-12-11T00:00:00 + Read + + + + + 7e9a5a9a-e1dc-4214-900d-046c3c8742ee + + Online Status + a0 + 2 + Read + + + + Free Busy Status + s23 + 2017-12-10T00:00:00 + Read + + + + + 8f198937-c405-4b29-bf69-104dd732fb66 + + Online Status + a0 + 0 + Read + + + + Free Busy Status + s23 + + Read + + + + + */ + #endregion + #region Attribute Query Response + if (args.Sig == _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomAttributeResponse) + { + Debug.Console(2, String.Format("RoomAttributeResponse Args: {0}", args.Sig.StringValue)); + XmlDocument availableRoomResponseXML = new XmlDocument(); + availableRoomResponseXML.LoadXml(args.Sig.StringValue); + + var availableRoomResponse = availableRoomResponseXML["RoomAttributeListResponse"]; + Debug.Console(2, String.Format("RequestID Args: {0}", availableRoomResponse)); + if (availableRoomResponse != null) + { + // It may be more efficent to get rid of this foreach JTA 2017-12-06 + foreach (XmlElement responseElement in availableRoomResponse) + { + Debug.Console(2, String.Format("RoomAttributeListResponseElement: {0} Value: {1}", responseElement.Name, responseElement.InnerXml)); + if (responseElement.Name == "Room") + { + XmlNodeList roomIDXml = responseElement.GetElementsByTagName("RoomID"); + Debug.Console(2, String.Format("RoomID: {0}", roomIDXml.Item(0).InnerXml)); + int index = RoomList.FindIndex(x => x.RoomID == roomIDXml.Item(0).InnerXml); + + XmlNodeList roomAttributes = responseElement.GetElementsByTagName("Attribute"); + + foreach (XmlElement attributeElement in roomAttributes) + { + Debug.Console(2, String.Format("RoomAttributeListResponseRoomElement: {0} Value: {1}", attributeElement.Name, attributeElement.InnerXml)); + string attributeType = attributeElement.GetElementsByTagName("Name").Item(0).InnerXml; + string attributeValue = attributeElement.GetElementsByTagName("Value").Item(0).InnerXml; + Debug.Console(2, String.Format("RoomAttributeListResponseRoomAttribute AssetType: {0} Value: {1}", attributeType, attributeValue)); + switch (attributeType) + { + case ("Online Status"): { if (attributeValue == "2") { RoomList[index].OnlineStatus = true; } else { RoomList[index].OnlineStatus = false; } break; } + case ("Free Busy Status"): { RoomList[index].FreeBusyStatus = attributeValue; break; } + } + } + } + } + } + OnAvailableRoomsUpdate(this, RoomList); + this.AvailableRoomStatus = false; + } + + + + #endregion + + #region Room List Response Example + /* + + * + * + RoomListRequest + + 56a0fc1c-ef0d-408d-a23e-702abe87dcf8 + IMF.HQ2.SLN200.Test (Delete Post 01/01/18) + RoomLoc + Fully_Connected + + + 7e9a5a9a-e1dc-4214-900d-046c3c8742ee + IMF.HQ2.SLN200.TestRoom03 (Delete Post 01/01/18) + RoomLoc + Fully_Connected + + + 8f198937-c405-4b29-bf69-104dd732fb66 + IMF.HQ2.SLN200.TestRoom2 (Delete Post 01/01/18) + RoomLoc + Not_Connected + + + * + * + * + * + * + */ + + + #endregion + #region Room List Response + if (args.Sig == _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomListResponse) + { + Debug.Console(2, String.Format("RoomList Response: {0}", args.Sig.StringValue)); + + try + { + XmlDocument roomListResponseXML = new XmlDocument(); + + roomListResponseXML.LoadXml(args.Sig.StringValue); + + var roomListResponse = roomListResponseXML["RoomListResponse"]; + + if (roomListResponse != null) + { + + var requestID = roomListResponse["RequestID"]; + RoomList.Clear(); + if (requestID.InnerText == "RoomListRequest") + { + XmlNodeList rooms = roomListResponse.GetElementsByTagName("Room"); + foreach (XmlElement element in rooms) + { + Room roomToAdd = new Room(); + roomToAdd.RoomName = element.GetElementsByTagName("RoomName").Item(0).InnerXml; + roomToAdd.RoomID = element.GetElementsByTagName("RoomID").Item(0).InnerXml; + roomToAdd.Location = element.GetElementsByTagName("Location").Item(0).InnerXml; + RoomList.Add(roomToAdd); + Debug.Console(2, String.Format("RoomAdded Name:{0} ID:{1} Location: {2}", roomToAdd.RoomName, roomToAdd.RoomID, roomToAdd.Location)); + /* + if (element.Name == "Room") { + XmlReader reader = new XmlReader(element.OuterXml); + Debug.Console(2, String.Format("OuterXML {0}", element.OuterXml)); + Room roomListRoom = new Room(); + + roomListRoom = CrestronXMLSerialization.DeSerializeObject(reader); + Debug.Console(2, String.Format("Var is: {0}, AssetType: {1}", roomListRoom.RoomName, roomListRoom.GetType())); + + // AvailableRooms.RoomList.Add(roomAvailable); + RoomList.Add(roomListRoom); + Debug.Console(2, String.Format("Room added to RoomList")); + + //RoomAvailibility.Add(AvailableRooms); + } + */ + + } + getAvailableRooms(); + } + } + } + catch (Exception e) + { + Debug.Console(2, String.Format("Error: {0}, {1}, {2}", e.Message, e.InnerException, e.StackTrace)); + Debug.Console(2, String.Format("E: {0}", e)); + } + + //getAvailableRooms(); + } + #endregion + } + } } \ No newline at end of file diff --git a/DynFusionEPI/Config/AssetsClass.cs b/src/Config/AssetsClass.cs similarity index 100% rename from DynFusionEPI/Config/AssetsClass.cs rename to src/Config/AssetsClass.cs diff --git a/DynFusionEPI/Config/CallStatistics.cs b/src/Config/CallStatistics.cs similarity index 100% rename from DynFusionEPI/Config/CallStatistics.cs rename to src/Config/CallStatistics.cs diff --git a/DynFusionEPI/Config/CallStatisticsDeviceConfig.cs b/src/Config/CallStatisticsDeviceConfig.cs similarity index 100% rename from DynFusionEPI/Config/CallStatisticsDeviceConfig.cs rename to src/Config/CallStatisticsDeviceConfig.cs diff --git a/DynFusionEPI/Config/CustomAttributes.cs b/src/Config/CustomAttributes.cs similarity index 100% rename from DynFusionEPI/Config/CustomAttributes.cs rename to src/Config/CustomAttributes.cs diff --git a/DynFusionEPI/Config/CustomProperties.cs b/src/Config/CustomProperties.cs similarity index 100% rename from DynFusionEPI/Config/CustomProperties.cs rename to src/Config/CustomProperties.cs diff --git a/DynFusionEPI/Config/DeviceUsage.cs b/src/Config/DeviceUsage.cs similarity index 100% rename from DynFusionEPI/Config/DeviceUsage.cs rename to src/Config/DeviceUsage.cs diff --git a/DynFusionEPI/Config/DeviceUsageDevice.cs b/src/Config/DeviceUsageDevice.cs similarity index 100% rename from DynFusionEPI/Config/DeviceUsageDevice.cs rename to src/Config/DeviceUsageDevice.cs diff --git a/DynFusionEPI/Config/DeviceUsageSoruce.cs b/src/Config/DeviceUsageSoruce.cs similarity index 100% rename from DynFusionEPI/Config/DeviceUsageSoruce.cs rename to src/Config/DeviceUsageSoruce.cs diff --git a/DynFusionEPI/Config/DisplayUsageDevice.cs b/src/Config/DisplayUsageDevice.cs similarity index 100% rename from DynFusionEPI/Config/DisplayUsageDevice.cs rename to src/Config/DisplayUsageDevice.cs diff --git a/DynFusionEPI/Config/DynFusionConfigObjectTemplate.cs b/src/Config/DynFusionConfigObjectTemplate.cs similarity index 100% rename from DynFusionEPI/Config/DynFusionConfigObjectTemplate.cs rename to src/Config/DynFusionConfigObjectTemplate.cs diff --git a/DynFusionEPI/Config/FusionCustomProperty.cs b/src/Config/FusionCustomProperty.cs similarity index 100% rename from DynFusionEPI/Config/FusionCustomProperty.cs rename to src/Config/FusionCustomProperty.cs diff --git a/DynFusionEPI/Config/FusionEssentialsAsset.cs b/src/Config/FusionEssentialsAsset.cs similarity index 100% rename from DynFusionEPI/Config/FusionEssentialsAsset.cs rename to src/Config/FusionEssentialsAsset.cs diff --git a/DynFusionEPI/Config/FusionOccupancyAsset.cs b/src/Config/FusionOccupancyAsset.cs similarity index 100% rename from DynFusionEPI/Config/FusionOccupancyAsset.cs rename to src/Config/FusionOccupancyAsset.cs diff --git a/DynFusionEPI/Config/FusionStaticAssetConfig.cs b/src/Config/FusionStaticAssetConfig.cs similarity index 100% rename from DynFusionEPI/Config/FusionStaticAssetConfig.cs rename to src/Config/FusionStaticAssetConfig.cs diff --git a/DynFusionEPI/DebugExtension.cs b/src/DebugExtension.cs similarity index 100% rename from DynFusionEPI/DebugExtension.cs rename to src/DebugExtension.cs diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..319870c --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,21 @@ + + + 1.0.0-local + $(Version) + PepperDash Technologies + PepperDash Technologies + PepperDash Crestron Fusion + Copyright © 2023 + https://github.com/PepperDash/epi-crestron-fusion + git + Crestron; 4series + ../output + True + LICENSE.md + README.md + + + + + + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 0000000..3af6067 --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,20 @@ + + + + true + content; + + + true + content; + + + + + + + + + + + diff --git a/DynFusionEPI/DynFusionAssetOccupancySensor.cs b/src/DynFusionAssetOccupancySensor.cs similarity index 97% rename from DynFusionEPI/DynFusionAssetOccupancySensor.cs rename to src/DynFusionAssetOccupancySensor.cs index eb4a118..9d3f531 100644 --- a/DynFusionEPI/DynFusionAssetOccupancySensor.cs +++ b/src/DynFusionAssetOccupancySensor.cs @@ -1,101 +1,101 @@ -using Crestron.SimplSharpPro.Fusion; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace DynFusion -{ - public class DynFusionAssetOccupancySensor : EssentialsBridgeableDevice - { - private readonly FusionRoom _fusionSymbol; - public uint AssetNumber { get; private set; } - - public DynFusionAssetOccupancySensor(string key, string linkKey, FusionRoom symbol, uint assetNumber) - : base(string.Format("{0}-OccAsset#{1}", symbol.Name, assetNumber)) - { - _fusionSymbol = symbol; - AssetNumber = assetNumber; - // _fusionSymbol.FusionAssetStateChange += new FusionAssetStateEventHandler(_fusionSymbol_FusionAssetStateChange); - } - - public void sendChange(string message) - { - Debug.Console(2, this, "OccupancySensor {0} recieved Message {1}", AssetNumber, message); - - if (message.StartsWith("<")) //For XML string from Fusion SSI module - ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) - .RoomOccupancyInfo.InputSig.StringValue = message; - - else if (message.StartsWith("{")) //For JSON string from custom module (legacy) - { - var messageObject = JsonConvert.DeserializeObject(message); - if (message.Contains("OccSensorEnabled")) - { - ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) - .EnableOccupancySensor.InputSig.BoolValue = messageObject.OccSensorEnabled; - } - if (message.Contains("RoomOccupied")) - { - ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset).RoomOccupied - .InputSig.BoolValue = messageObject.RoomOccupied; - } - else - { - ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset).RoomOccupied - .InputSig.BoolValue = false; - } - if (message.Contains("OccSensorTimeout")) - { - ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) - .OccupancySensorTimeout.InputSig.UShortValue = messageObject.OccSensorTimeout; - } - } - } - - - public override void LinkToApi(Crestron.SimplSharpPro.DeviceSupport.BasicTriList trilist, uint joinStart, - string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DynFusionAssetOccupancySensorJoinMap(joinStart); - - _fusionSymbol.FusionAssetStateChange += (s, a) => - { - Debug.Console(2, this, "OccupancySensor State Change {0} recieved EventID {1}", s, a.EventId); - // Debug.Console(2, this, "OccupancySensor State Change {0} recieved EventID {1}", device, args.EventId); - switch (a.EventId) - { - case FusionAssetEventId.DisableOccupancySensorReceivedEventId: - { - trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = "Disable\r"; - break; - } - case FusionAssetEventId.EnableOccupancySensorReceivedEventId: - { - trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = "Enable\r"; - break; - } - case FusionAssetEventId.OccupancySensorTimeoutReceivedEventId: - { - trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = string.Format("SetTimeout: {0}", - ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) - .OccupancySensorTimeout.OutputSig.UShortValue); - break; - } - } - }; - - // TODO: this might be better to send with an online from Fusion - trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = "SendValues\r"; - trilist.SetStringSigAction(joinMap.StringIO.JoinNumber, (s) => sendChange(s)); - } - } - - public class DynFusionAssetsOccupancySensorMessage - { - public bool OccSensorEnabled; - public bool RoomOccupied; - public ushort OccSensorTimeout; - public string RoomOccupancyInfo; - } +using Crestron.SimplSharpPro.Fusion; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace DynFusion +{ + public class DynFusionAssetOccupancySensor : EssentialsBridgeableDevice + { + private readonly FusionRoom _fusionSymbol; + public uint AssetNumber { get; private set; } + + public DynFusionAssetOccupancySensor(string key, string linkKey, FusionRoom symbol, uint assetNumber) + : base(string.Format("{0}-OccAsset#{1}", symbol.Name, assetNumber)) + { + _fusionSymbol = symbol; + AssetNumber = assetNumber; + // _fusionSymbol.FusionAssetStateChange += new FusionAssetStateEventHandler(_fusionSymbol_FusionAssetStateChange); + } + + public void sendChange(string message) + { + Debug.Console(2, this, "OccupancySensor {0} recieved Message {1}", AssetNumber, message); + + if (message.StartsWith("<")) //For XML string from Fusion SSI module + ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) + .RoomOccupancyInfo.InputSig.StringValue = message; + + else if (message.StartsWith("{")) //For JSON string from custom module (legacy) + { + var messageObject = JsonConvert.DeserializeObject(message); + if (message.Contains("OccSensorEnabled")) + { + ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) + .EnableOccupancySensor.InputSig.BoolValue = messageObject.OccSensorEnabled; + } + if (message.Contains("RoomOccupied")) + { + ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset).RoomOccupied + .InputSig.BoolValue = messageObject.RoomOccupied; + } + else + { + ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset).RoomOccupied + .InputSig.BoolValue = false; + } + if (message.Contains("OccSensorTimeout")) + { + ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) + .OccupancySensorTimeout.InputSig.UShortValue = messageObject.OccSensorTimeout; + } + } + } + + + public override void LinkToApi(Crestron.SimplSharpPro.DeviceSupport.BasicTriList trilist, uint joinStart, + string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DynFusionAssetOccupancySensorJoinMap(joinStart); + + _fusionSymbol.FusionAssetStateChange += (s, a) => + { + Debug.Console(2, this, "OccupancySensor State Change {0} recieved EventID {1}", s, a.EventId); + // Debug.Console(2, this, "OccupancySensor State Change {0} recieved EventID {1}", device, args.EventId); + switch (a.EventId) + { + case FusionAssetEventId.DisableOccupancySensorReceivedEventId: + { + trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = "Disable\r"; + break; + } + case FusionAssetEventId.EnableOccupancySensorReceivedEventId: + { + trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = "Enable\r"; + break; + } + case FusionAssetEventId.OccupancySensorTimeoutReceivedEventId: + { + trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = string.Format("SetTimeout: {0}", + ((FusionOccupancySensor) _fusionSymbol.UserConfigurableAssetDetails[AssetNumber].Asset) + .OccupancySensorTimeout.OutputSig.UShortValue); + break; + } + } + }; + + // TODO: this might be better to send with an online from Fusion + trilist.StringInput[joinMap.StringIO.JoinNumber].StringValue = "SendValues\r"; + trilist.SetStringSigAction(joinMap.StringIO.JoinNumber, (s) => sendChange(s)); + } + } + + public class DynFusionAssetsOccupancySensorMessage + { + public bool OccSensorEnabled; + public bool RoomOccupied; + public ushort OccSensorTimeout; + public string RoomOccupancyInfo; + } } \ No newline at end of file diff --git a/DynFusionEPI/DynFusionAssetOccupancySensorJoinMap.cs b/src/DynFusionAssetOccupancySensorJoinMap.cs similarity index 63% rename from DynFusionEPI/DynFusionAssetOccupancySensorJoinMap.cs rename to src/DynFusionAssetOccupancySensorJoinMap.cs index 0701861..031e250 100644 --- a/DynFusionEPI/DynFusionAssetOccupancySensorJoinMap.cs +++ b/src/DynFusionAssetOccupancySensorJoinMap.cs @@ -1,16 +1,16 @@ -using PepperDash.Essentials.Core; - -namespace DynFusion -{ - public class DynFusionAssetOccupancySensorJoinMap : JoinMapBaseAdvanced - { - public JoinDataComplete StringIO = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Label = "String IO", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - - - public DynFusionAssetOccupancySensorJoinMap(uint joinStart) - :base(joinStart) - { - - } - } +using PepperDash.Essentials.Core; + +namespace DynFusion +{ + public class DynFusionAssetOccupancySensorJoinMap : JoinMapBaseAdvanced + { + public JoinDataComplete StringIO = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "String IO", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + + + public DynFusionAssetOccupancySensorJoinMap(uint joinStart) + :base(joinStart) + { + + } + } } \ No newline at end of file diff --git a/DynFusionEPI/DynFusionAttribute.cs b/src/DynFusionAttribute.cs similarity index 95% rename from DynFusionEPI/DynFusionAttribute.cs rename to src/DynFusionAttribute.cs index 0181273..9b9e3a5 100644 --- a/DynFusionEPI/DynFusionAttribute.cs +++ b/src/DynFusionAttribute.cs @@ -1,173 +1,173 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Crestron.SimplSharpPro; -using PepperDash.Core; -using Crestron.SimplSharp.Reflection; - -namespace DynFusion -{ - - - public class DynFusionDigitalAttribute : DynFusionAttributeBase - { - - public DynFusionDigitalAttribute(string name, UInt32 joinNumber) - : base(name, eSigType.Bool, joinNumber) - { - BoolValueFeedback = new BoolFeedback(() => { return BoolValue; }); - Debug.Console(2, "Creating DigitalAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); - } - - public DynFusionDigitalAttribute(string name, UInt32 joinNumber, string deviceKey, string boolAction, string boolFeedback) - : base(name, eSigType.Bool, joinNumber) - { - - BoolValueFeedback = new BoolFeedback(() => { return BoolValue; }); - Debug.Console(2, "Creating DigitalAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); - - if (deviceKey != null) - { - if (boolFeedback != null) - { - try - { - var fb = DeviceJsonApi.GetPropertyByName(deviceKey, boolFeedback) as BoolFeedback; - fb.OutputChange += ((sender, args) => - { - this.BoolValue = args.BoolValue; - }); - } - catch (Exception ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "DynFuison Issue linking Device {0} BoolFB {1}\n{2}", deviceKey, boolFeedback, ex); - } - - } - } - - } - public BoolFeedback BoolValueFeedback { get; set; } - - private bool _BoolValue { get; set; } - public bool BoolValue - { - get - { - - return _BoolValue; - - } - set - { - _BoolValue = value; - BoolValueFeedback.FireUpdate(); - Debug.Console(2, "Changed Value of DigitalAttribute {0} {1} {2}", this.JoinNumber, this.Name, value); - - } - } - } - public class DynFusionAnalogAttribute : DynFusionAttributeBase - { - public DynFusionAnalogAttribute(string name, UInt32 joinNumber) - : base(name, eSigType.UShort, joinNumber) - { - UShortValueFeedback = new IntFeedback( () => { return (int)UShortValue; }); - - Debug.Console(2, "Creating AnalogAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); - } - - public IntFeedback UShortValueFeedback { get; set; } - private UInt32 _UShortValue { get; set; } - public UInt32 UShortValue - { - get - { - return _UShortValue; - - } - set - { - _UShortValue = value; - UShortValueFeedback.FireUpdate(); - - } - } - } - public class DynFusionSerialAttribute : DynFusionAttributeBase - { - public DynFusionSerialAttribute(string name, UInt32 joinNumber) - : base(name, eSigType.String, joinNumber) - { - StringValueFeedback = new StringFeedback(() => { return StringValue; }); - - Debug.Console(2, "Creating StringAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); - } - public StringFeedback StringValueFeedback { get; set; } - private String _StringValue { get; set; } - public String StringValue - { - get - { - return _StringValue; - - } - set - { - _StringValue = value; - StringValueFeedback.FireUpdate(); - - } - - } - } - public class DynFusionAttributeBase - { - public DynFusionAttributeBase (string name, eSigType type, UInt32 joinNumber) - { - Name = name; - SignalType = type; - JoinNumber = joinNumber; - - } - - [JsonProperty("SignalType")] - [JsonConverter(typeof(StringEnumConverter))] - public eSigType SignalType { get; set; } - - [JsonProperty("JoinNumber")] - public UInt32 JoinNumber { get; set; } - - [JsonProperty("Name")] - public string Name { get; set; } - - [JsonProperty("RwType")] - [JsonConverter(typeof(StringEnumConverter))] - public eReadWrite RwType { get; set; } - - [JsonProperty("LinkDeviceKey")] - public string LinkDeviceKey { get; set; } - - [JsonProperty("LinkDeviceMethod")] - public string LinkDeviceMethod { get; set; } - - [JsonProperty("LinkDeviceFeedback")] - public string LinkDeviceFeedback { get; set; } - - - } - public enum eReadWrite - { - Read = 1, - Write = 2, - R = 1, - W = 2, - ReadWrite = 3, - RW = 3 - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Crestron.SimplSharpPro; +using PepperDash.Core; +using Crestron.SimplSharp.Reflection; + +namespace DynFusion +{ + + + public class DynFusionDigitalAttribute : DynFusionAttributeBase + { + + public DynFusionDigitalAttribute(string name, UInt32 joinNumber) + : base(name, eSigType.Bool, joinNumber) + { + BoolValueFeedback = new BoolFeedback(() => { return BoolValue; }); + Debug.Console(2, "Creating DigitalAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); + } + + public DynFusionDigitalAttribute(string name, UInt32 joinNumber, string deviceKey, string boolAction, string boolFeedback) + : base(name, eSigType.Bool, joinNumber) + { + + BoolValueFeedback = new BoolFeedback(() => { return BoolValue; }); + Debug.Console(2, "Creating DigitalAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); + + if (deviceKey != null) + { + if (boolFeedback != null) + { + try + { + var fb = DeviceJsonApi.GetPropertyByName(deviceKey, boolFeedback) as BoolFeedback; + fb.OutputChange += ((sender, args) => + { + this.BoolValue = args.BoolValue; + }); + } + catch (Exception ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "DynFuison Issue linking Device {0} BoolFB {1}\n{2}", deviceKey, boolFeedback, ex); + } + + } + } + + } + public BoolFeedback BoolValueFeedback { get; set; } + + private bool _BoolValue { get; set; } + public bool BoolValue + { + get + { + + return _BoolValue; + + } + set + { + _BoolValue = value; + BoolValueFeedback.FireUpdate(); + Debug.Console(2, "Changed Value of DigitalAttribute {0} {1} {2}", this.JoinNumber, this.Name, value); + + } + } + } + public class DynFusionAnalogAttribute : DynFusionAttributeBase + { + public DynFusionAnalogAttribute(string name, UInt32 joinNumber) + : base(name, eSigType.UShort, joinNumber) + { + UShortValueFeedback = new IntFeedback( () => { return (int)UShortValue; }); + + Debug.Console(2, "Creating AnalogAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); + } + + public IntFeedback UShortValueFeedback { get; set; } + private UInt32 _UShortValue { get; set; } + public UInt32 UShortValue + { + get + { + return _UShortValue; + + } + set + { + _UShortValue = value; + UShortValueFeedback.FireUpdate(); + + } + } + } + public class DynFusionSerialAttribute : DynFusionAttributeBase + { + public DynFusionSerialAttribute(string name, UInt32 joinNumber) + : base(name, eSigType.String, joinNumber) + { + StringValueFeedback = new StringFeedback(() => { return StringValue; }); + + Debug.Console(2, "Creating StringAttribute {0} {1} {2}", this.JoinNumber, this.Name, this.RwType); + } + public StringFeedback StringValueFeedback { get; set; } + private String _StringValue { get; set; } + public String StringValue + { + get + { + return _StringValue; + + } + set + { + _StringValue = value; + StringValueFeedback.FireUpdate(); + + } + + } + } + public class DynFusionAttributeBase + { + public DynFusionAttributeBase (string name, eSigType type, UInt32 joinNumber) + { + Name = name; + SignalType = type; + JoinNumber = joinNumber; + + } + + [JsonProperty("SignalType")] + [JsonConverter(typeof(StringEnumConverter))] + public eSigType SignalType { get; set; } + + [JsonProperty("JoinNumber")] + public UInt32 JoinNumber { get; set; } + + [JsonProperty("Name")] + public string Name { get; set; } + + [JsonProperty("RwType")] + [JsonConverter(typeof(StringEnumConverter))] + public eReadWrite RwType { get; set; } + + [JsonProperty("LinkDeviceKey")] + public string LinkDeviceKey { get; set; } + + [JsonProperty("LinkDeviceMethod")] + public string LinkDeviceMethod { get; set; } + + [JsonProperty("LinkDeviceFeedback")] + public string LinkDeviceFeedback { get; set; } + + + } + public enum eReadWrite + { + Read = 1, + Write = 2, + R = 1, + W = 2, + ReadWrite = 3, + RW = 3 + } } \ No newline at end of file diff --git a/DynFusionEPI/DynFusionCallStatisticsDevice.cs b/src/DynFusionCallStatisticsDevice.cs similarity index 100% rename from DynFusionEPI/DynFusionCallStatisticsDevice.cs rename to src/DynFusionCallStatisticsDevice.cs diff --git a/DynFusionEPI/DynFusionDevice.cs b/src/DynFusionDevice.cs similarity index 97% rename from DynFusionEPI/DynFusionDevice.cs rename to src/DynFusionDevice.cs index b13e74c..9ed54d5 100644 --- a/DynFusionEPI/DynFusionDevice.cs +++ b/src/DynFusionDevice.cs @@ -1,1018 +1,1018 @@ -// For Basic SIMPL# Classes -// For Basic SIMPL#Pro classes - -using Crestron.SimplSharpPro.DeviceSupport; -using DynFusion.Config; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Interfaces; -using PepperDash.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharpPro.Fusion; -using Crestron.SimplSharpPro; -using Crestron.SimplSharp.CrestronXml; -using Crestron.SimplSharp.CrestronXml.Serialization; -using Crestron.SimplSharp; -using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; - - -namespace DynFusion -{ - public class DynFusionDevice : EssentialsBridgeableDevice, ILogStringsWithLevel, ILogStrings - { - public const ushort FusionJoinOffset = 49; - //DynFusion Joins - - private DynFusionConfigObjectTemplate _Config; - private Dictionary DigitalAttributesToFusion; - private Dictionary AnalogAttributesToFusion; - private Dictionary SerialAttributesToFusion; - private Dictionary DigitalAttributesFromFusion; - private Dictionary AnalogAttributesFromFusion; - private Dictionary SerialAttributesFromFusion; - - private readonly IDictionary _callStatisticsDevices - = new Dictionary(); - - private readonly IDictionary _staticAssets - = new Dictionary(); - - private static DynFusionJoinMap JoinMapStatic; - - public BoolFeedback FusionOnlineFeedback; - public RoomInformation RoomInformation; - - public DynFusionDeviceUsage DeviceUsage; - public FusionRoom FusionSymbol; - private CTimer ErrorLogTimer; - private string ErrorLogLastMessageSent; - - public DynFusionDevice(string key, string name, DynFusionConfigObjectTemplate config) - : base(key, name) - { - Debug.Console(0, this, "Constructing new DynFusionDevice instance"); - _Config = config; - DigitalAttributesToFusion = new Dictionary(); - AnalogAttributesToFusion = new Dictionary(); - SerialAttributesToFusion = new Dictionary(); - DigitalAttributesFromFusion = new Dictionary(); - AnalogAttributesFromFusion = new Dictionary(); - SerialAttributesFromFusion = new Dictionary(); - JoinMapStatic = new DynFusionJoinMap(1); - Debug.Console(2, "Creating Fusion Symbol {0} {1}", _Config.Control.IpId, Key); - FusionSymbol = new FusionRoom(_Config.Control.IpIdInt, Global.ControlSystem, "", Guid.NewGuid().ToString()); - - if (FusionSymbol.Register() != eDeviceRegistrationUnRegistrationResponse.Success) - { - Debug.Console(0, this, "Faliure to register Fusion Symbol"); - } - FusionSymbol.ExtenderFusionRoomDataReservedSigs.Use(); - } - - public override bool CustomActivate() - { - try - { - // Online Status - FusionOnlineFeedback = new BoolFeedback(() => { return FusionSymbol.IsOnline; }); - FusionSymbol.OnlineStatusChange += new OnlineStatusChangeEventHandler(FusionSymbol_OnlineStatusChange); - - // Attribute State Changes - FusionSymbol.FusionStateChange += new FusionStateEventHandler(FusionSymbol_FusionStateChange); - FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += - new DeviceExtenderJoinChangeEventHandler(FusionSymbol_RoomDataDeviceExtenderSigChange); - - // Create Custom Atributes - foreach (var att in _Config.CustomAttributes.DigitalAttributes) - { - FusionSymbol.AddSig(eSigType.Bool, att.JoinNumber - FusionJoinOffset, att.Name, - GetIOMask(att.RwType)); - - if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Read) - { - DigitalAttributesToFusion.Add(att.JoinNumber, - new DynFusionDigitalAttribute(att.Name, att.JoinNumber, att.LinkDeviceKey, - att.LinkDeviceMethod, att.LinkDeviceFeedback)); - - DigitalAttributesToFusion[att.JoinNumber].BoolValueFeedback.LinkInputSig( - FusionSymbol.UserDefinedBooleanSigDetails[att.JoinNumber - FusionJoinOffset].InputSig); - } - if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Write) - { - DigitalAttributesFromFusion.Add(att.JoinNumber, - new DynFusionDigitalAttribute(att.Name, att.JoinNumber)); - } - } - - foreach (var att in _Config.CustomAttributes.AnalogAttributes) - { - FusionSymbol.AddSig(eSigType.UShort, att.JoinNumber - FusionJoinOffset, att.Name, - GetIOMask(att.RwType)); - - if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Read) - { - AnalogAttributesToFusion.Add(att.JoinNumber, - new DynFusionAnalogAttribute(att.Name, att.JoinNumber)); - - AnalogAttributesToFusion[att.JoinNumber].UShortValueFeedback.LinkInputSig( - FusionSymbol.UserDefinedUShortSigDetails[att.JoinNumber - FusionJoinOffset].InputSig); - } - if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Write) - { - AnalogAttributesFromFusion.Add(att.JoinNumber, - new DynFusionAnalogAttribute(att.Name, att.JoinNumber)); - } - } - foreach (var att in _Config.CustomAttributes.SerialAttributes) - { - FusionSymbol.AddSig(eSigType.String, att.JoinNumber - FusionJoinOffset, att.Name, - GetIOMask(att.RwType)); - if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Read) - { - SerialAttributesToFusion.Add(att.JoinNumber, - new DynFusionSerialAttribute(att.Name, att.JoinNumber)); - - SerialAttributesToFusion[att.JoinNumber].StringValueFeedback.LinkInputSig( - FusionSymbol.UserDefinedStringSigDetails[att.JoinNumber - FusionJoinOffset].InputSig); - } - if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Write) - { - SerialAttributesFromFusion.Add(att.JoinNumber, - new DynFusionSerialAttribute(att.Name, att.JoinNumber)); - } - } - - // Create Links for Standard joins - CreateStandardJoin(JoinMapStatic.SystemPowerOn, FusionSymbol.SystemPowerOn); - CreateStandardJoin(JoinMapStatic.SystemPowerOff, FusionSymbol.SystemPowerOff); - CreateStandardJoin(JoinMapStatic.DisplayPowerOn, FusionSymbol.DisplayPowerOn); - CreateStandardJoin(JoinMapStatic.DisplayPowerOff, FusionSymbol.DisplayPowerOff); - CreateStandardJoin(JoinMapStatic.MsgBroadcastEnabled, FusionSymbol.MessageBroadcastEnabled); - CreateStandardJoin(JoinMapStatic.AuthenticationSucceeded, FusionSymbol.AuthenticateSucceeded); - CreateStandardJoin(JoinMapStatic.AuthenticationFailed, FusionSymbol.AuthenticateFailed); - - CreateStandardJoin(JoinMapStatic.DeviceUsage, FusionSymbol.DisplayUsage); - CreateStandardJoin(JoinMapStatic.BoradcasetMsgType, FusionSymbol.BroadcastMessageType); - - CreateStandardJoin(JoinMapStatic.HelpMsg, FusionSymbol.Help); - CreateStandardJoin(JoinMapStatic.ErrorMsg, FusionSymbol.ErrorMessage); - CreateStandardJoin(JoinMapStatic.LogText, FusionSymbol.LogText); - - // Room Data Extender - CreateStandardJoin(JoinMapStatic.ActionQuery, - FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQuery); - CreateStandardJoin(JoinMapStatic.RoomConfig, - FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomConfigQuery); - - if (_Config.CustomProperties != null) - { - if (_Config.CustomProperties.DigitalProperties != null) - { - foreach (var att in _Config.CustomProperties.DigitalProperties) - { - DigitalAttributesFromFusion.Add(att.JoinNumber, - new DynFusionDigitalAttribute(att.Id, att.JoinNumber)); - } - } - if (_Config.CustomProperties.AnalogProperties != null) - { - foreach (var att in _Config.CustomProperties.AnalogProperties) - { - AnalogAttributesFromFusion.Add(att.JoinNumber, - new DynFusionAnalogAttribute(att.Id, att.JoinNumber)); - } - } - if (_Config.CustomProperties.SerialProperties != null) - { - foreach (var att in _Config.CustomProperties.SerialProperties) - { - SerialAttributesFromFusion.Add(att.JoinNumber, - new DynFusionSerialAttribute(att.Id, att.JoinNumber)); - } - } - } - - if (_Config.Assets != null) - { - if (_Config.Assets.OccupancySensors != null) - { - var sensors = from occSensorConfig in _Config.Assets.OccupancySensors - select - new DynFusionAssetOccupancySensor( - occSensorConfig.Key, - occSensorConfig.LinkToDeviceKey, - FusionSymbol, - GetNextAvailableAssetNumber(FusionSymbol)); - - sensors - .ToList() - .ForEach(sensor => - FusionSymbol.AddAsset( - eAssetType.OccupancySensor, - sensor.AssetNumber, - sensor.Key, - "Occupancy Sensor", - Guid.NewGuid().ToString())); - } - - Debug.Console(DebugExtensions.Trace, this, "DynFusionDevice SetupAsset: StaticAssets config {0} null", - _Config.Assets.StaticAssets == null ? "==" : "!="); - - if (_Config.Assets.StaticAssets != null) - { - var staticAssets = from staticAssetsConfig in _Config.Assets.StaticAssets - select - new DynFusionStaticAsset( - this, - FusionSymbol, - GetNextAvailableAssetNumber(FusionSymbol), - staticAssetsConfig); - - //staticAssets - // .ToList() - // .ForEach(staticAsset => - // FusionSymbol.AddAsset( - // eAssetType.StaticAsset, - // staticAsset.AssetNumber, - // staticAsset.Key, - // staticAsset.AssetType, - // Guid.NewGuid().ToString())); - - staticAssets - .ToList() - .ForEach(staticAsset => - { - _staticAssets.Add(staticAsset.AssetNumber, staticAsset); - }); - } - } - - if (_Config.CallStatistics != null) - { - var callStats = from callStatsConfig in _Config.CallStatistics.Devices - select - new DynFusionCallStatisticsDevice( - Key + "-" + callStatsConfig.Name, - callStatsConfig.Name, - FusionSymbol, - callStatsConfig.Type, - callStatsConfig.UseCallTimer, - callStatsConfig.PostMeetingId, - callStatsConfig.JoinNumber); - - callStats - .ToList() - .ForEach(callStat => _callStatisticsDevices.Add(callStat.JoinNumber, callStat)); - } - - DeviceUsageFactory(); - // Scheduling Bits for Future - //FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.Use(); - //FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(ExtenderRoomViewSchedulingDataReservedSigs_DeviceExtenderSigChange); - - // Future for time sync - // FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange); - if ( string.IsNullOrEmpty(FusionSymbol.ParameterRoomName)) - { - FusionSymbol.ParameterRoomName = EthernetHelper.LanHelper.Hostname + "-program " + InitialParametersClass.ApplicationNumber + CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0) +CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); - - } - - - FusionRVI.GenerateFileForAllFusionDevices(); - } - catch (Exception ex) - { - Debug.Console(2, this, "Exception DynFusion SetupAsset {0}", ex); - } - return true; - } - - - - private void DeviceUsageFactory() - { - if (_Config.DeviceUsage != null) - { - DeviceUsage = new DynFusionDeviceUsage(string.Format("{0}-DeviceUsage", Key), this); - if (_Config.DeviceUsage.UsageMinThreshold > 0) - { - DeviceUsage.usageMinThreshold = (int) _Config.DeviceUsage.UsageMinThreshold; - } - - if (_Config.DeviceUsage.Devices != null && _Config.DeviceUsage.Devices.Count > 0) - { - foreach (var device in _Config.DeviceUsage.Devices) - { - try - { - Debug.Console(1, this, "Creating Device: {0}, {1}, {2}", device.JoinNumber, device.Type, - device.Name); - DeviceUsage.CreateDevice(device.JoinNumber, device.Type, device.Name); - } - catch (Exception ex) - { - Debug.Console(0, this, "{0}", ex); - } - } - } - if (_Config.DeviceUsage.Displays != null && _Config.DeviceUsage.Displays.Count > 0) - { - foreach (var display in _Config.DeviceUsage.Displays) - { - try - { - Debug.Console(1, this, "Creating Display: {0}, {1}", display.JoinNumber, display.Name); - DeviceUsage.CreateDisplay(display.JoinNumber, display.Name); - } - catch (Exception ex) - { - Debug.Console(0, this, "{0}", ex); - } - } - } - if (_Config.DeviceUsage.Sources != null && _Config.DeviceUsage.Sources.Count > 0) - { - foreach (var source in _Config.DeviceUsage.Sources) - { - try - { - Debug.Console(1, this, "Creating Source: {0}, {1}", source.SourceNumber, source.Name); - DeviceUsage.CreateSource(source.SourceNumber, source.Name, source.Type); - } - catch (Exception ex) - { - Debug.Console(0, this, "{0}", ex); - } - } - } - } - } - - private void CreateStandardJoin(JoinDataComplete join, BooleanSigDataFixedName Sig) - { - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) - { - DigitalAttributesFromFusion.Add(join.JoinNumber, - new DynFusionDigitalAttribute(join.Metadata.Description, join.JoinNumber)); - } - - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) - { - DigitalAttributesToFusion.Add(join.JoinNumber, - new DynFusionDigitalAttribute(join.Metadata.Description, join.JoinNumber)); - DigitalAttributesToFusion[join.JoinNumber].BoolValueFeedback.LinkInputSig(Sig.InputSig); - } - } - - private void CreateStandardJoin(JoinDataComplete join, UShortSigDataFixedName Sig) - { - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) - { - AnalogAttributesFromFusion.Add(join.JoinNumber, - new DynFusionAnalogAttribute(join.Metadata.Description, join.JoinNumber)); - } - - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) - { - AnalogAttributesToFusion.Add(join.JoinNumber, - new DynFusionAnalogAttribute(join.Metadata.Description, join.JoinNumber)); - AnalogAttributesToFusion[join.JoinNumber].UShortValueFeedback.LinkInputSig(Sig.InputSig); - } - } - - private void CreateStandardJoin(JoinDataComplete join, StringSigDataFixedName Sig) - { - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) - { - SerialAttributesFromFusion.Add(join.JoinNumber, - new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); - } - - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) - { - SerialAttributesToFusion.Add(join.JoinNumber, - new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); - SerialAttributesToFusion[join.JoinNumber].StringValueFeedback.LinkInputSig(Sig.InputSig); - } - } - - private void CreateStandardJoin(JoinDataComplete join, StringInputSig Sig) - { - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) - { - SerialAttributesFromFusion.Add(join.JoinNumber, - new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); - } - - if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || - join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) - { - SerialAttributesToFusion.Add(join.JoinNumber, - new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); - SerialAttributesToFusion[join.JoinNumber].StringValueFeedback.LinkInputSig(Sig); - } - } - - private void FusionSymbol_RoomDataDeviceExtenderSigChange(DeviceExtender currentDeviceExtender, - SigEventArgs args) - { - Debug.Console(DebugExtensions.Verbose, this, - string.Format("DynFusion DeviceExtenderChange {0} {1} {2} {3}", currentDeviceExtender.ToString(), - args.Sig.Number, args.Sig.Type, args.Sig.StringValue)); - - var joinNumber = (ushort) args.Sig.Number; - - switch (args.Sig.Type) - { - case eSigType.Bool: - { - break; - } - case eSigType.UShort: - { - break; - } - - case eSigType.String: - { - //var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; - DynFusionSerialAttribute output; - - - if (SerialAttributesFromFusion.TryGetValue(args.Sig.Number, out output)) - { - output.StringValue = args.Sig.StringValue; - } - - if (args.Sig == FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse && - args.Sig.StringValue != null) - { - RoomConfigParseData(args.Sig.StringValue); - } - - - break; - } - } - } - - private void FusionSymbol_FusionStateChange(FusionBase device, FusionStateEventArgs args) - { - Debug.Console(DebugExtensions.Verbose, this, "DynFusion FusionStateChange {0} {1}", args.EventId, - args.UserConfiguredSigDetail.ToString()); - - switch (args.EventId) - { - case FusionEventIds.SystemPowerOnReceivedEventId: - { - // Comments - var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; - DynFusionDigitalAttribute output; - if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.SystemPowerOn.JoinNumber, out output)) - { - output.BoolValue = sigDetails.OutputSig.BoolValue; - } - break; - } - case FusionEventIds.SystemPowerOffReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; - DynFusionDigitalAttribute output; - if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.SystemPowerOff.JoinNumber, out output)) - { - output.BoolValue = sigDetails.OutputSig.BoolValue; - } - break; - } - case FusionEventIds.DisplayPowerOnReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; - DynFusionDigitalAttribute output; - if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.DisplayPowerOn.JoinNumber, out output)) - { - output.BoolValue = sigDetails.OutputSig.BoolValue; - } - break; - } - case FusionEventIds.DisplayPowerOffReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; - DynFusionDigitalAttribute output; - if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.DisplayPowerOff.JoinNumber, out output)) - { - output.BoolValue = sigDetails.OutputSig.BoolValue; - } - break; - } - case FusionEventIds.BroadcastMessageTypeReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionAnalogAttribute output; - if (AnalogAttributesFromFusion.TryGetValue(JoinMapStatic.BoradcasetMsgType.JoinNumber, out output)) - { - output.UShortValue = sigDetails.OutputSig.UShortValue; - } - break; - } - case FusionEventIds.HelpMessageReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionSerialAttribute output; - if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.SystemPowerOn.JoinNumber, out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - case FusionEventIds.TextMessageFromRoomReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionSerialAttribute output; - if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.TextMessage.JoinNumber, out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - case FusionEventIds.BroadcastMessageReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionSerialAttribute output; - if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.BroadcastMsg.JoinNumber, out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - case FusionEventIds.GroupMembershipRequestReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionSerialAttribute output; - if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.GroupMembership.JoinNumber, out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - case FusionEventIds.AuthenticateFailedReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionSerialAttribute output; - if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.AuthenticationFailed.JoinNumber, out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - case FusionEventIds.AuthenticateSucceededReceivedEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; - DynFusionSerialAttribute output; - if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.AuthenticationSucceeded.JoinNumber, - out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - case FusionEventIds.UserConfiguredBoolSigChangeEventId: - { - var sigDetails = args.UserConfiguredSigDetail as BooleanSigData; - var joinNumber = sigDetails.Number + FusionJoinOffset; - DynFusionDigitalAttribute output; - - Debug.Console(DebugExtensions.Verbose, this, "DynFusion UserAttribute Digital Join:{0} Name:{1} Value:{2}", joinNumber, - sigDetails.Name, sigDetails.OutputSig.BoolValue); - - if (DigitalAttributesFromFusion.TryGetValue(joinNumber, out output)) - { - output.BoolValue = sigDetails.OutputSig.BoolValue; - } - break; - } - - case FusionEventIds.UserConfiguredUShortSigChangeEventId: - { - var sigDetails = args.UserConfiguredSigDetail as UShortSigData; - var joinNumber = sigDetails.Number + FusionJoinOffset; - DynFusionAnalogAttribute output; - - Debug.Console(DebugExtensions.Verbose, this, "DynFusion UserAttribute Analog Join:{0} Name:{1} Value:{2}", joinNumber, - sigDetails.Name, sigDetails.OutputSig.UShortValue); - - if (AnalogAttributesFromFusion.TryGetValue(joinNumber, out output)) - { - output.UShortValue = sigDetails.OutputSig.UShortValue; - } - break; - } - case FusionEventIds.UserConfiguredStringSigChangeEventId: - { - var sigDetails = args.UserConfiguredSigDetail as StringSigData; - var joinNumber = sigDetails.Number + FusionJoinOffset; - DynFusionSerialAttribute output; - - Debug.Console(DebugExtensions.Verbose, this, "DynFusion UserAttribute Analog Join:{0} Name:{1} Value:{2}", joinNumber, - sigDetails.Name, sigDetails.OutputSig.StringValue); - - if (SerialAttributesFromFusion.TryGetValue(joinNumber, out output)) - { - output.StringValue = sigDetails.OutputSig.StringValue; - } - break; - } - } - } - - private void FusionSymbol_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - FusionOnlineFeedback.FireUpdate(); - if (args.DeviceOnLine) - { - GetRoomConfig(); - } - } - - public static eSigIoMask GetIOMask(eReadWrite mask) - { - var type = eSigIoMask.NA; - - switch (mask) - { - case eReadWrite.R: - type = eSigIoMask.InputSigOnly; - break; - case eReadWrite.W: - type = eSigIoMask.OutputSigOnly; - break; - case eReadWrite.RW: - type = eSigIoMask.InputOutputSig; - break; - } - return (type); - } - - public static eSigIoMask GetIOMask(string mask) - { - var _RWType = eSigIoMask.NA; - - switch (mask) - { - case "R": - _RWType = eSigIoMask.InputSigOnly; - break; - case "W": - _RWType = eSigIoMask.OutputSigOnly; - break; - case "RW": - _RWType = eSigIoMask.InputOutputSig; - break; - } - return (_RWType); - } - - private static eReadWrite GeteReadWrite(eJoinCapabilities mask) - { - eReadWrite type = eReadWrite.ReadWrite; - - switch (mask) - { - case eJoinCapabilities.FromSIMPL: - type = eReadWrite.Read; - break; - case eJoinCapabilities.ToSIMPL: - type = eReadWrite.Write; - break; - case eJoinCapabilities.ToFromSIMPL: - type = eReadWrite.ReadWrite; - break; - } - return (type); - } - - public static uint GetNextAvailableAssetNumber(FusionRoom room) - { - uint slotNum = 0; - foreach (var item in room.UserConfigurableAssetDetails) - { - if (item.Number > slotNum) - { - slotNum = item.Number; - } - } - if (slotNum < 5) - { - slotNum = 5; - } - else - slotNum = slotNum + 1; - - Debug.Console(DebugExtensions.Verbose, string.Format("#Next available fusion asset number is: {0}", slotNum)); - - return slotNum; - } - - #region Overrides of EssentialsBridgeableDevice - - public void GetRoomConfig() - { - try - { - if (FusionSymbol.IsOnline) - { - string fusionRoomConfigRequest = - String.Format( - "RoomConfigurationRequest"); - - Debug.Console(DebugExtensions.Verbose, this, "Room Request: {0}", fusionRoomConfigRequest); - FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomConfigQuery.StringValue = - fusionRoomConfigRequest; - } - } - catch (Exception e) - { - Debug.Console(DebugExtensions.Warn, this, "GetRoomConfig Exception Message: {0}", e.Message); - Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception StackTrace: {0}", e.StackTrace); - if(e.InnerException != null) Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception InnerException: {0}", e.InnerException); - } - } - - #endregion - - #region ILogStringsWithLevel Members - - public void SendToLog(IKeyed device, Debug.ErrorLogLevel level, string logMessage) - { - int fusionLevel; - switch (level) - { - case Debug.ErrorLogLevel.Error: - { - fusionLevel = 3; - break; - } - case Debug.ErrorLogLevel.Notice: - { - fusionLevel = 1; - break; - } - case Debug.ErrorLogLevel.Warning: - { - fusionLevel = 2; - break; - } - case Debug.ErrorLogLevel.None: - { - fusionLevel = 0; - break; - } - default: - { - fusionLevel = 0; - break; - } - } - var tempLogMessage = string.Format("{0}:{1}", fusionLevel, logMessage); - long errorlogThrottleTime = 60000; - if (ErrorLogLastMessageSent != tempLogMessage) - { - ErrorLogLastMessageSent = tempLogMessage; - if (ErrorLogTimer == null) - { - ErrorLogTimer = new CTimer(o => - { - Debug.Console(DebugExtensions.Verbose, this, "SendToLog Message:{0}", ErrorLogLastMessageSent); - FusionSymbol.ErrorMessage.InputSig.StringValue = ErrorLogLastMessageSent; - }, errorlogThrottleTime); - } - else - { - ErrorLogTimer.Reset(errorlogThrottleTime); - } - } - } - - #endregion - - #region ILogStrings Members - - public void SendToLog(IKeyed device, string logMessage) - { - FusionSymbol.LogText.InputSig.StringValue = logMessage; - } - - #endregion - - private void RoomConfigParseData(string data) - { - data = data.Replace("&", "and"); - - try - { - XmlDocument roomConfigResponse = new XmlDocument(); - - roomConfigResponse.LoadXml(data); - - var requestRoomConfiguration = roomConfigResponse["RoomConfigurationResponse"]; - - if (requestRoomConfiguration != null) - { - foreach (XmlElement e in roomConfigResponse.FirstChild.ChildNodes) - { - if (e.Name == "RoomInformation") - { - XmlReader roomInfo = new XmlReader(e.OuterXml); - - RoomInformation = CrestronXMLSerialization.DeSerializeObject(roomInfo); - var attirbute = SerialAttributesFromFusion.SingleOrDefault(x => x.Value.Name == "Name"); - - if (attirbute.Value != null) - { - attirbute.Value.StringValue = RoomInformation.Name; - } - } - else if (e.Name == "CustomFields") - { - foreach (XmlElement el in e) - { - var id = el.Attributes["ID"].Value; - - var type = el.SelectSingleNode("CustomFieldType").InnerText; - var val = el.SelectSingleNode("CustomFieldValue").InnerText; - if (type == "Boolean") - { - var attribute = DigitalAttributesFromFusion.SingleOrDefault(x => x.Value.Name == id); - - if (attribute.Value != null) - { - attribute.Value.BoolValue = Boolean.Parse(val); - } - } - else if (type == "Integer") - { - var attribute = AnalogAttributesFromFusion.SingleOrDefault(x => x.Value.Name == id); - - if (attribute.Value != null) - { - attribute.Value.UShortValue = uint.Parse(val); - } - } - else if (type == "String" || type == "Text" || type == "URL") - { - var attribute = SerialAttributesFromFusion.SingleOrDefault(x => x.Value.Name == id); - - if (attribute.Value != null) - { - attribute.Value.StringValue = val; - } - } - Debug.Console(2, this, "RoomConfigParseData {0} {1} {2}", type, id, val); - } - } - } - } - } - catch (Exception e) - { - Debug.Console(DebugExtensions.Warn, this, "GetRoomConfig Exception Message: {0}", e.Message); - Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception StackTrace: {0}", e.StackTrace); - if(e.InnerException != null) Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception InnerException: {0}", e.InnerException); - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - Debug.Console(DebugExtensions.Warn, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(DebugExtensions.Trace, "Linking to Bridge AssetType {0}", GetType().Name); - var joinMap = new DynFusionJoinMap(joinStart); - - FusionOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Online.JoinNumber]); - - foreach (var att in DigitalAttributesToFusion) - { - var attLocal = att.Value; - trilist.SetBoolSigAction(attLocal.JoinNumber, (b) => { attLocal.BoolValue = b; }); - } - foreach (var att in DigitalAttributesFromFusion) - { - var attLocal = att.Value; - attLocal.BoolValueFeedback.LinkInputSig(trilist.BooleanInput[attLocal.JoinNumber]); - } - foreach (var att in AnalogAttributesToFusion) - { - var attLocal = att.Value; - trilist.SetUShortSigAction(attLocal.JoinNumber, (a) => { attLocal.UShortValue = a; }); - } - foreach (var att in AnalogAttributesFromFusion) - { - var attLocal = att.Value; - attLocal.UShortValueFeedback.LinkInputSig(trilist.UShortInput[attLocal.JoinNumber]); - } - - foreach (var att in SerialAttributesToFusion) - { - var attLocal = att.Value; - trilist.SetStringSigAction(attLocal.JoinNumber, (a) => { attLocal.StringValue = a; }); - } - foreach (var att in SerialAttributesFromFusion) - { - var attLocal = att.Value; - attLocal.StringValueFeedback.LinkInputSig(trilist.StringInput[attLocal.JoinNumber]); - } - - trilist.SetSigTrueAction(joinMap.RoomConfig.JoinNumber, () => GetRoomConfig()); - - foreach (var staticAsset in _staticAssets) - { - var device = staticAsset.Value; - device.LinkToApi(trilist, joinStart, joinMapKey, bridge); - } - - foreach (var callStatisticsDevice in _callStatisticsDevices) - { - var join = callStatisticsDevice.Key; - var device = callStatisticsDevice.Value; - - trilist.SetBoolSigAction(join, state => - { - if (state) - { - device.StartDevice(); - } - else - { - device.StopDevice(); - } - }); - - device.CallTimeFeedback.LinkInputSig(trilist.StringInput[join]); - } - - if (DeviceUsage != null) - { - foreach (var device in DeviceUsage.usageInfoDict) - { - switch (device.Value.usageType) - { - case DynFusionDeviceUsage.UsageType.Display: - { - ushort x = device.Value.joinNumber; - trilist.SetUShortSigAction(device.Value.joinNumber, - (args) => DeviceUsage.changeSource(x, args)); - break; - } - case DynFusionDeviceUsage.UsageType.Device: - { - ushort x = device.Value.joinNumber; - trilist.SetBoolSigAction(device.Value.joinNumber, - (args) => DeviceUsage.StartStopDevice(x, args)); - break; - } - } - } - } - trilist.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - GetRoomConfig(); - foreach (var att in SerialAttributesFromFusion) - { - var attLocal = att.Value; - var trilistLocal = o as BasicTriList; - trilistLocal.StringInput[attLocal.JoinNumber].StringValue = attLocal.StringValue; - } - } - }; - } - } - - public class RoomInformation - { - public string ID { get; set; } - public string Name { get; set; } - public string Location { get; set; } - public string Description { get; set; } - public string TimeZone { get; set; } - public string WebcamURL { get; set; } - public string BacklogMsg { get; set; } - public string SubErrorMsg { get; set; } - public string EmailInfo { get; set; } - public List FusionCustomProperties { get; set; } - - public RoomInformation() - { - FusionCustomProperties = new List(); - } - } +// For Basic SIMPL# Classes +// For Basic SIMPL#Pro classes + +using Crestron.SimplSharpPro.DeviceSupport; +using DynFusion.Config; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Interfaces; +using PepperDash.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharpPro.Fusion; +using Crestron.SimplSharpPro; +using Crestron.SimplSharp.CrestronXml; +using Crestron.SimplSharp.CrestronXml.Serialization; +using Crestron.SimplSharp; +using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; + + +namespace DynFusion +{ + public class DynFusionDevice : EssentialsBridgeableDevice, ILogStringsWithLevel, ILogStrings + { + public const ushort FusionJoinOffset = 49; + //DynFusion Joins + + private DynFusionConfigObjectTemplate _Config; + private Dictionary DigitalAttributesToFusion; + private Dictionary AnalogAttributesToFusion; + private Dictionary SerialAttributesToFusion; + private Dictionary DigitalAttributesFromFusion; + private Dictionary AnalogAttributesFromFusion; + private Dictionary SerialAttributesFromFusion; + + private readonly IDictionary _callStatisticsDevices + = new Dictionary(); + + private readonly IDictionary _staticAssets + = new Dictionary(); + + private static DynFusionJoinMap JoinMapStatic; + + public BoolFeedback FusionOnlineFeedback; + public RoomInformation RoomInformation; + + public DynFusionDeviceUsage DeviceUsage; + public FusionRoom FusionSymbol; + private CTimer ErrorLogTimer; + private string ErrorLogLastMessageSent; + + public DynFusionDevice(string key, string name, DynFusionConfigObjectTemplate config) + : base(key, name) + { + Debug.Console(0, this, "Constructing new DynFusionDevice instance"); + _Config = config; + DigitalAttributesToFusion = new Dictionary(); + AnalogAttributesToFusion = new Dictionary(); + SerialAttributesToFusion = new Dictionary(); + DigitalAttributesFromFusion = new Dictionary(); + AnalogAttributesFromFusion = new Dictionary(); + SerialAttributesFromFusion = new Dictionary(); + JoinMapStatic = new DynFusionJoinMap(1); + Debug.Console(2, "Creating Fusion Symbol {0} {1}", _Config.Control.IpId, Key); + FusionSymbol = new FusionRoom(_Config.Control.IpIdInt, Global.ControlSystem, "", Guid.NewGuid().ToString()); + + if (FusionSymbol.Register() != eDeviceRegistrationUnRegistrationResponse.Success) + { + Debug.Console(0, this, "Faliure to register Fusion Symbol"); + } + FusionSymbol.ExtenderFusionRoomDataReservedSigs.Use(); + } + + public override bool CustomActivate() + { + try + { + // Online Status + FusionOnlineFeedback = new BoolFeedback(() => { return FusionSymbol.IsOnline; }); + FusionSymbol.OnlineStatusChange += new OnlineStatusChangeEventHandler(FusionSymbol_OnlineStatusChange); + + // Attribute State Changes + FusionSymbol.FusionStateChange += new FusionStateEventHandler(FusionSymbol_FusionStateChange); + FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += + new DeviceExtenderJoinChangeEventHandler(FusionSymbol_RoomDataDeviceExtenderSigChange); + + // Create Custom Atributes + foreach (var att in _Config.CustomAttributes.DigitalAttributes) + { + FusionSymbol.AddSig(eSigType.Bool, att.JoinNumber - FusionJoinOffset, att.Name, + GetIOMask(att.RwType)); + + if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Read) + { + DigitalAttributesToFusion.Add(att.JoinNumber, + new DynFusionDigitalAttribute(att.Name, att.JoinNumber, att.LinkDeviceKey, + att.LinkDeviceMethod, att.LinkDeviceFeedback)); + + DigitalAttributesToFusion[att.JoinNumber].BoolValueFeedback.LinkInputSig( + FusionSymbol.UserDefinedBooleanSigDetails[att.JoinNumber - FusionJoinOffset].InputSig); + } + if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Write) + { + DigitalAttributesFromFusion.Add(att.JoinNumber, + new DynFusionDigitalAttribute(att.Name, att.JoinNumber)); + } + } + + foreach (var att in _Config.CustomAttributes.AnalogAttributes) + { + FusionSymbol.AddSig(eSigType.UShort, att.JoinNumber - FusionJoinOffset, att.Name, + GetIOMask(att.RwType)); + + if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Read) + { + AnalogAttributesToFusion.Add(att.JoinNumber, + new DynFusionAnalogAttribute(att.Name, att.JoinNumber)); + + AnalogAttributesToFusion[att.JoinNumber].UShortValueFeedback.LinkInputSig( + FusionSymbol.UserDefinedUShortSigDetails[att.JoinNumber - FusionJoinOffset].InputSig); + } + if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Write) + { + AnalogAttributesFromFusion.Add(att.JoinNumber, + new DynFusionAnalogAttribute(att.Name, att.JoinNumber)); + } + } + foreach (var att in _Config.CustomAttributes.SerialAttributes) + { + FusionSymbol.AddSig(eSigType.String, att.JoinNumber - FusionJoinOffset, att.Name, + GetIOMask(att.RwType)); + if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Read) + { + SerialAttributesToFusion.Add(att.JoinNumber, + new DynFusionSerialAttribute(att.Name, att.JoinNumber)); + + SerialAttributesToFusion[att.JoinNumber].StringValueFeedback.LinkInputSig( + FusionSymbol.UserDefinedStringSigDetails[att.JoinNumber - FusionJoinOffset].InputSig); + } + if (att.RwType == eReadWrite.ReadWrite || att.RwType == eReadWrite.Write) + { + SerialAttributesFromFusion.Add(att.JoinNumber, + new DynFusionSerialAttribute(att.Name, att.JoinNumber)); + } + } + + // Create Links for Standard joins + CreateStandardJoin(JoinMapStatic.SystemPowerOn, FusionSymbol.SystemPowerOn); + CreateStandardJoin(JoinMapStatic.SystemPowerOff, FusionSymbol.SystemPowerOff); + CreateStandardJoin(JoinMapStatic.DisplayPowerOn, FusionSymbol.DisplayPowerOn); + CreateStandardJoin(JoinMapStatic.DisplayPowerOff, FusionSymbol.DisplayPowerOff); + CreateStandardJoin(JoinMapStatic.MsgBroadcastEnabled, FusionSymbol.MessageBroadcastEnabled); + CreateStandardJoin(JoinMapStatic.AuthenticationSucceeded, FusionSymbol.AuthenticateSucceeded); + CreateStandardJoin(JoinMapStatic.AuthenticationFailed, FusionSymbol.AuthenticateFailed); + + CreateStandardJoin(JoinMapStatic.DeviceUsage, FusionSymbol.DisplayUsage); + CreateStandardJoin(JoinMapStatic.BoradcasetMsgType, FusionSymbol.BroadcastMessageType); + + CreateStandardJoin(JoinMapStatic.HelpMsg, FusionSymbol.Help); + CreateStandardJoin(JoinMapStatic.ErrorMsg, FusionSymbol.ErrorMessage); + CreateStandardJoin(JoinMapStatic.LogText, FusionSymbol.LogText); + + // Room Data Extender + CreateStandardJoin(JoinMapStatic.ActionQuery, + FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQuery); + CreateStandardJoin(JoinMapStatic.RoomConfig, + FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomConfigQuery); + + if (_Config.CustomProperties != null) + { + if (_Config.CustomProperties.DigitalProperties != null) + { + foreach (var att in _Config.CustomProperties.DigitalProperties) + { + DigitalAttributesFromFusion.Add(att.JoinNumber, + new DynFusionDigitalAttribute(att.Id, att.JoinNumber)); + } + } + if (_Config.CustomProperties.AnalogProperties != null) + { + foreach (var att in _Config.CustomProperties.AnalogProperties) + { + AnalogAttributesFromFusion.Add(att.JoinNumber, + new DynFusionAnalogAttribute(att.Id, att.JoinNumber)); + } + } + if (_Config.CustomProperties.SerialProperties != null) + { + foreach (var att in _Config.CustomProperties.SerialProperties) + { + SerialAttributesFromFusion.Add(att.JoinNumber, + new DynFusionSerialAttribute(att.Id, att.JoinNumber)); + } + } + } + + if (_Config.Assets != null) + { + if (_Config.Assets.OccupancySensors != null) + { + var sensors = from occSensorConfig in _Config.Assets.OccupancySensors + select + new DynFusionAssetOccupancySensor( + occSensorConfig.Key, + occSensorConfig.LinkToDeviceKey, + FusionSymbol, + GetNextAvailableAssetNumber(FusionSymbol)); + + sensors + .ToList() + .ForEach(sensor => + FusionSymbol.AddAsset( + eAssetType.OccupancySensor, + sensor.AssetNumber, + sensor.Key, + "Occupancy Sensor", + Guid.NewGuid().ToString())); + } + + Debug.Console(DebugExtensions.Trace, this, "DynFusionDevice SetupAsset: StaticAssets config {0} null", + _Config.Assets.StaticAssets == null ? "==" : "!="); + + if (_Config.Assets.StaticAssets != null) + { + var staticAssets = from staticAssetsConfig in _Config.Assets.StaticAssets + select + new DynFusionStaticAsset( + this, + FusionSymbol, + GetNextAvailableAssetNumber(FusionSymbol), + staticAssetsConfig); + + //staticAssets + // .ToList() + // .ForEach(staticAsset => + // FusionSymbol.AddAsset( + // eAssetType.StaticAsset, + // staticAsset.AssetNumber, + // staticAsset.Key, + // staticAsset.AssetType, + // Guid.NewGuid().ToString())); + + staticAssets + .ToList() + .ForEach(staticAsset => + { + _staticAssets.Add(staticAsset.AssetNumber, staticAsset); + }); + } + } + + if (_Config.CallStatistics != null) + { + var callStats = from callStatsConfig in _Config.CallStatistics.Devices + select + new DynFusionCallStatisticsDevice( + Key + "-" + callStatsConfig.Name, + callStatsConfig.Name, + FusionSymbol, + callStatsConfig.Type, + callStatsConfig.UseCallTimer, + callStatsConfig.PostMeetingId, + callStatsConfig.JoinNumber); + + callStats + .ToList() + .ForEach(callStat => _callStatisticsDevices.Add(callStat.JoinNumber, callStat)); + } + + DeviceUsageFactory(); + // Scheduling Bits for Future + //FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.Use(); + //FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(ExtenderRoomViewSchedulingDataReservedSigs_DeviceExtenderSigChange); + + // Future for time sync + // FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange); + if ( string.IsNullOrEmpty(FusionSymbol.ParameterRoomName)) + { + FusionSymbol.ParameterRoomName = EthernetHelper.LanHelper.Hostname + "-program " + InitialParametersClass.ApplicationNumber + CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0) +CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); + + } + + + FusionRVI.GenerateFileForAllFusionDevices(); + } + catch (Exception ex) + { + Debug.Console(2, this, "Exception DynFusion SetupAsset {0}", ex); + } + return true; + } + + + + private void DeviceUsageFactory() + { + if (_Config.DeviceUsage != null) + { + DeviceUsage = new DynFusionDeviceUsage(string.Format("{0}-DeviceUsage", Key), this); + if (_Config.DeviceUsage.UsageMinThreshold > 0) + { + DeviceUsage.usageMinThreshold = (int) _Config.DeviceUsage.UsageMinThreshold; + } + + if (_Config.DeviceUsage.Devices != null && _Config.DeviceUsage.Devices.Count > 0) + { + foreach (var device in _Config.DeviceUsage.Devices) + { + try + { + Debug.Console(1, this, "Creating Device: {0}, {1}, {2}", device.JoinNumber, device.Type, + device.Name); + DeviceUsage.CreateDevice(device.JoinNumber, device.Type, device.Name); + } + catch (Exception ex) + { + Debug.Console(0, this, "{0}", ex); + } + } + } + if (_Config.DeviceUsage.Displays != null && _Config.DeviceUsage.Displays.Count > 0) + { + foreach (var display in _Config.DeviceUsage.Displays) + { + try + { + Debug.Console(1, this, "Creating Display: {0}, {1}", display.JoinNumber, display.Name); + DeviceUsage.CreateDisplay(display.JoinNumber, display.Name); + } + catch (Exception ex) + { + Debug.Console(0, this, "{0}", ex); + } + } + } + if (_Config.DeviceUsage.Sources != null && _Config.DeviceUsage.Sources.Count > 0) + { + foreach (var source in _Config.DeviceUsage.Sources) + { + try + { + Debug.Console(1, this, "Creating Source: {0}, {1}", source.SourceNumber, source.Name); + DeviceUsage.CreateSource(source.SourceNumber, source.Name, source.Type); + } + catch (Exception ex) + { + Debug.Console(0, this, "{0}", ex); + } + } + } + } + } + + private void CreateStandardJoin(JoinDataComplete join, BooleanSigDataFixedName Sig) + { + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) + { + DigitalAttributesFromFusion.Add(join.JoinNumber, + new DynFusionDigitalAttribute(join.Metadata.Description, join.JoinNumber)); + } + + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) + { + DigitalAttributesToFusion.Add(join.JoinNumber, + new DynFusionDigitalAttribute(join.Metadata.Description, join.JoinNumber)); + DigitalAttributesToFusion[join.JoinNumber].BoolValueFeedback.LinkInputSig(Sig.InputSig); + } + } + + private void CreateStandardJoin(JoinDataComplete join, UShortSigDataFixedName Sig) + { + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) + { + AnalogAttributesFromFusion.Add(join.JoinNumber, + new DynFusionAnalogAttribute(join.Metadata.Description, join.JoinNumber)); + } + + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) + { + AnalogAttributesToFusion.Add(join.JoinNumber, + new DynFusionAnalogAttribute(join.Metadata.Description, join.JoinNumber)); + AnalogAttributesToFusion[join.JoinNumber].UShortValueFeedback.LinkInputSig(Sig.InputSig); + } + } + + private void CreateStandardJoin(JoinDataComplete join, StringSigDataFixedName Sig) + { + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) + { + SerialAttributesFromFusion.Add(join.JoinNumber, + new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); + } + + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) + { + SerialAttributesToFusion.Add(join.JoinNumber, + new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); + SerialAttributesToFusion[join.JoinNumber].StringValueFeedback.LinkInputSig(Sig.InputSig); + } + } + + private void CreateStandardJoin(JoinDataComplete join, StringInputSig Sig) + { + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.ToSIMPL) + { + SerialAttributesFromFusion.Add(join.JoinNumber, + new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); + } + + if (join.Metadata.JoinCapabilities == eJoinCapabilities.ToFromSIMPL || + join.Metadata.JoinCapabilities == eJoinCapabilities.FromSIMPL) + { + SerialAttributesToFusion.Add(join.JoinNumber, + new DynFusionSerialAttribute(join.Metadata.Description, join.JoinNumber)); + SerialAttributesToFusion[join.JoinNumber].StringValueFeedback.LinkInputSig(Sig); + } + } + + private void FusionSymbol_RoomDataDeviceExtenderSigChange(DeviceExtender currentDeviceExtender, + SigEventArgs args) + { + Debug.Console(DebugExtensions.Verbose, this, + string.Format("DynFusion DeviceExtenderChange {0} {1} {2} {3}", currentDeviceExtender.ToString(), + args.Sig.Number, args.Sig.Type, args.Sig.StringValue)); + + var joinNumber = (ushort) args.Sig.Number; + + switch (args.Sig.Type) + { + case eSigType.Bool: + { + break; + } + case eSigType.UShort: + { + break; + } + + case eSigType.String: + { + //var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; + DynFusionSerialAttribute output; + + + if (SerialAttributesFromFusion.TryGetValue(args.Sig.Number, out output)) + { + output.StringValue = args.Sig.StringValue; + } + + if (args.Sig == FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse && + args.Sig.StringValue != null) + { + RoomConfigParseData(args.Sig.StringValue); + } + + + break; + } + } + } + + private void FusionSymbol_FusionStateChange(FusionBase device, FusionStateEventArgs args) + { + Debug.Console(DebugExtensions.Verbose, this, "DynFusion FusionStateChange {0} {1}", args.EventId, + args.UserConfiguredSigDetail.ToString()); + + switch (args.EventId) + { + case FusionEventIds.SystemPowerOnReceivedEventId: + { + // Comments + var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; + DynFusionDigitalAttribute output; + if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.SystemPowerOn.JoinNumber, out output)) + { + output.BoolValue = sigDetails.OutputSig.BoolValue; + } + break; + } + case FusionEventIds.SystemPowerOffReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; + DynFusionDigitalAttribute output; + if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.SystemPowerOff.JoinNumber, out output)) + { + output.BoolValue = sigDetails.OutputSig.BoolValue; + } + break; + } + case FusionEventIds.DisplayPowerOnReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; + DynFusionDigitalAttribute output; + if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.DisplayPowerOn.JoinNumber, out output)) + { + output.BoolValue = sigDetails.OutputSig.BoolValue; + } + break; + } + case FusionEventIds.DisplayPowerOffReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as BooleanSigDataFixedName; + DynFusionDigitalAttribute output; + if (DigitalAttributesFromFusion.TryGetValue(JoinMapStatic.DisplayPowerOff.JoinNumber, out output)) + { + output.BoolValue = sigDetails.OutputSig.BoolValue; + } + break; + } + case FusionEventIds.BroadcastMessageTypeReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionAnalogAttribute output; + if (AnalogAttributesFromFusion.TryGetValue(JoinMapStatic.BoradcasetMsgType.JoinNumber, out output)) + { + output.UShortValue = sigDetails.OutputSig.UShortValue; + } + break; + } + case FusionEventIds.HelpMessageReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionSerialAttribute output; + if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.SystemPowerOn.JoinNumber, out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + case FusionEventIds.TextMessageFromRoomReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionSerialAttribute output; + if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.TextMessage.JoinNumber, out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + case FusionEventIds.BroadcastMessageReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionSerialAttribute output; + if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.BroadcastMsg.JoinNumber, out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + case FusionEventIds.GroupMembershipRequestReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionSerialAttribute output; + if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.GroupMembership.JoinNumber, out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + case FusionEventIds.AuthenticateFailedReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionSerialAttribute output; + if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.AuthenticationFailed.JoinNumber, out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + case FusionEventIds.AuthenticateSucceededReceivedEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigDataFixedName; + DynFusionSerialAttribute output; + if (SerialAttributesFromFusion.TryGetValue(JoinMapStatic.AuthenticationSucceeded.JoinNumber, + out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + case FusionEventIds.UserConfiguredBoolSigChangeEventId: + { + var sigDetails = args.UserConfiguredSigDetail as BooleanSigData; + var joinNumber = sigDetails.Number + FusionJoinOffset; + DynFusionDigitalAttribute output; + + Debug.Console(DebugExtensions.Verbose, this, "DynFusion UserAttribute Digital Join:{0} Name:{1} Value:{2}", joinNumber, + sigDetails.Name, sigDetails.OutputSig.BoolValue); + + if (DigitalAttributesFromFusion.TryGetValue(joinNumber, out output)) + { + output.BoolValue = sigDetails.OutputSig.BoolValue; + } + break; + } + + case FusionEventIds.UserConfiguredUShortSigChangeEventId: + { + var sigDetails = args.UserConfiguredSigDetail as UShortSigData; + var joinNumber = sigDetails.Number + FusionJoinOffset; + DynFusionAnalogAttribute output; + + Debug.Console(DebugExtensions.Verbose, this, "DynFusion UserAttribute Analog Join:{0} Name:{1} Value:{2}", joinNumber, + sigDetails.Name, sigDetails.OutputSig.UShortValue); + + if (AnalogAttributesFromFusion.TryGetValue(joinNumber, out output)) + { + output.UShortValue = sigDetails.OutputSig.UShortValue; + } + break; + } + case FusionEventIds.UserConfiguredStringSigChangeEventId: + { + var sigDetails = args.UserConfiguredSigDetail as StringSigData; + var joinNumber = sigDetails.Number + FusionJoinOffset; + DynFusionSerialAttribute output; + + Debug.Console(DebugExtensions.Verbose, this, "DynFusion UserAttribute Analog Join:{0} Name:{1} Value:{2}", joinNumber, + sigDetails.Name, sigDetails.OutputSig.StringValue); + + if (SerialAttributesFromFusion.TryGetValue(joinNumber, out output)) + { + output.StringValue = sigDetails.OutputSig.StringValue; + } + break; + } + } + } + + private void FusionSymbol_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + FusionOnlineFeedback.FireUpdate(); + if (args.DeviceOnLine) + { + GetRoomConfig(); + } + } + + public static eSigIoMask GetIOMask(eReadWrite mask) + { + var type = eSigIoMask.NA; + + switch (mask) + { + case eReadWrite.R: + type = eSigIoMask.InputSigOnly; + break; + case eReadWrite.W: + type = eSigIoMask.OutputSigOnly; + break; + case eReadWrite.RW: + type = eSigIoMask.InputOutputSig; + break; + } + return (type); + } + + public static eSigIoMask GetIOMask(string mask) + { + var _RWType = eSigIoMask.NA; + + switch (mask) + { + case "R": + _RWType = eSigIoMask.InputSigOnly; + break; + case "W": + _RWType = eSigIoMask.OutputSigOnly; + break; + case "RW": + _RWType = eSigIoMask.InputOutputSig; + break; + } + return (_RWType); + } + + private static eReadWrite GeteReadWrite(eJoinCapabilities mask) + { + eReadWrite type = eReadWrite.ReadWrite; + + switch (mask) + { + case eJoinCapabilities.FromSIMPL: + type = eReadWrite.Read; + break; + case eJoinCapabilities.ToSIMPL: + type = eReadWrite.Write; + break; + case eJoinCapabilities.ToFromSIMPL: + type = eReadWrite.ReadWrite; + break; + } + return (type); + } + + public static uint GetNextAvailableAssetNumber(FusionRoom room) + { + uint slotNum = 0; + foreach (var item in room.UserConfigurableAssetDetails) + { + if (item.Number > slotNum) + { + slotNum = item.Number; + } + } + if (slotNum < 5) + { + slotNum = 5; + } + else + slotNum = slotNum + 1; + + Debug.Console(DebugExtensions.Verbose, string.Format("#Next available fusion asset number is: {0}", slotNum)); + + return slotNum; + } + + #region Overrides of EssentialsBridgeableDevice + + public void GetRoomConfig() + { + try + { + if (FusionSymbol.IsOnline) + { + string fusionRoomConfigRequest = + String.Format( + "RoomConfigurationRequest"); + + Debug.Console(DebugExtensions.Verbose, this, "Room Request: {0}", fusionRoomConfigRequest); + FusionSymbol.ExtenderFusionRoomDataReservedSigs.RoomConfigQuery.StringValue = + fusionRoomConfigRequest; + } + } + catch (Exception e) + { + Debug.Console(DebugExtensions.Warn, this, "GetRoomConfig Exception Message: {0}", e.Message); + Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception StackTrace: {0}", e.StackTrace); + if(e.InnerException != null) Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception InnerException: {0}", e.InnerException); + } + } + + #endregion + + #region ILogStringsWithLevel Members + + public void SendToLog(IKeyed device, Debug.ErrorLogLevel level, string logMessage) + { + int fusionLevel; + switch (level) + { + case Debug.ErrorLogLevel.Error: + { + fusionLevel = 3; + break; + } + case Debug.ErrorLogLevel.Notice: + { + fusionLevel = 1; + break; + } + case Debug.ErrorLogLevel.Warning: + { + fusionLevel = 2; + break; + } + case Debug.ErrorLogLevel.None: + { + fusionLevel = 0; + break; + } + default: + { + fusionLevel = 0; + break; + } + } + var tempLogMessage = string.Format("{0}:{1}", fusionLevel, logMessage); + long errorlogThrottleTime = 60000; + if (ErrorLogLastMessageSent != tempLogMessage) + { + ErrorLogLastMessageSent = tempLogMessage; + if (ErrorLogTimer == null) + { + ErrorLogTimer = new CTimer(o => + { + Debug.Console(DebugExtensions.Verbose, this, "SendToLog Message:{0}", ErrorLogLastMessageSent); + FusionSymbol.ErrorMessage.InputSig.StringValue = ErrorLogLastMessageSent; + }, errorlogThrottleTime); + } + else + { + ErrorLogTimer.Reset(errorlogThrottleTime); + } + } + } + + #endregion + + #region ILogStrings Members + + public void SendToLog(IKeyed device, string logMessage) + { + FusionSymbol.LogText.InputSig.StringValue = logMessage; + } + + #endregion + + private void RoomConfigParseData(string data) + { + data = data.Replace("&", "and"); + + try + { + XmlDocument roomConfigResponse = new XmlDocument(); + + roomConfigResponse.LoadXml(data); + + var requestRoomConfiguration = roomConfigResponse["RoomConfigurationResponse"]; + + if (requestRoomConfiguration != null) + { + foreach (XmlElement e in roomConfigResponse.FirstChild.ChildNodes) + { + if (e.Name == "RoomInformation") + { + XmlReader roomInfo = new XmlReader(e.OuterXml); + + RoomInformation = CrestronXMLSerialization.DeSerializeObject(roomInfo); + var attirbute = SerialAttributesFromFusion.SingleOrDefault(x => x.Value.Name == "Name"); + + if (attirbute.Value != null) + { + attirbute.Value.StringValue = RoomInformation.Name; + } + } + else if (e.Name == "CustomFields") + { + foreach (XmlElement el in e) + { + var id = el.Attributes["ID"].Value; + + var type = el.SelectSingleNode("CustomFieldType").InnerText; + var val = el.SelectSingleNode("CustomFieldValue").InnerText; + if (type == "Boolean") + { + var attribute = DigitalAttributesFromFusion.SingleOrDefault(x => x.Value.Name == id); + + if (attribute.Value != null) + { + attribute.Value.BoolValue = Boolean.Parse(val); + } + } + else if (type == "Integer") + { + var attribute = AnalogAttributesFromFusion.SingleOrDefault(x => x.Value.Name == id); + + if (attribute.Value != null) + { + attribute.Value.UShortValue = uint.Parse(val); + } + } + else if (type == "String" || type == "Text" || type == "URL") + { + var attribute = SerialAttributesFromFusion.SingleOrDefault(x => x.Value.Name == id); + + if (attribute.Value != null) + { + attribute.Value.StringValue = val; + } + } + Debug.Console(2, this, "RoomConfigParseData {0} {1} {2}", type, id, val); + } + } + } + } + } + catch (Exception e) + { + Debug.Console(DebugExtensions.Warn, this, "GetRoomConfig Exception Message: {0}", e.Message); + Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception StackTrace: {0}", e.StackTrace); + if(e.InnerException != null) Debug.Console(DebugExtensions.Verbose, this, "GetRoomConfig Exception InnerException: {0}", e.InnerException); + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + Debug.Console(DebugExtensions.Warn, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(DebugExtensions.Trace, "Linking to Bridge AssetType {0}", GetType().Name); + var joinMap = new DynFusionJoinMap(joinStart); + + FusionOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Online.JoinNumber]); + + foreach (var att in DigitalAttributesToFusion) + { + var attLocal = att.Value; + trilist.SetBoolSigAction(attLocal.JoinNumber, (b) => { attLocal.BoolValue = b; }); + } + foreach (var att in DigitalAttributesFromFusion) + { + var attLocal = att.Value; + attLocal.BoolValueFeedback.LinkInputSig(trilist.BooleanInput[attLocal.JoinNumber]); + } + foreach (var att in AnalogAttributesToFusion) + { + var attLocal = att.Value; + trilist.SetUShortSigAction(attLocal.JoinNumber, (a) => { attLocal.UShortValue = a; }); + } + foreach (var att in AnalogAttributesFromFusion) + { + var attLocal = att.Value; + attLocal.UShortValueFeedback.LinkInputSig(trilist.UShortInput[attLocal.JoinNumber]); + } + + foreach (var att in SerialAttributesToFusion) + { + var attLocal = att.Value; + trilist.SetStringSigAction(attLocal.JoinNumber, (a) => { attLocal.StringValue = a; }); + } + foreach (var att in SerialAttributesFromFusion) + { + var attLocal = att.Value; + attLocal.StringValueFeedback.LinkInputSig(trilist.StringInput[attLocal.JoinNumber]); + } + + trilist.SetSigTrueAction(joinMap.RoomConfig.JoinNumber, () => GetRoomConfig()); + + foreach (var staticAsset in _staticAssets) + { + var device = staticAsset.Value; + device.LinkToApi(trilist, joinStart, joinMapKey, bridge); + } + + foreach (var callStatisticsDevice in _callStatisticsDevices) + { + var join = callStatisticsDevice.Key; + var device = callStatisticsDevice.Value; + + trilist.SetBoolSigAction(join, state => + { + if (state) + { + device.StartDevice(); + } + else + { + device.StopDevice(); + } + }); + + device.CallTimeFeedback.LinkInputSig(trilist.StringInput[join]); + } + + if (DeviceUsage != null) + { + foreach (var device in DeviceUsage.usageInfoDict) + { + switch (device.Value.usageType) + { + case DynFusionDeviceUsage.UsageType.Display: + { + ushort x = device.Value.joinNumber; + trilist.SetUShortSigAction(device.Value.joinNumber, + (args) => DeviceUsage.changeSource(x, args)); + break; + } + case DynFusionDeviceUsage.UsageType.Device: + { + ushort x = device.Value.joinNumber; + trilist.SetBoolSigAction(device.Value.joinNumber, + (args) => DeviceUsage.StartStopDevice(x, args)); + break; + } + } + } + } + trilist.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + GetRoomConfig(); + foreach (var att in SerialAttributesFromFusion) + { + var attLocal = att.Value; + var trilistLocal = o as BasicTriList; + trilistLocal.StringInput[attLocal.JoinNumber].StringValue = attLocal.StringValue; + } + } + }; + } + } + + public class RoomInformation + { + public string ID { get; set; } + public string Name { get; set; } + public string Location { get; set; } + public string Description { get; set; } + public string TimeZone { get; set; } + public string WebcamURL { get; set; } + public string BacklogMsg { get; set; } + public string SubErrorMsg { get; set; } + public string EmailInfo { get; set; } + public List FusionCustomProperties { get; set; } + + public RoomInformation() + { + FusionCustomProperties = new List(); + } + } } \ No newline at end of file diff --git a/DynFusionEPI/DynFusionDeviceFactory.cs b/src/DynFusionDeviceFactory.cs similarity index 100% rename from DynFusionEPI/DynFusionDeviceFactory.cs rename to src/DynFusionDeviceFactory.cs diff --git a/DynFusionEPI/DynFusionDeviceUsage.cs b/src/DynFusionDeviceUsage.cs similarity index 100% rename from DynFusionEPI/DynFusionDeviceUsage.cs rename to src/DynFusionDeviceUsage.cs diff --git a/DynFusionEPI/DynFusionJoinMap.cs b/src/DynFusionJoinMap.cs similarity index 50% rename from DynFusionEPI/DynFusionJoinMap.cs rename to src/DynFusionJoinMap.cs index 38730db..20ffc8f 100644 --- a/DynFusionEPI/DynFusionJoinMap.cs +++ b/src/DynFusionJoinMap.cs @@ -1,57 +1,57 @@ -using PepperDash.Essentials.Core; - -namespace DynFusion -{ - public class DynFusionJoinMap : JoinMapBaseAdvanced - { - public JoinDataComplete DeviceName = new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1}, new JoinMetadata{Label = "Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial}); - - // Bools - public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Label = "Fusion Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete SystemPowerOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Label = "SystemPowerOn", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete SystemPowerOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata { Label = "SystemPowerOff", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete DisplayPowerOn = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata { Label = "DisplayPowerOn", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete DisplayPowerOff = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata { Label = "DisplayPowerOoff", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete MsgBroadcastEnabled = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Label = "MsgBroadcastEnabled", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete AuthenticationSucceeded = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, new JoinMetadata { Label = "AuthenticationSucceeded", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public JoinDataComplete AuthenticationFailed = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata { Label = "AuthenticationFailed", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - public JoinDataComplete DisplayUsage = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Label = "DisplayUsage", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - public JoinDataComplete BoradcasetMsgType = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Label = "BoradcasetMsgType", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - public JoinDataComplete HelpMsg = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Label = "HelpMsg", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete ErrorMsg = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Label = "ErrorMsg", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete LogText = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Label = "LogText", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete DeviceUsage = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata { Label = "DeviceUsage", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete TextMessage = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata { Label = "TextMessage", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete BroadcastMsg = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Label = "BroadcastMsg", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete FreeBusyStatus = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, new JoinMetadata { Label = "FreeBusyStatus", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete GroupMembership = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata { Label = "GroupMembership", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - // Scheduling Data Extender - public JoinDataComplete SchedulingQuerey = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, new JoinMetadata { Label = "SchedulingQuerey", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete SchedulingCreate = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, new JoinMetadata { Label = "SchedulingCreate", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete SchedulingRemove = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, new JoinMetadata { Label = "SchedulingRemove", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - - // Room Data Extender - public JoinDataComplete TimeClockQuery = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Label = "TimeClockQuery", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete ActionQuery = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, new JoinMetadata { Label = "ActionQuery", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - public JoinDataComplete RoomConfig = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, new JoinMetadata { Label = "RoomConfigJoin", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); - - /* - public const ushort CurrentTime = 41; - public const ushort CurrentTimeFormat = 41; - public const ushort CurrentDate = 40; - public const ushort CurrentDateFormat = 40; - public const ushort ScheduleGet = 42; - */ - - public DynFusionJoinMap(uint joinStart) - :base(joinStart) - { - - } - - - } +using PepperDash.Essentials.Core; + +namespace DynFusion +{ + public class DynFusionJoinMap : JoinMapBaseAdvanced + { + public JoinDataComplete DeviceName = new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1}, new JoinMetadata{Description = "Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial}); + + // Bools + public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "Fusion Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete SystemPowerOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Description = "SystemPowerOn", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete SystemPowerOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata { Description = "SystemPowerOff", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete DisplayPowerOn = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata { Description = "DisplayPowerOn", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete DisplayPowerOff = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata { Description = "DisplayPowerOoff", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete MsgBroadcastEnabled = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Description = "MsgBroadcastEnabled", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete AuthenticationSucceeded = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, new JoinMetadata { Description = "AuthenticationSucceeded", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete AuthenticationFailed = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata { Description = "AuthenticationFailed", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + public JoinDataComplete DisplayUsage = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Description = "DisplayUsage", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + public JoinDataComplete BoradcasetMsgType = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Description = "BoradcasetMsgType", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + public JoinDataComplete HelpMsg = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "HelpMsg", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete ErrorMsg = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Description = "ErrorMsg", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete LogText = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Description = "LogText", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete DeviceUsage = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata { Description = "DeviceUsage", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete TextMessage = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata { Description = "TextMessage", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete BroadcastMsg = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Description = "BroadcastMsg", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete FreeBusyStatus = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, new JoinMetadata { Description = "FreeBusyStatus", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete GroupMembership = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata { Description = "GroupMembership", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + // Scheduling Data Extender + public JoinDataComplete SchedulingQuerey = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, new JoinMetadata { Description = "SchedulingQuerey", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete SchedulingCreate = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, new JoinMetadata { Description = "SchedulingCreate", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete SchedulingRemove = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, new JoinMetadata { Description = "SchedulingRemove", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + + // Room Data Extender + public JoinDataComplete TimeClockQuery = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Description = "TimeClockQuery", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete ActionQuery = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, new JoinMetadata { Description = "ActionQuery", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + public JoinDataComplete RoomConfig = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, new JoinMetadata { Description = "RoomConfigJoin", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + + /* + public const ushort CurrentTime = 41; + public const ushort CurrentTimeFormat = 41; + public const ushort CurrentDate = 40; + public const ushort CurrentDateFormat = 40; + public const ushort ScheduleGet = 42; + */ + + public DynFusionJoinMap(uint joinStart) + :base(joinStart) + { + + } + + + } } \ No newline at end of file diff --git a/DynFusionEPI/DynFusionScheduleFactory.cs b/src/DynFusionScheduleFactory.cs similarity index 100% rename from DynFusionEPI/DynFusionScheduleFactory.cs rename to src/DynFusionScheduleFactory.cs diff --git a/DynFusionEPI/DynFusionStaticAsset.cs b/src/DynFusionStaticAsset.cs similarity index 100% rename from DynFusionEPI/DynFusionStaticAsset.cs rename to src/DynFusionStaticAsset.cs diff --git a/DynFusionEPI/DynFusionStaticAssetJoinMap.cs b/src/DynFusionStaticAssetJoinMap.cs similarity index 100% rename from DynFusionEPI/DynFusionStaticAssetJoinMap.cs rename to src/DynFusionStaticAssetJoinMap.cs diff --git a/DynFusionEPI/FeedbackExtensions.cs b/src/FeedbackExtensions.cs similarity index 93% rename from DynFusionEPI/FeedbackExtensions.cs rename to src/FeedbackExtensions.cs index f27ce73..4f69a3f 100644 --- a/DynFusionEPI/FeedbackExtensions.cs +++ b/src/FeedbackExtensions.cs @@ -1,28 +1,28 @@ -using PepperDash.Essentials.Core; - -namespace DynFusion -{ - public class BoolWithFeedback - { - private bool _value; - public readonly BoolFeedback Feedback; - - public bool Value - { - get - { - return _value; - } - set - { - _value = value; - Feedback.FireUpdate(); - } - } - - public BoolWithFeedback() - { - Feedback = new BoolFeedback(() => _value); - } - } +using PepperDash.Essentials.Core; + +namespace DynFusion +{ + public class BoolWithFeedback + { + private bool _value; + public readonly BoolFeedback Feedback; + + public bool Value + { + get + { + return _value; + } + set + { + _value = value; + Feedback.FireUpdate(); + } + } + + public BoolWithFeedback() + { + Feedback = new BoolFeedback(() => _value); + } + } } \ No newline at end of file diff --git a/DynFusionEPI/PDTDynFusionEPI.csproj b/src/PDTDynFusionEPI.csproj similarity index 98% rename from DynFusionEPI/PDTDynFusionEPI.csproj rename to src/PDTDynFusionEPI.csproj index 05d0f05..8cad3e8 100644 --- a/DynFusionEPI/PDTDynFusionEPI.csproj +++ b/src/PDTDynFusionEPI.csproj @@ -1,141 +1,141 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9D249E47-8F95-4437-A6BB-563510287AD1} - Library - Properties - DynFusion - PDTDynFusionEPI - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\Debug\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\Release\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\Essentials Devices Common.dll - - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_Core.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_DM.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9D249E47-8F95-4437-A6BB-563510287AD1} + Library + Properties + DynFusion + PDTDynFusionEPI + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\Debug\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\Release\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\Essentials Devices Common.dll + + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_Core.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_DM.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/DynFusionEPI/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs similarity index 97% rename from DynFusionEPI/Properties/AssemblyInfo.cs rename to src/Properties/AssemblyInfo.cs index 28e2ee9..43fd4f3 100644 --- a/DynFusionEPI/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -1,8 +1,8 @@ -using System.Reflection; - -[assembly: AssemblyTitle("EssentialsPluginTemplateEpi")] -[assembly: AssemblyCompany("PepperDash")] -[assembly: AssemblyProduct("EssentialsPluginTemplateEpi")] -[assembly: AssemblyCopyright("Copyright © 2023")] -[assembly: AssemblyVersion("1.0.0.*")] - +using System.Reflection; + +[assembly: AssemblyTitle("EssentialsPluginTemplateEpi")] +[assembly: AssemblyCompany("PepperDash")] +[assembly: AssemblyProduct("EssentialsPluginTemplateEpi")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyVersion("1.0.0.*")] + diff --git a/src/Properties/ControlSystem.cfg b/src/Properties/ControlSystem.cfg new file mode 100644 index 0000000..e69de29 diff --git a/DynFusionEPI/Scheduling.cs b/src/Scheduling.cs similarity index 97% rename from DynFusionEPI/Scheduling.cs rename to src/Scheduling.cs index 73741a0..d12237a 100644 --- a/DynFusionEPI/Scheduling.cs +++ b/src/Scheduling.cs @@ -1,1426 +1,1426 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.CrestronXml; -using Crestron.SimplSharp.CrestronXml.Serialization; -using Crestron.SimplSharp.CrestronXmlLinq; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.Fusion; -using System.Threading; -using Crestron.SimplSharpPro.CrestronThread; -using Crestron.SimplSharp.Net; -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace DynFusion -{ - public class DynFusionScheduleChangeEventArgs : EventArgs - { - string data; - public DynFusionScheduleChangeEventArgs(string someString) - { - data = someString; - } - - } - public class DynFusionSchedule : EssentialsBridgeableDevice - { - public bool fusionOnline = false; - - //public event EventHandler ScheduleChanged; - public event EventHandler ScheduleChanged; - public event EventHandler UpdateRemainingTime; - - - BoolWithFeedback enableMeetingReserve15 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingReserve30 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingReserve45 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingReserve60 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingReserve90 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingExtend15 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingExtend30 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingExtend45 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingExtend60 = new BoolWithFeedback(); - BoolWithFeedback enableMeetingExtend90 = new BoolWithFeedback(); - - long schedulePullTimerTimeout = 300000; - long schedulePushTimerTimeout = 90000; - - DynFusionDevice _DynFusion; - CTimer schedulePullTimer = null; - CTimer schedulePushTimer; - CTimer UpdateRemainingTimeTimer = null; - CTimer getScheduleTimeOut = null; - - SchedulingConfig _Config; - - RoomSchedule CurrentSchedule; - public DynFusionScheduleAvailableRooms AvailableRooms; - - List RoomAvailabilityScheduleResponse = new List(); - - private BoolWithFeedback RegisterdForPush = new BoolWithFeedback(); - private BoolWithFeedback ScheduleBusy = new BoolWithFeedback(); - - - public Event CurrentMeeting; - Event NextMeeting; - Event ThirdMeeting; - Event FourthMeeting; - Event FifthMeeting; - Event SixthMeeting; - - - public DynFusionSchedule(string key, string name, SchedulingConfig config) - : base(key, name) - { - try - { - _Config = config; - } - catch (Exception e) - { - Debug.Console(2, this, String.Format("Get Schedule Error: {0}", e.Message)); - Debug.ConsoleWithLog(2, this, e.ToString()); - } - } - - - public override bool CustomActivate() - { - - if (_Config.DynFusionKey != null) - { - _DynFusion = (DynFusionDevice)DeviceManager.GetDeviceForKey(_Config.DynFusionKey); - - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "DynFusionDeviceKey is not present in config file"); - return false; - } - if (_DynFusion == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error getting DynFusionDevice for key {0}", _Config.DynFusionKey); - return false; - } - _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.Use(); - _DynFusion.FusionSymbol.OnlineStatusChange += new OnlineStatusChangeEventHandler(FusionSymbolStatusChange); - _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(FusionScheduleExtenderSigChange); - _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(FusionRoomDataExtenderSigChange); - AvailableRooms = new DynFusionScheduleAvailableRooms(_DynFusion); - return true; - } - - public void StartSchedPushTimer() - { - //Debug.ConsoleWithLog(2, this, "StartSchedPushTimer", 1); - if (schedulePushTimer == null) - { - Debug.ConsoleWithLog(2, this, "StartSchedPushTimer START", 1); - schedulePushTimer = new CTimer(new CTimerCallbackFunction(GetRoomSchedule), null, schedulePushTimerTimeout, schedulePushTimerTimeout); - } - } - - public void ResetSchedPushTimer() - { - Debug.Console(2, this, "ResetSchedPushTimer", 1); - if (schedulePushTimer != null && !schedulePushTimer.Disposed) - { - Debug.ConsoleWithLog(2, this, "ResetSchedPushTimer RESET", 1); - schedulePushTimer.Reset(schedulePushTimerTimeout, schedulePushTimerTimeout); - } - } - public void StopSchedPushTimer() - { - //Debug.ConsoleWithLog(2, this, "StopSchedPushTimer", 1); - if (schedulePushTimer != null && !schedulePushTimer.Disposed) - { - Debug.ConsoleWithLog(2, this, "StopSchedPushTimer STOP", 1); - schedulePullTimer.Stop(); - schedulePullTimer.Dispose(); - } - } - - - - void AvailableRooms_OnAvailableRoomsUpdate() - { - throw new NotImplementedException(); - } - - void FusionSymbolStatusChange(object o, OnlineOfflineEventArgs e) - { - Debug.Console(2, this, "FusionSymbolStatusChange {0}", e.DeviceOnLine); - fusionOnline = e.DeviceOnLine; - if (fusionOnline) - { - // GetRoomSchedule(); - GetPushSchedule(); - StartUpdateRemainingTimeTimer(); - } - else - { - //UpdateRemainingTimeTimer.Stop(); - } - } - - void GetPushSchedule() - { - try - { - if (fusionOnline) - { - string requestID = "InitialPushRequest"; - string fusionActionRequest = ""; - - fusionActionRequest = String.Format("\n{0}\n" + - "RegisterPushModel\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n", requestID); - - _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = fusionActionRequest; - } - } - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, String.Format("Get Push Schedule Error: {0}", e.Message), 3); - } - } - - void GetRoomSchedule(object unused) - { - GetRoomSchedule(); - } - - public void GetRoomSchedule() - { - if (ScheduleBusy.Value == false) - { - ScheduleBusy.Value = true; - getScheduleTimeOut = new CTimer(getRoomScheduleTimeOut, 6000); - Debug.Console(2, this, String.Format("Get RoomSchedule")); - string roomID = _DynFusion.RoomInformation.ID; - string requestType = "ScheduleRequest"; - GetFullRoomSchedule(roomID, requestType.ToString()); - - } - } - - public void getRoomScheduleTimeOut(object unused) - { - ScheduleBusy.Value = false; - Debug.ConsoleWithLog(2, this, "Error getRoomScheduleTimeOut"); - } - - - void GetFullRoomSchedule(string roomID, string requestType) - { - try - { - if (fusionOnline) - { - string fusionScheduleRequest = ""; - string RFCTime; - - RFCTime = String.Format("{0:s}", DateTime.Now); - - fusionScheduleRequest = String.Format("{0}{1}{2}24", requestType, roomID, RFCTime.ToString()); - - _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = fusionScheduleRequest; - - //if (isRegisteredForSchedulePushNotifications) - //schedulePushTimer.Stop(); - } - } - catch (Exception e) - { - Debug.Console(2, this, String.Format("Get Full Schedule Error: {0}", e.Message)); - Debug.ConsoleWithLog(2, this, e.ToString()); - } - } - - void ExtendMeeting(int extendTimeIn) - { - try - { - if (fusionOnline) - { - if (CurrentMeeting != null) - { - if (CurrentMeeting.isInProgress) - { - string fusionExtendMeetingRequest = ""; - string extendTime; - string meetingID = CurrentMeeting.MeetingID; - - if (extendTimeIn != 0) - { - TimeSpan timeToExtend = CurrentMeeting.dtEnd.Subtract(DateTime.Now); - ushort totalMeetingExtend = (ushort)(timeToExtend.TotalMinutes + extendTimeIn); - extendTime = totalMeetingExtend.ToString(); - } - else - extendTime = extendTimeIn.ToString(); - - - fusionExtendMeetingRequest = String.Format("ExtendMeetingRequestMeetingChange" + - "", meetingID, extendTime.ToString()); - - Debug.Console(2, this, String.Format("ExtendRequest: {0}", fusionExtendMeetingRequest)); - _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = fusionExtendMeetingRequest; - } - else - { - Debug.Console(2, this, String.Format("No Meeting in Progress")); - } - } - } - } - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, e.ToString()); - } - } - - void CreateMeeting(ushort meetingTimeIn) - { - try - { - if (fusionOnline) - { - if (CurrentMeeting == null) - { - string fusionCreateMeetingRequest = ""; - string meetingTime = meetingTimeIn.ToString(); - string startTime; - string endTime; - - TimeSpan meetingLength = new TimeSpan(0, (int)meetingTimeIn, 0); - - startTime = String.Format("{0:s}", DateTime.Now); - endTime = String.Format("{0:s}", DateTime.Now.Add(meetingLength)); - - Debug.Console(2, this, String.Format("Start Time: {0}, End Time: {1}", startTime, endTime)); - - fusionCreateMeetingRequest = String.Format("ExtendMeetingRequest" + - "{0}{1}Ad-Hoc Meeting Created{2}" + - "Meeting Created>", startTime, endTime, _DynFusion.RoomInformation.Name.ToString()); - - Debug.Console(2, this, String.Format("Create Meeting Request: {0}", fusionCreateMeetingRequest)); - _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = fusionCreateMeetingRequest; - } - else - { - Debug.Console(2, this, String.Format("Meeting In Progress")); - } - } - } - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, e.ToString()); - } - } - - - - void FusionRoomAttributeExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) - { - Debug.Console(2, this, String.Format("RoomAttributeQuery Response: {0}", args.Sig.StringValue)); - } - void FusionRoomDataExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) - { - - try - { - string result = Regex.Replace(args.Sig.StringValue, "&(?!(amp|apos|quot|lt|gt);)", "&"); - - Debug.Console(2, this, String.Format("Args: {0}", result)); - if (args.Sig == _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQueryResponse && args.Sig.StringValue != null) - { - - XmlDocument actionResponseXML = new XmlDocument(); - actionResponseXML.LoadXml(result); - - var actionResponse = actionResponseXML["ActionResponse"]; - - if (actionResponse != null) - { - var requestID = actionResponse["RequestID"]; - - if (requestID.InnerText == "InitialPushRequest") - { - if (actionResponse["ActionID"].InnerText == "RegisterPushModel") - { - var parameters = actionResponse["Parameters"]; - - foreach (XmlElement parameter in parameters) - { - if (parameter.HasAttributes) - { - var attributes = parameter.Attributes; - - if (attributes["ID"].Value == "Registered") - { - var isRegsitered = Int32.Parse(attributes["Value"].Value.ToString()); - - if (isRegsitered == 1) - { - RegisterdForPush.Value = true; - - // JTA EXTRA Logging - Debug.ConsoleWithLog(2, this, string.Format("SchedulePush: {0}", RegisterdForPush.Value), 1); - - this.StartSchedPushTimer(); - } - - else if (isRegsitered == 0) - { - RegisterdForPush.Value = false; - // JTA EXTRA Logging - Debug.ConsoleWithLog(2, this, string.Format("SchedulePush: {0}", RegisterdForPush.Value), 1); - this.StopSchedPushTimer(); - - schedulePullTimer = new CTimer(GetRoomSchedule, null, schedulePullTimerTimeout, schedulePullTimerTimeout); - } - } - } - } - } - - - } - - if (requestID.InnerText == "ExtendMeetingRequest") - { - - if (actionResponse["ActionID"].InnerText == "MeetingChange") - { - this.GetRoomSchedule(null); - var parameters = actionResponse["Parameters"]; - - foreach (XmlElement parameter in parameters) - { - if (parameter.HasAttributes) - { - var attributes = parameter.Attributes; - - if (attributes["ID"].Value == "MeetingID") - { - if (attributes["Value"].Value != null) - { - string value = attributes["Value"].Value; - } - } - else if (attributes["ID"].Value == "InstanceID") - { - if (attributes["Value"].Value != null) - { - string value = attributes["Value"].Value; - } - } - else if (attributes["ID"].Value == "Status") - { - if (attributes["Value"].Value != null) - { - string value = attributes["Value"].Value; - } - } - } - - } - } - } - } - } - if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) - { - GetRoomSchedule(); - } - else if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.RemoveMeeting) - { - GetRoomSchedule(); - } - } - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, e.ToString()); - } - - //PrintTodaysSchedule(); - - } - - - void FusionScheduleExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) - { - try - { - Debug.Console(2, this, string.Format("FusionScheduleExtenderSigChange args {0}", args.Sig.StringValue)); - if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleResponse) - { - XmlDocument scheduleXML = new XmlDocument(); - - scheduleXML = scheduleXML.CustomEscapeDocument(args.Sig.StringValue.ToString()); - - if (scheduleXML != null) - { - - Debug.Console(2, this, string.Format("Escaped XML {0}", scheduleXML.ToString())); - - var response = scheduleXML["ScheduleResponse"]; - var responseEvent = scheduleXML.FirstChild.SelectSingleNode("Event"); - - if (response != null) - { - this.ResetSchedPushTimer(); - - - if (response["RequestID"].InnerText == "RVRequest") - { - var action = response["Action"]; - - if (action.OuterXml.IndexOf("RequestSchedule") > -1) - { - GetRoomSchedule(); - } - } - #region ScheduleRequest - else if (response["RequestID"].InnerText == "ScheduleRequest") - { - - CurrentSchedule = new RoomSchedule(); - - CurrentMeeting = null; - NextMeeting = null; - ThirdMeeting = null; - FourthMeeting = null; - FifthMeeting = null; - SixthMeeting = null; - - ScheduleResponse scheduleResponse = new ScheduleResponse(); - scheduleResponse.RoomName = scheduleXML.FirstChild.SelectSingleNode("RoomName").InnerText; - scheduleResponse.RequestID = scheduleXML.FirstChild.SelectSingleNode("RequestID").InnerText; - scheduleResponse.RoomID = scheduleXML.FirstChild.SelectSingleNode("RoomID").InnerText; - - var eventStack = scheduleXML.FirstChild.SelectNodes("Event"); - Debug.Console(2, this, String.Format("EventStack Count: {0}", eventStack.Count)); - - if (eventStack.Count > 0) - { - Event tempEvent = new Event(); - tempEvent = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(0).OuterXml)); - scheduleResponse.Events.Add(tempEvent); - if (tempEvent.isInProgress) - { - CurrentMeeting = new Event(); - CurrentMeeting = tempEvent; - if (eventStack.Count > 1) { NextMeeting = new Event(); NextMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(1).OuterXml)); } - if (eventStack.Count > 2) { ThirdMeeting = new Event(); ThirdMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } - if (eventStack.Count > 3) { FourthMeeting = new Event(); FourthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(3).OuterXml)); } - if (eventStack.Count > 4) { FifthMeeting = new Event(); FifthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(3).OuterXml)); } - if (eventStack.Count > 5) { SixthMeeting = new Event(); SixthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(3).OuterXml)); } - - AvailableRooms.sendFreeBusyStatusNotAvailable(); - } - else - { - NextMeeting = new Event(); NextMeeting = tempEvent; - if (eventStack.Count > 1) { ThirdMeeting = new Event(); ThirdMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(1).OuterXml)); } - if (eventStack.Count > 2) { FourthMeeting = new Event(); FourthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } - if (eventStack.Count > 3) { FifthMeeting = new Event(); FifthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } - if (eventStack.Count > 4) { SixthMeeting = new Event(); SixthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } - AvailableRooms.sendFreeBusyStatusAvailableUntil(NextMeeting.dtStart); - } - } - else - { - AvailableRooms.sendFreeBusyStatusAvailable(); - } - if (CurrentMeeting != null) { Debug.Console(2, this, String.Format("Current Meeting {0}", CurrentMeeting.Subject)); } - if (NextMeeting != null) { Debug.Console(2, this, String.Format("Next Meeting {0}", NextMeeting.Subject)); } - if (ThirdMeeting != null) { Debug.Console(2, this, String.Format("Later Meeting {0}", ThirdMeeting.Subject)); } - if (FourthMeeting != null) { Debug.Console(2, this, String.Format("Latest Meeting {0}", FourthMeeting.Subject)); } - if (FifthMeeting != null) { Debug.Console(2, this, String.Format("Fifth Meeting {0}", FifthMeeting.Subject)); } - if (SixthMeeting != null) { Debug.Console(2, this, String.Format("Sixth Meeting {0}", SixthMeeting.Subject)); } - - - /* - if (!RegisterdForPush.value) - { - schedulePullTimer.Reset(schedulePullTimerTimeout, schedulePullTimerTimeout); - } - */ - getScheduleTimeOut.Stop(); - var handler = ScheduleChanged; - if(handler != null) - { - Debug.Console(2, this, String.Format("Schedule Changed Firing Event!")); - handler(this, new DynFusionScheduleChangeEventArgs("BAM!")); - } - - - - - ScheduleBusy.Value = false; - } - #endregion - else if (response["RequestID"].InnerText == "PushNotification") - { - this.GetRoomSchedule(null); - Debug.Console(2, this, String.Format("Got a Push Notification!")); - - } - #region RoomListScheduleRequest - else if (response["RequestID"].InnerText == "AvailableRoomSchedule") - { - if (responseEvent != null) - { - RoomAvailabilityScheduleResponse = null; - - foreach (XmlElement element in scheduleXML.FirstChild.ChildNodes) - { - ScheduleResponse AvailibleSchedule = new ScheduleResponse(); - - if (element.Name == "RequestID") - { - AvailibleSchedule.RequestID = element.InnerText; - } - else if (element.Name == "RoomID") - { - AvailibleSchedule.RoomID = element.InnerText; - } - else if (element.Name == "RoomName") - { - AvailibleSchedule.RoomName = element.InnerText; - } - else if (element.Name == "Event") - { - XmlReader readerXML = new XmlReader(element.OuterXml); - - Event RoomAvailabilityScheduleEvent = new Event(); - - RoomAvailabilityScheduleEvent = CrestronXMLSerialization.DeSerializeObject(readerXML); - - AvailibleSchedule.Events.Add(RoomAvailabilityScheduleEvent); - - } - - RoomAvailabilityScheduleResponse.Add(AvailibleSchedule); - } - } - } - #endregion - } - } - } - if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) - { - GetRoomSchedule(); - } - else if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.RemoveMeeting) - { - GetRoomSchedule(); - } - } - - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, "{0}\n{1}\n{2}", e.InnerException, e.Message, e.StackTrace); - } - - } - - void StartUpdateRemainingTimeTimer() - { - UpdateRemainingTimeTimer = new CTimer(new CTimerCallbackFunction(_UpdateRemainingTime), null, Crestron.SimplSharp.Timeout.Infinite, 60000); - } - - - - void _UpdateRemainingTime(object o) - { - var handler = UpdateRemainingTime; - if (handler != null) - { - handler(this, new EventArgs()); - } - - } - - - // TODO: Eventually we should move this to an event and have the API update based on an event change. Encapsulation. JTA 2018-04-04 - void UpdateMeetingInfo() - { - try - { - Debug.Console(2, this, "UpdateMeetingInfo"); - - UpdateRemainingTimeTimer.Reset(0, 60000); - - } - catch (Exception ex) - { - Debug.ConsoleWithLog(2, this, ex.ToString()); - } - } - - void CheckMeetingExtend() - { - try - { - if (CurrentMeeting != null) - { - if (NextMeeting != null) - { - TimeSpan timeToNext = NextMeeting.dtStart.Subtract(CurrentMeeting.dtEnd); - - if (timeToNext.TotalMinutes >= 90) - { - enableMeetingExtend15.Value = true; - enableMeetingExtend30.Value = true; - enableMeetingExtend45.Value = true; - enableMeetingExtend60.Value = true; - enableMeetingExtend90.Value = true; - } - else if (timeToNext.TotalMinutes >= 60) - { - enableMeetingExtend15.Value = true; - enableMeetingExtend30.Value = true; - enableMeetingExtend45.Value = true; - enableMeetingExtend60.Value = true; - enableMeetingExtend90.Value = false; - } - else if (timeToNext.TotalMinutes >= 45) - { - enableMeetingExtend15.Value = true; - enableMeetingExtend30.Value = true; - enableMeetingExtend45.Value = true; - enableMeetingExtend60.Value = false; - enableMeetingExtend90.Value = false; - } - else if (timeToNext.TotalMinutes >= 30) - { - enableMeetingExtend15.Value = true; - enableMeetingExtend30.Value = true; - enableMeetingExtend45.Value = false; - enableMeetingExtend60.Value = false; - enableMeetingExtend90.Value = false; - } - else if (timeToNext.TotalMinutes >= 15) - { - enableMeetingExtend15.Value = true; - enableMeetingExtend30.Value = false; - enableMeetingExtend45.Value = false; - enableMeetingExtend60.Value = false; - enableMeetingExtend90.Value = false; - } - else - { - enableMeetingExtend15.Value = false; - enableMeetingExtend30.Value = false; - enableMeetingExtend45.Value = false; - enableMeetingExtend60.Value = false; - enableMeetingExtend90.Value = false; - } - } - else - { - enableMeetingExtend15.Value = true; - enableMeetingExtend30.Value = true; - enableMeetingExtend45.Value = true; - enableMeetingExtend60.Value = true; - enableMeetingExtend90.Value = true; - } - } - else - { - enableMeetingExtend15.Value = false; - enableMeetingExtend30.Value = false; - enableMeetingExtend45.Value = false; - enableMeetingExtend60.Value = false; - enableMeetingExtend90.Value = false; - } - } - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, e.ToString()); - } - - - - } - - void CheckMeetingReserve() - { - try - { - if (CurrentMeeting == null) - { - if (NextMeeting != null) - { - TimeSpan timeToNext = NextMeeting.dtStart.Subtract(DateTime.Now); - - if (timeToNext.TotalMinutes >= 90) - { - enableMeetingReserve15.Value = true; - enableMeetingReserve30.Value = true; - enableMeetingReserve45.Value = true; - enableMeetingReserve60.Value = true; - enableMeetingReserve90.Value = true; - } - else if (timeToNext.TotalMinutes >= 60) - { - enableMeetingReserve15.Value = true; - enableMeetingReserve30.Value = true; - enableMeetingReserve45.Value = true; - enableMeetingReserve60.Value = true; - enableMeetingReserve90.Value = false; - } - else if (timeToNext.TotalMinutes >= 45) - { - enableMeetingReserve15.Value = true; - enableMeetingReserve30.Value = true; - enableMeetingReserve45.Value = true; - enableMeetingReserve60.Value = false; - enableMeetingReserve90.Value = false; - } - else if (timeToNext.TotalMinutes >= 30) - { - enableMeetingReserve15.Value = true; - enableMeetingReserve30.Value = true; - enableMeetingReserve45.Value = false; - enableMeetingReserve60.Value = false; - enableMeetingReserve90.Value = false; - } - else if (timeToNext.TotalMinutes >= 15) - { - enableMeetingReserve15.Value = true; - enableMeetingReserve30.Value = false; - enableMeetingReserve45.Value = false; - enableMeetingReserve60.Value = false; - enableMeetingReserve90.Value = false; - } - else - { - enableMeetingReserve15.Value = false; - enableMeetingReserve30.Value = false; - enableMeetingReserve45.Value = false; - enableMeetingReserve60.Value = false; - enableMeetingReserve90.Value = false; - } - } - else - { - enableMeetingReserve15.Value = true; - enableMeetingReserve30.Value = true; - enableMeetingReserve45.Value = true; - enableMeetingReserve60.Value = true; - enableMeetingReserve90.Value = true; - } - } - else - { - enableMeetingReserve15.Value = false; - enableMeetingReserve30.Value = false; - enableMeetingReserve45.Value = false; - enableMeetingReserve60.Value = false; - enableMeetingReserve90.Value = false; - } - } - catch (Exception e) - { - Debug.ConsoleWithLog(2, this, e.ToString()); - } - - - } - - public override void LinkToApi(Crestron.SimplSharpPro.DeviceSupport.BasicTriList trilist, uint joinStart, string joinMapKey, PepperDash.Essentials.Core.Bridges.EiscApiAdvanced bridge) - { - try - { - - var joinMap = new SchedulingJoinMap(joinStart); - ScheduleBusy.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ScheduleBusy.JoinNumber]); - - - - trilist.SetSigTrueAction(joinMap.GetSchedule.JoinNumber, () => GetRoomSchedule()); - trilist.SetSigTrueAction(joinMap.GetRoomList.JoinNumber, () => AvailableRooms.GetRoomList()); - trilist.SetSigTrueAction(joinMap.CheckMeetings.JoinNumber, () => { CheckMeetingReserve(); CheckMeetingExtend(); }); - trilist.SetSigTrueAction(joinMap.ExtendMeeting15Minutes.JoinNumber, () => ExtendMeeting(15)); - trilist.SetSigTrueAction(joinMap.ExtendMeeting30Minutes.JoinNumber, () => ExtendMeeting(30)); - trilist.SetSigTrueAction(joinMap.ExtendMeeting45Minutes.JoinNumber, () => ExtendMeeting(45)); - trilist.SetSigTrueAction(joinMap.ExtendMeeting60Minutes.JoinNumber, () => ExtendMeeting(60)); - trilist.SetSigTrueAction(joinMap.ExtendMeeting90Minutes.JoinNumber, () => ExtendMeeting(90)); - trilist.SetSigTrueAction(joinMap.EndCurrentMeeting.JoinNumber, () => ExtendMeeting(0)); - trilist.SetSigTrueAction(joinMap.ReserveMeeting15Minutes.JoinNumber, () => CreateMeeting(15)); - trilist.SetSigTrueAction(joinMap.ReserveMeeting30Minutes.JoinNumber, () => CreateMeeting(30)); - trilist.SetSigTrueAction(joinMap.ReserveMeeting45Minutes.JoinNumber, () => CreateMeeting(45)); - trilist.SetSigTrueAction(joinMap.ReserveMeeting60Minutes.JoinNumber, () => CreateMeeting(60)); - trilist.SetSigTrueAction(joinMap.ReserveMeeting90Minutes.JoinNumber, () => CreateMeeting(90)); - - RegisterdForPush.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.PushNotificationRegistered.JoinNumber]); - enableMeetingExtend15.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting15Minutes.JoinNumber]); - enableMeetingExtend30.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting30Minutes.JoinNumber]); - enableMeetingExtend45.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting45Minutes.JoinNumber]); - enableMeetingExtend60.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting60Minutes.JoinNumber]); - enableMeetingExtend90.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting90Minutes.JoinNumber]); - enableMeetingReserve15.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting15Minutes.JoinNumber]); - enableMeetingReserve30.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting30Minutes.JoinNumber]); - enableMeetingReserve45.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting45Minutes.JoinNumber]); - enableMeetingReserve60.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting60Minutes.JoinNumber]); - enableMeetingReserve90.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting90Minutes.JoinNumber]); - - - - UpdateRemainingTime += new EventHandler((s, e) => - { - CheckMeetingExtend(); - CheckMeetingReserve(); - if (CurrentMeeting != null && !CurrentMeeting.isInProgress) { GetRoomSchedule(); } - if (NextMeeting != null && NextMeeting.isInProgress) { GetRoomSchedule(); } - Debug.Console(2, this, "UpdateRemainingTime"); - if (CurrentMeeting != null) - { - trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = CurrentMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(CurrentMeeting.TimeRemainingInMin); - } - else - { - trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = ""; - trilist.UShortInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].UShortValue = 0; - } - if (NextMeeting != null) - { - trilist.StringInput[joinMap.NextMeetingRemainingTime.JoinNumber].StringValue = NextMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.NextMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(NextMeeting.TimeRemainingInMin); - - DateTime date = DateTime.Parse(NextMeeting.StartDate.ToString()); - if (date.Date == DateTime.Today.Date) - trilist.BooleanInput[joinMap.NextMeetingIsToday.JoinNumber].BoolValue = true; - else - trilist.BooleanInput[joinMap.NextMeetingIsToday.JoinNumber].BoolValue = false; - - } - if (ThirdMeeting != null) - { - trilist.StringInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].StringValue = ThirdMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(ThirdMeeting.TimeRemainingInMin); - } - if (FourthMeeting != null) - { - trilist.StringInput[joinMap.FourthMeetingRemainingTime.JoinNumber].StringValue = FourthMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.FourthMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(FourthMeeting.TimeRemainingInMin); - } - if (FifthMeeting != null) - { - trilist.StringInput[joinMap.FifthMeetingRemainingTime.JoinNumber].StringValue = FifthMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.FifthMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(FifthMeeting.TimeRemainingInMin); - } - if (SixthMeeting != null) - { - trilist.StringInput[joinMap.SixthMeetingRemainingTime.JoinNumber].StringValue = SixthMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.SixthMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(SixthMeeting.TimeRemainingInMin); - } - }); - - ScheduleChanged += ((s, e) => - { - try - { - Debug.Console(2, this, "ScheduleChanged"); - if (CurrentMeeting != null) - { - trilist.StringInput[joinMap.CurrentMeetingOrganizer.JoinNumber].StringValue = CurrentMeeting.Organizer; - trilist.StringInput[joinMap.CurrentMeetingSubject.JoinNumber].StringValue = CurrentMeeting.Subject; - trilist.StringInput[joinMap.CurrentMeetingMeetingID.JoinNumber].StringValue = CurrentMeeting.MeetingID; - trilist.StringInput[joinMap.CurrentMeetingStartTime.JoinNumber].StringValue = CurrentMeeting.StartTime; - trilist.StringInput[joinMap.CurrentMeetingStartDate.JoinNumber].StringValue = CurrentMeeting.StartDate; - trilist.StringInput[joinMap.CurrentMeetingEndTime.JoinNumber].StringValue = CurrentMeeting.EndTime; - trilist.StringInput[joinMap.CurrentMeetingEndDate.JoinNumber].StringValue = CurrentMeeting.EndDate; - trilist.StringInput[joinMap.CurrentMeetingDuration.JoinNumber].StringValue = CurrentMeeting.DurationInMinutes; - trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = CurrentMeeting.TimeRemainingString; - trilist.UShortInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(CurrentMeeting.TimeRemainingInMin); - trilist.BooleanInput[joinMap.MeetingInProgress.JoinNumber].BoolValue = CurrentMeeting.isInProgress; - } - else - { - trilist.StringInput[joinMap.CurrentMeetingOrganizer.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingSubject.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingMeetingID.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingStartTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingStartDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingEndTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingEndDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingDuration.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = ""; - trilist.BooleanInput[joinMap.MeetingInProgress.JoinNumber].BoolValue = false; - } - - if (NextMeeting != null) - { - trilist.StringInput[joinMap.NextMeetingOrganizer.JoinNumber].StringValue = NextMeeting.Organizer; - trilist.StringInput[joinMap.NextMeetingSubject.JoinNumber].StringValue = NextMeeting.Subject; - trilist.StringInput[joinMap.NextMeetingMeetingID.JoinNumber].StringValue = NextMeeting.MeetingID; - trilist.StringInput[joinMap.NextMeetingStartTime.JoinNumber].StringValue = NextMeeting.StartTime; - trilist.StringInput[joinMap.NextMeetingStartDate.JoinNumber].StringValue = NextMeeting.StartDate; - trilist.StringInput[joinMap.NextMeetingEndTime.JoinNumber].StringValue = NextMeeting.EndTime; - trilist.StringInput[joinMap.NextMeetingEndDate.JoinNumber].StringValue = NextMeeting.EndDate; - trilist.StringInput[joinMap.NextMeetingDuration.JoinNumber].StringValue = NextMeeting.DurationInMinutes; - trilist.StringInput[joinMap.NextMeetingRemainingTime.JoinNumber].StringValue = NextMeeting.TimeRemainingString; - - - } - else - { - trilist.StringInput[joinMap.NextMeetingOrganizer.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingSubject.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingMeetingID.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingStartTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingStartDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingEndTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingEndDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingDuration.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.NextMeetingRemainingTime.JoinNumber].StringValue = ""; - trilist.BooleanInput[joinMap.NextMeetingIsToday.JoinNumber].BoolValue = false; - } - - if (ThirdMeeting != null) - { - trilist.StringInput[joinMap.ThirdMeetingOrganizer.JoinNumber].StringValue = ThirdMeeting.Organizer; - trilist.StringInput[joinMap.ThirdMeetingSubject.JoinNumber].StringValue = ThirdMeeting.Subject; - trilist.StringInput[joinMap.ThirdMeetingMeetingID.JoinNumber].StringValue = ThirdMeeting.MeetingID; - trilist.StringInput[joinMap.ThirdMeetingStartTime.JoinNumber].StringValue = ThirdMeeting.StartTime; - trilist.StringInput[joinMap.ThirdMeetingStartDate.JoinNumber].StringValue = ThirdMeeting.StartDate; - trilist.StringInput[joinMap.ThirdMeetingEndTime.JoinNumber].StringValue = ThirdMeeting.EndTime; - trilist.StringInput[joinMap.ThirdMeetingEndDate.JoinNumber].StringValue = ThirdMeeting.EndDate; - trilist.StringInput[joinMap.ThirdMeetingDuration.JoinNumber].StringValue = ThirdMeeting.DurationInMinutes; - trilist.StringInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].StringValue = ThirdMeeting.TimeRemainingString; - } - else - { - trilist.StringInput[joinMap.ThirdMeetingOrganizer.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingSubject.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingMeetingID.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingStartTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingStartDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingEndTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingEndDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingDuration.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].StringValue = ""; - } - - if (FourthMeeting != null) - { - trilist.StringInput[joinMap.FourthMeetingOrganizer.JoinNumber].StringValue = FourthMeeting.Organizer; - trilist.StringInput[joinMap.FourthMeetingSubject.JoinNumber].StringValue = FourthMeeting.Subject; - trilist.StringInput[joinMap.FourthMeetingMeetingID.JoinNumber].StringValue = FourthMeeting.MeetingID; - trilist.StringInput[joinMap.FourthMeetingStartTime.JoinNumber].StringValue = FourthMeeting.StartTime; - trilist.StringInput[joinMap.FourthMeetingStartDate.JoinNumber].StringValue = FourthMeeting.StartDate; - trilist.StringInput[joinMap.FourthMeetingEndTime.JoinNumber].StringValue = FourthMeeting.EndTime; - trilist.StringInput[joinMap.FourthMeetingEndDate.JoinNumber].StringValue = FourthMeeting.EndDate; - trilist.StringInput[joinMap.FourthMeetingDuration.JoinNumber].StringValue = FourthMeeting.DurationInMinutes; - trilist.StringInput[joinMap.FourthMeetingRemainingTime.JoinNumber].StringValue = FourthMeeting.TimeRemainingString; - } - else - { - trilist.StringInput[joinMap.FourthMeetingOrganizer.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingSubject.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingMeetingID.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingStartTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingStartDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingEndTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingEndDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingDuration.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FourthMeetingRemainingTime.JoinNumber].StringValue = ""; - } - if (FifthMeeting != null) - { - trilist.StringInput[joinMap.FifthMeetingOrganizer.JoinNumber].StringValue = FifthMeeting.Organizer; - trilist.StringInput[joinMap.FifthMeetingSubject.JoinNumber].StringValue = FifthMeeting.Subject; - trilist.StringInput[joinMap.FifthMeetingMeetingID.JoinNumber].StringValue = FifthMeeting.MeetingID; - trilist.StringInput[joinMap.FifthMeetingStartTime.JoinNumber].StringValue = FifthMeeting.StartTime; - trilist.StringInput[joinMap.FifthMeetingStartDate.JoinNumber].StringValue = FifthMeeting.StartDate; - trilist.StringInput[joinMap.FifthMeetingEndTime.JoinNumber].StringValue = FifthMeeting.EndTime; - trilist.StringInput[joinMap.FifthMeetingEndDate.JoinNumber].StringValue = FifthMeeting.EndDate; - trilist.StringInput[joinMap.FifthMeetingDuration.JoinNumber].StringValue = FifthMeeting.DurationInMinutes; - trilist.StringInput[joinMap.FifthMeetingRemainingTime.JoinNumber].StringValue = FifthMeeting.TimeRemainingString; - } - else - { - trilist.StringInput[joinMap.FifthMeetingOrganizer.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingSubject.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingMeetingID.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingStartTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingStartDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingEndTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingEndDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingDuration.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.FifthMeetingRemainingTime.JoinNumber].StringValue = ""; - } - if (SixthMeeting != null) - { - trilist.StringInput[joinMap.SixthMeetingOrganizer.JoinNumber].StringValue = SixthMeeting.Organizer; - trilist.StringInput[joinMap.SixthMeetingSubject.JoinNumber].StringValue = SixthMeeting.Subject; - trilist.StringInput[joinMap.SixthMeetingMeetingID.JoinNumber].StringValue = SixthMeeting.MeetingID; - trilist.StringInput[joinMap.SixthMeetingStartTime.JoinNumber].StringValue = SixthMeeting.StartTime; - trilist.StringInput[joinMap.SixthMeetingStartDate.JoinNumber].StringValue = SixthMeeting.StartDate; - trilist.StringInput[joinMap.SixthMeetingEndTime.JoinNumber].StringValue = SixthMeeting.EndTime; - trilist.StringInput[joinMap.SixthMeetingEndDate.JoinNumber].StringValue = SixthMeeting.EndDate; - trilist.StringInput[joinMap.SixthMeetingDuration.JoinNumber].StringValue = SixthMeeting.DurationInMinutes; - trilist.StringInput[joinMap.SixthMeetingRemainingTime.JoinNumber].StringValue = SixthMeeting.TimeRemainingString; - } - else - { - trilist.StringInput[joinMap.SixthMeetingOrganizer.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingSubject.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingMeetingID.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingStartTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingStartDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingEndTime.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingEndDate.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingDuration.JoinNumber].StringValue = ""; - trilist.StringInput[joinMap.SixthMeetingRemainingTime.JoinNumber].StringValue = ""; - } - } - catch (Exception ex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, ex.Message); - } - }); - - } - catch (Exception ex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, ex.Message); - } - } - - - } - - - - //************************************************************************************************************************************ - - public class RoomSchedule - { - public List Meetings { get; set; } - - public RoomSchedule() - { - Meetings = new List(); - } - } - - //************************************************************************************************************************************ - // Helper Classes - public class LocalTimeRequest - { - public string RequestID { get; set; } - } - - public class RequestSchedule - { - public string RequestID { get; set; } - public string RoomID { get; set; } - public DateTime Start { get; set; } - public double HourSpan { get; set; } - - public RequestSchedule(string requestID, string roomID) - { - RequestID = requestID; - RoomID = roomID; - Start = DateTime.Now; - HourSpan = 24; - } - } - - public class RequestAction - { - public string RequestID { get; set; } - public string RoomID { get; set; } - public string ActionID { get; set; } - public List Parameters { get; set; } - - public RequestAction(string roomID, string actionID, List parameters) - { - RoomID = roomID; - ActionID = actionID; - Parameters = parameters; - } - } - - public class ActionResponse - { - public string RequsetID { get; set; } - public string ActionID { get; set; } - public List Parameters { get; set; } - } - - public class Parameter - { - public string ID { get; set; } - public string Value { get; set; } - } - - public class ScheduleResponse - { - public string RequestID { get; set; } - public string RoomID { get; set; } - public string RoomName { get; set; } - public List Events { get; set; } - - public ScheduleResponse() - { - Events = new List(); - } - } - - public class Event - { - public string Recurring { get; set; } - public string MeetingID { get; set; } - public string RVMeetingID { get; set; } - public DateTime dtStart { get; set; } - public DateTime dtEnd { get; set; } - public string Organizer { get; set; } - public string Subject { get; set; } - public string IsPrivate { get; set; } - public string IsExchangePrivate { get; set; } - public Attendees Attendees { get; set; } - // public Resources Resources { get; set; } - public string IsEvent { get; set; } - public string IsRoomViewMeeting { get; set; } - public MeetingTypes MeetingTypes { get; set; } - public LiveMeeting LiveMeeting { get; set; } - public string WelcomeMsg { get; set; } - public string Body { get; set; } - public string Location { get; set; } - public string ShareDocPath { get; set; } - public string ParticipantCode { get; set; } - public string PhoneNo { get; set; } - public string InstanceID { get; set; } - - public Event() - { - - } - - public string StartTime - { - get - { - string startTimeShort; - - startTimeShort = dtStart.ToShortTimeString(); - - return startTimeShort; - - } - } - - public string StartDate - { - get - { - string startDateShort; - - startDateShort = dtStart.ToShortDateString(); - - return startDateShort; - - } - } - - public string EndTime - { - get - { - string endTimeShort; - - endTimeShort = dtEnd.ToShortTimeString(); - - return endTimeShort; - - } - } - - public string EndDate - { - get - { - string endDateShort; - - endDateShort = dtEnd.ToShortDateString(); - - return endDateShort; - - } - } - - public string DurationInMinutes - { - get - { - string duration; - - var timeSpan = dtEnd.Subtract(dtStart); - int hours = timeSpan.Hours; - double minutes = timeSpan.Minutes; - double minutesRounded = Math.Round(minutes); - if (hours > 0) - { - duration = String.Format("{0} Hours {1} Minutes", hours, minutesRounded); - } - else - { - duration = String.Format("{0} Minutes", minutesRounded); - } - - return duration; - } - } - public double TimeRemainingInMin - { - - get - { - DateTime timeMarker = new DateTime(); - if (dtStart <= DateTime.Now) { timeMarker = dtEnd; } - else { timeMarker = dtStart; } - - double totalMinutes = timeMarker.Subtract(DateTime.Now).TotalMinutes; - if (totalMinutes >= 0) - return Math.Round(totalMinutes); - else - return 0; - } - } - public string TimeRemainingString - { - get - { - var now = DateTime.Now; - string remainingTimeString; - - DateTime timeMarker = new DateTime(); - if (GetInProgress()) { timeMarker = dtEnd; } - else { timeMarker = dtStart; } - - var hourTag = ""; - var minTag = ""; - int hours = timeMarker.Subtract(DateTime.Now).Hours; - int minutes = timeMarker.Subtract(DateTime.Now).Minutes; - if (hours > 1) { hourTag = "Hours"; } - else if (hours == 1) { hourTag = "Hour"; } - if (minutes == 1) { minTag = "Minute"; } - else { minTag = "Minutes"; } - - if (hourTag.Length == 0) { remainingTimeString = string.Format("{0} {1}", minutes, minTag); } - else { remainingTimeString = string.Format("{0} {1} {2} {3}", hours, hourTag, minutes, minTag); } - - return remainingTimeString; - - } - } - - public bool isInProgress - { - get - { - return GetInProgress(); - } - } - - bool GetInProgress() - { - var now = DateTime.Now; - - if (now > dtStart && now < dtEnd) - { - return true; - } - else - { - return false; - } - } - } - - public class Attendees - { - public Required Required { get; set; } - public Optional Optional { get; set; } - } - - public class Required - { - public List Atendee { get; set; } - } - - public class Optional - { - public List Atendee { get; set; } - } - /* - public class Resources - { - public Rooms Rooms { get; set; } - } - */ - - - - - - - public class MeetingType - { - public string ID { get; set; } - public string Value { get; set; } - } - - public class MeetingTypes - { - public List MeetingType { get; set; } - } - - public class LiveMeeting - { - public string URL { get; set; } - public string ID { get; set; } - public string Key { get; set; } - public string Subject { get; set; } - } - - public class LiveMeetingURL - { - public LiveMeeting LiveMeeting { get; set; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.CrestronXml; +using Crestron.SimplSharp.CrestronXml.Serialization; +using Crestron.SimplSharp.CrestronXmlLinq; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.Fusion; +using System.Threading; +using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharp.Net; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace DynFusion +{ + public class DynFusionScheduleChangeEventArgs : EventArgs + { + string data; + public DynFusionScheduleChangeEventArgs(string someString) + { + data = someString; + } + + } + public class DynFusionSchedule : EssentialsBridgeableDevice + { + public bool fusionOnline = false; + + //public event EventHandler ScheduleChanged; + public event EventHandler ScheduleChanged; + public event EventHandler UpdateRemainingTime; + + + BoolWithFeedback enableMeetingReserve15 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingReserve30 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingReserve45 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingReserve60 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingReserve90 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingExtend15 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingExtend30 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingExtend45 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingExtend60 = new BoolWithFeedback(); + BoolWithFeedback enableMeetingExtend90 = new BoolWithFeedback(); + + long schedulePullTimerTimeout = 300000; + long schedulePushTimerTimeout = 90000; + + DynFusionDevice _DynFusion; + CTimer schedulePullTimer = null; + CTimer schedulePushTimer; + CTimer UpdateRemainingTimeTimer = null; + CTimer getScheduleTimeOut = null; + + SchedulingConfig _Config; + + RoomSchedule CurrentSchedule; + public DynFusionScheduleAvailableRooms AvailableRooms; + + List RoomAvailabilityScheduleResponse = new List(); + + private BoolWithFeedback RegisterdForPush = new BoolWithFeedback(); + private BoolWithFeedback ScheduleBusy = new BoolWithFeedback(); + + + public Event CurrentMeeting; + Event NextMeeting; + Event ThirdMeeting; + Event FourthMeeting; + Event FifthMeeting; + Event SixthMeeting; + + + public DynFusionSchedule(string key, string name, SchedulingConfig config) + : base(key, name) + { + try + { + _Config = config; + } + catch (Exception e) + { + Debug.Console(2, this, String.Format("Get Schedule Error: {0}", e.Message)); + Debug.ConsoleWithLog(2, this, e.ToString()); + } + } + + + public override bool CustomActivate() + { + + if (_Config.DynFusionKey != null) + { + _DynFusion = (DynFusionDevice)DeviceManager.GetDeviceForKey(_Config.DynFusionKey); + + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "DynFusionDeviceKey is not present in config file"); + return false; + } + if (_DynFusion == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Error getting DynFusionDevice for key {0}", _Config.DynFusionKey); + return false; + } + _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.Use(); + _DynFusion.FusionSymbol.OnlineStatusChange += new OnlineStatusChangeEventHandler(FusionSymbolStatusChange); + _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(FusionScheduleExtenderSigChange); + _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(FusionRoomDataExtenderSigChange); + AvailableRooms = new DynFusionScheduleAvailableRooms(_DynFusion); + return true; + } + + public void StartSchedPushTimer() + { + //Debug.ConsoleWithLog(2, this, "StartSchedPushTimer", 1); + if (schedulePushTimer == null) + { + Debug.ConsoleWithLog(2, this, "StartSchedPushTimer START", 1); + schedulePushTimer = new CTimer(new CTimerCallbackFunction(GetRoomSchedule), null, schedulePushTimerTimeout, schedulePushTimerTimeout); + } + } + + public void ResetSchedPushTimer() + { + Debug.Console(2, this, "ResetSchedPushTimer", 1); + if (schedulePushTimer != null && !schedulePushTimer.Disposed) + { + Debug.ConsoleWithLog(2, this, "ResetSchedPushTimer RESET", 1); + schedulePushTimer.Reset(schedulePushTimerTimeout, schedulePushTimerTimeout); + } + } + public void StopSchedPushTimer() + { + //Debug.ConsoleWithLog(2, this, "StopSchedPushTimer", 1); + if (schedulePushTimer != null && !schedulePushTimer.Disposed) + { + Debug.ConsoleWithLog(2, this, "StopSchedPushTimer STOP", 1); + schedulePullTimer.Stop(); + schedulePullTimer.Dispose(); + } + } + + + + void AvailableRooms_OnAvailableRoomsUpdate() + { + throw new NotImplementedException(); + } + + void FusionSymbolStatusChange(object o, OnlineOfflineEventArgs e) + { + Debug.Console(2, this, "FusionSymbolStatusChange {0}", e.DeviceOnLine); + fusionOnline = e.DeviceOnLine; + if (fusionOnline) + { + // GetRoomSchedule(); + GetPushSchedule(); + StartUpdateRemainingTimeTimer(); + } + else + { + //UpdateRemainingTimeTimer.Stop(); + } + } + + void GetPushSchedule() + { + try + { + if (fusionOnline) + { + string requestID = "InitialPushRequest"; + string fusionActionRequest = ""; + + fusionActionRequest = String.Format("\n{0}\n" + + "RegisterPushModel\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n", requestID); + + _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = fusionActionRequest; + } + } + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, String.Format("Get Push Schedule Error: {0}", e.Message), 3); + } + } + + void GetRoomSchedule(object unused) + { + GetRoomSchedule(); + } + + public void GetRoomSchedule() + { + if (ScheduleBusy.Value == false) + { + ScheduleBusy.Value = true; + getScheduleTimeOut = new CTimer(getRoomScheduleTimeOut, 6000); + Debug.Console(2, this, String.Format("Get RoomSchedule")); + string roomID = _DynFusion.RoomInformation.ID; + string requestType = "ScheduleRequest"; + GetFullRoomSchedule(roomID, requestType.ToString()); + + } + } + + public void getRoomScheduleTimeOut(object unused) + { + ScheduleBusy.Value = false; + Debug.ConsoleWithLog(2, this, "Error getRoomScheduleTimeOut"); + } + + + void GetFullRoomSchedule(string roomID, string requestType) + { + try + { + if (fusionOnline) + { + string fusionScheduleRequest = ""; + string RFCTime; + + RFCTime = String.Format("{0:s}", DateTime.Now); + + fusionScheduleRequest = String.Format("{0}{1}{2}24", requestType, roomID, RFCTime.ToString()); + + _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = fusionScheduleRequest; + + //if (isRegisteredForSchedulePushNotifications) + //schedulePushTimer.Stop(); + } + } + catch (Exception e) + { + Debug.Console(2, this, String.Format("Get Full Schedule Error: {0}", e.Message)); + Debug.ConsoleWithLog(2, this, e.ToString()); + } + } + + void ExtendMeeting(int extendTimeIn) + { + try + { + if (fusionOnline) + { + if (CurrentMeeting != null) + { + if (CurrentMeeting.isInProgress) + { + string fusionExtendMeetingRequest = ""; + string extendTime; + string meetingID = CurrentMeeting.MeetingID; + + if (extendTimeIn != 0) + { + TimeSpan timeToExtend = CurrentMeeting.dtEnd.Subtract(DateTime.Now); + ushort totalMeetingExtend = (ushort)(timeToExtend.TotalMinutes + extendTimeIn); + extendTime = totalMeetingExtend.ToString(); + } + else + extendTime = extendTimeIn.ToString(); + + + fusionExtendMeetingRequest = String.Format("ExtendMeetingRequestMeetingChange" + + "", meetingID, extendTime.ToString()); + + Debug.Console(2, this, String.Format("ExtendRequest: {0}", fusionExtendMeetingRequest)); + _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = fusionExtendMeetingRequest; + } + else + { + Debug.Console(2, this, String.Format("No Meeting in Progress")); + } + } + } + } + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, e.ToString()); + } + } + + void CreateMeeting(ushort meetingTimeIn) + { + try + { + if (fusionOnline) + { + if (CurrentMeeting == null) + { + string fusionCreateMeetingRequest = ""; + string meetingTime = meetingTimeIn.ToString(); + string startTime; + string endTime; + + TimeSpan meetingLength = new TimeSpan(0, (int)meetingTimeIn, 0); + + startTime = String.Format("{0:s}", DateTime.Now); + endTime = String.Format("{0:s}", DateTime.Now.Add(meetingLength)); + + Debug.Console(2, this, String.Format("Start Time: {0}, End Time: {1}", startTime, endTime)); + + fusionCreateMeetingRequest = String.Format("ExtendMeetingRequest" + + "{0}{1}Ad-Hoc Meeting Created{2}" + + "Meeting Created>", startTime, endTime, _DynFusion.RoomInformation.Name.ToString()); + + Debug.Console(2, this, String.Format("Create Meeting Request: {0}", fusionCreateMeetingRequest)); + _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = fusionCreateMeetingRequest; + } + else + { + Debug.Console(2, this, String.Format("Meeting In Progress")); + } + } + } + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, e.ToString()); + } + } + + + + void FusionRoomAttributeExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) + { + Debug.Console(2, this, String.Format("RoomAttributeQuery Response: {0}", args.Sig.StringValue)); + } + void FusionRoomDataExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) + { + + try + { + string result = Regex.Replace(args.Sig.StringValue, "&(?!(amp|apos|quot|lt|gt);)", "&"); + + Debug.Console(2, this, String.Format("Args: {0}", result)); + if (args.Sig == _DynFusion.FusionSymbol.ExtenderFusionRoomDataReservedSigs.ActionQueryResponse && args.Sig.StringValue != null) + { + + XmlDocument actionResponseXML = new XmlDocument(); + actionResponseXML.LoadXml(result); + + var actionResponse = actionResponseXML["ActionResponse"]; + + if (actionResponse != null) + { + var requestID = actionResponse["RequestID"]; + + if (requestID.InnerText == "InitialPushRequest") + { + if (actionResponse["ActionID"].InnerText == "RegisterPushModel") + { + var parameters = actionResponse["Parameters"]; + + foreach (XmlElement parameter in parameters) + { + if (parameter.HasAttributes) + { + var attributes = parameter.Attributes; + + if (attributes["ID"].Value == "Registered") + { + var isRegsitered = Int32.Parse(attributes["Value"].Value.ToString()); + + if (isRegsitered == 1) + { + RegisterdForPush.Value = true; + + // JTA EXTRA Logging + Debug.ConsoleWithLog(2, this, string.Format("SchedulePush: {0}", RegisterdForPush.Value), 1); + + this.StartSchedPushTimer(); + } + + else if (isRegsitered == 0) + { + RegisterdForPush.Value = false; + // JTA EXTRA Logging + Debug.ConsoleWithLog(2, this, string.Format("SchedulePush: {0}", RegisterdForPush.Value), 1); + this.StopSchedPushTimer(); + + schedulePullTimer = new CTimer(GetRoomSchedule, null, schedulePullTimerTimeout, schedulePullTimerTimeout); + } + } + } + } + } + + + } + + if (requestID.InnerText == "ExtendMeetingRequest") + { + + if (actionResponse["ActionID"].InnerText == "MeetingChange") + { + this.GetRoomSchedule(null); + var parameters = actionResponse["Parameters"]; + + foreach (XmlElement parameter in parameters) + { + if (parameter.HasAttributes) + { + var attributes = parameter.Attributes; + + if (attributes["ID"].Value == "MeetingID") + { + if (attributes["Value"].Value != null) + { + string value = attributes["Value"].Value; + } + } + else if (attributes["ID"].Value == "InstanceID") + { + if (attributes["Value"].Value != null) + { + string value = attributes["Value"].Value; + } + } + else if (attributes["ID"].Value == "Status") + { + if (attributes["Value"].Value != null) + { + string value = attributes["Value"].Value; + } + } + } + + } + } + } + } + } + if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) + { + GetRoomSchedule(); + } + else if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.RemoveMeeting) + { + GetRoomSchedule(); + } + } + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, e.ToString()); + } + + //PrintTodaysSchedule(); + + } + + + void FusionScheduleExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) + { + try + { + Debug.Console(2, this, string.Format("FusionScheduleExtenderSigChange args {0}", args.Sig.StringValue)); + if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleResponse) + { + XmlDocument scheduleXML = new XmlDocument(); + + scheduleXML = scheduleXML.CustomEscapeDocument(args.Sig.StringValue.ToString()); + + if (scheduleXML != null) + { + + Debug.Console(2, this, string.Format("Escaped XML {0}", scheduleXML.ToString())); + + var response = scheduleXML["ScheduleResponse"]; + var responseEvent = scheduleXML.FirstChild.SelectSingleNode("Event"); + + if (response != null) + { + this.ResetSchedPushTimer(); + + + if (response["RequestID"].InnerText == "RVRequest") + { + var action = response["Action"]; + + if (action.OuterXml.IndexOf("RequestSchedule") > -1) + { + GetRoomSchedule(); + } + } + #region ScheduleRequest + else if (response["RequestID"].InnerText == "ScheduleRequest") + { + + CurrentSchedule = new RoomSchedule(); + + CurrentMeeting = null; + NextMeeting = null; + ThirdMeeting = null; + FourthMeeting = null; + FifthMeeting = null; + SixthMeeting = null; + + ScheduleResponse scheduleResponse = new ScheduleResponse(); + scheduleResponse.RoomName = scheduleXML.FirstChild.SelectSingleNode("RoomName").InnerText; + scheduleResponse.RequestID = scheduleXML.FirstChild.SelectSingleNode("RequestID").InnerText; + scheduleResponse.RoomID = scheduleXML.FirstChild.SelectSingleNode("RoomID").InnerText; + + var eventStack = scheduleXML.FirstChild.SelectNodes("Event"); + Debug.Console(2, this, String.Format("EventStack Count: {0}", eventStack.Count)); + + if (eventStack.Count > 0) + { + Event tempEvent = new Event(); + tempEvent = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(0).OuterXml)); + scheduleResponse.Events.Add(tempEvent); + if (tempEvent.isInProgress) + { + CurrentMeeting = new Event(); + CurrentMeeting = tempEvent; + if (eventStack.Count > 1) { NextMeeting = new Event(); NextMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(1).OuterXml)); } + if (eventStack.Count > 2) { ThirdMeeting = new Event(); ThirdMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } + if (eventStack.Count > 3) { FourthMeeting = new Event(); FourthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(3).OuterXml)); } + if (eventStack.Count > 4) { FifthMeeting = new Event(); FifthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(3).OuterXml)); } + if (eventStack.Count > 5) { SixthMeeting = new Event(); SixthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(3).OuterXml)); } + + AvailableRooms.sendFreeBusyStatusNotAvailable(); + } + else + { + NextMeeting = new Event(); NextMeeting = tempEvent; + if (eventStack.Count > 1) { ThirdMeeting = new Event(); ThirdMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(1).OuterXml)); } + if (eventStack.Count > 2) { FourthMeeting = new Event(); FourthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } + if (eventStack.Count > 3) { FifthMeeting = new Event(); FifthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } + if (eventStack.Count > 4) { SixthMeeting = new Event(); SixthMeeting = CrestronXMLSerialization.DeSerializeObject(new XmlReader(eventStack.Item(2).OuterXml)); } + AvailableRooms.sendFreeBusyStatusAvailableUntil(NextMeeting.dtStart); + } + } + else + { + AvailableRooms.sendFreeBusyStatusAvailable(); + } + if (CurrentMeeting != null) { Debug.Console(2, this, String.Format("Current Meeting {0}", CurrentMeeting.Subject)); } + if (NextMeeting != null) { Debug.Console(2, this, String.Format("Next Meeting {0}", NextMeeting.Subject)); } + if (ThirdMeeting != null) { Debug.Console(2, this, String.Format("Later Meeting {0}", ThirdMeeting.Subject)); } + if (FourthMeeting != null) { Debug.Console(2, this, String.Format("Latest Meeting {0}", FourthMeeting.Subject)); } + if (FifthMeeting != null) { Debug.Console(2, this, String.Format("Fifth Meeting {0}", FifthMeeting.Subject)); } + if (SixthMeeting != null) { Debug.Console(2, this, String.Format("Sixth Meeting {0}", SixthMeeting.Subject)); } + + + /* + if (!RegisterdForPush.value) + { + schedulePullTimer.Reset(schedulePullTimerTimeout, schedulePullTimerTimeout); + } + */ + getScheduleTimeOut.Stop(); + var handler = ScheduleChanged; + if(handler != null) + { + Debug.Console(2, this, String.Format("Schedule Changed Firing Event!")); + handler(this, new DynFusionScheduleChangeEventArgs("BAM!")); + } + + + + + ScheduleBusy.Value = false; + } + #endregion + else if (response["RequestID"].InnerText == "PushNotification") + { + this.GetRoomSchedule(null); + Debug.Console(2, this, String.Format("Got a Push Notification!")); + + } + #region RoomListScheduleRequest + else if (response["RequestID"].InnerText == "AvailableRoomSchedule") + { + if (responseEvent != null) + { + RoomAvailabilityScheduleResponse = null; + + foreach (XmlElement element in scheduleXML.FirstChild.ChildNodes) + { + ScheduleResponse AvailibleSchedule = new ScheduleResponse(); + + if (element.Name == "RequestID") + { + AvailibleSchedule.RequestID = element.InnerText; + } + else if (element.Name == "RoomID") + { + AvailibleSchedule.RoomID = element.InnerText; + } + else if (element.Name == "RoomName") + { + AvailibleSchedule.RoomName = element.InnerText; + } + else if (element.Name == "Event") + { + XmlReader readerXML = new XmlReader(element.OuterXml); + + Event RoomAvailabilityScheduleEvent = new Event(); + + RoomAvailabilityScheduleEvent = CrestronXMLSerialization.DeSerializeObject(readerXML); + + AvailibleSchedule.Events.Add(RoomAvailabilityScheduleEvent); + + } + + RoomAvailabilityScheduleResponse.Add(AvailibleSchedule); + } + } + } + #endregion + } + } + } + if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) + { + GetRoomSchedule(); + } + else if (args.Sig == _DynFusion.FusionSymbol.ExtenderRoomViewSchedulingDataReservedSigs.RemoveMeeting) + { + GetRoomSchedule(); + } + } + + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, "{0}\n{1}\n{2}", e.InnerException, e.Message, e.StackTrace); + } + + } + + void StartUpdateRemainingTimeTimer() + { + UpdateRemainingTimeTimer = new CTimer(new CTimerCallbackFunction(_UpdateRemainingTime), null, Crestron.SimplSharp.Timeout.Infinite, 60000); + } + + + + void _UpdateRemainingTime(object o) + { + var handler = UpdateRemainingTime; + if (handler != null) + { + handler(this, new EventArgs()); + } + + } + + + // TODO: Eventually we should move this to an event and have the API update based on an event change. Encapsulation. JTA 2018-04-04 + void UpdateMeetingInfo() + { + try + { + Debug.Console(2, this, "UpdateMeetingInfo"); + + UpdateRemainingTimeTimer.Reset(0, 60000); + + } + catch (Exception ex) + { + Debug.ConsoleWithLog(2, this, ex.ToString()); + } + } + + void CheckMeetingExtend() + { + try + { + if (CurrentMeeting != null) + { + if (NextMeeting != null) + { + TimeSpan timeToNext = NextMeeting.dtStart.Subtract(CurrentMeeting.dtEnd); + + if (timeToNext.TotalMinutes >= 90) + { + enableMeetingExtend15.Value = true; + enableMeetingExtend30.Value = true; + enableMeetingExtend45.Value = true; + enableMeetingExtend60.Value = true; + enableMeetingExtend90.Value = true; + } + else if (timeToNext.TotalMinutes >= 60) + { + enableMeetingExtend15.Value = true; + enableMeetingExtend30.Value = true; + enableMeetingExtend45.Value = true; + enableMeetingExtend60.Value = true; + enableMeetingExtend90.Value = false; + } + else if (timeToNext.TotalMinutes >= 45) + { + enableMeetingExtend15.Value = true; + enableMeetingExtend30.Value = true; + enableMeetingExtend45.Value = true; + enableMeetingExtend60.Value = false; + enableMeetingExtend90.Value = false; + } + else if (timeToNext.TotalMinutes >= 30) + { + enableMeetingExtend15.Value = true; + enableMeetingExtend30.Value = true; + enableMeetingExtend45.Value = false; + enableMeetingExtend60.Value = false; + enableMeetingExtend90.Value = false; + } + else if (timeToNext.TotalMinutes >= 15) + { + enableMeetingExtend15.Value = true; + enableMeetingExtend30.Value = false; + enableMeetingExtend45.Value = false; + enableMeetingExtend60.Value = false; + enableMeetingExtend90.Value = false; + } + else + { + enableMeetingExtend15.Value = false; + enableMeetingExtend30.Value = false; + enableMeetingExtend45.Value = false; + enableMeetingExtend60.Value = false; + enableMeetingExtend90.Value = false; + } + } + else + { + enableMeetingExtend15.Value = true; + enableMeetingExtend30.Value = true; + enableMeetingExtend45.Value = true; + enableMeetingExtend60.Value = true; + enableMeetingExtend90.Value = true; + } + } + else + { + enableMeetingExtend15.Value = false; + enableMeetingExtend30.Value = false; + enableMeetingExtend45.Value = false; + enableMeetingExtend60.Value = false; + enableMeetingExtend90.Value = false; + } + } + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, e.ToString()); + } + + + + } + + void CheckMeetingReserve() + { + try + { + if (CurrentMeeting == null) + { + if (NextMeeting != null) + { + TimeSpan timeToNext = NextMeeting.dtStart.Subtract(DateTime.Now); + + if (timeToNext.TotalMinutes >= 90) + { + enableMeetingReserve15.Value = true; + enableMeetingReserve30.Value = true; + enableMeetingReserve45.Value = true; + enableMeetingReserve60.Value = true; + enableMeetingReserve90.Value = true; + } + else if (timeToNext.TotalMinutes >= 60) + { + enableMeetingReserve15.Value = true; + enableMeetingReserve30.Value = true; + enableMeetingReserve45.Value = true; + enableMeetingReserve60.Value = true; + enableMeetingReserve90.Value = false; + } + else if (timeToNext.TotalMinutes >= 45) + { + enableMeetingReserve15.Value = true; + enableMeetingReserve30.Value = true; + enableMeetingReserve45.Value = true; + enableMeetingReserve60.Value = false; + enableMeetingReserve90.Value = false; + } + else if (timeToNext.TotalMinutes >= 30) + { + enableMeetingReserve15.Value = true; + enableMeetingReserve30.Value = true; + enableMeetingReserve45.Value = false; + enableMeetingReserve60.Value = false; + enableMeetingReserve90.Value = false; + } + else if (timeToNext.TotalMinutes >= 15) + { + enableMeetingReserve15.Value = true; + enableMeetingReserve30.Value = false; + enableMeetingReserve45.Value = false; + enableMeetingReserve60.Value = false; + enableMeetingReserve90.Value = false; + } + else + { + enableMeetingReserve15.Value = false; + enableMeetingReserve30.Value = false; + enableMeetingReserve45.Value = false; + enableMeetingReserve60.Value = false; + enableMeetingReserve90.Value = false; + } + } + else + { + enableMeetingReserve15.Value = true; + enableMeetingReserve30.Value = true; + enableMeetingReserve45.Value = true; + enableMeetingReserve60.Value = true; + enableMeetingReserve90.Value = true; + } + } + else + { + enableMeetingReserve15.Value = false; + enableMeetingReserve30.Value = false; + enableMeetingReserve45.Value = false; + enableMeetingReserve60.Value = false; + enableMeetingReserve90.Value = false; + } + } + catch (Exception e) + { + Debug.ConsoleWithLog(2, this, e.ToString()); + } + + + } + + public override void LinkToApi(Crestron.SimplSharpPro.DeviceSupport.BasicTriList trilist, uint joinStart, string joinMapKey, PepperDash.Essentials.Core.Bridges.EiscApiAdvanced bridge) + { + try + { + + var joinMap = new SchedulingJoinMap(joinStart); + ScheduleBusy.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ScheduleBusy.JoinNumber]); + + + + trilist.SetSigTrueAction(joinMap.GetSchedule.JoinNumber, () => GetRoomSchedule()); + trilist.SetSigTrueAction(joinMap.GetRoomList.JoinNumber, () => AvailableRooms.GetRoomList()); + trilist.SetSigTrueAction(joinMap.CheckMeetings.JoinNumber, () => { CheckMeetingReserve(); CheckMeetingExtend(); }); + trilist.SetSigTrueAction(joinMap.ExtendMeeting15Minutes.JoinNumber, () => ExtendMeeting(15)); + trilist.SetSigTrueAction(joinMap.ExtendMeeting30Minutes.JoinNumber, () => ExtendMeeting(30)); + trilist.SetSigTrueAction(joinMap.ExtendMeeting45Minutes.JoinNumber, () => ExtendMeeting(45)); + trilist.SetSigTrueAction(joinMap.ExtendMeeting60Minutes.JoinNumber, () => ExtendMeeting(60)); + trilist.SetSigTrueAction(joinMap.ExtendMeeting90Minutes.JoinNumber, () => ExtendMeeting(90)); + trilist.SetSigTrueAction(joinMap.EndCurrentMeeting.JoinNumber, () => ExtendMeeting(0)); + trilist.SetSigTrueAction(joinMap.ReserveMeeting15Minutes.JoinNumber, () => CreateMeeting(15)); + trilist.SetSigTrueAction(joinMap.ReserveMeeting30Minutes.JoinNumber, () => CreateMeeting(30)); + trilist.SetSigTrueAction(joinMap.ReserveMeeting45Minutes.JoinNumber, () => CreateMeeting(45)); + trilist.SetSigTrueAction(joinMap.ReserveMeeting60Minutes.JoinNumber, () => CreateMeeting(60)); + trilist.SetSigTrueAction(joinMap.ReserveMeeting90Minutes.JoinNumber, () => CreateMeeting(90)); + + RegisterdForPush.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.PushNotificationRegistered.JoinNumber]); + enableMeetingExtend15.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting15Minutes.JoinNumber]); + enableMeetingExtend30.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting30Minutes.JoinNumber]); + enableMeetingExtend45.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting45Minutes.JoinNumber]); + enableMeetingExtend60.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting60Minutes.JoinNumber]); + enableMeetingExtend90.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ExtendMeeting90Minutes.JoinNumber]); + enableMeetingReserve15.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting15Minutes.JoinNumber]); + enableMeetingReserve30.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting30Minutes.JoinNumber]); + enableMeetingReserve45.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting45Minutes.JoinNumber]); + enableMeetingReserve60.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting60Minutes.JoinNumber]); + enableMeetingReserve90.Feedback.LinkInputSig(trilist.BooleanInput[joinMap.ReserveMeeting90Minutes.JoinNumber]); + + + + UpdateRemainingTime += new EventHandler((s, e) => + { + CheckMeetingExtend(); + CheckMeetingReserve(); + if (CurrentMeeting != null && !CurrentMeeting.isInProgress) { GetRoomSchedule(); } + if (NextMeeting != null && NextMeeting.isInProgress) { GetRoomSchedule(); } + Debug.Console(2, this, "UpdateRemainingTime"); + if (CurrentMeeting != null) + { + trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = CurrentMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(CurrentMeeting.TimeRemainingInMin); + } + else + { + trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = ""; + trilist.UShortInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].UShortValue = 0; + } + if (NextMeeting != null) + { + trilist.StringInput[joinMap.NextMeetingRemainingTime.JoinNumber].StringValue = NextMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.NextMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(NextMeeting.TimeRemainingInMin); + + DateTime date = DateTime.Parse(NextMeeting.StartDate.ToString()); + if (date.Date == DateTime.Today.Date) + trilist.BooleanInput[joinMap.NextMeetingIsToday.JoinNumber].BoolValue = true; + else + trilist.BooleanInput[joinMap.NextMeetingIsToday.JoinNumber].BoolValue = false; + + } + if (ThirdMeeting != null) + { + trilist.StringInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].StringValue = ThirdMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(ThirdMeeting.TimeRemainingInMin); + } + if (FourthMeeting != null) + { + trilist.StringInput[joinMap.FourthMeetingRemainingTime.JoinNumber].StringValue = FourthMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.FourthMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(FourthMeeting.TimeRemainingInMin); + } + if (FifthMeeting != null) + { + trilist.StringInput[joinMap.FifthMeetingRemainingTime.JoinNumber].StringValue = FifthMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.FifthMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(FifthMeeting.TimeRemainingInMin); + } + if (SixthMeeting != null) + { + trilist.StringInput[joinMap.SixthMeetingRemainingTime.JoinNumber].StringValue = SixthMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.SixthMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(SixthMeeting.TimeRemainingInMin); + } + }); + + ScheduleChanged += ((s, e) => + { + try + { + Debug.Console(2, this, "ScheduleChanged"); + if (CurrentMeeting != null) + { + trilist.StringInput[joinMap.CurrentMeetingOrganizer.JoinNumber].StringValue = CurrentMeeting.Organizer; + trilist.StringInput[joinMap.CurrentMeetingSubject.JoinNumber].StringValue = CurrentMeeting.Subject; + trilist.StringInput[joinMap.CurrentMeetingMeetingID.JoinNumber].StringValue = CurrentMeeting.MeetingID; + trilist.StringInput[joinMap.CurrentMeetingStartTime.JoinNumber].StringValue = CurrentMeeting.StartTime; + trilist.StringInput[joinMap.CurrentMeetingStartDate.JoinNumber].StringValue = CurrentMeeting.StartDate; + trilist.StringInput[joinMap.CurrentMeetingEndTime.JoinNumber].StringValue = CurrentMeeting.EndTime; + trilist.StringInput[joinMap.CurrentMeetingEndDate.JoinNumber].StringValue = CurrentMeeting.EndDate; + trilist.StringInput[joinMap.CurrentMeetingDuration.JoinNumber].StringValue = CurrentMeeting.DurationInMinutes; + trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = CurrentMeeting.TimeRemainingString; + trilist.UShortInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].UShortValue = Convert.ToUInt16(CurrentMeeting.TimeRemainingInMin); + trilist.BooleanInput[joinMap.MeetingInProgress.JoinNumber].BoolValue = CurrentMeeting.isInProgress; + } + else + { + trilist.StringInput[joinMap.CurrentMeetingOrganizer.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingSubject.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingMeetingID.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingStartTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingStartDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingEndTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingEndDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingDuration.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.CurrentMeetingRemainingTime.JoinNumber].StringValue = ""; + trilist.BooleanInput[joinMap.MeetingInProgress.JoinNumber].BoolValue = false; + } + + if (NextMeeting != null) + { + trilist.StringInput[joinMap.NextMeetingOrganizer.JoinNumber].StringValue = NextMeeting.Organizer; + trilist.StringInput[joinMap.NextMeetingSubject.JoinNumber].StringValue = NextMeeting.Subject; + trilist.StringInput[joinMap.NextMeetingMeetingID.JoinNumber].StringValue = NextMeeting.MeetingID; + trilist.StringInput[joinMap.NextMeetingStartTime.JoinNumber].StringValue = NextMeeting.StartTime; + trilist.StringInput[joinMap.NextMeetingStartDate.JoinNumber].StringValue = NextMeeting.StartDate; + trilist.StringInput[joinMap.NextMeetingEndTime.JoinNumber].StringValue = NextMeeting.EndTime; + trilist.StringInput[joinMap.NextMeetingEndDate.JoinNumber].StringValue = NextMeeting.EndDate; + trilist.StringInput[joinMap.NextMeetingDuration.JoinNumber].StringValue = NextMeeting.DurationInMinutes; + trilist.StringInput[joinMap.NextMeetingRemainingTime.JoinNumber].StringValue = NextMeeting.TimeRemainingString; + + + } + else + { + trilist.StringInput[joinMap.NextMeetingOrganizer.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingSubject.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingMeetingID.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingStartTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingStartDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingEndTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingEndDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingDuration.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.NextMeetingRemainingTime.JoinNumber].StringValue = ""; + trilist.BooleanInput[joinMap.NextMeetingIsToday.JoinNumber].BoolValue = false; + } + + if (ThirdMeeting != null) + { + trilist.StringInput[joinMap.ThirdMeetingOrganizer.JoinNumber].StringValue = ThirdMeeting.Organizer; + trilist.StringInput[joinMap.ThirdMeetingSubject.JoinNumber].StringValue = ThirdMeeting.Subject; + trilist.StringInput[joinMap.ThirdMeetingMeetingID.JoinNumber].StringValue = ThirdMeeting.MeetingID; + trilist.StringInput[joinMap.ThirdMeetingStartTime.JoinNumber].StringValue = ThirdMeeting.StartTime; + trilist.StringInput[joinMap.ThirdMeetingStartDate.JoinNumber].StringValue = ThirdMeeting.StartDate; + trilist.StringInput[joinMap.ThirdMeetingEndTime.JoinNumber].StringValue = ThirdMeeting.EndTime; + trilist.StringInput[joinMap.ThirdMeetingEndDate.JoinNumber].StringValue = ThirdMeeting.EndDate; + trilist.StringInput[joinMap.ThirdMeetingDuration.JoinNumber].StringValue = ThirdMeeting.DurationInMinutes; + trilist.StringInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].StringValue = ThirdMeeting.TimeRemainingString; + } + else + { + trilist.StringInput[joinMap.ThirdMeetingOrganizer.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingSubject.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingMeetingID.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingStartTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingStartDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingEndTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingEndDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingDuration.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.ThirdMeetingRemainingTime.JoinNumber].StringValue = ""; + } + + if (FourthMeeting != null) + { + trilist.StringInput[joinMap.FourthMeetingOrganizer.JoinNumber].StringValue = FourthMeeting.Organizer; + trilist.StringInput[joinMap.FourthMeetingSubject.JoinNumber].StringValue = FourthMeeting.Subject; + trilist.StringInput[joinMap.FourthMeetingMeetingID.JoinNumber].StringValue = FourthMeeting.MeetingID; + trilist.StringInput[joinMap.FourthMeetingStartTime.JoinNumber].StringValue = FourthMeeting.StartTime; + trilist.StringInput[joinMap.FourthMeetingStartDate.JoinNumber].StringValue = FourthMeeting.StartDate; + trilist.StringInput[joinMap.FourthMeetingEndTime.JoinNumber].StringValue = FourthMeeting.EndTime; + trilist.StringInput[joinMap.FourthMeetingEndDate.JoinNumber].StringValue = FourthMeeting.EndDate; + trilist.StringInput[joinMap.FourthMeetingDuration.JoinNumber].StringValue = FourthMeeting.DurationInMinutes; + trilist.StringInput[joinMap.FourthMeetingRemainingTime.JoinNumber].StringValue = FourthMeeting.TimeRemainingString; + } + else + { + trilist.StringInput[joinMap.FourthMeetingOrganizer.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingSubject.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingMeetingID.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingStartTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingStartDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingEndTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingEndDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingDuration.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FourthMeetingRemainingTime.JoinNumber].StringValue = ""; + } + if (FifthMeeting != null) + { + trilist.StringInput[joinMap.FifthMeetingOrganizer.JoinNumber].StringValue = FifthMeeting.Organizer; + trilist.StringInput[joinMap.FifthMeetingSubject.JoinNumber].StringValue = FifthMeeting.Subject; + trilist.StringInput[joinMap.FifthMeetingMeetingID.JoinNumber].StringValue = FifthMeeting.MeetingID; + trilist.StringInput[joinMap.FifthMeetingStartTime.JoinNumber].StringValue = FifthMeeting.StartTime; + trilist.StringInput[joinMap.FifthMeetingStartDate.JoinNumber].StringValue = FifthMeeting.StartDate; + trilist.StringInput[joinMap.FifthMeetingEndTime.JoinNumber].StringValue = FifthMeeting.EndTime; + trilist.StringInput[joinMap.FifthMeetingEndDate.JoinNumber].StringValue = FifthMeeting.EndDate; + trilist.StringInput[joinMap.FifthMeetingDuration.JoinNumber].StringValue = FifthMeeting.DurationInMinutes; + trilist.StringInput[joinMap.FifthMeetingRemainingTime.JoinNumber].StringValue = FifthMeeting.TimeRemainingString; + } + else + { + trilist.StringInput[joinMap.FifthMeetingOrganizer.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingSubject.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingMeetingID.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingStartTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingStartDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingEndTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingEndDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingDuration.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.FifthMeetingRemainingTime.JoinNumber].StringValue = ""; + } + if (SixthMeeting != null) + { + trilist.StringInput[joinMap.SixthMeetingOrganizer.JoinNumber].StringValue = SixthMeeting.Organizer; + trilist.StringInput[joinMap.SixthMeetingSubject.JoinNumber].StringValue = SixthMeeting.Subject; + trilist.StringInput[joinMap.SixthMeetingMeetingID.JoinNumber].StringValue = SixthMeeting.MeetingID; + trilist.StringInput[joinMap.SixthMeetingStartTime.JoinNumber].StringValue = SixthMeeting.StartTime; + trilist.StringInput[joinMap.SixthMeetingStartDate.JoinNumber].StringValue = SixthMeeting.StartDate; + trilist.StringInput[joinMap.SixthMeetingEndTime.JoinNumber].StringValue = SixthMeeting.EndTime; + trilist.StringInput[joinMap.SixthMeetingEndDate.JoinNumber].StringValue = SixthMeeting.EndDate; + trilist.StringInput[joinMap.SixthMeetingDuration.JoinNumber].StringValue = SixthMeeting.DurationInMinutes; + trilist.StringInput[joinMap.SixthMeetingRemainingTime.JoinNumber].StringValue = SixthMeeting.TimeRemainingString; + } + else + { + trilist.StringInput[joinMap.SixthMeetingOrganizer.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingSubject.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingMeetingID.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingStartTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingStartDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingEndTime.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingEndDate.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingDuration.JoinNumber].StringValue = ""; + trilist.StringInput[joinMap.SixthMeetingRemainingTime.JoinNumber].StringValue = ""; + } + } + catch (Exception ex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, ex.Message); + } + }); + + } + catch (Exception ex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, ex.Message); + } + } + + + } + + + + //************************************************************************************************************************************ + + public class RoomSchedule + { + public List Meetings { get; set; } + + public RoomSchedule() + { + Meetings = new List(); + } + } + + //************************************************************************************************************************************ + // Helper Classes + public class LocalTimeRequest + { + public string RequestID { get; set; } + } + + public class RequestSchedule + { + public string RequestID { get; set; } + public string RoomID { get; set; } + public DateTime Start { get; set; } + public double HourSpan { get; set; } + + public RequestSchedule(string requestID, string roomID) + { + RequestID = requestID; + RoomID = roomID; + Start = DateTime.Now; + HourSpan = 24; + } + } + + public class RequestAction + { + public string RequestID { get; set; } + public string RoomID { get; set; } + public string ActionID { get; set; } + public List Parameters { get; set; } + + public RequestAction(string roomID, string actionID, List parameters) + { + RoomID = roomID; + ActionID = actionID; + Parameters = parameters; + } + } + + public class ActionResponse + { + public string RequsetID { get; set; } + public string ActionID { get; set; } + public List Parameters { get; set; } + } + + public class Parameter + { + public string ID { get; set; } + public string Value { get; set; } + } + + public class ScheduleResponse + { + public string RequestID { get; set; } + public string RoomID { get; set; } + public string RoomName { get; set; } + public List Events { get; set; } + + public ScheduleResponse() + { + Events = new List(); + } + } + + public class Event + { + public string Recurring { get; set; } + public string MeetingID { get; set; } + public string RVMeetingID { get; set; } + public DateTime dtStart { get; set; } + public DateTime dtEnd { get; set; } + public string Organizer { get; set; } + public string Subject { get; set; } + public string IsPrivate { get; set; } + public string IsExchangePrivate { get; set; } + public Attendees Attendees { get; set; } + // public Resources Resources { get; set; } + public string IsEvent { get; set; } + public string IsRoomViewMeeting { get; set; } + public MeetingTypes MeetingTypes { get; set; } + public LiveMeeting LiveMeeting { get; set; } + public string WelcomeMsg { get; set; } + public string Body { get; set; } + public string Location { get; set; } + public string ShareDocPath { get; set; } + public string ParticipantCode { get; set; } + public string PhoneNo { get; set; } + public string InstanceID { get; set; } + + public Event() + { + + } + + public string StartTime + { + get + { + string startTimeShort; + + startTimeShort = dtStart.ToShortTimeString(); + + return startTimeShort; + + } + } + + public string StartDate + { + get + { + string startDateShort; + + startDateShort = dtStart.ToShortDateString(); + + return startDateShort; + + } + } + + public string EndTime + { + get + { + string endTimeShort; + + endTimeShort = dtEnd.ToShortTimeString(); + + return endTimeShort; + + } + } + + public string EndDate + { + get + { + string endDateShort; + + endDateShort = dtEnd.ToShortDateString(); + + return endDateShort; + + } + } + + public string DurationInMinutes + { + get + { + string duration; + + var timeSpan = dtEnd.Subtract(dtStart); + int hours = timeSpan.Hours; + double minutes = timeSpan.Minutes; + double minutesRounded = Math.Round(minutes); + if (hours > 0) + { + duration = String.Format("{0} Hours {1} Minutes", hours, minutesRounded); + } + else + { + duration = String.Format("{0} Minutes", minutesRounded); + } + + return duration; + } + } + public double TimeRemainingInMin + { + + get + { + DateTime timeMarker = new DateTime(); + if (dtStart <= DateTime.Now) { timeMarker = dtEnd; } + else { timeMarker = dtStart; } + + double totalMinutes = timeMarker.Subtract(DateTime.Now).TotalMinutes; + if (totalMinutes >= 0) + return Math.Round(totalMinutes); + else + return 0; + } + } + public string TimeRemainingString + { + get + { + var now = DateTime.Now; + string remainingTimeString; + + DateTime timeMarker = new DateTime(); + if (GetInProgress()) { timeMarker = dtEnd; } + else { timeMarker = dtStart; } + + var hourTag = ""; + var minTag = ""; + int hours = timeMarker.Subtract(DateTime.Now).Hours; + int minutes = timeMarker.Subtract(DateTime.Now).Minutes; + if (hours > 1) { hourTag = "Hours"; } + else if (hours == 1) { hourTag = "Hour"; } + if (minutes == 1) { minTag = "Minute"; } + else { minTag = "Minutes"; } + + if (hourTag.Length == 0) { remainingTimeString = string.Format("{0} {1}", minutes, minTag); } + else { remainingTimeString = string.Format("{0} {1} {2} {3}", hours, hourTag, minutes, minTag); } + + return remainingTimeString; + + } + } + + public bool isInProgress + { + get + { + return GetInProgress(); + } + } + + bool GetInProgress() + { + var now = DateTime.Now; + + if (now > dtStart && now < dtEnd) + { + return true; + } + else + { + return false; + } + } + } + + public class Attendees + { + public Required Required { get; set; } + public Optional Optional { get; set; } + } + + public class Required + { + public List Atendee { get; set; } + } + + public class Optional + { + public List Atendee { get; set; } + } + /* + public class Resources + { + public Rooms Rooms { get; set; } + } + */ + + + + + + + public class MeetingType + { + public string ID { get; set; } + public string Value { get; set; } + } + + public class MeetingTypes + { + public List MeetingType { get; set; } + } + + public class LiveMeeting + { + public string URL { get; set; } + public string ID { get; set; } + public string Key { get; set; } + public string Subject { get; set; } + } + + public class LiveMeetingURL + { + public LiveMeeting LiveMeeting { get; set; } + } } \ No newline at end of file diff --git a/DynFusionEPI/SchedulingConfig.cs b/src/SchedulingConfig.cs similarity index 94% rename from DynFusionEPI/SchedulingConfig.cs rename to src/SchedulingConfig.cs index b37c437..9658767 100644 --- a/DynFusionEPI/SchedulingConfig.cs +++ b/src/SchedulingConfig.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace DynFusion -{ - public class SchedulingConfig - { - public string DynFusionKey {get; set;} - } - - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace DynFusion +{ + public class SchedulingConfig + { + public string DynFusionKey {get; set;} + } + + } \ No newline at end of file diff --git a/DynFusionEPI/SchedulingJoinMap.cs b/src/SchedulingJoinMap.cs similarity index 61% rename from DynFusionEPI/SchedulingJoinMap.cs rename to src/SchedulingJoinMap.cs index 6ac8769..520d3e4 100644 --- a/DynFusionEPI/SchedulingJoinMap.cs +++ b/src/SchedulingJoinMap.cs @@ -1,177 +1,177 @@ -using PepperDash.Essentials.Core; - -namespace DynFusion -{ - public class SchedulingJoinMap : JoinMapBaseAdvanced - { - [JoinName("GetSchedule")] - public JoinDataComplete GetSchedule = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Label = "GetSchedule", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("EndCurrentMeeting")] - public JoinDataComplete EndCurrentMeeting = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Label = "EndCurrentMeeting", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("CheckMeetings")] - public JoinDataComplete CheckMeetings = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Label = "CheckMeetings", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ScheduleBusy")] - public JoinDataComplete ScheduleBusy = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Label = "ScheduleBusy", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("GetRoomInfo")] - public JoinDataComplete GetRoomInfo = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata { Label = "GetRoomInfo", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - [JoinName("GetRoomList")] - public JoinDataComplete GetRoomList = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata { Label = "GetRoomList", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("PushNotificationRegistered")] - public JoinDataComplete PushNotificationRegistered = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Label = "PushNotificationRegistered", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - [JoinName("MeetingInProgress")] - public JoinDataComplete MeetingInProgress = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Label = "GetSchedule", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ExtendMeeting15Minutes")] - public JoinDataComplete ExtendMeeting15Minutes = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata { Label = "ExtendMeeting15Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ExtendMeeting30Minutes")] - public JoinDataComplete ExtendMeeting30Minutes = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata { Label = "ExtendMeeting30Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ExtendMeeting45Minutes")] - public JoinDataComplete ExtendMeeting45Minutes = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, new JoinMetadata { Label = "ExtendMeeting45Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ExtendMeeting60Minutes")] - public JoinDataComplete ExtendMeeting60Minutes = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, new JoinMetadata { Label = "ExtendMeeting60Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ExtendMeeting90Minutes")] - public JoinDataComplete ExtendMeeting90Minutes = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, new JoinMetadata { Label = "ExtendMeeting90Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ReserveMeeting15Minutes")] - public JoinDataComplete ReserveMeeting15Minutes = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Label = "ReserveMeeting15Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ReserveMeeting30Minutes")] - public JoinDataComplete ReserveMeeting30Minutes = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Label = "ReserveMeeting30Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ReserveMeeting45Minutes")] - public JoinDataComplete ReserveMeeting45Minutes = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, new JoinMetadata { Label = "ReserveMeeting45Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ReserveMeeting60Minutes")] - public JoinDataComplete ReserveMeeting60Minutes = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, new JoinMetadata { Label = "ReserveMeeting60Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ReserveMeeting90Minutes")] - public JoinDataComplete ReserveMeeting90Minutes = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, new JoinMetadata { Label = "ReserveMeeting90Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - - [JoinName("RoomID")] - public JoinDataComplete RoomID = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Label = "RoomID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("RoomLocation")] - public JoinDataComplete RoomLocation = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Label = "RoomLocation", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingOrganizer")] - public JoinDataComplete CurrentMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingSubject")] - public JoinDataComplete CurrentMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingMeetingID")] - public JoinDataComplete CurrentMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingStartTime")] - public JoinDataComplete CurrentMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingStartDate")] - public JoinDataComplete CurrentMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingEndTime")] - public JoinDataComplete CurrentMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingEndDate")] - public JoinDataComplete CurrentMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingDuration")] - public JoinDataComplete CurrentMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentMeetingRemainingTime")] - public JoinDataComplete CurrentMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, new JoinMetadata { Label = "CurrentMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingOrganizer")] - public JoinDataComplete NextMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingSubject")] - public JoinDataComplete NextMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingMeetingID")] - public JoinDataComplete NextMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingStartTime")] - public JoinDataComplete NextMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingStartDate")] - public JoinDataComplete NextMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingEndTime")] - public JoinDataComplete NextMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 36, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingEndDate")] - public JoinDataComplete NextMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 37, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingDuration")] - public JoinDataComplete NextMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 38, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingRemainingTime")] - public JoinDataComplete NextMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 39, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("NextMeetingIsToday")] - public JoinDataComplete NextMeetingIsToday = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, new JoinMetadata { Label = "NextMeetingIsToday", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ThirdMeetingOrganizer")] - public JoinDataComplete ThirdMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingSubject")] - public JoinDataComplete ThirdMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingMeetingID")] - public JoinDataComplete ThirdMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingStartTime")] - public JoinDataComplete ThirdMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 44, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingStartDate")] - public JoinDataComplete ThirdMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 45, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingEndTime")] - public JoinDataComplete ThirdMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 46, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingEndDate")] - public JoinDataComplete ThirdMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 47, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingDuration")] - public JoinDataComplete ThirdMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 48, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("ThirdMeetingRemainingTime")] - public JoinDataComplete ThirdMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 49, JoinSpan = 1 }, new JoinMetadata { Label = "ThirdMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingOrganizer")] - public JoinDataComplete FourthMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingSubject")] - public JoinDataComplete FourthMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingMeetingID")] - public JoinDataComplete FourthMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 53, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingStartTime")] - public JoinDataComplete FourthMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 54, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingStartDate")] - public JoinDataComplete FourthMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 55, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingEndTime")] - public JoinDataComplete FourthMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 56, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingEndDate")] - public JoinDataComplete FourthMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 57, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingDuration")] - public JoinDataComplete FourthMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 58, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FourthMeetingRemainingTime")] - public JoinDataComplete FourthMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 59, JoinSpan = 1 }, new JoinMetadata { Label = "FourthMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingOrganizer")] - public JoinDataComplete FifthMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 61, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingSubject")] - public JoinDataComplete FifthMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 62, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingMeetingID")] - public JoinDataComplete FifthMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 63, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingStartTime")] - public JoinDataComplete FifthMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 64, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingStartDate")] - public JoinDataComplete FifthMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 65, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingEndTime")] - public JoinDataComplete FifthMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 66, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingEndDate")] - public JoinDataComplete FifthMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 67, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingDuration")] - public JoinDataComplete FifthMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 68, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("FifthMeetingRemainingTime")] - public JoinDataComplete FifthMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 69, JoinSpan = 1 }, new JoinMetadata { Label = "FifthMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingOrganizer")] - public JoinDataComplete SixthMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 71, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingSubject")] - public JoinDataComplete SixthMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 72, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingMeetingID")] - public JoinDataComplete SixthMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 73, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingStartTime")] - public JoinDataComplete SixthMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 74, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingStartDate")] - public JoinDataComplete SixthMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 75, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingEndTime")] - public JoinDataComplete SixthMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 76, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingEndDate")] - public JoinDataComplete SixthMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 77, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingDuration")] - public JoinDataComplete SixthMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 78, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - [JoinName("SixthMeetingRemainingTime")] - public JoinDataComplete SixthMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 79, JoinSpan = 1 }, new JoinMetadata { Label = "SixthMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - public SchedulingJoinMap(uint joinStart) - : this(joinStart, typeof(SchedulingJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// AssetType of the child join map - protected SchedulingJoinMap(uint joinStart, System.Type type) - : base(joinStart, type) - { - } - - } +using PepperDash.Essentials.Core; + +namespace DynFusion +{ + public class SchedulingJoinMap : JoinMapBaseAdvanced + { + [JoinName("GetSchedule")] + public JoinDataComplete GetSchedule = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Description = "GetSchedule", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("EndCurrentMeeting")] + public JoinDataComplete EndCurrentMeeting = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "EndCurrentMeeting", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CheckMeetings")] + public JoinDataComplete CheckMeetings = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Description = "CheckMeetings", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ScheduleBusy")] + public JoinDataComplete ScheduleBusy = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Description = "ScheduleBusy", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("GetRoomInfo")] + public JoinDataComplete GetRoomInfo = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata { Description = "GetRoomInfo", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("GetRoomList")] + public JoinDataComplete GetRoomList = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata { Description = "GetRoomList", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PushNotificationRegistered")] + public JoinDataComplete PushNotificationRegistered = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Description = "PushNotificationRegistered", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("MeetingInProgress")] + public JoinDataComplete MeetingInProgress = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "GetSchedule", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ExtendMeeting15Minutes")] + public JoinDataComplete ExtendMeeting15Minutes = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata { Description = "ExtendMeeting15Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ExtendMeeting30Minutes")] + public JoinDataComplete ExtendMeeting30Minutes = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata { Description = "ExtendMeeting30Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ExtendMeeting45Minutes")] + public JoinDataComplete ExtendMeeting45Minutes = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, new JoinMetadata { Description = "ExtendMeeting45Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ExtendMeeting60Minutes")] + public JoinDataComplete ExtendMeeting60Minutes = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, new JoinMetadata { Description = "ExtendMeeting60Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ExtendMeeting90Minutes")] + public JoinDataComplete ExtendMeeting90Minutes = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, new JoinMetadata { Description = "ExtendMeeting90Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ReserveMeeting15Minutes")] + public JoinDataComplete ReserveMeeting15Minutes = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Description = "ReserveMeeting15Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ReserveMeeting30Minutes")] + public JoinDataComplete ReserveMeeting30Minutes = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Description = "ReserveMeeting30Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ReserveMeeting45Minutes")] + public JoinDataComplete ReserveMeeting45Minutes = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, new JoinMetadata { Description = "ReserveMeeting45Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ReserveMeeting60Minutes")] + public JoinDataComplete ReserveMeeting60Minutes = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, new JoinMetadata { Description = "ReserveMeeting60Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ReserveMeeting90Minutes")] + public JoinDataComplete ReserveMeeting90Minutes = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, new JoinMetadata { Description = "ReserveMeeting90Minutes", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + + [JoinName("RoomID")] + public JoinDataComplete RoomID = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata { Description = "RoomID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("RoomLocation")] + public JoinDataComplete RoomLocation = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata { Description = "RoomLocation", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingOrganizer")] + public JoinDataComplete CurrentMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingSubject")] + public JoinDataComplete CurrentMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingMeetingID")] + public JoinDataComplete CurrentMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingStartTime")] + public JoinDataComplete CurrentMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingStartDate")] + public JoinDataComplete CurrentMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingEndTime")] + public JoinDataComplete CurrentMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingEndDate")] + public JoinDataComplete CurrentMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingDuration")] + public JoinDataComplete CurrentMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentMeetingRemainingTime")] + public JoinDataComplete CurrentMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, new JoinMetadata { Description = "CurrentMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingOrganizer")] + public JoinDataComplete NextMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingSubject")] + public JoinDataComplete NextMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingMeetingID")] + public JoinDataComplete NextMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingStartTime")] + public JoinDataComplete NextMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingStartDate")] + public JoinDataComplete NextMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingEndTime")] + public JoinDataComplete NextMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 36, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingEndDate")] + public JoinDataComplete NextMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 37, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingDuration")] + public JoinDataComplete NextMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 38, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingRemainingTime")] + public JoinDataComplete NextMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 39, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("NextMeetingIsToday")] + public JoinDataComplete NextMeetingIsToday = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, new JoinMetadata { Description = "NextMeetingIsToday", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ThirdMeetingOrganizer")] + public JoinDataComplete ThirdMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingSubject")] + public JoinDataComplete ThirdMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingMeetingID")] + public JoinDataComplete ThirdMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingStartTime")] + public JoinDataComplete ThirdMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 44, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingStartDate")] + public JoinDataComplete ThirdMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 45, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingEndTime")] + public JoinDataComplete ThirdMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 46, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingEndDate")] + public JoinDataComplete ThirdMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 47, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingDuration")] + public JoinDataComplete ThirdMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 48, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ThirdMeetingRemainingTime")] + public JoinDataComplete ThirdMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 49, JoinSpan = 1 }, new JoinMetadata { Description = "ThirdMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingOrganizer")] + public JoinDataComplete FourthMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingSubject")] + public JoinDataComplete FourthMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingMeetingID")] + public JoinDataComplete FourthMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 53, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingStartTime")] + public JoinDataComplete FourthMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 54, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingStartDate")] + public JoinDataComplete FourthMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 55, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingEndTime")] + public JoinDataComplete FourthMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 56, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingEndDate")] + public JoinDataComplete FourthMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 57, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingDuration")] + public JoinDataComplete FourthMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 58, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FourthMeetingRemainingTime")] + public JoinDataComplete FourthMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 59, JoinSpan = 1 }, new JoinMetadata { Description = "FourthMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingOrganizer")] + public JoinDataComplete FifthMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 61, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingSubject")] + public JoinDataComplete FifthMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 62, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingMeetingID")] + public JoinDataComplete FifthMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 63, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingStartTime")] + public JoinDataComplete FifthMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 64, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingStartDate")] + public JoinDataComplete FifthMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 65, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingEndTime")] + public JoinDataComplete FifthMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 66, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingEndDate")] + public JoinDataComplete FifthMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 67, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingDuration")] + public JoinDataComplete FifthMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 68, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("FifthMeetingRemainingTime")] + public JoinDataComplete FifthMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 69, JoinSpan = 1 }, new JoinMetadata { Description = "FifthMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingOrganizer")] + public JoinDataComplete SixthMeetingOrganizer = new JoinDataComplete(new JoinData { JoinNumber = 71, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingOrganizer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingSubject")] + public JoinDataComplete SixthMeetingSubject = new JoinDataComplete(new JoinData { JoinNumber = 72, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingSubject", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingMeetingID")] + public JoinDataComplete SixthMeetingMeetingID = new JoinDataComplete(new JoinData { JoinNumber = 73, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingMeetingID", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingStartTime")] + public JoinDataComplete SixthMeetingStartTime = new JoinDataComplete(new JoinData { JoinNumber = 74, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingStartTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingStartDate")] + public JoinDataComplete SixthMeetingStartDate = new JoinDataComplete(new JoinData { JoinNumber = 75, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingStartDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingEndTime")] + public JoinDataComplete SixthMeetingEndTime = new JoinDataComplete(new JoinData { JoinNumber = 76, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingEndTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingEndDate")] + public JoinDataComplete SixthMeetingEndDate = new JoinDataComplete(new JoinData { JoinNumber = 77, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingEndDate", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingDuration")] + public JoinDataComplete SixthMeetingDuration = new JoinDataComplete(new JoinData { JoinNumber = 78, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingDuration", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SixthMeetingRemainingTime")] + public JoinDataComplete SixthMeetingRemainingTime = new JoinDataComplete(new JoinData { JoinNumber = 79, JoinSpan = 1 }, new JoinMetadata { Description = "SixthMeetingRemainingTime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + public SchedulingJoinMap(uint joinStart) + : this(joinStart, typeof(SchedulingJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// AssetType of the child join map + protected SchedulingJoinMap(uint joinStart, System.Type type) + : base(joinStart, type) + { + } + + } } \ No newline at end of file diff --git a/DynFusionEPI/XmlExtensions.cs b/src/XmlExtensions.cs similarity index 96% rename from DynFusionEPI/XmlExtensions.cs rename to src/XmlExtensions.cs index fa18388..78123a3 100644 --- a/DynFusionEPI/XmlExtensions.cs +++ b/src/XmlExtensions.cs @@ -1,60 +1,60 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronXml; -using Crestron.SimplSharp.CrestronXml.Serialization; -using Crestron.SimplSharp.CrestronXmlLinq; -using System.Text.RegularExpressions; - -namespace DynFusion -{ - public static class XmlExtensions - { - //DynFusion fusion { get; set; } - - //public XmlExtensions(DynFusion fus) - //{ - // fusion = fus; - //} - - /// - /// Custom method that needs to be updated if other properties - /// are found to be invalid. This checks for & and will fix the Location field for lt gt - /// - /// - /// - public static XmlDocument CustomEscapeDocument(this XmlDocument doc, string nonEscapedXml) - { - try - { - var noAmp = Regex.Replace(nonEscapedXml, "&(?!(amp|apos|quot|lt|gt);)", "&"); - var escape = Regex.Replace(noAmp, "(.*?)", (match) => - { - var original = match.Value; - Regex rgx = new Regex("(.*?)"); - var split = rgx.Split(original); - split = split.Where(x => !string.IsNullOrEmpty(x)).ToArray(); - if (split.Count() > 0 && split[0].Contains('>') || split[0].Contains('<')) - { - var update = split[0].Replace(">", ">"); - update = update.Replace("<", "<"); - update = "" + update + ""; - return update; - } - return original; - }); - - XmlDocument scheduleXML = new XmlDocument(); - scheduleXML.LoadXml(escape); - return scheduleXML; - } - catch (Exception ex) - { - ErrorLog.Error("Error Escaping XML: {0}. Inner Exception {1}", ex.Message, ex.InnerException); - } - return null; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronXml; +using Crestron.SimplSharp.CrestronXml.Serialization; +using Crestron.SimplSharp.CrestronXmlLinq; +using System.Text.RegularExpressions; + +namespace DynFusion +{ + public static class XmlExtensions + { + //DynFusion fusion { get; set; } + + //public XmlExtensions(DynFusion fus) + //{ + // fusion = fus; + //} + + /// + /// Custom method that needs to be updated if other properties + /// are found to be invalid. This checks for & and will fix the Location field for lt gt + /// + /// + /// + public static XmlDocument CustomEscapeDocument(this XmlDocument doc, string nonEscapedXml) + { + try + { + var noAmp = Regex.Replace(nonEscapedXml, "&(?!(amp|apos|quot|lt|gt);)", "&"); + var escape = Regex.Replace(noAmp, "(.*?)", (match) => + { + var original = match.Value; + Regex rgx = new Regex("(.*?)"); + var split = rgx.Split(original); + split = split.Where(x => !string.IsNullOrEmpty(x)).ToArray(); + if (split.Count() > 0 && split[0].Contains('>') || split[0].Contains('<')) + { + var update = split[0].Replace(">", ">"); + update = update.Replace("<", "<"); + update = "" + update + ""; + return update; + } + return original; + }); + + XmlDocument scheduleXML = new XmlDocument(); + scheduleXML.LoadXml(escape); + return scheduleXML; + } + catch (Exception ex) + { + ErrorLog.Error("Error Escaping XML: {0}. Inner Exception {1}", ex.Message, ex.InnerException); + } + return null; + } + } } \ No newline at end of file diff --git a/src/epi-crestron-fusion.4series.csproj b/src/epi-crestron-fusion.4series.csproj new file mode 100644 index 0000000..644a6cf --- /dev/null +++ b/src/epi-crestron-fusion.4series.csproj @@ -0,0 +1,36 @@ + + + ProgramLibrary + + + net472 + Pepperdash.Essentials.Plugins.Crestron.Fusion + false + EPI.Crestron.Fusion + PepperDash Technologies + This software is a plugin designed to work as a part of PepperDash Essentials for Crestron control processors. This plugin allows for integration of Crestron Fusion. + Copyright 2024 + 1.0.0-local + true + $(Version) + 4Series\bin\$(Configuration)\ + PepperDash Technologies + Pepperdash.Essentials.Plugins.Crestron.Fusion + https://github.com/PepperDash/epi-crestron-fusion + crestron 4series fusion + + + $(DefineConstants);SERIES4 + + + + + + + + + + + + +