/// <summary> /// returns the guid for a given loan_number, using Encompass's search function /// </summary> /// <param name="session">an active Encompass session</param> /// <param name="loan_number">loan number of the loan</param> /// <returns>the guid (as a string) or String.Empty if not found.</returns> public static string GetGuidForLoanNumber(Session session, string loan_number) { StringFieldCriterion sfc = new StringFieldCriterion("Loan.LoanNumber", loan_number, StringFieldMatchType.Exact, true); LoanIdentityList loanList = session.Loans.Query(sfc); string guid = String.Empty; //Loan.LoanNumber SHOULD be unique, but there is a timing bug //If multiple loans found, retun the last one foreach (LoanIdentity id in loanList) { guid = id.Guid; } return(guid); }
public static IList <string> LoansLastModifiedBetween(Session session, QueryCriterion criterion) { IList <string> loans = new List <string>(); try { LoanIdentityList loanList = session.Loans.Query(criterion); foreach (LoanIdentity id in loanList) { loans.Add(id.Guid); } } catch { //noop } return(loans); }
/// <summary> /// Entry point for the SDK Application /// </summary> static void Main(string[] args) { // Start the Encompass Session using a user's credentials Session session = new Session(); session.Start( String.Format("https://{0}.ea.elliemae.net${0}", ConfigurationManager.AppSettings["InstanceID"]), ConfigurationManager.AppSettings["UserID"], ConfigurationManager.AppSettings["Password"] ); // Query for a Loan StringFieldCriterion cri = new StringFieldCriterion() { FieldName = "Loan.LoanNumber", Value = "1801EM000070" }; // Run the query to get the Loan Identifier LoanIdentityList loanIds = session.Loans.Query(cri); if (loanIds.Count != 1) { Console.WriteLine("Loan number did not return a unique match"); return; } // Open and lock the Loan string loanGuid = loanIds[0].Guid; using (Loan loan = session.Loans.Open(loanGuid, true, true)) { loan.Fields["1887"].Value = DateTime.Today; loan.Commit(); loan.Unlock(); } // Close the session session.End(); }
public static void Main() { // Open the session to the remote server Session session = new Session(); session.Start("myserver", "mary", "maryspwd"); // Build the query criterion for all loans that were opened this year DateFieldCriterion dateCri = new DateFieldCriterion(); dateCri.FieldName = "Loan.DateFileOpened"; dateCri.Value = DateTime.Now; dateCri.Precision = DateFieldMatchPrecision.Year; // Perform the query to get the IDs of the loans LoanIdentityList ids = session.Loans.Query(dateCri); // Create a list of the specific fields we want to print from each loan. // In this case, we'll select the Loan Amount and Interest Rate. StringList fieldIds = new StringList(); fieldIds.Add("2"); // Loan Amount fieldIds.Add("3"); // Rate // For each loan, select the desired fields foreach (LoanIdentity id in ids) { // Select the field values for the current loan StringList fieldValues = session.Loans.SelectFields(id.Guid, fieldIds); // Print out the returned values Console.WriteLine("Fields for loan " + id.ToString()); Console.WriteLine("Amount: " + fieldValues[0]); Console.WriteLine("Rate: " + fieldValues[1]); } // End the session to gracefully disconnect from the server session.End(); }
private List <LoanActionResult> UnassignRole(IProgress <string> progress, Role roleSelected, List <string> loanNumbersToUnassign) { List <LoanActionResult> response = new List <LoanActionResult>(); int count = 0; foreach (var loanNumber in loanNumbersToUnassign) { count++; string loanProgress = $"{count}/{loanNumbersToUnassign.Count}. {loanNumber}."; progress.Report($"{loanProgress} Searching for loan.."); var loanResult = new LoanActionResult() { WasSuccessful = true }; try { StringFieldCriterion loanNumberCri = new StringFieldCriterion(); loanNumberCri.FieldName = "Loan.LoanNumber"; loanNumberCri.Value = loanNumber; loanNumberCri.MatchType = StringFieldMatchType.Exact; loanNumberCri.Include = true; QueryCriterion fullQuery = loanNumberCri; LoanIdentityList ids = EncompassApplication.Session.Loans.Query(fullQuery); if (ids.Count == 0) // if no loans found { progress.Report($"{loanProgress} Cannot find loan."); loanResult.Result = $"Cannot find loan";; response.Add(loanResult); // logger.Info((rowIndex - 1) + "/" + (rowCount - 1) + ". Cannot find loan number \"" + loanNumberCri + "\". Going to next."); continue; // skip the remainder of this iteration } //logger.Info((rowIndex - 1) + "/" + (rowCount - 1) + ". Opening loan guid: " + ids[0].Guid); progress.Report($"{loanProgress} Opening loan.."); Loan currentLoan = EncompassApplication.Session.Loans.Open(ids[0].Guid); loanResult.LoanNumber = currentLoan.LoanNumber; if (currentLoan.GetCurrentLocks().Count > 0) { string msg = $"Loan opened by {currentLoan.GetCurrentLock().LockedBy}"; progress.Report($"{loanProgress} {msg}"); loanResult.Result = msg; response.Add(loanResult); //loanSummaryCell.Value = $"Loan opened by {currentLoan.GetCurrentLock().LockedBy}"; currentLoan.Close(); continue; } currentLoan.Lock(); bool needToSaveLoan = false; string userName = ""; foreach (LoanAssociate loanAssociate in currentLoan.Associates) { if (loanAssociate.WorkflowRole == roleSelected) { if (loanAssociate.User != null) { userName = loanAssociate.User.FullName; loanAssociate.Unassign(); needToSaveLoan = true; } } } if (needToSaveLoan) { string msg = $"'{roleSelected.Name}' role successfully unassigned"; progress.Report($"{loanProgress} {msg}. Saving..."); currentLoan.Commit(); loanResult.Result = msg; } else { string msg = $"'{roleSelected.Name}' role not found on loan"; progress.Report($"{loanProgress} {msg}."); loanResult.Result = msg; } currentLoan.Close(); } catch (Exception ex) { loanResult.WasSuccessful = false; progress.Report($"{loanProgress} ERROR HIT {ex.ToString()}."); loanResult.ErrorMessage = ex.ToString(); } response.Add(loanResult); } return(response); }
private static void ConditionReport(string SellerID, string LimitedSet, string newFileName) { try { //login to server Session session = new Session(); session.Start("https://be11147937.ea.elliemae.net$be11147937", "sdkreport", "CqR3Fdt3LTKwVKCr"); using (session) { //build loan query DateFieldCriterion tpoSubmitted = new DateFieldCriterion(); tpoSubmitted.FieldName = "Fields.TPO.X90"; tpoSubmitted.Value = DateFieldCriterion.NonEmptyDate; tpoSubmitted.MatchType = OrdinalFieldMatchType.Equals; tpoSubmitted.Precision = DateFieldMatchPrecision.Exact; StringFieldCriterion sellerID = new StringFieldCriterion(); sellerID.FieldName = "Fields.TPO.X15"; sellerID.Value = SellerID; sellerID.MatchType = StringFieldMatchType.Exact; if (SellerID.ToUpper().Equals("ALL")) { sellerID.Value = ""; sellerID.Include = false; } else { sellerID.Include = true; } NumericFieldCriterion allCondCount = new NumericFieldCriterion(); allCondCount.FieldName = "Fields.UWC.ALLCOUNT"; allCondCount.Value = 0; allCondCount.MatchType = OrdinalFieldMatchType.GreaterThan; StringFieldCriterion msPurchaseAC = new StringFieldCriterion(); msPurchaseAC.FieldName = "Fields.Log.MS.Status.Purchase - AC"; msPurchaseAC.Value = "Achieved"; msPurchaseAC.MatchType = StringFieldMatchType.Contains; msPurchaseAC.Include = false; StringFieldCriterion loanFolder = new StringFieldCriterion(); loanFolder.FieldName = "Loan.LoanFolder"; loanFolder.Value = "Corr. Active"; loanFolder.MatchType = StringFieldMatchType.Exact; loanFolder.Include = true; QueryCriterion query = loanFolder.And(sellerID.And(allCondCount.And(tpoSubmitted.And(msPurchaseAC)))); //get loans LoanIdentityList ids = session.Loans.Query(query); Console.WriteLine("Found " + ids.Count + " loans"); if (ids.Count > 0) { //Found Loans build Excel file FileInfo newFile = new FileInfo(@"output\" + newFileName); if (newFile.Exists) { newFile.Delete(); newFile = new FileInfo(@"output\"+newFileName); } using (ExcelPackage package = new ExcelPackage(newFile)) { //add a new worksheet ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Conditions"); //write header row worksheet.Cells["A1"].Value = "Seller Name"; worksheet.Cells["B1"].Value = "Seller Loan Num"; worksheet.Cells["C1"].Value = "DH Loan Num"; worksheet.Cells["D1"].Value = "Borrower Name"; worksheet.Cells["E1"].Value = "Property State"; worksheet.Cells["F1"].Value = "Loan Purpose"; worksheet.Cells["G1"].Value = "Occupancy"; worksheet.Cells["H1"].Value = "Last Finished Milestone"; worksheet.Cells["I1"].Value = "Last Finished Milestone Date"; worksheet.Cells["J1"].Value = "Date Condition Added"; worksheet.Cells["K1"].Value = "Condition Status"; worksheet.Cells["L1"].Value = "Condition Type"; worksheet.Cells["M1"].Value = "Condition Title"; worksheet.Cells["N1"].Value = "Condition Details"; worksheet.Cells["O1"].Value = "Added By"; worksheet.Cells["P1"].Value = "For Intenal Use"; worksheet.Cells["Q1"].Value = "For External Use"; int row = 2; foreach (LoanIdentity id in ids) { Loan loan = session.Loans.Open(id.Guid); LogUnderwritingConditions conds = loan.Log.UnderwritingConditions; //we only want the report to contain loans with conditions if (conds.Count > 0) { var ClosedList = new List<ConditionStatus> { (ConditionStatus)7, (ConditionStatus)8, (ConditionStatus)12 }; Console.WriteLine("Found " + conds.Count + " total conditions in Loan: " + loan.LoanNumber); if (LimitedSet.ToUpper().Equals("LIMITED")) { Console.WriteLine("Only Pulling Open Conditions"); } foreach (UnderwritingCondition cond in conds) { if (LimitedSet.ToUpper().Equals("ALL") || (!LimitedSet.ToUpper().Equals("ALL") && !ClosedList.Contains(cond.Status))) { //fill in row details here worksheet.Cells[row, 1].Value = loan.Fields["TPO.X14"]; worksheet.Cells[row, 2].Value = loan.Fields["CX.DH.SELLERLOANNUM"]; worksheet.Cells[row, 3].Value = loan.Fields["364"]; worksheet.Cells[row, 4].Value = loan.Fields["4002"] + ", " + loan.Fields["4000"]; worksheet.Cells[row, 5].Value = loan.Fields["14"]; worksheet.Cells[row, 6].Value = loan.Fields["19"]; worksheet.Cells[row, 7].Value = loan.Fields["1811"]; worksheet.Cells[row, 8].Value = loan.Fields["LOG.MS.LASTCOMPLETED"]; worksheet.Cells[row, 9].Value = loan.Fields["MS.STATUSDATE"].ToDate().Date; worksheet.Cells[row, 10].Value = cond.DateAdded.Date; worksheet.Cells[row, 11].Value = cond.Status.ToString(); worksheet.Cells[row, 12].Value = cond.PriorTo.ToString(); worksheet.Cells[row, 13].Value = cond.Title.ToString(); worksheet.Cells[row, 14].Value = cond.Description.ToString().Replace("\"", "'"); worksheet.Cells[row, 15].Value = cond.AddedBy.ToString(); worksheet.Cells[row, 16].Value = cond.ForInternalUse.ToString(); worksheet.Cells[row, 17].Value = cond.ForExternalUse.ToString(); row++; } } row++; } } //format range as table var range = worksheet.Cells[1, 1, row - 2, 17]; var xltable = worksheet.Tables.Add(range, null); xltable.TableStyle = TableStyles.Medium14; //finish up worksheet worksheet.Cells.AutoFitColumns(0); worksheet.Column(9).Style.Numberformat.Format = "m/d/yyyy"; worksheet.Column(10).Style.Numberformat.Format = "m/d/yyyy"; worksheet.Column(14).Style.WrapText = true; worksheet.PrinterSettings.RepeatRows = worksheet.Cells["1:1"]; worksheet.View.PageLayoutView = false; worksheet.View.PageLayoutView = false; //finish up package package.Save(); } } } } catch (Exception ex) { Console.WriteLine("Unknown Error:"); Console.WriteLine("\r\n\r\n{0}", ex); } } // End ConditionReport