Exemple #1
0
        private long GetItemInfo(string dp2mserverUrl,
                                 string remoteUserName,
                                 string biblioPath,
                                 out string itemList,
                                 out string strError)
        {
            itemList = "";
            strError = "";

            CancellationToken cancel_token = new CancellationToken();
            string            id           = "2-item";               // Guid.NewGuid().ToString();
            SearchRequest     request      = new SearchRequest(id,
                                                               null, // TODO
                                                               "getItemInfo",
                                                               "entity",
                                                               biblioPath,
                                                               "",
                                                               "",
                                                               "",
                                                               "opac",
                                                               10,
                                                               0,
                                                               -1);

            try
            {
                MessageConnection connection = this._channels.GetConnectionTaskAsync(
                    dp2mserverUrl,
                    remoteUserName).Result;

                SearchResult result = null;
                try
                {
                    result = connection.SearchTaskAsync(
                        remoteUserName,
                        request,
                        new TimeSpan(0, 1, 0),
                        cancel_token).Result;
                }
                catch (Exception ex)
                {
                    strError = "检索出错:[SearchAsync异常]" + ex.Message;
                    return(-1);
                }

                if (result.ResultCount == -1)
                {
                    strError = "检索出错:" + result.ErrorInfo;
                    return(-1);
                }
                if (result.ResultCount == 0)
                {
                    strError = "未命中";
                    return(0);
                }

                for (int i = 0; i < result.Records.Count; i++)
                {
                    string      xml = result.Records[i].Data;
                    XmlDocument dom = new XmlDocument();
                    dom.LoadXml(xml);

                    string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode");
                    string strRefID   = DomUtil.GetElementText(dom.DocumentElement, "refID");
                    // 册条码号
                    string strViewBarcode = "";
                    if (string.IsNullOrEmpty(strBarcode) == false)
                    {
                        strViewBarcode = strBarcode;
                    }
                    else
                    {
                        strViewBarcode = "refID:" + strRefID;  //"@refID:"
                    }
                    itemList += strViewBarcode + "\n";
                }

                return(result.Records.Count);
            }
            catch (AggregateException ex)
            {
                strError = MessageConnection.GetExceptionText(ex);
                goto ERROR1;
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                goto ERROR1;
            }
ERROR1:
            return(-1);
        }
Exemple #2
0
        private int GetBiblioSummary(string dp2mserverUrl,
                                     string remoteUserName,
                                     string biblioPath,
                                     out string summary,
                                     out string strError)
        {
            summary  = "";
            strError = "";

            CancellationToken cancel_token = new CancellationToken();
            string            id           = Guid.NewGuid().ToString();
            SearchRequest     request      = new SearchRequest(id,
                                                               null, // TODO:
                                                               "getBiblioInfo",
                                                               "<全部>",
                                                               biblioPath,
                                                               "",
                                                               "",
                                                               "",
                                                               "summary",
                                                               1,
                                                               0,
                                                               -1);

            try
            {
                MessageConnection connection = this._channels.GetConnectionTaskAsync(
                    dp2mserverUrl,
                    remoteUserName).Result;

                SearchResult result = connection.SearchTaskAsync(
                    remoteUserName,
                    request,
                    new TimeSpan(0, 1, 0),
                    cancel_token).Result;
                if (result.ResultCount == -1)
                {
                    strError = "检索出错:" + result.ErrorInfo;
                    return(-1);
                }
                if (result.ResultCount == 0)
                {
                    strError = "未命中";
                    return(0);
                }

                summary = result.Records[0].Data;


                return(1);
            }
            catch (AggregateException ex)
            {
                strError = MessageConnection.GetExceptionText(ex);
                goto ERROR1;
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                goto ERROR1;
            }
ERROR1:
            return(-1);
        }