public IHierarchicalEnumerable GetChildren() { if (_children == null) { _children = new TreeViewLocationCollection(); switch (_type) { case LOCATION_TYPE__FUNCTIONAL_AREA: { WBLogging.Debug("In GetChildren() for type Functional Area"); WBTaxonomy recordsTypes = _manager.RecordsTypesTaxonomy; TermCollection terms = recordsTypes.TermSet.Terms; foreach (Term childTerm in terms) { WBRecordsType recordsType = new WBRecordsType(recordsTypes, childTerm); bool protectiveZoneOK = true; //if (!String.IsNullOrEmpty(_minimumProtectiveZone)) //{ // protectiveZoneOK = (recordsType.IsZoneAtLeastMinimum(_minimumProtectiveZone)); // } if (recordsType.BranchCanHaveDocuments() && recordsType.IsRelevantToFunctionalArea(_functionalArea) && protectiveZoneOK) { TreeViewLocation newLocation = new TreeViewLocation(this, _manager, _mode, _minimumProtectiveZone, _functionalArea, recordsType); // If we're looking for existing records then we'll only add this location if it has a real folder existing underneath it: if (_mode == VIEW_MODE__NEW || newLocation._folder != null) { _children.Add(newLocation); } } else { WBLogging.Debug("In GetChildren() excluded " + recordsType.Name + " because " + recordsType.BranchCanHaveDocuments() + " && " + protectiveZoneOK); } } break; } case LOCATION_TYPE__RECORDS_TYPE: { WBLogging.Debug("In GetChildren() for type Records Type"); WBTaxonomy recordsTypes = _manager.RecordsTypesTaxonomy; TermCollection terms = _recordsType.Term.Terms; if (terms.Count > 0) { foreach (Term childTerm in terms) { WBRecordsType recordsType = new WBRecordsType(recordsTypes, childTerm); bool protectiveZoneOK = true; if (!String.IsNullOrEmpty(_minimumProtectiveZone)) { protectiveZoneOK = (recordsType.IsZoneAtLeastMinimum(_minimumProtectiveZone)); } if (recordsType.BranchCanHaveDocuments() && recordsType.IsRelevantToFunctionalArea(_functionalArea) && protectiveZoneOK) { TreeViewLocation newLocation = new TreeViewLocation(this, _manager, _mode, _minimumProtectiveZone, _functionalArea, recordsType); // If we're looking for existing records then we'll only add this location if it has a real folder existing underneath it: if (_mode == VIEW_MODE__NEW || newLocation._folder != null) { _children.Add(newLocation); } } } } else { if (_mode != VIEW_MODE__NEW) { // WBLogging.Debug("In view mode replace switching to folders part of tree"); string fullClassPath = WBUtils.NormalisePath(Path); // WBLogging.Debug("Looking for starting folder = " + fullClassPath); SPFolder protectedLibraryRootFolder = _manager.Libraries.ProtectedMasterLibrary.List.RootFolder; // WBLogging.Debug("Got library root folder"); SPFolder recordsTypeFolder = protectedLibraryRootFolder.WBxGetFolderPath(fullClassPath); // WBLogging.Debug("Got records type folder - definitely changed .. " + recordsTypeFolder); if (recordsTypeFolder != null) { foreach (SPFolder child in recordsTypeFolder.SubFolders) { _children.Add(new TreeViewLocation(this, _manager, _mode, _minimumProtectiveZone, child)); } } else { WBLogging.Debug("The master library doesn't have a folder with path: " + fullClassPath); } // WBLogging.Debug("Added children folders"); } } break; } case LOCATION_TYPE__FOLDER: { WBLogging.Debug("In GetChildren() for type Folder"); if (_folder.SubFolders.Count > 0) { foreach (SPFolder child in _folder.SubFolders) { _children.Add(new TreeViewLocation(this, _manager, _mode, _minimumProtectiveZone, child)); } } else { if (_mode == VIEW_MODE__REPLACE) { SPListItemCollection items = GetItemsRecursive(_folder); foreach (SPListItem item in items) { if (ItemCanBePicked(item)) { _children.Add(new TreeViewLocation(this, _manager, _mode, _minimumProtectiveZone, new WBDocument(_manager.Libraries.ProtectedMasterLibrary, item))); } } } } break; } case LOCATION_TYPE__DOCUMENT: { WBLogging.Debug("In GetChildren() for type Document"); break; } } } return(_children); }
public String PasteClipboard(WorkBox workBox, String folderPath) { Dictionary <String, List <int> > clipboardItems = new Dictionary <String, List <int> >(); UserProfile userProfile = GetUserProfile(workBox.Site); String clipboardAction = ""; try { clipboardAction = GetClipboard(userProfile, clipboardItems); SPFolder folder = workBox.DocumentLibrary.RootFolder; WBLogging.Generic.Unexpected("Folder path: ##" + folderPath + "##"); if (folder == null) { WBLogging.Generic.Unexpected("folder is null !!!"); } folderPath = folderPath.WBxTrim(); if (!String.IsNullOrEmpty(folderPath)) { folder = folder.WBxGetFolderPath(folderPath); } bool allowUnsafeUpdatesOriginalValue = workBox.Web.AllowUnsafeUpdates; workBox.Web.AllowUnsafeUpdates = true; foreach (String workBoxURL in clipboardItems.Keys) { List <int> ids = clipboardItems[workBoxURL]; using (WorkBox clipboardWorkBox = new WorkBox(workBoxURL)) { clipboardWorkBox.Web.AllowUnsafeUpdates = true; SPDocumentLibrary documents = clipboardWorkBox.DocumentLibrary; foreach (int id in ids) { SPListItem item = documents.GetItemById(id); bool cutOriginal = (clipboardAction == WBUser.CLIPBOARD_ACTION__CUT); try { WBUtils.CutOrCopyIntoFolder(workBox.Web, folder, item, cutOriginal); } catch (Exception docLevelException) { WBUtils.SendErrorReport(workBox.Web, "Error pasting a particular document in PasteClipboard", "Exception : " + docLevelException + " \n\n " + docLevelException.StackTrace); } } clipboardWorkBox.Web.AllowUnsafeUpdates = false; } } if (clipboardAction == CLIPBOARD_ACTION__CUT) { // You cannot paste more than once items that have been cut: ClearClipboard(userProfile); } workBox.Web.AllowUnsafeUpdates = allowUnsafeUpdatesOriginalValue; } catch (Exception exception) { WBUtils.SendErrorReport(workBox.Web, "Error in PasteClipboard", "Exception : " + exception + " \n\n " + exception.StackTrace); WBLogging.Generic.Unexpected("Clearing the user's clipboard in the hope that that will fix the error they are having."); ClearClipboard(userProfile); } return(clipboardAction); }