Exemplo n.º 1
0
 private void Folder_Delete_Click(object sender, EventArgs e)
 {
     if (client == null)
     {
         MessageBox.Show("Veuillez vous connecter !");
     }
     else
     {
         if (MessageBox.Show("Voulez-vous vraiment effacer tous les fichiers ?", "Attention !", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
         {
             if (wait_async == false)
             {
                 progress_multiple = true;
                 Progress_Init();
                 wait_async = true;
                 int loop_count = 0;
                 client.DeleteCompleted += new EventHandler <LiveOperationCompletedEventArgs>(Folder_Delete_Completed);
                 foreach (object entry in list_files_skydrive)
                 {
                     client.DeleteAsync(list_files_skydrive.ElementAt(loop_count).Id.ToString(), loop_count);
                     loop_count = loop_count + 1;
                 }
             }
         }
     }
     list_select_id   = null;
     list_select_name = null;
     ListBox_SkyContent.SelectedItem = null;
 }
        public override async Task DeleteAsync(IEntryModel entryModel, CancellationToken ct)
        {
            await _profile.checkLoginAsync();

            LiveConnectClient   liveClient = new LiveConnectClient(_profile.Session);
            LiveOperationResult result     = await liveClient.DeleteAsync((entryModel as SkyDriveItemModel).UniqueId, ct);
        }
Exemplo n.º 3
0
        public async Task DeleteFileFromTrackTimerFolder(string filePath)
        {
            LiveConnectSessionStatus connectStatus;

            if (client != null || (connectStatus = await Connect()) == LiveConnectSessionStatus.Connected)
            {
                await client.DeleteAsync(filePath);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deletes all data and folder from OneDrive cloud
        /// </summary>
        /// <param name="folderId">id of BBLyrics folder</param>
        /// <returns></returns>
        public static async Task DeleteFolderAsync(string folderId)
        {
            if (_client != null)
            {
                LiveOperationResult operationResult = await _client.DeleteAsync(folderId);

                OneDriveManager._folderId = null;
            }
        }
Exemplo n.º 5
0
        private void DeleteSync()
        {
            foreach (var file in _filesForDelete)
            {
                _deleteCounter++;
                _client.DeleteAsync(file);
            }

            _deleteCounter++;
            ClientDeleteCompleted(null, null);
        }
 public void TestDeleteNullPath()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.DeleteAsync(null);
         Assert.Fail("Expected ArguementNullException to be thrown.");
     }
     catch (ArgumentNullException)
     {
     }
 }
        public void TestDeleteNullPath()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.DeleteAsync(null);
                Assert.Fail("Expected ArguementNullException to be thrown.");
            }
            catch (ArgumentNullException)
            {
            }
        }
        public void TestDeleteEmptyStringPath()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.DeleteAsync(string.Empty);
                Assert.Fail("Expected ArguementException to be thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
 /// <summary>
 /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#deleting_folders
 /// The wl.skydrive_update scope is required.
 /// </summary>
 public void DeleteFileOrFolder()
 {
     if (session == null)
     {
         Debug.WriteLine("You must sign in first.");
     }
     else
     {
         LiveConnectClient client = new LiveConnectClient(session);
         client.DeleteCompleted +=
             new EventHandler <LiveOperationCompletedEventArgs>(DeleteFileOrFolder_Completed);
         client.DeleteAsync("folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!147");
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Download a file from onedrive
        /// </summary>
        /// <returns></returns>
        public static async Task <int> DeleteAsync(string Foldername, string Filename)
        {
            try
            {
                string fileID = string.Empty;

                //  get folder ID
                string folderID = await GetFolderIDAsync(Foldername, false);

                if (string.IsNullOrEmpty(folderID))
                {
                    return(0); // doesnt exists
                }

                //  get list of files in this folder
                LiveOperationResult loResults = await liveClient.GetAsync(folderID + "/files");

                List <object> folder = loResults.Result["data"] as List <object>;

                //  search for our file
                foreach (object fileDetails in folder)
                {
                    IDictionary <string, object> file = fileDetails as IDictionary <string, object>;
                    if (string.Compare(file["name"].ToString(), Filename, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        //  found our file
                        fileID = file["id"].ToString();
                        break;
                    }
                }

                if (string.IsNullOrEmpty(fileID))
                {
                    //  file doesnt exists
                    return(0);
                }

                //  download file from OneDrive
                await liveClient.DeleteAsync(fileID);

                return(1);
            }
            catch
            {
            }
            return(0);
        }
Exemplo n.º 11
0
        internal void DeleteWalletCommand()
        {
            var clientFolder = new LiveConnectClient(App.Session);

            clientFolder.DeleteCompleted += (object sender, LiveOperationCompletedEventArgs e) =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.Message, "Delete Wallet Failed", MessageBoxButton.OK);
                }

                if (OnWalletDeleted != null)
                {
                    OnWalletDeleted(this, null);
                }
            };
            clientFolder.DeleteAsync(App.MyWalletFile.FileId);
        }
Exemplo n.º 12
0
        /// <summary>
        /// ContextMenu delete button tergar MenuDelte_Click and delete the picture from sky drive
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MenuDelte_Click(object sender, RoutedEventArgs e)
        {
            var           Menu         = sender as MenuItem;
            SkydrivePhoto selectedFile = Menu.DataContext as SkydrivePhoto;

            string           msgDelPic      = SkyPhoto.Resources.Resources.msgDelPic;
            string           msgDelPicTitel = SkyPhoto.Resources.Resources.msgDelPicTitle;
            MessageBoxResult m = MessageBox.Show(msgDelPic + selectedFile.Title + "?", msgDelPicTitel, MessageBoxButton.OKCancel);

            if (m == MessageBoxResult.OK)
            {
                LiveConnectClient   client = new LiveConnectClient(App.Session);
                LiveOperationResult result = await client.DeleteAsync(selectedFile.ID);

                DeleteFile_Completed(selectedFile, result);
            }
            else
            {
                return;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// ContextMenu delete button tergar MenuDelte_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuDelte_Click(object sender, RoutedEventArgs e)
        {
            var           Menu             = sender as MenuItem;
            SkydriveAlbum selectedAlbum    = Menu.DataContext as SkydriveAlbum;
            string        msgDel           = SkyPhoto.Resources.Resources.msgDelAlbum;
            string        msgDelAlbumTitel = SkyPhoto.Resources.Resources.msgDelAlbumTitel;

            MessageBoxResult m = MessageBox.Show(msgDel + selectedAlbum.Title + "?", msgDelAlbumTitel, MessageBoxButton.OKCancel);

            if (m == MessageBoxResult.OK)
            {
                LiveConnectClient client = new LiveConnectClient(App.Session);
                client.DeleteCompleted +=
                    new EventHandler <LiveOperationCompletedEventArgs>(DeleteFolder_Completed);
                client.DeleteAsync(selectedAlbum.ID, selectedAlbum);
            }
            else
            {
                return;
            }
        }
 public void TestDeleteEmptyStringPath()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.DeleteAsync(string.Empty);
         Assert.Fail("Expected ArguementException to be thrown.");
     }
     catch (ArgumentException)
     {
     }
 }
Exemplo n.º 15
0
        //DB ENTRIES FÜR DIE FOLDER NOCH MACHEN !!!!!!!!!!!!!
        //public async Task<bool> UploadSynchronizationAsync(List<Interfaces.FileInformation> fileInfo, object DriveServiceClient)
        //{
        //    try
        //    {
        //        Interfaces.FileInformation[] fileArr = fileInfo.ToArray();
        //        LiveConnectClient client = DriveServiceClient as LiveConnectClient;

        //        foreach (var item in fileArr)
        //        {
        //            if (!item.isFile)
        //            {
        //                string cloudPath = item.Path.Substring(CloudManagerUI.Properties.Settings.Default.MainFolderLocation.Length + 1, item.Path.Length - CloudManagerUI.Properties.Settings.Default.MainFolderLocation.Length + 1);
        //                string[] pathFragments = cloudPath.Split('/');
        //                string pathFragment = CloudManagerUI.Properties.Resources.OneDriveRoot;
        //                int i = 0;


        //                switch (item.Mode) //DB ENTRIES NOCH MACHEN FÜR DIE FOLDER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        //                {
        //                    case "cr":
        //                        foreach (var fragment in pathFragments)
        //                        {
        //                            if (i == 0)
        //                            {
        //                                i++;
        //                                await CreateDirectoryAsync(fragment, pathFragment, client);
        //                                pathFragment = String.Empty;
        //                            }
        //                            else
        //                            {
        //                                pathFragment += fragment;
        //                                await CreateDirectoryAsync(fragment, pathFragment, client);
        //                                pathFragment += "/";
        //                            }

        //                        }

        //                        break;

        //                    case "ch":
        //                        foreach (var fragment in pathFragments)
        //                        {
        //                            if (i == 0)
        //                            {
        //                                i++;
        //                                await CreateDirectoryAsync(fragment, pathFragment, client);
        //                                pathFragment = String.Empty;
        //                            }
        //                            else
        //                            {
        //                                pathFragment += fragment;
        //                                await CreateDirectoryAsync(fragment, pathFragment, client);
        //                                pathFragment += "/";
        //                            }

        //                        }
        //                        break;

        //                    case "re":
        //                        foreach (var fragment in pathFragments)
        //                        {
        //                            if (i == 0)
        //                            {
        //                                i++;
        //                                await CreateDirectoryAsync(fragment, pathFragment, client);
        //                                pathFragment = String.Empty;
        //                            }
        //                            else
        //                            {
        //                                pathFragment += fragment;
        //                                await CreateDirectoryAsync(fragment, pathFragment, client);
        //                                pathFragment += "/";
        //                            }

        //                        }
        //                        break;

        //                    case "de": await client.DeleteAsync(item.FileID);
        //                        break;
        //                }
        //            }


        //        }


        //        foreach (var item in fileArr)
        //        {
        //            if (item.isFile)
        //            {
        //                string cloudPath = item.Path.Substring(CloudManagerUI.Properties.Settings.Default.MainFolderLocation.Length + 1, item.Path.Length - CloudManagerUI.Properties.Settings.Default.MainFolderLocation.Length + 1);
        //                string id = await GetSkyDriveFolderID(cloudPath, client);
        //                bool root = false;
        //                if (!cloudPath.Contains('/'))
        //                {
        //                    root = true;
        //                }

        //                switch (item.Mode)
        //                {

        //                    case "ch":

        //                        using (FileStream stream = new FileStream(item.Path + "\\" + item.FileName, FileMode.Open))
        //                        {
        //                            if (stream != null)
        //                            {
        //                                await client.UploadAsync(id, item.FileName, stream, OverwriteOption.Overwrite);
        //                            }
        //                        }

        //                        this.dbEntry.execEntry(id, "OneDrive", item.FileName, item.Path + "\\" + item.FileName, item.LastUpdated, false, false, root, cloudPath);



        //                        break;

        //                    case "cr":

        //                        using (FileStream stream = new FileStream(item.Path + "\\" + item.FileName, FileMode.Open))
        //                        {
        //                            if (stream != null)
        //                            {
        //                                await client.UploadAsync(id, item.FileName, stream, OverwriteOption.Overwrite);
        //                            }
        //                        }

        //                        break;

        //                    case "de":

        //                        await client.DeleteAsync(id);
        //                        this.dbEntry.execEntry(id, "OneDrive", item.FileName, item.Path, item.LastUpdated, true, false, root, cloudPath);

        //                        break;

        //                    case "re":

        //                        using (FileStream stream = new FileStream(item.Path + "\\" + item.FileName, FileMode.Open))
        //                        {
        //                            if (stream != null)
        //                            {
        //                                await client.UploadAsync(id, item.FileName, stream, OverwriteOption.Overwrite);
        //                            }
        //                        }

        //                        this.dbEntry.execEntry(id, "OneDrive", item.FileName, item.Path + "\\" + item.FileName, item.LastUpdated, false, false, root, cloudPath);
        //                        break;
        //                }
        //            }
        //        }


        //    }
        //    catch (Exception) { }

        //    return false;
        //}

        public async Task <bool> UploadSynchronizationAsync(List <Interfaces.FileInformation> fileInfo, object DriveServiceClient)
        {
            try
            {
                Interfaces.FileInformation[] fileArr = fileInfo.ToArray();
                LiveConnectClient            client  = DriveServiceClient as LiveConnectClient;

                foreach (var item in fileArr)
                {
                    if (!item.isFile)
                    {
                        string   cloudPath     = item.Path.Substring(MainFolder.MainFolderPath.Length + 1, item.Path.Length - MainFolder.MainFolderPath.Length + 1);
                        string[] pathFragments = cloudPath.Split('/');
                        string   pathFragment  = CloudManagerUI.Properties.Resources.OneDriveRoot;
                        int      i             = 0;


                        switch (item.Mode) //DB ENTRIES NOCH MACHEN FÜR DIE FOLDER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                        {
                        case "cr":
                            foreach (var fragment in pathFragments)
                            {
                                if (i == 0)
                                {
                                    i++;
                                    await CreateDirectoryAsync(fragment, pathFragment, client);

                                    pathFragment = String.Empty;
                                }
                                else
                                {
                                    pathFragment += fragment;
                                    await CreateDirectoryAsync(fragment, pathFragment, client);

                                    pathFragment += "/";
                                }
                            }

                            break;

                        case "ch":
                            foreach (var fragment in pathFragments)
                            {
                                if (i == 0)
                                {
                                    i++;
                                    await CreateDirectoryAsync(fragment, pathFragment, client);

                                    pathFragment = String.Empty;
                                }
                                else
                                {
                                    pathFragment += fragment;
                                    await CreateDirectoryAsync(fragment, pathFragment, client);

                                    pathFragment += "/";
                                }
                            }
                            break;

                        case "re":
                            foreach (var fragment in pathFragments)
                            {
                                if (i == 0)
                                {
                                    i++;
                                    await CreateDirectoryAsync(fragment, pathFragment, client);

                                    pathFragment = String.Empty;
                                }
                                else
                                {
                                    pathFragment += fragment;
                                    await CreateDirectoryAsync(fragment, pathFragment, client);

                                    pathFragment += "/";
                                }
                            }
                            break;

                        case "de": await client.DeleteAsync(item.FileID);

                            break;
                        }
                    }
                }


                foreach (var item in fileArr)
                {
                    DirectoryInfo di = new DirectoryInfo(item.Path);
                    DateTime      dt = di.LastWriteTime;


                    if (item.isFile)
                    {
                        string cloudPath = item.Path.Substring(MainFolder.MainFolderPath.Length + 1, item.Path.Length - MainFolder.MainFolderPath.Length + 1);
                        string id        = await GetSkyDriveFolderID(cloudPath, client);

                        bool root = false;
                        if (!cloudPath.Contains('/'))
                        {
                            root = true;
                        }

                        switch (item.Mode)
                        {
                        case "ch":

                            using (FileStream stream = new FileStream(item.Path + "\\" + item.FileName, FileMode.Open))
                            {
                                if (stream != null)
                                {
                                    await client.UploadAsync(id, item.FileName, stream, OverwriteOption.Overwrite);
                                }
                            }

                            this.dbEntry.execEntry(id, "OneDrive", item.FileName, item.Path + "\\" + item.FileName, dt, false, false, root, cloudPath);



                            break;

                        case "cr":

                            using (FileStream stream = new FileStream(item.Path + "\\" + item.FileName, FileMode.Open))
                            {
                                if (stream != null)
                                {
                                    await client.UploadAsync(id, item.FileName, stream, OverwriteOption.Overwrite);
                                }
                            }

                            break;

                        case "de":

                            await client.DeleteAsync(id);

                            this.dbEntry.execEntry(id, "OneDrive", item.FileName, item.Path, dt, true, false, root, cloudPath);

                            break;

                        case "re":

                            using (FileStream stream = new FileStream(item.Path + "\\" + item.FileName, FileMode.Open))
                            {
                                if (stream != null)
                                {
                                    await client.UploadAsync(id, item.FileName, stream, OverwriteOption.Overwrite);
                                }
                            }

                            this.dbEntry.execEntry(id, "OneDrive", item.FileName, item.Path + "\\" + item.FileName, dt, false, false, root, cloudPath);
                            break;
                        }
                    }
                }
            }
            catch (Exception) { }

            return(false);
        }
Exemplo n.º 16
0
 public async Task DeleteSkyDriveItemAsync(String skyDriveItemId)
 {
     // requires wl.skydrive_update scope
     var client = new LiveConnectClient(_session);
     await client.DeleteAsync(skyDriveItemId);
 }
Exemplo n.º 17
0
 private static void DeleteFileHelper(object sender, LiveOperationCompletedEventArgs e)
 {
     try
     {
         JavaScriptSerializer ser = new JavaScriptSerializer();
         Files.RootObject data = ser.Deserialize<Files.RootObject>(e.RawResult);
         string guidToDelete = (string)guidToDownloadQueue.Dequeue();
         foreach (Files.Datum listItem in data.data)
         {
             if (listItem.name == guidToDelete)
             {
                 LiveConnectClient client = new LiveConnectClient(Properties.session);
                 client.DeleteCompleted += UltiDrive.SkyDrive.Utilities.ConnectClient_DeleteCompleted;
                 client.DeleteAsync(listItem.id);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 18
0
        private async void RunButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Validate parameters
                string path        = pathTextBox.Text;
                string destination = destinationTextBox.Text;
                string requestBody = requestBodyTextBox.Text;
                var    scope       = (authScopesComboBox.SelectedValue as ComboBoxItem).Content as string;
                var    method      = (methodsComboBox.SelectedValue as ComboBoxItem).Content as string;

                // acquire auth permissions
                var authClient = new LiveAuthClient();
                var authResult = await authClient.LoginAsync(new string[] { scope });

                if (authResult.Session == null)
                {
                    throw new InvalidOperationException("You need to login and give permission to the app.");
                }

                var liveConnectClient = new LiveConnectClient(authResult.Session);
                LiveOperationResult operationResult = null;
                switch (method)
                {
                case "GET":
                    operationResult = await liveConnectClient.GetAsync(path);

                    break;

                case "POST":
                    operationResult = await liveConnectClient.PostAsync(path, requestBody);

                    break;

                case "PUT":
                    operationResult = await liveConnectClient.PutAsync(path, requestBody);

                    break;

                case "DELETE":
                    operationResult = await liveConnectClient.DeleteAsync(path);

                    break;

                case "COPY":
                    operationResult = await liveConnectClient.CopyAsync(path, destination);

                    break;

                case "MOVE":
                    operationResult = await liveConnectClient.MoveAsync(path, destination);

                    break;
                }

                if (operationResult != null)
                {
                    Log("Operation succeeded: \r\n" + operationResult.RawResult);
                }
            }
            catch (Exception ex)
            {
                Log("Got error: " + ex.Message);
            }
        }
Exemplo n.º 19
0
 public async Task DeleteCalendarEventAsync(String eventId)
 {
     // requires wl.calendars_update
     var client = new LiveConnectClient(_session);
     await client.DeleteAsync(eventId);
 }