public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo) { IPlugInAPI.strMultiReturn result = default; result.DataOut = actionInfo.DataIn; result.TrigActInfo = actionInfo; result.sResult = string.Empty; if (postData != null && postData.Count > 0) { RefreshDeviceAction action = (actionInfo.DataIn != null) ? (RefreshDeviceAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) : new RefreshDeviceAction(); foreach (var pair in postData) { string text = Convert.ToString(pair, CultureInfo.InvariantCulture); if (!string.IsNullOrWhiteSpace(text) && text.StartsWith(RefreshActionUIDropDownName, StringComparison.Ordinal)) { action.DeviceRefId = Convert.ToInt32(postData[text], CultureInfo.InvariantCulture); } } result.DataOut = ObjectSerialize.SerializeToBytes(action); } return(result); }
public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo) { IPlugInAPI.strMultiReturn result = default; result.DataOut = actionInfo.DataIn; result.TrigActInfo = actionInfo; result.sResult = string.Empty; if (postData != null && postData.Count > 0) { var action = (actionInfo.DataIn != null) ? (TakeSnapshotAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) : new TakeSnapshotAction(); foreach (var pair in postData) { string text = Convert.ToString(pair, CultureInfo.InvariantCulture); if (!string.IsNullOrWhiteSpace(text)) { if (text.StartsWith(nameof(TakeSnapshotAction.Id), StringComparison.Ordinal)) { action.Id = postData[text]; } else if (text.StartsWith(NameToIdWithPrefix(nameof(TakeSnapshotAction.TimeSpan)), StringComparison.Ordinal)) { try { action.TimeSpan = TimeSpan.Parse(postData[text], CultureInfo.InvariantCulture); } catch (Exception) { result.sResult += "<BR>Time span is not valid"; } } else if (text.StartsWith(NameToIdWithPrefix(nameof(TakeSnapshotAction.Interval)), StringComparison.Ordinal)) { try { action.Interval = TimeSpan.Parse(postData[text], CultureInfo.InvariantCulture); } catch (Exception) { result.sResult += "<BR>Interval is not valid"; } } } } if (string.IsNullOrWhiteSpace(action.Id)) { result.sResult += "<BR>Camera is not valid"; } result.DataOut = ObjectSerialize.SerializeToBytes(action); } return(result); }
public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo) { IPlugInAPI.strMultiReturn result = default; result.DataOut = actionInfo.DataIn; result.TrigActInfo = actionInfo; result.sResult = string.Empty; if (postData != null && postData.Count > 0) { var action = (actionInfo.DataIn != null) ? (ChromecastCastAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) : new ChromecastCastAction(); foreach (var pair in postData) { string text = Convert.ToString(pair); if (!string.IsNullOrWhiteSpace(text)) { if (text.StartsWith(nameof(ChromecastCastAction.ChromecastDeviceId))) { action.ChromecastDeviceId = postData[text]; } else if (text.StartsWith(nameof(ChromecastCastAction.Url))) { action.Url = postData[text]; } else if (text.StartsWith(nameof(ChromecastCastAction.ContentType))) { action.ContentType = postData[text]; } else if (text.StartsWith(nameof(ChromecastCastAction.Live))) { action.Live = postData[text] == "checked"; } } } if (string.IsNullOrWhiteSpace(action.Url)) { result.sResult += "<BR>Url is not valid"; } if (string.IsNullOrWhiteSpace(action.ChromecastDeviceId)) { result.sResult += "<BR>Chromecast device is not valid"; } result.DataOut = ObjectSerialize.SerializeToBytes(action); } return(result); }
public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActInfo actionInfo) { StringBuilder stb = new StringBuilder(); var currentDevices = GetCurrentDeviceImportDevices(); RefreshDeviceAction refreshDeviceAction = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as RefreshDeviceAction; string selection = string.Empty; if (refreshDeviceAction != null) { selection = refreshDeviceAction.DeviceRefId.ToString(CultureInfo.InvariantCulture); } stb.Append(FormDropDown(RefreshActionUIDropDownName + uniqueControlId, currentDevices, selection, 400, string.Empty, true, "Events")); return(stb.ToString()); }
public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActInfo actionInfo) { StringBuilder stb = new StringBuilder(); var action = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as TakeSnapshotAction; var cameras = new NameValueCollection(); foreach (var camera in pluginConfig.AllCameras) { cameras.Add(camera.Key, camera.Value.Name); } stb.Append(FormDropDown(nameof(TakeSnapshotAction.Id) + uniqueControlId, cameras, action?.Id ?? string.Empty, 250, string.Empty, true)); stb.Append("for "); stb.Append(FormTimeSpan(nameof(TakeSnapshotAction.TimeSpan) + uniqueControlId, string.Empty, action?.TimeSpan ?? TimeSpan.Zero, true)); stb.Append("at interval"); stb.Append(FormTimeSpan(nameof(TakeSnapshotAction.Interval) + uniqueControlId, string.Empty, action?.Interval ?? TimeSpan.FromSeconds(1), true)); return(stb.ToString()); }
public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActInfo actionInfo) { StringBuilder stb = new StringBuilder(); var action = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as ChromecastCastAction; var chromecastDevices = new NameValueCollection(); foreach (var device in pluginConfig.Devices) { chromecastDevices.Add(device.Key, device.Value.Name); } stb.Append(FormDropDown(nameof(ChromecastCastAction.ChromecastDeviceId) + uniqueControlId, chromecastDevices, action?.ChromecastDeviceId, 250, string.Empty, false)); stb.Append("<p> Url:"); stb.Append(HtmlTextBox(nameof(ChromecastCastAction.Url) + uniqueControlId, action?.Url, 100)); stb.Append("</p><p> Content mime type:"); stb.Append(HtmlTextBox(nameof(ChromecastCastAction.ContentType) + uniqueControlId, action?.ContentType, 50)); stb.Append("</p><p> Live:"); stb.Append(FormCheckBox(nameof(ChromecastCastAction.Live) + uniqueControlId, string.Empty, action?.Live ?? false)); stb.Append("</p>"); stb.Append(FormPageButton(SaveButtonName + uniqueControlId, "Save")); return(stb.ToString()); }