Exemplo n.º 1
0
        // -------------------------------------------------------------------
        //                Saves TreeNode of a client tree
        // -------------------------------------------------------------------
        private static TreeNode SaveTreeNodeToClient(TreeNode treeNode, int parentID, ClientDocumentSet clientDocumentSet)
        {
            TreeNode       ret  = new TreeNode();
            ClientDocument cdsl = new ClientDocument();

            var t = treeNode.Tag.GetType();

            // If the type is not document, it is an existing document
            //
            // var documentLink = new FCMStructures.scClientDocSetDocLink();
            var documentLink = new scClientDocSetDocLink();

            if (t.Name == "scClientDocSetDocLink")
            {
                documentLink = (scClientDocSetDocLink)treeNode.Tag;
                documentLink.clientDocument.SequenceNumber = treeNode.Index;
            }

            //
            // If the type is Document, it means a new document added to the client
            // list
            //
            if (t.Name == "Document")
            #region Document
            {
                documentLink.document = new Model.ModelDocument.Document();
                documentLink.document = (Model.ModelDocument.Document)treeNode.Tag;

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

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

                documentLink.clientDocument.EndDate = System.DateTime.MaxValue;
                documentLink.clientDocument.FKClientDocumentSetUID = clientDocumentSet.ClientSetID; // Utils.ClientSetID;
                documentLink.clientDocument.FKClientUID            = clientDocumentSet.FKClientUID; //Utils.ClientID;
                if (clientDocumentSet.FKClientUID <= 0)
                {
                    MessageBox.Show("Client ID not supplied.");
                    return(null);
                }
                documentLink.clientDocument.FKDocumentUID     = documentLink.document.UID;
                documentLink.clientDocument.Generated         = 'N';
                documentLink.clientDocument.SourceIssueNumber = documentLink.document.IssueNumber;
                documentLink.clientDocument.ClientIssueNumber = 00;

                // When the source is client, the name will have already all the numbers
                //
                //if (documentLink.document.SourceCode == Utils.SourceCode.CLIENT)
                //{
                //    documentLink.clientDocument.ComboIssueNumber = documentLink.document.CUID;
                //}
                //else
                //{

                //}

                if (documentLink.document.RecordType == Utils.RecordType.FOLDER)
                {
                    documentLink.clientDocument.ComboIssueNumber = documentLink.document.CUID;
                    documentLink.clientDocument.FileName         = documentLink.document.SimpleFileName;
                }
                else
                {
                    documentLink.clientDocument.ComboIssueNumber =
                        RepClientDocument.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 = destFolder.clientDocument.UID;
                documentLink.clientDocument.ParentUID = parentID;

                //  documentLink.clientDocument.Location = txtDestinationFolder.Text +
                //                                         Utils.GetClientPathInside(documentLink.document.Location);

                documentLink.clientDocument.Location = GetClientDocumentLocation(parentID);

                documentLink.clientDocument.RecordType     = documentLink.document.RecordType;
                documentLink.clientDocument.SequenceNumber = treeNode.Index;
                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          = clientDocumentSet.ClientSetID; // clientDocumentSet.UID; // Utils.ClientSetID;
                documentLink.clientDocumentSet.SourceFolder = clientDocumentSet.SourceFolder;
                documentLink.clientDocumentSet.ClientSetID  = clientDocumentSet.ClientSetID; // Utils.ClientSetID;
                documentLink.clientDocumentSet.FKClientUID  = clientDocumentSet.FKClientUID;
                documentLink.clientDocumentSet.Folder       = clientDocumentSet.Folder;
            }
            #endregion Document

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

            documentLink.clientDocument.UID = RepClientDocument.LinkDocumentToClientSet(documentLink);

            foreach (TreeNode children in treeNode.Nodes)
            {
                SaveTreeNodeToClient(children, documentLink.clientDocument.UID, clientDocumentSet);
            }


            return(ret);
        }
Exemplo n.º 2
0
 public static string GetComboIssueNumber(string documentCUID, int documentVersionNumber, int clientUID)
 {
     return(RepClientDocument.GetComboIssueNumber(documentCUID,
                                                  documentVersionNumber,
                                                  clientUID));
 }