示例#1
0
        public int SendHello()
        {
            if (sipclient == null || !sipclient.Connected())
            {
                return(ErrorCode.DisConnectedWithLibraryServer);
            }

            int result;

            try
            {
                SipTransaction st  = sipclient.SendHello();
                string         msg = st.Response;
                result = ErrorCode.Success;
            }
            catch (Exception exception)
            {
                if (exception.InnerException.GetType() == typeof(SocketException))
                {
                    //logger.Error("Send hello to library server failed.");
                    //logger.Error(exception.ToString());
                    sipclient.Close();
                }
                result = ErrorCode.ServerException;
            }

            return(result);
        }
示例#2
0
        public int MakeAnAppointment(string readerBarcode, string bookBarcode)
        {
            if (sipclient == null || !sipclient.Connected())
            {
                return(ErrorCode.DisConnectedWithLibraryServer);
            }

            int result;

            try
            {
                SipTransaction st  = sipclient.MakeAnAppointment(readerBarcode, bookBarcode);
                string         msg = st.Response;
                if (msg.StartsWith(Sip2Common.RenewAllResponse) && msg.EndsWith(Sip2Common.EndOfMessage) &&
                    CheckMessage(msg))
                {
                    result = ErrorCode.Success;
                }
                else
                {
                    result = ErrorCode.InvalidMessage;
                }
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString());
                result = ErrorCode.ServerException;
            }

            return(result);
        }
示例#3
0
        public int ReaderStatus(string readerBarcode, string readerPIN = "")
        {
            if (sipclient == null || !sipclient.Connected())
            {
                return(ErrorCode.DisConnectedWithLibraryServer);
            }

            int result;

            try
            {
                SipTransaction st  = sipclient.PatronStatus(readerBarcode, readerPIN);
                string         msg = st.Response;
                if (msg.StartsWith(Sip2Common.PatronStatusResponse) && msg.EndsWith(Sip2Common.EndOfMessage) &&
                    CheckMessage(msg))
                {
                    result = ErrorCode.Success;
                }
                else
                {
                    result = ErrorCode.InvalidMessage;
                }
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString);
                result = ErrorCode.ServerException;
            }

            return(result);
        }
示例#4
0
        /// <summary>
        /// 还书
        /// </summary>
        /// <param name="bookBarcode">书籍条码</param>
        public int BookCheckIn(string bookBarcode, ref string message, ref string readerCode)
        {
            if (sipclient == null || !sipclient.Connected())
            {
                return(ErrorCode.DisConnectedWithLibraryServer);
            }

            int result;

            try
            {
                SipTransaction st  = sipclient.ItemCheckIn(bookBarcode);
                string         msg = st.Response;
                if (!msg.StartsWith(Sip2Common.CheckinResponse) || !msg.EndsWith(Sip2Common.EndOfMessage) ||
                    !CheckMessage(msg))
                {
                    result = ErrorCode.InvalidMessage;
                }
                else
                {
                    result = ErrorCode.Failed;
                    string[] m = msg.Split('|');
                    foreach (string s in m)
                    {
                        switch (s.Substring(0, 2))
                        {
                        case ScreenMessage:
                            message = s.Substring(2);
                            break;

                        case PatronIdentifier:
                            readerCode = s.Substring(2, s.Length - 2);
                            break;

                        case CheckinResponse:
                            if (s.Substring(2, 1) == "1")
                            {
                                result = ErrorCode.Success;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString());
                result = ErrorCode.ServerException;
            }

            return(result);
        }
示例#5
0
        public string BookCheckIn(string bookBarcode)
        {
            string result = "发送失败,请先连接Sip2服务器!";

            if (sipclient == null || !sipclient.Connected())
            {
                return(result);
            }
            try
            {
                SipTransaction st = sipclient.ItemCheckIn(bookBarcode);
                result = st.Response;
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString());
            }
            return(result);
        }
示例#6
0
        public string Login2(string uid, string pwd, string locationCode, string vp)
        {
            string result = "发送失败,请先连接Sip2服务器!";

            if (sipclient == null || !sipclient.Connected())
            {
                return(result);
            }
            try
            {
                SipTransaction st = sipclient.Login(uid, pwd, locationCode, vp);
                result = st.Response;
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString());
            }
            return(result);
        }
示例#7
0
        /// <summary>
        /// 暂无此功能,获取读者排行榜中读者的书籍信息
        /// </summary>
        /// <param name="patronBarcode"></param>
        /// <returns></returns>
        public int ItemOfPatron(string patronBarcode)
        {
            if (sipclient == null || !sipclient.Connected())
            {
                return(ErrorCode.DisConnectedWithLibraryServer);
            }

            SipTransaction st  = sipclient.ItemOfPatron(patronBarcode);
            string         msg = st.Response;

            if (msg.StartsWith(Sip2Common.RenewAllResponse) && msg.EndsWith(Sip2Common.EndOfMessage) &&
                CheckMessage(msg))
            {
            }
            else
            {
                return(ErrorCode.InvalidMessage);
            }

            return(ErrorCode.Success);
        }
示例#8
0
        public string ReaderInformation(string readerBarcode, string readerPIN, string type)
        {
            string result = "发送失败,请先连接Sip2服务器!";

            if (sipclient == null || !sipclient.Connected())
            {
                return(result);
            }

            try
            {
                SipTransaction st = sipclient.PatronInformation(readerBarcode, readerPIN, string.IsNullOrEmpty(type) ? "none" : type);
                result = st.Response;
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString());
            }

            return(result);
        }
示例#9
0
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="pwd"></param>
        public int Login(string uid, string pwd)
        {
            if (sipclient == null || !sipclient.Connected())
            {
                return(ErrorCode.DisConnectedWithLibraryServer);
            }

            int result = 0;

            try
            {
                SipTransaction st  = sipclient.Login(uid, pwd, locationCode, VP);
                string         msg = st.Response;
                if (msg.StartsWith(Sip2Common.LoginResponse))
                {
                    char ok = msg.ElementAt(2);
                    if (ok == '1')
                    {
                        result = ErrorCode.Success;
                    }
                    else
                    {
                        result = ErrorCode.LoginLibraryServerFailed;
                    }
                }
                else
                {
                    //logger.Debug("Response message: " + msg);
                    result = ErrorCode.InvalidMessage;
                }
            }
            catch (Exception exception)
            {
                //logger.Error(exception.ToString());
                result = ErrorCode.ServerException;
            }

            return(result);
        }