/// <summary> /// 加载boundsParams用于计算 /// </summary> /// <returns></returns> private List <AqiParam> loadBoundsParams() { List <AqiParam> apList = new List <AqiParam>(); //扩展参数 List <AqiParam> apListTemp = AqiParam.CreateListFormJson(this, this.Tag, "boundsParams"); //根据 扩展参数 生成最终参数 foreach (AqiParam apTemp in apListTemp) { double lonS = double.Parse(apTemp["lonStart"]); double latS = double.Parse(apTemp["latStart"]); double lonEnd = double.Parse(apTemp["lonEnd"]); double latEnd = double.Parse(apTemp["latEnd"]); double increase = double.Parse(apTemp["increase"]); for (double lon = lonS; lon < lonEnd; lon = lon + increase) { for (double lat = latS; lat < latEnd; lat = lat + increase) { AqiParam ap = new AqiParam("[枚举图块]\\" + apTemp.Name + "\\" + lon.ToString() + "-" + lat.ToString()); //ap.Add("", createurlByLonLat(lon, lat, increase)); ap.Add("lurlv2", apTemp["lurlv2"]); ap.Add("z", apTemp["z"]); ap.Add("bounds", createUrlByLonLat(lon, lat, increase)); apList.Add(ap); } } } return(apList); }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> listParam = new List<AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject jo = JObject.Parse(json); JToken jt = jo.SelectToken("items"); if (!(jt is JArray)) { throw new DataDifferentException("与预期的数据不一致(items属性应该是JSON数组),可能数据源已经发生变化"); } JArray ja = jt as JArray; JEnumerable<JToken> je = ja.Children(); foreach (JToken j in je) { if (!(j is JObject)) { throw new DataDifferentException("与预期的数据不一致(JSON数组子元素应该是对象),可能数据源已经发生变化"); } JObject joOne = j as JObject; JToken jttype = joOne.GetValue("type"); if (jttype.ToString().Equals("1")) { //跳过无效参数 continue; } JToken jtcode = joOne.GetValue("subid"); if (jtcode == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含subid属性),可能数据源已经发生变化"); } string name = jtcode.ToString() + "号站点"; //名称 JToken jtname = joOne.GetValue("pname"); if (jtname != null) { name = name + "-" + jtname; } JToken jtcity = joOne.GetValue("cityName"); if (jtcity != null) { name = name + "-" + jtcity; } AqiParam ap = new AqiParam(name); ap.Add("Method", "GetNjdValue"); ap.Add("StationID", jtcode.ToString()); listParam.Add(ap); } return listParam; }
public List <AqiParam> ParseParam(byte[] data) { List <AqiParam> list = AqiParam.CreateListFormJson(this, this.Tag, AqiParam.PARAMS); List <AqiParam> listParam = new List <AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject jo = JObject.Parse(json); JToken jdata = jo.GetValue("data"); if (!(jdata is JArray)) { throw new DataDifferentException("与预期的数据不一致(JSON对象应该包含data属性),可能数据源已经发生变化"); } JEnumerable <JToken> je = jdata.Children(); foreach (JToken j in je) { if (!(j is JObject)) { throw new DataDifferentException("与预期的数据不一致(JSON数组子元素应该是对象),可能数据源已经发生变化"); } JObject joOne = j as JObject; JToken jcity = joOne.GetValue("xzqdm"); if (jcity == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含xzqdm属性),可能数据源已经发生变化"); } JToken jstationname = joOne.GetValue("zdmc"); if (jstationname == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含zdmc属性),可能数据源已经发生变化"); } JToken jstation = joOne.GetValue("zddm"); if (jstation == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含zddm属性),可能数据源已经发生变化"); } foreach (AqiParam p in list) { AqiParam ap = new AqiParam(p["pollutant"] + @"\" + jstation.ToString() + "-" + jstationname.ToString()); ap.Add("pollutant", p["pollutant"]); ap.Add("timestart", DateTime.Now.AddDays(-1).ToString("yyyyMMddHH0000")); ap.Add("timeend", DateTime.Now.ToString("yyyyMMddHH0000")); ap.Add("citycode", jcity.ToString()); ap.Add("stationcode", jstation.ToString()); listParam.Add(ap); } } return(listParam); }
public List <AqiParam> ParseParam(byte[] data) { List <AqiParam> listParam = new List <AqiParam>(); //XNamespace b = "http://schemas.datacontract.org/2004/07/Env.Publish.Province.DAL"; //XDocument xd = XDocument.Load(new MemoryStream(data)); //IEnumerable<XElement> elements = xd.Descendants(XName.Get("AQICityStation", b.ToString())); //foreach (XElement node in elements) //{ // string name = node.Element(XName.Get("PositionName", b.ToString())).Value; // string id = node.Element(XName.Get("StationID", b.ToString())).Value; // string cityName = node.Element(XName.Get("CityName", b.ToString())).Value; // AqiParam ap = new AqiParam(id + "_" + name); // ap.Add("stationCode", id); // listParam.Add(ap); //} XNamespace b = "http://schemas.datacontract.org/2004/07/Env.Publish.Province.DAL"; XDocument xd = XDocument.Load(new MemoryStream(data)); IEnumerable <XElement> elements = xd.Descendants(XName.Get("AQIDataPublishLive", b.ToString())); foreach (XElement node in elements) { string name = node.Element(XName.Get("PositionName", b.ToString())).Value; string id = node.Element(XName.Get("StationCode", b.ToString())).Value; string cityName = node.Element(XName.Get("Area", b.ToString())).Value; AqiParam ap = new AqiParam(id + "_" + name); ap.Add("stationCode", id); listParam.Add(ap); } return(listParam); }
/// <summary> /// 加载depthsParams用于计算 /// </summary> /// <returns></returns> private List <AqiParam> loadDepthsParams() { List <AqiParam> apList = new List <AqiParam>(); //扩展参数 List <AqiParam> apListTemp = AqiParam.CreateListFormJson(this, this.Tag, "depthsParams"); //根据 扩展参数 生成最终参数 foreach (AqiParam apTemp in apListTemp) { int idS = Int32.Parse(apTemp["yearidStart"]); int idE = Int32.Parse(apTemp["yearidEnd"]); int idD = Int32.Parse(apTemp["yearidDepth"]); for (int yearid = idS; yearid <= idE; yearid++) { int id = yearid % 100; if (id > idD) { yearid = (yearid / 100) * 100 + 101; continue; } AqiParam ap = new AqiParam(apTemp.Name + "\\" + yearid); ap.Add("", yearid.ToString()); apList.Add(ap); } } return(apList); }
public List <AqiParam> ParseParam(byte[] data) { List <AqiParam> listParam = new List <AqiParam>(); string json = Encoding.UTF8.GetString(data); JArray ja = JArray.Parse(json); JEnumerable <JToken> je = ja.Children(); foreach (JToken j in je) { if (!(j is JObject)) { throw new DataDifferentException("与预期的数据不一致(JSON数组子元素应该是对象),可能数据源已经发生变化"); } JObject joOne = j as JObject; JToken jttf = joOne.GetValue("tfid"); if (jttf == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含tfid属性),可能数据源已经发生变化"); } AqiParam ap = new AqiParam(jttf.ToString() + "号台风"); ap.Add("", jttf.ToString()); listParam.Add(ap); } return(listParam); }
public List <AqiParam> ParseParam(byte[] data) { List <AqiParam> listParam = new List <AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject joOne = JObject.Parse(json); JToken jtimg = joOne.GetValue("VisibleImage"); if (jtimg == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含VisibleImage属性),可能数据源已经发生变化"); } if (String.IsNullOrEmpty(jtimg.ToString())) { return(listParam); } string name = jtimg.ToString(); AqiParam ap = new AqiParam(name); ap.Unique = true; ap.Add("", jtimg.ToString()); listParam.Add(ap); return(listParam); }
public List <AqiParam> ParseParam(byte[] data) { List <AqiParam> listParam = new List <AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject ja = JObject.Parse(json); JToken jt = ja.SelectToken("Bodies.[0].Content.headers.DSId"); if (jt == null) { throw new DataDifferentException("与预期的数据不一致(Bodies.[0].Content.headers.DSId应有数据),可能数据源已经发生变化"); } AqiParam ap = new AqiParam("DSId"); ap.Add("DSId", jt.ToString()); listParam.Add(ap); return(listParam); }
/// <summary> /// 加载boundsParams用于计算 /// </summary> /// <returns></returns> private List <AqiParam> loadBoundsParams() { List <AqiParam> apList = new List <AqiParam>(); //扩展参数 List <AqiParam> apListTemp = AqiParam.CreateListFormJson(this, this.Tag, "boundsParams"); //根据 扩展参数 生成最终参数 foreach (AqiParam apTemp in apListTemp) { int yearS = DateTime.Now.Year; int yearE = DateTime.Now.Year; if (apTemp.ContainsKey("yearStart")) { yearS = Int32.Parse(apTemp["yearStart"]); } if (apTemp.ContainsKey("yearEnd")) { yearE = Int32.Parse(apTemp["yearEnd"]); } if (yearS > yearE) { //错误 throw new ParamException("开始年份大于结束年份"); } for (int year = yearS; year <= yearE; year++) { AqiParam ap = new AqiParam(apTemp.Name + "\\" + year.ToString()); ap.Group = apTemp.Group; ap.Add("", year.ToString()); apList.Add(ap); } } return(apList); }
/// <summary> /// 加载boundsParams用于计算 /// </summary> /// <returns></returns> private List<AqiParam> loadBoundsParams() { List<AqiParam> apList = new List<AqiParam>(); //扩展参数 List<AqiParam> apListTemp = AqiParam.CreateListFormJson(this, this.Tag, "boundsParams"); //根据 扩展参数 生成最终参数 foreach (AqiParam apTemp in apListTemp) { int yearS = DateTime.Now.Year; int yearE = DateTime.Now.Year; if (apTemp.ContainsKey("yearStart")) { yearS = Int32.Parse(apTemp["yearStart"]); } if (apTemp.ContainsKey("yearEnd")) { yearE = Int32.Parse(apTemp["yearEnd"]); } if (yearS > yearE) { //错误 throw new ParamException("开始年份大于结束年份"); } for (int year = yearS; year <= yearE; year++) { AqiParam ap = new AqiParam(apTemp.Name + "\\" + year.ToString()); ap.Group = apTemp.Group; ap.Add("", year.ToString()); apList.Add(ap); } } return apList; }
/// <summary> /// 加载boundsParams用于计算 /// </summary> /// <returns></returns> private List<AqiParam> loadBoundsParams() { List<AqiParam> apList = new List<AqiParam>(); //扩展参数 List<AqiParam> apListTemp = AqiParam.CreateListFormJson(this, this.Tag, "boundsParams"); //根据 扩展参数 生成最终参数 foreach (AqiParam apTemp in apListTemp) { double lonS = double.Parse(apTemp["lonStart"]); double latS = double.Parse(apTemp["latStart"]); double lonEnd = double.Parse(apTemp["lonEnd"]); double latEnd = double.Parse(apTemp["latEnd"]); double increase = double.Parse(apTemp["increase"]); for (double lon = lonS; lon < lonEnd; lon = lon + increase) { for (double lat = latS; lat < latEnd; lat = lat + increase) { AqiParam ap = new AqiParam("[枚举图块]\\" + apTemp.Name + "\\" + lon.ToString() + "-" + lat.ToString()); //ap.Add("", createurlByLonLat(lon, lat, increase)); ap.Add("lurlv2", apTemp["lurlv2"]); ap.Add("z", apTemp["z"]); ap.Add("bounds", createUrlByLonLat(lon, lat, increase)); apList.Add(ap); } } } return apList; }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> listParam = new List<AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject ja = JObject.Parse(json); JToken jt = ja.SelectToken("Bodies.[0].Content.headers.DSId"); if (jt == null) { throw new DataDifferentException("与预期的数据不一致(Bodies.[0].Content.headers.DSId应有数据),可能数据源已经发生变化"); } AqiParam ap = new AqiParam("DSId"); ap.Add("DSId", jt.ToString()); listParam.Add(ap); return listParam; }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> listParam = new List<AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject jo = JObject.Parse(json); JToken jt = jo.SelectToken("items"); if (!(jt is JArray)) { throw new DataDifferentException("与预期的数据不一致(items属性应该是JSON数组),可能数据源已经发生变化"); } JArray ja = jt as JArray; JEnumerable<JToken> je = ja.Children(); foreach (JToken j in je) { if (!(j is JObject)) { throw new DataDifferentException("与预期的数据不一致(JSON数组子元素应该是对象),可能数据源已经发生变化"); } JObject joOne = j as JObject; JToken jttype = joOne.GetValue("type"); if (jttype.ToString().Equals("1")) { //跳过无效参数 continue; } JToken jtcode = joOne.GetValue("subid"); if (jtcode == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含subid属性),可能数据源已经发生变化"); } string name = jtcode.ToString() + "号站点"; //名称 JToken jtname = joOne.GetValue("pname"); if (jtname != null) { name = name + "-" + jtname; } JToken jtcity = joOne.GetValue("cityName"); if (jtcity != null) { name = name + "-" + jtcity; } AqiParam ap = new AqiParam(name); ap.Add("Method", "GetNjdValue"); ap.Add("StationID", jtcode.ToString()); listParam.Add(ap); } return listParam; }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> listParam = new List<AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject joOne = JObject.Parse(json); JToken jtimg = joOne.GetValue("VisibleImage"); if (jtimg == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含VisibleImage属性),可能数据源已经发生变化"); } if(String.IsNullOrEmpty(jtimg.ToString())) { return listParam; } string name = jtimg.ToString(); AqiParam ap = new AqiParam(name); ap.Unique = true; ap.Add("", jtimg.ToString()); listParam.Add(ap); return listParam; }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> list = AqiParam.CreateListFormJson(this, this.Tag, AqiParam.PARAMS); List<AqiParam> listParam = new List<AqiParam>(); string json = Encoding.UTF8.GetString(data); JObject jo = JObject.Parse(json); JToken jdata = jo.GetValue("data"); if (!(jdata is JArray)) { throw new DataDifferentException("与预期的数据不一致(JSON对象应该包含data属性),可能数据源已经发生变化"); } JEnumerable<JToken> je = jdata.Children(); foreach (JToken j in je) { if (!(j is JObject)) { throw new DataDifferentException("与预期的数据不一致(JSON数组子元素应该是对象),可能数据源已经发生变化"); } JObject joOne = j as JObject; JToken jcity = joOne.GetValue("xzqdm"); if (jcity == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含xzqdm属性),可能数据源已经发生变化"); } JToken jstationname = joOne.GetValue("zdmc"); if (jstationname == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含zdmc属性),可能数据源已经发生变化"); } JToken jstation = joOne.GetValue("zddm"); if (jstation == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含zddm属性),可能数据源已经发生变化"); } foreach(AqiParam p in list) { AqiParam ap = new AqiParam(p["pollutant"] + @"\" + jstation.ToString() + "-" + jstationname.ToString()); ap.Add("pollutant", p["pollutant"]); ap.Add("timestart", DateTime.Now.AddDays(-1).ToString("yyyyMMddHH0000")); ap.Add("timeend", DateTime.Now.ToString("yyyyMMddHH0000")); ap.Add("citycode", jcity.ToString()); ap.Add("stationcode", jstation.ToString()); listParam.Add(ap); } } return listParam; }
/// <summary> /// 加载depthsParams用于计算 /// </summary> /// <returns></returns> private List<AqiParam> loadDepthsParams() { List<AqiParam> apList = new List<AqiParam>(); //扩展参数 List<AqiParam> apListTemp = AqiParam.CreateListFormJson(this, this.Tag, "depthsParams"); //根据 扩展参数 生成最终参数 foreach (AqiParam apTemp in apListTemp) { int idS = Int32.Parse(apTemp["yearidStart"]); int idE = Int32.Parse(apTemp["yearidEnd"]); int idD = Int32.Parse(apTemp["yearidDepth"]); for (int yearid = idS; yearid <= idE; yearid++) { int id = yearid % 100; if (id > idD) { yearid = (yearid / 100) * 100 + 101; continue; } AqiParam ap = new AqiParam(apTemp.Name + "\\" + yearid); ap.Add("", yearid.ToString()); apList.Add(ap); } } return apList; }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> listParam = new List<AqiParam>(); XNamespace b = "http://schemas.datacontract.org/2004/07/Env.Publish.Province.DAL"; XDocument xd = XDocument.Load(new MemoryStream(data)); IEnumerable<XElement> elements = xd.Descendants(XName.Get("AQICityStation", b.ToString())); foreach (XElement node in elements) { string name = node.Element(XName.Get("PositionName", b.ToString())).Value; string id = node.Element(XName.Get("StationID", b.ToString())).Value; string cityName = node.Element(XName.Get("CityName", b.ToString())).Value; AqiParam ap = new AqiParam(id + "_" + name); ap.Add("stationCode", id); listParam.Add(ap); } return listParam; }
public List<AqiParam> ParseParam(byte[] data) { List<AqiParam> listParam = new List<AqiParam>(); string json = Encoding.UTF8.GetString(data); JArray ja = JArray.Parse(json); JEnumerable<JToken> je = ja.Children(); foreach (JToken j in je) { if (!(j is JObject)) { throw new DataDifferentException("与预期的数据不一致(JSON数组子元素应该是对象),可能数据源已经发生变化"); } JObject joOne = j as JObject; JToken jttf = joOne.GetValue("tfid"); if (jttf == null) { throw new DataDifferentException("与预期的数据不一致(JSON数组对象应该包含tfid属性),可能数据源已经发生变化"); } AqiParam ap = new AqiParam(jttf.ToString() + "号台风"); ap.Add("", jttf.ToString()); listParam.Add(ap); } return listParam; }