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); if (!string.IsNullOrWhiteSpace(text) && text.StartsWith(RefreshActionUIDropDownName)) { action.DeviceRefId = Convert.ToInt32(postData[text]); } } result.DataOut = ObjectSerialize.SerializeToBytes(action); } return(result); }
public override bool ActionConfigured(IPlugInAPI.strTrigActInfo actionInfo) { try { switch (actionInfo.TANumber) { case ActionRefreshTANumber: if (actionInfo.DataIn != null) { RefreshDeviceAction refreshDeviceAction = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as RefreshDeviceAction; if ((refreshDeviceAction != null) && (refreshDeviceAction.DeviceRefId != 0)) { return(HS.GetDeviceByRef(refreshDeviceAction.DeviceRefId) != null); } } return(false); default: return(base.ActionConfigured(actionInfo)); } } catch (Exception ex) { Trace.TraceError(Invariant($"Failed to ActionConfigured with {ex.GetFullMessage()}")); return(false); } }
public override bool HandleAction(IPlugInAPI.strTrigActInfo actionInfo) { try { switch (actionInfo.TANumber) { case ActionRefreshTANumber: if (actionInfo.DataIn != null) { RefreshDeviceAction refreshDeviceAction = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as RefreshDeviceAction; if ((refreshDeviceAction != null) && (refreshDeviceAction.DeviceRefId != 0)) { if (ImportDeviceFromDB(refreshDeviceAction.DeviceRefId)) { return(true); } } } Trace.TraceWarning(Invariant($"Failed to execute action with Device not Found")); return(false); default: return(base.HandleAction(actionInfo)); } } catch (Exception ex) { Trace.TraceWarning(Invariant($"Failed to execute action with {ex.GetFullMessage()}")); return(false); } }
public override string ActionFormatUI(IPlugInAPI.strTrigActInfo actionInfo) { try { switch (actionInfo.TANumber) { case ActionRefreshTANumber: if (actionInfo.DataIn != null) { RefreshDeviceAction refreshDeviceAction = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as RefreshDeviceAction; if ((refreshDeviceAction != null) && (refreshDeviceAction.DeviceRefId != 0)) { HSHelper hSHelper = new HSHelper(HS); return(Invariant($"Refresh {hSHelper.GetName(refreshDeviceAction.DeviceRefId)} from Influx DB")); } } return(Invariant($"{PlugInData.PlugInName} Unknown Device Import Refresh")); default: return(base.ActionFormatUI(actionInfo)); } } catch (Exception ex) { Trace.TraceError(Invariant($"Failed to ActionFormatUI with {ex.GetFullMessage()}")); throw; } }
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 override bool ActionReferencesDevice(IPlugInAPI.strTrigActInfo actionInfo, int deviceId) { try { switch (actionInfo.TANumber) { case ActionRefreshTANumber: if (actionInfo.DataIn != null) { RefreshDeviceAction refreshDeviceAction = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as RefreshDeviceAction; return((refreshDeviceAction != null) && (refreshDeviceAction.DeviceRefId == deviceId)); } return(false); default: return(false); } } catch (Exception ex) { Trace.TraceError(Invariant($"Failed to ActionReferencesDevice with {ex.GetFullMessage()}")); return(false); } }