Exemplo n.º 1
0
        public BaseResult TestConnection(string serviceUrl, string userName, string password, string facility)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Rest.TestConnectionBehavior.TestConnection"))
            {
                if (_restRepository.Credentials == null)
                {
                    _restRepository.Credentials = new Credentials()
                    {
                        BaseUrl  = serviceUrl,
                        Username = userName,
                        Password = password,
                        Facility = facility
                    };
                }
                tr.LogObject(_restRepository.Credentials);

                tr.Log($"Session _session null? => {_session == null}");
                if (_session == null)
                {
                    tr.Log("Call GetSession() to get new _session");
                    _session = GetSession();
                }
                tr.LogObject(_session);

                try
                {
                    tr.Log("Calling IRestRepository.TestConnection");
                    _connectionEstablished = _restRepository.TestConnection(_session);
                    tr.Log($"_connectionEstablished = {_connectionEstablished}");
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Rest.TestConnectionBehavior.TestConnection");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to call REST Repository TestConnection(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _session = null;
                }

                if (_connectionEstablished)
                {
                    result.Result = true;
                }
                else
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, "Connection to CCM REST service was not established");
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public JsonResult Index(FormCollection formValues)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Web.CCMAdminController.Index(FormCollection)"))
            {
                tr.LogObject(formValues);

                var model = new CCMAdminModel(_solutionCode, _paramEnumName);

                TryUpdateModel(model);

                var validationResult = ValidateParameters(model);

                if (!string.IsNullOrWhiteSpace(validationResult))
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, validationResult);

                    return(result.ToJsonResult());
                }

                if (formValues["IsActive"] == "on")
                {
                    model.IsActive = true;
                }

                tr.LogObject(model);

                var parameters = new Parameters();

                try
                {
                    parameters.SetActiveFlag(Parameters.Parameter.Solution, _solutionCode, model.IsActive);
                    parameters.SetParameterValue(Parameters.Parameter.Solution, _solutionCode, "CCM_USERNAME", model.UserName.Trim());
                    parameters.SetParameterValue(Parameters.Parameter.Solution, _solutionCode, "CCM_PASSWORD", model.Password.Trim());
                    parameters.SetParameterValue(Parameters.Parameter.Solution, _solutionCode, "CCM_FACILITY", model.Facility.Trim());
                    parameters.SetParameterValue(Parameters.Parameter.Solution, _solutionCode, "CCM_SOAP_SERVICE_URL", model.SoapServiceUrl.Trim());
                    parameters.SetParameterValue(Parameters.Parameter.Solution, _solutionCode, "CCM_REST_SERVICE_URL", model.RestServiceUrl.Trim());
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Web.Controllers.CCMAdminController.Index(FormCollection)");
                    result.AddMessage(MessageType.Error, $"There was a problem saving the connection parameters: {ex.Message}");

                    return(result.ToJsonResult());
                }

                result.Result = true;
                tr.LogObject(result);
            }

            return(result.ToJsonResult());
        }
Exemplo n.º 3
0
        public BaseResult UpdatePerson(LmsPerson lmsPerson)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Soap.UpdatePersonBehavior.UpdatePerson"))
            {
                if (lmsPerson.Applicant != null)
                {
                    tr.Log($"UpdatePerson for ApplicantId {lmsPerson.Applicant.ApplicantId}, PersonNumber => {lmsPerson.Applicant.PersonNumber}");
                }
                else if (lmsPerson.AuthorizedUser != null)
                {
                    tr.Log($"UpdatePerson for AuthorizedUserId {lmsPerson.AuthorizedUser.AuthorizedUserId}, PersonNumber => {lmsPerson.AuthorizedUser.PersonNumber}");
                }

                tr.Log($"UpdatePerson _person null? => {_person == null}");
                if (_person == null)
                {
                    tr.Log("Call GetDto() to get new _person");
                    _person = GetDto(lmsPerson);
                }
                tr.LogObject(_person);

                try
                {
                    tr.Log("Calling ISoapRepository.UpdatePerson");
                    _messageResponse = _soapRepository.UpdatePerson(_person, _app);

                    tr.Log($"_messageResponse.ResponseCode = {_messageResponse?.ResponseCode}");
                    tr.Log($"_messageResponse.ErrorMessage = {_messageResponse?.ErrorMessage}");
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Soap.UpdatePersonBehavior.UpdatePerson");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to call SOAP Repository UpdatePerson(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _person = null;
                }

                if (_messageResponse?.ResponseCode != "Success" && _messageResponse?.ErrorMessage?.Length > 0)
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, _messageResponse.ErrorMessage);

                    return(result);
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tests the connections to CCM SOAP and REST services.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="facility"></param>
        /// <param name="soapServiceUrl"></param>
        /// <param name="restServiceUrl"></param>
        /// <returns></returns>
        public BaseResult TestConnections(string userName, string password, string facility, string soapServiceUrl, string restServiceUrl)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.CCMOrigination.TestConnections"))
            {
                try
                {
                    var soapConnectionResult = TestSoapConnection(soapServiceUrl, userName, password, facility);
                    result.AppendResult(soapConnectionResult);
                    tr.Log($"SOAP connection result = {soapConnectionResult.Result}");

                    var restConnectionResult = TestRestConnection(restServiceUrl, userName, password, facility);
                    result.AppendResult(restConnectionResult);
                    tr.Log($"REST connection result = {restConnectionResult.Result}");

                    result.Result = soapConnectionResult.Result && restConnectionResult.Result;
                }
                catch (Exception ex)
                {
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.CCMOrigination.TestConnections");
                    result.AddMessage(MessageType.Error, ex.Message);
                    tr.LogException(ex);
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a person to CCM using AddPerson behavior call.
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="applicant"></param>
        /// <returns></returns>
        public BaseResult AddPerson(ClientStrategy strategy, Applicant applicant)
        {
            var result    = new BaseResult();
            var lmsPerson = new LmsPerson()
            {
                Applicant = applicant
            };

            var addPersonStrategyResult = strategy.AddPerson(lmsPerson);

            result.AppendResult(addPersonStrategyResult);

            if (!addPersonStrategyResult.Result)
            {
                if (applicant.ApplicantTypeId.GetValueOrDefault() == (int)Akcelerant.Lending.Lookups.Constants.Values.ApplicantType.Joint)
                {
                    string applicantTypeName = LookupCodes.ApplicantType.Joint;
                    result.AddMessage(MessageType.Warning, $"An error occured adding the {applicantTypeName} Applicant Type. {applicant.FullName} will not be added to CCM.");
                }
                else
                {
                    result.AddError("An error occurred creating the credit card record for the loan. The credit card will not be created in CCM.");

                    return(result);
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a card for the authorized user using AddCard behavior call. Then sets the authorized user's card number in LMS.
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="authorizedUser"></param>
        /// <returns></returns>
        public BaseResult AddCard(ClientStrategy strategy, AuthorizedUser authorizedUser)
        {
            var result    = new BaseResult();
            var lmsPerson = new LmsPerson()
            {
                AuthorizedUser = authorizedUser
            };
            string cardNumber = string.Empty;

            var addCardResult = strategy.AddCard(lmsPerson, out cardNumber);

            result.AppendResult(addCardResult);

            if (addCardResult.Result)
            {
                //Store the CCM AccountNumber received from the response to the authorized user CardNumber field
                var authUser = _app.AuthorizedUsers.SingleOrDefault(a => a.AuthorizedUserId == authorizedUser.AuthorizedUserId);
                authUser.CardNumber = cardNumber;
            }
            else
            {
                result.AddMessage(MessageType.Warning, $"An error occured creating the plastic card. The card will not be created on CCM for {authorizedUser.FirstName} {authorizedUser.LastName}.");
                result.Result = true;
            }

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a card for the primary or joint applicant using AddCard behavior call. Then sets the applicant's card number in LMS.
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="primaryOrJointApplicant"></param>
        /// <returns></returns>
        public BaseResult AddCard(ClientStrategy strategy, Applicant primaryOrJointApplicant)
        {
            var result    = new BaseResult();
            var lmsPerson = new LmsPerson()
            {
                Applicant = primaryOrJointApplicant
            };
            string cardNumber = string.Empty;

            var addCardStrategyResult = strategy.AddCard(lmsPerson, out cardNumber);

            result.AppendResult(addCardStrategyResult);

            if (addCardStrategyResult.Result)
            {
                // Store the CCM AccountNumber received from the response to the primary or joint applicant CardNumber field
                var applicant = _app.Applicants.SingleOrDefault(a => a.ApplicantId == primaryOrJointApplicant.ApplicantId);
                applicant.CardNumber = cardNumber;
            }
            else
            {
                var applicantName = (primaryOrJointApplicant.IsOrganization) ? primaryOrJointApplicant.OrganizationName : primaryOrJointApplicant.FullName;
                result.AddMessage(MessageType.Warning, $"An error occured creating the plastic card. The card will not be created on CCM for {applicantName}.");
                result.Result = true;
            }

            return(result);
        }
Exemplo n.º 8
0
        public BaseResult AddAccount(Applicant applicant)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Soap.AddAccountBehavior.AddAccount"))
            {
                tr.Log($"AddAccount for ApplicantId {applicant.ApplicantId}, PersonNumber => {applicant.PersonNumber}");

                tr.Log($"AddAccount _account null? => {_account == null}");
                if (_account == null)
                {
                    tr.Log("Call GetDto() to get new _account");
                    _account = GetDto(applicant);
                }
                tr.LogObject(_account);

                try
                {
                    tr.Log("Calling ISoapRepository.AddAccount");
                    _messageResponse = _soapRepository.AddAccount(_account, _app, applicant);

                    tr.Log($"_messageResponse.AccountNumber = {_messageResponse?.AccountNumber}");
                    tr.Log($"_messageResponse.ResponseCode = {_messageResponse?.ResponseCode}");
                    tr.Log($"_messageResponse.ErrorMessage = {_messageResponse?.ErrorMessage}");
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Soap.AddAccountBehavior.AddAccount");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to call SOAP Repository AddAcount(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _account = null;
                }

                if (_messageResponse?.ResponseCode != "Success" && _messageResponse?.ErrorMessage?.Length > 0)
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, _messageResponse.ErrorMessage);
                }
            }

            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Disburses the Application to CCM.
        /// </summary>
        /// <param name="userToken"></param>
        /// <param name="app"></param>
        /// <returns></returns>
        public BaseResult DisburseApplication(string userToken, ref Application app)
        {
            var result = new BaseResult();

            _app       = app;
            _userToken = userToken;

            using (var tr = new Tracer("LMS.Connector.CCM.Service.Api.DisburseApplication"))
            {
                var restStrategy = new RestStrategy(app, userToken);

                var soapRepository = new SoapRepository(userToken);
                var soapStrategy   = new SoapStrategy(app, userToken, soapRepository);
                soapStrategy.Repository = soapRepository;

                var ccm = new CCMOrigination(app, userToken, restStrategy, soapStrategy);

                try
                {
                    result = ccm.DisburseApplication();
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Service.Api.DisburseApplication");
                    result.AddError(ex.Message);
                }

                if (result.Result)
                {
                    result.AddMessage(MessageType.Success, "Loan product disbursed successfully.");
                    result.AddMessage(MessageType.Success, "Application has been disbursed.");

                    app.IsLoanDisbursed    = true;
                    app.StatusId           = (int)Akcelerant.Lending.Lookups.Constants.Values.ApplicationStatus.Disbursed;
                    app.DisbursementUserId = app.LoggedInUser.UserId;

                    tr.Log($"ApplicationId {app.ApplicationId} DisbursementUserId => {app.LoggedInUser.UserId}");
                }

                tr.Log($"ApplicationId {app.ApplicationId} IsLoanDisbursed => {app.IsLoanDisbursed}");
                tr.Log($"ApplicationId {app.ApplicationId} StatusId => {app.StatusId}");
                tr.Log($"LMS.Connector.CCM.Service.Api.DisburseApplication result => {result.Result}");
            }

            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Makes an Inquiry behavior call to determine if a person exists in CCM, and also gets RelationshipInfo objects.
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="personNumber"></param>
        /// <param name="errorMessage"></param>
        /// <param name="relationshipInfos"></param>
        /// <returns></returns>
        public BaseResult MakeInquiry(ClientStrategy strategy, string personNumber, out string errorMessage, out IList <RelationshipInfo> relationshipInfos)
        {
            var result = new BaseResult();

            var inquiryResult = strategy.Inquiry(personNumber, out errorMessage, out relationshipInfos);

            result.AppendResult(inquiryResult);

            if (!inquiryResult.Result)
            {
                result.AddMessage(MessageType.Warning, $"An error occured making Inquiry for personNumber {personNumber}.");
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Adds a party relationship for a joint applicant in CCM using AddAccountPartyRelationship behavior call.
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="applicant"></param>
        /// <returns></returns>
        public BaseResult AddAccountPartyRelationship(ClientStrategy strategy, Applicant applicant)
        {
            var result = new BaseResult();
            var addAccountPartyRelationshipStrategyResult = strategy.AddAccountPartyRelationship(applicant);

            result.AppendResult(addAccountPartyRelationshipStrategyResult);

            if (!addAccountPartyRelationshipStrategyResult.Result)
            {
                var jointApplicantName = (applicant.IsOrganization) ? applicant.OrganizationName : applicant.FullName;
                result.AddMessage(MessageType.Warning, $"An error occured adding the Joint. {jointApplicantName} will not be added on CCM.");
            }

            return(result);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds an authorized user to CCM using AddPerson behavior call.
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="authorizedUser"></param>
        /// <returns></returns>
        public BaseResult AddAuthorizedUser(ClientStrategy strategy, AuthorizedUser authorizedUser)
        {
            var result    = new BaseResult();
            var lmsPerson = new LmsPerson()
            {
                AuthorizedUser = authorizedUser
            };

            var addAuthorizedUserStrategyResult = strategy.AddPerson(lmsPerson);

            result.AppendResult(addAuthorizedUserStrategyResult);

            if (!addAuthorizedUserStrategyResult.Result)
            {
                result.AddMessage(MessageType.Warning, $"An error occured adding the AUTHORIZED USER. {authorizedUser.FirstName} {authorizedUser.LastName} will not be added to CCM.");
            }

            return(result);
        }
Exemplo n.º 13
0
        public BaseResult AddOrganization(Applicant organization)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Soap.AddOrganizationBehavior.AddOrganization"))
            {
                tr.Log($"AddOrganization for ApplicantId {organization.ApplicantId}, PersonNumber => {organization.PersonNumber}");

                tr.Log($"Address _currentAddress null? => {_currentAddress == null}");
                if (_currentAddress == null)
                {
                    tr.Log("Call GetCurrentAddress() to get new _currentAddress");
                    _currentAddress = GetCurrentAddress(organization);
                }
                tr.LogObject(_currentAddress);

                tr.Log($"Phone _mainPhone null? => {_mainPhone == null}");
                if (_mainPhone == null)
                {
                    tr.Log("Call GetMainPhone() to get new _mainPhone");
                    _mainPhone = GetMainPhone(organization);
                }
                tr.LogObject(_mainPhone);

                tr.Log($"AddOrganization _organization null? => {_organization == null}");
                if (_organization == null)
                {
                    tr.Log("Call GetDto() to get new _organization");
                    _organization = GetDto(organization);
                }
                tr.LogObject(_organization);

                try
                {
                    tr.Log("Calling ISoapRespository.AddOrganization");
                    _messageResponse = _soapRepository.AddOrganization(_organization, _app, organization, _currentAddress, _mainPhone);

                    tr.Log($"_messageResponse.OrganizationPartyId = {_messageResponse?.OrganizationPartyId}");
                    tr.Log($"_messageResponse.ResponseCode = {_messageResponse?.ResponseCode}");
                    tr.Log($"_messageResponse.ErrorMessage = {_messageResponse?.ErrorMessage}");
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Soap.AddOrganizationBehavior.AddOrganization");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to call SOAP Repository AddOrganization(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTOs
                    _currentAddress = null;
                    _mainPhone      = null;
                    _organization   = null;
                }

                if (_messageResponse?.ResponseCode != "Success" && _messageResponse?.ErrorMessage?.Length > 0)
                {
                    if (_messageResponse?.ErrorMessage.IndexOf("already exists", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        result.Result = true;
                    }
                    else
                    {
                        result.Result = false;
                        result.AddMessage(MessageType.Error, _messageResponse.ErrorMessage);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 14
0
        public BaseResult Inquiry(string personNumber)
        {
            var result = new BaseResult();

            _errorMessage = "Relationship not found";

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Rest.InquiryBehavior.Inquiry"))
            {
                tr.Log($"Inquiry personNumber = {personNumber}");

                tr.Log($"PartyRelationshipsInquiry _inquiry null? => {_inquiry == null}");
                if (_inquiry == null)
                {
                    tr.Log("Call GetDto() to get new _inquiry");
                    _inquiry = GetDto(personNumber);
                }
                tr.LogObject(_inquiry);

                try
                {
                    tr.Log("Calling IRestRepository.MakeInquiry");
                    _relationshipInfos = _restRepository.MakeInquiry(_inquiry);
                    tr.LogObject(_relationshipInfos);
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Rest.InquiryBehavior.Inquiry");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to call REST Repository MakeInquiry(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _inquiry = null;
                }

                if (_relationshipInfos?.Count > 0)
                {
                    int i = 0;
                    tr.Log($"Iterating through _relationshipInfos to determine if party has an account in CCM (i.e. relationshipInfo[i].AccountNumber == _app.CreditCardNumber <{_app.CreditCardNumber}>)");
                    foreach (var relationshipInfo in _relationshipInfos)
                    {
                        tr.Log($"_relationshipInfos[{i}].AccountNumber = {relationshipInfo.AccountNumber}");
                        if (relationshipInfo.AccountNumber == _app.CreditCardNumber)
                        {
                            _errorMessage = "Found";
                            tr.Log($"Found in _relationshipInfos[{i}]");

                            break;
                        }

                        i++;
                    }
                }

                tr.Log($"Inquiry error message: {_errorMessage}");
            }

            return(result);
        }
Exemplo n.º 15
0
        public BaseResult TestConnection(string serviceUrl, string userName, string password, string facility)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Soap.TestConnectionBehavior.TestConnection"))
            {
                _soapRepository.Credentials = new Credentials()
                {
                    BaseUrl  = serviceUrl,
                    Username = userName,
                    Password = password,
                    Facility = facility
                };

                tr.LogObject(_soapRepository.Credentials);

                // Can be any primary Applicant -- doesn't matter since we are only testing a connection.
                var lmsPerson = new LmsPerson()
                {
                    Applicant = _app.Applicants.SingleOrDefault(a => a.ApplicantTypeId == (int)Akcelerant.Lending.Lookups.Constants.Values.ApplicantType.Primary)
                };

                tr.Log($"UpdatePerson _person null? => {_person == null}");
                if (_person == null)
                {
                    tr.Log("Call GetDto() to get new _person");
                    _person = GetDto(lmsPerson);
                }
                tr.LogObject(_person);

                try
                {
                    tr.Log("Calling ISoapRespository.UpdatePerson");
                    _messageResponse = _soapRepository.UpdatePerson(_person, _app);

                    tr.Log($"_messageResponse.ResponseCode = {_messageResponse?.ResponseCode}");
                    tr.Log($"_messageResponse.ErrorMessage = {_messageResponse?.ErrorMessage}");

                    var isSystemMalfunction = (_messageResponse?.ResponseCode.Equals("SystemMalfunction", StringComparison.InvariantCulture) == true) ? true : false;
                    tr.Log($"isSystemMalfunction = {isSystemMalfunction}");

                    var isErrorMessageModifyPartyRequestFailed = (_messageResponse?.ErrorMessage.Contains($"Modify Party request failed. Party {_person.Message?.DataUpdate?.Person?.PartyNumber} not found.") == true) ? true : false;
                    tr.Log($"isErrorMessageModifyPartyRequestFailed = {isErrorMessageModifyPartyRequestFailed}");

                    //Use reponseCode and errorMessage to derive connectionEstablished according to business rules
                    _connectionEstablished = (isSystemMalfunction && isErrorMessageModifyPartyRequestFailed) ? true : false;
                    tr.Log($"_connectionEstablished = {_connectionEstablished}");
                }
                catch (Exception ex)
                {
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Soap.TestConnectionBehavior.TestConnection");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to get a MessageResponse from SOAP Repository UpdateAccount(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _person = null;
                }

                if (_connectionEstablished)
                {
                    result.Result = true;
                }
                else
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, "Connection to CCM SOAP service was not established");
                }
            }

            return(result);
        }
Exemplo n.º 16
0
        public JsonResult TestConnections(CCMAdminModel model)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Web.CCMAdminController.TestConnections(CCMAdminModel)"))
            {
                var validationResult = ValidateParameters(model);

                if (!string.IsNullOrWhiteSpace(validationResult))
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, validationResult);

                    return(result.ToJsonResult());
                }

                var connectorParams = new List <HostParameter>()
                {
                    new HostParameter("CCM_USERNAME", model.UserName.Trim()),
                    new HostParameter("CCM_PASSWORD", model.Password.Trim()),
                    new HostParameter("CCM_FACILITY", model.Facility.Trim()),
                    new HostParameter("CCM_SOAP_SERVICE_URL", model.SoapServiceUrl.Trim()),
                    new HostParameter("CCM_REST_SERVICE_URL", model.RestServiceUrl.Trim()),
                    new HostParameter("USERTOKEN", WebUtil.UserToken)
                };

                tr.LogObject(connectorParams);

                try
                {
                    using (var svc = new Akcelerant.Lending.Client.Services.DisburseApplication())
                    {
                        svc.SetEndpointAddress(GetDisbursementProviderServiceLocation(DISBURSEMENT_PROVIDER_ID));

                        result = svc.TestConnection(connectorParams);

                        if (result.Result)
                        {
                            result.Messages.Add(new Akcelerant.Core.Data.DTO.Result.Message(MessageType.Success, "Connection to CCM was successful."));
                            tr.LogObject(result);
                        }
                        else
                        {
                            result.Result = false;
                            result.Messages.Clear();
                            result.AddError("Connection to the Credit Card Management - Loan Origination service failed. Please validate your credentials and try again.");
                        }
                    }
                }
                catch (FaultException <ExceptionDetail> ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Web.Controllers.CCMAdminController.TestConnection");
                    result.AddError("Connection to the Credit Card Management - Loan Origination service failed. Please validate your credentials and try again.");
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Web.Controllers.CCMAdminController.TestConnection");
                    result.AddError("Connection to the Credit Card Management - Loan Origination service failed. Please validate your credentials and try again.");
                }
            }

            return(result.ToJsonResult());
        }