Ejemplo n.º 1
0
        /// <summary>
        /// Gets the address.
        /// </summary>
        /// <param name="memId">The mem id.</param>
        /// <param name="orgId">The org id.</param>
        /// <returns></returns>
        private string GetAddress(Guid memId, Guid orgId)
        {
            string addressLine1 = string.Empty;
            ClientServiceClient clientService = null;

            try
            {
                CollectionRequest     collectionRequest = new CollectionRequest();
                AddressSearchCriteria criteria          = new AddressSearchCriteria();
                criteria.MemberId       = memId;
                criteria.OrganisationId = orgId;

                clientService = new ClientServiceClient();
                AddressSearchReturnValue returnValue = clientService.GetClientAddresses(_logonSettings.LogonId,
                                                                                        collectionRequest,
                                                                                        criteria);

                if (returnValue.Success)
                {
                    if (returnValue.Addresses.Rows.Length > 0)
                    {
                        addressLine1 = returnValue.Addresses.Rows[0].Line1;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        clientService.Close();
                    }
                }
            }

            return(addressLine1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the client details.
        /// </summary>
        private void LoadAddressDetails()
        {
            ClientServiceClient serviceClient = null;

            try
            {
                serviceClient             = new ClientServiceClient();
                _addressSearchReturnValue = new AddressSearchReturnValue();
                CollectionRequest     collectionRequest = new CollectionRequest();
                AddressSearchCriteria searchCriteria    = new AddressSearchCriteria();
                searchCriteria.MemberId       = _memId;
                searchCriteria.OrganisationId = _orgId;
                _addressSearchReturnValue     = serviceClient.GetClientAddresses(_logonId, collectionRequest, searchCriteria);

                if (_addressSearchReturnValue.Success)
                {
                    GetAddressTypes();
                    DisplayAddressDetails();
                }
                else
                {
                    throw new Exception(_addressSearchReturnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (serviceClient != null)
                {
                    if (serviceClient.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        serviceClient.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Loads the client details.
        /// </summary>
        private void LoadAddressDetails()
        {
            ClientServiceClient serviceClient = null;
            try
            {
                serviceClient = new ClientServiceClient();
                _addressSearchReturnValue = new AddressSearchReturnValue();
                CollectionRequest collectionRequest = new CollectionRequest();
                AddressSearchCriteria searchCriteria = new AddressSearchCriteria();
                searchCriteria.MemberId = _memId;
                searchCriteria.OrganisationId = _orgId;
                _addressSearchReturnValue = serviceClient.GetClientAddresses(_logonId, collectionRequest, searchCriteria);

                if (_addressSearchReturnValue.Success)
                {
                    GetAddressTypes();
                    DisplayAddressDetails();
                }
                else
                {
                    throw new Exception(_addressSearchReturnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (serviceClient != null)
                {
                    if (serviceClient.State != System.ServiceModel.CommunicationState.Faulted)
                        serviceClient.Close();
                }
            }
        }
        /// <summary>
        /// Gets the address.
        /// </summary>
        /// <param name="memId">The mem id.</param>
        /// <param name="orgId">The org id.</param>
        /// <returns></returns>
        private string GetAddress(Guid memId, Guid orgId)
        {
            string addressLine1 = string.Empty;
            ClientServiceClient clientService = null;

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                AddressSearchCriteria criteria = new AddressSearchCriteria();
                criteria.MemberId = memId;
                criteria.OrganisationId = orgId;

                clientService = new ClientServiceClient();
                AddressSearchReturnValue returnValue = clientService.GetClientAddresses(_logonSettings.LogonId,
                                                                                       collectionRequest,
                                                                                       criteria);

                if (returnValue.Success)
                {
                    if (returnValue.Addresses.Rows.Length > 0)
                    {
                        addressLine1 = returnValue.Addresses.Rows[0].Line1;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.Close();
                }
            }

            return addressLine1;
        }
        /// <summary>
        /// Saves the addresses.
        /// </summary>
        private void SaveAddresses()
        {
            ContactServiceClient contactService = null;
            ClientServiceClient clientService = null;
            try
            {
                CheckForModifiedAddress();
                List<string> updatedAddresses = (List<string>)ViewState[UpdatedAddresses];
                //Check if any of the addresses have been modified
                if (updatedAddresses.Count > 0)
                {
                    contactService = new ContactServiceClient();
                    List<Address> clientAddresses = (List<Address>)Session[SessionName.ClientAddresses];
                    foreach (string addressType in updatedAddresses)
                    {
                        foreach (Address address in clientAddresses)
                        {
                            if (address.TypeId.ToString() == addressType)
                            {

                                if (_logonSettings.UserType == (int)DataConstants.UserType.ThirdParty && Request.QueryString["mydetails"] == "true")
                                {
                                    address.MemberId = _logonSettings.MemberId;
                                    address.OrganisationId = _logonSettings.OrganisationId;
                                }
                                else
                                {
                                    address.MemberId = (Guid)Session[SessionName.MemberId];
                                    address.OrganisationId = (Guid)Session[SessionName.OrganisationId];
                                }

                                AddressReturnValue returnValue = contactService.SaveAddress(_logonSettings.LogonId, address);
                                if (!returnValue.Success)
                                {
                                    _lblMessage.CssClass = "errorMessage";
                                    _lblMessage.Text = returnValue.Message;
                                }
                                break;
                            }
                        }
                    }
                    updatedAddresses.Clear();
                    //Reload the addresses
                    clientService = new ClientServiceClient();
                    AddressSearchCriteria searchCriteria = new AddressSearchCriteria();
                    searchCriteria.MemberId = _memberId;
                    searchCriteria.OrganisationId = _organisationId;
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;

                    if (Request.QueryString["mydetails"] == "true" && _logonSettings.UserType == (int)DataConstants.UserType.ThirdParty)
                    {
                        AddressSearchReturnValue addressSearchReturnValue = new AddressSearchReturnValue();
                        ContactServiceClient serviceClient = new ContactServiceClient();
                        addressSearchReturnValue = serviceClient.GetContactAddresses(_logonSettings.LogonId, collectionRequest, searchCriteria);
                        clientAddresses.Clear();
                        //Store the addresses in a list so that we can add items if necessary
                        foreach (Address address in addressSearchReturnValue.Addresses.Rows)
                        {
                            clientAddresses.Add(address);
                        }

                    }
                    else
                    {
                        AddressSearchReturnValue addresses = clientService.GetClientAddresses(_logonSettings.LogonId,
                                                                                            collectionRequest,
                                                                                            searchCriteria);
                        clientAddresses.Clear();
                        //Store the addresses in a list so that we can add items if necessary
                        foreach (Address address in addresses.Addresses.Rows)
                        {
                            clientAddresses.Add(address);
                        }
                    }

                    if (Request.QueryString["mydetails"] == "true" && _logonSettings.UserType == (int)DataConstants.UserType.ThirdParty)
                    {
                        DisplayContactAddressDetails();
                    }
                    else
                    {
                        DisplayAddressDetails();
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = ex.Message;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }

                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.Close();
                }
            }
        }