//Prueba GetClientesByRouter static void Main(string[] args) { var servicio = new SrvClient(); var clients = servicio.GetClientsAllConnections(); foreach (QueueSimple qs in clients) { Console.WriteLine(string.Format("Name: {0} - Target: {1} - MaxLimit: {2} - BurstLimit: {3} - LimitAt: {4} - Rate: {5}", qs.Name, qs.Target, qs.MaxLimit, qs.BurstLimit, qs.LimitAt, qs.Rate)); } Console.ReadKey(); }
/// <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> /// Update an existing client's address or add a new one /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="memberId">Member id of the client</param> /// <param name="organisationId">Orgainisation id of the client</param> /// <param name="address">Address to update or new address to add. /// If the Address.Id = 0 then a new address is being added.</param> /// <returns></returns> public ReturnValue UpdateClientAddress(Guid logonId, Guid memberId, Guid organisationId, Address address) { ReturnValue returnValue = new ReturnValue(); 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: if (!ApplicationSettings.Instance.IsUser(memberId, organisationId)) throw new Exception("Access denied"); break; case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } SrvClient srvClient = new SrvClient(); srvClient.Load(memberId, organisationId); SrvAddress srvAddress = null; if (address.Id != 0) { // Updating an existing address so check it exists on this client foreach (SrvAddress addr in srvClient.Addresses) { if (addr.AddressId == address.Id) { // Found it srvAddress = addr; break; } } if (srvAddress == null) throw new Exception("Address does not exist for client"); } else { // A new address is being added srvAddress = new SrvAddress(); srvAddress.MemberId = memberId; srvAddress.OrganisationId = organisationId; } srvAddress.AddressTypeId = address.TypeId; srvAddress.AddressLine1 = address.Line1; // TODO more address fields string errorMessage; returnValue.Success = srvAddress.Save(out errorMessage); 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> /// 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; }
/// <summary> /// Update an existing client /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="client">Client details</param> /// <param name="person"></param> /// <param name="organisation"></param> /// <returns></returns> public IRIS.Law.WebServiceInterfaces.ReturnValue UpdateClient(Guid logonId, Client client, Person person, Organisation organisation) { ReturnValue returnValue = new ReturnValue(); 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: if (!ApplicationSettings.Instance.IsUser(client.MemberId, client.OrganisationId)) throw new Exception("Access denied"); break; case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } SrvClient srvClient = new SrvClient(); srvClient.Load(client.MemberId, client.OrganisationId); srvClient.MemberId = client.MemberId; srvClient.OrganisationId = client.OrganisationId; srvClient.ClientPartnerId = client.PartnerId; srvClient.ClientBranch = client.Branch; srvClient.ClientOpenDate = client.OpenDate; srvClient.PreviousReference = client.PreviousReference; srvClient.SourceId = client.BusinessSourceId; srvClient.RatingId = client.RatingId; srvClient.IsClientDoUpload = client.IsWebCaseTracking; srvClient.ClientNetPassword = client.NetPassword; srvClient.ClientGroup = client.Group; srvClient.ClientHOUCN = client.HOUCN; srvClient.ClientUCN = client.UCN; srvClient.IsClientArchived = client.IsArchived; srvClient.ClientType = client.Type; srvClient.IsReceivingMarketing = client.IsReceivingMarketing; srvClient.CliCashCollID = client.CashCollectionId; srvClient.CliTotalLockup = client.TotalLockup; srvClient.CampaignId = client.CampaignId; //Since SrvClient saves the Person/Organisation details when we call save //we need to pass the Person/Organisation ojects srvClient.Person.PersonId = person.MemberId; srvClient.Person.Title = person.Title; srvClient.Person.ForeName = person.ForeName; srvClient.Person.Surname = person.Surname; srvClient.Person.MaritalId = person.MaritalStatusId; srvClient.Person.PersonPreviousName = person.PreviousName; srvClient.Person.PersonOccupation = person.Occupation; srvClient.Person.Sex = person.Sex; srvClient.Person.PersonDOB = person.DOB; srvClient.Person.PersonDOD = person.DOD; srvClient.Person.PersonPlaceOfBirth = person.PlaceOfBirth; srvClient.Person.PersonBirthName = person.BirthName; srvClient.Person.PersonSalletForm = person.SalutationLettterFormal; srvClient.Person.PersonSalutationlettterInformal = person.SalutationLettterInformal; srvClient.Person.PersonSalLet = person.SalutationLettterFriendly; srvClient.Person.PersonSalEnv = person.SalutationEnvelope; srvClient.Person.PersonEthnicityId = person.EthnicityId; srvClient.Person.PersonDisability = person.DisabilityId; srvClient.Person.PersonInArmedForces = person.IsInArmedForces; srvClient.Person.PersonArmedForcesNo = person.ArmedForcesNo; srvClient.Person.PersonNINo = person.NINo; //Update the organisation details srvClient.Organisation.OrganisationId = organisation.OrganisationId; srvClient.Organisation.Name = organisation.Name; srvClient.Organisation.RegisteredName = organisation.RegisteredName; srvClient.Organisation.RegisteredNumber = organisation.RegisteredNo; srvClient.Organisation.VATNumber = organisation.VATNo; srvClient.Organisation.SubTypesId = organisation.SubTypeId; string errorMessage; returnValue.Success = srvClient.Save(out errorMessage); if (!returnValue.Success) { throw new Exception(errorMessage); } if (client.MemberId == DataConstants.DummyGuid) { //check if industry has been assigned and update the value if (organisation.IndustryId != 0) { errorMessage = string.Empty; SrvIndustry srvIndustry = new SrvIndustry(); srvIndustry.Id = organisation.IndustryId; srvIndustry.MemberId = DataConstants.DummyGuid; srvIndustry.OrganisationId = organisation.OrganisationId; returnValue.Success = srvIndustry.Save(out errorMessage); } } 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; }