private void ProcessRecordsReferencingTheWord(TextSearchContainer container) { //Search For String Field Matches //Append The Search For Records Referencing Records Which ZHad Name Matches //Then Output The Matching Fields From Those RecordTypes var bookmark = container.AddHeadingWithBookmark("Field Matches"); var recordTypes = GetSearchRecordTypes().ToArray(); var count = recordTypes.Count(); var done = 0; //load all the activity party references foreach (var recordType in recordTypes) { var recordsToOutput = new Dictionary <string, IRecord>(); try { AppendStringFieldMatches(container, recordType, done, count, recordsToOutput); AppendReferenceMatches(container, done, count, recordType, recordsToOutput); AppendFieldMatchesToDocument(container, recordsToOutput, recordType, bookmark); } catch (Exception ex) { container.Response.AddResponseItem( new TextSearchResponseItem("Error Searching Entity Fields", recordType, ex)); } done++; } }
private void ProcessEntireRecordExtracts(TextSearchContainer container) { //for each record with exact match on name do record extract //3. foreachrecord with name output them through recordextract var done = 0; var count = container.NameMatches.Count; var typesWithExactNameMatch = container.NameMatches.Select(r => r.Type).Distinct(); var bookmark = container.AddHeadingWithBookmark("Detail of Records With Name Match"); foreach (var type in typesWithExactNameMatch.OrderBy(Service.GetDisplayName)) { var thisType = type; var thisBookmark = container.Section.AddHeading2WithBookmark(Service.GetCollectionName(thisType)); bookmark.AddChildBookmark(thisBookmark); foreach (var record in container.NameMatches.Where(r => r.Type == thisType)) { try { container.Controller.UpdateProgress(done++, count, string.Format("Extracting Detail For {0} {1}", Service.GetDisplayName(type), record.GetStringField(Service.GetPrimaryField(type)))); var thisResponse = RecordExtractService.ExtractRecordToDocument(container.Controller.GetLevel2Controller(), record.ToLookup(), container.Section, container.Request.DetailOfRecordsRelatedToMatches); container.Response.AddResponseItems( thisResponse.ResponseItems.Select(r => new TextSearchResponseItem(r))); if (!thisResponse.Success) { throw thisResponse.Exception; } thisBookmark.AddChildBookmarks(thisResponse.Bookmarks); } catch (Exception ex) { container.Response.AddResponseItem(new TextSearchResponseItem("Error Extracting Record", thisType, ex)); } } } }
void ProcessRecordsContainedInName(TextSearchContainer container) { var bookmark = container.AddHeadingWithBookmark("Records With Matching Name"); var recordTypes = GetSearchRecordTypes().ToArray(); var count = recordTypes.Count(); var done = 0; foreach (var recordType in recordTypes) { try { var progressTextPrefix = string.Format("Searching Record Names In {0}", Service.GetCollectionName(recordType)); container.Controller.UpdateProgress(done++, count, progressTextPrefix); var primaryField = Service.GetPrimaryField(recordType); if (!primaryField.IsNullOrWhiteSpace()) { var conditions = new[] { new Condition(primaryField, ConditionType.Like, string.Format("%{0}%", container.Request.SearchText)) }; var matches = Service.RetrieveAllAndClauses(recordType, conditions, new[] { primaryField }).ToArray(); if (matches.Any()) { try { var thisBookmark = container.Section.AddHeading2WithBookmark(string.Format("{0} ({1})", Service.GetCollectionName(recordType), matches.Count())); bookmark.AddChildBookmark(thisBookmark); var table = container.Section.Add1ColumnTable(); var matchCount = matches.Count(); var matchCountDone = 0; foreach (var match in matches) { container.Controller.UpdateProgress(done, count, string.Format("{0} (Adding {1} Of {2})", progressTextPrefix, ++matchCountDone, matchCount)); container.AddNameMatch(match); var outputText = match.GetStringField(primaryField); outputText = ExtractUtility.CheckStripFormatting(outputText, recordType, primaryField); table.AddRow(outputText); } } catch (Exception ex) { container.Response.AddResponseItem( new TextSearchResponseItem("Error Adding Matched Record", recordType, ex)); } } } } catch (Exception ex) { container.Response.AddResponseItem(new TextSearchResponseItem("Error Adding Match Records", recordType, ex)); } } }