Exemple #1
0
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            //some metadata function call maybe not this
            MetaDataController mdc = new MetaDataController(currFolder.Text);

            this.Close();
        }
Exemple #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);
        }
        private void infoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem    item = (ToolStripItem)sender;
            ContextMenuStrip menu = (ContextMenuStrip)item.Owner;
            DataGridView     grid = (DataGridView)menu.SourceControl;
            object           sel  = grid.Rows[SelectedRow].HeaderCell.Value;

            if (sel == null)
            {
                return;
            }
            else
            {
                MetaDataController m1 = new MetaDataController();
                AddMediaMeta = m1.MetaManual(sel);
                QGrid.Rows.Clear();
                foreach (var asd in AddMediaMeta)
                {
                    QGrid.Rows.Add(asd.Key, asd.Value);
                }
                QueueLabel.Text = AddMediaMeta["Name"];
            }
            if (sel.GetType() == typeof(Song))
            {
                Song s = (Song)sel;
                QueueLabel.Text = s.GetMetadata().GetName();
                MetaDataController m1 = new MetaDataController();
                AddMediaMeta = m1.MetaManual(s.GetFileName(), "song");
                QGrid.Rows.Clear();
                foreach (var asd in AddMediaMeta)
                {
                    QGrid.Rows.Add(asd.Key, asd.Value);
                }
            }
        }
Exemple #4
0
        public void addMetaDataFolderTest()
        {
            string             root       = "L://TestingFolder";
            MetaDataController mc         = new MetaDataController(root);
            string             testString = mc.addMetaDataFolder("", "", "a*");

            Assert.AreEqual("a_", testString);
        }
Exemple #5
0
        private async Task fetchAllMDFiles(MetaDataController controller, string relativeRequestPath, string parentID)
        {
            var _oneDriveClient = InitializeAPI.oneDriveClient;

            //will hold all of the children from this directory (parentID)
            List<Item> allChildren = new List<Item>();

            //will hold the current children gathered from an iteration, oneDrive returns 200 children by default
            IChildrenCollectionPage curChildren;
            curChildren = await _oneDriveClient.Drive.Items[parentID].Children.Request().GetAsync();


            allChildren.AddRange(curChildren);
            //NextPageRequest is not null iff there are more children to fetch
            while (curChildren.NextPageRequest != null)
            {
                //Get the nextPageRequest, will be null if there isn't anymore.
                string nextPageLinkString = curChildren.NextPageRequest.GetHttpRequestMessage().RequestUri.ToString();
                curChildren.InitializeNextPageRequest(_oneDriveClient, nextPageLinkString);
                curChildren = await curChildren.NextPageRequest.GetAsync();
                allChildren.AddRange(curChildren);
            }

            //Have all of the children, now iterate through them
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            CommonDescriptor curCD;
            string curFileSerialized, cleansedName;

            foreach (var child in allChildren)
            {
                
                curFileSerialized = serializer.Serialize(child);
                if(child.File == null) //folder
                {
                    //For each folder add the metaDataFolder, the CD, and then recurse.
                    cleansedName = controller.addMetaDataFolder(curFileSerialized, relativeRequestPath, child.Name);
                    curCD = oneDriveCommParser.createCommonDescriptor(relativeRequestPath, curFileSerialized);
                    controller.addCommonDescriptorFile(curCD);
                    await fetchAllMDFiles(controller, relativeRequestPath + "\\" + cleansedName, child.Id);
                }
                else  //file
                {
                    //For each file add the metadatafile, and the CD.
                    cleansedName = controller.addMetaDataFile(curFileSerialized, relativeRequestPath, child.Name);
                    curCD = oneDriveCommParser.createCommonDescriptor(relativeRequestPath, curFileSerialized);
                    controller.addCommonDescriptorFile(curCD);

                    var s = child.File.MimeType;

                    //var a = child.File.MimeType;

                }

            }

        }
Exemple #6
0
 public void getMetaDataFileTest()
 {
     try
     {
         MetaDataController mc = new MetaDataController("\\");
         mc.getMetaDataFile("\\");
     }
     catch (ArgumentException)
     {
         Assert.IsTrue(true);
     }
 }
Exemple #7
0
 public void getRootTest()
 {
     try
     {
         string             root = "L://TestingFolder";
         MetaDataController mc   = new MetaDataController(root);
         mc.getRoot("OneDrive", root, "OneDrive");
     }
     catch (Exception)
     {
     }
 }
        private void radioVideo_CheckedChanged(object sender, EventArgs e)
        {
            MediaType          = "video";
            FileNameLabel.Text = openFileDialog1.FileName;
            string             path = $@"{openFileDialog1.FileName}";
            MetaDataController m1   = new MetaDataController();

            AddMediaMeta = m1.MetaManual(path, MediaType);
            MetaGrid.Rows.Clear();
            foreach (var item in AddMediaMeta)
            {
                MetaGrid.Rows.Add(item.Key, item.Value);
            }
        }
Exemple #9
0
 public async Task<bool> fetchAllMetaData(MetaDataController controller, string accountName)
 {
     string rootId = "root";
     try {
         await fetchAllMDFiles(controller, accountName, rootId);   
         return true;
     }
     catch(Exception e)
     {
         //TODO: what do we do with errors?
         Console.WriteLine(e.StackTrace);
     }
     return false;
 }
Exemple #10
0
 public void deleteCloudObjetTest()
 {
     try
     {
         string             root = "L://TestingFolder";
         CommonDescriptor   cd   = new CommonDescriptor("name", "ftype", "fpath", "fid", "acct", new DateTime(), 10);
         MetaDataController mc   = new MetaDataController(root);
         mc.deleteCloudObjet(cd);
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
Exemple #11
0
        // probably not great for code coverage
        public void removeFileTest()
        {
            string             root = "L://TestingFolder";
            MetaDataController mc   = new MetaDataController(root);

            try
            {
                mc.removeFile("", "");
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Exemple #12
0
        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();
            }
        }
Exemple #13
0
        public void MetaDataControllerTest()
        {
            string root = "L://TestingFolder";

            try
            {
                MetaDataController controller = new MetaDataController(root);
                if (controller.GetType() == null)
                {
                    Assert.Fail();
                }
            }
            catch (Exception e)
            {
                Assert.Fail();
            }
        }
Exemple #14
0
        //TODO: have controller be global, or static
        private void fetchAllMDFiles(MetaDataController controller, string relativeRequestPath, string parentID)
        {
            string googleFolderName = "application/vnd.google-apps.folder";
            int    numItemsPerFetch = 1000;

            //over arching list of files in this directory
            IList <Google.Apis.Drive.v3.Data.File> allFiles = new List <Google.Apis.Drive.v3.Data.File>();

            //Each iteration fill the files list.
            IList <Google.Apis.Drive.v3.Data.File> iterationFiles;

            //Execution for each iteration
            FileList exec;

            var googleDriveService = InitializeAPI.googleDriveService;

            FilesResource.ListRequest listRequest = googleDriveService.Files.List();

            string nextPageToken = null;

            Boolean moreFilesExist = true;

            //get all files in this directory
            while (moreFilesExist)
            {
                listRequest          = googleDriveService.Files.List();
                listRequest.Fields   = "nextPageToken, files";
                listRequest.PageSize = numItemsPerFetch; //get 20 things each pass
                listRequest.Q        = "'" + parentID + "' in parents";
                //get the next 10 possible folders
                if (nextPageToken != null)
                {
                    listRequest.PageToken = nextPageToken;
                }
                exec           = listRequest.Execute();
                nextPageToken  = exec.NextPageToken;
                iterationFiles = exec.Files;


                foreach (var cur in iterationFiles)
                {
                    if (cur.Trashed != true)
                    {
                        //not trash
                        allFiles.Add(cur);
                    }
                }
                if (iterationFiles.Count != numItemsPerFetch)
                {
                    //we did not have max items, no more items to fetch
                    moreFilesExist = false;
                }
            }


            //now we have all files/folders in the current directory

            Google.Apis.Drive.v3.Data.File curFile;

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string           curFileSerialized;
            string           cleansedName;
            CommonDescriptor curCD;

            while (allFiles.Count != 0)               //while there are elements
            {
                curFile           = allFiles.First(); //get first file
                curFileSerialized = serializer.Serialize(curFile);
                //pathForFile = controller.getAbsoluteFilePathForAddingMDFile(relativeRequestPath);


                if (curFile.MimeType.Equals(googleFolderName)) //folder
                {
                    //For each folder add the metaDataFolder, the CD, and then recurse.
                    cleansedName = controller.addMetaDataFolder(curFileSerialized, relativeRequestPath, curFile.Name);
                    curCD        = googleCommParser.createCommonDescriptor(relativeRequestPath, curFileSerialized);
                    controller.addCommonDescriptorFile(curCD);
                    fetchAllMDFiles(controller, relativeRequestPath + "\\" + cleansedName, curFile.Id);
                }
                else  //file
                {
                    //For each file add the metadatafile, and the CD.

                    //cleansedName is the 'clean' name of the curFile.Name, don't need to use it cause this terminates.
                    cleansedName = controller.addMetaDataFile(curFileSerialized, relativeRequestPath, curFile.Name);
                    curCD        = googleCommParser.createCommonDescriptor(relativeRequestPath, curFileSerialized);
                    controller.addCommonDescriptorFile(curCD);
                }
                allFiles.RemoveAt(0); //remove this element
            }
        }
Exemple #15
0
 public async Task <bool> fetchAllMetaData(MetaDataController controller, string accountName)
 {
     fetchAllMDFiles(controller, accountName, "root");
     return(true);
 }