brw59 brw59 -3 years ago 146
C# Question

Get field data outside of reporting database using Encompass360 SDK

I'm trying to build a standalone application that creates a custom report for Encompass360 without needing to put certain fields into the reporting database.
So far I have only found one way to do it, but it is extremely slow. (Much slower than a normal report within encompass when retrieving data outside of the reporting database.) It takes almost 2 minutes to pull the data for 5 loans doing this:

int count = 5;
StringList fields = new StringList();
fields.Add("Fields.317");
fields.Add("Fields.3238");
fields.Add("Fields.313");
fields.Add("Fields.319");
fields.Add("Fields.2");

// lstLoans.Items contains the string location of the loans(i.e. "My Pipeline\Dave#6")
foreach (LoanIdentity loanID in lstLoans.Items)
{
string[] loanIdentifier = loanID.ToString().Split('\\');
Loan loan = Globals.Session.Loans.Folders[loanIdentifier[0]].OpenLoan(loanIdentifier[1]);

bool fundingPlus = true; // if milestone == funding || shipping || suspended || completion;

if (!fundingPlus)
continue;

bool oneIsChecked = false;
LogMilestoneEvents msEvents = loan.Log.MilestoneEvents;
DateTime date;
MilestoneEvent ms = null; // better way to do this probably
if (checkBox4.Checked)
{
ms = msEvents.GetEventForMilestone("Completion");
if (ms.Completed)
{
oneIsChecked = true;
}
}
else if (checkBox3.Checked)
{
ms = msEvents.GetEventForMilestone("Suspended");
if (ms.Completed)
{
oneIsChecked = true;
}
}
else if (checkBox2.Checked)
{
ms = msEvents.GetEventForMilestone("Shipping");
if (ms.Completed)
{
oneIsChecked = true;
}
}
else if (checkBox1.Checked)
{
ms = msEvents.GetEventForMilestone("Funding");
if (ms.Completed)
{
oneIsChecked = true;
}
}

if (!oneIsChecked)
continue;

string LO = loan.Fields["317"].FormattedValue;
string LOid = loan.Fields["3238"].FormattedValue;
string city = loan.Fields["313"].FormattedValue;
string address = loan.Fields["319"].FormattedValue;
string loanAmount = loan.Fields["2"].FormattedValue;
if (loanAmount == "")
{
Console.WriteLine(LO);
continue;
}
int numLoans = 1;


addLoanFieldToListView(LO, numLoans, city, address, loanAmount);

if (--count == 0)
break;
}
}


I haven't been able to figure out how to use any of the pipeline methods to retrieve data outside the reporting database, but when all of the fields I am looking for are in the reporting database, it hardly takes a couple seconds to retrieve the contents of hundreds of loans using these tools:

session.Reports.SelectReportingFieldsForLoans(loanGUIDs, fields);
session.Loans.QueryPipeline(selectedDate, PipelineSortOrder.None);
session.Loans.OpenPipeline(PipelineSortOrder.None);


What would really help me is if somebody provided a simple example for retrieving data outside of the reporting database by using the encompass sdk that doesn't take longer than it ought to for retrieving the data.

Note: I am aware I can add the fields to the reporting database that aren't in it currently, so this is not the answer I am looking for.

Note #2: Encompass360 doesn't have it's own tag, if somebody knows of better tags that can be added for the subject at hand, please add them.

Answer Source

I use the SelectFields method on Loans to retrieve loan field data that is not in the reporting database in Encompass. It is very performant compared to opening loans up one by one but the results are returned as strings so it requires some parsing to get the values in their native types. Below is the example from the documentation for using this method.

using System;
using System.IO;
using EllieMae.Encompass.Client;
using EllieMae.Encompass.BusinessObjects;
using EllieMae.Encompass.Query;
using EllieMae.Encompass.Collections;
using EllieMae.Encompass.BusinessObjects.Loans;

class LoanReader
{
   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();
   }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download