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; }
public ServiceResponses(string Name, BlackLight.Services.Modules.Help.Lists.ErrorList Errors, BlackLight.Services.Modules.Help.Lists.CommandList Commands) { this.Name = Name; this.Errors = Errors; this.Commands = Commands; }