示例#1
0
        private void LoadAlbums()
        {
            // TODO: 这个判断很重要,因为PagerControl会多次调用PageChange,没有必要我们不要多次调用网络。
            if (m_curr_page == m_pgc_morealbum.CurrentPage && m_curr_rows_per_page == m_pgc_morealbum.RowsPerPage)
            {
                Console.WriteLine("No need to do duplicated operation");
                return;
            }
            HGAlbumSearchParams hgasp = new HGAlbumSearchParams(m_pgc_morealbum.CurrentPage, m_pgc_morealbum.RowsPerPage);

            m_curr_page          = m_pgc_morealbum.CurrentPage;
            m_curr_rows_per_page = m_pgc_morealbum.RowsPerPage;
            HGData.getInstance().Album = HGRestfulAPI.getInstance().getHGAlbum(hgasp);
            HGAlbum hga = HGData.getInstance().Album;

            if (hga == null)
            {
                return;
            }
            m_pgc_morealbum.RecordCount = hga.Total;

            foreach (AlbumInfo ai in m_albums)
            {
                this.Controls.Remove(ai);
            }
            m_albums.Clear();
            for (int i = 0; i < hga.Data.Length; i++)
            {
                HGAlbumItem hgai = hga.Data[i];

                AlbumInfo ai = new AlbumInfo(m_album_type, hgai);
                ai.AlbumName = hgai.AlbumName;
                if (!String.IsNullOrEmpty(hgai.FileUrl))
                {
                    try
                    {
                        MemoryStream ms = new MemoryStream();
                        Util.Download(HGRestfulAPI.FileServerBaseUrl + hgai.FileUrl, ms);
                        ai.AlbumImage = Image.FromStream(ms);
                    }
                    catch (Exception ex)
                    {
                        //TODO; don't do that, just log
                        MessageBox.Show("下载网络图片" + hgai.FileUrl + "失败:" + ex.Message);
                    }
                }
                ai.ClickEventHandler += ShowAlbumDetail;

                m_albums.Add(ai);
            }
            ShowAlbums();
        }
示例#2
0
        public HGAlbum getHGAlbum(HGAlbumSearchParams hgasp)
        {
            String resturl = "/platform/album/query";

            if (hgasp == null)
            {
                throw new Exception("查询专辑传递的参数为空");
            }
            string json_params = JsonConvert.SerializeObject(hgasp);

            Console.WriteLine(json_params);
            String  res     = HttpHelper.HttpPostJsonData(BaseUrl + resturl, json_params, buildHeaderParams(null));
            HGAlbum hgalbum = parseHGData <HGAlbum>(res);

            return(hgalbum);
        }
示例#3
0
        public void displayAlbums()
        {
            HGAlbum hga = HGData.getInstance().Album;

            if (hga == null)
            {
                return;
            }
            for (int i = 0; i < hga.Data.Length; i++)
            {
                HGAlbumItem hgai = hga.Data[i];
                AlbumType   at   = (AlbumType)hgai.AlbumType;
                if (at == AlbumType.AudioAlbum)
                {
                    Console.WriteLine("Audio : " + hga.Data[i].AlbumName + " Url: " + hga.Data[i].FileUrl);
                    m_alp_audio.addAlbum(hga.Data[i]);
                }
                else if (at == AlbumType.VideoAlbum)
                {
                    Console.WriteLine("Video : " + hga.Data[i].AlbumName + " Url: " + hga.Data[i].FileUrl);
                    m_alp_video.addAlbum(hga.Data[i]);
                }
            }
        }