/// <summary>
 /// Add a new client
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="client">client details</param>
 /// <param name="person">Person details</param>
 /// <param name="organisation">Organisation details</param>
 /// <param name="addresses">Addresses</param>
 /// <param name="addressInformation"></param>
 /// <returns></returns>
 public ClientReturnValue AddClient(HostSecurityToken oHostSecurityToken, Client client,
     Person person,
     Organisation organisation,
     List<Address> addresses,
     List<AdditionalAddressElement> addressInformation)
 {
     ClientReturnValue returnValue = null;
     try
     {
         if (Functions.ValidateIWSToken(oHostSecurityToken))
         {
             oClientService = new ClientService();
             returnValue = oClientService.AddClient(Functions.GetLogonIdFromToken(oHostSecurityToken), client, person, organisation, addresses, addressInformation);
         }
         else
         {
             returnValue = new ClientReturnValue();
             returnValue.Success = false;
             returnValue.Message = "Invalid Token";
         }
     }
     catch (Exception ex)
     {
         returnValue = new ClientReturnValue();
         returnValue.Success = false;
         returnValue.Message = ex.Message;
     }
     return returnValue;
 }
Esempio n. 2
0
        /// <summary>
        /// Add a new client
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="client">client details</param>
        /// <param name="person">Person details</param>
        /// <param name="organisation">Organisation details</param>
        /// <param name="addresses">Addresses</param>
        /// <param name="addressInformation"></param>
        /// <returns></returns>
        public ClientReturnValue AddClient(HostSecurityToken oHostSecurityToken, Client client,
                                           Person person,
                                           Organisation organisation,
                                           List <Address> addresses,
                                           List <AdditionalAddressElement> addressInformation)
        {
            ClientReturnValue returnValue = null;

            try
            {
                if (Functions.ValidateIWSToken(oHostSecurityToken))
                {
                    oClientService = new ClientService();
                    returnValue    = oClientService.AddClient(Functions.GetLogonIdFromToken(oHostSecurityToken), client, person, organisation, addresses, addressInformation);
                }
                else
                {
                    returnValue         = new ClientReturnValue();
                    returnValue.Success = false;
                    returnValue.Message = "Invalid Token";
                }
            }
            catch (Exception ex)
            {
                returnValue         = new ClientReturnValue();
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }
            return(returnValue);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the client type id and the default branch.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="clientId">The client id.</param>
        /// <param name="isMember">if set to <c>true</c> [is member].</param>
        /// <returns></returns>
        public ClientReturnValue GetClientDefaults(HostSecurityToken oHostSecurityToken, Guid clientId)
        {
            ClientReturnValue returnValue = new ClientReturnValue();

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oClientService = new ClientService();
                returnValue    = oClientService.GetClientDefaults(Functions.GetLogonIdFromToken(oHostSecurityToken), clientId);
            }
            else
            {
                returnValue         = new ClientReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Esempio n. 4
0
        public ClientReturnValue GetClient(HostSecurityToken oHostSecurityToken, Guid memberId, Guid organisationId)
        {
            ClientReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oClientService = new ClientService();
                returnValue    = oClientService.GetClient(Functions.GetLogonIdFromToken(oHostSecurityToken), memberId, organisationId);
            }
            else
            {
                returnValue         = new ClientReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        /// <summary>
        /// Loads the client details.
        /// </summary>
        private void LoadClient()
        {
            ClientServiceClient serviceClient = null;
            try
            {

                if (_logonSettings.UserType == (int)DataConstants.UserType.ThirdParty && Request.QueryString["mydetails"] == "true")
                {
                    LoadContact();
                }
                else
                {
                    serviceClient = new ClientServiceClient();
                    _clientReturnValue = serviceClient.GetClient(_logonSettings.LogonId, _memberId, _organisationId);

                    if (_clientReturnValue.Success)
                    {
                        DisplayData();
                    }
                    else
                    {
                        throw new Exception(_clientReturnValue.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (serviceClient != null)
                {
                    if (serviceClient.State != System.ServiceModel.CommunicationState.Faulted)
                        serviceClient.Close();
                }
            }
        }
 /// <summary>
 /// Gets the client type id and the default branch.
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="clientId">The client id.</param>
 /// <param name="isMember">if set to <c>true</c> [is member].</param>
 /// <returns></returns>
 public ClientReturnValue GetClientDefaults(HostSecurityToken oHostSecurityToken, Guid clientId)
 {
     ClientReturnValue returnValue = new ClientReturnValue();
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oClientService = new ClientService();
         returnValue = oClientService.GetClientDefaults(Functions.GetLogonIdFromToken(oHostSecurityToken), clientId);
     }
     else
     {
         returnValue = new ClientReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }
 public ClientReturnValue GetClient(HostSecurityToken oHostSecurityToken, Guid memberId, Guid organisationId)
 {
     ClientReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oClientService = new ClientService();
         returnValue = oClientService.GetClient(Functions.GetLogonIdFromToken(oHostSecurityToken), memberId, organisationId);
     }
     else
     {
         returnValue = new ClientReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }
        /// <summary>
        /// Gets the client type id and the default branch.
        /// </summary>
        /// <param name="logonId">The logon id.</param>
        /// <param name="clientId">The client id.</param>
        /// <param name="isMember">if set to <c>true</c> [is member].</param>
        /// <returns></returns>
        public ClientReturnValue GetClientDefaults(Guid logonId, Guid clientId)
        {
            ClientReturnValue returnValue = new ClientReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    string errorMessage = string.Empty;
                    string warningMessage = string.Empty;
                    SrvMatter srvMatter = new SrvMatter();
                    srvMatter.ClientId = clientId;
                    bool success = srvMatter.ValidateClientId(out errorMessage, out warningMessage);
                    if (success)
                    {
                        returnValue.Client = new Client();
                        returnValue.Client.TypeId = srvMatter.ClientTypeId;
                        returnValue.Client.Branch = srvMatter.DefaultBranchId;
                    }
                    else
                    {
                        returnValue.Success = false;
                        returnValue.Message = errorMessage;
                    }
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }
        /// <summary>
        /// Get one client
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the Client service</param>
        /// <param name="memberId">Member id</param>
        /// <param name="organisationId">Organisation id</param>
        /// <returns></returns>
        public ClientReturnValue GetClient(Guid logonId, Guid memberId, Guid organisationId)
        {
            ClientReturnValue returnValue = new ClientReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                // ApplicationSettings.Instance can now be used to get the
                // ApplicationSettings for this session.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.ThirdParty:
                            if (!SrvClientCommon.WebAllowedToAccessClient(memberId, organisationId))
                                throw new Exception("Access denied");
                            break;
                        case DataConstants.UserType.Client:
                            if (!ApplicationSettings.Instance.IsUser(memberId, organisationId))
                                throw new Exception("Access denied");
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    SrvClient srvClient = new SrvClient();

                    srvClient.Load(memberId, organisationId);

                    Client client = new Client();
                    client.MemberId = srvClient.MemberId;
                    client.OrganisationId = srvClient.OrganisationId;
                    client.PartnerId = srvClient.ClientPartnerId;
                    client.Branch = srvClient.ClientBranch.Trim();
                    client.OpenDate = srvClient.ClientOpenDate;
                    client.PreviousReference = srvClient.PreviousReference.Trim();
                    client.BusinessSourceId = srvClient.SourceId;
                    client.RatingId = srvClient.RatingId;
                    client.IsWebCaseTracking = srvClient.IsClientDoUpload;
                    client.NetPassword = srvClient.ClientNetPassword;
                    client.Group = srvClient.ClientGroup.Trim();
                    client.HOUCN = srvClient.ClientHOUCN.Trim();
                    client.UCN = srvClient.ClientUCN.Trim();
                    client.IsArchived = srvClient.IsClientArchived;
                    client.Type = srvClient.ClientType;
                    client.IsReceivingMarketing = srvClient.IsReceivingMarketing;
                    client.CashCollectionId = srvClient.CliCashCollID;
                    client.TotalLockup = srvClient.CliTotalLockup;
                    client.Reference = srvClient.ClientText.Trim();
                    client.CampaignId = srvClient.CampaignId;

                    returnValue.Client = client;

                    if (srvClient.IsMember)
                    {
                        Person person = new Person();

                        person.MemberId = srvClient.Person.PersonId;
                        person.Title = srvClient.Person.Title;
                        person.ForeName = srvClient.Person.ForeName;
                        person.Surname = srvClient.Person.Surname;
                        client.FullName = IRIS.Law.PmsCommonData.CommonServices.CommonFunctions.MakeFullName(person.Title, person.ForeName, person.Surname);
                        person.MaritalStatusId = srvClient.Person.MaritalId;
                        person.PreviousName = srvClient.Person.PersonPreviousName;
                        person.Occupation = srvClient.Person.PersonOccupation;
                        person.Sex = srvClient.Person.Sex;
                        person.DOB = srvClient.Person.PersonDOB;
                        person.DOD = srvClient.Person.PersonDOD;
                        person.PlaceOfBirth = srvClient.Person.PersonPlaceOfBirth;
                        person.BirthName = srvClient.Person.PersonBirthName;
                        person.SalutationLettterFormal = srvClient.Person.PersonSalletForm;
                        person.SalutationLettterInformal = srvClient.Person.PersonSalutationlettterInformal;
                        person.SalutationLettterFriendly = srvClient.Person.PersonSalLet;
                        person.SalutationEnvelope = srvClient.Person.PersonSalEnv;
                        person.EthnicityId = srvClient.Person.PersonEthnicityId;
                        person.DisabilityId = srvClient.Person.PersonDisability;
                        person.IsInArmedForces = srvClient.Person.PersonInArmedForces;
                        person.ArmedForcesNo = srvClient.Person.PersonArmedForcesNo;
                        person.NINo = srvClient.Person.PersonNINo;

                        returnValue.Person = person;
                    }

                    if (srvClient.IsOrganisation)
                    {
                        Organisation organisation = new Organisation();

                        organisation.OrganisationId = srvClient.Organisation.OrganisationId;
                        organisation.Name = srvClient.Organisation.Name;
                        client.FullName = organisation.Name;
                        organisation.RegisteredName = srvClient.Organisation.RegisteredName;
                        organisation.RegisteredNo = srvClient.Organisation.RegisteredNumber;
                        organisation.VATNo = srvClient.Organisation.VATNumber;
                        organisation.IndustryId = srvClient.Organisation.IndustryId;
                        organisation.SubTypeId = srvClient.Organisation.SubTypesId;

                        returnValue.Organisation = organisation;
                    }

                    returnValue.Addresses = new List<Address>();
                    returnValue.AdditionalAddressElements = new List<AdditionalAddressElement>();
                    foreach (SrvAddress address in srvClient.Addresses)
                    {
                        Address clientAddress = new Address();

                        clientAddress.Id = address.AddressId;
                        clientAddress.TypeId = address.AddressTypeId;
                        clientAddress.Line1 = address.AddressLine1;
                        clientAddress.Line2 = address.AddressLine2;
                        clientAddress.Line3 = address.AddressLine3;
                        clientAddress.Town = address.AddressTown;
                        clientAddress.County = address.AddressCounty;
                        clientAddress.PostCode = address.AddressPostCode;
                        clientAddress.DXTown = address.AddressDXTown;
                        clientAddress.DXNumber = address.AddressDXNumber;
                        clientAddress.Country = address.AddressCountry;
                        clientAddress.IsMailingAddress = address.IsMailingAddress;
                        clientAddress.IsBillingAddress = address.IsBillingAddress;
                        clientAddress.Comment = address.AddressComment;
                        clientAddress.OrganisationName = address.AddressOrgName;
                        clientAddress.Department = address.AddressDepartment;
                        clientAddress.PostBox = address.AddressPostBox;
                        clientAddress.SubBuilding = address.AddressSubBuilding;
                        clientAddress.StreetNumber = address.AddressStreetNumber;
                        clientAddress.HouseName = address.AddressHouseName;
                        clientAddress.DependantLocality = address.AddressDependantLocality;
                        clientAddress.LastVerified = address.AddressLastVerified;

                        returnValue.Addresses.Add(clientAddress);

                        //Get the contact details from the main address
                        if (address.AddressTypeId == 1)
                        {
                            DsAdditionalAddElTypes dsAdditionalAddElTypes = SrvAddressLookup.GetAdditionalAddressElTypes();
                            // integer array which specifies the order of the addAddressElements to display
                            // eg { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 } would display the items as listed in the
                            // table but in the reverse order
                            int[] additionalTypeOrder = new int[11] { 1, 2, 3, 10, 4, 5, 6, 7, 8, 9, 11 };
                            bool addItem = true;

                            for (int x = 0; x < dsAdditionalAddElTypes.AdditionalAddElTypes.Rows.Count; x++)
                            {
                                // Loop through element type table and get the next id type you want
                                for (int i = 0; i < dsAdditionalAddElTypes.AdditionalAddElTypes.Rows.Count; i++)
                                {
                                    int typeId = (int)dsAdditionalAddElTypes.AdditionalAddElTypes[i].AddElTypeID;
                                    if (typeId == additionalTypeOrder[x])
                                    {
                                        string typeText = (string)dsAdditionalAddElTypes.AdditionalAddElTypes[i].AddElTypeText;
                                        string elementText = string.Empty;
                                        string elementComment = string.Empty;

                                        // Loop through member or organisation addEl tables to see if there are any matches.
                                        if (srvClient.IsMember)
                                        {
                                            addItem = true;
                                        }
                                        else
                                        {
                                            if (typeId == 1 || typeId == 7 || typeId == 10)
                                            {
                                                addItem = false;
                                            }
                                            else
                                            {
                                                addItem = true;
                                            }
                                        }

                                        if (addItem)
                                        {
                                            for (int j = 0; j < address.AdditionalInfoElements.Count; j++)
                                            {
                                                if (address.AdditionalInfoElements[j].AddressElTypeId == typeId)
                                                {
                                                    elementText = address.AdditionalInfoElements[j].AddressElementText;
                                                    elementComment = address.AdditionalInfoElements[j].AddressElComment;
                                                    break;
                                                }
                                            }

                                            AdditionalAddressElement additionalAddressElement = new AdditionalAddressElement();
                                            additionalAddressElement.TypeId = typeId;
                                            additionalAddressElement.TypeText = typeText;
                                            additionalAddressElement.ElementText = elementText;
                                            additionalAddressElement.ElementComment = elementComment;
                                            additionalAddressElement.AddressId = address.AddressId;
                                            returnValue.AdditionalAddressElements.Add(additionalAddressElement);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }
        /// <summary>
        /// Add a new client subject to user type, permissions and licensing
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="client">client details</param>
        /// <param name="person">Person details</param>
        /// <param name="organisation">Organisation details</param>
        /// <param name="addresses">Addresses list</param>
        /// <param name="addressInformation">Address information list</param>
        /// <returns>Returns one client entity</returns>
        public ClientReturnValue AddClient(
            Guid logonId,
            Client client,
            Person person,
            Organisation organisation,
            List<Address> addresses,
            List<AdditionalAddressElement> addressInformation)
        {
            ClientReturnValue returnValue = new ClientReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    // Ensure we have permission
                    if (!UserSecuritySettings.GetUserSecuitySettings(2))
                    {
                        throw new Exception("You do not have sufficient permissions to carry out this request");
                    }

                    // Verify Annual Licence
                    if (!IRIS.Law.PmsBusiness.LicenseDetails.AnnualLicenseIsValid())
                    {
                        throw new Exception("Unable to add Client. Your Annual Licence has expired or is invalid.");
                    }

                    SrvClient srvClient = new SrvClient();

                    // Load client fields
                    srvClient.ClientType = client.Type;
                    srvClient.ClientPartnerId = client.PartnerId;
                    srvClient.ClientBranch = client.Branch;
                    srvClient.ClientNetPassword = client.NetPassword;
                    srvClient.ConflictNoteSummary = client.ConflictNoteSummary;
                    srvClient.ConflictNoteContent = client.ConflictNoteContent;

                    // Load person fields
                    switch (client.Type)
                    {
                        case IRISLegal.IlbCommon.ContactType.Individual:
                            srvClient.Person.Title = person.Title;
                            srvClient.Person.setDefaultSex();
                            srvClient.Person.Surname = person.Surname;
                            srvClient.Person.ForeName = person.ForeName;
                            break;
                        case IRISLegal.IlbCommon.ContactType.Organisation:
                            srvClient.Organisation = new SrvOrganisation();
                            srvClient.Organisation.Name = organisation.Name;
                            break;
                        default:
                            throw new Exception("Unknown ClientType");
                    }

                    // This will be used if Client Type selected is multiple
                    // so that second person will be associated with the first person
                    if (client.AssociationId != DataConstants.DummyGuid)
                    {
                        srvClient.AssociationRoleId = client.AssociationRoleId;
                        srvClient.AssociationId = client.AssociationId;
                    }

                    // Load address of person
                    if (addresses != null)
                    {
                        foreach (Address address in addresses)
                        {
                            SrvAddress srvAddress = new SrvAddress();

                            srvAddress.AddressTypeId = address.TypeId;
                            srvAddress.AddressStreetNumber = address.StreetNumber;
                            srvAddress.AddressPostCode = address.PostCode;
                            srvAddress.AddressHouseName = address.HouseName;
                            srvAddress.AddressLine1 = address.Line1;
                            srvAddress.AddressLine2 = address.Line2;
                            srvAddress.AddressLine3 = address.Line3;
                            srvAddress.AddressTown = address.Town;
                            srvAddress.AddressCounty = address.County;
                            srvAddress.AddressCountry = address.Country;
                            srvAddress.AddressDXTown = address.DXTown;
                            srvAddress.AddressDXNumber = address.DXNumber;
                            srvAddress.IsMailingAddress = address.IsMailingAddress;
                            srvAddress.IsBillingAddress = address.IsBillingAddress;

                            srvAddress.AddressOrgName = address.OrganisationName;
                            srvAddress.AddressComment = address.Comment;
                            srvAddress.AddressDepartment = address.Department;
                            srvAddress.AddressPostBox = address.PostBox;
                            srvAddress.AddressSubBuilding = address.SubBuilding;
                            srvAddress.AddressStreetNumber = address.StreetNumber;
                            srvAddress.AddressDependantLocality = address.DependantLocality;
                            srvAddress.AddressLastVerified = address.LastVerified;

                            // Save Additional Address Info to Address Object
                            if (addressInformation != null)
                            {
                                for (int i = 0; i <= addressInformation.Count - 1; i++)
                                {
                                    srvAddress.AdditionalInfoElements[i].AddressElementText =
                                        addressInformation[i].ElementText;
                                }
                            }

                            // TODO more address fields
                            srvClient.Addresses.Add(srvAddress);
                        }
                    }

                    string errorMessage;

                    returnValue.Success = srvClient.Save(out errorMessage);
                    returnValue.Message = errorMessage;

                    client.MemberId = srvClient.MemberId;
                    client.IsMember = srvClient.IsMember;

                    client.OrganisationId = srvClient.OrganisationId;

                    returnValue.Client = client;
                    returnValue.Person = person;
                    returnValue.Organisation = organisation;
                    returnValue.Addresses = addresses;
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }