예제 #1
0
        /// <summary>
        /// Associate documents from selected document set to selected client
        /// </summary>
        /// <param name="clientDocumentSet"> </param>
        /// <param name="documentSetUID"></param>
        /// <param name="headerInfo"> </param>
        public static void AssociateDocumentsToClient(
            ClientDocumentSet clientDocumentSet,
            int documentSetUID,
            HeaderInfo headerInfo)
        {
            // It is a new client document set
            // It maybe a new client, the client document set MUST be new or empty
            // 1) Instantiate a TREE for the Client Document Set document
            // 2) Instantiate a second tree for the documents related to that document set
            // 3) Now the old copy all starts, all the nodes from the second tree are moved to the new tree
            //    following current process
            // 4) Save happens as per usual
            //

            TreeView tvFileList           = new TreeView();               // This is the list of documents for a client, it should be EMPTY
            TreeView tvDocumentsAvailable = new TreeView();               // This is the list of documents for a client, it should be EMPTY
            string   folderOnly           = clientDocumentSet.FolderOnly; // Contains the folder location of the file

            // Add root folder
            //
            ClientDocument clientDocument = new ClientDocument();

            // clientDocument.AddRootFolder( clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID, clientDocumentSet.FolderOnly );

            RepClientDocument.AddRootFolder(clientDocument, clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID, clientDocumentSet.FolderOnly);

            // List client document list !!!!!!! Important because the ROOT folder is loaded ;-)

            var documentSetList = new ClientDocument();

            // documentSetList.List( clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID );

            RepClientDocument.List(documentSetList, clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID);

            tvFileList.Nodes.Clear();
            // documentSetList.ListInTree(tvFileList, "CLIENT");

            RepClientDocument.ListInTree(documentSetList, tvFileList, "CLIENT");

            if (tvFileList.Nodes.Count > 0)
            {
                tvFileList.Nodes[0].Expand();
            }

            // Load available documents
            //
            tvDocumentsAvailable.Nodes.Clear();

            // Get document list for a given document set
            //
            DocumentSet documentSet = new DocumentSet();

            documentSet.UID = documentSetUID;
            documentSet.Read(IncludeDocuments: 'Y');

            // Load document in the treeview
            //
            Model.ModelDocument.Document root = new Model.ModelDocument.Document();
            // root.GetRoot(headerInfo);

            root = RepDocument.GetRoot(headerInfo);

            DocumentList.ListInTree(tvDocumentsAvailable, documentSet.documentList, root);

            while (tvDocumentsAvailable.Nodes[0].Nodes.Count > 0)
            {
                TreeNode tn = tvDocumentsAvailable.Nodes[0].Nodes[0];
                tn.Remove();

                tvFileList.Nodes[0].Nodes.Add(tn);
            }

            tvFileList.SelectedNode = tvFileList.Nodes[0];

            // -------------------------------------------------------------------
            // The documents have been moved from the available to client's tree
            // Now it is time to save the documents
            // -------------------------------------------------------------------
            Save(clientDocumentSet, documentSetUID, tvFileList);

            ClientDocumentLink cloneLinks = new ClientDocumentLink();

            cloneLinks.ReplicateDocSetDocLinkToClient(clientDocumentSet.FKClientUID, clientDocumentSet.ClientSetID, documentSetUID);
        }
예제 #2
0
 public static void AddRootFolder(ClientDocument clientDocument, int clientUID, int DocSetUID, string DestinationFolder)
 {
     RepClientDocument.AddRootFolder(clientDocument, clientUID, DocSetUID, DestinationFolder);
 }