Beispiel #1
0
        /// <summary>
        /// 获得相册的JSON格式数据
        /// </summary>
        /// <param name="albumid">相册ID</param>
        /// <returns></returns>
        public static string GetAlbumJsonData(int albumid)
        {
            DataTable     dtAlbum = Data.DbProvider.GetInstance().GetPhotosByAlbumid(albumid);
            StringBuilder builder = new StringBuilder();

            builder.Append("{\"items\":[");
            foreach (DataRow dr in dtAlbum.Rows)
            {
                if (dr["filename"].ToString().Trim().ToLower().IndexOf("http") == 0)
                {
                    builder.AppendFormat(@"{{""photoid"":{0},""userid"":{1},""title"":""{2}"",""image"":""{3}"",""square"":""{4}"",""thumbnail"":""{5}""}},", dr["photoid"], dr["userid"], dr["title"].ToString().Trim().Replace("\"", "\\\""), dr["filename"].ToString().Trim(), Globals.GetSquareImage(dr["filename"].ToString().Trim()), Globals.GetThumbnailImage(dr["filename"].ToString().Trim()));
                }
                else
                {
                    builder.AppendFormat(@"{{""photoid"":{0},""userid"":{1},""title"":""{2}"",""image"":""{3}"",""square"":""{4}"",""thumbnail"":""{5}""}},", dr["photoid"], dr["userid"], dr["title"].ToString().Trim().Replace("\"", "\\\""), BaseConfigs.GetForumPath + dr["filename"].ToString().Trim(), Globals.GetSquareImage(BaseConfigs.GetForumPath + dr["filename"].ToString().Trim()), Globals.GetThumbnailImage(BaseConfigs.GetForumPath + dr["filename"].ToString().Trim()));
                }
            }
            builder.Remove(builder.Length - 1, 1);
            builder.Append("]}");
            return(builder.ToString());
        }