public async Task<Archive> GetNewestArchiveAsync(string market) { using (HttpClient client = CreateClient()) { var where = new { market = market }; string requestUri = $"{URLBASE}/1.1/classes/Archive?where={WebUtility.UrlEncode(JsonConvert.SerializeObject(where))}&order=-date&limit=1"; return (await client.GetJsonAsync<LeanCloudResultCollection<Archive>>(new Uri(requestUri))).FirstOrDefault(); } }
public async Task<LeanCloudResultCollection<Archive>> GetArchivesAsync(int year, int month, string market) { using (HttpClient client = CreateClient()) { var where = new { market = market, date = new Dictionary<string, string> { { "$regex", @"\Q" + new DateTime(year,month,1).ToString("yyyyMM") + @"\E" } } }; string requestUri = $"{URLBASE}/1.1/classes/Archive?where={WebUtility.UrlEncode(JsonConvert.SerializeObject(where))}&order=-date"; return await client.GetJsonAsync<LeanCloudResultCollection<Archive>>(new Uri(requestUri)); } }
public async Task<LeanCloudResultCollection<Archive>> GetArchivesAsync(int year, int month, string market) { var where = new { market = market, date = new Dictionary<string, string> { { "$regex", @"\Q" + new DateTime(year,month,1).ToString("yyyyMM") + @"\E" } } }; string requestUri = $"{URLBASE}/1.1/classes/Archive?where={WebUtility.UrlEncode(JsonConvert.SerializeObject(where))}&order=-date"; string json; if (DataCache.ContainsKey(requestUri) && DataCache[requestUri].IsUseable()) { json = DataCache[requestUri].Json; } else { using (HttpClient client = CreateClient()) { var requestTime = DateTime.Now; json = await client.GetStringAsync(new Uri(requestUri)); DataCache[requestUri] = new JsonResultCache() { Json = json, RequestTime = requestTime }; } } return JsonConvert.DeserializeObject<LeanCloudResultCollection<Archive>>(json); }
public async Task<LeanCloudResultCollection<Image>> GetImagesAsync(string[] objectIds) { if (objectIds == null) { throw new ArgumentNullException(nameof(objectIds)); } if (objectIds.Length == 0) { return new LeanCloudResultCollection<Image>(); } var where = new { objectId = new Dictionary<string, string[]> { { "$in", objectIds } } }; string requestUri = $"{URLBASE}/1.1/classes/Image?where={WebUtility.UrlEncode(JsonConvert.SerializeObject(where))}&order=-updatedAt"; string json; if (DataCache.ContainsKey(requestUri) && DataCache[requestUri].IsUseable()) { json = DataCache[requestUri].Json; } else { using (HttpClient client = CreateClient()) { var requestTime = DateTime.Now; json = await client.GetStringAsync(new Uri(requestUri)); DataCache[requestUri] = new JsonResultCache() { Json = json, RequestTime = requestTime }; } } return JsonConvert.DeserializeObject<LeanCloudResultCollection<Image>>(json); }