/// <summary> /// Gets the organisation. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="clientId">The client id.</param> /// <returns></returns> public OrganisationReturnValue GetOrganisation(HostSecurityToken oHostSecurityToken, Guid organisationId) { OrganisationReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.GetOrganisation(Functions.GetLogonIdFromToken(oHostSecurityToken), organisationId); } else { returnValue = new OrganisationReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Gets the name of the organisation to perform conflict check. /// </summary> /// <param name="clientId">The client id.</param> /// <returns></returns> private string GetOrganisationName(Guid clientId) { string name = string.Empty; ContactServiceClient contactService = null; try { contactService = new ContactServiceClient(); OrganisationReturnValue returnValue = contactService.GetOrganisation(_logonSettings.LogonId, clientId); if (returnValue.Success) { if (returnValue.Organisation != null) { name = returnValue.Organisation.Name; } } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService != null) { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) { contactService.Close(); } } } return(name); }
/// <summary> /// Gets the organisation. /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service.</param> /// <param name="clientId">The client id.</param> /// <returns></returns> public OrganisationReturnValue GetOrganisation(Guid logonId, Guid organisationId) { OrganisationReturnValue returnValue = new OrganisationReturnValue(); 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(DataConstants.DummyGuid, organisationId)) throw new Exception("Access denied"); break; case DataConstants.UserType.ThirdParty: if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, organisationId)) throw new Exception("Access denied"); break; default: throw new Exception("Access denied"); } DsOrganisations dsOrganisations = SrvOrganisationlookup.GetOrganisation(organisationId); if (dsOrganisations.Organisations.Rows.Count > 0) { returnValue.Organisation = new Organisation(); returnValue.Organisation.OrganisationId = dsOrganisations.Organisations[0].OrgID; returnValue.Organisation.Name = dsOrganisations.Organisations[0].OrgName.Trim(); returnValue.Organisation.RegisteredName = dsOrganisations.Organisations[0].OrgRegisteredName.Trim(); returnValue.Organisation.RegisteredNo = dsOrganisations.Organisations[0].OrgRegisteredNumber.Trim(); returnValue.Organisation.VATNo = dsOrganisations.Organisations[0].OrgVatNumber; returnValue.Organisation.SubTypeId = dsOrganisations.Organisations[0].OrgSubTypesID; } } 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> /// Loads the contact details. /// </summary> private void LoadContact() { ContactServiceClient serviceClient = null; try { serviceClient = new ContactServiceClient(); //_contactReturnValue = serviceClient.GetGeneralContact(_logonSettings.LogonId, _memberId, _organisationId); if (_memberId != DataConstants.DummyGuid) { _personReturnValue = serviceClient.GetPerson(_logonSettings.LogonId, _memberId); if (_personReturnValue.Success) { DisplayContactData(); } else { throw new Exception(_contactReturnValue.Message); } } else if (_organisationId != DataConstants.DummyGuid) { _organisationReturnValue = serviceClient.GetOrganisation(_logonSettings.LogonId, _organisationId); if (_organisationReturnValue.Success) { DisplayContactData(); } else { throw new Exception(_contactReturnValue.Message); } } } catch (Exception ex) { throw ex; } finally { if (serviceClient != null) { if (serviceClient.State != System.ServiceModel.CommunicationState.Faulted) serviceClient.Close(); } } }
/// <summary> /// Gets the organisation. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="clientId">The client id.</param> /// <returns></returns> public OrganisationReturnValue GetOrganisation(HostSecurityToken oHostSecurityToken, Guid organisationId) { OrganisationReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.GetOrganisation(Functions.GetLogonIdFromToken(oHostSecurityToken), organisationId); } else { returnValue = new OrganisationReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }