示例#1
0
 private void DelFriend(HttpRequestPost post, string cryptographic, HttpRequestGet get)
 {
     var resPost = post.DelFriend(cryptographic, Friend.ToString(),
         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 followers = get.GetFriends(new List<User>(), "users",
                     Singleton.Singleton.Instance().CurrentUser.id.ToString());
                 followers.ContinueWith(delegate(Task<object> task1)
                 {
                     var res = task1.Result as List<User>;
                     if (res != null)
                     {
                         Singleton.Singleton.Instance().CurrentUser.friends.Clear();
                         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                             () =>
                             {
                                 foreach (var user in res)
                                 {
                                     Singleton.Singleton.Instance().CurrentUser.friends.Add(user);
                                 }
                                 ServiceLocator.Current.GetInstance<MyNetworkViewModel>().UpdateFriend();
                                 new MessageDialog("Suppression OK").ShowAsync();
                             });
                     }
                 });
             });
         }
     });
 }
示例#2
0
        public static void GetUserKeyForFriend(string id, bool friend)
        {
            var post = new HttpRequestPost();
            var get = new HttpRequestGet();

            ValidateKey.GetValideKey();
            if (!friend)
                AddFriend(post, Singleton.Singleton.Instance().SecureKey, get, id);
            else
                DelFriend(post, Singleton.Singleton.Instance().SecureKey, get, id);
        }
示例#3
0
 public static void GetValideKey()
 {
     if (CheckValidateKey()) return;
     var get = new HttpRequestGet();
     var userKey = get.GetUserKey(Singleton.Singleton.Instance().CurrentUser.id.ToString());
     userKey.ContinueWith(delegate(Task<object> task)
     {
         var key = task.Result as String;
         if (key != null)
         {
             var obj = JsonConvert.DeserializeObject(key, typeof (Key)) as Key;
             var stringEncrypt = obj.key;
             Singleton.Singleton.Instance().Key = obj;
             Singleton.Singleton.Instance().SecureKey =
                 EncriptSha256.EncriptStringToSha256(Singleton.Singleton.Instance().CurrentUser.salt +
                                                     stringEncrypt);
         }
     });
 }
示例#4
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();
                        });
                }
            });
        }
示例#5
0
        public static void LoadConversation()
        {
            try
            {
                ValidateKey.GetValideKey();
                var get = new HttpRequestGet();
                var res = get.FindConversation(new List<Message>(), Singleton.Singleton.Instance().SecureKey,
                    Singleton.Singleton.Instance().CurrentUser.id.ToString());
                res.ContinueWith(delegate(Task<object> tmp2)
                {
                    var result = tmp2.Result as List<Message>;
                    if (result != null)
                    {
                        _conversation = new ObservableCollection<Message>(result);
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                            CheckConversation);
                    }
                });
            }
            catch (Exception)
            {
            }

        }
示例#6
0
 private void LoadBattle()
 {
     var request = new HttpRequestGet();
     var listBattle = request.GetListObject(new List<Battle>(), "battles");
     listBattle.ContinueWith(delegate(Task<object> tmp)
     {
         var test = tmp.Result as List<Battle>;
         if (test != null)
         {
             foreach (var item in test)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     () =>
                     {
                         item.artist_one.image = "http://soonzikapi.herokuapp.com/assets/usersImage/avatars/" +
                                                 item.artist_one.image;
                         item.artist_two.image = "http://soonzikapi.herokuapp.com/assets/usersImage/avatars/" +
                                                 item.artist_two.image;
                         ListBattles.Add(item);
                     });
             }
         }
     });
 }
示例#7
0
        public void Charge()
        {
            var request = new HttpRequestGet();

            var listNews = request.GetListNews(new List<News>(), "news", Singleton.Singleton.Instance().CurrentUser.language);
            listNews.ContinueWith(delegate(Task<object> tmp)
            {
                var test = tmp.Result as List<News>;
                if (test != null)
                {
                    foreach (var item in test)
                    {
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                            () =>
                            {
                                item.attachments[0].url =
                                    new Uri(UrlImage + item.attachments[0].url, UriKind.RelativeOrAbsolute).ToString();
                                ListNews.Add(item);
                            });
                    }
                }
            });
        }
示例#8
0
        private void DelToPlaylistExecute()
        {
            if (ThePlaylist != null)
            {
                _selectedMusic = SelectedMusic;
                var request = new HttpRequestGet();

                ValidateKey.GetValideKey();
                var resDel = request.DeleteMusicFromPlaylist(ThePlaylist, _selectedMusic,
                    Singleton.Singleton.Instance().SecureKey,
                    Singleton.Singleton.Instance().CurrentUser);

                resDel.ContinueWith(delegate(Task<string> tmp)
                {
                    var test = tmp.Result;
                    if (test != null)
                    {
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                            () =>
                            {
                                var stringJson = JObject.Parse(test).SelectToken("code").ToString();
                                if (stringJson == "200")
                                {
                                    new MessageDialog(loader.GetString("MusicDelete")).ShowAsync();
                                    UpdatePlaylist.Execute(null);
                                }
                                else
                                {
                                    new MessageDialog(loader.GetString("ErrorDeleteMusic") + stringJson).ShowAsync();
                                }
                            });
                    }
                });
            }
            else
            {
                new MessageDialog(loader.GetString("ErrorAddPlaylist")).ShowAsync();
            }
        }
示例#9
0
 private void ItemClickExecute()
 {
     var get = new HttpRequestGet();
     ValidateKey.GetValideKey();
     var res = get.GetSecureNews(new News(), "news", SelectedNews.id.ToString(),
         Singleton.Singleton.Instance().SecureKey,
         Singleton.Singleton.Instance().CurrentUser);
     res.ContinueWith(delegate(Task<object> tmp)
     {
         var news = tmp.Result as News;
         if (news != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     news.imageNews =
                         new BitmapImage(new Uri(UrlImage + news.attachments[0].url, UriKind.RelativeOrAbsolute));
                     NewsDetailViewModel.TheNews = news;
                     GlobalMenuControl.SetChildren(new NewsDetail());
                 });
         }
     });
 }
示例#10
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();
                 });
         }
     });
 }
示例#11
0
 private void Unfollow(HttpRequestPost post, string cryptographic, HttpRequestGet get)
 {
     var resPost = post.Unfollow(cryptographic, TheArtiste.id.ToString(),
         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 followers = get.GetFollows(new List<User>(), "users",
                     Singleton.Singleton.Instance().CurrentUser.id.ToString());
                 followers.ContinueWith(delegate(Task<object> task1)
                 {
                     var res = task1.Result as List<User>;
                     if (res != null)
                     {
                         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                             () =>
                             {
                                 Singleton.Singleton.Instance().CurrentUser.follows = res;
                                 var a = TheArtiste;
                                 _follow = false;
                                 SetFollowText();
                             });
                     }
                 });
             });
         }
     });
 }
示例#12
0
        public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args)
        {
            ProgressOn = true;
            ObjFBHelper.ContinueAuthentication(args);
            if (ObjFBHelper.AccessToken != null)
            {
                fbclient = new FacebookClient(ObjFBHelper.AccessToken);
                Singleton.Singleton.Instance().MyFacebookClient = new FacebookClient(ObjFBHelper.AccessToken);

                dynamic result = await fbclient.GetTaskAsync("me");
                string id = result.id;

                var connecionSocial = new HttpRequestPost();
                var getKey = new HttpRequestGet();

                var key = await getKey.GetSocialToken(id, "facebook") as string;
                char[] delimiter = {' ', '"', '{', '}'};
                var word = key.Split(delimiter);
                var stringEncrypt = (id + word[4] + "3uNi@rCK$L$om40dNnhX)#jV2$40wwbr_bAK99%E");
                var sha256 = EncriptSha256.EncriptStringToSha256(stringEncrypt);

                await connecionSocial.ConnexionSocial("facebook", sha256, ObjFBHelper.AccessToken, id);
                var res = connecionSocial.Received;
                GetUser(res);
            }
        }
示例#13
0
        private void DeletePlaylistExecute()
        {
            _delete = true;
            var request = new HttpRequestGet();

            ValidateKey.GetValideKey();
            var resDel = request.DeletePlaylist(SelectedPlaylist, Singleton.Singleton.Instance().SecureKey,
                Singleton.Singleton.Instance().CurrentUser);

            resDel.ContinueWith(delegate(Task<string> tmp)
            {
                var test = tmp.Result;
                if (test != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var stringJson = JObject.Parse(test).SelectToken("code").ToString();
                        if (stringJson == "202")
                        {
                            new MessageDialog(loader.GetString("ErrorDeletePlaylist")).ShowAsync();
                            RefreshPlaylist();
                        }
                        else
                            new MessageDialog("Delete Fail code: " + stringJson).ShowAsync();
                    });
                }
            });
        }
示例#14
0
 private void LoadTweet()
 {
     ListTweets = new ObservableCollection<Tweets>();
     var req = new HttpRequestGet();
     var listTweets = req.GetListObject(new List<Tweets>(), "tweets");
     listTweets.ContinueWith(delegate(Task<object> tmp)
     {
         var res = tmp.Result as List<Tweets>;
         if (res != null)
         {
             foreach (var item in res)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     () =>
                     {
                         ListTweets.Insert(0, item);
                         //ListTweets.Add(item);
                     });
             }
         }
     });
 }
示例#15
0
 private void AddMusicToCartExecute()
 {
     _selectedMusic = SelectedMusic;
     var request = new HttpRequestGet();
     var post = new HttpRequestPost();
     ValidateKey.GetValideKey();
     var res = post.SaveCart(_selectedMusic, null, Singleton.Singleton.Instance().SecureKey,
         Singleton.Singleton.Instance().CurrentUser);
     res.ContinueWith(delegate(Task<string> tmp2)
     {
         var res2 = tmp2.Result;
         if (res2 != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () => { new MessageDialog(loader.GetString("ProductAddToCart")).ShowAsync(); });
         }
     });
 }
示例#16
0
 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());
                 });
         }
     });
 }
示例#17
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;
     }
 }
示例#18
0
 private void AlbumStackPanel_OnTapped(object sender, TappedRoutedEventArgs e)
 {
     AlbumViewModel.MyAlbum = SelectedAlbum;
     var get = new HttpRequestGet();
     ValidateKey.GetValideKey();
     var res = get.GetSecureObject(new Album(), "albums", SelectedAlbum.id.ToString(),
         Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser.id.ToString());
     res.ContinueWith(delegate(Task<object> tmp)
     {
         var album = tmp.Result as Album;
         if (album != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     album.imageAlbum =
                         new BitmapImage(new Uri(Constant.UrlImageAlbum + album.image, UriKind.RelativeOrAbsolute));
                     AlbumViewModel.MyAlbum = album;
                     SetChildren(new AlbumView());
                 });
         }
     });
 }
示例#19
0
        private async void MakeTheSearch()
        {
            var request = new HttpRequestGet();
            try
            {
                var list = (SearchResult) await request.Search(new SearchResult(), SearchText);
                if (list != null)
                {
                    MyResult = list;
                    DisplayResult();
                }
            }

            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
示例#20
0
        private async Task GetTwitterUserNameAsync(string webAuthResultResponseData)
        {
            TwitterCredentials _appCredentials;
            //
            // Acquiring a access_token first
            //
            _appCredentials = new TwitterCredentials(_consumerKey, ConsumerSecret);
            _appCredentials.AccessToken = _accessToken;
            _appCredentials.AccessTokenSecret = _accessTokenSecret;
            var responseData = webAuthResultResponseData.Substring(webAuthResultResponseData.IndexOf("oauth_token"));
            string request_token = null;
            string oauth_verifier = null;
            var keyValPairs = responseData.Split('&');

            for (var i = 0; i < keyValPairs.Length; i++)
            {
                var splits = keyValPairs[i].Split('=');
                switch (splits[0])
                {
                    case "oauth_token":
                        request_token = splits[1];
                        break;
                    case "oauth_verifier":
                        oauth_verifier = splits[1];
                        break;
                }
            }

            var TwitterUrl = "https://api.twitter.com/oauth/access_token";

            var timeStamp = GetTimeStamp();
            var nonce = GetNonce();

            var SigBaseStringParams = "oauth_consumer_key=" + "ooWEcrlhooUKVOxSgsVNDJ1RK";
            SigBaseStringParams += "&" + "oauth_nonce=" + nonce;
            SigBaseStringParams += "&" + "oauth_signature_method=HMAC-SHA1";
            SigBaseStringParams += "&" + "oauth_timestamp=" + timeStamp;
            SigBaseStringParams += "&" + "oauth_token=" + request_token;
            SigBaseStringParams += "&" + "oauth_version=1.0";
            var SigBaseString = "POST&";
            SigBaseString += Uri.EscapeDataString(TwitterUrl) + "&" + Uri.EscapeDataString(SigBaseStringParams);

            var Signature = GetSignature(SigBaseString, "BtLpq9ZlFzXrFklC2f1CXqy8EsSzgRRVPZrKVh0imI2TOrZAan");

            var httpContent = new HttpStringContent("oauth_verifier=" + oauth_verifier, UnicodeEncoding.Utf8);
            httpContent.Headers.ContentType = HttpMediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");
            var authorizationHeaderParams = "oauth_consumer_key=\"" + "ooWEcrlhooUKVOxSgsVNDJ1RK" + "\", oauth_nonce=\"" +
                                            nonce + "\", oauth_signature_method=\"HMAC-SHA1\", oauth_signature=\"" +
                                            Uri.EscapeDataString(Signature) + "\", oauth_timestamp=\"" + timeStamp +
                                            "\", oauth_token=\"" + Uri.EscapeDataString(request_token) +
                                            "\", oauth_version=\"1.0\"";

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("OAuth",
                authorizationHeaderParams);
            var httpResponseMessage = await httpClient.PostAsync(new Uri(TwitterUrl), httpContent);
            var response = await httpResponseMessage.Content.ReadAsStringAsync();

            var Tokens = response.Split('&');
            string oauth_token_secret = null;
            string access_token = null;
            string screen_name = null;
            string user_id = null;

            for (var i = 0; i < Tokens.Length; i++)
            {
                var splits = Tokens[i].Split('=');
                switch (splits[0])
                {
                    case "screen_name":
                        screen_name = splits[1];
                        break;
                    case "oauth_token":
                        access_token = splits[1];
                        break;
                    case "oauth_token_secret":
                        oauth_token_secret = splits[1];
                        break;
                    case "user_id":
                        user_id = splits[1];
                        break;
                }
            }

            // Check if everything is fine AND do_SOCIAL__CNX
            if (user_id != null && access_token != null && oauth_token_secret != null)
            {
                var connec = new HttpRequestPost();
                var getKey = new HttpRequestGet();

                var key = await getKey.GetSocialToken(user_id, "twitter") as string;
                char[] delimiter = {' ', '"', '{', '}'};
                var word = key.Split(delimiter);
                var stringEncrypt = (user_id + word[4] + "3uNi@rCK$L$om40dNnhX)#jV2$40wwbr_bAK99%E");
                var sha256 = EncriptSha256.EncriptStringToSha256(stringEncrypt);
                await connec.ConnexionSocial("twitter", sha256, oauth_token_secret, user_id);
                var res = connec.Received;
                GetUser(res);
            }
        }
示例#21
0
 private void LikeCommandExecute()
 {
     if (!TheConcert.hasLiked)
     {
         Like = bmLike;
         ValidateKey.GetValideKey();
         var post = new HttpRequestPost();
         var res = post.SetLike("Concerts", Singleton.Singleton.Instance().SecureKey,
             Singleton.Singleton.Instance().CurrentUser.id.ToString(), TheConcert.id.ToString());
         res.ContinueWith(delegate(Task<string> tmp2)
         {
             var result = tmp2.Result;
             if (result != null)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     UpdateConcert);
             }
         });
     }
     else
     {
         Like = bmDislike;
         ValidateKey.GetValideKey();
         var get = new HttpRequestGet();
         var res = get.DestroyLike("Concerts", TheConcert.id.ToString(), Singleton.Singleton.Instance().SecureKey,
             Singleton.Singleton.Instance().CurrentUser.id.ToString());
         res.ContinueWith(delegate(Task<string> tmp2)
         {
             var result = tmp2;
             if (result != null)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     UpdateConcert);
             }
         });
     }
 }
示例#22
0
        private void PlaylistTappedExecute()
        {
            if (MusicForPlaylist == null && !_delete)
            {
                PlaylistViewModel.PlaylistTmp = SelectedPlaylist;
                GlobalMenuControl.SetChildren(new PlaylistView());
            }
            else if (!_delete)
            {
                new MessageDialog(loader.GetString("AddPlaylist")).ShowAsync();

                SelectedPlaylist.musics.Add(MusicForPlaylist);

                var request = new HttpRequestGet();
                var post = new HttpRequestPost();
                try
                {
                    ValidateKey.GetValideKey();
                    var test = post.UpdatePlaylist(SelectedPlaylist, MusicForPlaylist,
                        Singleton.Singleton.Instance().SecureKey,
                        Singleton.Singleton.Instance().CurrentUser);
                    test.ContinueWith(delegate(Task<string> tmp)
                    {
                        var res = tmp.Result;
                        if (res != null)
                        {
                            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                RefreshPlaylist);
                        }
                    });
                }
                catch (Exception)
                {
                    new MessageDialog(loader.GetString("ErrorUpdatePlaylist")).ShowAsync();
                }
            }
            else
            {
                _delete = false;
            }
        }
示例#23
0
 private void UpdateConcert()
 {
     var request = new HttpRequestGet();
     ValidateKey.CheckValidateKey();
     var news = request.GetSecureObject(new Concerts(), "concerts", TheConcert.id.ToString(),
         Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser.id.ToString());
     news.ContinueWith(delegate(Task<object> tmp)
     {
         var test = tmp.Result as Concerts;
         if (test != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     TheConcert.hasLiked = test.hasLiked;
                     TheConcert.likes = test.likes;
                     Likes = test.likes;
                 });
         }
     });
 }
示例#24
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();
     }
 }
示例#25
0
        public void LoadContent()
        {
            var request = new HttpRequestGet();

            ValidateKey.GetValideKey();
            var listAlbumTmp = request.GetAllMusicForUser(new UserMusic(), Singleton.Singleton.Instance().SecureKey,
                Singleton.Singleton.Instance().CurrentUser.id.ToString());

            listAlbumTmp.ContinueWith(delegate(Task<object> tmp)
            {
                var test = tmp.Result as UserMusic;
                if (test != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        if (test.ListAlbums != null)
                            foreach (var album in test.ListAlbums)
                                ListAlbum.Add(album);
                        if (test.ListMusiques != null)
                            foreach (var music in test.ListMusiques)
                                ListMusique.Add(music);
                        if (test.ListPack != null)
                            foreach (var playlist in test.ListPack)
                                ListPack.Add(playlist);
                    });
                }
            });

            var listPlaylist = request.Find(new List<Playlist>(), "playlists",
                Singleton.Singleton.Instance().CurrentUser.id.ToString());
            listPlaylist.ContinueWith(delegate(Task<object> tmp)
            {
                var res = tmp.Result as List<Playlist>;

                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (res != null)
                        foreach (var playlist in res)
                        {
                            ListPlaylist.Add(playlist);
                        }
                });
            });
        }
示例#26
0
        private void FollowCommandExecute()
        {
            var post = new HttpRequestPost();
            var get = new HttpRequestGet();

            if (_follow)
                Unfollow(post, Singleton.Singleton.Instance().SecureKey, get);
            else if (!_follow)
                Follow(post, Singleton.Singleton.Instance().SecureKey, get);
        }
示例#27
0
        private void RefreshPlaylist()
        {
            ListPlaylist = new ObservableCollection<Playlist>();
            MusicForPlaylist = null;
            var request = new HttpRequestGet();
            var listPlaylist = request.Find(new List<Playlist>(), "playlists",
                Singleton.Singleton.Instance().CurrentUser.id.ToString());
            listPlaylist.ContinueWith(delegate(Task<object> tmp)
            {
                var res = tmp.Result as List<Playlist>;

                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (res != null)
                        foreach (var playlist in res)
                        {
                            ListPlaylist.Add(playlist);
                        }
                });
            });
        }
示例#28
0
 private void ItemClickCommandExecute()
 {
     var request = new HttpRequestGet();
     var album = request.GetSecureObject(new Album(), "albums", TheAlbum.id.ToString(),
         Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser.id.ToString());
     album.ContinueWith(delegate(Task<object> tmp)
     {
         var test = tmp.Result as Album;
         if (test != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 TheAlbum = test;
                 TheAlbum.imageAlbum =
                     new BitmapImage(new Uri(Constant.UrlImageAlbum + TheAlbum.image, UriKind.RelativeOrAbsolute));
                 AlbumViewModel.MyAlbum = TheAlbum;
                 GlobalMenuControl.SetChildren(new AlbumView());
             });
         }
     });
 }
示例#29
0
        public void Charge()
        {
            var request = new HttpRequestGet();

            var res = request.GetArtist(new Artist(), "users", TheUser.id.ToString());
            res.ContinueWith(delegate(Task<object> obj)
            {
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (ListAlbums.Count != 0)
                        ListAlbums.Clear();
                    var art = obj.Result as Artist;
                    if (art != null && art.artist)
                    {
                        foreach (var album in art.albums)
                        {
                            album.imageAlbum =
                                new BitmapImage(new Uri(Constant.UrlImageAlbum + album.image, UriKind.RelativeOrAbsolute));
                            NbrTitres = album.musics.Count + " titres";
                            ListAlbums.Add(album);
                        }
                    }
                    if (TheArtiste.follows != null)
                        NbrFollowers = TheArtiste.follows.Count.ToString();
                });
            });
        }
示例#30
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;
                    });
            });
        }