private void InvokeAction(CCommand cmd) { var dres = cmd.InvokeAction(Params.Array.ToArray()); if (!string.IsNullOrEmpty(dres.Message)) { if (dres.Result == CDebugResult.Warn) { LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.WarnMethod, dres.CColor); Beep(800, 100); } else if (dres.Result == CDebugResult.Error) { LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.ErrorMethod, dres.CColor); Beep(85, 300); } else if (dres.Result == CDebugResult.OK) { LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.OKMethod, dres.CColor); Beep(3500, 100); } else if (dres.Result == CDebugResult.Working) { LogFramework.WriteNewLog(dres.Message, dres.CClass, dres.Object, dres.Action, LogEnums.ResultCode.WorkingMethod, dres.CColor); } } }
/* * internal void Add(ConsoleDebug.ActionResult action, string cline, string cl, bool uwp = false, string description = null) * { * Commands.Add(CCommand.New(action, cline, cl, uwp, description)); * } * internal void SAdd(ConsoleDebug.ActionResult action, string cline, string cl, bool uwp = false, string description = null) * { * Commands.Add(CCommand.SNew(action, cline, cl, uwp, description)); * } */ public void WaitCommand(string cline) { bool normal = true; if (string.IsNullOrEmpty(cline)) { normal = false; } if (normal) { if (cline[0] == ' ') { for (var i = 1; i != cline.Length; i++) { if (cline[i] != ' ') { cline = cline.Remove(0, i); break; } } } if (string.IsNullOrEmpty(cline)) { normal = false; } } bool finded = false; if (normal) { string clinesp = cline; //var spacep = clinesp.Length - 1; for (var i = clinesp.Length - 1; i != 0; i--) { if (clinesp[i] == ' ') { clinesp = clinesp.Remove(i, 1); } else { break; } } string c = clinesp; var clines = CommandActions.GetLine(clinesp); if (!Params.IsNull()) { Params.Clear(); } if (clines.Length > 1) { Params = new ExtraArray <CParameter>(CParameter.FromLine(clinesp).ToArray().AsMemory()); var cc = clinesp.Split(' '); c = cc[0]; } foreach (var item in GetCCommandList()) { if (item.CommandLine == c) { finded = true; if (Params.Count == item.Params.Length) { InvokeAction(item); } else { if (item.Params.Length > 0 && !item.UseWithoutParams) { var ot = $""; foreach (var item1 in item.Params) { ot += $" <{item1}>"; } Beep(800, 100); LogFramework.WriteNewLog($"Instruction of {item.CommandLine}:{ot}.", CClass, this, null, LogEnums.ResultCode.WarnMethod); } else if (item.Params.Length > 0 && item.UseWithoutParams) { InvokeAction(item); } else { Beep(800, 100); LogFramework.WriteNewLog($"{item.CommandLine}: using without parameters.", CClass, this, null, LogEnums.ResultCode.WarnMethod); } } } } } if (!finded) { LogFramework.WriteNewLog("Unknown command.", CClass, this, null, LogEnums.ResultCode.ErrorMethod); Beep(85, 300); } }
/// <summary> /// Invokes message for debug. /// </summary> /// <param name="text">Text for invoke.</param> /// <param name="resultCode">State of cmd.</param> /// <param name="cColor">Console color (work if ResultCode = OK)</param> public void InvokeMessage(string text, LogEnums.ResultCode resultCode, ConsoleColor cColor = ConsoleColor.Green, Exception ex = null) { LogFramework.WriteNewLog(text, CClass, this, Command.Action, resultCode, cColor, ex); }