// --------------------------------------------------------- // Copy document links to client document links // --------------------------------------------------------- public void ReplicateDocLinkToClientDeprecated(int ClientUID, int ClientSetUID) { // 1... GetClientDocument // List documents for a Client Set Document // var clientDocumentList = new ClientDocument(); // clientDocumentList.List(ClientUID, ClientSetUID); RepClientDocument.List(clientDocumentList, ClientUID, ClientSetUID); // 2... foreach( clientDocument ) // For each client document, retrieve the linked documents // foreach (var clientDocument in clientDocumentList.clientDocSetDocLink) { // 3...... GetDocumentChildren( currentClientDocument) // This part retrieves Document Links and not ClientDocument Links // that's why we need to get the equivalent ClientDocumentUID... var children = DocumentLinkList.ListRelatedDocuments(clientDocument.document.UID); // 4...... foreach (GetDocumentChildren) foreach (var child in children.documentLinkList) { // 5..... CreateClientDocumentLink(Client,ClientSet,DocumentParent,DocumentChild, Type) ClientDocumentLink newLink = new ClientDocumentLink(); // This is the client document UID newLink.FKParentDocumentUID = clientDocument.clientDocument.UID; // Get clientUID for child document ClientDocument childDocument = new ClientDocument(); //childDocument.FKDocumentUID = child.UID; childDocument.FKDocumentUID = child.documentTo.UID; // childDocument.Find(child.documentTo.UID, clientDocument.clientDocumentSet.UID, 'N', ClientUID); childDocument = RepClientDocument.Find(child.documentTo.UID, clientDocument.clientDocumentSet.UID, 'N', ClientUID); if (childDocument.UID > 0) { newLink.FKChildDocumentUID = childDocument.UID; newLink.LinkType = child.LinkType; // Replace by link type newLink.Add(); } } } //using (var connection = new MySqlConnection(ConnString.ConnectionString)) //{ // var commandString = string.Format( // " SELECT " + // " UID " + // " FROM ClientDocument " + // " WHERE " + // " FKClientUID = {0} " + // " AND FKClientDocumentSetUID = {1} ", // ClientUID, // ClientSetUID // ); // using (var command = new MySqlCommand( // commandString, connection)) // { // connection.Open(); // using (MySqlDataReader reader = command.ExecuteReader()) // { // while (reader.Read()) // { // int ClientDocumentUID; // ClientDocumentUID = Convert.ToInt32(reader["UID"].ToString()); // } // } // } //} }
/// <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()); }