private string AppendIncludedChildInfoString(string baseUrlStr, SenslinkInfoTypes includedChildInfos) { if (includedChildInfos == SenslinkInfoTypes.None) { return(baseUrlStr); } IEnumerable <SenslinkInfoTypes> types = System.Enum.GetValues(typeof(SenslinkInfoTypes)).OfType <SenslinkInfoTypes>(); StringBuilder sb = new StringBuilder($"{baseUrlStr}/{{"); foreach (SenslinkInfoTypes cunType in types) { if (cunType == SenslinkInfoTypes.None) { continue; } if (includedChildInfos.HasFlag(cunType)) { sb.Append($"{cunType.ToString()}|"); } } sb.Remove(sb.Length - 1, 1); sb.Append("}"); return(sb.ToString()); }
/// <summary> /// 6.5.1 ~ 6.5.2 /// </summary> /// <param name="includedChildInfos"></param> /// <returns></returns> public HttpStatusCode StationGroupGetAll(out IEnumerable <StationGroupInfo> stationGroupInfos, SenslinkInfoTypes includedChildInfos) { string resposeString = string.Empty; StringBuilder sb = new StringBuilder("StationGroup/Get/All"); if (includedChildInfos != SenslinkInfoTypes.None) { bool isFirstChild = true; sb.Append("/{"); if (includedChildInfos.HasFlag(SenslinkInfoTypes.PhysicalQuantity)) { sb.Append("PhysicalQuantity"); isFirstChild = false; } if (includedChildInfos.HasFlag(SenslinkInfoTypes.Category)) { if (!isFirstChild) { sb.Append("|"); } sb.Append("Category"); isFirstChild = false; } sb.Append("}"); } HttpStatusCode resultCode = HttpGet(sb.ToString(), out resposeString); stationGroupInfos = null; if (resultCode == HttpStatusCode.OK) { JArray stationGroupJArray = JArray.Parse(resposeString); JToken[] stationGroupTokens = stationGroupJArray.ToArray(); List <StationGroupInfo> parsedStationGroupInfos = new List <StationGroupInfo>(); foreach (JToken stationGroupToken in stationGroupTokens) { StationGroupInfo cunInfo = stationGroupToken.ToObject <StationGroupInfo>(); parsedStationGroupInfos.Add(cunInfo); } stationGroupInfos = parsedStationGroupInfos.ToList(); } return(resultCode); }
public HttpStatusCode StationGroupGet(out StationGroupInfo stationGroupInfo, Guid id, SenslinkInfoTypes includedChildInfos) { string resposeString = string.Empty; StringBuilder sb = new StringBuilder($"StationGroup/Get/{id.ToString()}"); if (includedChildInfos != SenslinkInfoTypes.None) { bool isFirstChild = true; sb.Append("/{"); if (includedChildInfos.HasFlag(SenslinkInfoTypes.PhysicalQuantity)) { sb.Append("PhysicalQuantity"); isFirstChild = false; } if (includedChildInfos.HasFlag(SenslinkInfoTypes.Category)) { if (!isFirstChild) { sb.Append("|"); } sb.Append("Category"); isFirstChild = false; } sb.Append("}"); } HttpStatusCode resultCode = HttpGet(sb.ToString(), out resposeString); stationGroupInfo = null; if (resultCode == HttpStatusCode.OK) { JToken stationGroupToken = JToken.Parse(resposeString); stationGroupInfo = stationGroupToken.ToObject <StationGroupInfo>(); } return(resultCode); }