public SpydusUser(string username, string password, string affiliate) { _affiliate = affiliate; var request = WebRequest.CreateHttp($"https://{_affiliate}.spydus.co.uk/cgi-bin/spydus.exe/PGM/OPAC/CCOPT/LB/2"); request.Method = "POST"; using (var stream = new StreamWriter(request.GetRequestStream())) { stream.WriteLine($"BRWLID={username}&BRWLPWD={password}&ISGLB=1&RDT=%2Fcgi-bin%2Fspydus.exe%2FMSGTRN%2FOPAC%2FBSEARCH%3FHOMEPRMS%3DGENPARAMS"); } request.CookieContainer = _cookies; var response = request.GetResponse(); var cookies = ((HttpWebResponse)response).Cookies; _brwlscn_443 = cookies["BRWLSCN_443"].Value; _brwl_443 = cookies["BRWL_443"].Value; _cookies.Add(cookies); _enquiryId = GetEnquiryId(); _books = GetCheckedOutBooks(); }
public void RenewAll() { if (_renewAllLink == null || _renewSelectionLink == null) { var books = GetCheckedOutBooks(); _renewAllLink = books.RenewAllLink; _renewSelectionLink = books.RenewSelectionLink; } var request = WebRequest.CreateHttp($"https://{_affiliate}.spydus.co.uk/cgi-bin/spydus.exe/PGM/OPAC/RFN"); request.Method = "POST"; request.CookieContainer = _cookies; using (var stream = new StreamWriter(request.GetRequestStream())) { stream.WriteLine($"RFN%5DRNWALL=&RNWSEL={WebUtility.HtmlEncode(_renewSelectionLink)}&RNWALL={WebUtility.HtmlEncode(_renewAllLink)}&NREC=0"); } var response = request.GetResponse(); var body = response.GetResponseBody(); _books = GetBooksFromHtml(body); }
public void RenewBooks(params Book[] books) { var request = WebRequest.CreateHttp($"https://{_affiliate}.spydus.co.uk/cgi-bin/spydus.exe/PGM/OPAC/RFN"); request.Method = "POST"; request.CookieContainer = _cookies; var concatenatedIds = books.Select(book => "&" + book.RenewId).Aggregate((s1, s2) => s1 + s2); using (var stream = new StreamWriter(request.GetRequestStream())) { stream.WriteLine($"RFN%5DRNWSEL=&RNWSEL={WebUtility.HtmlEncode(_renewSelectionLink)}&RNWALL={WebUtility.HtmlEncode(_renewAllLink)}{concatenatedIds}"); } var response = request.GetResponse(); var body = response.GetResponseBody(); _books = GetBooksFromHtml(body); }