public static PartnerFindTDSSearchResultTable FindPartners(string AFirstName, string AFamilyNameOrOrganisation, string ACity, string APartnerClass, short AMaxRecords, out int ATotalRecords) { TPartnerFind PartnerFind = new TPartnerFind(); PartnerFindTDSSearchCriteriaTable CriteriaData = new PartnerFindTDSSearchCriteriaTable(); PartnerFindTDSSearchCriteriaRow CriteriaRow = CriteriaData.NewRowTyped(); CriteriaData.Rows.Add(CriteriaRow); CriteriaRow.PartnerName = AFamilyNameOrOrganisation; // CriteriaRow.PersonalName = AFirstName; CriteriaRow.City = ACity; // TODO: only works for one partner class at the moment if (APartnerClass.Length > 0) { CriteriaRow.PartnerClass = APartnerClass; } else { CriteriaRow.PartnerClass = "*"; } PartnerFind.PerformSearch(CriteriaData, true); Int32 TotalRecords; short TotalPages; DataTable typedResult = PartnerFind.GetDataPagedResult(0, AMaxRecords, out TotalRecords, out TotalPages); // tell the web client how many records have been found ATotalRecords = TotalRecords; return((PartnerFindTDSSearchResultTable)typedResult); }
public static PartnerFindTDS FindPartners(string AFirstName, string AFamilyNameOrOrganisation, string ACity, string APartnerClass) { TPartnerFind PartnerFind = new TPartnerFind(); PartnerFindTDSSearchCriteriaTable CriteriaData = new PartnerFindTDSSearchCriteriaTable(); PartnerFindTDSSearchCriteriaRow CriteriaRow = CriteriaData.NewRowTyped(); CriteriaData.Rows.Add(CriteriaRow); CriteriaRow.PartnerName = AFamilyNameOrOrganisation; // CriteriaRow.PersonalName = AFirstName; CriteriaRow.City = ACity; // TODO: only works for one partner class at the moment if (APartnerClass.Length > 0) { CriteriaRow.PartnerClass = APartnerClass; } else { CriteriaRow.PartnerClass = "*"; } PartnerFind.PerformSearch(CriteriaData, true); Int32 TotalRecords; short TotalPages; const short MaxRecords = 50; PartnerFindTDS result = new PartnerFindTDS(); DataTable typedResult = PartnerFind.GetDataPagedResult(0, MaxRecords, out TotalRecords, out TotalPages); if (typedResult != null) { result.SearchResult.Merge(typedResult); if (TotalRecords > MaxRecords) { // TODO load all data into the datatable. the webconnector does not have paging yet? } } return(result); }
public static PartnerFindTDS FindPartners(Int64 APartnerKey, Boolean AExactMatch) { TPartnerFind PartnerFind = new TPartnerFind(); PartnerFindTDSSearchCriteriaTable CriteriaData = new PartnerFindTDSSearchCriteriaTable(); PartnerFindTDSSearchCriteriaRow CriteriaRow = CriteriaData.NewRowTyped(); CriteriaData.Rows.Add(CriteriaRow); CriteriaRow.PartnerKey = APartnerKey; CriteriaRow.PartnerClass = "*"; CriteriaRow.ExactPartnerKeyMatch = AExactMatch; // call this in the same thread, without progress tracker. bool UseDifferentThread = false; PartnerFind.PerformSearch(CriteriaData, true, UseDifferentThread); // NOTE from AlanP - Dec 2015: // If CriteriaRow.ExactPartnerKeyMatch is false and the value of APartnerKey is, say, 0012345600 the search will return all partners between // 001234500 and 001234599. This means that if we request 50 records we may not actually get the partnerkey record we asked for. Int32 TotalRecords; short TotalPages; const short MaxRecords = 50; PartnerFindTDS result = new PartnerFindTDS(); DataTable typedResult = PartnerFind.GetDataPagedResult(0, MaxRecords, out TotalRecords, out TotalPages); if (typedResult != null) { result.SearchResult.Merge(typedResult); if (TotalRecords > MaxRecords) { // TODO load all data into the datatable. the webconnector does not have paging yet? // See above NOTE if ExactPartnerMatch is false! } } return(result); }
public static PartnerFindTDSSearchResultTable FindPartners( string APartnerKey, string AFirstName, string AFamilyNameOrOrganisation, string AStreetName, string ACity, string APostCode, string AEmailAddress, string APartnerClass, bool AActiveOnly, string ASortBy, Int16 AMaxRecords, out Int32 ATotalRecords, out TVerificationResultCollection AVerificationResult) { TPartnerFind PartnerFind = new TPartnerFind(); AVerificationResult = new TVerificationResultCollection(); ATotalRecords = -1; PartnerFindTDSSearchCriteriaTable CriteriaData = new PartnerFindTDSSearchCriteriaTable(); PartnerFindTDSSearchCriteriaRow CriteriaRow = CriteriaData.NewRowTyped(); CriteriaData.Rows.Add(CriteriaRow); CriteriaRow.PartnerName = "%" + AFamilyNameOrOrganisation + "%"; if (APartnerKey.Length > 0) { Int64 PartnerKey = -1; if (!Int64.TryParse(APartnerKey, out PartnerKey)) { AVerificationResult.Add(new TVerificationResult("error", "Invalid Contact Key", "error_invalid_contact_key", TResultSeverity.Resv_Critical)); return(new PartnerFindTDSSearchResultTable()); } CriteriaRow.PartnerKey = PartnerKey; CriteriaRow.ExactPartnerKeyMatch = false; } // CriteriaRow.PersonalName = AFirstName; CriteriaRow.City = ACity; CriteriaRow.Address2 = AStreetName; CriteriaRow.Email = AEmailAddress; // TODO: only works for one partner class at the moment if (APartnerClass.Length > 0) { CriteriaRow.PartnerClass = APartnerClass; } else { CriteriaRow.PartnerClass = "*"; } if (APostCode.Length > 0) { CriteriaRow.PostCode = APostCode; } if (AActiveOnly) { CriteriaRow.PartnerStatus = MPartnerConstants.PARTNERSTATUS_ACTIVE; } else { CriteriaRow.PartnerStatus = "*"; } CriteriaRow.SortBy = ASortBy; // call this in the same thread, without progress tracker. bool UseDifferentThread = false; PartnerFind.PerformSearch(CriteriaData, true, UseDifferentThread); Int32 TotalRecords; Int16 TotalPages; if (AMaxRecords <= 0) { AMaxRecords = 32767; } DataTable typedResult = PartnerFind.GetDataPagedResult(0, AMaxRecords, out TotalRecords, out TotalPages); // tell the web client how many records have been found ATotalRecords = TotalRecords; return((PartnerFindTDSSearchResultTable)typedResult); }
/// <summary> /// Returns the specified find results page. /// /// @comment Pages can be requested in any order! /// /// </summary> /// <param name="APage">Page to return</param> /// <param name="APageSize">Number of records to return per page</param> /// <param name="ATotalRecords">The amount of rows found by the SELECT statement</param> /// <param name="ATotalPages">The number of pages that will be needed on client-side to /// hold all rows found by the SELECT statement</param> /// <returns>DataTable containing the find result records for the specified page /// </returns> public DataTable GetDataPagedResult(System.Int16 APage, System.Int16 APageSize, out System.Int32 ATotalRecords, out System.Int16 ATotalPages) { return(FPartnerFind.GetDataPagedResult(APage, APageSize, out ATotalRecords, out ATotalPages)); }