public ContactSearchItem[] SearchContact(int startRow, int pageSize, string sortBy, string contactName, string organisation, string houseNo, string POBox, string postCode, string town, bool forceRefresh) { ContactServiceClient contactService = null; ContactSearchItem[] contacts = null; try { if (HttpContext.Current.Session[SessionName.LogonSettings] != null) { Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = forceRefresh; collectionRequest.StartRow = startRow; collectionRequest.RowCount = pageSize; ContactSearchCriteria criteria = new ContactSearchCriteria(); criteria.ContactName = contactName; criteria.HouseNumber = houseNo; criteria.Organisation = organisation; criteria.POBox = POBox; criteria.PostCode = postCode; criteria.Town = town; criteria.OrderBy = sortBy; contactService = new ContactServiceClient(); ContactSearchReturnValue returnValue = contactService.ContactSearch(_logonId, collectionRequest, criteria); if (returnValue.Success) { contacts = returnValue.Contacts.Rows; _contactSearchRowCount = returnValue.Contacts.TotalRowCount; } else { ErrorEventArgs e = new ErrorEventArgs(); e.Message = returnValue.Message; OnError(e); } } return(contacts); } catch (Exception ex) { throw ex; } finally { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) { contactService.Close(); } } }
public ContactSearchItem[] SearchContact(int startRow, int pageSize, string sortBy, string contactName, string organisation, string houseNo, string POBox, string postCode, string town, bool forceRefresh) { ContactServiceClient contactService = null; ContactSearchItem[] contacts = null; try { if (HttpContext.Current.Session[SessionName.LogonSettings] != null) { Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = forceRefresh; collectionRequest.StartRow = startRow; collectionRequest.RowCount = pageSize; ContactSearchCriteria criteria = new ContactSearchCriteria(); criteria.ContactName = contactName; criteria.HouseNumber = houseNo; criteria.Organisation = organisation; criteria.POBox = POBox; criteria.PostCode = postCode; criteria.Town = town; criteria.OrderBy = sortBy; contactService = new ContactServiceClient(); ContactSearchReturnValue returnValue = contactService.ContactSearch(_logonId, collectionRequest, criteria); if (returnValue.Success) { contacts = returnValue.Contacts.Rows; _contactSearchRowCount = returnValue.Contacts.TotalRowCount; } else { ErrorEventArgs e = new ErrorEventArgs(); e.Message = returnValue.Message; OnError(e); } } return contacts; } catch (Exception ex) { throw ex; } finally { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) contactService.Close(); } }