Exemple #1
0
        private void DownloadMusicExecute()
        {
            var request = new HttpRequestGet();
            var res = request.GetObject(new Music(), "musics", SelectedMusic.id.ToString());
            res.ContinueWith(delegate(Task<object> task)
            {
                var music = task.Result as Music;
                if (music != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                        () =>
                        {
                            SelectedMusic = music;
                            SelectedMusic.file = "http://soonzikapi.herokuapp.com/musics/get/" + SelectedMusic.id;

                            DownloadFile();
                        });
                }
            });
        }
 private void ArtistStackPanel_OnTapped(object sender, TappedRoutedEventArgs e)
 {
     var get = new HttpRequestGet();
     var res = get.GetObject(new User(), "users", SelectedArtist.id.ToString());
     res.ContinueWith(delegate(Task<object>tmp)
     {
         var user = tmp.Result as User;
         if (user != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     user.profilImage =
                         new BitmapImage(new Uri(Constant.UrlImageUser + user.image, UriKind.RelativeOrAbsolute));
                     ProfilArtisteViewModel.TheUser = user;
                     SetChildren(new ProfilArtiste());
                 });
         }
     });
 }
Exemple #3
0
 private static async void CheckConversation()
 {
     var localFolder = ApplicationData.Current.LocalFolder;
     try
     {
         // Getting JSON from file if it exists, or file not found exception if it does not  
         var textFile = await localFolder.GetFileAsync("conversations");
         if (textFile == null)
         {
             var localFolder2 = ApplicationData.Current.LocalFolder;
             textFile = await localFolder2.CreateFileAsync("conversations",
                 CreationCollisionOption.ReplaceExisting);
         }
         using (IRandomAccessStream textStream = await textFile.OpenReadAsync())
         {
             // Read text stream     
             using (var textReader = new DataReader(textStream))
             {
                 //get size                       
                 var textLength = (uint) textStream.Size;
                 await textReader.LoadAsync(textLength);
                 // read it                    
                 var jsonContents = textReader.ReadString(textLength);
                 // deserialize back to our product!  
                 var getConv = JsonConvert.DeserializeObject<ObservableCollection<Message>>(jsonContents);
                 if (getConv.Count == _conversation.Count)
                 {
                     return;
                 }
                 AgileCallback();
                 var newList = new ObservableCollection<Message>();
                 for (var i = getConv.Count; i < _conversation.Count; i++)
                 {
                     if (_conversation[i].user_id != Singleton.Singleton.Instance().CurrentUser.id)
                         newList.Add(_conversation[i]);
                 }
                 var req = new HttpRequestGet();
                 foreach (var message in newList)
                 {
                     var user = req.GetObject(new User(), "users", message.user_id.ToString());
                     user.ContinueWith(delegate(Task<object> task)
                     {
                         var res = task.Result as User;
                         if (res != null)
                         {
                             var toastType = ToastTemplateType.ToastText02;
                             var toastXml = ToastNotificationManager.GetTemplateContent(toastType);
                             var toastTextElement = toastXml.GetElementsByTagName("text");
                             toastTextElement[0].AppendChild(
                                 toastXml.CreateTextNode("New Message from " + res.username));
                             var toastNode = toastXml.SelectSingleNode("/toast");
                             ((XmlElement) toastNode).SetAttribute("duration", "long");
                             var toast = new ToastNotification(toastXml);
                             ToastNotificationManager.CreateToastNotifier().Show(toast);
                         }
                     });
                 }
             }
         }
     }
     catch (Exception ex)
     {
         var Text = "Exception: " + ex.Message;
     }
 }
Exemple #4
0
 private void PlayCommandExecute()
 {
     if (SelecMusic != null)
         SelectedMusic = SelecMusic;
     var request = new HttpRequestGet();
     var res = request.GetObject(new Music(), "musics", SelectedMusic.id.ToString());
     res.ContinueWith(delegate(Task<object> task)
     {
         var music = task.Result as Music;
         if (music != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     SelectedMusic = music;
                     SelectedMusic.file = "http://soonzikapi.herokuapp.com/musics/get/" + SelectedMusic.id;
                     Singleton.Singleton.Instance().SelectedMusicSingleton.Clear();
                     Singleton.Singleton.Instance().SelectedMusicSingleton.Add(SelectedMusic);
                     GlobalMenuControl.MyPlayerToggleButton.IsChecked = true;
                     GlobalMenuControl.SetPlayerAudio();
                 });
         }
     });
 }
Exemple #5
0
 public void LoadContent()
 {
     ListArtiste = new ObservableCollection<User>();
     ListMusique = new ObservableCollection<Music>();
     ListInfluences = new ObservableCollection<Influence>();
     ListAmbiance = new ObservableCollection<Ambiance>();
     var request = new HttpRequestGet();
     try
     {
         var listIdentities = request.GetIdentities(new List<Identities>(), Singleton.Singleton.Instance().CurrentUser.id.ToString(), Singleton.Singleton.Instance().SecureKey);
         listIdentities.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Identities>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     if (item.provider == "soundcloud")
                     {
                         var post = new HttpRequestPost();
                         var result = post.GetMusicalPast(item.uid, Singleton.Singleton.Instance().SecureKey,
                             Singleton.Singleton.Instance().CurrentUser.id.ToString());
                         result.ContinueWith(delegate(Task<string> t) { var res = t.Result; });
                     }
                 }
             }
         });
         var listGenre = request.GetListObject(new List<Influence>(), "influences");
         listGenre.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Influence>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                         () => { ListInfluences.Add(item); });
                 }
             }
         });
         var listUser = request.GetListObject(new List<User>(), "users");
         listUser.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<User>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     var res = request.GetArtist(new Artist(), "users", item.id.ToString());
                     res.ContinueWith(delegate(Task<object> obj)
                     {
                         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                             () =>
                             {
                                 var art = obj.Result as Artist;
                                 item.profilImage =
                                     new BitmapImage(new Uri(Constant.UrlImageUser + item.image,
                                         UriKind.RelativeOrAbsolute));
                                 if (art != null && art.artist)
                                     ListArtiste.Add(item);
                             });
                     });
                 }
             }
         });
         ValidateKey.GetValideKey();
         var listZik = request.GetSuggest(new List<Music>(), "music");
         listZik.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Music>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                         CoreDispatcherPriority.Normal,
                         () =>
                         {
                             item.album.imageAlbum =
                                 new BitmapImage(new Uri(Constant.UrlImageAlbum + item.album.image,
                                     UriKind.RelativeOrAbsolute));
                             ListMusique.Add(item);
                         });
                 }
             }
         });
         var listAmb = request.GetListObject(new List<Ambiance>(), "ambiances");
         listAmb.ContinueWith(delegate(Task<object> task)
         {
             var test = listAmb.Result as List<Ambiance>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                         CoreDispatcherPriority.Normal,
                         () =>
                         {
                             var ambiance = request.GetObject(new Ambiance(), "ambiances", item.id.ToString());
                             ambiance.ContinueWith(delegate(Task<object> task1)
                             {
                                 var am = task1.Result as Ambiance;
                                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                                     CoreDispatcherPriority.Normal,
                                     () =>
                                     {
                                         foreach (var music in am.musics)
                                         {
                                             music.album.imageAlbum =
                                                 new BitmapImage(
                                                     new Uri(Constant.UrlImageAlbum + music.album.image,
                                                         UriKind.RelativeOrAbsolute));
                                         }
                                         ListAmbiance.Add(am);
                                     });
                             });
                         });
                 }
             }
         });
     }
     catch (Exception e)
     {
         //new MessageDialog("probleme reseau : " + e.Message).ShowAsync();
     }
 }
Exemple #6
0
        private void UpdatePlaylistExecute()
        {
            var request = new HttpRequestGet();

            var res = request.GetObject(new Playlist(), "playlists", ThePlaylist.id.ToString());
            res.ContinueWith(delegate(Task<object> tmp)
            {
                var pl = tmp.Result as Playlist;
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                    () =>
                    {
                        if (pl != null)
                            ThePlaylist = pl;
                    });
            });
        }
 private void GetUser()
 {
     var request = new HttpRequestGet();
     var res = request.GetObject(new User(), "users", Friend.ToString());
     res.ContinueWith(delegate(Task<object> tmp)
     {
         var user = tmp.Result as User;
         if (user != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     TheUser = user;
                     if (user.groups.Count > 0)
                     {
                         if (user.groups[0].name == "User")
                             ProfilFriendViewModel.UserFromButton = user;
                         else if (user.groups[0].name == "Artist")
                             ProfilArtisteViewModel.TheUser = user;
                     }
                     else
                     {
                         ProfilFriendViewModel.UserFromButton = user;
                     }
                 });
         }
     });
 }
Exemple #8
0
        public void Charge()
        {
            var request = new HttpRequestGet();

            var test = request.GetObject(new User(), "users", Instance().NewProfilUser.ToString());
            test.ContinueWith(delegate(Task<object> tmp)
            {
                var res = tmp.Result as User;
                if (res != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                        () => { SelectedUser = res; });
                }
            });
        }
 private void Vote(HttpRequestPost post, string cryptographic, HttpRequestGet get, string artistId)
 {
     var resPost = post.Vote(cryptographic, CurrentBattle.id.ToString(), artistId,
         Singleton.Singleton.Instance().CurrentUser.id.ToString());
     resPost.ContinueWith(delegate(Task<string> tmp)
     {
         var test = tmp.Result;
         if (test != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 var resGet = get.GetObject(new Battle(), "battles", CurrentBattle.id.ToString());
                 resGet.ContinueWith(
                     delegate(Task<object> newBattle) { CurrentBattle = newBattle.Result as Battle; });
                 InitializeData();
             });
         }
     });
 }
Exemple #10
0
 private void SelectionCommandExecute()
 {
     ListGenreSelected = new ObservableCollection<Genre>();
     var get = new HttpRequestGet();
     foreach (var genre in TheListGenres)
     {
         var res = get.GetObject(new Genre(), "genres", genre.id.ToString());
         res.ContinueWith(delegate(Task<object> task)
         {
             var r = task.Result as Genre;
             if (r != null)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                 {
                     foreach (var mus in r.musics)
                     {
                         mus.album.imageAlbum =
                             new BitmapImage(new Uri(Constant.UrlImageAlbum + mus.album.image,
                                 UriKind.RelativeOrAbsolute));
                     }
                     ListGenreSelected.Add(r);
                 });
             }
         });
     }
 }