public async Task ModifyTrace(INetworkResult results) { //custom tracing behavior await System.Threading.Tasks.Task.Delay(1000); //results TraceResult tr = new TraceResult(); tr.tracedSegmentOids = new List<long>() { 10, 123, 15, 9, 345, 634 }; results.UpdateResult(tr); }
private void AddVersionResultStruct(INetworkResult iNetworkResult) { NetworkResult networkResult = (NetworkResult)iNetworkResult; foreach (var netResult in networkResult.NetVersionResultStruct) { m_NetVersionDataDic.Add(netResult.Key, netResult.Value); } }
public async Task ModifyTrace(INetworkResult results) { //custom tracing behavior await System.Threading.Tasks.Task.Delay(1000); //results TraceResult tr = new TraceResult(); tr.tracedSegmentOids = new List <long>() { 10, 123, 15, 9, 345, 634 }; results.UpdateResult(tr); }
/// <summary> /// 添加设备 /// </summary> /// <param name="device_id"></param> /// <param name="result"></param> public void AddDevice(string device_id, INetworkResult result) { // client.Authenticator = new HttpBasicAuthenticator(username, password); var request = new RestRequest("devices/{device_id}", Method.GET); request.AddUrlSegment("device_id", device_id); // replaces matching token in request.Resource // add parameters for all properties on an object //request.AddObject(object); // or just whitelisted properties //request.AddObject(object, "PersonId", "Name", ...); // easily add HTTP Headers request.AddHeader("api-key", "VtaeS4yK3Fk6xiOljgw69lYcH9k="); IRestResponse response = client.Execute(request); var content = response.Content; // raw content as string if (response.ResponseStatus == ResponseStatus.Completed) { Device device = JsonHelper.DeserializeJsonToObject <Device>(content); if (device.error.Equals("succ")) { DeviceDataDao.Instance.Insert(device.data); RemarksDao.Instance.Insert(device.data); GetLatestPoint(device.data, result); } else { result.OnFailure(device.error); } } else { result.OnFailure("获取设备信息失败"); } }
private List<TreeNode> GenerateNetworkSnapshotNodes(INetworkResult networkResult, StyleStruct ss) { List<TreeNode> list = new List<TreeNode>(); List<string> snapshots = networkResult.GetSnapshots(); foreach (string text in snapshots) { TreeNode parentNode = new TreeNode(); parentNode.Text = text; parentNode.Name = text; parentNode.ContextMenuStrip = this.m_ContextMenuView.SnapShotContextMenuStrip; parentNode.ImageKey = "SimulationSnapshot"; parentNode.SelectedImageKey = "SimulationSnapshot"; parentNode.StateImageIndex = 1; List<TreeNode> childNodes = this.GenerateStyleNodes(ss); this.AddMulitNodes(parentNode, childNodes); list.Add(parentNode); } return list; }
/// <summary> /// 获取绘制图表的数据点 /// </summary> /// <param name="deviceData"></param> /// <param name="result"></param> public void GetDataPoints(ItemPoint deviceData, INetworkResult result, string datastream_id, string limit, string start, string end, string cursor, string duration) { // client.Authenticator = new HttpBasicAuthenticator(username, password); var request = new RestRequest("devices/{device_id}/datapoints", Method.GET); request.AddUrlSegment("device_id", deviceData.deviceId); // replaces matching token in request.Resource // add parameters for all properties on an object //request.AddObject(object); // or just whitelisted properties //request.AddObject(object, "PersonId", "Name", ...); // easily add HTTP Headers request.AddHeader("api-key", "VtaeS4yK3Fk6xiOljgw69lYcH9k="); if (!string.IsNullOrEmpty(datastream_id)) { request.AddParameter("datastream_id", datastream_id); } if (!string.IsNullOrEmpty(limit)) { request.AddParameter("limit", limit); } if (!string.IsNullOrEmpty(start)) { request.AddParameter("start", start); } if (!string.IsNullOrEmpty(end)) { request.AddParameter("end", end); } if (!string.IsNullOrEmpty(cursor)) { request.AddParameter("cursor", cursor); } if (!string.IsNullOrEmpty(duration)) { request.AddParameter("duration", duration); } IRestResponse response = client.Execute(request); var content = response.Content; // raw content as string if (response.ResponseStatus == ResponseStatus.Completed) { AppPoint point = JsonHelper.DeserializeJsonToObject <AppPoint>(content); if (point.error.Equals("succ")) { ItemPoint item = new ItemPoint { deviceId = deviceData.deviceId, title = deviceData.title }; StringBuilder builder = new StringBuilder(); foreach (DataStreams dataStream in point.data.datastreams) { RemarksID remarksID = RemarksDao.Instance.GetDeviceDataById(item.deviceId + dataStream.id); foreach (DataPoints dataPoints in dataStream.datapoints) { dataPoints.at = dataPoints.at.Substring(0, dataPoints.at.Length - 4); } if (dataStream.id.Equals("P") || dataStream.id.Equals("T") || dataStream.id.Equals("H")) { //只获取最新的一个点在列表里显示 bool m = false; foreach (DataPoints dataPoints in dataStream.datapoints) { if (m) { break; } if (remarksID == null || string.IsNullOrEmpty(remarksID.remarks)) { builder.Append(dataStream.id + "=" + dataPoints.value); } else { builder.Append(remarksID.remarks + "=" + dataPoints.value); } foreach (DeviceDataStreams stream in deviceData.deviceDatastreams) { if (dataStream.id.Equals(stream.id)) { builder.Append(stream.unit + " "); m = true; break; } } } } } item.dataStreamsList = point.data.datastreams; item.deviceDatastreams = deviceData.deviceDatastreams; item.dataStrams = builder.ToString(); result.OnSuccess(item); } else { result.OnFailure(point.error); } } else { result.OnFailure("获取" + deviceData.title + "的数据失败"); } }