예제 #1
0
        public void GetFolderByPath()
        {
            var folderPath = "/Document Library01/TestFolder";
            var listItems  = _sp.SpList.GetListItems("Document Library01", CamlHelper.CamlQueryBuilder(folderPath, DocumentType.File));

            foreach (ListItem listItem in listItems)
            {
                Debug.WriteLine("Id: {0} Title: {1}, FileRef: {2}, FolderCount: {3}, ItemCount: {4}", listItem.Id, listItem["Title"], listItem["FileRef"], listItem["FolderChildCount"], listItem["ItemChildCount"]);
            }
        }
예제 #2
0
        private List <Ent::Folder> CommitFolders(Ent::Site site, Ent::DocumentLibrary documentLibrary, string folderPath, Ent::Folder folder)
        {
            var commitedFolders = new List <Ent::Folder>();

            try
            {
                var folderListItems = _sp.SpList.GetListItems(documentLibrary.Title, CamlHelper.CamlQueryBuilder(folderPath, DocumentType.Folder));
                if (folderListItems != null)
                {
                    foreach (ListItem listItem in folderListItems)
                    {
                        var folderItem = new Ent::Folder()
                        {
                            SiteID            = site.ID,
                            DocumentLibraryID = documentLibrary.ID,
                            ParentFolderID    = folder?.ID ?? 0,
                            RemoteID          = listItem.Id,
                            FileLeafRef       = SpTypeHelper.GetStringValue(listItem["FileLeafRef"]),
                            FileRef           = SpTypeHelper.GetStringValue(listItem["FileRef"]),
                            Title             = SpTypeHelper.GetStringValue(listItem["Title"]),
                            Created           = SpTypeHelper.GetDateTimeValue(listItem["Created"]),
                            Author            = SpTypeHelper.GetFieldUserValue(listItem["Author"]),
                            Modified          = SpTypeHelper.GetDateTimeValue(listItem["Modified"]),
                            Editor            = SpTypeHelper.GetFieldUserValue(listItem["Editor"]),
                            CopySource        = String.Empty,
                            ItemChildCount    = SpTypeHelper.GetIntValue(listItem["ItemChildCount"]),
                            FolderChildCount  = SpTypeHelper.GetIntValue(listItem["FolderChildCount"])
                        };
                        _unitOfWork.FolderRepository.Add(folderItem);
                        commitedFolders.Add(folderItem);
                    }
                    _unitOfWork.Commit();
                }
            }
            catch
            {
                Thread.Sleep(new TimeSpan(0, 0, 1, 0));
                Initialize();
                commitedFolders = CommitFolders(site, documentLibrary, folderPath, folder);
            }
            return(commitedFolders);
        }
예제 #3
0
 private void CommitFiles(Ent::Site site, Ent::DocumentLibrary documentLibrary, string folderPath, Ent::Folder folder)
 {
     try
     {
         var fileListItems = _sp.SpList.GetListItems(documentLibrary.Title, CamlHelper.CamlQueryBuilder(folderPath, DocumentType.File));
         if (fileListItems != null)
         {
             foreach (ListItem listItem in fileListItems)
             {
                 var file = new Ent::File()
                 {
                     SiteID            = site.ID,
                     DocumentLibraryID = documentLibrary.ID,
                     FolderID          = folder?.ID ?? 0,
                     RemoteID          = listItem.Id,
                     FileLeafRef       = SpTypeHelper.GetStringValue(listItem["FileLeafRef"]),
                     FileRef           = SpTypeHelper.GetStringValue(listItem["FileRef"]),
                     FileDirRef        = SpTypeHelper.GetStringValue(listItem["FileDirRef"]),
                     Title             = SpTypeHelper.GetStringValue(listItem["Title"]),
                     Created           = SpTypeHelper.GetDateTimeValue(listItem["Created"]),
                     Author            = SpTypeHelper.GetFieldUserValue(listItem["Author"]),
                     Modified          = SpTypeHelper.GetDateTimeValue(listItem["Modified"]),
                     Editor            = SpTypeHelper.GetFieldUserValue(listItem["Editor"]),
                     CopySource        = String.Empty,
                     FileType          = SpTypeHelper.GetStringValue(listItem["File_x0020_Type"]),
                     FileSize          = SpTypeHelper.GetIntValue(listItem["File_x0020_Size"]),
                     Aktarildimi       = false
                 };
                 _unitOfWork.FileRepository.Add(file);
             }
             _unitOfWork.Commit();
         }
     }
     catch
     {
         Thread.Sleep(new TimeSpan(0, 0, 1, 0));
         Initialize();
         CommitFiles(site, documentLibrary, folderPath, folder);
     }
 }