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()); }
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()); }