Beispiel #1
0
        // 获得一个册的题名字符串
        // .Value
        //      0   没有找到
        //      1   找到
        public static GetEntityDataResult GetEntityData(string pii)
        {
            LibraryChannel channel = App.CurrentApp.GetChannel();
            TimeSpan old_timeout = channel.Timeout;
            channel.Timeout = TimeSpan.FromSeconds(10);
            try
            {
                // TODO: ItemXml 和 BiblioSummary 可以考虑在本地缓存一段时间
                int nRedoCount = 0;
            REDO_GETITEMINFO:
                long lRet = channel.GetItemInfo(null,
                    "item",
                    pii,
                    "",
                    "xml",
                    out string item_xml,
                    out string item_recpath,
                    out _,
                    "",
                    out _,
                    out _,
                    out string strError);
                if (lRet == -1)
                {
                    if ((channel.ErrorCode == ErrorCode.RequestError ||
                        channel.ErrorCode == ErrorCode.RequestTimeOut)
                        && nRedoCount < 2)
                    {
                        nRedoCount++;
                        goto REDO_GETITEMINFO;
                    }
                    return new GetEntityDataResult
                    {
                        Value = -1,
                        ErrorInfo = strError
                    };
                }

                nRedoCount = 0;
            REDO_GETBIBLIOSUMMARY:
                lRet = channel.GetBiblioSummary(
    null,
    pii,
    "", // strConfirmItemRecPath,
    null,
    out _,
    out string strSummary,
    out strError);
                if (lRet == -1)
                {
                    if ((channel.ErrorCode == ErrorCode.RequestError ||
    channel.ErrorCode == ErrorCode.RequestTimeOut)
    && nRedoCount < 2)
                    {
                        nRedoCount++;
                        goto REDO_GETBIBLIOSUMMARY;
                    }
                    return new GetEntityDataResult
                    {
                        Value = -1,
                        ErrorInfo = strError
                    };
                }

                strSummary = strSummary?.Replace(". -- ", "\r\n");   // .Replace("/", "\r\n");

                return new GetEntityDataResult
                {
                    Value = (int)lRet,
                    ItemXml = item_xml,
                    ItemRecPath = item_recpath,
                    Title = strSummary,
                    ErrorInfo = strError,
                    ErrorCode = channel.ErrorCode.ToString()
                };
            }
            finally
            {
                channel.Timeout = old_timeout;
                App.CurrentApp.ReturnChannel(channel);
            }
        }
Beispiel #2
0
        // 获得一个册的题名字符串
        // .Value
        //      0   没有找到
        //      1   找到
        public static GetEntityDataResult GetEntityData(string pii)
        {
            /*
             * title = "";
             * item_xml = "";
             * item_recpath = "";
             */

            LibraryChannel channel = App.CurrentApp.GetChannel();

            try
            {
                long lRet = channel.GetItemInfo(null,
                                                "item",
                                                pii,
                                                "",
                                                "xml",
                                                out string item_xml,
                                                out string item_recpath,
                                                out byte[] item_timestamp,
                                                "",
                                                out string biblio_xml,
                                                out string biblio_recpath,
                                                out string strError);
                if (lRet == -1)
                {
                    return new GetEntityDataResult
                           {
                               Value     = -1,
                               ErrorInfo = strError
                           }
                }
                ;

                lRet = channel.GetBiblioSummary(
                    null,
                    pii,
                    "", // strConfirmItemRecPath,
                    null,
                    out string strBiblioRecPath,
                    out string strSummary,
                    out strError);
                if (lRet == -1)
                {
                    return new GetEntityDataResult
                           {
                               Value     = -1,
                               ErrorInfo = strError
                           }
                }
                ;

                strSummary = strSummary.Replace(". -- ", "\r\n");   // .Replace("/", "\r\n");

                return(new GetEntityDataResult
                {
                    Value = (int)lRet,
                    ItemXml = item_xml,
                    ItemRecPath = item_recpath,
                    Title = strSummary,
                    ErrorInfo = strError,
                    ErrorCode = channel.ErrorCode.ToString()
                });
            }
            finally
            {
                App.CurrentApp.ReturnChannel(channel);
            }
        }
        // 获得一系列册的摘要字符串
        // 
        // paramters:
        //      strStyle    风格。逗号间隔的列表。如果包含html text表示格式。forcelogin
        //      strOtherParams  <a>命令中其余的参数。例如" target='_blank' "可以用来打开新窗口
        public static string GetBarcodesSummary(
            OpacApplication app,
            // SessionInfo sessioninfo,
            LibraryChannel channel,
            string strBarcodes,
            string strArrivedItemBarcode,
            string strStyle,
            string strOtherParams)
        {
            string strSummary = "";

            if (strOtherParams == null)
                strOtherParams = "";

            string strDisableClass = "";
            if (string.IsNullOrEmpty(strArrivedItemBarcode) == false)
                strDisableClass = "deleted";

            bool bForceLogin = false;
            if (StringUtil.IsInList("forcelogin", strStyle) == true)
                bForceLogin = true;

            string strPrevBiblioRecPath = "";
            string[] barcodes = strBarcodes.Split(new char[] { ',' });
            for (int j = 0; j < barcodes.Length; j++)
            {
                string strBarcode = barcodes[j];
                if (String.IsNullOrEmpty(strBarcode) == true)
                    continue;

                // 获得摘要
                string strOneSummary = "";
                string strBiblioRecPath = "";

                string strError = "";
                long lRet = channel.GetBiblioSummary(
                    null,
                    strBarcode,
    null,
    strPrevBiblioRecPath,   // 前一个path
    out strBiblioRecPath,
    out strOneSummary,
    out strError);
                if (lRet == -1 || lRet == 0)
                    strOneSummary = strError;
                /*
                LibraryServerResult result = this.GetBiblioSummary(sessioninfo,
    strBarcode,
    null,
    strPrevBiblioRecPath,   // 前一个path
    out strBiblioRecPath,
    out strOneSummary);
                if (result.Value == -1 || result.Value == 0)
                    strOneSummary = result.ErrorInfo;
                 * */

                if (strOneSummary == ""
                    && strPrevBiblioRecPath == strBiblioRecPath)
                    strOneSummary = "(同上)";

                if (StringUtil.IsInList("html", strStyle) == true)
                {

                    string strBarcodeLink = "<a "
                        + (string.IsNullOrEmpty(strDisableClass) == false && strBarcode != strArrivedItemBarcode ? "class='" + strDisableClass + "'" : "")
                        + " href='book.aspx?barcode=" + strBarcode +
                        (bForceLogin == true ? "&forcelogin=userid" : "")
                        + "' " + strOtherParams + " >" + strBarcode + "</a>";

                    strSummary += strBarcodeLink + " : " + strOneSummary + "<br/>";
                }
                else
                {
                    strSummary += strBarcode + " : " + strOneSummary + "<br/>";
                }

                strPrevBiblioRecPath = strBiblioRecPath;
            }

            return strSummary;
        }
Beispiel #4
0
        void FillBiblioSummary(List <ListViewItem> items_param)
        {
            List <ListViewItem> items = new List <ListViewItem>();
            List <string>       piis  = new List <string>();

            // 第一阶段,准备 ListViewItem 和 PII 集合
            this.Invoke((Action)(() =>
            {
                foreach (ListViewItem item in items_param)
                {
                    string summary = ListViewUtil.GetItemText(item, 2);
                    if (string.IsNullOrEmpty(summary) == false)
                    {
                        continue;
                    }
                    items.Add(item);
                    piis.Add(ListViewUtil.GetItemText(item, 1));
                }
            }));

            if (piis.Count == 0)
            {
                return;
            }

            // 第二阶段,从服务器获得摘要
            List <string> summarys = new List <string>();

            foreach (string pii in piis)
            {
                // 获得缓存中的bibliosummary
                // return:
                //      -1  出错
                //      0   没有找到
                //      1   找到
                int nRet = Program.MainForm.GetCachedBiblioSummary(pii,
                                                                   null,
                                                                   out string strSummary,
                                                                   out string strError);
                if (nRet == -1)
                {
                    strSummary = $"GetCachedBiblioSummary() 出错: {strError}";
                }
                else if (nRet == 1)
                {
                }
                else
                {
                    try
                    {
                        _limit.WaitOne(TimeSpan.FromSeconds(10));

                        LibraryChannel channel     = Program.MainForm.GetChannel();
                        TimeSpan       old_timeout = channel.Timeout;
                        channel.Timeout = new TimeSpan(0, 0, 5);

                        try
                        {
                            long lRet = channel.GetBiblioSummary(
                                null,
                                pii,
                                null,
                                null,
                                out string strBiblioRecPath,
                                out strSummary,
                                out strError);
                            if (lRet == -1)
                            {
                                strSummary = $"出错: {strError}";
                            }
                            else
                            {
                                Program.MainForm.SetBiblioSummaryCache(pii,
                                                                       null,
                                                                       strSummary);
                            }
                        }
                        finally
                        {
                            channel.Timeout = old_timeout;
                            Program.MainForm.ReturnChannel(channel);

                            _limit.Release();
                        }
                    }
                    catch (Exception ex)
                    {
                        strSummary = $"异常: {ex.Message}";
                    }
                }

                summarys.Add(strSummary);
            }

            this.Invoke((Action)(() =>
            {
                // 第三阶段填充
                int i = 0;
                foreach (string summary in summarys)
                {
                    ListViewItem item = items[i];

                    ListViewUtil.ChangeItemText(item, 2, summary);
                    i++;
                }
            }));
        }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        // 是否登录?
        if (string.IsNullOrEmpty(sessioninfo.UserID) == true)
        {
            sessioninfo.UserID   = "public";
            sessioninfo.IsReader = false;
        }

        string strError = "";
        int    nRet     = 0;

        string strBarcode = this.Request["barcode"];

        if (string.IsNullOrEmpty(strBarcode) == true)
        {
            strError = "需要指定barcode参数";
            goto ERROR1;
        }

        string strLang = this.Request["lang"];

        if (string.IsNullOrEmpty(strLang) == false)
        {
            //this.UICulture = strLang;
            //this.Culture = strLang;
            try
            {
                Thread.CurrentThread.CurrentCulture =
                    CultureInfo.CreateSpecificCulture(strLang);
                Thread.CurrentThread.CurrentUICulture = new
                                                        CultureInfo(strLang);
            }
            catch
            {
            }

            //this.Session["lang"] = Thread.CurrentThread.CurrentUICulture.Name;
        }

#if NO
        // test
        this.Response.Write("test");
        this.Response.End();
        return;
#endif

        if (StringUtil.HasHead(strBarcode, "biblio_html:") == true)
        {
            string strBiblioRecPath = strBarcode.Substring("biblio_html:".Length);

            // 获得书目记录XML
            string[] formats = new string[1];
            formats[0] = "xml";
            byte[] timestamp = null;

            string[] results = null;

            // 2016/1/24
            if (string.IsNullOrEmpty(sessioninfo.UserID) == true)
            {
                strError = "sessioninfo.UserID 为空 (sessioninfo.Parameters='" + sessioninfo.Parameters + "') {F548F93A-3ED7-4F7A-8729-CD65E375D360}";
                goto ERROR1;
            }

            LibraryChannel channel = null;
#if CHANNEL_POOL
            channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/);
#else
            channel = sessioninfo.GetChannel(false);
#endif
            long lRet = channel.GetBiblioInfos(
                null,
                strBiblioRecPath,
                "",
                formats,
                out results,
                out timestamp,
                out strError);
#if CHANNEL_POOL
            sessioninfo.ReturnChannel(channel);
#endif
            if (lRet == -1)
            {
                strError = "获得书目记录 '" + strBiblioRecPath + "' 时出错: " + strError;
                goto ERROR1;
            }
            if (lRet == 0)
            {
                strError = "书目记录 '" + strBiblioRecPath + "' 不存在";
                goto ERROR1;
            }
            if (results == null || results.Length < 1)
            {
                strError = "results error {87C72690-662D-48E3-920D-B0E0C5D53726}";
                goto ERROR1;
            }
            string strBiblioXml = results[0];

            // 创建HTML
            string strBiblioDbName = StringUtil.GetDbName(strBiblioRecPath);

            // 需要从内核映射过来文件
            string strLocalPath = "";
            nRet = app.MapKernelScriptFile(
                // null,   // sessioninfo,
                strBiblioDbName,
                "./cfgs/opac_biblio.fltx",  // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件
                out strLocalPath,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            // 将种记录数据从XML格式转换为HTML格式
            string strResult = "";

            KeyValueCollection result_params     = null;
            string             strFilterFileName = strLocalPath; // app.CfgDir + "\\biblio.fltx";
            nRet = app.ConvertBiblioXmlToHtml(
                strFilterFileName,
                strBiblioXml,
                strBiblioRecPath,
                out strResult,
                out result_params,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
            this.Response.Write(strResult);
            this.Response.End();
            return;
        }
        else if (StringUtil.HasHead(strBarcode, "formated:") == true)
        {
            strBarcode = strBarcode.Substring("formated:".Length);
            string strArrivedItemBarcode = "";

            string[] barcodes = strBarcode.Split(new char[] { ',' });
            string   strTemp  = "";
            foreach (string barcode in barcodes)
            {
                if (string.IsNullOrEmpty(barcode) == true)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(strTemp) == false)
                {
                    strTemp += ",";
                }

                if (barcode[0] == '!')
                {
                    strArrivedItemBarcode = barcode.Substring(1);
                    strTemp += strArrivedItemBarcode;
                }
                else
                {
                    strTemp += barcode;
                }
            }

            strBarcode = strTemp;

            string strStyle       = "html"; // this.Request["style"];
            string strOtherParams = "";     // this.Request["otherparams"];

            LibraryChannel channel = null;
#if CHANNEL_POOL
            channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/); // 2016/1/25 增加第二参数
#else
            channel = sessioninfo.GetChannel(false);
#endif

            // 获得一系列册的摘要字符串
            //
            // paramters:
            //      strStyle    风格。逗号间隔的列表。如果包含html text表示格式。forcelogin
            //      strOtherParams  <a>命令中其余的参数。例如" target='_blank' "可以用来打开新窗口
            string strResult = ReservationInfoControl.GetBarcodesSummary(
                app,
                channel,
                strBarcode,
                strArrivedItemBarcode,
                strStyle,
                strOtherParams);

#if CHANNEL_POOL
            sessioninfo.ReturnChannel(channel);
#endif
            this.Response.Write(strResult);
            this.Response.End();
            return;
        }
        else
        {
            // 2016/1/25
            if (string.IsNullOrEmpty(sessioninfo.UserID) == true)
            {
                strError = "sessioninfo.UserID 为空 (sessioninfo.Parameters='" + sessioninfo.Parameters + "') {9A54CD5B-B1CF-43D2-8AE3-1969B5873055}";
                goto ERROR1;
            }

            // 获得摘要
            string strSummary       = "";
            string strBiblioRecPath = "";

            LibraryChannel channel = null;
#if CHANNEL_POOL
            channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/); // 2016/1/25 增加第二参数
#else
            channel = sessioninfo.GetChannel(false);
#endif

            long lRet = channel.GetBiblioSummary(
                null,
                strBarcode,
                null,
                null,
                out strBiblioRecPath,
                out strSummary,
                out strError);
#if CHANNEL_POOL
            sessioninfo.ReturnChannel(channel);
#endif
            if (lRet == -1 || lRet == 0)
            {
                strSummary = strError;
            }

            this.Response.Write(strSummary);
            this.Response.End();
        }
        return;

ERROR1:
        this.Response.Write(strError);
        this.Response.End();
    }
Beispiel #6
0
        // 获得一系列册的摘要字符串
        //
        // paramters:
        //      strStyle    风格。逗号间隔的列表。如果包含html text表示格式。forcelogin
        //      strOtherParams  <a>命令中其余的参数。例如" target='_blank' "可以用来打开新窗口
        public static string GetBarcodesSummary(
            OpacApplication app,
            // SessionInfo sessioninfo,
            LibraryChannel channel,
            string strBarcodes,
            string strArrivedItemBarcode,
            string strStyle,
            string strOtherParams)
        {
            string strSummary = "";

            if (strOtherParams == null)
            {
                strOtherParams = "";
            }

            string strDisableClass = "";

            if (string.IsNullOrEmpty(strArrivedItemBarcode) == false)
            {
                strDisableClass = "deleted";
            }

            bool bForceLogin = false;

            if (StringUtil.IsInList("forcelogin", strStyle) == true)
            {
                bForceLogin = true;
            }

            string strPrevBiblioRecPath = "";

            string[] barcodes = strBarcodes.Split(new char[] { ',' });
            for (int j = 0; j < barcodes.Length; j++)
            {
                string strBarcode = barcodes[j];
                if (String.IsNullOrEmpty(strBarcode) == true)
                {
                    continue;
                }

                // 获得摘要
                string strOneSummary    = "";
                string strBiblioRecPath = "";

                string strError = "";
                long   lRet     = channel.GetBiblioSummary(
                    null,
                    strBarcode,
                    null,
                    strPrevBiblioRecPath, // 前一个path
                    out strBiblioRecPath,
                    out strOneSummary,
                    out strError);
                if (lRet == -1 || lRet == 0)
                {
                    strOneSummary = strError;
                }

                /*
                 * LibraryServerResult result = this.GetBiblioSummary(sessioninfo,
                 * strBarcode,
                 * null,
                 * strPrevBiblioRecPath,   // 前一个path
                 * out strBiblioRecPath,
                 * out strOneSummary);
                 * if (result.Value == -1 || result.Value == 0)
                 *  strOneSummary = result.ErrorInfo;
                 * */

                if (strOneSummary == "" &&
                    strPrevBiblioRecPath == strBiblioRecPath)
                {
                    strOneSummary = "(同上)";
                }

                if (StringUtil.IsInList("html", strStyle) == true)
                {
                    string strBarcodeLink = "<a "
                                            + (string.IsNullOrEmpty(strDisableClass) == false && strBarcode != strArrivedItemBarcode ? "class='" + strDisableClass + "'" : "")
                                            + " href='book.aspx?barcode=" + strBarcode +
                                            (bForceLogin == true ? "&forcelogin=userid" : "")
                                            + "' " + strOtherParams + " >" + strBarcode + "</a>";

                    strSummary += strBarcodeLink + " : " + strOneSummary + "<br/>";
                }
                else
                {
                    strSummary += strBarcode + " : " + strOneSummary + "<br/>";
                }

                strPrevBiblioRecPath = strBiblioRecPath;
            }

            return(strSummary);
        }
Beispiel #7
0
        // 获得册记录信息和书目摘要信息
        // parameters:
        //      style   风格。network 表示只从网络获取册记录;否则优先从本地获取,本地没有再从网络获取册记录。无论如何,书目摘要都是尽量从本地获取
        // .Value
        //      0   没有找到
        //      1   找到
        public static async Task <GetEntityDataResult> GetEntityDataAsync(string pii,
                                                                          string style)
        {
            bool network = StringUtil.IsInList("network", style);

            try
            {
                using (var releaser = await _channelLimit.EnterAsync())
                    using (BiblioCacheContext context = new BiblioCacheContext())
                    {
                        if (_cacheDbCreated == false)
                        {
                            context.Database.EnsureCreated();
                            _cacheDbCreated = true;
                        }

                        LibraryChannel channel     = App.CurrentApp.GetChannel();
                        TimeSpan       old_timeout = channel.Timeout;
                        channel.Timeout = TimeSpan.FromSeconds(10);
                        try
                        {
                            GetEntityDataResult result = null;
                            List <NormalResult> errors = new List <NormalResult>();

                            EntityItem entity_record = null;

                            // ***
                            // 第一步:获取册记录

                            if (network == false)
                            {
                                // 先尝试从本地实体库中获得记录
                                entity_record = context.Entities.Where(o => o.PII == pii).FirstOrDefault();
                                // EntityItem entity_record = null;   // testing
                            }

                            if (entity_record != null)
                            {
                                result = new GetEntityDataResult
                                {
                                    Value       = 1,
                                    ItemXml     = entity_record.Xml,
                                    ItemRecPath = entity_record.RecPath,
                                    Title       = "",
                                }
                            }
                            ;
                            else
                            {
                                // 再尝试从 dp2library 服务器获取
                                // TODO: ItemXml 和 BiblioSummary 可以考虑在本地缓存一段时间
                                int nRedoCount = 0;
REDO_GETITEMINFO:
                                long lRet = channel.GetItemInfo(null,
                                                                "item",
                                                                pii,
                                                                "",
                                                                "xml",
                                                                out string item_xml,
                                                                out string item_recpath,
                                                                out byte[] timestamp,
                                                                "",
                                                                out _,
                                                                out _,
                                                                out string strError);
                                if (lRet == -1)
                                {
                                    if ((channel.ErrorCode == ErrorCode.RequestError ||
                                         channel.ErrorCode == ErrorCode.RequestTimeOut) &&
                                        nRedoCount < 2)
                                    {
                                        nRedoCount++;
                                        goto REDO_GETITEMINFO;
                                    }
                                    // TODO: 这里不着急返回,还需要尝试获得书目摘要
                                    errors.Add(new NormalResult
                                    {
                                        Value     = -1,
                                        ErrorInfo = strError,
                                        ErrorCode = channel.ErrorCode.ToString()
                                    });

                                    /*
                                     * return new GetEntityDataResult
                                     * {
                                     *  Value = -1,
                                     *  ErrorInfo = strError,
                                     *  ErrorCode = channel.ErrorCode.ToString()
                                     * };
                                     */
                                }
                                else
                                {
                                    result = new GetEntityDataResult
                                    {
                                        Value       = 1,
                                        ItemXml     = item_xml,
                                        ItemRecPath = item_recpath,
                                        Title       = "",
                                    };

                                    // 保存到本地数据库
                                    await AddOrUpdateAsync(context, new EntityItem
                                    {
                                        PII       = pii,
                                        Xml       = item_xml,
                                        RecPath   = item_recpath,
                                        Timestamp = timestamp,
                                    });

#if NO
                                    context.Entities.Add(new EntityItem
                                    {
                                        PII       = pii,
                                        Xml       = item_xml,
                                        RecPath   = item_recpath,
                                        Timestamp = timestamp,
                                    });
                                    try
                                    {
                                        await context.SaveChangesAsync();
                                    }
                                    catch (Exception ex)
                                    {
                                        SqliteException sqlite_exception = ex.InnerException as SqliteException;
                                        if (sqlite_exception != null && sqlite_exception.SqliteErrorCode == 19)
                                        {
                                            // PII 发生重复了
                                        }
                                        else
                                        {
                                            throw ex;
                                        }
                                    }
#endif
                                }
                            }

                            // ***
                            /// 第二步:获取书目摘要

                            // 先尝试从本地书目库中获取书目摘要

                            var item = context.BiblioSummaries.Where(o => o.PII == pii).FirstOrDefault();
                            if (item != null &&
                                string.IsNullOrEmpty(item.BiblioSummary) == false)
                            {
                                if (result == null)
                                {
                                    result = new GetEntityDataResult();
                                }

                                result.Title = item.BiblioSummary;
                            }
                            else
                            {
                                // 从 dp2library 服务器获取书目摘要
                                int nRedoCount = 0;
REDO_GETBIBLIOSUMMARY:
                                long lRet = channel.GetBiblioSummary(
                                    null,
                                    pii,
                                    "", // strConfirmItemRecPath,
                                    null,
                                    out _,
                                    out string strSummary,
                                    out string strError);
                                if (lRet == -1)
                                {
                                    if ((channel.ErrorCode == ErrorCode.RequestError ||
                                         channel.ErrorCode == ErrorCode.RequestTimeOut) &&
                                        nRedoCount < 2)
                                    {
                                        nRedoCount++;
                                        goto REDO_GETBIBLIOSUMMARY;
                                    }

                                    errors.Add(new NormalResult
                                    {
                                        Value     = -1,
                                        ErrorInfo = strError,
                                        ErrorCode = channel.ErrorCode.ToString()
                                    });

                                    /*
                                     * return new GetEntityDataResult
                                     * {
                                     *  Value = -1,
                                     *  ErrorInfo = strError,
                                     *  ErrorCode = channel.ErrorCode.ToString(),
                                     * };
                                     */
                                }
                                else
                                {
                                    strSummary = strSummary?.Replace(". -- ", "\r\n"); // .Replace("/", "\r\n");

                                    if (result == null)
                                    {
                                        result = new GetEntityDataResult();
                                    }

                                    result.Title = strSummary;

                                    // 存入数据库备用
                                    if (lRet == 1 && string.IsNullOrEmpty(strSummary) == false)
                                    {
                                        try
                                        {
                                            var exist_item = context.BiblioSummaries.Where(o => o.PII == pii).FirstOrDefault();

                                            if (exist_item != null)
                                            {
                                                if (exist_item.BiblioSummary != strSummary)
                                                {
                                                    exist_item.BiblioSummary = strSummary;
                                                    context.BiblioSummaries.Update(exist_item);
                                                }
                                            }
                                            else
                                            {
                                                context.BiblioSummaries.Add(new BiblioSummaryItem
                                                {
                                                    PII           = pii,
                                                    BiblioSummary = strSummary
                                                });
                                            }
                                            await context.SaveChangesAsync();
                                        }
                                        catch (Exception ex)
                                        {
                                            WpfClientInfo.WriteErrorLog($"GetEntityDataAsync() 中保存 summary 时(PII 为 '{pii}')出现异常:{ExceptionUtil.GetDebugText(ex)}");
                                        }
                                    }
                                }

                                /*
                                 * return new GetEntityDataResult
                                 * {
                                 *  Value = (int)lRet,
                                 *  ItemXml = item_xml,
                                 *  ItemRecPath = item_recpath,
                                 *  Title = strSummary,
                                 *  ErrorInfo = strError,
                                 *  ErrorCode = channel.ErrorCode.ToString()
                                 * };
                                 */
                            }

                            // 完全成功
                            if (result != null && errors.Count == 0)
                            {
                                return(result);
                            }
                            if (result == null)
                            {
                                return new GetEntityDataResult
                                       {
                                           Value     = errors[0].Value,
                                           ErrorInfo = errors[0].ErrorInfo,
                                           ErrorCode = errors[0].ErrorCode
                                       }
                            }
                            ;
                            result.ErrorInfo = errors[0].ErrorInfo;
                            result.ErrorCode = errors[0].ErrorCode;
                            return(result);
                        }
                        finally
                        {
                            channel.Timeout = old_timeout;
                            App.CurrentApp.ReturnChannel(channel);
                        }
                    }
            }
            catch (Exception ex)
            {
                WpfClientInfo.WriteErrorLog($"GetEntityDataAsync() 出现异常: {ExceptionUtil.GetDebugText(ex)}");

                return(new GetEntityDataResult
                {
                    Value = -1,
                    ErrorInfo = $"GetEntityDataAsync() 出现异常: {ex.Message}",
                    ErrorCode = ex.GetType().ToString()
                });
            }
        }
Beispiel #8
0
        void FillSummary(
            ListView list,
            LibraryChannel channel,
            int iColumnBarcode,
            int iColumnSummary)
        {
            string strError = "";

            for (int i = 0; i < list.Items.Count; i++)
            {
                if (m_bStopFilling == true)
                    return;
                
                ListViewItem item = list.Items[i];

                string strSummary = ListViewUtil.GetItemText(item, iColumnSummary);
                string strItemBarcode = ListViewUtil.GetItemText(item, iColumnBarcode);
                // string strItemRecPath = ListViewUtil.GetItemText(item, iColumnSummary);

                if (String.IsNullOrEmpty(strSummary) == false)
                    continue;

                if (String.IsNullOrEmpty(strItemBarcode) == true
                    /*&& String.IsNullOrEmpty(strItemRecPath) == true*/)
                    continue;

                this.stop.SetMessage("正在后台获取摘要 " + strItemBarcode + " ...");

                try
                {

                    string strBiblioRecPath = "";
                    long lRet = channel.GetBiblioSummary(
                        null,
                        strItemBarcode,
                        "", // strItemRecPath,
                        null,
                        out strBiblioRecPath,
                        out strSummary,
                        out strError);
                    if (lRet == -1)
                    {
                        strSummary = strError;  // 2009/3/13 changed
                        // return -1;
                    }

                }
                finally
                {
                }

                ListViewUtil.ChangeItemText(item, iColumnSummary, strSummary);
            }

            this.stop.SetMessage("");
        }
Beispiel #9
0
        /*public*/
        void ThreadFillAmercingMain()
        {
            string strError = "";
            m_bStopFillAmercing = false;

            LibraryChannel channel = new LibraryChannel();
            channel.Url = this.MainForm.LibraryServerUrl;

            channel.BeforeLogin += new BeforeLoginEventHandle(Channel_BeforeLogin);

            try
            {

                Safe_clearList(this.listView_overdues);

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(this.FillAmercingParam.Xml);
                }
                catch (Exception ex)
                {
                    strError = "读者XML记录装入XMLDOM时发生错误: " + ex.Message;
                    goto ERROR1;
                }

                List<string> dup_ids = new List<string>();

                // 选出所有<overdue>元素
                XmlNodeList nodes = dom.DocumentElement.SelectNodes("overdues/overdue");

                for (int i = 0; i < nodes.Count; i++)
                {
                    if (this.m_bStopFillAmercing == true)
                    {
                        strError = "中断,列表不完整...";
                        goto ERROR1;
                    }

                    XmlNode node = nodes[i];
                    string strItemBarcode = DomUtil.GetAttr(node, "barcode");
                    string strItemRecPath = DomUtil.GetAttr(node, "recPath");
                    string strReason = DomUtil.GetAttr(node, "reason");
                    string strBorrowDate = DomUtil.GetAttr(node, "borrowDate");

                    strBorrowDate = DateTimeUtil.LocalTime(strBorrowDate, "u");

                    string strBorrowPeriod = DomUtil.GetAttr(node, "borrowPeriod");
                    string strReturnDate = DomUtil.GetAttr(node, "returnDate");

                    strReturnDate = DateTimeUtil.LocalTime(strReturnDate, "u");

                    string strID = DomUtil.GetAttr(node, "id");
                    string strPrice = DomUtil.GetAttr(node, "price");
                    string strComment = DomUtil.GetAttr(node, "comment");

                    string strBorrowOperator = DomUtil.GetAttr(node, "borrowOperator");
                    string strReturnOperator = DomUtil.GetAttr(node, "operator");

                    XmlNodeList dup_nodes = dom.DocumentElement.SelectNodes("overdues/overdue[@id='" + strID + "']");
                    if (dup_nodes.Count > 1)
                    {
                        dup_ids.Add(strID);
                    }


                    // TODO: 摘要建议异步作,或者在全部数据装载完成后单独扫描一遍做
                    string strSummary = "";


                    ListViewItem item = new ListViewItem(strItemBarcode);

                    // 摘要
                    // item.SubItems.Add(strSummary);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BIBLIOSUMMARY, strSummary);

                    // 金额
                    // item.SubItems.Add(strPrice);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_PRICE, strPrice);

                    // 注释
                    // item.SubItems.Add(strComment);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_COMMENT, strComment);

                    // 违约原因
                    // item.SubItems.Add(strReason);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_REASON, strReason);

                    // 借阅日期
                    // item.SubItems.Add(strBorrowDate);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWDATE, strBorrowDate);

                    // 借阅时限
                    // item.SubItems.Add(strBorrowPeriod);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWPERIOD, strBorrowPeriod);

                    // 还书日期
                    // item.SubItems.Add(strReturnDate);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_RETURNDATE, strReturnDate);

                    // id
                    // item.SubItems.Add(strID);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_ID, strID);

                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWOPERATOR, strBorrowOperator);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_RETURNOPERATOR, strReturnOperator);

                    // 储存原始价格和注释备用
                    AmercingItemInfo info = new AmercingItemInfo();
                    info.Price = strPrice;
                    info.Comment = strComment;
                    info.Xml = node.OuterXml;
                    item.Tag = info;

                    Safe_addListItem(this.listView_overdues, item);
                }

                if (dup_ids.Count > 0)
                {
                    StringUtil.RemoveDupNoSort(ref dup_ids);
                    Debug.Assert(dup_ids.Count >= 1, "");
                    strError = "未交费用列表中发现下列ID出现了重复,这是一个严重错误,请系统管理员尽快排除。\r\n---\r\n" + StringUtil.MakePathList(dup_ids, "; ");
                    goto ERROR1;
                }

                // 第二阶段,填充摘要
                if (this.FillAmercingParam.FillSummary == true)
                {
                    List<ListViewItem> items = Safe_getItemList(listView_overdues);

                    for (int i = 0; i < items.Count; i++)
                    {
                        if (this.m_bStopFillAmercing == true)
                            return;

                        ListViewItem item = items[i];

                        string strSummary = "";
                        string strItemBarcode = "";

                        Safe_getBarcodeAndSummary(listView_overdues,
        item,
        out strItemBarcode,
        out strSummary);

                        // 已经有内容了,就不刷新了
                        if (String.IsNullOrEmpty(strSummary) == false)
                            continue;

                        if (String.IsNullOrEmpty(strItemBarcode) == true
                            /*&& String.IsNullOrEmpty(strItemRecPath) == true*/)
                            continue;

                        try
                        {
                            string strBiblioRecPath = "";
                            long lRet = channel.GetBiblioSummary(
                                null,
                                strItemBarcode,
                                "", // strItemRecPath,
                                null,
                                out strBiblioRecPath,
                                out strSummary,
                                out strError);
                            if (lRet == -1)
                            {
                                strSummary = strError;  // 2009/3/13 changed
                                // return -1;
                            }

                        }
                        finally
                        {
                        }

                        Safe_changeItemText(item, COLUMN_AMERCING_BIBLIOSUMMARY, strSummary);
                    }
                }


                return;
            }
            finally
            {
                channel.BeforeLogin -= new BeforeLoginEventHandle(Channel_BeforeLogin);
                channel.Close();
                m_bStopFillAmercing = true;
            }

        ERROR1:
            Safe_setError(this.listView_overdues, strError);
            // Safe_errorBox(strError);
        }
Beispiel #10
0
        /*public*/
        void ThreadFillAmercedMain()
        {
            string strError = "";
            m_bStopFillAmerced = false;

            LibraryChannel channel = new LibraryChannel();
            channel.Url = this.MainForm.LibraryServerUrl;

            channel.BeforeLogin += new BeforeLoginEventHandle(Channel_BeforeLogin);

            channel.AfterLogin += new AfterLoginEventHandle(Channel_AfterLogin);

            try
            {
                string strResultSetName = "";
                // 获得一些系统参数
                string strDbName = "违约金";
                string strQueryXml = "";
                string strLang = "zh";

                long lRet = Channel.GetSystemParameter(
                    stop,
                    "amerce",
                    "dbname",
                    out strDbName,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                if (m_bStopFillAmerced == true)
                    return;

                // 2010/12/16 change
                if (lRet == 0 || String.IsNullOrEmpty(strDbName) == true)
                {
                    if (String.IsNullOrEmpty(strError) == true)
                        strError = "违约金库名没有配置。";
                    goto ERROR1;
                }

                if (string.IsNullOrEmpty(this.FillAmercedParam.ReaderBarcode) == false)
                {
                    Safe_clearList(this.listView_amerced);

                    string strFrom = "读者证条码";
                    string strMatchStyle = "exact";

                    // 2007/4/5 改造 加上了 GetXmlStringSimple()
                    strQueryXml = "<target list='" + strDbName + ":" + strFrom + "'><item><word>"
        + StringUtil.GetXmlStringSimple(this.FillAmercedParam.ReaderBarcode)
        + "</word><match>" + strMatchStyle + "</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>" + strLang + "</lang></target>";

                    strResultSetName = "amercing";
                } // end of strReaderBarcode != ""
                else
                {
                    if (this.FillAmercedParam.IDs == null || this.FillAmercedParam.IDs.Count == 0)
                    {
                        strError = "IDs 参数不能为空";
                        goto ERROR1;
                    }

                    string strFrom = "ID";
                    string strMatchStyle = "exact";

                    strQueryXml = "<target list='" + strDbName + ":" + strFrom + "'>";
                    for (int i = 0; i < this.FillAmercedParam.IDs.Count; i++)
                    {
                        string strID = this.FillAmercedParam.IDs[i];

                        if (i > 0)
                            strQueryXml += "<operator value='OR' />";

                        strQueryXml += "<item><word>"
            + StringUtil.GetXmlStringSimple(strID)
            + "</word><match>" + strMatchStyle + "</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>" + strLang + "</lang>";
                    }
                    strQueryXml += "</target>";

                    strResultSetName = "amerced";
                }

                // 开始检索
                lRet = channel.Search(
    stop,
    strQueryXml,
    strResultSetName,
    "", // strOutputStyle
    out strError);
                if (lRet == 0)
                {
                    strError = "not found";
                    return;   // not found
                }
                if (lRet == -1)
                    goto ERROR1;

                if (m_bStopFillAmerced == true)
                    return;

                long lHitCount = lRet;

                long lStart = 0;
                long lPerCount = Math.Min(50, lHitCount);
                Record[] searchresults = null;

                // 获得结果集,装入listview
                for (; ; )
                {

                    if (m_bStopFillAmerced == true)
                    {
                        strError = "中断,列表不完整...";
                        goto ERROR1;
                    }
                    // stop.SetMessage("正在装入浏览信息 " + (lStart + 1).ToString() + " - " + (lStart + lPerCount).ToString() + " (命中 " + lHitCount.ToString() + " 条记录) ...");

                    lRet = channel.GetSearchResult(
                        stop,
                        strResultSetName,   // strResultSetName
                        lStart,
                        lPerCount,
                        "id",   // "id,cols"
                        strLang,
                        out searchresults,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                    if (lRet == 0)
                    {
                        strError = "未命中";
                        return;
                    }

                    // 处理浏览结果
                    for (int i = 0; i < searchresults.Length; i++)
                    {
                        if (m_bStopFillAmerced == true)
                        {
                            strError = "中断,列表不完整...";
                            goto ERROR1;
                        }

                        string strPath = searchresults[i].Path;

                        byte[] timestamp = null;
                        string strXml = "";

                        lRet = channel.GetRecord(stop,
                            strPath,
                            out timestamp,
                            out strXml,
                            out strError);
                        if (lRet == -1)
                        {
                            if (channel.ErrorCode == ErrorCode.AccessDenied)
                                continue;
                            goto ERROR1;
                        }

                        int nRet = Safe_fillAmercedLine(
                            stop,
                            strXml,
                            strPath,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;

                    }

                    lStart += searchresults.Length;
                    if (lStart >= lHitCount || lPerCount <= 0)
                        break;
                }


                // 第二阶段,填充摘要
                if (this.FillAmercedParam.FillSummary == true)
                {
                    List<ListViewItem> items = Safe_getItemList(this.listView_amerced);

                    for (int i = 0; i < items.Count; i++)
                    {
                        if (this.m_bStopFillAmerced == true)
                            return;

                        ListViewItem item = items[i];

                        string strSummary = "";
                        string strItemBarcode = "";

                        Safe_getBarcodeAndSummary(listView_amerced,
        item,
        out strItemBarcode,
        out strSummary);

                        // 已经有内容了,就不刷新了
                        if (String.IsNullOrEmpty(strSummary) == false)
                            continue;

                        if (String.IsNullOrEmpty(strItemBarcode) == true
                            /*&& String.IsNullOrEmpty(strItemRecPath) == true*/)
                            continue;

                        try
                        {
                            string strBiblioRecPath = "";
                            lRet = channel.GetBiblioSummary(
                                null,
                                strItemBarcode,
                                "", // strItemRecPath,
                                null,
                                out strBiblioRecPath,
                                out strSummary,
                                out strError);
                            if (lRet == -1)
                            {
                                strSummary = strError;  // 2009/3/13 changed
                                // return -1;
                            }

                        }
                        finally
                        {
                        }

                        Safe_changeItemText(item, COLUMN_AMERCING_BIBLIOSUMMARY, strSummary);
                    }
                }
                return;
            }
            finally
            {
                channel.BeforeLogin -= new BeforeLoginEventHandle(Channel_BeforeLogin);
                channel.AfterLogin -= new AfterLoginEventHandle(Channel_AfterLogin);
                channel.Close();
                m_bStopFillAmerced = true;
            }

        ERROR1:
            Safe_setError(this.listView_amerced, strError);
            // Safe_errorBox(strError);
        }
Beispiel #11
0
        // 获得一个册的题名字符串
        NormalResult GetEntityData(string pii,
                                   out string title,
                                   out string item_xml,
                                   out string item_recpath)
        {
            title        = "";
            item_xml     = "";
            item_recpath = "";

            LibraryChannel channel = App.CurrentApp.GetChannel();

            try
            {
#if NO
                GetItemInfo(
                    stop,
                    "item",
                    strBarcode,
                    "",
                    strResultType,
                    out strResult,
                    out strItemRecPath,
                    out item_timestamp,
                    strBiblioType,
                    out strBiblio,
                    out strBiblioRecPath,
                    out strError);
#endif
                long lRet = channel.GetItemInfo(null,
                                                "item",
                                                pii,
                                                "",
                                                "xml",
                                                out item_xml,
                                                out item_recpath,
                                                out byte[] item_timestamp,
                                                "",
                                                out string biblio_xml,
                                                out string biblio_recpath,
                                                out string strError);
                if (lRet == -1)
                {
                    return new NormalResult {
                               Value = -1, ErrorInfo = strError
                    }
                }
                ;

                lRet = channel.GetBiblioSummary(
                    null,
                    pii,
                    "", // strConfirmItemRecPath,
                    null,
                    out string strBiblioRecPath,
                    out string strSummary,
                    out strError);
                if (lRet == -1)
                {
                    return new NormalResult {
                               Value = -1, ErrorInfo = strError
                    }
                }
                ;

                title = strSummary;

                return(new NormalResult());
            }
            finally
            {
                App.CurrentApp.ReturnChannel(channel);
            }
        }
Beispiel #12
0
        protected override void Render(HtmlTextWriter writer)
        {
            int    nRet     = 0;
            string strError = "";

            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            bool bManager = false;

            if (String.IsNullOrEmpty(sessioninfo.UserID) == true ||
                StringUtil.IsInList("managecomment", sessioninfo.RightsOrigin) == false)
            {
                bManager = false;
            }
            else
            {
                bManager = true;
            }

            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

            bool bReader = false;

            if (sessioninfo.ReaderInfo != null &&
                sessioninfo.IsReader == true && loginstate != LoginState.Public)
            {
                bReader = true;
            }

            if (bManager == false)
            {
                Button delete_button = (Button)this.FindControl("delete_button");
                delete_button.Visible = false;

                Button open_modify_state_button = (Button)this.FindControl("open_modify_state_button");
                open_modify_state_button.Visible = false;

                Button selectall_button = (Button)this.FindControl("selectall_button");
                selectall_button.Visible = false;

                Button unselectall_button = (Button)this.FindControl("unselectall_button");
                unselectall_button.Visible = false;
            }

            /*
             * if (sessioninfo.Account == null)
             * {
             *  // 临时的SessionInfo对象
             *  SessionInfo temp_sessioninfo = new SessionInfo(app);
             *
             *  // 模拟一个账户
             *  Account account = new Account();
             *  account.LoginName = "opac_column";
             *  account.Password = "";
             *  account.Rights = "getbibliosummary";
             *
             *  account.Type = "";
             *  account.Barcode = "";
             *  account.Name = "opac_column";
             *  account.UserID = "opac_column";
             *  account.RmsUserName = app.ManagerUserName;
             *  account.RmsPassword = app.ManagerPassword;
             *
             *  temp_sessioninfo.Account = account;
             *  sessioninfo = temp_sessioninfo;
             * }
             * */

            bool    bUseBiblioSummary = false; // 使用书目摘要(否则就是详细书目格式)
            bool    bDitto            = true;  // 书目 同上...
            XmlNode nodeBookReview    = app.WebUiDom.DocumentElement.SelectSingleNode("bookReview");

            if (nodeBookReview != null)
            {
                DomUtil.GetBooleanParam(nodeBookReview,
                                        "ditto",
                                        true,
                                        out bDitto,
                                        out strError);
                DomUtil.GetBooleanParam(nodeBookReview,
                                        "useBiblioSummary",
                                        false,
                                        out bUseBiblioSummary,
                                        out strError);
            }

            int nPageNo = this.StartIndex / this.PageMaxLines;

            SetTitle(String.IsNullOrEmpty(this.Title) == true ? this.GetString("栏目") : this.Title);

            SetResultInfo();

            if (this.CommentColumn == null ||
                this.CommentColumn.Opened == false)
            {
                this.SetDebugInfo("errorinfo", "尚未创建栏目缓存...");
            }

            if (this.CommentColumn != null)
            {
                LibraryChannel channel = sessioninfo.GetChannel(true);
                app.m_lockCommentColumn.AcquireReaderLock(app.m_nCommentColumnLockTimeout);
                try
                {
                    string strPrevBiblioRecPath = "";

                    for (int i = 0; i < this.PageMaxLines; i++)
                    {
                        PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i));
                        if (line == null)
                        {
                            PlaceHolder insertpoint = (PlaceHolder)this.FindControl("insertpoint");
                            PlaceHolder content     = (PlaceHolder)this.FindControl("content");

                            line = this.NewContentLine(content, i, insertpoint);
                        }

                        LiteralControl no          = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_no");
                        HyperLink      pathcontrol = (HyperLink)this.FindControl("line" + Convert.ToString(i) + "_path");
                        // LiteralControl contentcontrol = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_content");
                        CommentControl commentcontrol = (CommentControl)this.FindControl("line" + Convert.ToString(i) + "_comment");

                        LiteralControl bibliosummarycontrol = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_bibliosummary");
                        HyperLink      bibliorecpathcontrol = (HyperLink)this.FindControl("line" + Convert.ToString(i) + "_bibliorecpath");
                        Button         newreview            = (Button)this.FindControl("line" + Convert.ToString(i) + "_newreview");
                        PlaceHolder    biblioinfo_holder    = (PlaceHolder)this.FindControl("line" + Convert.ToString(i) + "_biblioinfo_holder");
                        BiblioControl  bibliocontrol        = (BiblioControl)this.FindControl("line_" + i.ToString() + "_bibliocontrol");

                        CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                        if (bManager == false)
                        {
                            checkbox.Visible = false;
                        }

                        int index = this.StartIndex + i;
                        if (index >= this.CommentColumn.Count)
                        {
                            checkbox.Visible       = false;
                            commentcontrol.Visible = false;
                            bibliocontrol.Visible  = false;
                            continue;
                        }
                        TopArticleItem record = (TopArticleItem)this.CommentColumn[index];

                        // 序号
                        string strNo = "&nbsp;";
                        strNo = Convert.ToString(i + this.StartIndex + 1);

                        no.Text = "<div>" + strNo + "</div>";

                        // 路径
                        string strPath = record.Line.m_strRecPath;

                        // 2012/7/11
                        commentcontrol.RecPath = app.GetLangItemRecPath(
                            "comment",
                            this.Lang,
                            strPath);

                        byte[] timestamp = null;
                        string strXml    = "";
                        // return:
                        //      -1  出错
                        //      0   没有找到
                        //      1   找到
                        nRet = commentcontrol.GetRecord(
                            app,
                            null,   // sessioninfo,
                            channel,
                            strPath,
                            out strXml,
                            out timestamp,
                            out strError);
                        if (nRet == -1)
                        {
                            goto ERROR1;
                        }
                        if (nRet == 0)
                        {
                        }

                        string strBiblioRecPath = "";
                        if (string.IsNullOrEmpty(strXml) == false)
                        {
                            string strParentID = "";
                            nRet = CommentControl.GetParentID(strXml,
                                                              out strParentID,
                                                              out strError);
                            if (nRet == -1)
                            {
                                goto ERROR1;
                            }

                            strBiblioRecPath = CommentControl.GetBiblioRecPath(
                                app,
                                strPath,
                                strParentID);
                        }
                        else
                        {
                            strBiblioRecPath = "";
                        }

                        //
                        if (bManager == true || bReader == true)
                        {
                            string strUrl = "./book.aspx?BiblioRecPath="
                                            + HttpUtility.UrlEncode(strBiblioRecPath)
                                            + "&CommentRecPath="
                                            + HttpUtility.UrlEncode(strPath)
                                            + "#newreview";
                            newreview.OnClientClick = "window.open('" + strUrl + "','_blank'); return cancelClick();";
                            // newreview.ToolTip = this.GetString("创建新的评注, 属于书目记录") + ":" + strBiblioRecPath;
                            // newreview.Attributes.Add("target", "_blank");
                            newreview.Visible = true;
                        }
                        else
                        {
                            newreview.Visible = false;
                        }

                        if (string.IsNullOrEmpty(strBiblioRecPath) == true)
                        {
                            biblioinfo_holder.Controls.Add(new LiteralControl("<div class='ditto'>" + this.GetString("无法定位书目记录") + "</div>"));
                            bibliocontrol.Visible = false;
                        }
                        else if (bDitto == true &&
                                 strBiblioRecPath == strPrevBiblioRecPath)
                        {
                            biblioinfo_holder.Controls.Add(new LiteralControl("<div class='ditto'>" + this.GetString("同上") + "</div>"));
                            bibliocontrol.Visible = false;
                        }
                        else
                        {
                            if (bUseBiblioSummary == true)
                            {
                                // 获得摘要
                                string strBarcode             = "@bibliorecpath:" + strBiblioRecPath;
                                string strSummary             = "";
                                string strOutputBiblioRecPath = "";
                                long   lRet = //sessioninfo.Channel.
                                              channel.GetBiblioSummary(
                                    null,
                                    strBarcode,
                                    null,
                                    null,
                                    out strOutputBiblioRecPath,
                                    out strSummary,
                                    out strError);
                                if (lRet == -1 || lRet == 0)
                                {
                                    strSummary = strError;
                                }

                                bibliosummarycontrol.Text = strSummary;
                                bibliocontrol.Visible     = false;
                            }
                            else
                            {
                                bibliocontrol.RecPath = strBiblioRecPath;
                                bibliocontrol.Visible = true;
                            }
                        }

                        strPrevBiblioRecPath = strBiblioRecPath;
                    }
                }
                finally
                {
                    app.m_lockCommentColumn.ReleaseReaderLock();
                    sessioninfo.ReturnChannel(channel);
                }
            }
            else
            {
                // 显示空行
                for (int i = 0; i < this.PageMaxLines; i++)
                {
                    PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i));
                    if (line == null)
                    {
                        continue;
                    }

                    CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                    checkbox.Visible = false;

                    CommentControl commentcontrol = (CommentControl)this.FindControl("line" + Convert.ToString(i) + "_comment");
                    commentcontrol.Visible = false;

                    BiblioControl bibliocontrol = (BiblioControl)this.FindControl("line_" + i.ToString() + "_bibliocontrol");
                    bibliocontrol.Visible = false;
                }
            }

            this.SetLineClassAndControlActive();
            base.Render(writer);
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
            base.Render(writer);
        }