Exemplo n.º 1
0
        // -----------------------------------------------------
        //    List Documents for a client
        // -----------------------------------------------------
        public void ListClient(int clientUID)
        {
            this.documentList = new List <Model.ModelDocument.Document>();

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    RepDocument.SQLDocumentConcat("DOC") +
                    "   FROM Document DOC " +
                    "  WHERE SourceCode = 'CLIENT' " +
                    "    AND FKClientUID = {0} " +
                    "    AND IsVoid <> 'Y' " +
                    "  ORDER BY PARENTUID ASC, SequenceNumber ASC ",
                    clientUID);

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Model.ModelDocument.Document _Document = new Model.ModelDocument.Document();
                            RepDocument.LoadDocumentFromReader(_Document, "DOC", reader);

                            documentList.Add(_Document);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        // -----------------------------------------------------
        //    List Documents
        // -----------------------------------------------------
        private void List(string Condition)
        {
            this.documentList = new List <Model.ModelDocument.Document>();

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    RepDocument.SQLDocumentConcat("DOC") +
                    "   FROM     Document DOC " +
                    "  WHERE DOC.SourceCode = 'FCM' " +
                    "    AND DOC.IsVoid = 'N' " +
                    Condition +
                    "  ORDER BY PARENTUID ASC, SequenceNumber ASC "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Model.ModelDocument.Document _Document = new Model.ModelDocument.Document();
                            RepDocument.LoadDocumentFromReader(_Document, "DOC", reader);

                            documentList.Add(_Document);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update or Create document
        /// </summary>
        /// <param name="documentSaveRequest"></param>
        /// <returns></returns>
        public static DocumentSaveResponse DocumentSave(DocumentSaveRequest documentSaveRequest)
        {
            var repDocSaveResp = RepDocument.Save(
                documentSaveRequest.headerInfo,
                documentSaveRequest.inDocument,
                documentSaveRequest.saveType);

            var documentSaveResponse = new DocumentSaveResponse();

            documentSaveResponse.document     = documentSaveRequest.inDocument;
            documentSaveResponse.document.UID = repDocSaveResp;
            if (repDocSaveResp == 0)
            {
                documentSaveResponse.response            = new ResponseStatus(MessageType.Error);
                documentSaveResponse.response.Message    = "Error Saving Document.";
                documentSaveResponse.response.Successful = false;
                documentSaveResponse.response.ReturnCode = -0010;
            }
            else
            {
                documentSaveResponse.response = new ResponseStatus(MessageType.Informational);
            }

            return(documentSaveResponse);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create new versions
        /// </summary>
        /// <param name="documentSaveRequest"></param>
        /// <returns></returns>
        public static DocumentNewVersionResponse DocumentNewVersion(
            DocumentNewVersionRequest documentSaveRequest)
        {
            var repNewVersionResp = RepDocument.NewVersion(
                documentSaveRequest.headerInfo,
                documentSaveRequest.inDocument);

            return(repNewVersionResp);
        }
Exemplo n.º 5
0
        /// <summary>
        /// List of documents
        /// </summary>
        public static DocumentListResponse DocumentListX(DocumentListRequest documentListRequest)
        {
            var documentListResponse = new DocumentListResponse();

            documentListResponse.response = new ResponseStatus();

            documentListResponse.documentList = RepDocument.List(documentListRequest.headerInfo, documentListRequest.inCondition);

            return(documentListResponse);
        }
Exemplo n.º 6
0
        /// <summary>
        /// List of documents
        /// </summary>
        public static DocumentListResponse DocumentListFolders(DocumentListRequest documentListRequest)
        {
            var documentListResponse = new DocumentListResponse();

            documentListResponse.response = new ResponseStatus();

            documentListResponse.documentList = RepDocument.ListFolders(documentListRequest.headerInfo);

            return(documentListResponse);
        }
Exemplo n.º 7
0
        /// <summary>
        /// List of clients
        /// </summary>
        public static DocumentListResponse DocumentList(HeaderInfo headerInfo)
        {
            var documentListResponse = new DocumentListResponse();

            documentListResponse.response = new ResponseStatus();

            documentListResponse.documentList = RepDocument.List(headerInfo);

            return(documentListResponse);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Retrieve document details
        /// </summary>
        /// <param name="documentReadRequest"></param>
        /// <returns></returns>
        public static DocumentReadResponse DocumentRead(DocumentReadRequest documentReadRequest)
        {
            var documentRead = RepDocument.Read(
                documentReadRequest.retrieveVoidedDocuments,
                documentReadRequest.UID,
                documentReadRequest.CUID);

            var documentReadResponse = new DocumentReadResponse();

            documentReadResponse.document = documentRead;
            documentReadResponse.response = new ResponseStatus(MessageType.Informational);

            return(documentReadResponse);
        }
Exemplo n.º 9
0
        // -----------------------------------------------------
        //        List Documents for a Document Set
        // -----------------------------------------------------
        public void ListDocSet(int documentSetUID)
        {
            this.documentList = new List <Model.ModelDocument.Document>();

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    "  SELECT " +
                    RepDocument.SQLDocumentConcat("DOC") +
                    " ,LNK.FKParentDocumentUID " +
                    " ,LNK.FKParentDocumentSetUID " +
                    " ,LNK.SequenceNumber " +
                    "   FROM Document DOC " +
                    "       ,DocumentSetDocument LNK" +
                    "  WHERE " +
                    "        LNK.FKDocumentUID = DOC.UID " +
                    "    AND DOC.SourceCode = 'FCM' " +
                    "    AND LNK.IsVoid     = 'N' " +
                    "    AND DOC.IsVoid     = 'N' " +
                    "    AND LNK.FKDocumentSetUID = {0}  " +
                    "  ORDER BY LNK.FKParentDocumentUID ASC, LNK.SequenceNumber ",
                    documentSetUID
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Model.ModelDocument.Document _Document = new Model.ModelDocument.Document();
                            RepDocument.LoadDocumentFromReader(_Document, "DOC", reader);

                            // This is necessary because when the list comes from DocumentSet, the parent may change
                            //
                            _Document.ParentUID = Convert.ToInt32(reader["FKParentDocumentUID"].ToString());

                            this.documentList.Add(_Document);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        public List <Document> ListDocumentsNotInSet(HeaderInfo headerInfo, int documentSetUID)
        {
            List <Document> documentsNotInSet   = new List <Document>();
            List <Document> documentsInSet      = new List <Document>();
            List <Document> fullListOfDocuments = new List <Document>();

            fullListOfDocuments = RepDocument.ListDocuments(headerInfo);

            ListDocumentsInSet(documentSetUID);
            documentsInSet = this.listOfDocumentsInSet;

            bool found = false;

            foreach (var document in fullListOfDocuments)
            {
                found = false;

                foreach (var documentInSet in listOfDocumentsInSet)
                {
                    // Document already in set
                    if (document.CUID == documentInSet.CUID)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    continue;
                }

                // if gets to this point, document is not in set

                documentsNotInSet.Add(document);
            }

            return(documentsNotInSet);
        }
Exemplo n.º 11
0
        public static void ListInTree(
            TreeView fileList,
            DocumentSetDocumentLinkList documentList,
            Model.ModelDocument.Document root)
        {
            // Find root folder
            //
            Model.ModelDocument.Document rootDocument = new Model.ModelDocument.Document();

            rootDocument.CUID       = root.CUID;
            rootDocument.RecordType = root.RecordType;
            rootDocument.UID        = root.UID;
            // rootDocument.Read();

            rootDocument = RepDocument.Read(false, root.UID);

            // Create root
            //
            var rootNode = new TreeNode(rootDocument.Name, MakConstant.Image.Folder, MakConstant.Image.Folder);

            // Add root node to tree
            //
            fileList.Nodes.Add(rootNode);
            rootNode.Tag  = rootDocument;
            rootNode.Name = rootDocument.Name;

            foreach (var document in documentList.documentSetDocumentLinkList)
            {
                int image = 0;
                image = Utils.ImageSelect(document.documentChild.RecordType.Trim());

                var treeNode = new TreeNode(document.documentChild.Name, image, image);
                treeNode.Tag  = document;
                treeNode.Name = document.LinkType;

                rootNode.Nodes.Add(treeNode);
            }
        }
Exemplo n.º 12
0
        public List <Document> ListDocumentsNotInSet(HeaderInfo headerInfo, int clientUID, int clientDocumentSetUID)
        {
            var documentsNotInSet   = new List <Document>();
            var documentsInSet      = new List <ClientDocument>();
            var fullListOfDocuments = new List <Document>();

            fullListOfDocuments = RepDocument.ListDocuments(headerInfo);
            documentsInSet      = RepClientDocument.ListCD(clientUID, clientDocumentSetUID);

            bool found = false;

            foreach (var document in fullListOfDocuments)
            {
                found = false;

                foreach (var documentInSet in documentsInSet)
                {
                    // Document already in set
                    if (document.UID == documentInSet.FKDocumentUID)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    continue;
                }

                // if gets to this point, document is not in set

                documentsNotInSet.Add(document);
            }

            return(documentsNotInSet);
        }
Exemplo n.º 13
0
        public static ClientDocumentLinkList ListRelatedDocuments(
            int clientUID,
            int clientDocumentSetUID,
            int documentUID,
            string type)
        {
            ClientDocumentLinkList ret = new ClientDocumentLinkList();

            ret.clientDocumentLinkList = new List <ClientDocumentLink>();

            string linktype = "";

            if (type == "ALL" || string.IsNullOrEmpty(type))
            {
                // do nothing
            }
            else
            {
                linktype = "  AND CDL.LinkType = '" + type + "'";
            }

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format
                                    (
                    "SELECT  " +
                    "    CDL.UID                     CDLUID   " +
                    "   ,CDL.FKParentDocumentUID             CDLFKParentDocumentUID   " +
                    "   ,CDL.FKChildDocumentUID              CDLFKChildDocumentUID    " +
                    "   ,CDL.LinkType                CDLLinkType   " +
                    "   ,CDL.IsVoid                  CDLIsVoid   " +
                    "   ,CDL.FKClientDocumentSetUID  CDLFKClientDocumentSetUID   " +
                    "   ,CDL.FKClientUID             CDLFKClientUID   " +
                    "  " +
                    "   FROM ClientDocumentLink CDL " +
                    "  WHERE  " +
                    "        CDL.IsVoid = 'N' " +
                    "    AND CDL.FKParentDocumentUID = {0} " +
                    "    AND CDL.FKClientDocumentSetUID = {1}  " +
                    "    AND CDL.FKClientUID = {2}  " +
                    linktype
                    , documentUID
                    , clientDocumentSetUID
                    , clientUID
                                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ClientDocumentLink clientDocumentLink = new ClientDocumentLink();
                            clientDocumentLink.UID = Convert.ToInt32(reader["CDLUID"].ToString());
                            clientDocumentLink.FKParentDocumentUID    = Convert.ToInt32(reader["CDLFKParentDocumentUID"].ToString());
                            clientDocumentLink.FKChildDocumentUID     = Convert.ToInt32(reader["CDLFKChildDocumentUID"].ToString());
                            clientDocumentLink.LinkType               = reader["CDLLinkType"].ToString();
                            clientDocumentLink.FKClientDocumentSetUID =
                                Convert.ToChar(reader["CDLFKClientDocumentSetUID"].ToString());
                            clientDocumentLink.FKClientUID = Convert.ToInt32(reader["CDLFKClientUID"].ToString());

                            // Get the client document child
                            clientDocumentLink.childClientDocument     = new ClientDocument();
                            clientDocumentLink.childClientDocument.UID = clientDocumentLink.FKChildDocumentUID;

                            // 04.02.2013
                            // clientDocumentLink.childClientDocument.Read();
                            clientDocumentLink.childClientDocument = RepClientDocument.Read(clientDocumentLink.FKChildDocumentUID);

                            // Get the document child
                            clientDocumentLink.childDocument     = new Model.ModelDocument.Document();
                            clientDocumentLink.childDocument.UID = clientDocumentLink.FKChildDocumentUID;
                            // clientDocumentLink.childDocument.Read();

                            clientDocumentLink.childDocument = RepDocument.Read(false, clientDocumentLink.FKChildDocumentUID);

                            // Get the client document parent
                            clientDocumentLink.parentClientDocument     = new ClientDocument();
                            clientDocumentLink.parentClientDocument.UID = clientDocumentLink.FKParentDocumentUID;
                            //clientDocumentLink.parentClientDocument.Read();

                            clientDocumentLink.parentClientDocument = RepClientDocument.Read(clientDocumentLink.FKParentDocumentUID);


                            // Get the document parent
                            clientDocumentLink.parentDocument     = new Model.ModelDocument.Document();
                            clientDocumentLink.parentDocument.UID = clientDocumentLink.FKParentDocumentUID;
                            // clientDocumentLink.parentDocument.Read();

                            clientDocumentLink.parentDocument =
                                RepDocument.Read(false, clientDocumentLink.FKParentDocumentUID);

                            // Get the client document set
                            clientDocumentLink.clientDocumentSet     = new ClientDocumentSet();
                            clientDocumentLink.clientDocumentSet.UID = clientDocumentLink.FKClientDocumentSetUID;
                            clientDocumentLink.clientDocumentSet.Read();

                            ret.clientDocumentLinkList.Add(clientDocumentLink);
                        }
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Load document into document set
        /// </summary>
        public void LoadAllDocuments()
        {
            // Retrieve all documents
            // For each document (order by parent uid)
            // check if it is already connected to current Document Set
            // If it is not, connect document
            // Link with parent document in the set
            // Replicate Document Links


            // 21/08/2013
            // Stop using DocumentList
            //

            //DocumentList dl = new DocumentList();
            //dl.List();

            List <Document> docl = RepDocument.List(HeaderInfo.Instance);

            foreach (Document document in docl)
            {
                var found = DocumentSet.FindDocumentInSet(this.UID, document.UID);

                if (found.document.UID > 0)
                {
                    continue;
                }
                else
                {
                    DocumentSetDocument dsl = new DocumentSetDocument();

                    // Generate new UID
                    dsl.UID = this.GetLastUID() + 1;

                    // Add document to set
                    //
                    dsl.FKDocumentSetUID       = this.UID;
                    dsl.FKDocumentUID          = document.UID;
                    dsl.Location               = document.Location;
                    dsl.IsVoid                 = 'N';
                    dsl.StartDate              = System.DateTime.Today;
                    dsl.EndDate                = System.DateTime.MaxValue;
                    dsl.FKParentDocumentUID    = document.ParentUID; // Uses the Document UID as the source (Has to be combined with Doc Set)
                    dsl.FKParentDocumentSetUID = dsl.FKDocumentSetUID;
                    dsl.SequenceNumber         = document.SequenceNumber;

                    dsl.Add();
                }
            }

            // Replicate document links
            //
            foreach (Document document in docl)
            {
                var children = DocumentLinkList.ListRelatedDocuments(document.UID);

                foreach (var child in children.documentLinkList)
                {
                    //
                    DocumentSetDocumentLink dsdl = new DocumentSetDocumentLink();
                    dsdl.FKParentDocumentUID = 0;
                    dsdl.FKChildDocumentUID  = 0;
                    dsdl.IsVoid   = 'N';
                    dsdl.LinkType = child.LinkType;
                    dsdl.UID      = GetLastUID() + 1;

                    // Find parent

                    var parent1 = DocumentSet.FindDocumentInSet(this.UID, child.FKParentDocumentUID);

                    // Find child
                    var child1 = DocumentSet.FindDocumentInSet(this.UID, child.FKChildDocumentUID);

                    dsdl.FKParentDocumentUID = parent1.DocumentSetDocument.UID;
                    dsdl.FKChildDocumentUID  = child1.DocumentSetDocument.UID;

                    dsdl.Add();
                }
            }
        }
Exemplo n.º 15
0
        // -----------------------------------------------------
        //           Load documents in a tree
        // -----------------------------------------------------
        public static void ListInTree(
            TreeView fileList,
            DocumentList documentList,
            Model.ModelDocument.Document root)
        {
            // Find root folder
            //
            Model.ModelDocument.Document rootDocument = new Model.ModelDocument.Document();

            rootDocument.CUID       = root.CUID;
            rootDocument.RecordType = root.RecordType;
            rootDocument.UID        = root.UID;
            // rootDocument.Read();

            rootDocument = RepDocument.Read(false, root.UID);

            // Create root
            //
            var rootNode = new TreeNode(rootDocument.FileName, MakConstant.Image.Folder, MakConstant.Image.Folder);

            // Add root node to tree
            //
            fileList.Nodes.Add(rootNode);
            rootNode.Tag  = rootDocument;
            rootNode.Name = rootDocument.Name;

            foreach (var document in documentList.documentList)
            {
                // Ignore root folder
                if (document.CUID == "ROOT")
                {
                    continue;
                }

                // Check if folder has a parent
                string cdocumentUID = document.UID.ToString();
                string cparentIUID  = document.ParentUID.ToString();

                int image         = 0;
                int imageSelected = 0;
                document.RecordType = document.RecordType.Trim();

                #region Image
                switch (document.DocumentType)
                {
                case Utils.DocumentType.WORD:
                    image         = MakConstant.Image.Word32;
                    imageSelected = MakConstant.Image.Word32;


                    // I have to think about this...
                    //
                    if (document.RecordType == Utils.RecordType.APPENDIX)
                    {
                        image         = MakConstant.Image.Appendix;
                        imageSelected = MakConstant.Image.Appendix;
                    }
                    break;

                case Utils.DocumentType.EXCEL:
                    image         = MakConstant.Image.Excel;
                    imageSelected = MakConstant.Image.Excel;
                    break;

                case Utils.DocumentType.FOLDER:
                    image         = MakConstant.Image.Folder;
                    imageSelected = MakConstant.Image.Folder;
                    break;

                case Utils.DocumentType.PDF:
                    image         = MakConstant.Image.PDF;
                    imageSelected = MakConstant.Image.PDF;
                    break;

                default:
                    image         = MakConstant.Image.Word32;
                    imageSelected = MakConstant.Image.Word32;

                    break;
                }
                #endregion Image

                if (document.ParentUID == 0)
                {
                    var treeNode = new TreeNode(document.FileName, 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.FileName, image, imageSelected);
                        treeNode.Tag  = document;
                        treeNode.Name = cdocumentUID;

                        node[0].Nodes.Add(treeNode);
                    }
                    else
                    {
                        // Add Element to the root
                        //
                        var treeNode = new TreeNode(document.FileName, image, imageSelected);
                        treeNode.Tag  = document;
                        treeNode.Name = cdocumentUID;

                        rootNode.Nodes.Add(treeNode);
                    }
                }
            }
        }
Exemplo n.º 16
0
        //
        // It returns a list of links for a given document set UID
        //
        public void List(DocumentSet documentSet)
        {
            documentSetDocumentList = new List <scDocoSetDocumentLink>();

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    "  UID " +
                    " ,FKDocumentUID " +
                    " ,FKDocumentSetUID " +
                    " ,StartDate " +
                    " ,EndDate " +
                    " ,IsVoid " +
                    "   FROM DocumentSetDocument " +
                    "   WHERE FKDocumentSetUID = {0} ",
                    documentSet.UID
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            // Ignore voids
                            if (Convert.ToChar(reader["IsVoid"]) == 'Y')
                            {
                                continue;
                            }

                            var docItem = new scDocoSetDocumentLink();

                            // Get document
                            //
                            docItem.document     = new Model.ModelDocument.Document();
                            docItem.document.UID = Convert.ToInt32(reader["FKDocumentUID"]);

                            // 11.01.2013
                            //
                            // docItem.document.Read();

                            docItem.document = RepDocument.Read(true, docItem.document.UID);

                            // Get DocumentSet
                            //
                            docItem.documentSet     = new DocumentSet();
                            docItem.documentSet.UID = Convert.ToInt32(reader["FKDocumentSetUID"].ToString());

                            // Set DocumentSetDocument
                            docItem.DocumentSetDocument                  = new DocumentSetDocument();
                            docItem.DocumentSetDocument.UID              = Convert.ToInt32(reader["UID"].ToString());
                            docItem.DocumentSetDocument.FKDocumentUID    = Convert.ToInt32(reader["FKDocumentUID"].ToString());
                            docItem.DocumentSetDocument.FKDocumentSetUID = Convert.ToInt32(reader["FKDocumentSetUID"].ToString());
                            docItem.DocumentSetDocument.IsVoid           = Convert.ToChar(reader["IsVoid"].ToString());
                            docItem.DocumentSetDocument.StartDate        = Convert.ToDateTime(reader["StartDate"].ToString());

                            if (reader["EndDate"] == null)
                            {
                                docItem.DocumentSetDocument.EndDate = System.DateTime.MaxValue;
                            }
                            else
                            {
                                docItem.DocumentSetDocument.EndDate = Convert.ToDateTime(reader["EndDate"].ToString());
                            }
                            documentSetDocumentList.Add(docItem);
                        }
                    }
                }

                return;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Retrieve document details
        /// </summary>
        /// <returns></returns>
        public static Document GetRootDocument()
        {
            var documentRead = RepDocument.Read(false, 0, "ROOT");

            return(documentRead);
        }
Exemplo n.º 18
0
        public static DocumentSetDocumentLinkList ListRelatedDocuments(int documentSetUID, int documentUID, string type)
        {
            DocumentSetDocumentLinkList ret = new DocumentSetDocumentLinkList();

            ret.documentSetDocumentLinkList = new List <DocumentSetDocumentLink>();

            string linktype = "";

            if (type == "ALL" || string.IsNullOrEmpty(type))
            {
                // do nothing
            }
            else
            {
                linktype = "  AND DSDL.LinkType = '" + type + "'";
            }

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format
                                    (
                    "SELECT DSDL.UID                        DSDLUID                 " +
                    "      ,DSDL.FKParentDocumentUID        DSDLFKParentDocumentUID " +
                    "       ,DSDL.FKChildDocumentUID        DSDLFKChildDocumentUID " +
                    "       ,DSDL.LinkType                  DSDLLinkType " +
                    "       ,DSDL.IsVoid                    DSDLIsVoid " +
                    "       ," +
                    RepDocument.SQLDocumentConcat("DOCUMENTCHILD") +
                    "       ," +
                    RepDocument.SQLDocumentConcat("DOCUMENTPARENT") +
                    "       ," +
                    RepDocumentSetDocument.SQLDocumentConcat("DSDCHILD") +
                    "       ," +
                    RepDocumentSetDocument.SQLDocumentConcat("DSDPARENT") +

                    "  " +
                    "   FROM DocumentSetDocumentLink DSDL " +
                    "       ,DocumentSetDocument DSDCHILD " +
                    "       ,DocumentSetDocument DSDPARENT " +
                    "       ,Document DOCUMENTCHILD " +
                    "       ,Document DOCUMENTPARENT " +
                    "  WHERE  " +
                    "        DSDL.IsVoid = 'N' " +
                    "    AND DSDL.FKParentDocumentUID = {0} " +
                    linktype +
                    "    AND DSDL.FKDocumentSetUID = {1}  " +
                    "    AND DSDL.FKChildDocumentUID = DSDCHILD.UID  " +
                    "    AND DSDL.FKParentDocumentUID = DSDPARENT.UID  " +
                    "    AND DSDCHILD.FKDocumentUID = DOCUMENTCHILD.UID " +
                    "    AND DSDPARENT.FKDocumentUID = DOCUMENTPARENT.UID "
                    , documentUID
                    , documentSetUID
                                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DocumentSetDocumentLink _Document = new DocumentSetDocumentLink();
                            _Document.documentChild             = new Model.ModelDocument.Document();
                            _Document.documentParent            = new Model.ModelDocument.Document();
                            _Document.documentSetDocumentChild  = new DocumentSetDocument();
                            _Document.documentSetDocumentParent = new DocumentSetDocument();

                            // Link information
                            //
                            _Document.FKChildDocumentUID  = Convert.ToInt32(reader["DSDLFKChildDocumentUID"].ToString());
                            _Document.FKParentDocumentUID = Convert.ToInt32(reader["DSDLFKParentDocumentUID"].ToString());
                            _Document.LinkType            = reader["DSDLLinkType"].ToString();

                            _Document.documentParent.UID            = Convert.ToInt32(reader["DOCUMENTPARENTUID"].ToString());
                            _Document.documentParent.SimpleFileName = reader["DOCUMENTPARENTUID"].ToString();
                            _Document.documentParent.CUID           = reader["DOCUMENTPARENTSimpleFileName"].ToString();
                            _Document.documentParent.Name           = reader["DOCUMENTPARENTName"].ToString();

                            _Document.documentChild.UID            = Convert.ToInt32(reader["DOCUMENTCHILDUID"].ToString());
                            _Document.documentChild.CUID           = reader["DOCUMENTCHILDSimpleFileName"].ToString();
                            _Document.documentChild.Name           = reader["DOCUMENTCHILDName"].ToString();
                            _Document.documentChild.SequenceNumber = Convert.ToInt32(reader["DOCUMENTCHILDSequenceNumber"].ToString());
                            _Document.documentChild.IssueNumber    = Convert.ToInt32(reader["DOCUMENTCHILDIssueNumber"].ToString());
                            _Document.documentChild.Location       = reader["DOCUMENTCHILDLocation"].ToString();
                            _Document.documentChild.Comments       = reader["DOCUMENTCHILDComments"].ToString();
                            _Document.documentChild.SourceCode     = reader["DOCUMENTCHILDSourceCode"].ToString();
                            _Document.documentChild.FileName       = reader["DOCUMENTCHILDFileName"].ToString();
                            _Document.documentChild.SimpleFileName = reader["DOCUMENTCHILDSimpleFileName"].ToString();
                            _Document.documentChild.FKClientUID    = Convert.ToInt32(reader["DOCUMENTCHILDFKClientUID"].ToString());
                            _Document.documentChild.ParentUID      = Convert.ToInt32(reader["DOCUMENTCHILDParentUID"].ToString());
                            _Document.documentChild.RecordType     = reader["DOCUMENTCHILDRecordType"].ToString();
                            _Document.documentChild.IsProjectPlan  = reader["DOCUMENTCHILDIsProjectPlan"].ToString();
                            _Document.documentChild.DocumentType   = reader["DOCUMENTCHILDDocumentType"].ToString();

                            _Document.documentSetDocumentChild.UID                    = Convert.ToInt32(reader["DSDCHILDUID"].ToString());
                            _Document.documentSetDocumentChild.FKDocumentUID          = Convert.ToInt32(reader["DSDCHILDFKDocumentUID"].ToString());
                            _Document.documentSetDocumentChild.FKDocumentSetUID       = Convert.ToInt32(reader["DSDCHILDFKDocumentSetUID"].ToString());
                            _Document.documentSetDocumentChild.Location               = reader["DSDCHILDLocation"].ToString();
                            _Document.documentSetDocumentChild.StartDate              = Convert.ToDateTime(reader["DSDCHILDStartDate"].ToString());
                            _Document.documentSetDocumentChild.EndDate                = Convert.ToDateTime(reader["DSDCHILDEndDate"].ToString());
                            _Document.documentSetDocumentChild.FKParentDocumentUID    = Convert.ToInt32(reader["DSDCHILDFKParentDocumentUID"].ToString());
                            _Document.documentSetDocumentChild.SequenceNumber         = Convert.ToInt32(reader["DSDCHILDSequenceNumber"].ToString());
                            _Document.documentSetDocumentChild.FKParentDocumentSetUID = Convert.ToInt32(reader["DSDCHILDFKParentDocumentSetUID"].ToString());

                            ret.documentSetDocumentLinkList.Add(_Document);
                        }
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 19
0
        //
        // List documents for a client
        //
        public void List(int clientID, int clientDocumentSetUID)
        {
            clientDocSetDocLink = new List <scClientDocSetDocLink>();

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    "   UID " +
                    "  ,FKClientUID " +
                    "  ,FKClientDocumentSetUID " +
                    "  ,FKDocumentUID " +
                    "  ,SequenceNumber " +
                    "  ,StartDate " +
                    "  ,EndDate " +
                    "  ,IsVoid " +
                    "  ,SourceLocation " +
                    "  ,SourceFileName " +
                    "  ,Location " +
                    "  ,FileName " +
                    "  ,SourceIssueNumber " +
                    "  ,Generated " +
                    "  ,RecordType " +
                    "  ,ParentUID " +
                    "   FROM ClientDocument " +
                    "   WHERE FKClientUID = {0} " +
                    "   AND FKClientDocumentSetUID = {1} " +
                    "   ORDER BY ParentUID ASC, SequenceNumber ASC ",
                    clientID,
                    clientDocumentSetUID
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            // Ignore voids
                            if (Convert.ToChar(reader["IsVoid"]) == 'Y')
                            {
                                continue;
                            }

                            var docItem = new scClientDocSetDocLink();

                            // Get document
                            //
                            docItem.document     = new Model.ModelDocument.Document();
                            docItem.document.UID = Convert.ToInt32(reader["FKDocumentUID"]);
                            // docItem.document.Read();

                            docItem.document = RepDocument.Read(false, docItem.document.UID);


                            // Get Client Document Set
                            //
                            docItem.clientDocumentSet             = new ClientDocumentSet();
                            docItem.clientDocumentSet.UID         = Convert.ToInt32(reader["FKClientDocumentSetUID"].ToString());
                            docItem.clientDocumentSet.FKClientUID = Convert.ToInt32(reader["FKClientUID"].ToString());

                            // Set Client Document
                            //
                            docItem.clientDocument                        = new ClientDocument();
                            docItem.clientDocument.UID                    = Convert.ToInt32(reader["UID"].ToString());
                            docItem.clientDocument.FKDocumentUID          = Convert.ToInt32(reader["FKDocumentUID"].ToString());
                            docItem.clientDocument.SequenceNumber         = Convert.ToInt32(reader["SequenceNumber"].ToString());
                            docItem.clientDocument.FKClientDocumentSetUID = Convert.ToInt32(reader["FKClientDocumentSetUID"].ToString());
                            docItem.clientDocument.IsVoid                 = Convert.ToChar(reader["IsVoid"].ToString());
                            docItem.clientDocument.StartDate              = Convert.ToDateTime(reader["StartDate"].ToString());
                            docItem.clientDocument.SourceLocation         = reader["SourceLocation"].ToString();
                            docItem.clientDocument.SourceFileName         = reader["SourceFileName"].ToString();
                            docItem.clientDocument.Location               = reader["Location"].ToString();
                            docItem.clientDocument.FileName               = reader["FileName"].ToString();
                            docItem.clientDocument.SourceIssueNumber      = Convert.ToInt32(reader["SourceIssueNumber"].ToString());
                            docItem.clientDocument.Generated              = Convert.ToChar(reader["Generated"]);
                            docItem.clientDocument.RecordType             = reader["RecordType"].ToString();
                            docItem.clientDocument.ParentUID              = Convert.ToInt32(reader["ParentUID"].ToString());


                            try
                            {
                                docItem.clientDocument.EndDate = Convert.ToDateTime(reader["EndDate"].ToString());
                            }
                            catch
                            {
                                docItem.clientDocument.EndDate = System.DateTime.MaxValue;
                            }

                            this.clientDocSetDocLink.Add(docItem);
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
        // -----------------------------------------------------
        //    Get Document Details
        // -----------------------------------------------------
        public static scDocoSetDocumentLink FindDocumentInSet(int documentSetUID, int documentUID)
        {
            //
            // EA SQL database
            //
            scDocoSetDocumentLink ret = new scDocoSetDocumentLink();

            ret.document            = new Model.ModelDocument.Document();
            ret.documentSet         = new DocumentSet();
            ret.DocumentSetDocument = new DocumentSetDocument();

            string commandString = "";

            commandString = string.Format(
                " SELECT " +
                "       Document.UID DocumentUID" +
                "      ,Document.CUID DocumentCUID " +
                "      ,Document.Name DocumentName " +
                "      ,Document.SequenceNumber DocumentSequenceNumber " +
                "      ,Document.IssueNumber DocumentIssueNumber " +
                "      ,Document.Location DocumentLocation " +
                "      ,Document.Comments DocumentComments" +
                "      ,Document.UID DocumentUID" +
                "      ,Document.FileName DocumentFileName" +
                "      ,Document.SourceCode DocumentSourceCode" +
                "      ,Document.FKClientUID DocumentFKClientUID" +
                "      ,Document.ParentUID DocumentParentUID" +
                "      ,Document.RecordType DocumentRecordType" +
                "      ,Document.IsProjectPlan DocumentIsProjectPlan" +
                "      ,Document.DocumentType DocumentDocumentType" +
                "      ,DocSetDoc.UID DocSetDocUID" +
                "      ,DocSetDoc.FKDocumentUID DocSetDocFKDocumentUID" +
                "      ,DocSetDoc.FKDocumentSetUID DocSetDocFKDocumentSetUID" +
                "      ,DocSetDoc.Location DocSetDocLocation" +
                "      ,DocSetDoc.IsVoid DocSetDocIsVoid" +
                "      ,DocSetDoc.StartDate DocSetDocStartDate" +
                "      ,DocSetDoc.EndDate DocSetDocEndDate" +
                "      ,DocSetDoc.FKParentDocumentUID DocSetDocFKParentDocumentUID" +
                "      ,DocSetDoc.FKParentDocumentSetUID DocSetDocFKParentDocumentSetUID" +
                "      ,DocSet.UID SetUID" +
                "      ,DocSet.TemplateType SetTemplateType" +
                "      ,DocSet.TemplateFolder SetTemplateFolder" +
                "  FROM  Document Document" +
                "       ,DocumentSetDocument DocSetDoc " +
                "       ,DocumentSet DocSet " +
                " WHERE " +
                "        Document.UID = DocSetDoc.FKDocumentUID " +
                "    AND DocSetDoc.FKDocumentSetUID = DocSet.UID " +
                "    AND Document.UID = {0} " +
                "    AND DocSetDoc.FKDocumentSetUID = {1}",
                documentUID,
                documentSetUID);

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    MySqlDataReader reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        try
                        {
                            // Document
                            //
                            RepDocument.LoadDocumentFromReader(ret.document, "", reader);
                            //ret.document.UID = Convert.ToInt32(reader["DocumentUID"].ToString());
                            //ret.document.CUID = reader["DocumentCUID"].ToString();
                            //ret.document.Name = reader["DocumentName"].ToString();
                            //ret.document.SequenceNumber = Convert.ToInt32(reader["DocumentSequenceNumber"].ToString());
                            //ret.document.IssueNumber = Convert.ToInt32(reader["DocumentIssueNumber"].ToString());
                            //ret.document.Location = reader["DocumentLocation"].ToString();
                            //ret.document.Comments = reader["DocumentComments"].ToString();
                            //ret.document.FileName = reader["DocumentFileName"].ToString();
                            //ret.document.SourceCode = reader["DocumentSourceCode"].ToString();
                            //ret.document.FKClientUID = Convert.ToInt32(reader["DocumentFKClientUID"].ToString());
                            //ret.document.ParentUID = Convert.ToInt32(reader["DocumentParentUID"].ToString());
                            //ret.document.RecordType = reader["DocumentRecordType"].ToString();
                            //ret.document.IsProjectPlan = Convert.ToChar(reader["DocumentIsProjectPlan"]);
                            //ret.document.DocumentType = reader["DocumentDocumentType"].ToString();

                            // Document Set
                            //
                            ret.documentSet.UID            = Convert.ToInt32(reader["SetUID"].ToString());
                            ret.documentSet.TemplateType   = reader["SetTemplateType"].ToString();
                            ret.documentSet.TemplateFolder = reader["SetTemplateFolder"].ToString();
                            ret.documentSet.UIDNameDisplay = ret.documentSet.UID.ToString() +
                                                             "; " + ret.documentSet.TemplateType;

                            // DocumentSetDocument
                            //
                            ret.DocumentSetDocument.UID                    = Convert.ToInt32(reader["DocSetDocUID"].ToString());
                            ret.DocumentSetDocument.FKDocumentUID          = Convert.ToInt32(reader["DocSetDocFKDocumentUID"].ToString());
                            ret.DocumentSetDocument.FKDocumentSetUID       = Convert.ToInt32(reader["DocSetDocFKDocumentSetUID"].ToString());
                            ret.DocumentSetDocument.Location               = reader["DocSetDocLocation"].ToString();
                            ret.DocumentSetDocument.IsVoid                 = Convert.ToChar(reader["DocSetDocIsVoid"].ToString());
                            ret.DocumentSetDocument.StartDate              = Convert.ToDateTime(reader["DocSetDocStartDate"].ToString());
                            ret.DocumentSetDocument.EndDate                = Convert.ToDateTime(reader["DocSetDocEndDate"].ToString());
                            ret.DocumentSetDocument.FKParentDocumentUID    = Convert.ToInt32(reader["DocSetDocFKParentDocumentUID"].ToString());
                            ret.DocumentSetDocument.FKParentDocumentSetUID = Convert.ToInt32(reader["DocSetDocFKParentDocumentSetUID"].ToString());
                        }
                        catch
                        {
                        }
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Load folder into FCM Database and into FCM folder
        /// </summary>
        /// <param name="sourceFolder"></param>
        /// <param name="uioutput"></param>
        /// <param name="parentUID"></param>
        /// <param name="sequenceNumber"></param>
        /// <param name="headerInfo"></param>
        /// <returns></returns>
        static public ResponseStatus LoadFolder(string sourceFolder,
                                                IOutputMessage uioutput,
                                                int parentUID, int sequenceNumber, HeaderInfo headerInfo)
        {
            ResponseStatus response = new ResponseStatus();

            response.Message = "Folder loaded successfully.";

            if (!Directory.Exists(sourceFolder))
            {
                response.ReturnCode = -0010;
                response.ReasonCode = -0001;
                response.Message    = "Source folder does not exist.";
                response.UniqueCode = "E00.00.0001";
                response.Icon       = MessageBoxIcon.Error;
                return(response);
            }

            string[] folderNameSplit = sourceFolder.Split('\\');
            string   folderName      = folderNameSplit[folderNameSplit.Length - 1];

            uioutput.Activate();

            string[] files = Directory.GetFiles(sourceFolder);

            // Create folder that contains files and keep the parent
            //
            // ...
            Model.ModelDocument.Document folder = new Model.ModelDocument.Document();

            if (folderName.Length >= 7)
            {
                folder.CUID = folderName.Substring(0, 7);
            }
            else
            {
                folder.CUID = folderName;
            }

            folder.FileName    = folderName;
            folder.Comments    = "Loaded by batch";
            folder.Name        = folderName;
            folder.DisplayName = folderName;
            folder.FKClientUID = 0;
            folder.IssueNumber = 0;
            string refPath =
                MakHelperUtils.getReferenceFilePathName(sourceFolder);

            if (string.IsNullOrEmpty(refPath))
            {
                response.ReturnCode = -0010;
                response.ReasonCode = -0002;
                response.Message    = "Folder selected is not under managed template folder.";
                response.UniqueCode = "E00.00.0001";
                return(response);
            }

            folder.Location = refPath;
            // Store the folder being loaded at the root level
            //
            folder.Location       = MakConstant.SYSFOLDER.TEMPLATEFOLDER;
            folder.ParentUID      = parentUID;
            folder.SequenceNumber = 0;
            folder.SourceCode     = "FCM";
            folder.UID            = 0;
            folder.RecordType     = MakHelperUtils.RecordType.FOLDER;
            folder.DocumentType   = MakHelperUtils.DocumentType.FOLDER;
            folder.SimpleFileName = folder.Name;
            folder.FileExtension  = "FOLDER";
            folder.IsProjectPlan  = "N";

            // parentUID = folder.Save(headerInfo, MakHelperUtils.SaveType.NEWONLY);

            parentUID = RepDocument.Save(headerInfo, folder, MakHelperUtils.SaveType.NEWONLY);

            // Store each file
            //
            foreach (string file in files)
            {
                #region File Processing
                string name = Path.GetFileName(file);

                string fileName      = Path.GetFileNameWithoutExtension(file);
                string fileExtension = Path.GetExtension(file);

                string validExtensions = ".doc .docx .xls .xlsx .pdf .dotx";

                // Not every extension will be loaded
                //
                if (!validExtensions.Contains(fileExtension))
                {
                    continue;
                }


                string fileNameExt = Path.GetFileName(file);

                string simpleFileName = fileNameExt;
                if (fileNameExt.Length > 10)
                {
                    simpleFileName = fileNameExt.Substring(10).Trim();
                }

                Model.ModelDocument.Document document = new Model.ModelDocument.Document();
                document.CUID     = fileName.Substring(0, 6);
                document.FileName = fileNameExt;

                //string refPath =
                //        Utils.getReferenceFilePathName(sourceFolder);

                document.Location = refPath;
                string issue = "1";
                document.IssueNumber = Convert.ToInt32(issue);

                try
                {
                    issue = fileName.Substring(7, 2);
                    document.IssueNumber = Convert.ToInt32(issue);
                }
                catch (Exception ex)
                {
                    LogFile.WriteToTodaysLogFile(ex.ToString());
                }
                document.Name           = fileName;
                document.SimpleFileName = simpleFileName;
                document.DisplayName    = simpleFileName;
                document.SequenceNumber = sequenceNumber;
                document.ParentUID      = parentUID;

                document.Comments      = "Loaded via batch";
                document.SourceCode    = "FCM";
                document.FKClientUID   = 0;
                document.RecordType    = MakHelperUtils.RecordType.DOCUMENT;
                document.FileExtension = fileExtension;
                document.Status        = FCMUtils.FCMConstant.DocumentStatus.ACTIVE;
                document.IsProjectPlan = "N";

                switch (fileExtension)
                {
                case ".doc":
                    document.DocumentType = MakHelperUtils.DocumentType.WORD;
                    break;

                case ".docx":
                    document.DocumentType = MakHelperUtils.DocumentType.WORD;
                    break;

                case ".dotx":
                    document.DocumentType = MakHelperUtils.DocumentType.WORD;
                    break;

                case ".xls":
                    document.DocumentType = MakHelperUtils.DocumentType.EXCEL;
                    break;

                case ".xlsx":
                    document.DocumentType = MakHelperUtils.DocumentType.EXCEL;
                    break;

                case ".pdf":
                    document.DocumentType = MakHelperUtils.DocumentType.PDF;
                    break;

                default:
                    document.DocumentType = MakHelperUtils.DocumentType.UNDEFINED;
                    break;
                }

                // document.Save(headerInfo, MakHelperUtils.SaveType.NEWONLY);

                RepDocument.Save(headerInfo, document, MakHelperUtils.SaveType.NEWONLY);

                uioutput.AddOutputMessage(document.Name, "", userID);

                sequenceNumber++;
                #endregion File Processing
            }

            // Recursion removed
            //
            string[] folders = Directory.GetDirectories(sourceFolder);
            foreach (string directory in folders)
            {
                string name = Path.GetFileName(directory);
                LoadFolder(directory, uioutput, parentUID, 0, headerInfo);
            }

            return(response);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Delete document
 /// </summary>
 /// <param name="documentUID"></param>
 public static void DeleteDocument(int documentUID)
 {
     RepDocument.Delete(documentUID);
     return;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Set document to void
 /// </summary>
 /// <param name="documentUID"></param>
 public static void SetToVoid(int documentUID)
 {
     RepDocument.SetToVoid(documentUID);
     return;
 }
Exemplo n.º 24
0
        // -----------------------------------------------------
        //           Load documents in a tree
        // -----------------------------------------------------
        public static void ListInTree(
            TreeView fileList,
            DocumentLinkList documentList,
            Model.ModelDocument.Document root)
        {
            // Find root folder
            //
            Model.ModelDocument.Document rootDocument = new Model.ModelDocument.Document();

            rootDocument.CUID       = root.CUID;
            rootDocument.RecordType = root.RecordType;
            rootDocument.UID        = root.UID;
            // rootDocument.Read();

            rootDocument = RepDocument.Read(true, root.UID);

            // Create root
            //
            var rootNode = new TreeNode(rootDocument.Name, MakConstant.Image.Folder, MakConstant.Image.Folder);

            // Add root node to tree
            //
            fileList.Nodes.Add(rootNode);
            rootNode.Tag  = rootDocument;
            rootNode.Name = rootDocument.Name;

            foreach (var document in documentList.documentLinkList)
            {
                // Ignore root folder
                if (document.documentTo.CUID == "ROOT")
                {
                    continue;
                }

                // Check if folder has a parent
                string cdocumentUID = document.UID.ToString();
                string cparentIUID  = document.documentTo.ParentUID.ToString();

                int image = 0;

                document.documentTo.RecordType = document.documentTo.RecordType.Trim();

                image = Utils.ImageSelect(document.documentTo.RecordType);

                if (document.documentTo.ParentUID == 0)
                {
                    var treeNode = new TreeNode(document.documentTo.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.documentTo.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.documentTo.Name, image, image);
                        treeNode.Tag  = document;
                        treeNode.Name = cdocumentUID;

                        rootNode.Nodes.Add(treeNode);
                    }
                }
            }
        }
Exemplo n.º 25
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);
        }