Exemplo n.º 1
0
        /// <summary>
        /// Delta 每页最多1000
        /// </summary>
        public List <DriveItem> DeltaTest(string driveId)
        {
            //var deltaData = graphServiceClient.Sites["xluov.sharepoint.com,2a3dda8f-3fc1-4d2d-a7fc-a10ea44aa310,144a5a37-0b91-4754-8459-f2b4a01c93d4"].Drive.Root.Delta().Request().Select("sharepointids,id,lastModifiedDateTime,name,webUrl,folder,createdDateTime").Top(1000).GetAsync().Result;
            var deltaData = graphServiceClient.Drives[driveId].Root.Delta().Request().Select("sharepointids,id,lastModifiedDateTime,name,webUrl,folder,createdDateTime").Top(1000).GetAsync().Result;

            //var deltaData = graphServiceClient.Sites["m365x157144-my.sharepoint.com,47b37a14-09dd-407f-9509-6fa9b4ad20d4,08d6db6f-5165-4fd4-ad22-7a61201f766a"].Drive.Root.Delta().Request().GetAsync().Result;
            return(GraphCommonUtility.GetRequestAllOfDatas <DriveItem>(deltaData));
        }
Exemplo n.º 2
0
        public List <DriveItem> GetAllItemsUnderFolder(string driveId, string folderId)
        {
            List <DriveItem> allOfFolders = new List <DriveItem>();
            var currentPage = graphServiceClient.Drives[driveId].Items[folderId].Children.Request().Select("sharepointids,id,lastModifiedDateTime,name,webUrl,folder,createdDateTime").Top(int.MaxValue).GetAsync().Result;
            var subItems    = GraphCommonUtility.GetRequestAllOfDatas <DriveItem>(currentPage).ToList();

            foreach (var child in subItems)
            {
                if (child.Folder != null && child.Folder.ChildCount > 0)
                {
                    allOfFolders.AddRange(GetAllItemsUnderFolder(driveId, child.Id));
                }
            }
            allOfFolders.AddRange(subItems);
            return(allOfFolders);
        }
Exemplo n.º 3
0
        public IEnumerable <DriveItem> GetDriveFiles(string siteId, string listId, string parentFolderUrl)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            IDriveItemChildrenCollectionPage currentPage = null;
            const string SelectValue = "SharePointIds,File";

            if (string.IsNullOrEmpty(parentFolderUrl))
            {
                currentPage = graphServiceClient.Sites[siteId].Lists[listId].Drive.Root.Children.Request().Select(SelectValue).GetAsync().Result;
            }
            else
            {
                currentPage = graphServiceClient.Sites[siteId].Lists[listId].Drive.Root.ItemWithPath(parentFolderUrl).Children.Request().Select(SelectValue).GetAsync().Result;
            }

            var items = GraphCommonUtility.GetRequestAllOfDatas <DriveItem>(currentPage).Where(item => item.File != null);

            watch.Stop();
            Console.WriteLine($"GetDriveFiles:{watch.Elapsed.TotalSeconds}");
            return(items);
        }