private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var note = 0; if (RadioButtonOne.IsChecked != null && RadioButtonOne.IsChecked.Value) note = 1; else if (RadioButtonTwo.IsChecked != null && RadioButtonTwo.IsChecked.Value) note = 2; else if (RadioButtonThree.IsChecked != null && RadioButtonThree.IsChecked.Value) note = 3; else if (RadioButtonFour.IsChecked != null && RadioButtonFour.IsChecked.Value) note = 4; else if (RadioButtonFive.IsChecked != null && RadioButtonFive.IsChecked.Value) note = 5; var request2 = new HttpRequestPost(); ValidateKey.GetValideKey(); var res = request2.SetRate(SelectMusic, Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser.id.ToString(), note); res.ContinueWith(delegate(Task<string> tmp) { if (tmp.Result != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { AlbumViewModel.RatePopup.IsOpen = false; }); } }); }
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(); }); } }); }); } }); }
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); }
private void SendTweetExecute() { var post = new HttpRequestPost(); try { ValidateKey.GetValideKey(); var test = post.SendTweet(TextTweet, CurrentUser, Singleton.Singleton.Instance().SecureKey); test.ContinueWith(delegate(Task<string> tmp) { var res = tmp.Result; if (res != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, LoadTweet); } }); } catch (Exception) { var loader = new ResourceLoader(); new MessageDialog(loader.GetString("ErrorTweet")).ShowAsync(); } }
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); } }
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); } }
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; } }
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); } }); } }
private async void PostUser() { var postRequest = new HttpRequestPost(); var res = await postRequest.Save(NewUser, "", Password); new MessageDialog(loader.GetString("SigInOk")).ShowAsync(); MakeConnexion(); }
private void RenameCommandExecute() { if (!BoolRename) { BoolRename = true; RenameButton = "Validate"; return; } if (BoolRename) { RenameButton = "Rename"; var request2 = new HttpRequestPost(); ValidateKey.GetValideKey(); var res = request2.UpdateNamePlaylist(ThePlaylist, Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser); res.ContinueWith(delegate(Task<string> tmp) { if (tmp.Result != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var stringJson = JObject.Parse(tmp.Result).SelectToken("content").ToString(); ThePlaylist = (Playlist)JsonConvert.DeserializeObject(stringJson, typeof(Playlist)); var i = ThePlaylist.musics.Count; }); } }); BoolRename = false; } }
private async Task UpdateData() { var loader = new ResourceLoader(); var post = new HttpRequestPost(); try { ValidateKey.GetValideKey(); var test = post.Update(CurrentUser, Singleton.Singleton.Instance().SecureKey); test.ContinueWith(delegate(Task<string> tmp) { var res = tmp.Result; }); } catch (Exception) { new MessageDialog(loader.GetString("ErrorUpdate")).ShowAsync(); } }
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(); }); } }); }
public void GetUserKeyForVote(string artistId) { var post = new HttpRequestPost(); var get = new HttpRequestGet(); ValidateKey.GetValideKey(); Vote(post, Singleton.Singleton.Instance().SecureKey, get, artistId); }
private void SendCommentExecute() { var post = new HttpRequestPost(); try { ValidateKey.GetValideKey(); var test = post.SendComment(TextComment, TheAlbum, null, 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, LoadComment); } }); } catch (Exception) { new MessageDialog("Erreur lors du post").ShowAsync(); } }
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); }
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(); }); } }); }); } }); }
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(); } }
private async void MakeConnexion() { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { if (NewUser.username != string.Empty && _password != string.Empty) { var connec = new HttpRequestPost(); await connec.ConnexionSimple(NewUser.email, _password); var res = connec.Received; GetUser(res); } else { new MessageDialog(loader.GetString("ErrorLogIn")).ShowAsync(); } }); }
private void SendFeedBack() { if (Email != null && ItemChoose != "Selectionner une categorie" && Object != null && Comment != null) { var post = new HttpRequestPost(); var res = post.Feedback(Email, ItemChoose, Object, Comment); res.ContinueWith(delegate(Task<string> tmp2) { var result = tmp2.Result; if (result != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, AgileCallback); } }); } else { var loader = new ResourceLoader(); new MessageDialog(loader.GetString("ErrorAbout")).ShowAsync(); } }
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(); }); } }); }
private async void MakeConnexion() { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { if (_username != null && _password != null) { ProgressOn = true; var connec = new HttpRequestPost(); await connec.ConnexionSimple(_username, _password); var res = connec.Received; GetUser(res); } else { new MessageDialog(loader.GetString("InfosConec")).ShowAsync(); } }); }
private void CreatePlaylistExecute() { var playlist = new Playlist { name = "MyPlaylist", user = Singleton.Singleton.Instance().CurrentUser, musics = new List<Music> {MusicForPlaylist} }; if (MusicForPlaylist != null) { var post = new HttpRequestPost(); try { ValidateKey.GetValideKey(); var test = post.SavePlaylist(playlist, 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, () => { var stringJson = JObject.Parse(res).SelectToken("content").ToString(); var playList = (Playlist) JsonConvert.DeserializeObject(stringJson, new Playlist().GetType()); try { ValidateKey.GetValideKey(); var up = post.UpdatePlaylist(playList, MusicForPlaylist, Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser); up.ContinueWith(delegate(Task<string> tmp2) { var res2 = tmp2.Result; if (res2 != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, RefreshPlaylist); } }); } catch (Exception) { new MessageDialog(loader.GetString("ErrorUpdatePlaylist")).ShowAsync(); } }); } }); } catch (Exception) { new MessageDialog(loader.GetString("ErrorUpdatePlaylist")).ShowAsync(); } } else { new MessageDialog(loader.GetString("ErrorNoMusic")).ShowAsync(); } }
private void SendCommandExecute() { var post = new HttpRequestPost(); ValidateKey.GetValideKey(); if (ConversationText != null) { var res = post.SaveMessage(ConversationText, FriendUser.id.ToString(), Singleton.Singleton.Instance().SecureKey, Singleton.Singleton.Instance().CurrentUser); res.ContinueWith(delegate(Task<string> tmp) { var res2 = tmp.Result; if (res2 != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Charge); } }); } }