Esempio n. 1
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);
        }
Esempio n. 2
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);
     }
 }
Esempio n. 3
0
        private void SyncDocumentLibrary(Ent::Site site)
        {
            var siteDocumentLibrary = new Dictionary <Ent::DocumentLibrary, List>();

            #region [DocumentLibrary CommitDb]

            foreach (var d in Settings.SharePoint.RootFolders)
            {
                //Elimizde yalnızca aktarılacak klasörler mevcut. Bu nedenle; bu klasörlerin liste özellikleri gerekli.
                var list = _sp.SpList.GetListByTitle(d, includeRootFolder: true);
                if (list == null)
                {
                    throw new ArgumentNullException(nameof(list));
                }

                var documentLibrary = new Ent::DocumentLibrary()
                {
                    SiteID    = site.ID,
                    Title     = list.Title,
                    URL       = list.RootFolder.ServerRelativeUrl,
                    ItemCount = list.ItemCount
                };
                _unitOfWork.DocumentLibraryRepository.Add(documentLibrary);
                siteDocumentLibrary.Add(documentLibrary, list);
            }
            _unitOfWork.Commit();

            #endregion

            foreach (var dl in siteDocumentLibrary)
            {
                SyncListItem(site, dl);
            }

            //Parallel.ForEach(siteDocumentLibrary, new ParallelOptions { MaxDegreeOfParallelism = 4 }, keyValuePair =>
            //  {
            //      SyncListItem(site, keyValuePair);
            //  });
        }
Esempio n. 4
0
        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);
                }
            }
        }