/// <summary> /// Generates the execution result, a list of individual results for each resolver tracked. /// </summary> /// <returns>IDictionary<System.String, System.Object>.</returns> private IResponseFieldSet GenerateExecutionResult() { // apollo tracing does not specifiy providing startOffset and duration keys for the execution // phase, just output the resolvers array var list = new ResponseList(); foreach (var timeEntry in _resolverEntries.OrderBy(x => x.Value.StartOffsetTicks)) { var resolverEntry = new ResponseFieldSet(); resolverEntry.Add("path", new ResponseList(timeEntry .Key .Request .Origin .Path .ToArray() .Select(x => new ResponseSingleValue(x)))); var parentType = _schema.KnownTypes.FindGraphType(timeEntry.Key.Request?.DataSource?.Value); if (parentType != null) { resolverEntry.AddSingleValue("parentType", parentType.Name); } resolverEntry.AddSingleValue("fieldName", timeEntry.Key.Request.Field.Name); resolverEntry.AddSingleValue("returnType", timeEntry.Key.Request.Field.TypeExpression.ToString()); resolverEntry.AddSingleValue("startOffset", timeEntry.Value.StartOffsetNanoseconds); resolverEntry.AddSingleValue("duration", timeEntry.Value.DurationNanoSeconds); list.Add(resolverEntry); } var dictionary = new ResponseFieldSet(); dictionary.Add("resolvers", list); return(dictionary); }
/// <summary> /// Adds the specified <paramref name="slimResponse"/> to the list of responses after applying the filters specified in /// the search options. /// </summary> /// <param name="slimResponse">The response to add.</param> public void AddResponse(SearchResponseSlim slimResponse) { if (State.HasFlag(SearchStates.InProgress) && slimResponse.Token == Token && ResponseMeetsOptionCriteria(slimResponse)) { var fullResponse = new SearchResponse(slimResponse); fullResponse = new SearchResponse(fullResponse, fullResponse.Files.Where(f => FileMeetsOptionCriteria(f)).ToList()); if (Options.FilterResponses && fullResponse.FileCount < Options.MinimumResponseFileCount) { return; } Interlocked.Add(ref resultCount, fullResponse.Files.Count); ResponseList.Add(fullResponse); ResponseReceived?.Invoke(this, fullResponse); SearchTimeoutTimer.Reset(); if (resultCount >= Options.FileLimit) { Complete(SearchStates.FileLimitReached); } } }
/// <summary> /// Generates a result representing the list items of this instance. This result /// is built in a manner that can be easily serialized. /// </summary> /// <param name="result">The result that was generated.</param> /// <returns><c>true</c> if the result that was generated is valid and should /// be included in a final result, <c>false</c> otherwise.</returns> private bool GenerateListItemResult(out IResponseItem result) { result = null; var includeResult = false; // this instance represents an array of children // create an output array of the generated data for each child if (_childListItems.Count == 0) { result = new ResponseList(); includeResult = true; } else { var list = new ResponseList(); foreach (var child in _childListItems) { var includeChildResult = child.GenerateResult(out var childResult); includeResult = includeResult || includeChildResult; if (includeChildResult) { list.Add(childResult); } } if (includeResult) { result = list; } } return(includeResult); }
private void ShowResult(Query value) { lock (_lock) { ResponseList.Add(value); } }
public override bool ModLoad() { HelpResponses = new ResponseList(); string loadDir; string loadFile; if (MyBase.ConfigManager.Configuration.ContainsKey("services-help1")) { OptionsList myConfig = MyBase.ConfigManager.Configuration["services-help1"]; if (myConfig.ContainsKey("help-file-directory1")) { loadDir = myConfig["help-file-directory1"]; } else { loadDir = "help/"; } if (myConfig.ContainsKey("help-language1")) { loadFile = myConfig["help-language1"]; } else { loadFile = "en.lang"; } } else { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Failed to find help configuration block", "", "", ""); return false; } if (new DirectoryInfo(loadDir).Exists == false) { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Failed to find help file directory", "Using default of \"help/\"", "", ""); loadDir = "help/"; if (new DirectoryInfo(loadDir).Exists == false) { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Failed to find help file directory", "", "", ""); return false; } } if (File.Exists(loadDir + loadFile) == false) { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Failed to find language file", "Using default of \"en.lang\"", "", ""); loadDir = "en.lang"; if (File.Exists(loadDir + loadFile) == false) { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Failed to find language file", "", "", ""); return false; } } System.Xml.XmlDocument XMLDOC = new System.Xml.XmlDocument(); XMLDOC.Load(loadDir + loadFile); string tName; string tErrorName; string tErrorValue; string[] tErrorValues; BlackLight.Services.Modules.Help.Lists.ErrorList tErrors = new BlackLight.Services.Modules.Help.Lists.ErrorList(); BlackLight.Services.Modules.Help.Lists.CommandList tCommands = new BlackLight.Services.Modules.Help.Lists.CommandList(); foreach (XmlNode tNode in XMLDOC.DocumentElement) { if (tNode.Name == "service") { if (tNode.Attributes["name"] != null && tNode.Attributes["name"].Value != "") { tName = tNode.Attributes["name"].Value; } else { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", ""); //MessageBox.Show("XML Data corruption"); return false; } foreach (XmlNode tNodeInner in tNode) { if (tNodeInner.Name == "responses") { foreach (XmlNode tErrorNode in tNodeInner) { if (tErrorNode.Attributes["name"] != null && tErrorNode.Attributes["name"].Value != "") { tErrorName = tErrorNode.Attributes["name"].Value; } else { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", ""); //Show("XML Data corruption"); return false; } if (tErrorNode.InnerText != null&& tErrorNode.InnerText != "") { tErrorValue = tErrorNode.InnerText.Trim(); } else { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", ""); //MessageBox.Show("XML Data corruption"); return false; } tErrorValue = tErrorValue.Replace(" ", " "); tErrorValue = tErrorValue.Replace(" ", " "); tErrorValue = tErrorValue.Replace("`B", ""); tErrorValue = tErrorValue.Replace("`U", ""); tErrorValue = tErrorValue.Replace("\r\n", "\r"); tErrorValue = tErrorValue.Replace("\n", "\r"); tErrorValues = tErrorValue.Split('\r'); tErrors.Add(new ServiceErrorResponse(tErrorName, tErrorValues)); } } else if (tNodeInner.Name == "commands") { if (GetAllCommands(tNodeInner, tCommands) == false) { return false; } } else { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", ""); //MessageBox.Show("XML Data corruption"); return false; } } HelpResponses.Add(new ServiceResponses(tName, tErrors, tCommands)); } else { MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", ""); //MessageBox.Show("XML Data corruption"); return false; } } //ListLoaded() return true; }