public async Task <ActionResult> VariableRead(string jstreeNode) { string[] delimiter = { "__$__" }; string[] jstreeNodeSplit = jstreeNode.Split(delimiter, 3, StringSplitOptions.None); string node; string actionResult = string.Empty; string endpointId = Session["EndpointId"].ToString(); if (jstreeNodeSplit.Length == 1) { node = jstreeNodeSplit[0]; } else { node = jstreeNodeSplit[1]; } try { ValueReadRequestApiModel model = new ValueReadRequestApiModel(); model.NodeId = node; var data = await TwinService.ReadNodeValueAsync(endpointId, model); string value = ""; if (data.Value != null) { if (data.Value.ToString().Length > 40) { value = data.Value.ToString().Substring(0, 40); value += "..."; } else { value = data.Value.ToString(); } } // We return the HTML formatted content, which is shown in the context panel. actionResult = Strings.BrowserOpcDataValueLabel + ": " + value + @"<br/>" + (data.ErrorInfo == null ? "" : (Strings.BrowserOpcDataStatusLabel + ": " + data.ErrorInfo.StatusCode + @"<br/>")) + Strings.BrowserOpcDataSourceTimestampLabel + ": " + data.SourceTimestamp + @"<br/>" + Strings.BrowserOpcDataServerTimestampLabel + ": " + data.ServerTimestamp; return(Content(actionResult)); } catch (Exception exception) { return(Content(CreateOpcExceptionActionString(exception))); } }
public async Task <ActionResult> VariableWriteFetch(string jstreeNode) { string[] delimiter = { "__$__" }; string[] jstreeNodeSplit = jstreeNode.Split(delimiter, 3, StringSplitOptions.None); string node; string actionResult = string.Empty; string endpointId = Session["EndpointId"].ToString(); if (jstreeNodeSplit.Length == 1) { node = jstreeNodeSplit[0]; } else { node = jstreeNodeSplit[1]; } try { ValueReadRequestApiModel model = new ValueReadRequestApiModel(); model.NodeId = node; var data = await TwinService.ReadNodeValueAsync(endpointId, model); if (data.Value != null) { if (data.Value.ToString().Length > 30) { actionResult = data.Value.ToString().Substring(0, 30); actionResult += "..."; } else { actionResult = data.Value.ToString(); } } return(Content(actionResult)); } catch (Exception exception) { return(Content(CreateOpcExceptionActionString(exception))); } }