Пример #1
0
 /// <summary>
 /// LiveOperationCompletedEventArgs event handler OnGetCompleted
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result.ContainsKey("first_name") ||
             e.Result.ContainsKey("last_name"))
         {
             if (e.Result.ContainsKey("first_name"))
             {
                 if (e.Result["first_name"] != null)
                 {
                     FirstName = e.Result["first_name"].ToString();
                 }
             }
             if (e.Result.ContainsKey("last_name"))
             {
                 if (e.Result["last_name"] != null)
                 {
                     LastName = e.Result["last_name"].ToString();
                 }
             }
             String Welcome = SkyPhoto.Resources.Resources.Welcome;
             ProfileName.Text = Welcome + " " + FirstName + " " + LastName; 
             gotoAlbum.Visibility = Visibility.Visible;
             GetProfilePicture();
             NavigationService.Navigate(new Uri("/AlbumPage.xaml", UriKind.Relative));
         }
     }
 }
Пример #2
0
        protected override bool IsValidPath(string path)
        {
            if (PathIsDrive(path))
            {
                return(true);
            }

            try
            {
                OneDriveInfo oneDrive = PSDriveInfo as OneDriveInfo;

                LiveOperationCompletedEventArgs eventArgs = default(LiveOperationCompletedEventArgs);
                using (ManualResetEvent signal = new ManualResetEvent(false))
                {
                    oneDrive.Client.GetCompleted += (s, e) => { eventArgs = e; signal.Set(); };
                    oneDrive.Client.GetAsync(hiddenRoot + path, signal);

                    signal.WaitOne();
                }

                OneDriveItem onedriveItem = new OneDriveItem((((object[])eventArgs.Result["data"]).Cast <IDictionary <string, object> >()).First());
                return(onedriveItem.IsFolder || onedriveItem.IsAlbum ? true : false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #3
0
 void btnSignin_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result.ContainsKey("first_name") &&
             e.Result.ContainsKey("last_name"))
         {
             if (e.Result["first_name"] != null &&
                 e.Result["last_name"] != null)
             {
                 infoTextBlock.Text =
                     "Hello, " +
                     e.Result["first_name"].ToString() + " " +
                     e.Result["last_name"].ToString() + "!";
             }
         }
         else
         {
             infoTextBlock.Text = "Hello, signed-in user!";
         }
     }
     else
     {
         infoTextBlock.Text = "Error calling API: " +
             e.Error.ToString();
     }
 }
Пример #4
0
        void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            Debug.WriteLine("OnGetCompleted");
            if (e.Error == null)
            {
                //if (e.Result.ContainsKey("first_name") &&
                //    e.Result.ContainsKey("last_name"))
                //{
                //    if (e.Result["first_name"] != null &&
                //        e.Result["last_name"] != null)
                //    {
                //        this.txtWelcome.Text =
                //            "Hello, " +
                //            e.Result["first_name"].ToString() + " " +
                //            e.Result["last_name"].ToString() + "!";
                //    }
                //}
                //else
                //{
                //    txtWelcome.Text = "Hello, signed-in user!";
                //}

                //IsAppFolderPresent();

                App.Current.SkyDriveFolders.GetFolderID();
            }
            else
            {
                txtCurFolder.Text = "Error calling API: " +
                                    e.Error.ToString();
            }
        }
Пример #5
0
        void folderListClient_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }

            int           i     = 0;
            SkydriveAlbum album = (SkydriveAlbum)e.UserState;

            album.Photos.Clear();
            List <object> data = (List <object>)e.Result["data"];

            foreach (IDictionary <string, object> photo in data)
            {
                var item = new SkydrivePhoto();
                item.Title    = (string)photo["name"];
                item.Subtitle = (string)photo["name"];

                item.PhotoUrl    = (string)photo["source"];
                item.Description = (string)photo["description"];
                item.ID          = (string)photo["id"];

                if (album != null)
                {
                    album.Photos.Add(item);
                }
                // Stop after downloaing 10 imates
                if (i++ > 10)
                {
                    break;
                }
            }
        }
Пример #6
0
 void clientGetPicture_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         ProfileImage = (string)e.Result["location"];
     }
 }
Пример #7
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);
             }
         }
     }
 }
Пример #8
0
 /// <summary>
 /// LiveOperationCompletedEventArgs event handler OnGetCompleted
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result.ContainsKey("first_name") ||
             e.Result.ContainsKey("last_name"))
         {
             if (e.Result.ContainsKey("first_name"))
             {
                 if (e.Result["first_name"] != null)
                 {
                     FirstName = e.Result["first_name"].ToString();
                 }
             }
             if (e.Result.ContainsKey("last_name"))
             {
                 if (e.Result["last_name"] != null)
                 {
                     LastName = e.Result["last_name"].ToString();
                 }
             }
             String Welcome = SkyPhoto.Resources.Resources.Welcome;
             ProfileName.Text     = Welcome + " " + FirstName + " " + LastName;
             gotoAlbum.Visibility = Visibility.Visible;
             GetProfilePicture();
             NavigationService.Navigate(new Uri("/AlbumPage.xaml", UriKind.Relative));
         }
     }
 }
Пример #9
0
 /// <summary>
 /// LiveOperationCompletedEventArgs event handler GetPicture_GetCompleted
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void GetPicture_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         ProfilePic.Source = new BitmapImage(new Uri((string)e.Result["location"], UriKind.RelativeOrAbsolute));
     }
 }
Пример #10
0
 void Show_Files_Completed(object sender, LiveOperationCompletedEventArgs e)
 {
     wait_async           = false;
     client.GetCompleted -= Show_Files_Completed;
     if (e.Error == null)
     {
         list_files_skydrive = new List <SkyDriveContent>();
         List <object> data = (List <object>)e.Result["data"];
         foreach (IDictionary <string, object> content in data)
         {
             string test_extension = content["name"].ToString().Substring(content["name"].ToString().Length - 7, 7);
             if (test_extension == "gpx.txt")
             {
                 SkyDriveContent skyContent = new SkyDriveContent();
                 skyContent.Name = content["name"].ToString().Substring(0, content["name"].ToString().Length - 4);
                 skyContent.Id   = (string)content["id"];
                 list_files_skydrive.Add(skyContent);
             }
         }
         ListBox_SkyContent.ItemsSource = list_files_skydrive;
         textBlockStatus.Text           = "Connecté";
     }
     else
     {
         MessageBox.Show("Erreur liste fichiers :" + e.Error.ToString());
         return;
     }
 }
Пример #11
0
        private void Signin_BaseFolder(object sender, LiveOperationCompletedEventArgs e)
        {
            client.GetCompleted -= Signin_BaseFolder;
            if (e.Result == null)
            {
                MessageBox.Show("Erreur lecture dossiers: " + e.Error.ToString());
                return;
            }
            List <object> entries;
            Dictionary <string, object> properties;

            entries = (List <object>)e.Result["data"];
            foreach (object entry in entries)
            {
                properties = (Dictionary <string, object>)entry;
                if ((((string)properties["name"]) == sky_base_folder) && (((string)properties["type"]) == "folder"))
                {
                    sky_base_folder_id   = (string)properties["id"];
                    textBlockStatus.Text = "Fichiers...";
                    client.GetCompleted += new EventHandler <LiveOperationCompletedEventArgs>(Show_Files_Completed);
                    client.GetAsync(sky_base_folder_id + "/files");
                }
            }
            if (sky_base_folder_id == null)
            {// create repertoire + recup ID
                Dictionary <string, object> folderData = new Dictionary <string, object>();
                folderData.Add("name", sky_base_folder);
                client.PostCompleted += new EventHandler <LiveOperationCompletedEventArgs>(Signin_BaseFolder_Completed);
                client.PostAsync("me/skydrive", folderData);
            }
        }
Пример #12
0
 void clientGetMe_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         FullName = (string)e.Result["name"];
     }
 }
Пример #13
0
        private void GetFolderProperties_Completed(object sender, LiveOperationCompletedEventArgs e)
        {

            if (e.Error == null)
            {
                Dictionary<string, object> folderData = (Dictionary<string, object>)e.Result;
                List<object> folders = (List<object>)folderData["data"];

                foreach (object item in folders)
                {
                    Dictionary<string, object> folder = (Dictionary<string, object>)item;
                    if (folder["name"].ToString() == skyDriveFolderName)
                        skyDriveFolderID = folder["id"].ToString();
                }

                if (skyDriveFolderID == string.Empty)
                {
                    Dictionary<string, object> skyDriveFolderData = new Dictionary<string, object>();
                    skyDriveFolderData.Add("name", skyDriveFolderName);
                    //You can add a folder description, but for some reason it does not work.
                    //folderData.Add("description", "Folder for storing files from my WP7 app isolated storage.");
                    client.PostCompleted += new EventHandler<LiveOperationCompletedEventArgs>(CreateFolder_Completed);
                    client.PostAsync("me/skydrive", skyDriveFolderData);
                }
                else
                    UploadFile();
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Пример #14
0
        private void client_GetFolderInfoCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                var folders = e.Result["data"] as List <object>;

                foreach (IDictionary <string, object> folder in folders)
                {
                    if (folder["name"].ToString() == _skyDriveFolderName)
                    {
                        _skyDriveFolderID = folder["id"].ToString();
                        break;
                    }
                }

                if (_skyDriveFolderID == string.Empty)
                {
                    var skyDriveFolderData = new Dictionary <string, object>();
                    skyDriveFolderData.Add("name", _skyDriveFolderName);
                    client.PostCompleted += client_CreateFolderCompleted;
                    client.PostAsync("me/skydrive", skyDriveFolderData);
                }
                else
                {
                    uploadFile();
                }
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Пример #15
0
 void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result.ContainsKey("first_name") &&
             e.Result.ContainsKey("last_name"))
         {
             if (e.Result["first_name"] != null &&
                 e.Result["last_name"] != null)
             {
                 this.txtWelcome.Text =
                     "Hello, " +
                     e.Result["first_name"].ToString() + " " +
                     e.Result["last_name"].ToString() + "!";
             }
         }
         else
         {
             txtWelcome.Text = "Hello, signed-in user!";
         }
     }
     else
     {
         txtWelcome.Text = "Error calling API: " +
             e.Error.ToString();
     }
 }
Пример #16
0
        protected override void GetChildItems(string path, bool recurse)
        {
            // Files = me/skydrive:me/skydrive/files
            // Folders = me/skydrive:me/skydrive/files?filter=folders
            // Photos = me/skydrive:me/skydrive/files?filter=albums

            OneDriveInfo oneDrive = PSDriveInfo as OneDriveInfo;

            LiveOperationCompletedEventArgs eventArgs = default(LiveOperationCompletedEventArgs);

            using (ManualResetEvent signal = new ManualResetEvent(false))
            {
                oneDrive.Client.GetCompleted += (s, e) => { eventArgs = e; signal.Set(); };
                oneDrive.Client.GetAsync(hiddenRoot + path, signal);

                signal.WaitOne();
            }

            var items = ((object[])eventArgs.Result["data"]).Cast <IDictionary <string, object> >();

            foreach (var item in items)
            {
                OneDriveItem onedriveItem = new OneDriveItem(item);
                WriteItemObject(onedriveItem, hiddenRoot + onedriveItem.Name, onedriveItem.IsFolder || onedriveItem.IsAlbum ? true : false);
            }
        }
Пример #17
0
        void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            try
            {
                if (e.Result.ContainsKey("available"))
                {
                    Int64  available = Convert.ToInt64(e.Result["available"]);
                    byte[] data      = RecordManager.GetRecordByteArray(MainPageViewModel.Instance.CurrentlyUploading);

                    if (available >= data.Length)
                    {
                        MemoryStream stream = new MemoryStream(data);

                        client = new LiveConnectClient(App.MicrosoftAccountSession);
                        client.UploadCompleted       += MicrosoftAccountClient_UploadCompleted;
                        client.UploadProgressChanged += MicrosoftAccountClient_UploadProgressChanged;
                        client.UploadAsync("me/skydrive", MainPageViewModel.Instance.CurrentlyUploading,
                                           stream, OverwriteOption.Overwrite);
                        grdUpload.Visibility     = System.Windows.Visibility.Visible;
                        ApplicationBar.IsVisible = false;
                    }
                    else
                    {
                        MessageBox.Show("Looks like you don't have enough space on your SkyDrive. Go to http://skydrive.com and either purchase more space or clean up the existing storage.", "Upload",
                                        MessageBoxButton.OK);
                    }
                }
            }
            catch
            {
                FailureAlert();
            }
        }
Пример #18
0
        void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                this.ApplicationTitle.Text = "got folder list";
                Dictionary<string, object> folderData = (Dictionary<string, object>)e.Result;
                List<object> folders = (List<object>)folderData["data"];

                foreach (object item in folders)
                {
                    Dictionary<string, object> folder = (Dictionary<string, object>)item;
                    if (folder["name"].ToString() == skyDriveFolderName)
                        skyDriveFolderID = folder["id"].ToString();
                }

                if (skyDriveFolderID == string.Empty)
                {
                    Dictionary<string, object> skyDriveFolderData = new Dictionary<string, object>();
                    skyDriveFolderData.Add("name", skyDriveFolderName);
                    skyDriveFolderData.Add("type", "folder");
                    client.PostCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_PostCompleted);
                    client.PostAsync("me/skydrive", skyDriveFolderData);
                }
                else
                {
                    this.ApplicationTitle.Text = "found folder";
                    UploadFile();
                }
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Пример #19
0
 private void uploadClient_BackgroundUploadCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Deployment.Current.Dispatcher.BeginInvoke(() => DownloadPictures(SelectedAlbum));
     }
 }
        void TraverseDirectory_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            string message;

            if (e.Error == null)
            {
                // Map query
                files = JsonConvert.DeserializeObject <Files>(e.RawResult);
                Debug.WriteLine(e.RawResult);
                foreach (SkyDriveBrowser.SkyDriveModels.FileInfo fileInfo in files.data)
                {
                    //          Debug.WriteLine(fileInfo.ToString());
                    Debug.WriteLine(fileInfo.Id.ToString());
                    Debug.WriteLine(fileInfo.Name.ToString());
                    Debug.WriteLine(fileInfo.Type.ToString());
                    //Debug.WriteLine(fileInfo.Description.ToString
                }
                filesListBox.ItemsSource = files.data;
            }
            else
            {
                message = "Error calling API: " + e.Error.Message;
                Debug.WriteLine("Error calling API: " + e.Error.Message);
            }
        }
Пример #21
0
        //创建image目录完成
        private void CreateFolder2_Completed(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                //infoTextBlock.Text = txtnote.Resources.StringLibrary.shareInfo_3;
                Dictionary <string, object> folder = (Dictionary <string, object>)e.Result;
                skyDriveFolderID_image = folder["id"].ToString(); //grab the folder ID
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
            //如果image文件夹不存在,建立之后,判断merge是否存在,不存在则建立之
            if (skyDriveFolderID_merge == string.Empty)
            {
                Dictionary <string, object> skyDriveFolderData = new Dictionary <string, object>();
                skyDriveFolderData.Add("name", "Merge");
                // client.PostCompleted -= new EventHandler<LiveOperationCompletedEventArgs>(CreateFolder_Completed);
                client.PostCompleted -= new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder2_Completed);
                client.PostCompleted += new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder3_Completed);

                client.PostAsync(skyDriveFolderID, skyDriveFolderData);
                infoTextBlock.Text = "Creating folder...Merge";
            }
        }
Пример #22
0
 void ClientDeleteCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     _deleteCounter--;
     if (_deleteCounter <= 0)
     {
         OnUploadComplited(EventArgs.Empty);
     }
 }
Пример #23
0
 void albumPictureClient_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         SkydriveAlbum album = (SkydriveAlbum)e.UserState;
         album.AlbumPicture = (string)e.Result["location"];
     }
 }
Пример #24
0
        /// <summary>
        /// uploadClient event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void ISFile_UploadCompleted(object sender, LiveOperationCompletedEventArgs args)
        {
            HideProgressBar();
            string progMsgDownAlumPic = SkyPhoto.Resources.Resources.progMsgDownAlumPic;

            ShowProgressBar(progMsgDownAlumPic);
            ImageCounter = 0;
            DownloadPictures(App.CurrentAlbum);
        }
Пример #25
0
        protected override PSDriveInfo NewDrive(PSDriveInfo drive)
        {
            try
            {
                using (var dialog = new SignInDialog())
                {
                    dialog.Scopes        = new[] { "wl.basic", "wl.signin", "wl.offline_access", "wl.skydrive_update", "wl.contacts_skydrive", "wl.emails" };
                    dialog.ShowInTaskbar = true;
                    dialog.Locale        = "en";
                    dialog.ClientId      = "000000004412E411";

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        OneDriveInfo oneDrive = new OneDriveInfo(drive);
                        oneDrive.Client = new LiveConnectClient(dialog.Session);

                        LiveOperationCompletedEventArgs eventArgs = default(LiveOperationCompletedEventArgs);
                        using (ManualResetEvent signal = new ManualResetEvent(false))
                        {
                            oneDrive.Client.GetCompleted += (s, e) => { eventArgs = e; signal.Set(); };
                            oneDrive.Client.GetAsync("me", signal);

                            signal.WaitOne();
                        }

                        if (eventArgs.Error == null)
                        {
                            foreach (var key in eventArgs.Result.Keys)
                            {
                                WriteVerbose(string.Format("{0}={1}", key, eventArgs.Result[key]));
                            }
                            return(oneDrive);
                        }

                        if (eventArgs.Cancelled)
                        {
                            WriteError(new ErrorRecord(new Exception("Operation cancelled by user."), "503", ErrorCategory.InvalidOperation, null));
                            return(null);
                        }

                        WriteError(new ErrorRecord(new Exception(eventArgs.Error.Message), "200", ErrorCategory.AuthenticationError, null));
                        return(null);
                    }
                    else
                    {
                        WriteError(new ErrorRecord(new Exception("Operation cancelled by user."), "502", ErrorCategory.InvalidOperation, null));
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex.InnerException, "100", ErrorCategory.NotSpecified, null));
                return(null);
            }
        }
Пример #26
0
        void clientGetPicture_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                var img = new System.Windows.Media.Imaging.BitmapImage();
                img.UriSource = new Uri((string)e.Result["location"]);

                dataPhoto.Source = img;
            }
        }
Пример #27
0
        static void ClientGetFolderList_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            try
            {
                if (e.Error == null)
                {
                    bool          dataFolderExists = false;
                    List <object> data             = (List <object>)e.Result["data"];
                    foreach (IDictionary <string, object> dictionary in data)
                    {
                        if (string.IsNullOrEmpty(skyDriveFolderID))
                        {
                            if (dictionary.ContainsKey("name") && (string)dictionary["name"] == SettingsApi.SkyDriveFolderName &&
                                dictionary.ContainsKey("type") && (string)dictionary["type"] == "folder")
                            {
                                if (dictionary.ContainsKey("id"))
                                {
                                    skyDriveFolderID = (string)dictionary["id"];
                                    dataFolderExists = true;
                                }
                            }
                        }
                    }

                    if (!dataFolderExists)
                    {
                        // create SkyDrive data folder
                        Dictionary <string, object> body = new Dictionary <string, object>();
                        body.Add("name", SettingsApi.SkyDriveFolderName);
                        object[] state = new object[2];
                        state[0] = "create folder";
                        state[1] = body["name"];

                        try
                        {
                            LiveConnectClient createFolderClient = new LiveConnectClient(App.Session);
                            createFolderClient.PostCompleted += new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder_Completed);
                            createFolderClient.PostAsync("/me/skydrive", body, state);
                        }
                        catch (Exception eCreateFolder)
                        {
                            MessageBox.Show("Nie można utworzyć folderu na SkyDrive: " + eCreateFolder.Message);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Problem z dostępem do SkyDrive: " + e.Error.Message);
                }
            }
            catch (Exception eFolder)
            {
                Debug.WriteLine("Błąd konfiguracji folderu: " + eFolder.Message);
            }
        }
 /// <summary>
 /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#file_links
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void GetSharedLink_Completed(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Debug.WriteLine("Shared link = " + e.Result["link"].ToString());
     }
     else
     {
         Debug.WriteLine("Error calling API: " + e.Error.ToString());
     }
 }
Пример #29
0
 void UploadCompleted(object sender, LiveOperationCompletedEventArgs args)
 {
     if (args.Error == null)
     {
         // File uploaded.
     }
     else
     {
         // There was an error uploading... should probably log this.
     }
 }
 /// <summary>
 /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#creating_folders
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void CreateFolder_Completed(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Debug.WriteLine("Folder created.");
     }
     else
     {
         Debug.WriteLine("Error calling API: " + e.Error.ToString());
     }
 }
 /// <summary>
 /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#updating_files_props
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void RenameFile_Completed(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Debug.WriteLine("File renamed.");
     }
     else
     {
         Debug.WriteLine("Error calling API: " + e.Error.ToString());
     }
 }
 /// <summary>
 /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#move
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void MoveFile_MoveCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Debug.WriteLine("File or folder move completed.");
     }
     else
     {
         Debug.WriteLine("Error calling API: " + e.Error.ToString());
     }
 }
Пример #33
0
 private static void ISFile_UploadCompleted(object sender, LiveOperationCompletedEventArgs args)
 {
     if (args.Error == null)
     {
         readStream.Dispose(); //stop using the readStream so that the user can click Backup again without it crashing
         App.ViewModel.UpdateFotoSyncStatus(Int32.Parse(args.UserState.ToString()), StatusEnum.Yes);
     }
     else
     {
         App.ViewModel.UpdateFotoSyncStatus(Int32.Parse(args.UserState.ToString()), StatusEnum.No);
     }
 }
Пример #34
0
 //finished creating the IsolatedStorageData folder
 private static void CreateFolder_Completed(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Dictionary <string, object> folder = (Dictionary <string, object>)e.Result;
         skyDriveFolderID = folder["id"].ToString(); //grab the folder ID
     }
     else
     {
         MessageBox.Show(e.Error.Message);
     }
 }
        private void client_UploadCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            busyIndicator.IsRunning = false;
            btnSignIn.IsEnabled = true;
            btnSave.IsEnabled = true;
            btnRestore.IsEnabled = true;

            if (e.Error == null)
                log.Add(new LogMessage(Labels.BackupCompleted, e.Result["name"].ToString()));//e.Result["id"].ToString()
            else
                log.Add(new LogMessage(e.Error.Message, null, true));
        }
Пример #36
0
 void client_PostCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         this.ApplicationTitle.Text = "created folder";
         skyDriveFolderID = e.Result["id"].ToString();
         UploadFile();
     }
     else
     {
         MessageBox.Show("Folder creation problem:\n\n" + e.Error.ToString());
     }
 }
Пример #37
0
        void clientDataFetch_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                // extract return data and populate ContentList with document names
                List<object> data = (List<object>)e.Result["data"];
                contentList.Clear();
                foreach (IDictionary<string, object> content in data)
                {
                    SkyDriveContent skyContent = new SkyDriveContent();
                    skyContent.Name = (string)content["name"];
                    skyContent.Type = (string)content["type"];
                    skyContent.ID = (string)content["id"];
                    contentList.Add(skyContent);
                }

                this.progressIndicator.IsVisible = false;
                this.contentListBox.ItemsSource = contentList;
            }
        }
Пример #38
0
 static void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result != null)
         {
             if (e.Result.ContainsKey("first_name") && e.Result.ContainsKey("last_name"))
             {
                 if (e.Result["first_name"] != null && e.Result["last_name"] != null)
                 {
                     CoreViewModel.Instance.MicrosoftAccountName = e.Result["first_name"].ToString() + " " + e.Result["last_name"].ToString();
                     MicrosoftAccountClient.GetAsync("me/picture", null);
                 }
             }
             else if (e.Result.ContainsKey("location"))
             {
                 CoreViewModel.Instance.MicrosoftAccountImage = e.Result["location"].ToString();
             }
         }
     }
 }
Пример #39
0
        void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            // thanks to http://www.silverlightshow.net/items/SkyDrive-usage-through-Live-SDK-on-Windows-Phone.aspx
            if (e.Error == null)
            {
                string firstName = "";
                string lastName = "";
                if (e.Result.ContainsKey("first_name") ||
                    e.Result.ContainsKey("last_name"))
                {
                    if (e.Result.ContainsKey("first_name"))
                    {
                        if (e.Result["first_name"] != null)
                        {
                            firstName = e.Result["first_name"].ToString();
                        }
                    }
                    if (e.Result.ContainsKey("last_name"))
                    {
                        if (e.Result["last_name"] != null)
                        {
                            lastName = e.Result["last_name"].ToString();
                        }
                    }
                    infoTextBlock.Text =
                        "Hello, " + firstName + " " + lastName + "!";
                }
                else
                {
                    infoTextBlock.Text = "Hello, signed-in user!";
                }

                this.btnViewContents.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                infoTextBlock.Text = "Error calling API: " +
                    e.Error.ToString();
            }
        }
Пример #40
0
        /// <summary>
        /// LiveConnectClient event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void GetAlubmData_Completed(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }

            List<object> data = (List<object>)e.Result["data"];
            if (ImageCounter == 0)
            {
                ImageCounter = data.Count;
            }

            foreach (IDictionary<string, object> album in data)
            {
                SkydriveAlbum albumItem = new SkydriveAlbum();
                albumItem.Title = (string)album["name"];
                albumItem.Description = (string)album["description"];
                albumItem.ID = (string)album["id"];
                Albums.Add(albumItem);
                GetAlbumPicture(albumItem);
            }
        }
        private void BackupCompletedCallback(object sender, LiveOperationCompletedEventArgs args)
        {
            _totalBackedUp += 1;
            if (args.Error == null)
            {
                _model.Message = "Backup complete.";

                if (_totalBackedUp == FileNames.Count)
                {
                    ReadStream.Dispose();
                    _totalBackedUp = 0;
                }

                _model.Date = "Checking for new backup...";

                //get the newly created fileID's (it will update the time too, and enable restoring)
                LiveClient.LiveClient = new LiveConnectClient(_session);
                LiveClient.GetLiveConnectData(SkyDriveFolderId + "/files", GetLiveConnectDataByFileIdCallback);
            }
            else
            {
                _model.Message = "Error uploading file: " + args.Error.ToString();
            }
        }
		private void OnLiveClientBackgroundDownloadCompleted(object sender, LiveOperationCompletedEventArgs e)
		{
			// Sync Step 5. The file has already been downloaded to isostore.
			// Just move it to its right location.
			// (This only runs on the device.)

			int filesLeft;
			string dlFilename;
			string originalFilename;
			PreProcessDownload(e, out filesLeft, out dlFilename, out originalFilename);

			string filepath = GetIsoStorePath(originalFilename);
			if (e.Result != null)
			{
				// Moves the file.
				using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
				{
					// Makes sure the directory exists.
					isf.CreateDirectory(IsoStoreCartridgesPath);

					// Removes the destination file if it exists.
					if (isf.FileExists(filepath))
					{
						isf.DeleteFile(filepath);
					}

					// Moves the downloaded file to the right place.
					try
					{
						isf.MoveFile(GetTempIsoStorePath(dlFilename), filepath);
					}
					catch (Exception ex)
					{
						// In case of exception here, do nothing.
						// An attempt to load the file will be done anyway.
						Geowigo.Utils.DebugUtils.DumpException(ex, string.Format("dlFilename={0};targetFilename={1}", dlFilename, filepath), true);
					}
				}
			}

			PostProcessDownload(filepath, filesLeft);
		}
Пример #43
0
 void UploadCompleted(object sender, LiveOperationCompletedEventArgs args)
 {
     if (args.Error == null)
     {
         // File uploaded.
     }
     else
     {
         // There was an error uploading... should probably log this.
     }
 }
Пример #44
0
        void findNoteList_Callback(object sender, LiveOperationCompletedEventArgs e)
        {
            client.GetCompleted -= findNoteList_Callback;

            if (e.Error == null)
            {
                notes = new Dictionary<string, noteListItem>();
                notesList.Items.Clear();

                List<object> data = (List<object>)e.Result["data"];

                // Generate parent folder list entry
                if (folderIds.Peek() != "/me/skydrive")
                {
                    createNoteListEntry("..", null, "folder");
                }

                 foreach (IDictionary<string, object> datum in data)
                {
                    String name = datum["name"].ToString();
                    String type = datum["type"].ToString();

                    if (type == "folder")
                    {
                        createNoteListEntry(name, datum["id"].ToString(), "folder");
                    }
                    else if (name.EndsWith(".txt"))
                    {
                        name = name.Replace(".txt", null);
                        createNoteListEntry(name, datum["id"].ToString(), "note");
                    }
                }
                statusTxt.Text = "Found " + notesList.Items.Count + " items";
             }
            else
            {
                statusTxt.Text = e.Error.Message;
            }

            notesList.SelectionChanged += notesList_SelectionChanged;
        }
Пример #45
0
        private void getUserName_Callback(object sender, LiveOperationCompletedEventArgs e)
        {
            client.GetCompleted -= getUserName_Callback;

            if (e.Error == null)
            {
                var user = e.Result;
                userNameTxt.Text = user["name"].ToString();
            }
            else
            {
                statusTxt.Text = e.Error.Message;
            }

            findNoteList("/me/skydrive");
        }
Пример #46
0
        void getUserPicture_Callback(object sender, LiveOperationCompletedEventArgs e)
        {
            client.GetCompleted -= getUserPicture_Callback;

            if (e.Error == null)
            {
                dynamic result = e.Result;
                BitmapImage imgSource = new BitmapImage();
                imgSource.UriSource = new Uri(result.location, UriKind.Absolute);
                this.userImage.Source = imgSource;

            }
            else
            {
                statusTxt.Text = e.Error.Message;
            }

            getUserName();
        }
Пример #47
0
        void saveNote_Callback(object sender, LiveOperationCompletedEventArgs e)
        {
            client.UploadCompleted -= saveNote_Callback;

            if (e.Error == null)
            {
                statusTxt.Text = "File saved";

                saveBtn.IsEnabled = false;
                addBtn.IsEnabled = true;
                deleteNoteBtn.IsEnabled = true;
                cancelBtn.IsEnabled = false;
                needToSave = false;

                findNoteList(folderIds.Peek());
            }
            else
            {
                statusTxt.Text = e.Error.Message;
            }
        }
Пример #48
0
 void albumPictureClient_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         SkydriveAlbum album = (SkydriveAlbum)e.UserState;
         album.AlbumPicture = (string)e.Result["location"];
     }
 }
        private void GetLiveConnectDataByFileIdCallback(object sender, LiveOperationCompletedEventArgs e)
        {
            _model.Date = "Obtaining previous backup...";

            List<object> data = (List<object>)e.Result["data"];

            DateTimeOffset date = DateTime.MinValue;

            IDictionary<string, object> test = (IDictionary<string, object>)data.FirstOrDefault();

            try
            {
                date = DateTimeOffset.Parse(((string)test["updated_time"]).Substring(0, 19));
            }

            catch { }

            foreach (IDictionary<string, object> content in data)
            {
                if (FileNames.Contains((string)content["name"]) && !Files.Keys.Contains((string)content["name"]))
                {
                    Files.Add((string)content["name"], (string)content["id"]);

                    try
                    {
                        date = DateTimeOffset.Parse(((string)content["updated_time"]).Substring(0, 19));
                    }

                    catch { }

                    // break;
                }
            }

            if (test != null)
            {
                try
                {
                    _model.Date = (date != DateTime.MinValue) ? "Last backup on " + date.Add(date.Offset).DateTime : "Last backup on: unknown";
                }

                catch
                {
                    _model.Date = "Last backup on: unknown";
                }

                _model.RestoreEnabled = true; //enable restoring since the file exists
            }

            else
                _model.Date = "No previous backup available to restore.";
        }
 private void CreateLiveConnectFoldersSkyDriveCallback(object sender, LiveOperationCompletedEventArgs e)
 {
     _model.Message = "Ready to backup.";
     _model.Date = "No previous backup available to restore.";
     _model.BackupEnabled = true;
     Dictionary<string, object> folder = (Dictionary<string, object>)e.Result;
     SkyDriveFolderId = folder["id"].ToString();
 }
        private void GetFoldersCallback(object sender, LiveOperationCompletedEventArgs e)
        {
            _model.Message = "Loading folder...";

            Dictionary<string, object> folderData = (Dictionary<string, object>)e.Result;
            List<object> folders = (List<object>)folderData["data"];

            foreach (object item in folders)
            {
                Dictionary<string, object> folder = (Dictionary<string, object>)item;
                if (folder["name"].ToString() == _appFolderName)
                {
                    SkyDriveFolderId = folder["id"].ToString();
                }
            }

            if (SkyDriveFolderId == string.Empty)
            {
                Dictionary<string, object> skyDriveFolderData = new Dictionary<string, object>();
                skyDriveFolderData.Add("name", _appFolderName);

                _model.Message = "Creating folder...";
                LiveClient.CreateLiveConnectFoldersSkyDrive(skyDriveFolderData, CreateLiveConnectFoldersSkyDriveCallback);
            }
            else
            {
                LiveClient.LiveClient = new LiveConnectClient(_session);
                _model.Message = "Ready to backup.";
                _model.Date = "Checking for previous backups...";
                _model.BackupEnabled = true;
                LiveClient.GetLiveConnectData(SkyDriveFolderId + "/files", GetLiveConnectDataByFileIdCallback);
            }
        }
Пример #52
0
        void clientFolder_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                List<object> data = (List<object>)e.Result["data"];

                foreach (IDictionary<string,object> album in data)
                {
                    SkydriveAlbum albumItem = new SkydriveAlbum();
                    albumItem.Title = (string)album["name"];

                    albumItem.Description = (string)album["description"];
                    albumItem.ID = (string)album["id"];

                    Albums.Add(albumItem);
                    GetAlbumPicture(albumItem);
                    DownloadPictures(albumItem);
                }
            }
        }
Пример #53
0
        void clientGetPicture_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {

                ProfileImage = (string)e.Result["location"];
            }
        }
Пример #54
0
        void folderListClient_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                int i = 0;
                SkydriveAlbum album = (SkydriveAlbum)e.UserState;

                album.Photos.Clear();
                List<object> data = (List<object>)e.Result["data"];

                foreach (IDictionary<string, object> photo in data)
                {
                    var item = new SkydrivePhoto();
                    item.Title = (string)photo["name"];
                    item.Subtitle = (string)photo["name"];

                    item.PhotoUrl = (string)photo["source"];
                    item.Description = (string)photo["description"];
                    item.ID = (string)photo["id"];

                    if (album != null)
                    {
                        album.Photos.Add(item);
                    }
                    // Stop after downloaing 10 imates
                    if (i++ > 10)
                        break;
                }
            }
        }
Пример #55
0
        void uploadClient_UploadCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {

                Deployment.Current.Dispatcher.BeginInvoke(() => DownloadPictures(SelectedAlbum));

            }
        }
        /// <summary>
        /// Une fois le transfère terminé, envoie d'un email
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void client_UploadCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Debug.WriteLine(e.Error.Message);
                //this.enableInterface();
                return;
            }
            //this.enableInterface();
            Debug.WriteLine("Upload File completed!");
            myIsolatedStorage.Dispose();
            fileStream.Dispose();
            reader.Dispose();
            IDictionary<string, object> file = e.Result;
            String link = file["source"] as string;
            Microsoft.Phone.Tasks.EmailComposeTask emailTask = new Microsoft.Phone.Tasks.EmailComposeTask();
            string str = String.Format("Bonjour, \n\n Le document Excel que vous avez demandé et désormais disponible à l'adresse suivante : \n\n");
            str += String.Format("{0}\n\n ", link);
            str += String.Format(" Lors de l'ouverture de ce document certaines erreurs pourraient survenir. Il vous suffit de les accepter pour pouvoir ouvrir votre feuille de frais. \nL'application étant encore en phase de test, n'hésitez pas à nous faire des retours sur la page adéquat du Windows Market Place. \nToute l'équipe de PlanMyWay vous remercie de votre confiance. \n\nCordialement,");
            emailTask.Body = str;
            emailTask.Subject = "PlanMyWay - Feuille de frais du " + this.myRoadM.Date.ToShortDateString();
            emailTask.Show();

            MessageBox.Show("Export Excel terminé. Votre feuille de frais est disponible sur votre skydrive");
        }
Пример #57
0
        void clientGetPicture_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                var img = new System.Windows.Media.Imaging.BitmapImage();
                img.UriSource = new Uri((string)e.Result["location"]);

                dataPhoto.Source = img;
            }
        }
		private void OnLiveClientGetCompleted(object sender, LiveOperationCompletedEventArgs e)
		{
			// Cancels the timeout timer.
			CancelTimeoutTimer();
			
			// No result? Nothing to do.
			if (e.Result == null)
			{
				EndSync(); 
				return;
			}

			if ("root".Equals(e.UserState))
			{
				// Sync Step 2: We are getting results for the root folder.
				// We need to enumerate through all file entries and find the first
				// folder whose name is "Geowigo".
				// Then, we will ask for file enumerations of this folder.
				// If no folder is found, the sync is over.

				// Enumerates through all the file entries.
				List<object> data = (List<object>)e.Result["data"];
				foreach (IDictionary<string, object> content in data)
				{
					// Is it a folder?
					if ("folder".Equals(content["type"]))
					{
						// Is its name "Geowigo"?
						if ("Geowigo".Equals((string)content["name"], StringComparison.InvariantCultureIgnoreCase))
						{
							// Sync Step 3. Asks for the list of files in this folder.
							_liveClient.GetAsync((string)content["id"] + "/files", "geowigo");

							// Starts the timeout timer.
							StartTimeoutTimer(GetRequestTimeoutTimeSpan);

							// Nothing more to do.
							return;
						}
					}
				}

				// If we are here, it means that the Geowigo folder was not found.
				// The sync ends.
				EndSync();
				return;
			}
			else if ("geowigo".Equals(e.UserState))
			{
				// Sync Step 4: We are getting results for the Geowigo folder.
				// We need to enumerate through all files and download each GWC
				// file in the background.

				// Enumerates through all the file entries.
				List<SkyDriveFile> cartFiles = new List<SkyDriveFile>();
				List<object> data = (List<object>)e.Result["data"];
				foreach (IDictionary<string, object> content in data)
				{
					// Is it a cartridge file?
					string name = (string)content["name"];
					if ("file".Equals(content["type"]) && name.ToLower().EndsWith(".gwc"))
					{
						// Adds the file to the list.
						string id = (string)content["id"];
						lock (_syncRoot)
						{
							cartFiles.Add(new SkyDriveFile(id, name));
						}
					}
				}

				// Creates the list of files in the isostore that do not exist 
				// on SkyDrive anymore.
				List<string> isoStoreFiles;
				List<string> toRemoveFiles;
				using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
				{
					isoStoreFiles =
						isf
						.GetFileNames(GetIsoStorePath("*.gwc"))
						.Select(s => IsoStoreCartridgesPath + "/" + s)
						.ToList();

					toRemoveFiles =
						isoStoreFiles
						.Where(s => !cartFiles.Any(sd => sd.Name == System.IO.Path.GetFileName(s)))
						.ToList();
				}

				// Creates the list of cartridges that are on SkyDrive but
				// not in the isolated storage.
				List<SkyDriveFile> toDlFiles = cartFiles
					.Where(sd => !isoStoreFiles.Contains(GetIsoStorePath(sd.Name)))
					.ToList();

				// Bakes an event for when the sync will be over.
				lock (_syncRoot)
				{
					_syncEventArgs = new CartridgeProviderSyncEventArgs()
					{
						AddedFiles = toDlFiles
							.Select(sd => GetIsoStorePath(sd.Name))
							.ToList(),
						ToRemoveFiles = toRemoveFiles
					};
				}

				// Sends a progress event for removing the files marked
				// to be removed.
				if (toRemoveFiles.Count > 0)
				{
					RaiseSyncProgress(toRemoveFiles: toRemoveFiles);
				}

				// Starts downloading all new files, or terminate
				// the sync if no new file is to be downloaded.
				if (toDlFiles.Count > 0)
				{
					toDlFiles.ForEach(sd => BeginDownloadCartridge(sd));
				}
				else
				{
					EndSync();
				}
			}
		}
Пример #59
0
 void clientGetMe_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         dataFullName.Text = (string)e.Result["name"];
     }
 }
Пример #60
0
        private void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                base.HandleHistory();

                this.Root = this.targetFolder == null ? NewDownload.RootDirectoryLabel : this.targetFolder.Title;
                this.Data = new ObservableCollection<BaseFile>();
                List<object> data = (List<object>)e.Result["data"];
                foreach (IDictionary<string, object> content in data)
                {
                    string name = (string)content["name"];
                    string type = (string)content["type"];
                    var mediaType = this.MediaSupportService.GetMediaType(name);
                    switch (mediaType)
                    {
                        case MediaType.Unknown:
                            if (type == "folder" || type == "album")
                            {
                                this.Data.Add(new Folder()
                                {
                                    Title = name,
                                    FilesCount = (int)content["count"],
                                    URL = (string)content["link"],
                                    Id = (string)content["id"]
                                });
                            }
                            break;
                        case MediaType.Video:
                            this.Data.Add(new VideoFile()
                            {
                                Title = name,
                                URL = (string)content["source"],
                                Size = FileSizeConverter.Convert((int)content["size"])
                            });
                            break;
                        case MediaType.Audio:
                            this.Data.Add(new AudioFile()
                            {
                                Title = name,
                                URL = (string)content["source"],
                                Size = FileSizeConverter.Convert((int)content["size"])
                            });
                            break;
                        default:
                            break;
                    }
                }
                this.Data = new ObservableCollection<BaseFile>(this.Data.OrderBy(d => d, new FileTypeComparer()).ThenBy(d => d.Title));
                this.EmptyFolder = !this.Data.Any();
            }
            else
            {
                this.DialogViewService.MessageBoxOk(NewDownload.Error, NewDownload.BrowseFolderFailedLabel);
            }
            base.MessengerInstance.Send<ScreenLock, URLSelectorSkydrivePage>(ScreenLock.Release());
        }