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 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();
        }
Beispiel #3
0
        public NewAlbumForm(ContentPublishPanel.AlbumType album_type)
        {
            InitializeComponent();
            m_album_type = album_type;

            m_cbx_albumcat1.Items.AddRange(HGData.getInstance().ComCategory);
            if (m_cbx_albumcat1.Items.Count > 0)
            {
                m_cbx_albumcat1.SelectedItem = m_cbx_albumcat1.Items[0];
            }
        }
Beispiel #4
0
 private void m_cbx_albumcat2_SelectedIndexChanged(object sender, EventArgs e)
 {
     Console.WriteLine(m_cbx_albumcat1.SelectedIndex);
     object[] cat3 = HGData.getInstance().ComCategory[m_cbx_albumcat1.SelectedIndex].Children[m_cbx_albumcat2.SelectedIndex].Children;
     m_cbx_albumcat3.Items.Clear();
     m_cbx_albumcat3.Items.AddRange(cat3);
     if (m_cbx_albumcat3.Items.Count > 0)
     {
         m_cbx_albumcat3.SelectedItem = m_cbx_albumcat3.Items[0];
     }
 }
Beispiel #5
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 #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            m_uc_offset = 90;

            InitNavigators();

            ButtonExChecked(m_btn_content);

            m_btn_content_Click(this, null);

            try {
                HGData.getInstance().ComCategory = HGRestfulAPI.getInstance().getHGComCategory();
                if (HGData.getInstance().ComCategory == null)
                {
                    MessageBox.Show("获取专辑分类失败,如服务器原因,请联系管理员。");
                }
            } catch (Exception ex)
            {
                MessageBox.Show("获取专辑分类失败,如服务器原因,请联系管理员。错误:" + ex.Message);
                HGData.getInstance().ComCategory = null;
            }
        }
Beispiel #7
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]);
                }
            }
        }
Beispiel #8
0
        private void m_bte_login_Click(object sender, EventArgs e)
        {
            String mobile   = m_tbx_mobile.Text;   // "13488613602";// "15811208494";
            String password = m_tbx_password.Text; // "hongka1018";
            String vcode    = m_tbx_captcha.Text;

            if (DebugHelper.getInstance().FastUserLogin)
            {
                mobile   = "13488613602";
                password = "******";
                vcode    = "eq32";
            }

            if (mobile.Equals("请输入手机号"))
            {
                MessageBox.Show("手机号不能为空");
                return;
            }
            if (password.Equals("请输入密码"))
            {
                MessageBox.Show("密码不能为空");
                return;
            }
            if (vcode.Equals("请输入验证码"))
            {
                MessageBox.Show("验证码不能为空");
                return;
            }
            // TODO: don't do the following, just for debug
            if (DebugHelper.getInstance().IsServerFail&& mobile != null)
            {
                MainForm mf = new MainForm();
                this.Hide();
                mf.ShowDialog();
                Application.ExitThread(); // mainthread change to MainForm
                return;
            }

            if (!isValidMobileNo(mobile))
            {
                MessageBox.Show("请输入正确的手机号");
                m_tbx_mobile.Focus();
                return;
            }

            if (m_hg_captcha == null)
            {
                MessageBox.Show("验证码未更新,请点击验证码图片,重新更新验证码");
                return;
            }

            String vtoken = m_hg_captcha.Vtoken;

            try
            {
                HGUser hgu = HGRestfulAPI.getInstance().login(mobile, password, vcode, vtoken);

                if (hgu != null)
                {
                    HGData.getInstance().User = hgu;
                    MainForm mf = new MainForm();
                    this.Hide();
                    mf.ShowDialog();
                    Application.ExitThread(); // mainthread change to MainForm
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }