Beispiel #1
0
        void FillCoverImage(LibraryChannel channel)
        {
            if (_issue_query_strings.Count == 0)
                return;
            PlaceHolder line = (PlaceHolder)this.FindControl("coverline");
            if (line == null)
                return;

            string displayBlank = this.DisplayBlankIssueCover;  // 缺省 "displayBlank,hideWhenAllBlank"
            string strPrefferSize = this.IssueCoverSize;    //  "MediumImage"; // "LargeImage",

            int nNotBlankCount = 0;
            StringBuilder text = new StringBuilder();
            foreach (IssueString s in _issue_query_strings)
            {
                string strUri = "";
                string strError = "";

                // 获得指定一期的封面图片 URI
                // parameters:
                //      strBiblioPath   书目记录路径
                //      strQueryString  检索词。例如 “2005|1|1000|50”。格式为 年|期号|总期号|卷号。一般为 年|期号| 即可。
                int nRet = channel.GetIssueCoverImageUri(null,
                    this.BiblioRecPath,
                    s.Query,
                    strPrefferSize,
                    out strUri,
                    out strError);
                if (nRet == -1)
                {
                    strError = "(用户 '" + channel.UserName + "') " + strError;
                    text.Append("<div>" + HttpUtility.HtmlEncode(strError) + "</div>");
                    continue;
                }

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

                string strUrl = "";

                if (string.IsNullOrEmpty(strUri))
                {
                    if (StringUtil.IsInList("displayBlank", displayBlank) == false)
                        continue;

                    if (strPrefferSize == "LargeImage")
                        strUrl = MyWebPage.GetStylePath(app, "blankcover_large.png");
                    else
                        strUrl = MyWebPage.GetStylePath(app, "blankcover_medium.png");
                }
                else
                {
                    strUrl = "./getobject.aspx?uri=" + HttpUtility.UrlEncode(strUri);
                    nNotBlankCount++;
                }

                text.Append("<div class='issue_cover' ><img src='" + strUrl + "' alt='封面图像' ></img><div class='issue_no'>" + HttpUtility.HtmlEncode(s.Volume) + "</div></div>");
            }

            if (StringUtil.IsInList("hideWhenAllBlank", displayBlank) == true
                && nNotBlankCount == 0)
            {

            }
            else
            {
                LiteralControl literal = new LiteralControl();
                literal.ID = "";
                literal.Text = "<div class='issue_cover_frame' >" + text.ToString() + "</div>";
                line.Controls.Add(literal);
            }

            _issue_query_strings.Clear();
        }