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()); }
/// <summary> /// Update or Create document /// </summary> /// <returns></returns> public static Document DocumentCreate(HeaderInfo headerInfo, string filename, string filelocation, int parentUID, string recordtype = "DOCUMENT") { string documenttype = "WORD"; // Just setting as initial value Document document = new Document(); document.ParentUID = parentUID; document.CUID = filename.Substring(0, 6); document.Location = filelocation; document.Location = Utils.getReferenceFilePathName(filelocation); document.DisplayName = filename.Substring(10); // Starts after HRM-01-01 HERExxxxxxxx document.SimpleFileName = filename.Substring(10); // Starts after HRM-01-01 HERExxxxxxxx document.Name = filename; var filesplit = filename.Split('.'); document.FileExtension = String.Concat("." + filesplit[1]); document.FileName = filename; document.RecordType = recordtype; string wordExtensions = ".doc .docx .dotx"; string excelExtensions = ".xls .xlsx"; string pdfExtensions = ".pdf"; // Not every extension will be loaded // if (wordExtensions.Contains(document.FileExtension)) { documenttype = "WORD"; } if (excelExtensions.Contains(document.FileExtension)) { documenttype = "EXCEL"; } if (pdfExtensions.Contains(document.FileExtension)) { documenttype = "PDF"; } document.DocumentType = documenttype; document.SequenceNumber = 1; document.IssueNumber = 1; document.SourceCode = "FCM"; document.Status = "ACTIVE"; document.Skip = "N"; document.IsVoid = "N"; document.IsProjectPlan = "N"; document.FKClientUID = 0; document.Comments = "Web Upload"; var documentSaveRequest = new DocumentSaveRequest(); documentSaveRequest.inDocument = document; documentSaveRequest.headerInfo = headerInfo; var docresp = BUSDocument.DocumentSave(documentSaveRequest); if (docresp.response.ReturnCode <= 0) { LogFile.WriteToTodaysLogFile(docresp.response.Message); } document = docresp.document; return(document); }