/// <summary> /// Initializes this control by loading documents in the specified locations /// </summary> /// <param name="contract">The test document contract.</param> /// <exception cref="System.ArgumentNullException">selectedDocuments</exception> public void Initialize(TestDocumentContract contract) { _contract = contract; var selectedDocument = contract.Replacement; if (allDocuments_TreeView.Nodes.Count == 0) { DocumentLibraryController documentLibrary = new DocumentLibraryController(DbConnect.DocumentLibraryConnectionString); DocumentCollection documents = documentLibrary.GetDocuments(); // First, add the top level nodes from the extensions table foreach (string location in documents.Select(n => n.Group).Distinct()) { RadTreeNode locationNode = allDocuments_TreeView.Nodes.Add(location, "FOLDER"); // Now add the document nodes for this location var files = documents.Where(n => n.Group == location).Select(n => n.FileName); foreach (string fileName in files) { locationNode.Nodes.Add(fileName, Path.GetExtension(fileName).ToUpperInvariant()); } } } if (!string.IsNullOrEmpty(selectedDocument)) { var node = allDocuments_TreeView.Nodes .SelectMany(x => x.Nodes) .FirstOrDefault(x => x.Tag != null && x.Text.Equals(selectedDocument)); if (node != null) { allDocuments_TreeView.SelectedNode = node; } } }
private DocumentIdCollection GetDocumentsFromQuery(DocumentQuery queryCriteria) { DocumentLibraryController controller = new DocumentLibraryController(DbConnect.DocumentLibraryConnectionString); return(new DocumentIdCollection(controller.GetDocuments(queryCriteria).Select(n => n.DocumentId))); }