Example #1
0
        /// <summary>
        /// Retrieve the parent folder for a given document
        /// </summary>
        /// <returns></returns>
        public static string GetClientDocumentLocation(int clientDocumentUID)
        {
            string ret            = "";
            var    clientDocument = BUSClientDocument.ClientDocumentReadS(clientDocumentUID);

            if (clientDocument.UID > 0)
            {
                //  This is to prevent the first level from taking an extra \\ at the front
                // it was causing the folder to be like \\%CLIENTFOLDER%\\
                // At the end the client folder was replace by a physical path
                // and it appears like "\\c:\\fcm\\document\\"

                clientDocument.Location = clientDocument.Location.Trim();

                if (string.IsNullOrEmpty(clientDocument.Location))
                {
                    ret = clientDocument.FileName;
                }
                else
                {
                    ret = clientDocument.Location + "\\" + clientDocument.SourceFileName;
                }

                // ret = clientDocument.Location + "\\" + clientDocument.FileName;
            }
            return(ret);
        }
Example #2
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());
        }