Exemple #1
0
        private string ImportLoansAndSubmitLoan(int iLoanID, string sProgram, string sType)
        {
            string         ReturnMessage = string.Empty;
            ServiceManager sm            = new ServiceManager();

            int[] FileIDs = new int[1];
            FileIDs.SetValue(iLoanID, 0);
            using (LP2ServiceClient service = sm.StartServiceClient())
            {
                ImportLoansRequest req = new ImportLoansRequest();
                req.hdr = new ReqHdr();
                req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                req.hdr.UserId        = this.CurrUser.iUserID;
                req.FileIds           = FileIDs;

                ImportLoansResponse respone = null;
                try
                {
                    respone = service.ImportLoans(req);

                    if (respone.hdr.Successful)
                    {
                        ReturnMessage = string.Empty;
                    }
                    else
                    {
                        ReturnMessage = respone.hdr.StatusInfo;
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    string sExMsg = string.Format("Failed to ImportLoans, reason: ImportLoans Manager is not running.");
                    LPLog.LogMessage(LogType.Logerror, sExMsg);

                    return(ReturnMessage);
                }
                catch (Exception ex)
                {
                    string sExMsg = string.Format("Failed toImportLoans, error: {0}", ex.Message);
                    LPLog.LogMessage(LogType.Logerror, sExMsg);

                    return(ReturnMessage);
                }


                DT_SubmitLoanRequest reqDT = new DT_SubmitLoanRequest();
                reqDT.hdr = new ReqHdr();
                reqDT.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                reqDT.hdr.UserId        = this.CurrUser.iUserID;
                reqDT.FileId            = iLoanID;
                reqDT.Loan_Program      = sProgram;
                reqDT.Originator_Type   = sType;

                DT_SubmitLoanResponse responeDT = null;
                try
                {
                    responeDT = service.DTSubmitLoan(reqDT);

                    if (responeDT.hdr.Successful)
                    {
                        ReturnMessage = string.Empty;
                    }
                    else
                    {
                        ReturnMessage = responeDT.hdr.StatusInfo;
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    string sExMsg = string.Format("Failed to ImportLoans, reason: ImportLoans Manager is not running.");
                    LPLog.LogMessage(LogType.Logerror, sExMsg);

                    return(ReturnMessage);
                }
                catch (Exception ex)
                {
                    string sExMsg = string.Format("Failed to ImportLoans, error: {0}", ex.Message);
                    LPLog.LogMessage(LogType.Logerror, sExMsg);

                    return(ReturnMessage);
                }

                try
                {
                    LoanActivities       _bLoanActivities = new LoanActivities();
                    Model.LoanActivities _mLoanActivities = new Model.LoanActivities();
                    _mLoanActivities.FileId       = iLoanID;
                    _mLoanActivities.UserId       = this.CurrUser.iUserID;
                    _mLoanActivities.ActivityName = "The loan has been submitted to DataTrac by " + this.CurrUser.sFullName;
                    _mLoanActivities.ActivityTime = DateTime.Now;
                    int iNew = _bLoanActivities.Add(_mLoanActivities);
                }
                catch (Exception ex)
                {
                    string sExMsg = string.Format("Failed to Update LoanActivities, error: {0}", ex.Message);
                    LPLog.LogMessage(LogType.Logerror, sExMsg);

                    return(ReturnMessage);
                }

                return(ReturnMessage);
            }
        }