private bool TryExecuteSingleCommand(string commandLine, bool manualMode = false) { IList <string> tokensList = CommandTokenizer.Tokenize(commandLine); if (tokensList.Count > 0) { string commandName = tokensList[0]; CCommand command = CRegistery.FindCommand(commandName); if (command != null) { command.Delegate = m_delegate; command.IsManualMode = manualMode; command.CommandString = commandLine; bool succeed = command.ExecuteTokens(tokensList, commandLine); command.Clear(); return(succeed); } if (manualMode) { m_delegate.LogTerminal(StringUtils.C(commandName + ": command not found", ColorCode.ErrorUnknownCommand)); } } return(false); }
////////////////////////////////////////////////////////////////////////////// #region Autocomplete public string DoAutoComplete(string line, int index, bool isDoubleTab) { try { CTerminalAutocompletion.Result result = CTerminalAutocompletion.Autocomplete(line, index); if (isDoubleTab && result.suggestions != null) { Add(CCommand.Prompt(line)); Add(result.suggestions); } return result.line; } catch (CCommandAutoCompleteException e) { Add(CCommand.Prompt(line)); Add(e.InnerException, "Exception while auto completing args"); } catch (Exception e) { Add(CCommand.Prompt(line)); Add(e, "Inner command auto completion error"); } return null; }
private static bool AddCommand(CCommand cmd) { string name = cmd.Name; for (LinkedListNode <CCommand> node = m_commands.First; node != null; node = node.Next) { CCommand otherCmd = node.Value; if (cmd == otherCmd) { return(false); // no duplicates } string otherName = otherCmd.Name; int compare = name.CompareTo(otherName); if (compare < 0) { m_commands.AddBefore(node, cmd); m_commandsLookup.Add(cmd.Name, cmd); return(true); } if (compare == 0) { node.Value = cmd; return(true); } } m_commands.AddLast(cmd); m_commandsLookup.Add(cmd.Name, cmd); return(true); }
// - - - - - - - - - - - - - - - - - - - - - - - - - // Запуск команды на Sql-сервере static bool StartSqlCmd(string CmdText) { if (CmdText == null) { return(false); } if (CmdText.Trim() == "") { return(false); } CConsole.ShowBox("", "Выполнение команды на сервере", ""); Connection = new CConnection(ConnectionString); Command = new CCommand(Connection); Command.Timeout = 599; bool Result = Command.Execute(CmdText); Command.Close(); Connection.Close(); CConsole.Clear(); CCommon.Print(CAbc.EMPTY, "Для продолжения нажмите Enter."); CConsole.ClearKeyboard(); CConsole.Flash(); CConsole.ReadChar(); return(Result); }
////////////////////////////////////////////////////////////////////////////// #region Aliases public static void AddAlias(string alias, string commandLine) { if (alias == null) { throw new ArgumentNullException("alias"); } if (commandLine == null) { throw new ArgumentNullException("commandLine"); } CCommand existingCmd = FindCommand(alias); if (existingCmd != null) { CAliasCommand cmd = existingCmd as CAliasCommand; if (cmd == null) { throw new CCommandException("Can't override command with alias: " + alias); } cmd.Alias = commandLine; } else { Register(new CAliasCommand(alias, commandLine)); } }
public static bool RegisterDelegate(string name, Delegate action) { if (name == null) { throw new ArgumentNullException("name"); } if (action == null) { throw new ArgumentNullException("action"); } CCommand existingCmd = FindCommand(name); if (existingCmd != null) { CDelegateCommand delegateCmd = existingCmd as CDelegateCommand; if (delegateCmd != null) { Log.w("Overriding command: {0}", name); delegateCmd.ActionDelegate = action; return(true); } Log.e("Another command with the same name exists: {0}", name); return(false); } return(Register(new CDelegateCommand(name, action))); }
public bool Save() { if (Connection == null) { return(false); } CCommand Command = new CCommand(Connection); string CmdText = ""; bool Result = true; for (Current = 0; Current < TOTAL_GROUP; Current++) { CmdText = "declare @OwnerCode as VarChar(32) select @OwnerCode=user_name() exec dbo.Mega_Common_Registry;2 @OwnerCode=@OwnerCode , @TaskCode='loader' , @TaskName='TAL\\FILIAL\\LOADER.EXC' "; if (Current == 0) { CmdText = CmdText + ", @FlagCode = '' "; } else { CmdText = CmdText + ", @FlagCode = '" + Current.ToString() + "' "; } CmdText = CmdText + ", @Name = '" + Topics[Current] + "' "; CmdText = CmdText + ", @Info = '" + Purposes[Current] + "' "; if (Command.Execute(CmdText) != true) { Result = false; } } Command.Close(); return(Result); }
public bool Load(CCommand Command, string FileName, string BranchCode, string TaskCode) { int LineNum; bool Result = true; string DebitAcc, CreditAcc, DebitIBAN, CreditIBAN; if (AFileReader == null) { return(false); } if (AFileReader.Open(FileName, CAbc.CHARSET_DOS)) { string ShortFileName = CCommon.GetFileName(FileName); LineNum = 1; while (AFileReader.Read()) { DebitAcc = AFileReader[CSepAFileInfo.L_DEBITACC].Replace("'", "`").Trim(); DebitAcc = CCommon.IsDigit(DebitAcc) ? DebitAcc : AFileReader[CSepAFileInfo.L_DEBITACC_EXT].Replace("'", "`").Trim(); DebitAcc = CCommon.IsDigit(DebitAcc) ? DebitAcc : ""; CreditAcc = AFileReader[CSepAFileInfo.L_CREDITACC].Replace("'", "`").Trim(); CreditAcc = CCommon.IsDigit(CreditAcc) ? CreditAcc : AFileReader[CSepAFileInfo.L_CREDITACC_EXT].Replace("'", "`").Trim(); CreditAcc = CCommon.IsDigit(CreditAcc) ? CreditAcc : ""; DebitIBAN = AFileReader[CSepAFileInfo.L_DEBITIBAN].Replace("'", "`").Trim(); DebitIBAN = CCommon.IsLetter(DebitIBAN) ? DebitIBAN : CAbc.EMPTY; CreditIBAN = AFileReader[CSepAFileInfo.L_CREDITIBAN].Replace("'", "`").Trim(); CreditIBAN = CCommon.IsLetter(CreditIBAN) ? CreditIBAN : CAbc.EMPTY; CmdText = "exec dbo.pMega_OpenGate_AddPalvis " + " @TaskCode = '" + TaskCode.Trim() + "'" + ",@BranchCode = '" + BranchCode.Trim() + "'" + ",@FileName = '" + ShortFileName + "'" + ",@LineNum = " + LineNum.ToString() + ",@Code = '" + AFileReader[CSepAFileInfo.L_NDOC].Replace("'", "`").Trim() + "'" + ",@Ctrls = '" + AFileReader[CSepAFileInfo.L_SYMBOL].Replace("'", "`").Trim() + "'" + ",@SourceCode = '" + AFileReader[CSepAFileInfo.L_DEBITMFO].Replace("'", "`").Trim() + "'" + ",@DebitMoniker = '" + DebitAcc + "'" + ",@DebitName = '" + AFileReader[CSepAFileInfo.L_DEBITNAME].Replace("'", "`").Trim() + "'" + ",@DebitState = '" + AFileReader[CSepAFileInfo.L_OKPO1].Replace("'", "`").Trim() + "'" + ",@DebitIBAN = '" + DebitIBAN + "'" + ",@TargetCode = '" + AFileReader[CSepAFileInfo.L_CREDITMFO].Replace("'", "`").Trim() + "'" + ",@CreditMoniker= '" + CreditAcc + "'" + ",@CreditName = '" + AFileReader[CSepAFileInfo.L_CREDITNAME].Replace("'", "`").Trim() + "'" + ",@CreditState = '" + AFileReader[CSepAFileInfo.L_OKPO2].Replace("'", "`").Trim() + "'" + ",@CreditIBAN = '" + CreditIBAN + "'" + ",@CrncyAmount = " + AFileReader[CSepAFileInfo.L_SUMA].Replace("'", "`").Trim() + ",@CurrencyId = " + AFileReader[CSepAFileInfo.L_CURRENCY].Replace("'", "`").Trim() + ",@Purpose = '" + AFileReader[CSepAFileInfo.L_PURPOSE].Replace("'", "`").Trim() + "'" + ",@OrgDate = " + CCommon.StrDate_To_IntDate("20" + AFileReader[CSepAFileInfo.L_DATE2].Trim()) + ",@UserName = '******'" ; if (Command.Execute(CmdText) != true) { Result = false; } LineNum = LineNum + 1; CConsole.ShowBox("", " Загружается строка" + CCommon.StrI(LineNum, 5) + " ", ""); } } AFileReader.Close(); return(Result); }
public static void ResolveOptions(CCommand command, Type commandType) { FieldInfo[] fields = commandType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); for (int i = 0; i < fields.Length; ++i) { FieldInfo info = fields[i]; object[] attributes = info.GetCustomAttributes(typeof(CCommandOptionAttribute), true); if (attributes.Length == 1) { CCommandOptionAttribute attr = (CCommandOptionAttribute)attributes[0]; string name = attr.Name != null ? attr.Name : info.Name; Option option = new Option(info, name, attr.Description); if (attr.Values != null) { option.Values = ParseValues(attr.Values, info.FieldType); } option.ShortName = attr.ShortName; option.IsRequired = attr.Required; option.DefaultValue = GetDefaultValue(command, info); command.AddOption(option); } } }
private static CCommand ResolveCommand(Type type) { CCommandAttribute cmdAttr = GetCustomAttribute <CCommandAttribute>(type); if (cmdAttr != null) { string commandName = cmdAttr.Name; if (!IsCorrectPlatform(cmdAttr.Flags)) { Debug.LogWarning("Skipping command: " + commandName); return(null); } CCommand command = ClassUtils.CreateInstance <CCommand>(type); if (command != null) { command.Name = commandName; command.Description = cmdAttr.Description; if (cmdAttr.Values != null) { command.Values = cmdAttr.Values.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } command.Flags |= cmdAttr.Flags; ResolveOptions(command); return(command); } else { Log.e("Unable to register command: name={0} type={1}", commandName, type); } } return(null); }
public CFilterControl(Popup pppParent, enFilterTarget filterTarget, List <FilterPredicate> predicates, FilterControlCommandHandler FilterCommandFunc, FilterControlCommandHandler CancelCommandFunc) { InitializeComponent(); ParentPopup = pppParent; FilterTarget = filterTarget; CloseReason = enCloseReason.LostFocus; m_FilterPredicatesOnOpen = new List <FilterPredicate>(); foreach (FilterPredicate predicate in predicates) { FilterPredicate NewPredicate = new FilterPredicate(predicate); NewPredicate.PropertyChanged += Predicate_PropertyChanged; FilterPredicates.Add(NewPredicate); m_FilterPredicatesOnOpen.Add(new FilterPredicate(predicate)); } CancelCommand = new CCommand(() => { CloseReason = enCloseReason.Cancel; CancelCommandFunc(this); }); FilterCommand = new CCommand(() => { CloseReason = enCloseReason.OK; FilterCommandFunc(this); }); Predicate_PropertyChanged(this, null); }
////////////////////////////////////////////////////////////////////////////// #region Delegate notification private void NotifyCommandExecuted(CCommand cmd) { if (Delegate != null) { Delegate.OnCommandExecuted(this, cmd); } }
////////////////////////////////////////////////////////////////////////////// #region Commands registry public static bool Register(CCommand cmd) { if (cmd.Name.StartsWith("@")) { cmd.Flags |= CCommandFlags.Hidden; } return(AddCommand(cmd)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Вычитка истории вполнения пунктов открытия/закрытия дня static bool SaveHistory(int Mode, int Choice) { Connection = new CConnection(ConnectionString); Command = new CCommand(Connection); bool Result = Command.Execute(" exec dbo.Mega_Day_Close;11 @DayDate=" + DayDate.ToString() + " , @FlagCode= " + Choice.ToString() + " , @Mode= " + Mode.ToString()); Command.Close(); Connection.Close(); return(Result); }
private static bool RemoveCommand(CCommand command) { if (m_commands.Remove(command)) { m_commandsLookup.Remove(command.Name); return(true); } return(false); }
private static string[] getSuggestedOptions(Iterator <string> iter, CCommand cmd, string optNameToken, string prefix) { List <Option> optionsList = new List <Option>(); // TODO: reuse list // list options bool useShort = prefix.Equals("-"); if (useShort) { cmd.ListShortOptions(optionsList, optNameToken); optionsList.Sort(delegate(Option op1, Option op2) { return(op1.ShortName.CompareTo(op2.ShortName)); }); } else { cmd.ListOptions(optionsList, optNameToken); optionsList.Sort(delegate(Option op1, Option op2) { return(op1.Name.CompareTo(op2.Name)); }); } if (optionsList.Count > 1) // multiple options available { return(getSuggestedOptions(optionsList, useShort)); } if (optionsList.Count == 1) // single option available { Option opt = optionsList[0]; if (isOptionNameMatch(opt, optNameToken, useShort)) // option name already matched - try values { if (opt.HasValues()) // option has predefined values? { if (iter.HasNext()) // has value token? { return(opt.ListValues(iter.Next())); } return(opt.Values); } if (iter.HasNext()) { return(EMPTY_SUGGESTIONS); // don't suggest option value } } return(singleSuggestion(getSuggestedOption(opt, useShort))); // suggest option`s name } return(EMPTY_SUGGESTIONS); }
private static object GetDefaultValue(CCommand command, FieldInfo info) { object value = info.GetValue(command); if (info.FieldType.IsValueType) { return(value); } return(value is ICloneable ? ((ICloneable)value).Clone() : value); }
public void setCommand( CCommand command ) { if (command.idx == null || command.idx == 0) { DaoManager.Instance.Insert("COMMAND.insert_command", command); } else { DaoManager.Instance.Update("COMMAND.update_command", command); } }
public CResult() { RemoveFalsestart = new CCommand(RemoveFalsestart_Executed, () => { return(AdditionalEventTypes.HasValue && AdditionalEventTypes.Value.HasFlag(enAdditionalEventTypes.Falsestart) && ResultInDB?.participations?.groups != null && !GlobalDefines.IsRoundFinished(ResultInDB.participations.groups.round_finished_flags, (enRounds)ResultInDB.round)); } ); }
private string[] ListShortOptions(CCommand cmd, string token = null) { IList <Option> options = cmd.ListShortOptions(token); string[] names = new string[options.Count]; for (int i = 0; i < options.Count; ++i) { names[i] = options[i].ShortName; } return(names); }
private static string[] getSuggestions(string commandLine, IList <string> tokens) { Iterator <string> iter = new Iterator <string>(tokens); CCommand cmd = CRegistery.FindCommand(iter.Next()); if (cmd == null) { return(EMPTY_SUGGESTIONS); // no command found } while (iter.HasNext()) { string token = iter.Next(); int iterPos = iter.Position; // store position to revert for the case if option skip fails // first try to parse options if (token.StartsWith("--")) // long option { string optionName = token.Substring(2); if (SkipOption(iter, cmd, optionName)) { continue; } iter.Position = iterPos; return(getSuggestedOptions(iter, cmd, optionName, "--")); } else if (token.StartsWith("-") && !StringUtils.IsNumeric(token)) // short option { string optionName = token.Substring(1); if (SkipOption(iter, cmd, optionName)) { continue; } iter.Position = iterPos; return(getSuggestedOptions(iter, cmd, optionName, "-")); } if (iter.HasNext()) { return(EMPTY_SUGGESTIONS); // TODO: add multiple args suggestion support } return(getSuggestedArgs(commandLine, cmd, token)); } return(getSuggestedArgs(commandLine, cmd, "")); }
bool Execute(string command) { CCommand cmd = CRegistery.FindCommand(command); if (cmd == null) { PrintError("{0}: command not found \"{1}\"", this.Name, command); return(false); } cmd.Delegate = this.Delegate; cmd.PrintUsage(true); cmd.Delegate = null; return(true); }
////////////////////////////////////////////////////////////////////////////// // Arguments private static string[] getSuggestedArgs(string commandLine, CCommand cmd, string token) { string[] values = cmd.Values; if (values != null && values.Length > 0) { return(getSuggestedArgs(values, token)); } IList <string> customValues = cmd.AutoCompleteCustomArgs(commandLine, token); if (customValues != null && customValues.Count > 0) { return(getSuggestedArgs(customValues, token)); } return(EMPTY_SUGGESTIONS); }
public object[] ExecuteCommand1(string commandName, string targetMethod, object data) { try { object[] result = new object[4]; result[0] = CCommand.Create(commandName).Execute(data); result[1] = targetMethod; result[2] = commandName; result[3] = data; return(result); } catch (Exception ex) { // TODO: add logging functionality throw; } }
internal static bool Unregister(ListCommandsFilter <CCommand> filter) { bool unregistered = false; for (LinkedListNode <CCommand> node = m_commands.First; node != null;) { LinkedListNode <CCommand> next = node.Next; CCommand cmd = node.Value; if (filter(cmd)) { unregistered |= Unregister(cmd); } node = next; } return(unregistered); }
public static bool Unregister(string commandName) { CCommand cmd = FindCommand(commandName); if (cmd != null) { if (cmd is CDelegateCommand) { Unregister(cmd); return(true); } Log.e("Unable to unregister a non-delegate command: {0}", cmd); return(false); } return(false); }
public object[] ExecuteCommand(string commandName, string callbackMethod, object data) { object[] result = new object[2]; try { Dictionary <string, object> param = (Dictionary <string, object>)data; //string actionView = (string)param["actionView"]; //Authorize here result[0] = CCommand.Create(commandName).Execute(data); result[1] = callbackMethod; } catch (Exception ex) { // TODO: add logging functionality throw; } return(result); }
internal static bool ShouldListCommand(CCommand cmd, string prefix, CommandListOptions options = CommandListOptions.None) { if (cmd.IsDebug && (options & CommandListOptions.Debug) == 0) { return(false); } if (cmd.IsSystem && (options & CommandListOptions.System) == 0) { return(false); } if (cmd.IsHidden && (options & CommandListOptions.Hidden) == 0) { return(false); } return(prefix == null || StringUtils.StartsWithIgnoreCase(cmd.Name, prefix)); }
// ------------------------------------------------------ static void LookForSertificates() { Command = new CCommand(Connection); string ScInputDir = ( string )__.IsNull(Command.GetScalar(" exec dbo.Mega_Day_Open;6 "), (string)CAbc.EMPTY); ScInputDir = ScInputDir.Trim(); if (ScInputDir.Length == 0) { __.Print("Ошибка определения входного каталога для ОДБ."); } string[] Sertificates = __.GetFileList(ScInputDir + "\\!*.*"); if (Sertificates != null) { if (Sertificates.Length > 0) { CConsole.GetBoxChoice("", "Найдены сертификаты открытых ключей от НБУ.", "", " Не забудьте загрузить их в `Скрудж`.", ""); } } Command.Close(); }
protected void RegisterCommand(Type type, bool hidden = true) { CCommand command = CClassUtils.CreateInstance <CCommand>(type); if (command == null) { throw new ArgumentException("Can't create class instance: " + type.FullName); } String commandName = type.Name; if (commandName.StartsWith("Cmd_")) { commandName = commandName.Substring("Cmd_".Length); } command.Name = commandName; command.IsHidden = hidden; CRuntimeResolver.ResolveOptions(command); CRegistery.Register(command); }
public ActionResult Write() { try { CCommand command = new CCommand(); if (Request["idx"] != null && int.Parse(Request["idx"]) > 0) { DaoCommand daoCommand = new DaoCommand(); command = daoCommand.getCommandOne(int.Parse(Request["idx"])); //ViewBag.status = new DaoCode().getCodeList("status", 0, null, 0); } ViewBag.command = command; } catch (Exception e) { throw new Exception(e.Message); } return View("~/VIews/Command/CommandWrite.cshtml"); }
public bool Load(CCommand Command, string FileName) { string CmdText = ""; bool Result = true; if (EFileReader.Open(FileName, CAbc.CHARSET_DOS)) { while ((EFileReader.Read()) && (Result)) { CmdText = "exec dbo.pMega_OpenGate_Params " + " @FileName = '!A" + CCommon.GetFileName(FileName).Substring(2, 10) + "'" + " , @LineNum = " + EFileReader[CErcEFileInfo.L_LINENUM] + " , @Code = '" + EFileReader[CErcEFileInfo.L_PARAMCODE] + "'" + " , @Info = '" + EFileReader[CErcEFileInfo.L_INFO] + "'"; if (Command.Execute(CmdText) != true) { Result = false; } } } EFileReader.Close(); return(Result); }
public virtual void PostNotification(CCommand cmd, string name, params object[] data) { m_notificationCenter.Post(cmd, name, data); }
private static string toDisplayName(CCommand cmd) { ColorCode color = cmd is CVarCommand ? ColorCode.TableVar : cmd.ColorCode; return StringUtils.C(cmd.Name, color); }
private string[] ListShortOptions(CCommand cmd, string token = null) { IList<Option> options = cmd.ListShortOptions(token); string[] names = new string[options.Count]; for (int i = 0; i < options.Count; ++i) { names[i] = options[i].ShortName; } return names; }
private static bool AddCommand(CCommand cmd) { string name = cmd.Name; for (LinkedListNode<CCommand> node = m_commands.First; node != null; node = node.Next) { CCommand otherCmd = node.Value; if (cmd == otherCmd) { return false; // no duplicates } string otherName = otherCmd.Name; int compare = name.CompareTo(otherName); if (compare < 0) { m_commands.AddBefore(node, cmd); m_commandsLookup.Add(cmd.Name, cmd); return true; } if (compare == 0) { node.Value = cmd; return true; } } m_commands.AddLast(cmd); m_commandsLookup.Add(cmd.Name, cmd); return true; }
internal static bool ShouldListCommand(CCommand cmd, string prefix, CommandListOptions options = CommandListOptions.None) { if (cmd.IsDebug && (options & CommandListOptions.Debug) == 0) { return false; } if (cmd.IsSystem && (options & CommandListOptions.System) == 0) { return false; } if (cmd.IsHidden && (options & CommandListOptions.Hidden) == 0) { return false; } return prefix == null || StringUtils.StartsWithIgnoreCase(cmd.Name, prefix); }
private static string[] getSuggestedOptions(Iterator<string> iter, CCommand cmd, string optNameToken, string prefix) { List<Option> optionsList = new List<Option>(); // TODO: reuse list // list options bool useShort = prefix.Equals("-"); if (useShort) { cmd.ListShortOptions(optionsList, optNameToken); optionsList.Sort(delegate(Option op1, Option op2) { return op1.ShortName.CompareTo(op2.ShortName); }); } else { cmd.ListOptions(optionsList, optNameToken); optionsList.Sort(delegate(Option op1, Option op2) { return op1.Name.CompareTo(op2.Name); }); } if (optionsList.Count > 1) // multiple options available { return getSuggestedOptions(optionsList, useShort); } if (optionsList.Count == 1) // single option available { Option opt = optionsList[0]; if (isOptionNameMatch(opt, optNameToken, useShort)) // option name already matched - try values { if (opt.HasValues()) // option has predefined values? { if (iter.HasNext()) // has value token? { return opt.ListValues(iter.Next()); } return opt.Values; } if (iter.HasNext()) { return EMPTY_SUGGESTIONS; // don't suggest option value } } return singleSuggestion(getSuggestedOption(opt, useShort)); // suggest option`s name } return EMPTY_SUGGESTIONS; }
////////////////////////////////////////////////////////////////////////////// // Arguments private static string[] getSuggestedArgs(string commandLine, CCommand cmd, string token) { string[] values = cmd.Values; if (values != null && values.Length > 0) { return getSuggestedArgs(values, token); } IList<string> customValues = cmd.AutoCompleteCustomArgs(commandLine, token); if (customValues != null && customValues.Count > 0) { return getSuggestedArgs(customValues, token); } return EMPTY_SUGGESTIONS; }
public static bool Unregister(CCommand cmd) { return RemoveCommand(cmd); }
public JObject Save() { JObject jsonObj = new JObject(); try { DaoCommand daoCommand = new DaoCommand(); CCommand command = new CCommand(); command.subject = Request["subject"]; command.ord_emp_no = Session["emp_no"].ToString(); command.ord_emp_name = Request["ord_emp_no"]; command.ord_type = Request["tree_value"]; command.content = Request["content"]; command.reg_ip = UtilityController.getUserIP(Request); if (Request["idx"] != null && Request["idx"].ToString() != "") { command.idx = int.Parse(Request["idx"]); command.reg_date = DateTime.Now; command.mod_date = DateTime.Now.Date; } else { command.mod_date = DateTime.Now; } daoCommand.setCommand(command); jsonObj.Add("RESULT", "OK"); } catch (Exception e) { jsonObj.Add("RESULT", "FAIL"); jsonObj.Add("MSG", e.Message); UtilityController.WriteLog(e.Message); //throw new Exception(e.Message); } return jsonObj; }
////////////////////////////////////////////////////////////////////////////// #region Commands registry public static bool Register(CCommand cmd) { if (cmd.Name.StartsWith("@")) { cmd.Flags |= CCommandFlags.Hidden; } return AddCommand(cmd); }
////////////////////////////////////////////////////////////////////////////// // Options private static bool SkipOption(Iterator<string> iter, CCommand cmd, string name) { Option opt = cmd.FindOption(name); return opt != null && SkipOption(iter, opt) && iter.HasNext(); }
private static bool RemoveCommand(CCommand command) { if (m_commands.Remove(command)) { m_commandsLookup.Remove(command.Name); return true; } return false; }