private bool MapDocumentToEfolder(Loan loan, BlendDocReturned document, TrackedDocument eFolder) { string docId = document.Id; try { var url = WcmSettings.GetDocumentFromBlendUri; GetDocumentResponse docResponse = BlendUtility.GetDocumentFromBlendPortal(docId, url); var data = new EllieMae.Encompass.BusinessObjects.DataObject(docResponse.DocumentData); EllieMae.Encompass.BusinessObjects.Loans.Attachment attachment = loan.Attachments.AddObject(data, ".pdf"); attachment.Title = $"{document.Name}"; eFolder.Attach(attachment); // once attached go update the export status var uri = WcmSettings.UpdateDocExportStatusBlendUri; var updateRequest = new UpdateDocumentExportStatusRequest() { BlendDocumentId = docId, UtcDocumentExportTime = DateTime.UtcNow.ToShortDateString() }; var requestTest = Newtonsoft.Json.JsonConvert.SerializeObject(updateRequest); var updateResponse = BlendUtility.PostDocumentExportStatusUpdate(updateRequest, uri); } catch (Exception ex) { Macro.Alert($"Error mapping {document.Name} to eFolder. Please submit a Help Desk Ticket." + Environment.NewLine + $"Error Message: {ex.Message}"); return(false); } return(true); }
private bool PostPreliminaryTitleOrderDocsToSilk(Loan loan, string orderId, out string msgForUser) { string docName = ""; string postDocToSilkUri = SilkSettings.PostDocToSilkUrl; //grab 1003 and title quote from eFolder List <B64SilkDocument> docsToPost = new List <B64SilkDocument>(); int bpCount = loan.BorrowerPairs.Count; //if borrower pair count is greater than 1 we need to grab all 1003s on the file - otherwise just want to get the latest attachment if (bpCount > 1) { List <Attachment> signed1003 = GetAttachmentForEachBorrowerPair(loan, "Disclosures - Signed 1003"); if (signed1003 == null) { throw new Exception("Error posting 1003 to Silk. Document is not in File!"); } foreach (var att in signed1003) { B64SilkDocument doc = new B64SilkDocument { Name = att.Title + ".pdf", Base64EncodedSilkDocument = Convert.ToBase64String(att.DataOriginal), FieldIdToSet = loan.Fields["CX.SILK.1003.UPLOAD.DATE"], Type = "1003" }; docsToPost.Add(doc); } } else { Attachment signed1003 = SilkUtility.GetLatestAttachment(loan, "Disclosures - Signed 1003", docName); if (signed1003 == null) { throw new Exception("Error posting 1003 to Silk. Document is not in File!"); } B64SilkDocument doc = new B64SilkDocument { Name = signed1003.Title + ".pdf", Base64EncodedSilkDocument = Convert.ToBase64String(signed1003.DataOriginal), FieldIdToSet = loan.Fields["CX.SILK.1003.UPLOAD.DATE"], Type = "1003" }; docsToPost.Add(doc); } Attachment titleQuoteFromEncompass = SilkUtility.GetLatestAttachment(loan, "Title Fee Estimate", docName); if (titleQuoteFromEncompass == null) { throw new Exception("Error posting Tax Quote to Silk. Document is not in File!"); } B64SilkDocument titleQuote = new B64SilkDocument { Name = titleQuoteFromEncompass.Title, Base64EncodedSilkDocument = Convert.ToBase64String(titleQuoteFromEncompass.DataOriginal), FieldIdToSet = loan.Fields["CX.SILK.FEE.UPLOAD.DATE"], Type = "Estimated Title Fees" }; docsToPost.Add(titleQuote); foreach (B64SilkDocument doc in docsToPost) { var docRequest = SilkUtility.MapLoanToPostSilkDocumentRequest(loan, doc, orderId); var docResponse = SilkUtility.PostDocumentToSilk(postDocToSilkUri, docRequest); if (!docResponse.WasSuccessful) { //need to do something if not successful loan.Fields["CX.SILK.DOC.UPLOAD.ERRORMSG"].Value = docResponse.ErrorMessage; msgForUser = docResponse.ErrorMessage; return(false); } doc.FieldIdToSet.Value = DateTime.Now; } msgForUser = "******"; return(true); }