Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        // ------------------------------------------
        //            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();
        }
Ejemplo n.º 3
0
        public static ResponseStatus AddDocumentToSet(HeaderInfo headerInfo, int documentSetUID, int documentUID)
        {
            // Find Document
            //
            DocumentReadRequest documentReadRequest = new DocumentReadRequest();

            documentReadRequest.headerInfo = headerInfo;
            documentReadRequest.retrieveVoidedDocuments = false;
            documentReadRequest.UID = documentUID;

            var documentReadResponse = BUSDocument.DocumentRead(documentReadRequest);
            var documentSelected     = new Document();

            documentSelected = documentReadResponse.document;

            // Find parent of the document
            //
            var folderReadRequestParent = new DocumentReadRequest();

            folderReadRequestParent.headerInfo = headerInfo;
            folderReadRequestParent.retrieveVoidedDocuments = false;
            folderReadRequestParent.UID = documentSelected.ParentUID; // Reading parent

            var folderParentResponse = BUSDocument.DocumentRead(folderReadRequestParent);
            var folderParent         = new Document();

            folderParent = folderParentResponse.document;

            // Find DocumentSet
            //
            var documentSet = new DocumentSet();

            documentSet.UID = documentSetUID;
            documentSet.Read('N');

            // Create link
            //
            DocumentSetDocument dsd = new DocumentSetDocument();

            dsd.FKDocumentSetUID = documentSet.UID;
            dsd.FKDocumentUID    = documentSelected.UID;
            dsd.EndDate          = System.DateTime.MaxValue;
            dsd.StartDate        = System.DateTime.Today;
            dsd.UID                    = 0;
            dsd.Location               = documentSelected.Location;
            dsd.SequenceNumber         = 1;
            dsd.IsVoid                 = 'N';
            dsd.FKParentDocumentSetUID = documentSet.UID;
            dsd.FKParentDocumentUID    = folderReadRequestParent.UID; // Is this the ID of the parent on the document table or the id of the document on this table?

            dsd.Add();


            return(new ResponseStatus());
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        private void fixDocumentLocation(TreeNode tn)
        {
            if (tn.Tag == null)
            {
                return;
            }

            Document document = (Document)tn.Tag;

            if (document.RecordType == "FOLDER")
            {
                foreach (TreeNode node in tn.Nodes)
                {
                    fixDocumentLocation(node);
                }
            }

            var drr = new DocumentReadRequest();

            drr.UID = document.UID;

            var docread = BUSDocument.DocumentRead(drr);

            var documentSaveRequest = new DocumentSaveRequest();

            documentSaveRequest.inDocument = docread.document;

            documentSaveRequest.inDocument.Name =
                UIHelper.ClientDocumentUIHelper.SetDocumentName(
                    documentSaveRequest.inDocument.SimpleFileName,
                    documentSaveRequest.inDocument.IssueNumber.ToString(),
                    documentSaveRequest.inDocument.CUID,
                    documentSaveRequest.inDocument.RecordType,
                    documentSaveRequest.inDocument.FileName);

            documentSaveRequest.headerInfo = HeaderInfo.Instance;
            documentSaveRequest.saveType   = FCMConstant.SaveType.UPDATE;

            var resp = BUSDocument.DocumentSave(documentSaveRequest);

            tn.Tag = resp.document;
        }
Ejemplo n.º 6
0
        private void btnFixLocation_Click(object sender, EventArgs e)
        {
            int documentUID = Convert.ToInt32(txtUID.Text);
            var drr         = new DocumentReadRequest();

            drr.UID = documentUID;

            var docread = BUSDocument.DocumentRead(drr);

            if (docread.document.RecordType == "FOLDER")
            {
                return;
            }

            var documentSaveRequest = new DocumentSaveRequest();

            documentSaveRequest.inDocument      = docread.document;
            documentSaveRequest.inDocument.Name =
                UIHelper.ClientDocumentUIHelper.SetDocumentName(
                    documentSaveRequest.inDocument.SimpleFileName,
                    documentSaveRequest.inDocument.IssueNumber.ToString(),
                    documentSaveRequest.inDocument.CUID,
                    documentSaveRequest.inDocument.RecordType,
                    documentSaveRequest.inDocument.FileName);
            documentSaveRequest.headerInfo = HeaderInfo.Instance;
            documentSaveRequest.saveType   = FCMConstant.SaveType.UPDATE;

            var resp = BUSDocument.DocumentSave(documentSaveRequest);

            txtLocation.Text = resp.document.Location;
            txtName.Text     = resp.document.Name;

            TreeNode tndocSelected = tvFileList.SelectedNode;

            if (tndocSelected != null)
            {
                if (tndocSelected.Tag.GetType().Name == "Document")
                {
                    tndocSelected.Tag = resp.document;
                }
            }
        }
Ejemplo n.º 7
0
        // -----------------------------------------------------
        //           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);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Add FCM document to Client Set
        /// </summary>
        /// <param name="headerInfo"></param>
        /// <param name="clientUID"></param>
        /// <param name="clientDocumentSetUID"></param>
        /// <param name="documentUID"></param>
        /// <returns></returns>
        public static ResponseStatus AddDocumentToSet(HeaderInfo headerInfo, int clientUID, int clientDocumentSetUID, int documentUID)
        {
            string sourceFolder      = "";
            string destinationFolder = "";


            if (clientUID <= 0)
            {
                return new ResponseStatus {
                           Message = "Client UID was not supplied.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0001
                }
            }
            ;

            if (clientDocumentSetUID <= 0)
            {
                return new ResponseStatus {
                           Message = "Client Document Set UID  was not supplied.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0002
                }
            }
            ;

            if (documentUID <= 0)
            {
                return new ResponseStatus {
                           Message = "Document UID  was not supplied.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0003
                }
            }
            ;

            // Find Document
            //
            DocumentReadRequest documentReadRequest = new DocumentReadRequest();

            documentReadRequest.headerInfo = headerInfo;
            documentReadRequest.retrieveVoidedDocuments = false;
            documentReadRequest.UID = documentUID;

            var documentReadResponse = BUSDocument.DocumentRead(documentReadRequest);
            var documentSelected     = new Document();

            documentSelected = documentReadResponse.document;

            // Find parent of the document
            //
            var folderReadRequestParent = new DocumentReadRequest();

            folderReadRequestParent.headerInfo = headerInfo;
            folderReadRequestParent.retrieveVoidedDocuments = false;
            folderReadRequestParent.UID = documentSelected.ParentUID; // Reading parent

            var folderParentResponse = BUSDocument.DocumentRead(folderReadRequestParent);
            var folderParent         = new Document();

            folderParent = folderParentResponse.document;

            // Find the equivalent parent in ClientDocumentSetDocument
            //
            var foundParent = RepClientDocument.Find(folderParent.UID, clientDocumentSetUID, 'N', clientUID);

            if (foundParent.UID <= 0)
            {
                return new ResponseStatus {
                           Message = "Parent folder not found.", XMessageType = MessageType.Error, ReturnCode = -0020, ReasonCode = 0006
                }
            }
            ;

            // Find ClientDocumentSet
            //
            var clientDocumentSet = new ClientDocumentSet();

            clientDocumentSet.UID         = clientDocumentSetUID;
            clientDocumentSet.FKClientUID = clientUID;
            clientDocumentSet.Read();

            if (clientDocumentSet.UID <= 0)
            {
                return new ResponseStatus {
                           Message = "Client Document Set not found.", XMessageType = MessageType.Error, ReturnCode = -0030, ReasonCode = 0004
                }
            }
            ;

            // Create link
            //
            var documentLink = new scClientDocSetDocLink();

            if (documentSelected.RecordType == "DOCUMENT")
            #region Document
            {
                documentLink.document = new Document();

                documentLink.document = documentSelected;

                documentLink.clientDocument    = new ClientDocument();
                documentLink.clientDocumentSet = new ClientDocumentSet();

                // Fill in the extra details...
                //

                documentLink.clientDocument.EndDate = System.DateTime.MaxValue;
                documentLink.clientDocument.FKClientDocumentSetUID = clientDocumentSet.UID;
                documentLink.clientDocument.FKClientUID            = clientDocumentSet.FKClientUID;
                documentLink.clientDocument.FKDocumentUID          = documentLink.document.UID;
                documentLink.clientDocument.Generated         = 'N';
                documentLink.clientDocument.SourceIssueNumber = documentLink.document.IssueNumber;
                documentLink.clientDocument.ClientIssueNumber = 00;

                if (documentLink.document.RecordType == FCMConstant.RecordType.FOLDER)
                {
                    documentLink.clientDocument.ComboIssueNumber = documentLink.document.CUID;
                    documentLink.clientDocument.FileName         = documentLink.document.SimpleFileName;
                }
                else
                {
                    documentLink.clientDocument.ComboIssueNumber =
                        BUSClientDocument.GetComboIssueNumber(documentLink.document.CUID,
                                                              documentLink.document.IssueNumber,
                                                              clientDocumentSet.FKClientUID);


                    documentLink.clientDocument.FileName = documentLink.clientDocument.ComboIssueNumber + " " +
                                                           documentLink.document.SimpleFileName;
                }
                documentLink.clientDocument.IsProjectPlan = documentLink.document.IsProjectPlan;
                documentLink.clientDocument.DocumentCUID  = documentLink.document.CUID;
                documentLink.clientDocument.DocumentType  = documentLink.document.DocumentType;
                // The client document location includes the client path (%CLIENTFOLDER%) plus the client document set id
                // %CLIENTFOLDER%\CLIENTSET201000001R0001\


                // How to identify the parent folder
                //
                documentLink.clientDocument.ParentUID = foundParent.UID;

                // Daniel
                // 01-Jul-2013
                // Retrieving the clientdocument parent using the UID for the parent clientdocument
                //
//                documentLink.clientDocument.Location = BUSClientDocument.GetClientDocumentLocation(folderReadRequestParent.UID);
                documentLink.clientDocument.Location = BUSClientDocument.GetClientDocumentLocation(foundParent.UID);

                documentLink.clientDocument.RecordType     = documentLink.document.RecordType;
                documentLink.clientDocument.SequenceNumber = 1;
                documentLink.clientDocument.SourceFileName = documentLink.document.FileName;
                documentLink.clientDocument.SourceLocation = documentLink.document.Location;

                documentLink.clientDocument.StartDate = System.DateTime.Today;
                documentLink.clientDocument.UID       = 0;

                documentLink.clientDocumentSet.UID          = clientDocumentSetUID;
                documentLink.clientDocumentSet.SourceFolder = sourceFolder;
                documentLink.clientDocumentSet.ClientSetID  = clientDocumentSet.UID;
                documentLink.clientDocumentSet.FKClientUID  = clientDocumentSet.FKClientUID;
                documentLink.clientDocumentSet.Folder       = destinationFolder;
            }
            #endregion Document

            // Save link to database
            //
            // documentLink.clientDocument.UID = cdsl.LinkDocumentToClientSet(documentLink);

            documentLink.clientDocument.UID = LinkDocumentToClientSet(documentLink);

            return(new ResponseStatus());
        }