Beispiel #1
0
        private void initAlbums()
        {
            // TODO: 根据界面参数来生成搜索参数
            HGAlbumSearchParams hgasp = new HGAlbumSearchParams(1, 10);

            HGData.getInstance().Album = HGRestfulAPI.getInstance().getHGAlbum(hgasp);
            // HGAlbum hga = HGRestfulAPI.getInstance().getHGAlbum(1, "", 2, 1521738981174, 1541738981174, 1, 10);
        }
Beispiel #2
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();
        }
Beispiel #3
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);
        }