public static string GetCacheFileName(string accountId, DateTime startOfWeek) { return(string.Format(@"cache\{0}\timetable-{1}.json", accountId, WeekHelper.GetDateStr(startOfWeek))); }
private async Task <(bool TokenExpired, List <Class> Classes)> GetTimetable(DateTime from, DateTime to, string accountId, string token) { try { using (HttpClient client = new HttpClient()) { // Get timetable string _url = "http://portalapp.xjtlu.edu.cn/edu-app/api/userTimeTable/findStudentsTimeTablesById?userId={0}&userType=S&fromDate={1}&toDate={2}"; client.DefaultRequestHeaders.Add("Authorization", token); HttpResponseMessage response = await client.GetAsync(string.Format(_url, accountId, WeekHelper.GetDateStr(from), WeekHelper.GetDateStr(to))); if (response.StatusCode == System.Net.HttpStatusCode.Forbidden) { return(true, null); } if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(false, null); } string responseStr = await response.Content.ReadAsStringAsync(); JObject rootObj = JObject.Parse(responseStr); return(false, rootObj["data"]["timeTables"].ToObject <List <Class> >()); } } catch { return(false, null); } }