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;
             }
         }
     }
 }
        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;
                    }
                }
            }
        }
Пример #3
0
            public async void LoadProfile(String SkyDriveFolderName = GenericName)
            {
                LiveOperationResult meResult;
                dynamic result;
                bool createLiveFolder = false;

               try
               {
                    LiveAuthClient authClient = new LiveAuthClient();
                    LiveLoginResult authResult = await authClient.LoginAsync(new List<String>() { "wl.skydrive_update" });

                    if (authResult.Status == LiveConnectSessionStatus.Connected)
                    {
                        try
                        {
                            meClient = new LiveConnectClient(authResult.Session);
                            meResult = await meClient.GetAsync("me/skydrive/" + SkyDriveFolderName);
                            result = meResult.Result;
                        }
                        catch (LiveConnectException)
                        {
                            createLiveFolder = true;
                        }
                        if (createLiveFolder == true)
                        {
                            try
                            {
                                var skyDriveFolderData = new Dictionary<String, Object>();
                                skyDriveFolderData.Add("name", SkyDriveFolderName);
                                LiveConnectClient LiveClient = new LiveConnectClient(meClient.Session);
                                LiveOperationResult operationResult = await LiveClient.PostAsync("me/skydrive/", skyDriveFolderData);
                                meResult = await meClient.GetAsync("me/skydrive/");

                            }
                            catch (LiveConnectException)
                            {
                            }
                        }

                    }

               }

               catch (LiveAuthException)
               {
               }

            }
        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;
            }

        }
        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");

            }
        }
Пример #6
0
 void clientDataFetch_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         List<object> data = (List<object>)e.Result["data"];
         string file_id = "";
         foreach (IDictionary<string, object> content in data)
         {
             if ((string)content["name"] == "BillDB.sdf")
                 file_id = (string)content["id"];
         }
         if (file_id == "")
             MessageBox.Show("No database file found.");
         else
         {
             MessageBox.Show("DB id: " + file_id + ";");
             try
             {
                 LiveConnectClient liveClient = new LiveConnectClient(session);
                 liveClient.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(shareLink_completed);
                 liveClient.GetAsync(file_id + "/shared_edit_link");
             }
             catch (LiveConnectException exception)
             {
                 MessageBox.Show("Error getting shared edit link: " + exception.Message);
             }
         }
     }
 }
Пример #7
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var liveIdClient = new LiveAuthClient();
            Task<LiveLoginResult> tskLoginResult = liveIdClient.LoginAsync(new string[] { "wl.signin" });
            tskLoginResult.Wait();

            switch (tskLoginResult.Result.Status)
            {
                case LiveConnectSessionStatus.Connected:

                    try
                    {
                        LiveConnectClient client = new LiveConnectClient(tskLoginResult.Result.Session);
                        LiveOperationResult liveOperationResult = await client.GetAsync("me");

                        dynamic operationResult = liveOperationResult.Result;
                        string name = string.Format("Hello {0} ", operationResult.first_name);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("ERRO, {0}", ex.Message), ex);
                    }

                    break;
                case LiveConnectSessionStatus.NotConnected:
                    int j = 10;
                    break;
                default:
                    int z = 10;
                    break;
            }
        }
Пример #8
0
        /// <summary>
        /// DownloadPictures downs picutre link from sky dirve
        /// </summary>
        /// <param name="albumItem"></param>
        private async void DownloadPictures(SkydriveAlbum albumItem)
        {
            LiveConnectClient folderListClient = new LiveConnectClient(App.Session);
            LiveOperationResult result = await folderListClient.GetAsync(albumItem.ID + "/files");
            FolderListClient_GetCompleted(result, albumItem);

        }
 private async void liveSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         liveClient = new LiveConnectClient(e.Session);
         LiveOperationResult operationResult = await liveClient.GetAsync("me");
         try
         {
             dynamic meResult = operationResult.Result;
             if (meResult.first_name != null && meResult.last_name != null)
             {
                 infoTextBlock.Text = "Hello " + meResult.first_name + " " + meResult.last_name + "!";
             }
             else
             {
                 infoTextBlock.Text = "Hello, signed-in user!";
             }
         }
         catch (LiveConnectException exception)
         {
             this.infoTextBlock.Text = "Error calling API: " + exception.Message;
         }
     }
     else
     {
         infoTextBlock.Text = "Not signed in.";
     }
 }
Пример #10
0
        private  async void loginButton_Click(object sender, RoutedEventArgs e)//登录
        {
            try
            {
                msgText.Text = "亲:正在登录";
                var authClient = new LiveAuthClient();

                LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.signin", "wl.skydrive" });

                if (result.Status == LiveConnectSessionStatus.Connected)
                {

                    var connectClient = new LiveConnectClient(result.Session);
                    var meResult = await connectClient.GetAsync("me");
                    msgText.Text = "亲爱的:" + meResult.Result["name"].ToString() + "  您已成功登录OneDrive!";
                }
                updateButton.Visibility = Visibility.Visible;
                uploadButton.Visibility = Visibility.Visible;
                downButton.Visibility = Visibility.Visible;


            }
            catch (LiveAuthException ex)
            {
                msgText.Text = ex.Message;
            }
            catch (LiveConnectException ex)
            {
                msgText.Text = ex.Message;
            }
        }
        /// <summary>
        /// Tests logging into MobileService with Live SDK token. App needs to be assosciated with a WindowsStoreApp
        /// </summary>
        private async Task TestLiveSDKLogin()
        {
            try
            {
                LiveAuthClient liveAuthClient = new LiveAuthClient(GetClient().MobileAppUri.ToString());
                LiveLoginResult result = await liveAuthClient.InitializeAsync(new string[] { "wl.basic", "wl.offline_access", "wl.signin" });
                if (result.Status != LiveConnectSessionStatus.Connected)
                {
                    result = await liveAuthClient.LoginAsync(new string[] { "wl.basic", "wl.offline_access", "wl.signin" });
                }
                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    LiveConnectSession session = result.Session;
                    LiveConnectClient client = new LiveConnectClient(result.Session);
                    LiveOperationResult meResult = await client.GetAsync("me");
                    MobileServiceUser loginResult = await GetClient().LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);

                    Log(string.Format("{0} is now logged into MobileService with userId - {1}", meResult.Result["first_name"], loginResult.UserId));
                }
            }
            catch (Exception exception)
            {
                Log(string.Format("ExceptionType: {0} Message: {1} StackTrace: {2}",
                                                exception.GetType().ToString(),
                                                exception.Message,
                                                exception.StackTrace));
                Assert.Fail("Log in with Live SDK failed");
            }
        }
Пример #12
0
 public async Task<ActionResult> Index()
 {
     // récupération du statut de la connection de l'utilisateur
     var loginResult = await AuthClient.InitializeWebSessionAsync(this.HttpContext);
     // si l'utilisateur est connecté
     if (loginResult != null && loginResult.Status == LiveConnectSessionStatus.Connected)
     {
         // Récupération et affichage des informations de l'utilisateur
         var userData = new UserDataModel();
         LiveConnectClient client = new LiveConnectClient(this.AuthClient.Session);
         LiveOperationResult meResult = await client.GetAsync("me");
         if (meResult != null)
         {
             dynamic meInfo = meResult.Result;
             userData.LastName = meInfo.last_name;
             userData.FirstName = meInfo.first_name;
         }
         return View("LoggedIn", userData);
     }
     else
     {
         // l'utilisateur n'est pas connecté, génération de l'URL de connection
         var options = new Dictionary<string, string>();
         options["state"] = REDIRECT_URL;
         string loginUrl = this.AuthClient.GetLoginUrl(new string[] { "wl.signin" }, REDIRECT_URL, options);
         ViewBag.loginUrl = loginUrl;
         return View("LoggedOut");
     }
 }
Пример #13
0
        public async static Task<List<SkyDriveEntity>> GetFolderContents(LiveConnectSession session, string folderId)
        {
            try
            {
                LiveConnectClient client = new LiveConnectClient(session);
                LiveOperationResult result = await client.GetAsync(folderId + "/files");

                //clear entries in data
                data.Clear();

                List<object> container = (List<object>)result.Result["data"];
                foreach (var item in container)
                {
                    SkyDriveEntity entity = new SkyDriveEntity();

                    IDictionary<string, object> dictItem = (IDictionary<string, object>)item;
                    string type = dictItem["type"].ToString();
                    entity.IsFolder = type == "folder" || type == "album" ? true : false;
                    entity.ID = dictItem["id"].ToString();
                    entity.Name = dictItem["name"].ToString();
                    data.Add(entity);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }
        private async Task<dynamic> GetUserLogged() 
        {
            var liveIdClient = new LiveAuthClient();
            Task<LiveLoginResult> tskLoginResult = liveIdClient.LoginAsync(new string[] { "wl.signin" });
            tskLoginResult.Wait();

            switch (tskLoginResult.Result.Status)
            {
                case LiveConnectSessionStatus.Connected:
                    try
                    {
                        LiveConnectClient client = new LiveConnectClient(tskLoginResult.Result.Session);
                        LiveOperationResult liveOperationResult = await client.GetAsync("me");

                        dynamic operationResult = liveOperationResult.Result;
                        return operationResult;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("ERRO, {0}", ex.Message), ex);
                    }
                case LiveConnectSessionStatus.NotConnected:
                    break;
            }

            return null;
        }
Пример #15
0
        public async Task<ActionResult> Redirect()
        {
            var result = await authClient.ExchangeAuthCodeAsync(HttpContext);
            if (result.Status == LiveConnectSessionStatus.Connected)
            {
                var client = new LiveConnectClient(this.authClient.Session);
                LiveOperationResult meResult = await client.GetAsync("me");
                LiveOperationResult mePicResult = await client.GetAsync("me/picture");
                LiveOperationResult calendarResult = await client.GetAsync("me/calendars");

                ViewBag.Name = meResult.Result["name"].ToString();
                ViewBag.PhotoLocation = mePicResult.Result["location"].ToString();
                ViewBag.CalendarJson = calendarResult.RawResult;
            }


            return View();
        }
Пример #16
0
        async void skydriveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SkyDriveListItem item = this.skydriveList.SelectedItem as SkyDriveListItem;
            if (item == null)
                return;

            try
            {
                LiveConnectClient client = new LiveConnectClient(this.session);
                if (item.Type == SkyDriveItemType.Folder)
                {
                    if (this.session != null)
                    {
                        this.skydriveList.ItemsSource = null;
                        this.currentFolderBox.Text = item.Name;
                        LiveOperationResult result = await client.GetAsync(item.SkyDriveID + "/files");
                        this.client_GetCompleted(result);
                    }
                }
                else if (item.Type == SkyDriveItemType.Savestate || item.Type == SkyDriveItemType.SRAM)
                {
                    if (item.Type == SkyDriveItemType.Savestate)
                    {
                        string slot = item.Name.Substring(item.Name.Length - 5, 1);
                        int parsedSlot = 0;
                        if (!int.TryParse(slot, out parsedSlot))
                        {
                            MessageBox.Show(AppResources.ImportSavestateInvalidFormat, AppResources.ErrorCaption, MessageBoxButton.OK);
                            return;
                        }
                    }
                    // Download
                    if (!item.Downloading)
                    {
                        try
                        {
                            item.Downloading = true;
                            await this.DownloadFile(item, client);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(String.Format(AppResources.DownloadErrorText, item.Name, ex.Message), AppResources.ErrorCaption, MessageBoxButton.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show(AppResources.AlreadyDownloadingText, AppResources.ErrorCaption, MessageBoxButton.OK);
                    }
                }
                this.statusLabel.Height = 0;
            }
            catch (LiveConnectException)
            {
                this.statusLabel.Height = this.labelHeight;
                this.statusLabel.Text = AppResources.SkyDriveInternetLost;
            }
        }
Пример #17
0
        /// <summary>
        /// Lädt informationen wie Namen über den Windows Live User.
        /// </summary>
        /// <param name="userId">id des Users.</param>
        /// <returns>Der neu erstellte User.</returns>
        internal async static Task<Person> GetNewUserData(string userId, string notificationChannel, int score, DateTime accountCreatedDate)
        {
            LiveConnectClient client = new LiveConnectClient(session);

            var data = (await client.GetAsync("me")).Result;

            return new Person(0, userId, (string)data["id"], (string)data["last_name"], (string)data["first_name"],
                    notificationChannel, System.Globalization.CultureInfo.CurrentCulture.ToString(), score, App.VersionNumber, accountCreatedDate);

        }
Пример #18
0
 /// <summary>
 /// GetAlubmData gets all the album
 /// </summary>
 private async void GetAlubmData()
 {
     ImageCounter = 0;
     // show progressbar.
     string progMsgDownAlbum = SkyPhoto.Resources.Resources.progMsgDownAlbum;
     ShowProgressBar(progMsgDownAlbum);
     LiveConnectClient clientFolder = new LiveConnectClient(App.Session);
     LiveOperationResult result = await clientFolder.GetAsync("/me/albums");
     GetAlubmData_Completed(result);
 }
Пример #19
0
        public void GetProfileData()
        {
            LiveConnectClient clientGetMe = new LiveConnectClient(App.Session);
            clientGetMe.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(clientGetMe_GetCompleted);
            clientGetMe.GetAsync("me");

            LiveConnectClient clientGetPicture = new LiveConnectClient(App.Session);
            clientGetPicture.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(clientGetPicture_GetCompleted);
            clientGetPicture.GetAsync("me/picture");
        }
Пример #20
0
 /// <summary>
 /// GetAlubmData gets all the album
 /// </summary>
 private void GetAlubmData()
 {
     ImageCounter = 0;
     // show progressbar.
     string progMsgDownAlbum = SkyPhoto.Resources.Resources.progMsgDownAlbum;
     ShowProgressBar(progMsgDownAlbum);
     LiveConnectClient clientFolder = new LiveConnectClient(App.Session);
     clientFolder.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(GetAlubmData_Completed);
     clientFolder.GetAsync("/me/albums");
 }
 public async Task<UserInfo> Authenticate()
 {
     var authClient = new LiveAuthClient();
     var authResult = await authClient.LoginAsync(new List<string>() { "wl.signin", "wl.basic", "wl.skydrive" });
     if (authResult.Status == LiveConnectSessionStatus.Connected)
     {
         var session = authResult.Session;
         var client = new LiveConnectClient(session);
         var liveOpResult = await client.GetAsync("me");
         dynamic dynResult = liveOpResult.Result;
         return new UserInfo {Id = dynResult.id, UserName  = dynResult.name, Name = dynResult.name};
     }
     return null;
 }
Пример #22
0
        private async Task LoadUser()
        {
            //윈도우 자체에 로그인 되어있으면 로그아웃 앙보여줘도 괜찮은..그렇지 않은 경우는 보여줌
            var aut = new Windows.Security.Authentication.OnlineId.OnlineIdAuthenticator();
            IsSignOutPossable = aut.CanSignOut;

            IsBusy = true;
            //프로필 로드하고
            var client = new LiveConnectClient(_authClient.Session);
            var liveOpResult = await client.GetAsync("me");
            User = Newtonsoft.Json.JsonConvert.DeserializeObject<LiveUser>(liveOpResult.RawResult);
            IsSignIn = true;
            IsBusy = false;
        }
Пример #23
0
 public static void MicrosoftAccount_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == Microsoft.Live.LiveConnectSessionStatus.Connected)
     {
         MicrosoftAccountClient = new LiveConnectClient(e.Session);
         MicrosoftAccountSession = e.Session;
         MicrosoftAccountClient.GetCompleted += client_GetCompleted;
         MicrosoftAccountClient.GetAsync("me", null);
     }
     else
     {
         CoreViewModel.Instance.MicrosoftAccountImage = "/Images/stock_user.png";
         CoreViewModel.Instance.MicrosoftAccountName = "no Microsoft Account connected";
         MicrosoftAccountClient = null;
     }
 }
Пример #24
0
        private async void Init(LiveConnectSession session)
        {
            if (session == null)
                throw new NullReferenceException("The 'session' parameter cannot be null");
            _liveClient = new LiveConnectClient(session);
            _absoluteRootDirectory = RootDirectory;

            LiveOperationResult operationResult = await _liveClient.GetAsync("me"); //me, or user id will be taken cared of by the session object which will specifically connect to a particular user. so no need to worry about supporting multiple user accounts here.
            dynamic result = operationResult.Result;
            this.UserName = result.name;

            _rootCloudObject = await GetRootDirectoryAsync();


            //_rootCloudObject = new SkyDriveObject(operationResult.Result.Result);
        }
Пример #25
0
        private async void btnFindFolder_Click(object sender, RoutedEventArgs e)
        {
            var client = new LiveConnectClient(Session); // セッションを取得済みであることが前提

            // SkyDrive上のフォルダ、アルバム一覧を取得
            var result1 = await client.GetAsync("me/skydrive/files?filter=folders,albums");
            var folders = (List<object>)result1.Result["data"];
            foreach (dynamic item in folders)
            {
                string name = item.name;
                string id = item.id;

                // デバッグ出力
                System.Diagnostics.Debug.WriteLine("{0}:{1}", name, id);
            }
        }
Пример #26
0
 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;
     }
 }
        public async Task<string> GetSkyDriveFolderID(string folderName, LiveConnectClient client)
        {
            string[] folderNames = folderName.Split('/');
            string result = CloudManagerUI.Properties.Resources.OneDriveRoot;
            int i = 0;
            string cmpValue = String.Empty;

            while (!cmpValue.Equals(folderNames[folderNames.Length - 1]))
            {


                //operationResult = await this.liveConnectClient.GetAsync(result + "/files?filter=folders,albums"); //me/skydrive/files?filter=folders
                LiveOperationResult operationResult = await client.GetAsync(String.Format("{0}/files?filter=folders,albums", result)); //me/skydrive/files?filter=folders


                var iEnum = operationResult.Result.Values.GetEnumerator();
                iEnum.MoveNext();
                var folders = iEnum.Current as IEnumerable;

                foreach (dynamic v in folders)
                {
                    if (v.name == folderNames[i])
                    {
                        i++;
                        result = v.id as string;
                        cmpValue = v.name as string;        //debug test var
                        break;                              //updated time bei values von 'v' für synchronize fürs download


                    }
                }

            }
            if (result != null)
            {

                return result;
            }
            else
            {
                //LogOutput("not found");
                return null;
            }

        }
Пример #28
0
        private async void btnLogin_SessionChanged_1(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                LiveConnectClient client = new LiveConnectClient(e.Session);
                LiveOperationResult operationResult = await client.GetAsync("me");
                try
                {
                    dynamic meResult = operationResult.Result;
                    this.infoTextBlock.Text = "Hello, " + meResult.name + "!";
                }
                catch (LiveConnectException exception)
                {
                    this.infoTextBlock.Text = "Error: " + exception.Message;
                }
            }

        }
Пример #29
0
 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;
     }
 }
Пример #30
0
 /// <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;
     }
 }
Пример #31
0
        private async void SkydriveDownload_Click(object sender, RoutedEventArgs e)
        {
            string id = string.Empty;

            try
            {
                LiveConnectClient   client   = new Microsoft.Live.LiveConnectClient(authClient.Session);
                LiveOperationResult opResult = await client.GetAsync("me/skydrive/files");

                dynamic result = opResult.Result;

                List <object> items = opResult.Result["data"] as List <object>;

                foreach (object item in items)
                {
                    IDictionary <string, object> file = item as IDictionary <string, object>;

                    if (file["name"].ToString() == theFileToGet)
                    {
                        id = file["id"].ToString();
                        tblUserName.Text = file["id"].ToString();
                        //file found
                        //terminate loop
                        break;
                    }
                }

                if (id != "")
                {
                    bool downloadOperationResult = await DownloadFile(id, theFileToGet);

                    if (!downloadOperationResult)
                    {
                        tblUserName.Text = "File Downloading Failed";
                    }
                    else
                    {
                        tblUserName.Text = "File Downloading Successful";
                        var file = await storageFolder.GetFileAsync(theFileToGet);

                        string text = await Windows.Storage.FileIO.ReadTextAsync(file);

                        try
                        {
                            GlobalV.tempLevel = Convert.ToInt32(text);
                        }
                        catch (OverflowException of)
                        {
                        }
                        catch (FormatException fx)
                        {
                        }
                    }
                }//end if (id != "")
                else
                {
                    tblUserName.Text = "file did not downloaded continue play";
                }
            }
            catch (Exception ex)
            {
                MessageDialog dlg = new MessageDialog("File did not downloaded from skydrive. please continue play");
                dlg.ShowAsync();
            }
        }//end download method