Esempio n. 1
0
        public AddOrganization GetDto(Applicant organization)
        {
            var addOrganization = new AddOrganization()
            {
                Message = GetMessage(organization)
            };

            return(addOrganization);
        }
        private static AddOrganization CreateOrganizationRequest(Random rand, string parentServiceProviderId)
        {
            AddOrganization request = new AddOrganization();

            // Required fields
            request.name            = "OrganizationC#_" + rand.Next().ToString() + rand.Next().ToString();
            request.login           = "******" + rand.Next().ToString();
            request.password        = "******";
            request.country         = "ro";
            request.Item            = parentServiceProviderId;
            request.ItemElementName = ItemChoiceType7.parentID;

            // Optionally fields
            request.company = "Company_" + rand.Next().ToString();
            request.email   = CreateEmail(rand);

            return(request);
        }
Esempio n. 3
0
        public AddOrganization GetAddOrganization()
        {
            var addOrganization = new AddOrganization()
            {
                Message = new Dto.Soap.Message()
                {
                    DataUpdate = new DataUpdate()
                    {
                        TraceNumber    = "554120039",
                        ProcessingCode = "ExternalUpdateRequest",
                        Source         = "LoanOrigination",
                        UpdateAction   = "Add",
                        Organization   = new Organization()
                        {
                            PartyNumber    = "18540",
                            TaxIdNumber    = "270754510",
                            PrimaryAddress = new PrimaryAddress()
                            {
                                AddressLine1  = "123 North South Street",
                                City          = "Westboro",
                                StateProvince = "IN",
                                PostalCode    = "48906",
                                CountryCode   = "US",
                                AddressType   = "Business"
                            },
                            PrimaryEmail = new PrimaryEmail()
                            {
                                EmailAddress = "*****@*****.**"
                            },
                            PrimaryPhone = new PrimaryPhone()
                            {
                                CityAreaCode     = "765",
                                LocalPhoneNumber = "6658897",
                                Description      = "My home phone",
                                PhoneType        = "Home"
                            },
                            Name = "The Red Poppy"
                        },
                    }
                }
            };

            return(addOrganization);
        }
        public static string AddOrganizationAccount(string accessToken, string parentServiceProviderID)
        {
            if (string.IsNullOrEmpty(parentServiceProviderID))
            {
                Console.WriteLine("The parentServiceProviderID parameter cannot be null or empty");

                return(null);
            }

            if (string.IsNullOrEmpty(accessToken))
            {
                Console.WriteLine("The access token cannot be null or empty!");

                return(null);
            }

            ServicePointManager.ServerCertificateValidationCallback += delegate(object sender,
                                                                                X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            {
                return(true);
            };

            ServicePointManager.Expect100Continue = false;

            userCredentials credentials = new userCredentials()
            {
                accessToken = accessToken
            };

            AddOrganization         request  = CreateOrganizationRequest(new Random(), parentServiceProviderID);
            AddOrganizationResponse response = new AddOrganizationResponse();

            OrganizationClient organizationClient = new OrganizationClient("OrganizationPort");

            Console.WriteLine("Adding an Organization");

            try
            {
                organizationClient.AddOrganization(credentials, request, out response);
            }
            catch (Exception e)
            {
                //exception found, so we check the stack trc
                String trace = e.StackTrace;

                //write the stack trace to the console
                Console.WriteLine("{0} Exception caught.", e);

                //wait for the user to press a key before closing the console
                Console.Read();
            }
            finally
            {
                Console.WriteLine("The operation response:");

                foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(response))
                {
                    string name  = descriptor.Name;
                    object value = descriptor.GetValue(response);
                    Console.WriteLine("\t{0}={1}", name, value);
                }

                Console.WriteLine();
            }

            return(response.ID);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public object Any(AddOrganization request)
        {
            VerifyOrganization v = new VerifyOrganization();

            v.isNameExists     = false;
            v.isUrlExists      = v.isEmailExists = false;
            v.ErrorDescription = "";
            //validation
            if (string.IsNullOrWhiteSpace(request.name))
            {
                v.ErrorDescription += "Name is required.\n";
                v.isNameExists      = true;
            }

            if (!string.IsNullOrWhiteSpace(request.url))
            {
                if (request.url.Length < 3 || request.url.Length > 20 || !(new Regex("^[0-9a-z][0-9a-z-]{1,18}[0-9a-z]$", RegexOptions.IgnoreCase | RegexOptions.Multiline)).IsMatch(request.url))
                {
                    v.ErrorDescription += "Url should be between 3 and 20 characters and can contains alphanumeric characters and hyphens";
                    v.isUrlExists       = true;
                }
                if (!CustomUrlProvider.ValidateCustomUrl(request.url))
                {
                    v.ErrorDescription += "Url: " + request.url + " is already exists.\n";
                    v.isUrlExists       = true;
                }
            }
            else
            {
                request.url = null;
            }

            if (!Utils.IsValidEmail(request.email))
            {
                v.ErrorDescription += "Email is required.\n";
                v.isEmailExists     = true;
            }
            else
            {
                LoginProvider lp = new LoginProvider();

                if (lp.ValidateLogin(request.email, null))
                {
                    v.isEmailExists     = true;
                    v.ErrorDescription += "User already have one registered organization. Please login OR set is_force_registration=true to continue.\n";
                }
            }

            v.isPasswordCorrect = v.isPasswordsMatch = true;
            if (!string.IsNullOrWhiteSpace(request.password))
            {
                if (!Utils.IsValidPassword(request.password))
                {
                    v.isPasswordCorrect = false;
                    v.ErrorDescription += "Password is too weak. It must be at least 5 characters.\n";
                }
                if (!request.password.Equals(request.password_confirm))
                {
                    v.isPasswordsMatch  = false;
                    v.ErrorDescription += "Passwords not match.\n";
                }
            }

            return(v);
        }
Esempio n. 7
0
 public void SetUp()
 {
     _organization = GetAddOrganization();
     _app          = GetApplication();
     _userToken    = "aBc123";
 }
Esempio n. 8
0
 public void TearDown()
 {
     _organization = null;
     _app          = null;
 }
Esempio n. 9
0
        public MessageResponse AddOrganization(AddOrganization organization, Application app, Applicant applicant, Address address, Phone phone)
        {
            MessageResponse messageResponse = null;
            string          messageXml      = string.Empty;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.AddOrganization"))
            {
                try
                {
                    messageXml = organization.Message?.SerializeToXmlString();
                    tr.Log($"AddOrganization: BEFORE setting host values => {messageXml}");

                    tr.Log("AddOrganization: Set Application-level host values ");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        app.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                        organization.Message?.HostValueParentNode
                        );
                    tr.Log($"AddOrganization: AFTER Application-level host values => {messageXml}");

                    tr.Log("AddOrganization: Set Applicant-level host values");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        applicant.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                        organization.Message?.HostValueParentNode
                        );
                    tr.Log($"AddOrganization: AFTER Applicant-level host values => {messageXml}");

                    tr.Log("AddOrganization: Set Address-level host values");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        address.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                        organization.Message?.HostValueParentNode
                        );
                    tr.Log($"AddOrganization: AFTER Address-level host values => {messageXml}");

                    tr.Log("AddOrganization: Set Phone-level host values");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        phone.HostValues.Where(hv => hv.Field1.StartsWith("AddOrganization.")).ToList(),
                        organization.Message?.HostValueParentNode
                        );
                    tr.Log($"AddOrganization: AFTER Phone-level host values => {messageXml}");

                    tr.LogObject(CredentialsHeader);

                    tr.Log("AddOrganization: Calling ISoapRepository.ProcessMessage");
                    messageResponse = ProcessMessage(messageXml);
                }
                catch (Exception ex)
                {
                    // Handle serialization and host value translation exceptions here

                    tr.LogException(ex);
                    Utility.LogError(ex, "LMS.Connector.CCM.Repositories.SoapRepository.AddOrganization");
                    throw;
                }
            }

            return(messageResponse);
        }