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); }