Encompass coding detail – 2

There are few lines of plugin and its explanation.

{
Loan currentLoan = EncompassApplication.CurrentLoan;
if (e.MilestoneEvent.MilestoneName.ToLower() != “funded”)
return;
string field1 = Macro.GetField(“1172”);
string field2 = Macro.GetField(“19”);
string field3 = Macro.GetField(“1543”);
string field4 = Macro.GetField(“VEND.X263”);
string field5 = Macro.GetField(“364”);
string field6 = Macro.GetField(“2553”);
DateTime result1;
DateTime? disbursementDateObj = string.IsNullOrEmpty(field6) || !(field6 != “//”) || !DateTime.TryParseExact(field6, “M/d/yyyy”, (IFormatProvider) CultureInfo.InvariantCulture, DateTimeStyles.None, out result1) ? new DateTime?() : new DateTime?(result1);
string field7 = Macro.GetField(“4114”);
DateTime result2;
DateTime? closingDateAtStpObj = string.IsNullOrEmpty(field7) || !(field7 != “//”) || !DateTime.TryParseExact(field7, “M/d/yyyy”, (IFormatProvider) CultureInfo.InvariantCulture, DateTimeStyles.None, out result2) ? new DateTime?() : new DateTime?(result2);
DateTime date1 = (DateTime) currentLoan.Log.MilestoneEvents.GetEventForMilestone(“Submitted to Processing”).Date;
DateTime date2 = (DateTime) currentLoan.Log.MilestoneEvents.GetEventForMilestone(“Resubmitted to UW”).Date;
DateTime date3 = (DateTime) currentLoan.Log.MilestoneEvents.GetEventForMilestone(“Resubmitted to UW”).Date;
DateTime date4 = (DateTime) currentLoan.Log.MilestoneEvents.GetEventForMilestone(“Cond Approval Received”).Date;
DateTime date5 = (DateTime) currentLoan.Log.MilestoneEvents.GetEventForMilestone(“CTC Approval”).Date;
TimeSpan stpTOstu = date2 – date1;
TimeSpan claTOrsu = date3 – date4;
TimeSpan claTOctc = date5 – date4;
TimeSpan? contractLength = disbursementDateObj.HasValue ? new TimeSpan?(disbursementDateObj.Value – date1) : new TimeSpan?();
this.Send_Email(Macro.GetField(“4002”) + “, ” + Macro.GetField(“4000″) + ” – ” + field5 + “: After Action Review”, this.BuildHtmlBody(field1, field2, field3, field4, stpTOstu, claTOrsu, claTOctc, contractLength, field7, disbursementDateObj, closingDateAtStpObj));
}
catch (Exception ex)
{
Macro.Alert(“Failed to Send AAR Email.”);
if (this.isDev)
Macro.Alert(ex.Message);
throw;
}
}

Explanation

This code appears to be written in C# and is part of a larger application or system that interacts with Encompass, which is likely a loan origination and management system. Let’s break down the code step by step:

1. **`Loan currentLoan = EncompassApplication.CurrentLoan;`**: Retrieves the current loan from the Encompass application. It seems to be using a static property called `CurrentLoan` from the `EncompassApplication` class.

2. **`if (e.MilestoneEvent.MilestoneName.ToLower() != “funded”) return;`**: Checks if the milestone associated with an event (`e.MilestoneEvent`) has the name “funded” (case-insensitive). If it doesn’t, the method returns early, and the subsequent code is not executed.

3. **Field Retrieval:**
– Several lines of code retrieve values from specific fields using the `Macro.GetField` method for fields with IDs “1172,” “19,” “1543,” “VEND.X263,” “364,” and “2553.”

4. **Date Parsing:**
– The code then attempts to parse two date fields (“field6” and “field7”) using `DateTime.TryParseExact` with specific date format strings (“M/d/yyyy”). If parsing is successful, it creates nullable `DateTime` objects (`disbursementDateObj` and `closingDateAtStpObj`) with the parsed values.

5. **Event Date Retrieval:**
– Several lines retrieve dates associated with specific milestones from the loan’s log using `currentLoan.Log.MilestoneEvents.GetEventForMilestone(“…”).Date`.

6. **Time Span Calculations:**
– Calculates time spans between various pairs of milestone dates (`stpTOstu`, `claTOrsu`, `claTOctc`).

7. **Contract Length Calculation:**
– Calculates the contract length as a time span between the disbursement date and the “Submitted to Processing” milestone date, if the disbursement date is available.

8. **Email Sending:**
– Calls a method named `Send_Email` with various parameters, including a concatenated string, which seems to be a subject for the email, and the result of a method call (`BuildHtmlBody`) that likely constructs the body of the email.

9. **Exception Handling:**
– The code is wrapped in a try-catch block to handle exceptions. If an exception occurs, it shows an alert, and if the application is in development mode (`this.isDev`), it shows the exception message. The exception is then re-thrown.

In summary, this code appears to be part of a larger process that involves interacting with Encompass loan data, retrieving field values, calculating date differences, and sending an email with the results. The code includes exception handling to provide feedback in case of errors.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.