Beispiel #1
0
        private async void MakeConnexion()
        {
            try
            {
                var connec = new HttpWebRequestPost();
                await connec.ConnexionSimple(_username, _password);
                var res = connec.Received;
                GetUser(res);
                MainWindow.ConnectionWindow.Close();

            }
            catch
            {
                MessageBox.Show("Erreur de connexion", "Erreur");
                return;
            }
        }
Beispiel #2
0
        public async void do_upload(int begin, int end)
        {
            string postData;
            string fileData;

            // creating request
            HttpWebRequestPost post = new HttpWebRequestPost();
            var request = (HttpWebRequest)WebRequest.Create(ArtistUrl + "/musics/uploadRediff");

            try
            {
                if (file.Length - begin >= char_nb)
                {
                    end += char_nb;
                    fileData = file.Substring(begin, char_nb);
                    postData = "filename=" + filename.Remove(filename.Length - 4) + "&data=" + WebUtility.UrlEncode(fileData) + "&user_id=" + Singleton.Singleton.Instance().TheArtiste.id.ToString() + "&secureKey=" + Security.getSecureKey(Singleton.Singleton.Instance().TheArtiste.id.ToString());
                    begin += char_nb;
                }
                else
                {
                    end = file.Length - begin;
                    fileData = file.Substring(begin, end);
                    if (fileData == "")
                        return;
                    postData = "filename=" + filename.Remove(filename.Length - 4) + "&data=" + WebUtility.UrlEncode(fileData) + "&user_id=" + Singleton.Singleton.Instance().TheArtiste.id.ToString() + "&secureKey=" + Security.getSecureKey(Singleton.Singleton.Instance().TheArtiste.id.ToString());
                    await post.GetHttpPostResponse(request, postData);

                    do_finish(); // --> END
                    return; // --> END
                }

                var response = await post.GetHttpPostResponse(request, postData);

                dynamic json = JObject.Parse(response).SelectToken("message");
                if (json == "Error")
                    MessageBox.Show("Erreur lors de la phase d'upload");
                
                do_upload(begin, end);
            }
            catch
            {
                MessageBox.Show("Erreur lors de la phase d'upload");
                return;
            }
        }
Beispiel #3
0
        public async void do_finish()
        {
            // /musics/uploadRediff ?finish=nimportequoi & album_id, music_name, duration, price, filename, limited
            HttpWebRequestPost post = new HttpWebRequestPost();
            var request = (HttpWebRequest)WebRequest.Create(ArtistUrl + "/musics/uploadRediff");

            try
            {
                dynamic json = JObject.Parse(album_response).SelectToken("content");

                string postData = "finish=" + "1"
                        + "&album_id=" + json.id
                        + "&music_name=" + WebUtility.UrlEncode(track_tb.Text)
                        + "&duration=" + duration
                        + "&price=" + price_tb.Text
                        + "&filename=" + filename.Remove(filename.Length - 4)
                        + "&limited=" + "false"
                        + "&user_id=" + Singleton.Singleton.Instance().TheArtiste.id
                        + "&secureKey=" + Security.getSecureKey(Singleton.Singleton.Instance().TheArtiste.id.ToString());

                await post.GetHttpPostResponse(request, postData);
                MessageBox.Show("Upload terminé");

            }
            catch
            {
                MessageBox.Show("Erreur lors de fin de l'upload");
                return;
            }
        }
Beispiel #4
0
        public async Task<bool> do_album()
        {
            // /musics/createAlbumSoftware    album_name, price, yearProd
            HttpWebRequestPost post = new HttpWebRequestPost();
            var request = (HttpWebRequest)WebRequest.Create(ArtistUrl + "/musics/createAlbumSoftware");

            try
            {
                string postData = "album_name=" + WebUtility.UrlEncode(album_tb.Text)
                                + "&price=" + price_tb.Text
                                + "&yearProd=" + DateTime.Now.Year.ToString()
                                + "&user_id=" + Singleton.Singleton.Instance().TheArtiste.id.ToString()
                                + "&secureKey=" + Security.getSecureKey(Singleton.Singleton.Instance().TheArtiste.id.ToString());

                album_response = await post.GetHttpPostResponse(request, postData);
                return true;
            }
            catch
            {
                MessageBox.Show("Erreur lors de la creation de l'album");
                return false;
            }
        }