private async void mimicLogin() { InitializeAPI temp = new InitializeAPI(); try { temp.initGoogleDriveAPI(); await CloudLogin.googleDriveLogin(); temp.initOneDriveAPI(); await CloudLogin.oneDriveLogin(user); GoogleDriveCalls gdc = new GoogleDriveCalls(); OneDriveCalls odc = new OneDriveCalls(); bool goog = await gdc.fetchAllMetaData(metaDataController, "Google Drive"); bool one = await odc.fetchAllMetaData(metaDataController, "One Drive"); } catch (Exception e) { } finally { Models.SupportClasses.TreeNode googleRootnode = metaDataController.getRoot("Google Drive", "googleRoot", "Google Drive"); Models.SupportClasses.TreeNode oneDriveRootnode = metaDataController.getRoot("One Drive", "driveRoot", "One Drive"); hierarchyAdd(googleRootnode); hierarchyAdd(oneDriveRootnode); } }
private void downloadButton_Click(object sender, RoutedEventArgs e) { //get selected items to download List <CommonDescriptor> filesToDownload = new List <CommonDescriptor>(); //get the controller ICloudCalls cloudCaller = null; //download foreach (dispFolder file in dF) { if (file.Checked) { filesToDownload.Add(file.CD); } } if (filesToDownload.Count == 0) { //no elements selected return; } if (filesToDownload.First().AccountType.Equals("Google Drive")) { cloudCaller = new GoogleDriveCalls(); } else { cloudCaller = new OneDriveCalls(); } foreach (CommonDescriptor curFile in filesToDownload) { cloudCaller.downloadFileAsync(curFile); } }
public void moveFileAsyncTest1() { CommonDescriptor cd = new CommonDescriptor(); cd.FileName = "Cheat Sheet Final"; cd.FileType = ".doc"; cd.FileID = "8FA41A1E5CF18E2B!1130"; CommonDescriptor folder = new CommonDescriptor(); folder.FileName = "Folder"; cd.FileType = "folder"; cd.FileID = "8FA41A1E5CF18E2B!696969"; var odc = new OneDriveCalls(); try { odc.moveFileAsync(cd, folder); } catch (Exception e) { Assert.Fail(); } }
private void copyButton_Click(object sender, RoutedEventArgs e) { ICloudCalls cloudCaller = null; if (dF.Count > 0) { List <dispFolder> itemsToCopy = new List <dispFolder>(); foreach (dispFolder file in dF) { if (file.Checked) { itemsToCopy.Add(file); } } if (itemsToCopy.Count == 0) { //no elements selected return; } if (itemsToCopy.First().CD.AccountType.Equals("Google Drive")) { cloudCaller = new GoogleDriveCalls(); } else if (itemsToCopy.First().CD.AccountType.Equals("One Drive")) { cloudCaller = new OneDriveCalls(); } else { //failure return; } List <Guqu.Models.SupportClasses.TreeNode> copy = new List <Models.SupportClasses.TreeNode>(); for (int i = 0; i < roots.Count; i++) { copy.Add(roots.ElementAt(i).ElementAt(0)); } Models.SupportClasses.TreeNode selected; moveView mv = new moveView(copy); mv.ShowDialog(); if (mv.getOK()) { selected = mv.getSelected(); foreach (dispFolder file in itemsToCopy) { cloudCaller.copyFile(file.CD, selected.getCommonDescriptor()); } } } }
private void shareButton_Click(object sender, RoutedEventArgs e) { if (emailListFormattedCorrectly(emailsToShareBox.Text)) { ICloudCalls cloudCaller = null; ArrayList shareEmails = parseEmailList(emailsToShareBox.Text); if (filesToShare.First().CD.AccountType == "Google Drive") { cloudCaller = new GoogleDriveCalls(); } else if (filesToShare.First().CD.AccountType == "One Drive") { //not implemented yet cloudCaller = new OneDriveCalls(); } else { throw new InvalidOperationException(); } foreach (String email in shareEmails) { foreach (dispFolder file in filesToShare) { if (read) { cloudCaller.shareFile(file.CD, "reader", email, optionalMessageBox.Text); } else if (write) { cloudCaller.shareFile(file.CD, "writer", email, optionalMessageBox.Text); } else if (comment) { cloudCaller.shareFile(file.CD, "commenter", email, optionalMessageBox.Text); } else { //didn't want to share... this.Close(); return; } } } } this.Close(); }
public void fetchAllMetaDataTest1() { MetaDataController con = new MetaDataController("L://"); string name = "onedrive"; var odc = new OneDriveCalls(); try { odc.fetchAllMetaData(con, name); } catch (Exception e) { Assert.Fail(); } }
public void deleteFileAsyncTest1() { CommonDescriptor cd = new CommonDescriptor(); cd.FileName = "Cheat Sheet Final"; cd.FileType = ".doc"; cd.FileID = "8FA41A1E5CF18E2B!696969"; var odc = new OneDriveCalls(); try { odc.deleteFileAsync(cd); } catch (Exception e) { Assert.Fail(); } }
private async void oneDriveClick(object sender, RoutedEventArgs e) { cloudId = 1; api.initOneDriveAPI(); //CloudLogin.oneDriveLogin(user); bool main = false;//check to see if there is a main open MainWindow mainWindow = null; foreach (var wnd in Application.Current.Windows) { if (wnd is MainWindow) { Console.WriteLine("Main or Cloud window open"); mainWindow = (MainWindow)wnd; main = true; } } //does a mainWindow exist? if (main == false) { //only if this was on new guqu account mainWindow = new MainWindow(user); mainWindow.Show(); } InitializeAPI temp = new InitializeAPI(); try { temp.initOneDriveAPI(); await CloudLogin.oneDriveLogin(user); } catch (Exception ex) { return; } OneDriveCalls odc = new OneDriveCalls(); mainWindow.addHierarchy(odc, "One Drive", "driveRoot", "One Drive"); mainWindow.setButtonsClickable(true); this.Close(); }
private void deleteButton_Click(object sender, RoutedEventArgs e) { ICloudCalls cloudCaller = null; if (dF.Count > 0) { List <dispFolder> itemsToRemove = new List <dispFolder>(); foreach (dispFolder file in dF) { if (file.Checked) { itemsToRemove.Add(file); } } if (itemsToRemove.Count == 0) { //no elements selected return; } if (itemsToRemove.First().CD.AccountType == "Google Drive") { cloudCaller = new GoogleDriveCalls(); } else if (itemsToRemove.First().CD.AccountType == "One Drive") { cloudCaller = new OneDriveCalls(); } else { //failure return; } bool res; foreach (dispFolder file in itemsToRemove) { //add delete call to actual web service dF.Remove(file); res = cloudCaller.deleteFile(file.CD); //if these delete went through, remove the object from our file hierarchy if (res) { metaDataController.deleteCloudObjet(file.CD); } } } else { Console.WriteLine("nothing in list"); } CommonDescriptor cd; Models.SupportClasses.TreeNode originalrootNode = selectedHierarchyFolder; while (originalrootNode.getParent() != null) { originalrootNode = originalrootNode.getParent(); } cd = originalrootNode.getCommonDescriptor(); cloudCaller.fetchAllMetaData(metaDataController, cd.FileName); Models.SupportClasses.TreeNode remadeRootNode = metaDataController.getRoot(cd.FileName, cd.FileID, cd.AccountType); hierarchyDelete(originalrootNode); hierarchyAdd(remadeRootNode); }
private void uploadButton_Click(object sender, RoutedEventArgs e) { //get the destination location if (selectedHierarchyFolder == null) { //can't upload without selecting DialogResult res = System.Windows.Forms.MessageBox.Show("Please select a folder to upload to."); return; } CommonDescriptor destinationLocation = selectedHierarchyFolder.getCommonDescriptor(); //determine what controller to use (google vs one drive) Models.SupportClasses.TreeNode rootNode = selectedHierarchyFolder; while (rootNode.getParent() != null) { rootNode = rootNode.getParent(); } CommonDescriptor root = rootNode.getCommonDescriptor(); string acctType = root.AccountType; ICloudCalls cloudCaller = null; //should be done with a level of obfuscation if (acctType.Equals("Google Drive")) { cloudCaller = new GoogleDriveCalls(); } else if (acctType.Equals("One Drive")) { cloudCaller = new OneDriveCalls(); } else { DialogResult res = System.Windows.Forms.MessageBox.Show("Cannot upload to this account for some reason."); return; //somehow nothing was set for the root node, this should be impossible. } //get the elements the user wants to upload List <UploadInfo> filesToUpload = windowsUploadManager.getUploadFiles(); //make the calls to upload List <string> uploadedFileIDs; uploadedFileIDs = cloudCaller.uploadFiles(filesToUpload, destinationLocation); //now that files are uploaded //download the metaData from these files //really bad, should have a more precise solution cloudCaller.fetchAllMetaData(metaDataController, root.FileName); //update the view //again a dumb solution, should be more precise Models.SupportClasses.TreeNode remadeRootNode = metaDataController.getRoot(root.FileName, root.FileID, root.AccountType); //attempt to 'refresh' the fileHierarchy view MenuItem temp = new MenuItem() { Title = root.FileName, ID = root.FileID }; //label as the account name hierarchyDelete(rootNode); hierarchyAdd(remadeRootNode); }