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); }
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); } }
private void RecursiveCommitItems(Ent::Site site, Ent::DocumentLibrary documentLibrary, Ent::Folder commitedFolder) { var commitedFolders = new List <Ent::Folder>(); //{ documentLibrary.URL} string folderPath = $"{commitedFolder.FileRef}"; if (commitedFolder.FolderChildCount > 0) { commitedFolders = CommitFolders(site, documentLibrary, folderPath, commitedFolder); } if (commitedFolder.ItemChildCount > 0) { CommitFiles(site, documentLibrary, folderPath, commitedFolder); } if (commitedFolders != null && commitedFolders.Any()) { foreach (var folder in commitedFolders) { RecursiveCommitItems(site, documentLibrary, folder); } } }