/// <summary> /// Authorizes patron barcode against the SIP server. /// </summary> /// <param name="barcode">Barcode of the patron.</param> /// <returns>Return true if authorization is successful. Returns false if bardcode failed to authorize.</returns> public bool AuthorizeBarcode(string barcode) { Patron patron = new Patron(); string PatronInformationResponse = String.Empty; if (connected) { string date = GetDateString(); string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD|BP|BQ|", date, barcode, sip.password); PatronInformationResponse = SipFactory(sipCommand); patron.PatronParse(PatronInformationResponse); if (patron.Authorized) { // All good. authorized = true; return(authorized); } else { // Blocked or excessive fines. Also could be an invalid barcode. authorized = false; return(authorized); } } else { throw new NotConnectedException("SIP server connection is not established. Failed to authorize barcode."); } }
/// <summary> /// Authorizes patron barcode against the SIP server. This is should be used for especially for public facing implementations of SIP2. /// </summary> /// <param name="barcode">Barcode of the patron.</param> /// <param name="patron">Instance of the patron class. This will be popluated with a human-readable break down of the Patron Response Message from the SIP server.</param> /// <param name="failureResponse">Reason, if any, that a card failed to authorize.</param> /// <returns>Return true if authorization is successful. Returns false if bardcode failed to authorize.</returns> public bool AuthorizeBarcode(string barcode, ref Patron patron, ref string failureResponse) { patron = new Patron(); string response = String.Empty; if (connected) { string date = GetDateString(); string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD|BP|BQ|", date, barcode, sip.password); response = SipFactory(sipCommand); patron.PatronParse(response); if ((patron.Authorized) & (patron.Fines < patron.FineLimit)) { failureResponse = ""; authorized = true; return(authorized); } else { failureResponse = "There seems to be a problem with your card. Please see a librarian!"; authorized = false; return(authorized); } } else { throw new NotConnectedException("Server is currently unavailable. Please see a librarian!"); } }
public bool PatronHome(string barcode) { bool result = false; Patron patron = new Patron(); string response = String.Empty; if (connected) { string date = GetDateString(); string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD|BP|BQ", date, barcode, this.password); response = sipFactory(sipCommand); patron.PatronParse(response); if (patron.Type != "" && patron.Type != null) if (patron.Type.ToUpper().Contains("RECIPROCAL")) result = true; return result; } else throw new NotConnectedException("Server is currently unavailable. Please see a librarian!"); }
//Returns "YES" on successful, no bars //If no need for descriptive responses a simple bool would do fine here public string AuthorizeBarcode(string barcode, string pin = "") { string result = ""; Patron patron = new Patron(); string response = String.Empty; if (connected) { string date = GetDateString(); //string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD{3}|BP|BQ", date, barcode, this.password, pin); string sipCommand = string.Format("63001{0} AO1|AA{1}|AD{3}|BP|BQ", date, barcode, this.password, pin); response = sipFactory(sipCommand); patron.PatronParse(response); string expire = patron.Expiry; DateTime exdate = DateTime.ParseExact(expire, "yyyyMMdd", CultureInfo.InvariantCulture); if ((patron.Pin == "Y")) { result = "YES"; if (patron.Message != null && patron.Message.ToUpper() == "BLOCKED") result = "BLOCKED"; if (patron.Fines > 10) result = "FINES"; if (expire != "") if (exdate < DateTime.Now) result = "EXPIRED"; } else result = "NO"; return result; } else { throw new NotConnectedException("Server is currently unavailable. Please see a librarian!"); } }
public Dictionary<string, string> PatronData(string barcode) { var patronArray = new Dictionary<string, string>(); Patron patron = new Patron(); string response = String.Empty; if (connected) { string date = GetDateString(); string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD|BP|BQ", date, barcode, this.password); response = sipFactory(sipCommand); patron.PatronParse(response); patronArray.Add("name", patron.Name); patronArray.Add("email", patron.Email); patronArray.Add("phone", patron.Phone); patronArray.Add("expiry", patron.Expiry); patronArray.Add("auth", patron.Authorized.ToString()); patronArray.Add("fines", patron.Fines.ToString()); patronArray.Add("inst", patron.InstitutionId); patronArray.Add("message", patron.Message); patronArray.Add("type", patron.Type); patronArray.Add("address", patron.Address); patronArray.Add("home", patron.Home); patronArray.Add("HoldCount", patron.HoldCount); patronArray.Add("OverdueCount", patron.OverdueCount); patronArray.Add("CheckOutCount", patron.CheckOutCount); patronArray.Add("FineItemsCount", patron.FinedItemCount); patronArray.Add("RecallItemCount", patron.RecallItemCount); patronArray.Add("UnavailableHoldCount", patron.UnavailableHoldCount); return patronArray; } else { throw new NotConnectedException("Server is currently unavailable. Please see a librarian!"); } }
/// <summary> /// Authorizes patron barcode against the SIP server. /// </summary> /// <param name="barcode">Barcode of the patron.</param> /// <returns>Return true if authorization is successful. Returns false if bardcode failed to authorize.</returns> public bool AuthorizeBarcode(string barcode) { Patron patron = new Patron(); string PatronInformationResponse = String.Empty; if (connected) { string date = GetDateString(); string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD|BP|BQ|", date, barcode, sip.password); PatronInformationResponse = SipFactory(sipCommand); patron.PatronParse(PatronInformationResponse); if (patron.Authorized) { // All good. authorized = true; return authorized; } else { // Blocked or excessive fines. Also could be an invalid barcode. authorized = false; return authorized; } } else { throw new NotConnectedException("SIP server connection is not established. Failed to authorize barcode."); } }
/// <summary> /// Authorizes patron barcode against the SIP server. This is should be used for especially for public facing implementations of SIP2. /// </summary> /// <param name="barcode">Barcode of the patron.</param> /// <param name="patron">Instance of the patron class. This will be popluated with a human-readable break down of the Patron Response Message from the SIP server.</param> /// <param name="failureResponse">Reason, if any, that a card failed to authorize.</param> /// <returns>Return true if authorization is successful. Returns false if bardcode failed to authorize.</returns> public bool AuthorizeBarcode(string barcode, ref Patron patron, ref string failureResponse) { patron = new Patron(); string response = String.Empty; if (connected) { string date = GetDateString(); string sipCommand = string.Format("63001{0} AO1|AA{1}|AC{2}|AD|BP|BQ|", date, barcode, sip.password); response = SipFactory(sipCommand); patron.PatronParse(response); if ((patron.Authorized) & (patron.Fines < patron.FineLimit)) { failureResponse = ""; authorized = true; return authorized; } else { failureResponse = "There seems to be a problem with your card. Please see a librarian!"; authorized = false; return authorized; } } else { throw new NotConnectedException("Server is currently unavailable. Please see a librarian!"); } }
//Takes in type of call with credentials and queries for a list of items for said patron dependent on type public List<string> PatronItemList(string typeOfCall, string barcode, string pin = "") { Patron patron = new Patron(); string response = String.Empty; string sipType = ""; List<string> ListedItems = new List<string>(); List<string> Items = new List<string>(); if (connected) { switch (typeOfCall) { case "holds": sipType = holdsIdentifier; break; case "overdues": sipType = overdueIdentifier; break; case "charges": sipType = chargedIdentifier; break; case "fines": sipType = finedIdentifier; break; case "recalls": sipType = recallIdentifier; break; case "unaholds": sipType = unaHoldsIdentifier; break; } string date = GetDateString(); string sipCommand = string.Format("63001{0}{4} AO|AA{1}|AD{3}", date, barcode, this.password, pin, sipType); response = sipFactory(sipCommand); patron.PatronParse(response); switch (typeOfCall) { case "holds": Items = patron.HoldItems; break; case "overdues": Items = patron.OverdueItems; break; case "charges": Items = patron.ChargedItems; break; case "fines": Items = patron.FinedItems; break; case "recalls": Items = patron.RecallItems; break; case "unaholds": Items = patron.UnHoldItems; break; } foreach (var h in Items) if (h != "") ListedItems.Add(h); return ListedItems; } else throw new NotConnectedException("Server is currently unavailable. Please see a librarian!"); }