private void ParentHasChanged() { var x = cbxDocument.Text; if (string.IsNullOrEmpty(x)) { return; } string[] doco = x.Split(';'); parentDocument.UID = Convert.ToInt32(doco[0]); // parentDocument.Read(); //parentDocument = RepDocument.Read(false, parentDocument.UID); // Using Business Layer var documentReadRequest = new DocumentReadRequest(); documentReadRequest.UID = parentDocument.UID; documentReadRequest.CUID = ""; documentReadRequest.retrieveVoidedDocuments = false; var docreadresp = BUSDocument.DocumentRead(documentReadRequest); if (docreadresp.response.ReturnCode == 0001) { // all good } else { MessageBox.Show(docreadresp.response.Message); return; } parentDocument = docreadresp.document; // // Get document set if (string.IsNullOrEmpty(cbxDocumentSet.Text)) { documentSetUID = 1; } else { var docSetUID = cbxDocumentSet.Text; string[] docoSet = docSetUID.Split(';'); // The first is the client id, the second is the document set id // documentSetUID = Convert.ToInt32(docoSet[1]); } ClientDocumentLinkList list = ClientDocumentLinkList.ListRelatedDocuments( selectedClient.UID, documentSetUID, parentDocument.UID, cbxLinkType.Text); loadLinkedDocuments(parentDocument); }
// ------------------------------------------ // List Documents // ------------------------------------------ public void loadLinkedDocuments(Document document) { // Image list // ImageList imageList = ControllerUtils.GetImageList(); // Binding tvLinkedDocuments.ImageList = imageList; // Clear nodes tvLinkedDocuments.Nodes.Clear(); var docoList = ClientDocumentLinkList.ListRelatedDocuments( selectedClient.UID, documentSetUID, document.UID, cbxLinkType.Text); // Load document in the treeview // // docoList.ListInTree(tvLinkedDocuments); Document root = new Document(); root.CUID = document.CUID; root.RecordType = FCMConstant.RecordType.FOLDER; root.UID = document.UID; // root.Read(); // root = RepDocument.Read(false, document.UID); // Using Business Layer var documentReadRequest = new DocumentReadRequest(); documentReadRequest.UID = document.UID; documentReadRequest.CUID = ""; documentReadRequest.retrieveVoidedDocuments = false; var docreadresp = BUSDocument.DocumentRead(documentReadRequest); if (docreadresp.response.ReturnCode == 0001) { // all good } else { MessageBox.Show(docreadresp.response.Message); return; } root = docreadresp.document; // ControllerUtils.ListInTree(tvLinkedDocuments, docoList, root); tvLinkedDocuments.ExpandAll(); }
// ----------------------------------------------------- // Load documents in a tree // ----------------------------------------------------- public static void ListInTree( TreeView fileList, ClientDocumentLinkList documentList, Document root) { // Find root folder // Document rootDocument = new Document(); rootDocument.CUID = root.CUID; rootDocument.RecordType = root.RecordType; rootDocument.UID = root.UID; // rootDocument.Read(); // rootDocument = RepDocument.Read(false, root.UID); // Using Business Layer var documentReadRequest = new DocumentReadRequest(); documentReadRequest.UID = root.UID; documentReadRequest.CUID = root.CUID; documentReadRequest.retrieveVoidedDocuments = false; var docreadresp = BUSDocument.DocumentRead(documentReadRequest); if (docreadresp.response.ReturnCode == 0001) { // all good } else { MessageBox.Show(docreadresp.response.Message); return; } rootDocument = docreadresp.document; // // Create root // var rootNode = new TreeNode(rootDocument.Name, FCMConstant.Image.Folder, FCMConstant.Image.Folder); // Add root node to tree // fileList.Nodes.Add(rootNode); rootNode.Tag = rootDocument; rootNode.Name = rootDocument.Name; foreach (var document in documentList.clientDocumentLinkList) { // Ignore root folder if (document.childDocument.CUID == "ROOT") { continue; } // Check if folder has a parent string cdocumentUID = document.UID.ToString(); string cparentIUID = document.childDocument.ParentUID.ToString(); int image = 0; if (document.childDocument.RecordType != null) { document.childDocument.RecordType = document.childDocument.RecordType.Trim(); } image = Utils.ImageSelect(document.childDocument.RecordType); if (document.childDocument.ParentUID == 0) { var treeNode = new TreeNode(document.childDocument.Name, image, image); treeNode.Tag = document; treeNode.Name = cdocumentUID; rootNode.Nodes.Add(treeNode); } else { // Find the parent node // var node = fileList.Nodes.Find(cparentIUID, true); if (node.Count() > 0) { var treeNode = new TreeNode(document.childDocument.Name, image, image); treeNode.Tag = document; treeNode.Name = cdocumentUID; node[0].Nodes.Add(treeNode); } else { // Add Element to the root // var treeNode = new TreeNode(document.childDocument.Name, image, image); treeNode.Tag = document; treeNode.Name = cdocumentUID; rootNode.Nodes.Add(treeNode); } } } }