Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public MainWindow(User user)
        {
            this.user = user;
            InitializeComponent();
            this.Height              = (SystemParameters.PrimaryScreenHeight);
            this.Width               = (SystemParameters.PrimaryScreenWidth);
            this.menu1.Width         = (SystemParameters.PrimaryScreenWidth);
            this.fileTreeMenu.Height = (SystemParameters.PrimaryScreenHeight) - 116; //82
            this.pathBox.Width       = (SystemParameters.PrimaryScreenWidth) - 198;
            this.scrollText.Width    = (SystemParameters.PrimaryScreenWidth) - 198;
            this.folderView.Width    = (SystemParameters.PrimaryScreenWidth) - 193;
            this.folderView.Height   = (SystemParameters.PrimaryScreenHeight) - 200;

//          Test Code to show that generatePath works
            CommonDescriptor cd1 = new CommonDescriptor("gpname", "filetype", "filePath", "fileID", "accountType", new DateTime(1), 1);
            CommonDescriptor cd2 = new CommonDescriptor("pname", "filetype", "filePath", "fileID", "accountType", new DateTime(1), 1);
            CommonDescriptor cd3 = new CommonDescriptor("name", "filetype", "filePath", "fileID", "accountType", new DateTime(1), 1);

            Models.SupportClasses.TreeNode grandparentNode = new Models.SupportClasses.TreeNode(null, cd1);
            Models.SupportClasses.TreeNode parentNode      = new Models.SupportClasses.TreeNode(grandparentNode, cd2);
            Models.SupportClasses.TreeNode node            = new Models.SupportClasses.TreeNode(parentNode, cd3);
            generatePath(node, " ");
//          End generatePath testcode

            windowsDownloadManager = new WindowsDownloadManager();
            windowsUploadManager   = new WindowsUploadManager();
            metaDataController     = new MetaDataController(metaDataStorageLocation);

            //mimicLogin();
            setButtonsClickable(false);
        }
Exemplo n.º 3
0
        public void hierarchyDelete(Models.SupportClasses.TreeNode root)
        {
            MenuItem rootToRemove = null;

            foreach (var item in fileTreeMenu.Items)
            {
                if (item.GetType() == typeof(MenuItem))
                {
                    MenuItem file = (MenuItem)item;
                    if (file.ID.Equals(root.getCommonDescriptor().FileID))
                    {
                        rootToRemove = file;
                    }
                }
            }
            if (rootToRemove != null)
            {
                //deleteMenuItems(rootToRemove);
                //roots = new List<Models.SupportClasses.TreeNode>();
                fileTreeMenu.Items.Remove(rootToRemove);
                for (int j = 0; j < roots.Count; j++)
                {
                    if (roots.ElementAt(j).ElementAt(0).getCommonDescriptor().FileID.Equals(rootToRemove.ID))
                    {
                        roots.RemoveAt(j);
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void populateTree(Guqu.Models.SupportClasses.TreeNode treeRoot, MenuItem xamlRoot)
 {
     xamlRoot = new MenuItem()
     {
         Title = treeRoot.getCommonDescriptor().FileName, ID = treeRoot.getCommonDescriptor().FileID
     };
     recursiveBuildTree(treeRoot, xamlRoot);
 }
Exemplo n.º 5
0
 private void generatePath(Models.SupportClasses.TreeNode currFolder, string path)
 {
     if (currFolder.getParent() != null)
     {
         pathBox.Text = currFolder.getCommonDescriptor().FileName + " > " + path;
         generatePath(currFolder.getParent(), currFolder.getCommonDescriptor().FileName + " > " + path);
     }
     else
     {
         pathBox.Text = currFolder.getCommonDescriptor().FileName + " > " + path;
     }
 }
Exemplo n.º 6
0
        public async void addHierarchy(ICloudCalls cloudCalls, string accountName, string rootID, string accountType)
        {
            bool complete = await cloudCalls.fetchAllMetaData(metaDataController, accountName);

            //Models.SupportClasses.TreeNode googleRootnode = metaDataController.getRoot("Google Drive", "googleRoot", "Google Drive");
            //Models.SupportClasses.TreeNode oneDriveRootnode = metaDataController.getRoot("One Drive", "driveRoot", "One Drive");
            if (complete)
            {
                Models.SupportClasses.TreeNode accountRootNode = metaDataController.getRoot(accountName, rootID, accountType);

                hierarchyAdd(accountRootNode);
            }
        }
Exemplo n.º 7
0
        private void hierarchyAdd(Models.SupportClasses.TreeNode newRoot)
        {
            MenuItem root = new MenuItem()
            {
                Title = newRoot.getCommonDescriptor().FileName, ID = newRoot.getCommonDescriptor().FileID
            };                                                                                                                            //label as the account name
            List <Models.SupportClasses.TreeNode> newList = new List <Models.SupportClasses.TreeNode>();

            newList.Add(newRoot);
            roots.Add(newList);
            root = populateMenuItem(root, newRoot, newList);
            fileTreeMenu.Items.Add(root);
        }
Exemplo n.º 8
0
 private void recursiveBuildTree(Guqu.Models.SupportClasses.TreeNode treeRoot, MenuItem xamlRoot)
 {
     foreach (Guqu.Models.SupportClasses.TreeNode child in treeRoot.getChildren())
     {
         MenuItem currNode = new MenuItem()
         {
             Title = treeRoot.getCommonDescriptor().FileName, ID = treeRoot.getCommonDescriptor().FileID
         };
         recursiveBuildTree(child, currNode);
         currNode.Items.Add(new MenuItem()
         {
             Title = child.getCommonDescriptor().FileName, ID = treeRoot.getCommonDescriptor().FileID
         });
         xamlRoot.Items.Add(currNode);
     }
 }
Exemplo n.º 9
0
 //call when a click is detected on the file hierarchy
 private void folderDisplay(Models.SupportClasses.TreeNode node, String fileID)
 {
     if (node.getCommonDescriptor() != null)
     {
         if (node.getCommonDescriptor().FileID.Equals(fileID))
         {
             //get list of children nodes convert to a list of common discriptors and populate listView
             LinkedList <Models.SupportClasses.TreeNode> children = node.getChildren();
             List <CommonDescriptor> disp = new List <CommonDescriptor>();
             selectedHierarchyFolder = node;
             foreach (var item in children)
             {
                 disp.Add(item.getCommonDescriptor());
             }
             populateListView(disp);
         }
     }
 }
Exemplo n.º 10
0
        private MenuItem populateMenuItem(MenuItem root, Models.SupportClasses.TreeNode node, List <Models.SupportClasses.TreeNode> folders)
        {
            MenuItem newFolder;

            foreach (var ele in node.getChildren())
            {
                if (ele.getCommonDescriptor().FileType.Equals("folder"))
                {
                    newFolder = new MenuItem()
                    {
                        Title = ele.getCommonDescriptor().FileName, ID = ele.getCommonDescriptor().FileID
                    };
                    folders.Add(ele);
                    newFolder.Click = new RoutedEventHandler(item_Click);
                    root.Items.Add(populateMenuItem(newFolder, ele, folders));
                }
                else
                {
                    //root.Items.Add(new MenuItem() { Title = ele.getCommonDescriptor().FileName });
                }
            }
            return(root);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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);
        }