コード例 #1
0
        private void SignInButtonSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Session != null)
            {
                _session = e.Session;
                var client = new LiveConnectClient(_session);
                EventHandler<LiveOperationCompletedEventArgs> handler = null;
                handler = (s, even) =>
                              {
                                  client.GetCompleted -= handler;
                                  var resultDict = (Dictionary<string, object>)even.Result;

                                  var items = (List<object>)resultDict["data"];
                                  // Перебираем все объекты в папке, отбиаем только тип folder
                                  foreach (var item in
                                      items.Cast<Dictionary<string, object>>().Where(item => item["type"].ToString() == "folder"))
                                  {
                                      _files.Add(new FileModel() { Name = item["name"].ToString() });
                                  }
                                  lbFileList.ItemsSource = _files;
                              };
                client.GetCompleted += handler;
                //Путь к корню вашего skydrive
                client.GetAsync("me/skydrive/files");

            }
        }
コード例 #2
0
        public async Task Authenticate(LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                CurrentLoginStatus = "Connected to Microsoft Services";
                liveConnectClient = new LiveConnectClient(e.Session);
                microsoftAccountLoggedInUser = await liveConnectClient.GetAsync("me");

                CurrentLoginStatus = "Getting Microsoft Account Details";
                mobileServiceLoggedInUser =
                    await App.MobileService.LoginWithMicrosoftAccountAsync(e.Session.AuthenticationToken);

                CurrentLoginStatus = string.Format("Welcome {0}!", microsoftAccountLoggedInUser.Result["name"]);
                userName = microsoftAccountLoggedInUser.Result["name"].ToString();

                await Task.Delay(2000); // non-blocking Thread.Sleep for 2000ms (2 seconds)

                CurrentlyLoggedIn = true;
                CurrentLoginStatus = string.Empty;
                // this will then flip the bit that shows the different UI for logged in

                await UpdateUserOnRemoteService(); // and update on the remote service
                await UpdateLeaderBoard(); // do first pass on leaderboard update
            }
            else
            {
                CurrentLoginStatus = "Y U NO LOGIN?";
                CurrentlyLoggedIn = false;
            }

        }
コード例 #3
0
        void btnSignin_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                this.session = e.Session;
                //this.statusLabel.Text = AppResources.StatusSignedIn;
                this.gotoImportButton.IsEnabled  = true;
                this.gotoBackupButton.IsEnabled  = true;
                this.gotoRestoreButton.IsEnabled = true;
            }
            else
            {
                this.gotoImportButton.IsEnabled  = false;
                this.gotoBackupButton.IsEnabled  = false;
                this.gotoRestoreButton.IsEnabled = false;
                //this.statusLabel.Text = AppResources.StatusNotSignedIn;
                session = null;

                //if (e.Error != null)
                //{
                //    MessageBox.Show(String.Format(AppResources.SkyDriveError, e.Error.Message), AppResources.ErrorCaption, MessageBoxButton.OK);
                //    //statusLabel.Text = e.Error.ToString();
                //}
            }
        }
コード例 #4
0
 private async void btnSignin_SessionChanged_2(object sender, LiveConnectSessionChangedEventArgs e)
 {
     currentLoginType = "Microsoft";
     if (TextValidation())
     {
         lblMsg.Text = "";
         App.liveAuthClient = new LiveAuthClient(redirectURL);
         LiveLoginResult liveLoginResult = await App.liveAuthClient.LoginAsync(new string[] { "wl.signin", "wl.basic" });
         if (liveLoginResult.Session != null && liveLoginResult.Status == LiveConnectSessionStatus.Connected)
         {
             client = new LiveConnectClient(liveLoginResult.Session);
             LiveOperationResult operationResult = await client.GetAsync("me");
             dynamic pic = await client.GetAsync("me/picture");
             try
             {
                 MobileServiceUser user = await App.MobileService.LoginAsync(client.Session.AuthenticationToken);
                 if (!String.IsNullOrEmpty(user.UserId))
                 {
                     dynamic meResult = operationResult.Result;
                     if (meResult.first_name != null && meResult.last_name != null)
                         //initiliazed user LiveUserInfo properties
                         SetUserDetails(user.UserId, meResult.name, meResult.first_name, meResult.last_name, pic.Result.location);
                     else
                         infoTextBlock.Text = "Welcome, Guest!";
                 }
             }
             catch (LiveConnectException exception)
             {
                 this.infoTextBlock.Text = "Error calling API: " +
                     exception.Message;
             }
         }
     }
 }
コード例 #5
0
 private void RaiseSessionChangedEvent(LiveConnectSessionChangedEventArgs args)
 {
     var handler = this.SessionChanged;
     if (handler != null)
     {
         handler(this, args);
     }
 }
コード例 #6
0
ファイル: SignInButton.cs プロジェクト: dmooring52/MySource
        private void RaiseSessionChangedEvent(LiveConnectSessionChangedEventArgs args)
        {
            var handler = this.SessionChanged;

            if (handler != null)
            {
                handler(this, args);
            }
        }
コード例 #7
0
        private void SignIn_SessionChanged (object sender, LiveConnectSessionChangedEventArgs e)
            {
            _progressIndicator.IsVisible = false;

            if (e.Status == LiveConnectSessionStatus.Connected)
                {
                Utilities.SkyDriveSession = e.Session;
                NavigationService.Navigate (new Uri ("/Upload.xaml", UriKind.RelativeOrAbsolute));
                }

            }
コード例 #8
0
 private void signInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         viewModel.Client = new LiveConnectClient(e.Session);
     }
     else
     {
         this.infoTextBlock.Text = "not signed in";
     }
 }
コード例 #9
0
 private void signInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         MainPage.session = e.Session;
         this.NavigationService.Navigate(new Uri("/Index.xaml", UriKind.Relative));
     }
     else
     {
         MainPage.session = null;
     }
 }
コード例 #10
0
ファイル: SkyDrive.cs プロジェクト: ApexHAB/apex-lumia
 public void LoginCompleted(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.Session = e.Session;
         if (dataFullName != null && dataPhoto != null) { GetProfileData(); }
     }
     else if (e.Error != null)
     {
         MessageBox.Show("Error logging in.");
     }
 }
コード例 #11
0
ファイル: MainPage.xaml.cs プロジェクト: natanelia/LiveSDK
 private void SignInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.Session = e.Session;
         this.pivotControl.SelectedItem = this.albumPivot;
         if (!App.ViewModel.IsDataLoaded)
         {
             App.ViewModel.LoadData();
         }
     }
 }
コード例 #12
0
        private void btnSignIn_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                btnSave.Visibility = App.ProfilesManager.Items.Count != 0 ? Visibility.Visible : Visibility.Collapsed;
                btnRestore.Visibility = Visibility.Visible;

                client = new LiveConnectClient(e.Session);
                client.UploadCompleted += client_UploadCompleted;
                client.GetCompleted += client_GetCompleted;
                client.DownloadCompleted += client_DownloadCompleted;
            }
        }
コード例 #13
0
        private void OnLogin(LiveLoginResult loginResult)
        {
            this.Session = loginResult.Session;

            var sessionChangedArgs =
                new LiveConnectSessionChangedEventArgs(loginResult.Status, loginResult.Session);

            this.RaiseSessionChangedEvent(sessionChangedArgs);

            if (loginResult.Status == LiveConnectSessionStatus.Connected)
            {
                this.SetButtonState(ButtonState.LogOut);
            }
        }
コード例 #14
0
 /// <summary>
 ///     Event handler for SignInButton.SessionChanged event.
 /// </summary>
 private void btnLogin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         this.liveClient = new LiveConnectClient(e.Session);
         this.GetMe();
     }
     else
     {
         this.liveClient = null;
         this.tbResponse.Text = e.Error != null ? e.Error.ToString() : string.Empty;
         this.imgMe.Source = null;
     }
 }
コード例 #15
0
        private void OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
                return;
            }

            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                ((App) App.Current).Session = e.Session;
                this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
コード例 #16
0
        private async void btnSignin_SessionChanged_2(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (TextValidation())
            {
                lblMsg.Text = "";
                App.liveAuthClient = new LiveAuthClient(redirectURL);
                LiveLoginResult liveLoginResult = await App.liveAuthClient.LoginAsync(new string[] { "wl.signin", "wl.basic" });
                if (liveLoginResult.Session != null && liveLoginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    client = new LiveConnectClient(liveLoginResult.Session);
                    LiveOperationResult operationResult = await client.GetAsync("me");
                    dynamic pic = await client.GetAsync("me/picture");

                    
                    try
                    {
                        MobileServiceUser user = await App.MobileService.LoginAsync(client.Session.AuthenticationToken);
                        if (!String.IsNullOrEmpty(user.UserId))
                        {
                            dynamic meResult = operationResult.Result;
                            if (meResult.first_name != null &&
                                meResult.last_name != null)
                            {
                                infoTextBlock.Text = "Welcome, " + meResult.name;
                                //initiliazed user LiveUserInfo properties
                                LiveUserInfo.Id = user.UserId;//meResult.id; // user.UserId; //generated by Zumo
                                LiveUserInfo.Name = meResult.name;
                                LiveUserInfo.FirstName = meResult.first_name;
                                LiveUserInfo.LastName = meResult.last_name;
                                PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
                                LiveUserInfo.channelUri = channel.Uri;
                                LiveUserInfo.pic = pic.Result.location;
                                this.Frame.Navigate(typeof(WhereTheFriend.Welcome));

                            }
                            else
                            {
                                infoTextBlock.Text = "Welcome, Guest!";
                            }
                        }
                    }
                    catch (LiveConnectException exception)
                    {
                        this.infoTextBlock.Text = "Error calling API: " +
                            exception.Message;
                    }
                }
            }
        }
コード例 #17
0
        public void OnSessionStateChanged(LiveConnectSessionChangedEventArgs evenementDeConnection)
        {
            if (evenementDeConnection.Status != LiveConnectSessionStatus.Connected)
            {
                IsActionPossible = false;
            }
            else
            {
                IsActionPossible = true;
                Session = evenementDeConnection.Session;
            }

            SauvegarderCommand.RaiseCanExecuteChanged();
            RestaurerCommand.RaiseCanExecuteChanged();
        }
コード例 #18
0
ファイル: BlankPage.xaml.cs プロジェクト: natanelia/LiveSDK
        private void OnSessionChanged(Object sender, LiveConnectSessionChangedEventArgs args)
        {
            if (args != null && args.Session != null && args.Status == LiveConnectSessionStatus.Connected)
            {
                this.client = new LiveConnectClient(args.Session);

                if (notes == null)
                {
                    signedInUser();
                }
            }
            else
            {
                signedOutUser();
            }
        }
コード例 #19
0
        private void skydrive_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e != null && e.Status == LiveConnectSessionStatus.Connected)
            {
                App.client = new LiveConnectClient(e.Session);
                this.GetAccountInformations();
                btnUpload.IsEnabled = true;
            }
            else
            {
                btnUpload.IsEnabled = false;
                App.client = null;

                if (rbtnSaveInCloud.IsChecked == true)
                    InfoText.Text = e.Error != null ? e.Error.Message : string.Empty;
            }
        }
コード例 #20
0
ファイル: Upload.xaml.cs プロジェクト: aabrohi/kinect-kollage
 private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null &&
         e.Session.Status == LiveConnectSessionStatus.Connected)
     {
         client = new LiveConnectClient(e.Session);
         infoTextBlock.Text = "Signed in.";
         client.GetCompleted +=
             new EventHandler<LiveOperationCompletedEventArgs>(btnSignin_GetCompleted);
         client.GetAsync("me", null);
     }
     else
     {
         infoTextBlock.Text = "Not signed in.";
         client = null;
     }
 }
コード例 #21
0
        private async void SignInButton_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Error == null && e.Status == LiveConnectSessionStatus.Connected)
            {
                _client = new LiveConnectClient(e.Session);

                try
                {
                    var meResult = await _client.GetAsync(LiveSdkConstants.MyDetails);
                    var myDetails = JsonConvert.DeserializeObject<MeDetails>(meResult.RawResult);

                    SignedInAs.Text = string.Format("Signed in as {0}", myDetails.Name);
                }
                catch
                {
                    MessageBox.Show("Something went wrong");
                }
            }
        }
コード例 #22
0
ファイル: MainPage.xaml.cs プロジェクト: dwhitney7/SkyNote
 private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         client = new LiveConnectClient(e.Session);
         App.Current.LiveSession = e.Session;
         infoTextBlock.Text = "Authenticated. Looking for you..";
         client.GetCompleted +=
             new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
         client.GetAsync("me", null);
     }
     else
     {
         // reset controls
         infoTextBlock.Text = "Sign in to allow SkyNote access to your files!";
         this.btnViewContents.Visibility = System.Windows.Visibility.Collapsed;
         client = null;
     }
 }
コード例 #23
0
ファイル: MainPage.xaml.cs プロジェクト: masiboo/SkyPhoto_WP8
 /// <summary>
 /// btnSignin_SessionChanged tregar signin button clicked.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
     {
         App.Session = e.Session;
         client = new LiveConnectClient(e.Session);
         LiveOperationResult result =  await client.GetAsync("me");
         OnGetCompleted(result);
     }
     else
     {
         // remove all live profile informaion.
         client = null;
         App.Session = null;
         gotoAlbum.Visibility = Visibility.Collapsed;
         ProfileName.Text = "";
         ProfilePic.Source = null;
     }
 }
コード例 #24
0
ファイル: Backup.xaml.cs プロジェクト: NPadrutt/Places
 private async void SignInButton_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         busyProceedAction.IsRunning = true;
         liveClient = new LiveConnectClient(e.Session);
         lblLoginInfo.Visibility = Visibility.Collapsed;
         btnBackup.IsEnabled = true;
         await GetFolderId();
         await CheckForBackup();
     }
     else
     {
         lblLoginInfo.Visibility = Visibility.Visible;
         btnBackup.IsEnabled = false;
         btnRestore.IsEnabled = false;
     }
     busyProceedAction.IsRunning = false;
 }
コード例 #25
0
 private void signInBtn_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     this.WorkDone();
     if ((e.Status != LiveConnectSessionStatus.Connected) && (e.Error != null))
     {
         if (!NetworkInterface.GetIsNetworkAvailable())
         {
             this.Alert(AppResources.NoAvailableNetworkMessage, AppResources.LoginLiveIDMessage.ToUpperInvariant());
         }
         else
         {
             this.Alert(AppResources.LiveConnectExceptionMessage, AppResources.LoginLiveIDMessage.ToUpperInvariant());
         }
     }
     else if (e.Status == LiveConnectSessionStatus.Connected)
     {
         this.viewModel.InitializeLiveConnector(e.Session);
         this.viewModel.IsLogonToLiveId = e.Status == LiveConnectSessionStatus.Connected;
     }
 }
コード例 #26
0
ファイル: Skydrive.xaml.cs プロジェクト: pkwd/SleepHack
        private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                //   client = new LiveConnectClient(e.Session);
                //   App.Current.LiveSession = e.Session;
                this.txtLoginResult.Text = "Signed in.";
                this.txtWelcome.Visibility = System.Windows.Visibility.Visible;
                this.btnShowContent.Visibility = System.Windows.Visibility.Visible;
                this.btnAddFile.Visibility = System.Windows.Visibility.Visible;

                //client.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
                // client.GetAsync("me", null);
            }
            else
            {
                this.txtLoginResult.Text = "Not signed in.";
                this.txtWelcome.Visibility = System.Windows.Visibility.Collapsed;
                //  client = null;
            }
        }
コード例 #27
0
        void btnSignin_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                PhoneApplicationService.Current.State["parameter"] = this.session = e.Session;
                this.NavigationService.Navigate(new Uri("/SkyDriveImportPage.xaml", UriKind.Relative));

                //LiveConnectClient client = new LiveConnectClient(e.Session);
                //this.session = e.Session;
                //testLabel.Text = "Signed in.";
                //client.GetCompleted += client_GetCompleted;
                //client.GetAsync("me", null);
            }
            else
            {
                session = null;
                if (e.Error != null)
                {
                    statusLabel.Text = "Error calling API: " + e.Error.ToString();
                }
            }
        }
コード例 #28
0
ファイル: Settings.xaml.cs プロジェクト: sirfergy/LEAF-Logger
 private void Signin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         App.SkyDriveEnabled = true;
         this.autoUpload.IsEnabled = true;
     }
 }
コード例 #29
0
        private void SignInButton_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            // As soon as user is logged in, passing her AuthenticationToken to the ViewModel to enable interaction with the service
            App.ViewModel.SetAuthenticationToken
            (
                e.Status == LiveConnectSessionStatus.Connected
                ? 
                e.Session.AuthenticationToken
                : 
                string.Empty
            );

            if (e.Error != null)
            {
                Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
            }
        }
コード例 #30
0
 private void WLSignIn_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     ((BackupRestoreViewModel)DataContext).SessionChangedCommand.Execute(e);
 }
コード例 #31
0
ファイル: MainPage.xaml.cs プロジェクト: nickhodge/HeadsTails
 private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     await headsTailsUserDetails.Authenticate(e);
 }
コード例 #32
0
 private void OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 {
     this.liveClient = (e.Status == LiveConnectSessionStatus.Connected) ? new LiveConnectClient(e.Session) : null;
 }
コード例 #33
0
		private void bLiveSignIn_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
		{
			if (e.Status != LiveConnectSessionStatus.Connected) return;

			_client = new LiveConnectClient(e.Session);
			App.LiveSession = e.Session;

		        GetMeAndFileListing();
		}
コード例 #34
0
        private void OnLogin(LiveLoginResult loginResult)
        {
            this.Session = loginResult.Session;

            var sessionChangedArgs = 
                new LiveConnectSessionChangedEventArgs(loginResult.Status, loginResult.Session);

            this.RaiseSessionChangedEvent(sessionChangedArgs);

            if (loginResult.Status == LiveConnectSessionStatus.Connected)
            {
                this.SetButtonState(ButtonState.LogOut);
            }
        }