예제 #1
0
 /// <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.");
     }
     
 }
예제 #2
0
 /// <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!");
     }
 }