/// <summary> /// Binds association roles /// </summary> private void BindAssociationRoles() { ContactServiceClient contactService = new ContactServiceClient(); try { CollectionRequest collectionRequest = new CollectionRequest(); AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria(); //PMS associationRoleCriteria.ApplicationId = 1; AssociationRoleSearchReturnValue associationRoleReturnValue = contactService.AssociationRoleForApplicationSearch(_logonSettings.LogonId, collectionRequest, associationRoleCriteria); if (associationRoleReturnValue.Success) { if (associationRoleReturnValue.AssociationRole != null) { //Sort based on AssociationRoleDescription IEnumerable <AssociationRoleSearchItem> assocRolesSorted = associationRoleReturnValue.AssociationRole.Rows.OrderBy(role => role.AssociationRoleDescription); _ddlRole.DataSource = assocRolesSorted; _ddlRole.DataTextField = "AssociationRoleDescription"; _ddlRole.DataValueField = "AssociationRoleID"; _ddlRole.DataBind(); } } else { throw new Exception(associationRoleReturnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) { contactService.Close(); } } }
/// <summary> /// Search for association roles based on the application /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">AssociationRole search criteria.</param> /// <returns></returns> public AssociationRoleSearchReturnValue AssociationRoleForApplicationSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, AssociationRoleSearchCriteria criteria) { AssociationRoleSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.AssociationRoleForApplicationSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new AssociationRoleSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Get a list of partners that match the search criteria /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Association Roles search criteria</param> /// <returns></returns> public AssociationRoleSearchReturnValue AssociationRoleSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, AssociationRoleSearchCriteria criteria) { AssociationRoleSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.AssociationRoleSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new AssociationRoleSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Binds association roles /// </summary> private void BindAssociationRoles() { ContactServiceClient contactService = new ContactServiceClient(); try { CollectionRequest collectionRequest = new CollectionRequest(); AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria(); //PMS associationRoleCriteria.ApplicationId = 1; AssociationRoleSearchReturnValue associationRoleReturnValue = contactService.AssociationRoleForApplicationSearch(_logonSettings.LogonId, collectionRequest, associationRoleCriteria); if (associationRoleReturnValue.Success) { if (associationRoleReturnValue.AssociationRole != null) { //Sort based on AssociationRoleDescription IEnumerable<AssociationRoleSearchItem> assocRolesSorted = associationRoleReturnValue.AssociationRole.Rows.OrderBy(role => role.AssociationRoleDescription); _ddlRole.DataSource = assocRolesSorted; _ddlRole.DataTextField = "AssociationRoleDescription"; _ddlRole.DataValueField = "AssociationRoleID"; _ddlRole.DataBind(); } } else { throw new Exception(associationRoleReturnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) contactService.Close(); } }
/// <summary> /// Show/hide the search that can be performed based on the selected association role id /// </summary> private void ShowHideAssociationSearch() { if (_ddlRole.Items.Count > 0) { CheckForClientOnSpecialMatters(); //Create a json object that will be used to show/hide the available searches. string jsonStr = "{"; ContactServiceClient contactService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria(); associationRoleCriteria.RoleId = Convert.ToInt32(_ddlRole.SelectedValue); contactService = new ContactServiceClient(); AssociationRoleSearchReturnValue associationRoleReturnValue = contactService.AssociationRoleForRoleIdSearch(_logonSettings.LogonId, collectionRequest, associationRoleCriteria); if (associationRoleReturnValue.Success) { if (associationRoleReturnValue.AssociationRole != null) { // Decide which rows to Show/Hide based on the selected role. // Build a json object which will be used to show/hide the options using js if (associationRoleReturnValue.AssociationRole.Rows.Length > 0) { // Client & Matter. if ((associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) && (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter)) { _lblClientSearch.Text = "Client/Matter"; jsonStr += "\"ClientSearch\":\"true\""; _clientSearch.DisplayMattersForClientGridview = true; } // Client. else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) { _lblClientSearch.Text = "Client"; jsonStr += "\"ClientSearch\":\"true\""; _clientSearch.DisplayMattersForClientGridview = false; } // Matter. else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter) { _lblClientSearch.Text = "Matter"; jsonStr += "\"ClientSearch\":\"true\""; _clientSearch.DisplayMattersForClientGridview = true; } else { jsonStr += "\"ClientSearch\":\"false\""; } // General Contact. if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchGeneral) { jsonStr += ",\"ContactSearch\":\"true\""; } else { jsonStr += ",\"ContactSearch\":\"false\""; } // Service Contact. if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchService) { jsonStr += ",\"ServiceSearch\":\"true\""; } else { jsonStr += ",\"ServiceSearch\":\"false\""; } // Search for Fee Earner if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchFeeEarner) { jsonStr += ",\"FeeEarnerSearch\":\"true\""; } else { jsonStr += ",\"FeeEarnerSearch\":\"false\""; } jsonStr += "}"; _hdnSearchDisplay.Value = jsonStr; // Determine whether the selected Association Role requires a specialised search. if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSpecialisedSearch) { _hdnIsSpecialisedSearch.Value = "true"; } else { _hdnIsSpecialisedSearch.Value = "false"; } } } } else { throw new Exception(associationRoleReturnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService != null) { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) contactService.Close(); } } } }
/// <summary> /// Show/hide the search that can be performed based on the selected association role id /// </summary> private void ShowHideAssociationSearch() { if (_ddlRole.Items.Count > 0) { CheckForClientOnSpecialMatters(); //Create a json object that will be used to show/hide the available searches. string jsonStr = "{"; ContactServiceClient contactService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria(); associationRoleCriteria.RoleId = Convert.ToInt32(_ddlRole.SelectedValue); contactService = new ContactServiceClient(); AssociationRoleSearchReturnValue associationRoleReturnValue = contactService.AssociationRoleForRoleIdSearch(_logonSettings.LogonId, collectionRequest, associationRoleCriteria); if (associationRoleReturnValue.Success) { if (associationRoleReturnValue.AssociationRole != null) { // Decide which rows to Show/Hide based on the selected role. // Build a json object which will be used to show/hide the options using js if (associationRoleReturnValue.AssociationRole.Rows.Length > 0) { // Client & Matter. if ((associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) && (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter)) { _lblClientSearch.Text = "Client/Matter"; jsonStr += "\"ClientSearch\":\"true\""; _clientSearch.DisplayMattersForClientGridview = true; } // Client. else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) { _lblClientSearch.Text = "Client"; jsonStr += "\"ClientSearch\":\"true\""; _clientSearch.DisplayMattersForClientGridview = false; } // Matter. else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter) { _lblClientSearch.Text = "Matter"; jsonStr += "\"ClientSearch\":\"true\""; _clientSearch.DisplayMattersForClientGridview = true; } else { jsonStr += "\"ClientSearch\":\"false\""; } // General Contact. if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchGeneral) { jsonStr += ",\"ContactSearch\":\"true\""; } else { jsonStr += ",\"ContactSearch\":\"false\""; } // Service Contact. if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchService) { jsonStr += ",\"ServiceSearch\":\"true\""; } else { jsonStr += ",\"ServiceSearch\":\"false\""; } // Search for Fee Earner if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchFeeEarner) { jsonStr += ",\"FeeEarnerSearch\":\"true\""; } else { jsonStr += ",\"FeeEarnerSearch\":\"false\""; } jsonStr += "}"; _hdnSearchDisplay.Value = jsonStr; // Determine whether the selected Association Role requires a specialised search. if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSpecialisedSearch) { _hdnIsSpecialisedSearch.Value = "true"; } else { _hdnIsSpecialisedSearch.Value = "false"; } } } } else { throw new Exception(associationRoleReturnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService != null) { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) { contactService.Close(); } } } } }
/// <summary> /// Get a list of partners that match the search criteria /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service.</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Association Roles search criteria</param> /// <returns></returns> public AssociationRoleSearchReturnValue AssociationRoleSearch(Guid logonId, CollectionRequest collectionRequest, AssociationRoleSearchCriteria criteria) { AssociationRoleSearchReturnValue returnValue = new AssociationRoleSearchReturnValue(); 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: case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: // Can do everything break; default: throw new Exception("Access denied"); } // Create a data list creator for a list of association roles DataListCreator<AssociationRoleSearchItem> dataListCreator = new DataListCreator<AssociationRoleSearchItem>(); // Declare an inline event (annonymous delegate) to read the dataset dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvAssociationRoleLookup.GetGeneralContactAssociationRoles(criteria.IncludeArchived); }; // Create the data list returnValue.AssociationRole = dataListCreator.Create(logonId, // Give the query a name so it can be cached "AssociationRoleSearch", // Tell it the query criteria used so if the cache is accessed // again it knows if it is the same query criteria.ToString(), collectionRequest, // Import mappings to map the dataset row fields to the data // list entity properties new ImportMapping[] { new ImportMapping("AssociationRoleID", "AssociationRolesID"), new ImportMapping("AssociationRoleDescription", "AssociationRoleDescription") } ); } 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; }