Пример #1
0
 private LibrarySearchResponse(HttpRequestBase request, LibrarySearchResult result)
     : base(result.User)
 {
     var keyword = result.Keyword;
     var moreUrl = result.MoreUrl;
     var books = result.Books;
     var converter = new UrlToAbsConverter(request);
     this.Articles = new List<Article>()
         {
             new Article
             {
                 Title = new StringXmlCDataSection(String.Format("搜索 {0} 的结果: {1}/{2}页", keyword, result.CurrentPage, result.PageCount)),
                 Description = new StringXmlCDataSection(keyword),
                 PicUrl = new StringXmlCDataSection(converter.Convert("/Content/images/lib.jpg")),
                 Url = new StringXmlCDataSection(converter.Convert("/Home/About")),
             }
         };
     if (books != null && books.Count > 0)
     {
         var bookArticles = from book in books
                            select new Article
                            {
                                Title = new StringXmlCDataSection(String.Format("[{0} 馆藏:{1}/{2}] {3} ({4})",
                                    book.Index, book.Available, book.Total, book.Title, book.Author)),
                                Description = new StringXmlCDataSection(keyword),
                                PicUrl = book.Available > 0 ?
                                    new StringXmlCDataSection(converter.Convert("/Content/Images/green_circle.png")) :
                                    new StringXmlCDataSection(converter.Convert("/Content/Images/red_circle.png")),
                                Url = new StringXmlCDataSection(getDetailUrl(converter, book.Url))
                            };
         this.Articles.AddRange(bookArticles);
         this.Articles.Add(new Article
         {
             Title = new StringXmlCDataSection(CMD),
             PicUrl = new StringXmlCDataSection(converter.Convert("/Content/Images/frog.jpg")),
             Url = new StringXmlCDataSection(converter.Convert("/Home/About"))
         });
     }
     else
     {
         this.Articles.Add(new Article
         {
             Title = new StringXmlCDataSection("没有匹配项"),
             PicUrl = new StringXmlCDataSection(converter.Convert("/Content/Images/frog.jpg")),
             Url = new StringXmlCDataSection(converter.Convert("/Home/About"))
         });
     }
 }
 private static string getDetailUrl(UrlToAbsConverter converter, string postfix)
 {
     return converter.Convert("/Library/Details?url=" + HttpUtility.UrlEncode(postfix));
 }
Пример #3
0
 private static NewsResponse getWebAppRsp(string user, HttpRequestBase request)
 {
     if (sArticles[0].Url == null)
     {
         var converter = new UrlToAbsConverter(request);
         sArticles[0].Url = new WeixinResponse.StringXmlCDataSection(converter.Convert("/Library"));
         sArticles[0].PicUrl = new WeixinResponse.StringXmlCDataSection(converter.Convert("/Content/Images/frog.jpg"));
     }
     return new NewsResponse(user) { Articles = sArticles };
 }