mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Added push registration feature
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -40,7 +40,7 @@ namespace PepperDash.Essentials
|
|||||||
},
|
},
|
||||||
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
|
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
//GoWithLoad();
|
GoWithLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
|
|
||||||
bool GuidFileExists;
|
bool GuidFileExists;
|
||||||
|
|
||||||
|
bool IsRegisteredForSchedulePushNotifications = false;
|
||||||
|
|
||||||
|
// Default poll time is 5 min unless overridden by config value
|
||||||
|
int SchedulePollInterval = 300000;
|
||||||
|
|
||||||
List<StaticAsset> StaticAssets;
|
List<StaticAsset> StaticAssets;
|
||||||
|
|
||||||
//ScheduleResponseEvent NextMeeting;
|
//ScheduleResponseEvent NextMeeting;
|
||||||
@@ -263,22 +268,40 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
{
|
{
|
||||||
if (args.DeviceOnLine)
|
if (args.DeviceOnLine)
|
||||||
{
|
{
|
||||||
|
CrestronEnvironment.Sleep(200);
|
||||||
|
|
||||||
// Send Push Notification Action request:
|
// Send Push Notification Action request:
|
||||||
|
|
||||||
string requestID = "InitialPushRequest";
|
string requestID = "InitialPushRequest";
|
||||||
|
|
||||||
|
|
||||||
string actionRequest =
|
string actionRequest =
|
||||||
string.Format("<RequestAction><RequestID>{0}</RequestID><RoomID>{1}</RoomID>", requestID, RoomGuid) +
|
string.Format("<RequestAction>\n<RequestID>{0}</RequestID>\n", requestID) +
|
||||||
"<ActionID>RegisterPushModel</ActionID>" +
|
"<ActionID>RegisterPushModel</ActionID>\n" +
|
||||||
"<Parameters><Parameter ID='Enabled' Value='1' /><Parameter ID='RequestID' Value='PushNotification' /><Parameter ID='Start' Value='00:00:00' />" +
|
"<Parameters>\n" +
|
||||||
"<Parameter ID='HourSpan' Value='24' /><Parameter ID='Field' Value='MeetingID' /><Parameter ID='Field' Value='RVMeetingID' />" +
|
"<Parameter ID='Enabled' Value='1' />\n" +
|
||||||
"<Parameter ID='Field' Value='InstanceID' /><Parameter ID='Field' Value='Recurring' /><Parameter ID='Field' Value='dtStart' />" +
|
"<Parameter ID='RequestID' Value='PushNotification' />\n" +
|
||||||
"<Parameter ID='Field' Value='dtEnd' /><Parameter ID='Field' Value='Subject' /><Parameter ID='Field' Value='Organizer' />" +
|
"<Parameter ID='Start' Value='00:00:00' />\n" +
|
||||||
"<Parameter ID='Field' Value='IsEvent' /><Parameter ID='Field' Value='IsPrivate' /><Parameter ID='Field' Value='IsExchangePrivate' />" +
|
"<Parameter ID='HourSpan' Value='24' />\n" +
|
||||||
"<Parameter ID='Field' Value='LiveMeeting' /><Parameter ID='Field' Value='ShareDocPath' /><Parameter ID='Field' Value='PhoneNo' /><Parameter ID='Field' Value='ParticipantCode' /></Parameters></RequestAction>'";
|
"<Parameter ID='Field' Value='MeetingID' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='RVMeetingID' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='InstanceID' />\n" +
|
||||||
|
//"<Parameter ID='Field' Value='Recurring' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='dtStart' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='dtEnd' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='Subject' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='Organizer' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='IsEvent' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='IsPrivate' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='IsExchangePrivate' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='LiveMeeting' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='ShareDocPath' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='PhoneNo' />\n" +
|
||||||
|
"<Parameter ID='Field' Value='ParticipantCode' />\n" +
|
||||||
|
"</Parameters>\n" +
|
||||||
|
"</RequestAction>\n";
|
||||||
|
|
||||||
Debug.Console(1, this, "Sending Fusion ScheduleQuery: \n{0}", actionRequest);
|
Debug.Console(1, this, "Sending Fusion ActionRequest: \n{0}", actionRequest);
|
||||||
|
|
||||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest;
|
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest;
|
||||||
}
|
}
|
||||||
@@ -373,6 +396,27 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ActionResponse actionResponse = new ActionResponse();
|
||||||
|
|
||||||
|
TextReader reader = new StringReader(args.Sig.StringValue);
|
||||||
|
|
||||||
|
actionResponse = CrestronXMLSerialization.DeSerializeObject<ActionResponse>(reader);
|
||||||
|
|
||||||
|
if (actionResponse.RequestID == "InitialPushRequest")
|
||||||
|
{
|
||||||
|
var tempParam = actionResponse.Parameters.FirstOrDefault(p => p.ID.Equals("Registered"));
|
||||||
|
|
||||||
|
if (tempParam != null)
|
||||||
|
{
|
||||||
|
if (tempParam.Value = 1)
|
||||||
|
IsRegisteredForSchedulePushNotifications = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsRegisteredForSchedulePushNotifications = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -397,8 +441,23 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
|
|
||||||
message.LoadXml(args.Sig.StringValue);
|
message.LoadXml(args.Sig.StringValue);
|
||||||
|
|
||||||
if (message.FirstChild.Name == "ScheduleResponse")
|
var scheuldResponse = message["ScheduleRespones"];
|
||||||
|
|
||||||
|
if (scheuldResponse != null)
|
||||||
{
|
{
|
||||||
|
// Check for push notification
|
||||||
|
if (scheuldResponse["RequestID"].InnerText == "RVRequest")
|
||||||
|
{
|
||||||
|
var action = scheuldResponse["Action"];
|
||||||
|
|
||||||
|
if (action.InnerText.IndexOf("RequestSchedule") > -1)
|
||||||
|
{
|
||||||
|
RequestFullRoomSchedule("PushScheduleRefresh");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Not a push notification
|
||||||
|
{
|
||||||
|
|
||||||
foreach (XmlElement element in message.FirstChild.ChildNodes)
|
foreach (XmlElement element in message.FirstChild.ChildNodes)
|
||||||
{
|
{
|
||||||
if (element.Name == "RequestID")
|
if (element.Name == "RequestID")
|
||||||
@@ -428,30 +487,12 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//XmlReader reader = new XmlReader(args.Sig.StringValue);
|
|
||||||
|
|
||||||
//scheduleResponse = CrestronXMLSerialization.DeSerializeObject<ScheduleResponse>(reader);
|
|
||||||
|
|
||||||
//Debug.Console(1, this, "ScheduleResponse DeSerialization Successful for Room: '{0}'", scheduleResponse.RoomName);
|
|
||||||
|
|
||||||
if (scheduleResponse.Events.Count > 0)
|
|
||||||
{
|
|
||||||
Debug.Console(1, this, "Meetings Count: {0}\n", scheduleResponse.Events.Count);
|
|
||||||
|
|
||||||
foreach (Event e in scheduleResponse.Events)
|
|
||||||
{
|
|
||||||
Debug.Console(1, this, "Subject: {0}", e.Subject);
|
|
||||||
Debug.Console(1, this, "MeetingID: {0}", e.MeetingID);
|
|
||||||
Debug.Console(1, this, "Start Time: {0}", e.dtStart);
|
|
||||||
Debug.Console(1, this, "End Time: {0}\n", e.dtEnd);
|
|
||||||
var duration = e.dtEnd.Subtract(e.dtStart);
|
|
||||||
Debug.Console(1, this, "Duration: {0} minutes", duration.Minutes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentSchedule = scheduleResponse;
|
CurrentSchedule = scheduleResponse;
|
||||||
|
|
||||||
|
PrintTodaysSchedule();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -460,6 +501,25 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintTodaysSchedule()
|
||||||
|
{
|
||||||
|
if (CurrentSchedule.Events.Count > 0)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name);
|
||||||
|
|
||||||
|
foreach (Event e in CurrentSchedule.Events)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Subject: {0}", e.Subject);
|
||||||
|
Debug.Console(1, this, "Organizer: {0}", e.Organizer);
|
||||||
|
Debug.Console(1, this, "MeetingID: {0}", e.MeetingID);
|
||||||
|
Debug.Console(1, this, "Start Time: {0}", e.dtStart);
|
||||||
|
Debug.Console(1, this, "End Time: {0}", e.dtEnd);
|
||||||
|
var duration = e.dtEnd.Subtract(e.dtStart);
|
||||||
|
Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SetUpSources()
|
void SetUpSources()
|
||||||
{
|
{
|
||||||
// Sources
|
// Sources
|
||||||
@@ -936,6 +996,17 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//[XmlRoot(ElementName = "ActionResponse")]
|
||||||
|
public class ActionResponse
|
||||||
|
{
|
||||||
|
//[XmlElement(ElementName = "RequestID")]
|
||||||
|
public string RequestID { get; set; }
|
||||||
|
//[XmlElement(ElementName = "ActionID")]
|
||||||
|
public string ActionID { get; set; }
|
||||||
|
//[XmlElement(ElementName = "Parameters")]
|
||||||
|
public List<Parameter> Parameters { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
//[XmlRoot(ElementName = "Parameter")]
|
//[XmlRoot(ElementName = "Parameter")]
|
||||||
public class Parameter
|
public class Parameter
|
||||||
{
|
{
|
||||||
@@ -1020,6 +1091,93 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
public string HaveAttendees { get; set; }
|
public string HaveAttendees { get; set; }
|
||||||
//[XmlElement(ElementName = "HaveResources")]
|
//[XmlElement(ElementName = "HaveResources")]
|
||||||
public string HaveResources { get; set; }
|
public string HaveResources { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the duration of the meeting
|
||||||
|
/// </summary>
|
||||||
|
public string DurationInMinutes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string duration;
|
||||||
|
|
||||||
|
var timeSpan = dtEnd.Subtract(dtStart);
|
||||||
|
int hours = timeSpan.Hours;
|
||||||
|
double minutes = timeSpan.Minutes;
|
||||||
|
double roundedMinutes = Math.Round(minutes);
|
||||||
|
if(hours > 0)
|
||||||
|
{
|
||||||
|
duration = string.Format("{0} hours {1} minutes", hours, roundedMinutes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
duration = string.Format("{0} minutes", roundedMinutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the remaining time in the meeting. Returns null if the meeting is not currently in progress.
|
||||||
|
/// </summary>
|
||||||
|
public string RemainingTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
|
||||||
|
string remainingTime;
|
||||||
|
|
||||||
|
if (GetInProgress())
|
||||||
|
{
|
||||||
|
var timeSpan = dtEnd.Subtract(now);
|
||||||
|
int hours = timeSpan.Hours;
|
||||||
|
double minutes = timeSpan.Minutes;
|
||||||
|
double roundedMinutes = Math.Round(minutes);
|
||||||
|
if (hours > 0)
|
||||||
|
{
|
||||||
|
remainingTime = string.Format("{0} hours {1} minutes", hours, roundedMinutes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
remainingTime = string.Format("{0} minutes", roundedMinutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remainingTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that the meeting is in progress
|
||||||
|
/// </summary>
|
||||||
|
public bool isInProgress
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetInProgress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the meeting is in progress
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Returns true if in progress</returns>
|
||||||
|
bool GetInProgress()
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
|
||||||
|
if (now > dtStart && now < dtEnd)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//[XmlRoot(ElementName = "Resources")]
|
//[XmlRoot(ElementName = "Resources")]
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user