/// <summary> /// Gets the client details. /// </summary> private void GetClientDetails(string matterReference) { ClientServiceClient clientService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; ClientSearchCriteria criteria = new ClientSearchCriteria(); criteria.ClientReference = matterReference.Substring(0, 6); clientService = new ClientServiceClient(); ClientSearchReturnValue returnValue = clientService.ClientSearch(_logonSettings.LogonId, collectionRequest, criteria); if (returnValue.Success) { if (returnValue.Clients != null) { Session[SessionName.MemberId] = returnValue.Clients.Rows[0].MemberId; Session[SessionName.OrganisationId] = returnValue.Clients.Rows[0].OrganisationId; Session[SessionName.ClientRef] = returnValue.Clients.Rows[0].ClientReference; Session[SessionName.ClientName] = returnValue.Clients.Rows[0].Name; } } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (clientService != null) { if (clientService.State != System.ServiceModel.CommunicationState.Faulted) { clientService.Close(); } } } }
/// <summary> /// Get a list of clients 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">Client search criteria</param> /// <returns></returns> public ClientSearchReturnValue ClientSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ClientSearchCriteria criteria) { ClientSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oClientService = new ClientService(); returnValue = oClientService.ClientSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new ClientSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Searches for clients that match the search criteria. /// </summary> public ClientSearchItem[] SearchClient(int startRow, int pageSize, string sortBy, string name, string NINo, string partner, string DOB, string postcode, string town, bool forceRefresh) { ClientServiceClient clientService = null; ClientSearchItem[] clients = null; try { if (HttpContext.Current.Session[SessionName.LogonSettings] != null) { if (name == null || name.Trim() == string.Empty) { if (NINo == null || NINo == string.Empty) { if (partner == null || partner.Trim() == string.Empty) { if (DOB == null || DOB.Trim() == string.Empty) { if (postcode == null || postcode.Trim() == string.Empty) { if (town == null || town.Trim() == string.Empty) { throw new Exception("Please enter search criteria"); } } } } } } if (!IsReset) { // LSC - Insert Wildcards - 28/08/2010 if (!string.IsNullOrWhiteSpace(name) && !name.Contains('%')) { name = "%" + name.Trim() + "%"; } Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = forceRefresh; collectionRequest.StartRow = startRow; collectionRequest.RowCount = pageSize; ClientSearchCriteria criteria = new ClientSearchCriteria(); criteria.Name = name != null?name.Replace("'", "''") : name; criteria.NINumber = NINo != null?NINo.Replace("'", "''") : NINo; criteria.OrganisationId = DataConstants.DummyGuid; criteria.MemberId = DataConstants.DummyGuid; criteria.OrderBy = sortBy; Guid partnerId = DataConstants.DummyGuid; if (partner != null && partner != string.Empty) { partnerId = new Guid(partner); } criteria.Partner = partnerId; if (DOB != null && DOB.Length > 0) { criteria.DateOfBirthFrom = Convert.ToDateTime(DOB.Trim()); criteria.DateOfBirthTo = Convert.ToDateTime(DOB.Trim()); } else { criteria.DateOfBirthFrom = null; criteria.DateOfBirthTo = null; } criteria.PostCode = postcode != null?postcode.Replace("'", "''") : postcode; criteria.Town = town != null?town.Replace("'", "''") : town; clientService = new ClientServiceClient(); ClientSearchReturnValue returnValue = clientService.ClientSearch(_logonId, collectionRequest, criteria); if (returnValue.Success) { _clientRowCount = returnValue.Clients.TotalRowCount; clients = returnValue.Clients.Rows; } else { if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.") { throw new Exception("Date is invalid"); } else { throw new Exception(returnValue.Message); } } } } return(clients); } catch (Exception ex) { throw ex; } finally { if (clientService != null) { if (clientService.State != System.ServiceModel.CommunicationState.Faulted) { clientService.Close(); } } } }
protected void _imgBtnSearch_Click(object sender, ImageClickEventArgs e) { if (_txtSearch.Text.Trim() == string.Empty) { _txtSearch.Text = AllClients; } ClientServiceClient clientService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; ClientSearchCriteria criteria = new ClientSearchCriteria(); if (_txtSearch.Text.Trim() == string.Empty || _txtSearch.Text.Trim() == AllClients) { criteria.Name = string.Empty; } else { criteria.Name = _txtSearch.Text.Trim(); } if (_ddlFeeEarner.SelectedIndex > 0) { criteria.Partner = new Guid(_ddlFeeEarner.SelectedValue); } clientService = new ClientServiceClient(); ClientSearchReturnValue returnValue = clientService.ClientSearch(_logonId, collectionRequest, criteria); _ddlClients.Items.Clear(); _ddlClientMatters.Items.Clear(); if (returnValue.Success) { if (returnValue.Clients.Rows.Length > 0) { foreach (ClientSearchItem client in returnValue.Clients.Rows) { ListItem item = new ListItem(); item.Text = client.ClientReference.Trim() + " - " + client.Name; item.Value = client.MemberId.ToString() + "$" + client.OrganisationId.ToString(); _ddlClients.Items.Add(item); } } else { SuccessEventArgs success = new SuccessEventArgs(); success.Message = "Search is complete. There are no results to display."; OnSearchSuccessful(success); } if (_ddlClients.Items.Count > 0) { _clientRowCount = _ddlClients.Items.Count; Guid memberId = new Guid(GetValueOnIndexFromArray(_ddlClients.SelectedValue, 0)); Guid organisationId = new Guid(GetValueOnIndexFromArray(_ddlClients.SelectedValue, 1)); GetClientMatters(memberId, organisationId); SelectLastMatter(); } } else { ErrorEventArgs error = new ErrorEventArgs(); error.Message = returnValue.Message.Replace("WebClientSearch requires some parameters", "Please select a Fee Earner or use the client search."); OnError(error); } } catch (Exception ex) { ErrorEventArgs error = new ErrorEventArgs(); error.Message = ex.Message; OnError(error); } finally { if (clientService != null) { if (clientService.State != System.ServiceModel.CommunicationState.Faulted) { clientService.Close(); } } } }
/// <summary> /// Get a list of clients 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">Client search criteria</param> /// <returns></returns> public ClientSearchReturnValue ClientSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ClientSearchCriteria criteria) { ClientSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oClientService = new ClientService(); returnValue = oClientService.ClientSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new ClientSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Get a list of clients 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">Client search criteria</param> /// <returns></returns> public ClientSearchReturnValue ClientSearch(Guid logonId, CollectionRequest collectionRequest, ClientSearchCriteria criteria) { ClientSearchReturnValue returnValue = new ClientSearchReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { switch (UserInformation.Instance.UserType) { // Can do everything case DataConstants.UserType.Staff: case DataConstants.UserType.ThirdParty: // The query will return only clients that the third party is allowed to see break; case DataConstants.UserType.Client: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } // Create a data list creator for a list of matters DataListCreator<ClientSearchItem> dataListCreator = new DataListCreator<ClientSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvClientCommon.WebClientSearch(criteria.OrganisationId, criteria.MemberId, criteria.Name, criteria.BusinessSource, criteria.ClientReference, criteria.DateOfBirthFrom, criteria.DateOfBirthTo, criteria.PostCode, criteria.Partner, criteria.Branch, criteria.NINumber, criteria.ClientGroup, criteria.Town); if (criteria.OrderBy != string.Empty) { DataTable dt = Functions.SortDataTable(e.DataSet.Tables[0], criteria.OrderBy); e.DataSet.Tables.Remove("Table"); e.DataSet.Tables.Add(dt); } }; // Create the data list DataList<ClientSearchItem> clientList = dataListCreator.Create(logonId, // Give the query a name so it can be cached "ClientSearch", // 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("MemberId", "memId"), new ImportMapping("OrganisationId", "orgId"), new ImportMapping("ClientReference", "cliRef"), new ImportMapping("Name", "Name"), new ImportMapping("Address","Address"), new ImportMapping("PartnerName", "Partner"), new ImportMapping("Partner","cliPartner"), new ImportMapping("DateOfBirth","DateofBirth"), new ImportMapping("NationalInsuranceNo","personNHINo"), new ImportMapping("DateOfDeath","PersonDOD") } ); clientList.Rows.ForEach(delegate(ClientSearchItem item) { if (item.MemberId != DataConstants.DummyGuid) { if (SrvClientCommon.IsClientArchived(item.MemberId)) { item.IsArchived = true; } else { item.IsArchived = false; } } if (item.OrganisationId != DataConstants.DummyGuid) { if (SrvClientCommon.IsClientArchived(item.OrganisationId)) { item.IsArchived = true; } else { item.IsArchived = false; } } }); returnValue.Clients = clientList; } 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; }