public List<List<string>> GetEDiary() { string response = TryAuthorize(); if (!response.Contains("Access is forbidden") && !response.Contains("Доступ запрещен") && response != null) { User user = new User(); Dictionary<string, string> data = user.GetUserData(); return GetEDiaryInternal(data["LOGIN"], data["GROUP"], data["UNIVER"], data["APPRENTICESHIP"], data["INTERVAL"]); } return null; }
public bool GetUserInfo(string login, string password) { string response = TryAuthorize(login, password); if (!response.Contains("Access is forbidden") && !response.Contains("Доступ запрещен") && response != null) { response = MakeRequest("GET", DE_IFMO_RU_UserInfo, ref DE_IFMO_Cookies); response = Regex.Replace(response, @"(<[^>]*>)|(\n{1,})|(\s{1,})", " "); string userData = response.Substring(response.IndexOf("Фамилия"), response.IndexOf("E-mail") - response.IndexOf("Фамилия")); string[] dataArray = userData.Trim().Split(' '); string initials = String.Format("{0} {1} {2}", dataArray[1], dataArray[3], dataArray[5]); string sex = dataArray[7]; string birth = dataArray[11]; string group = dataArray[dataArray.Length - 1]; response = MakeRequest("GET", DE_IFMO_RU_EDiary_Page, ref DE_IFMO_Cookies); string match = Regex.Matches(response, "UNIVER"\\sValue=.*([0-9]{1})"")[0].Value; string univer = match.Substring(match.LastIndexOf(';') + 1, 1); User currentUser = new User(login, password, initials, sex, group, birth, univer); success = true; return true; } success = false; return false; }
private string TryAuthorize() { User user = new User(); Dictionary<string, string> userData = new Dictionary<string, string>(); userData = user.GetUserData(); DE_IFMO_Cookies = new CookieContainer(); string data = String.Format("Rule=LOGON&LOGIN={0}&PASSWD={1}", userData["LOGIN"], userData["PASSWD"]); string response = MakeRequest("POST", DE_IFMO_RU, ref DE_IFMO_Cookies, data); return response; }