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(); } } }
/// <summary> /// Search for contacts. /// </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">Contact search criteria.</param> /// <returns></returns> public ContactSearchReturnValue ContactSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ContactSearchCriteria criteria) { ContactSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.ContactSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new ContactSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Search for contacts. /// </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">Contact search criteria.</param> /// <returns></returns> public ContactSearchReturnValue ContactSearch(Guid logonId, CollectionRequest collectionRequest, ContactSearchCriteria criteria) { ContactSearchReturnValue returnValue = new ContactSearchReturnValue(); 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"); } // Create a data list creator for a list of contacts DataListCreator<ContactSearchItem> dataListCreator = new DataListCreator<ContactSearchItem>(); // Declare an inline event (annonymous delegate) to read the dataset dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvContactLookup.WebContactSearch(criteria.ContactName, criteria.Organisation, criteria.HouseNumber, criteria.POBox, criteria.PostCode, 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 returnValue.Contacts = dataListCreator.Create(logonId, // Give the query a name so it can be cached "ContactSearch", // 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("OrganisationId", "orgId"), new ImportMapping("MemberId", "memId"), new ImportMapping("Name", "Name"), new ImportMapping("Address", "Address"), new ImportMapping("Town", "Town"), new ImportMapping("PostCode", "PostCode") } ); } 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> /// Search for contacts. /// </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">Contact search criteria.</param> /// <returns></returns> public ContactSearchReturnValue ContactSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ContactSearchCriteria criteria) { ContactSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.ContactSearch(Functions.GetLogonIdFromToken(oHostSecurityToken),collectionRequest,criteria); } else { returnValue = new ContactSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }