--- /dev/null
+using System;\r
+using System.Xml;\r
+\r
+namespace TechBot.Library\r
+{\r
+ public class ErrorCommand : BaseCommand, ICommand\r
+ {\r
+ private IServiceOutput serviceOutput;\r
+ private NtStatusCommand ntStatus;\r
+ private WinerrorCommand winerror;\r
+ private HresultCommand hresult;\r
+\r
+ public ErrorCommand(IServiceOutput serviceOutput, string ntstatusXml,\r
+ string winerrorXml, string hresultXml)\r
+ {\r
+ this.serviceOutput = serviceOutput;\r
+ this.ntStatus = new NtStatusCommand(serviceOutput,\r
+ ntstatusXml);\r
+ this.winerror = new WinerrorCommand(serviceOutput,\r
+ winerrorXml);\r
+ this.hresult = new HresultCommand(serviceOutput,\r
+ hresultXml);\r
+ }\r
+ \r
+ public bool CanHandle(string commandName)\r
+ {\r
+ return CanHandle(commandName,\r
+ new string[] { "error" });\r
+ }\r
+\r
+ public void Handle(MessageContext context,\r
+ string commandName,\r
+ string parameters)\r
+ {\r
+ string errorText = parameters;\r
+ if (errorText.Equals(String.Empty))\r
+ {\r
+ serviceOutput.WriteLine(context,\r
+ "Please provide an Error Code.");\r
+ return;\r
+ }\r
+\r
+ NumberParser np = new NumberParser();\r
+ long error = np.Parse(errorText);\r
+ if (np.Error)\r
+ {\r
+ serviceOutput.WriteLine(context,\r
+ String.Format("{0} is not a valid Error Code.",\r
+ errorText));\r
+ return;\r
+ }\r
+\r
+ string description = null;\r
+ if (winerror.GetWinerrorDescription(error) != null)\r
+ {\r
+ description = winerror.GetWinerrorDescription(error);\r
+ serviceOutput.WriteLine(context,\r
+ String.Format("{0} is {1}.",\r
+ error,\r
+ description));\r
+ }\r
+ if (ntStatus.GetNtstatusDescription(error) != null)\r
+ {\r
+ description = ntStatus.GetNtstatusDescription(error);\r
+ serviceOutput.WriteLine(context,\r
+ String.Format("{0} is {1}.",\r
+ errorText,\r
+ description));\r
+ }\r
+ if (hresult.GetHresultDescription(error) != null)\r
+ {\r
+ description = hresult.GetHresultDescription(error);\r
+ serviceOutput.WriteLine(context,\r
+ String.Format("{0} is {1}.",\r
+ errorText,\r
+ description));\r
+ }\r
+ if(description == null)\r
+ {\r
+ serviceOutput.WriteLine(context,\r
+ String.Format("I don't know about Error Code {0}.",\r
+ errorText));\r
+ }\r
+ }\r
+ \r
+ public string Help()\r
+ {\r
+ return "!error <value>";\r
+ }\r
+ }\r
+}\r
<File name=".\NumberParser.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
<File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
<File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
+ <File name=".\ErrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
<File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
<File name=".\BugCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
<File name=".\WmCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
<Output directory="..\bin\Release" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />\r
</Configuration>\r
</Configurations>\r
-</Project>
\ No newline at end of file
+</Project>\r