示例#1
0
 /**************************************************
  *
  *      Public Methods
  *
  **************************************************/
 public bool AuthorizeSip(string barcode)
 {
     try
     {
         if (CurrentApplicationData.SipEnabled)
         {
             SipConnection sip = new SipConnection(CurrentApplicationData.SipIP, CurrentApplicationData.SipPort, CurrentApplicationData.SipUsername, CurrentApplicationData.SipPassword, CurrentApplicationData.SipExtraNumber);
             sip.Open();
             bool authorized = sip.AuthorizeBarcode(barcode);
             sip.Dispose();
             LogStatistics();
             return authorized;
         }
         else return false;
     }
     catch (Exception ex)
     {
         ErrorLog.LogError(DateTime.Now.ToString() + " : Could not connect to SIP server!", ex.Message);
         return false;
     }
 }
示例#2
0
 /****************************************************************
  *      Barcode Scanner Functions                               *
  ****************************************************************/
 public static bool authorizeBarcode(string barcode)
 {
     SipConnection sip = new SipConnection("", "", "", "");
     sip.Open();
     return sip.AuthorizeBarcode(barcode);
 }
示例#3
0
 public static Patron getPatronInfo(string barcode)
 {
     Patron patron = new Patron();
     try
     {
         string failureResponse = String.Empty;
         SipConnection sip = new SipConnection("");
         sip.Open();
         sip.AuthorizeBarcode(barcode, ref patron, ref failureResponse);
     }
     catch (Exception)
     {
         return new Patron { Pin = "-1", Name = "Could not access patron information at this time." };
     }
     return patron;
 }
        private void btnSubmitSIP_Click(object sender, EventArgs e)
        {
            Button ButtonDown = (Button)sender;
            if (chkSipEnabled.Checked)
            {
                if (AllBoxesFilledIn(ButtonDown.Parent))
                {
                    SipServerParameters SipParams = new SipServerParameters();
                    SipParams.ip = txtSipIP1.Text + "." + txtSipIP2.Text + "." + txtSipIP3.Text + "." + txtSipIP4.Text;
                    SipParams.port = txtSipPort.Text;
                    SipParams.username = txtSipUsername.Text;
                    SipParams.password = txtSipPassword.Text;
                    SipParams.extra_number = txtSipExtraNumber.Text;
                    try
                    {
                        using (SipConnection sip = new SipConnection(SipParams))
                        {
                            try
                            {
                                if (sip.TestConnection())
                                {
                                    ServerData.SipIP = SipParams.ip;
                                    ServerData.SipPort = SipParams.port;
                                    ServerData.SipUsername = SipParams.username;
                                    ServerData.SipPassword = SipParams.password;
                                    ServerData.SipExtraNumber = SipParams.extra_number;
                                    ServerData.SipEnabled = chkSipEnabled.Checked;
                                    HideAndDisplay(ButtonDown);
                                }
                                else
                                {
                                    MessageBox.Show("Could not connect to the SIP server!  If you do not wish to enter your SIP settings now, remove the checkmark for 'enabled'. You can reeanable SIP and add your credentials later through the administration interface.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + ".  If you do not wish to enter your SIP settings now, remove the checkmark for 'enabled'. You can reeanable SIP and add your credentials later through the administration interface.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                         }
                    }
                    catch (Exception) { }
                }
            }
            else
            {
                DialogResult diag = MessageBox.Show("You have chosen to disable SIP.  Are you sure?  SIP can be reenabled later through the administrator interface.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (diag == DialogResult.Yes)
                {
                    ServerData.SipIP = "0.0.0.0";
                    ServerData.SipPort = "6001";
                    ServerData.SipUsername = "******";
                    ServerData.SipPassword = "******";
                    ServerData.SipExtraNumber = "1";
                    ServerData.SipEnabled = chkSipEnabled.Checked;
                    HideAndDisplay(ButtonDown);
                }
            }
        }