Esempio n. 1
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;

                }

            }

        }
Esempio n. 2
0
        public void createCommonDescriptorTest()
        {
            OneDriveCommunicationParser odcp = new OneDriveCommunicationParser();
            string json    = "\"FileName\":\"Delt Calendar 2015\",\"FileType\":\"application/vnd.google-apps.spreadsheet\",\"FilePath\":\"GoogleDrive\\Delta Tau Delta - Beta Gamma\\The Delt Library\",\"FileID\":\"1Sjaiv_xT_wvuoSvjy7lQeU09QY6kQ6DLuSRciYvx9ys\",\"LastModified\":\"Date(1449039649000)\",\"FileSize\":0";
            string relPath = "OneDrive";

            try {
                var cd = odcp.createCommonDescriptor(relPath, json);
            }
            catch (Exception e)
            {
            }
        }