public void AddExtendedInfo(ISearchResult[] bestImages) { // todo? ExtendedResults.AddRange(bestImages); AltFunction = () => { var rg = FromExtendedResult(bestImages); NConsole.IO.HandleOptions(rg); return(null); }; }
public void AddExtendedResults(ISearchResult[] bestImages) { // todo? var rg = FromExtendedResult(bestImages); ExtendedResults.AddRange(rg); foreach (var result in rg) { SearchClient.Client.RunProcessingTask(result); } AltFunction = () => { NConsoleIO.HandleOptions(ExtendedResults); return(null); }; }
private List <string> EnumerateResults(ProgressiveDataSet reader) { List <string> csvRecords = new List <string>(); bool finalResults = false; bool isProgressive = false; try { IEnumerator <ProgressiveDataSetFrame> resultFrames = reader.GetFrames(); while (!finalResults && resultFrames.MoveNext()) //while (resultFrames.MoveNext()) { ProgressiveDataSetFrame resultFrame = resultFrames.Current; Log.Debug($"resultFrame:", resultFrame); switch (resultFrame.FrameType) { case FrameType.DataSetCompletion: { ProgressiveDataSetCompletionFrame result = resultFrame as ProgressiveDataSetCompletionFrame; Log.Info($"{result.GetType()}", result); break; } case FrameType.DataSetHeader: { ProgressiveDataSetHeaderFrame result = resultFrame as ProgressiveDataSetHeaderFrame; Log.Info($"{result.GetType()}", result); isProgressive = result.IsProgressive; break; } case FrameType.DataTable: { ProgressiveDataSetDataTableFrame result = resultFrame as ProgressiveDataSetDataTableFrame; Log.Info($"{result.GetType()}", result); if (result.TableName.Equals("@ExtendedProperties")) { ExtendedResults = EnumerateResults(result.TableData); if (ExtendedResults.Any(x => x.Contains("Cursor"))) { string cursorRecord = ExtendedResults.FirstOrDefault(x => x.Contains("Cursor")); Cursor = $"'{Regex.Match(cursorRecord, @"Cursor,(?<cursor>\d+?)(?:,|$)").Groups["cursor"].Value}'"; Log.Info($"setting db cursor to {Cursor}"); } } if (result.TableKind.Equals(WellKnownDataSet.PrimaryResult)) { csvRecords = EnumerateResults(result.TableData); } // if non progressive, this may be last frame if (!isProgressive) { finalResults = true; } break; } case FrameType.TableCompletion: { ProgressiveDataSetTableCompletionFrame result = resultFrame as ProgressiveDataSetTableCompletionFrame; Log.Info($"{result.GetType()}", result); break; } case FrameType.TableFragment: { ProgressiveDataSetDataTableFragmentFrame result = resultFrame as ProgressiveDataSetDataTableFragmentFrame; Log.Error($"not implemented: {result.GetType()}", result); result.ToDataTable(); break; } case FrameType.TableHeader: { ProgressiveDataSetHeaderFrame result = resultFrame as ProgressiveDataSetHeaderFrame; Log.Info($"{result.GetType()}", result); break; } case FrameType.TableProgress: { ProgressiveDataSetTableProgressFrame result = resultFrame as ProgressiveDataSetTableProgressFrame; Log.Info($"{result.GetType()}", result); break; } case FrameType.LastInvalid: default: { Log.Warning($"unknown frame type:{resultFrame.FrameType}"); return(csvRecords); } } } return(csvRecords); } catch (Exception e) { Log.Exception($"{e}"); return(csvRecords); } }