public string BuildJson() { string gid = linkID.Split('_')[1]; string aid = linkID.Split('_')[0]; Article a = ThisArticle; ShopWindow win = new ShopWindow(); win.GroupID = gid; win.LinkID = linkID; ShopWindowImage img = new ShopWindowImage(); if (a != null) { img.StyleNumber = a.ID.Trim('{').Trim('}').Split('-')[4]; img.Name = a.Title; img.Desc = BuildContent(a.Content); img.Thumbnail = GetThumbUrl(a.Thumbnail, "_pt"); img.MinThumbnail = GetThumbUrl(a.Thumbnail, "_pm"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "f"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "b"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "l"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "r"); win.Images.Add(img); } return(win.ToJson(ThisArticle.Title, img.Thumbnail)); }
public void LoadData(string cid) { List <Article> list = ArticleHelper.QueryArticlesByChannel(cid, true); if (list == null) { return; } int i = 0; foreach (Article a in list) { string guid = i++.ToString(); ShopWindow win = new ShopWindow(); Data.Add(win); win.GroupID = guid; win.LinkID = a.ID + "_" + guid; ShopWindowImage img = new ShopWindowImage(); img.StyleNumber = a.ID.Trim('{').Trim('}').Split('-')[4]; img.Name = a.Title; img.Desc = a.Content; img.Thumbnail = GetThumbUrl(a.Thumbnail, "_pt"); img.MinThumbnail = GetThumbUrl(a.Thumbnail, "_pm"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "f"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "b"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "l"); AddThumb(img.Full, img.Zoom, a.Thumbnail, "r"); win.Images.Add(img); } }
string BuildImage(ShopWindowImage img) { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.AppendFormat("{0}:'{1}'", "style_number", img.StyleNumber); //sb.AppendFormat(",{0}:'{1}'", "display_style_number", img.StyleNumber); sb.AppendFormat(",{0}:'{1}'", "display_style_number", ""); sb.Append(",images:{"); sb.Append("mpi:["); for (int i = 0; i < img.Full.Count; i++) { if (i != 0) { sb.Append(","); } sb.AppendFormat("'{0}'", img.Full[i]); } sb.Append("]"); sb.AppendFormat(",is360:{0}", img.Zoom.Count); sb.AppendFormat(",{0}:'{1}'", "full", img.Full.Count > 0 ? img.Full[0] : ""); sb.Append(",zoom:["); for (int i = 0; i < img.Zoom.Count; i++) { if (i != 0) { sb.Append(","); } sb.AppendFormat("'{0}'", img.Zoom[i]); } sb.Append("]"); sb.AppendFormat(",{0}:'{1}'", "panel_thumb", img.Thumbnail); sb.AppendFormat(",{0}:'{1}'", "miniThumb", img.MinThumbnail); sb.AppendFormat(",{0}:'{1}'", "thumb", img.Thumbnail); sb.Append("}"); sb.Append(",text:{"); sb.AppendFormat("{0}:'{1}'", "grpdesc", img.Name); sb.AppendFormat(",{0}:'{1}'", "vardesc", img.Desc); sb.Append("}"); sb.Append(",path:'/spring-summer-10/handbags/'"); sb.Append(",collection:'Spring Summer'"); sb.Append(",department:'HANDBAGS'"); sb.Append("}"); return(sb.ToString()); }
void BuildImageList(StringBuilder sb, List <ShopWindowImage> list) { if (list.Count > 0) { ShopWindowImage orign = list[0]; sb.Append(",leadStyle:"); sb.Append(BuildImage(orign)); sb.Append(",variations:["); for (int i = 1; i < list.Count; i++) { ShopWindowImage vari = list[i]; sb.Append(BuildImage(vari)); } sb.Append("]"); } }