Ejemplo n.º 1
0
        private void m_bte_add_Click(object sender, EventArgs e)
        {
            String albumName  = m_tbx_albumname.Text;
            String albumLabel = m_tbx_albumtags.Text;
            String albumIntro = m_tbx_albumintro.Text;

            if (String.IsNullOrEmpty(albumName))
            {
                MessageBox.Show("专辑名称不能为空");
                m_tbx_albumname.Focus();
                return;
            }
            // TODO: 判断是否选择了category
            // String albumCategoryId = "[10000000, 10001000, 10001001]";
            HGComCategory        hgcc   = HGData.getInstance().ComCategory[m_cbx_albumcat1.SelectedIndex];
            int                  cat1   = hgcc.Value;
            HGComCategoryItem    hgcci  = hgcc.Children[m_cbx_albumcat2.SelectedIndex];
            int                  cat2   = hgcci.Value;
            HGComCategorySubItem hgccsi = hgcci.Children[m_cbx_albumcat3.SelectedIndex];
            int                  cat3   = hgccsi.Value;

            Console.WriteLine("cat1 " + cat1 + " cat2 " + cat2 + "cat3 " + cat3);
            // TODO: 是否一定要封面?
            if (m_hg_iur == null)
            {
                MessageBox.Show("请上传专辑封面");
                return;
            }
            String albumCoverUrl = HGRestfulAPI.FileServerBaseUrl + m_hg_iur.Url;
            String albumFileId   = m_hg_iur.Data.FileId;

            Model.HGAlbumParams hgap = new HGAlbumParams(albumName, (int)m_album_type, albumIntro, albumCoverUrl, albumFileId, albumLabel, 10000000, 10001000, 10000001);
            if (Helpers.DebugHelper.getInstance().FakeNewAlbum)
            {
                hgap = new HGAlbumParams("70周年大阅兵7", (int)m_album_type, "70周年大阅兵,简介", "https://filetest.hongkazhijia.com/cb/cb7a88314621ad93ce4f9c5fe0495c942953197489e01f925162314153baa0a2.jpg", "cb7a88314621ad93ce4f9c5fe0495c942953197489e01f925162314153baa0a2", "70周年", 10000000, 10001000, 10000001);
            }
            try
            {
                // bool newAlbumOK = HGRestfulAPI.getInstance().newHGAlbum(albumName, 1, albumIntro, albumCoverUrl, albumFileId, albumLabel, albumCategoryId);
                bool newAlbumOK = HGRestfulAPI.getInstance().newHGAlbum(hgap);
                if (newAlbumOK)
                {
                    MessageBox.Show("专辑《" + albumName + "》创建成功");
                }
                else
                {
                    MessageBox.Show("专辑《" + albumName + "》创建失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            this.Close();
        }
Ejemplo n.º 2
0
        public bool newHGAlbum(HGAlbumParams hgap)
        {
            String resturl = "/platform/album/add";

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

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

            return(true);
        }