public override void handleCommand(CommandString command) { switch (command.getOp()) { case "incoming_available": { callId = command.get("destination_id"); Console.WriteLine("Incoming call!: " + callId); CommandString cmd = new CommandString(callId, SipCommandString.accept_invite, ""); sendCommand("sip", cmd); break; } case "remote_cancelled_invite": Console.WriteLine("Missed call!"); break; case "invite_ok": { CommandString cmd = new CommandString(callId, MediaCommandString.set_session_sound_settings, "senders", "ON"); sendCommand("media", cmd); Console.WriteLine("Activated media"); break; } case "remote_hang_up": Console.WriteLine("Hangup"); break; default: Console.WriteLine("My handleCommand: " + command.getString()); break; } }
public async Task <string> Execute(CommandString cmd, MessageEventArgs messageEventArgs) { if (cmd.Parameters.Length < 2) { return(null); } var msg = messageEventArgs.Message; if (msg.Chat.Type != ChatType.Private) { return(null); } string name = cmd.Parameters[0]; string adminToken = cmd.Parameters[1]; var changed = await db.DeleteTopic(name, adminToken); if (changed > 0) { return($"deleted {name} and all its subscriptions"); } else { return($"invalid topic name or admin token"); } }
public async override void PerformAction() { CommandString = CommandString.ToUpper(); string strDestination = ""; if (CommandString.Contains(" TO ")) { strDestination = CommandString.Substring(CommandString.IndexOf(" TO ") + 4); } else { // have bob ask the user where they want to go TextToSpeechEngine.SpeakText(this.MediaElement, "Sure, where do you want to go?"); // sleep the thread to give bob enough time to speak if (!await SpeechRecognitionManager.RequestListen(this.GetType(), (text) => { strDestination = text; GetDirections(text); })) { string message = "Sorry, but something went wrong. To get directions, say \"Hey Bob, how do I get to thePlace\""; TextToSpeechEngine.SpeakText(this.MediaElement, message); this.ShowMessage(message); } else { ProvideDirectionsSuccessMessage(strDestination); } } if (StringUtils.IsNotBlank(strDestination)) { GetDirections(strDestination); ProvideDirectionsSuccessMessage(strDestination); } }
public async Task <string> Execute(CommandString cmd, MessageEventArgs messageEventArgs) { if (cmd.Parameters.Length < 1) { return(null); } if (!await CommandHelper.CheckAdministrator(bot, messageEventArgs.Message)) { return(null); } var msg = messageEventArgs.Message; var chat = NamespacedId.Telegram(msg.Chat.Id); var topicName = cmd.Parameters[0]; int affected = await db.RemoveSubscription(topicName, chat); if (affected >= 1) { return($"unsubscribed from {topicName}"); } else { return($"could not find subscription for {topicName}"); } }
public Task Handle(RequestContext ctx, Func <RequestContext, Task> next) { log.Debug("Message received"); CommandString cmd = ctx.Command; Feature feature = new Feature() { Router = this }; ctx.AddFeature(feature); try { if (commands.ContainsKey(cmd.Command)) { feature.CommandType = commands[cmd.Command].GetType(); log.Debug($"Handling message via {feature.CommandType.Name}"); async Task processCommand() => feature.Succeded = await commands[cmd.Command].Execute(ctx); return(processCommand()); } } catch (Exception e) { log.Error($"Error while handling command {cmd.Command}!"); log.Error(e); } return(next(ctx)); }
/// <summary> /// Handles the specified query. /// </summary> /// <param name="query">The query.</param> /// <returns></returns> /// <exception cref="PoisonMessageException">An error has occured trying to re-assemble a message de-queued from SQLite</exception> /// <exception cref="MessageQueueId"></exception> public async Task <IReceivedMessageInternal> Handle(ReceiveMessageQueryAsync <IDbConnection, IDbTransaction> query) { if (!_databaseExists.Exists(_connectionInformation.ConnectionString)) { return(null); } using (var connection = _dbFactory.CreateConnection(_connectionInformation.ConnectionString, false)) { connection.Open(); using (var transaction = _dbFactory.CreateTransaction(connection).BeginTransaction()) { using (var selectCommand = connection.CreateCommand()) { selectCommand.Transaction = transaction; CommandString commandString = GetDeQueueCommand(_tableNameHelper.MetaDataName, _tableNameHelper.QueueName, _tableNameHelper.StatusName, query.Routes); if (commandString == null) { throw new DotNetWorkQueueException("Failed to generate command text for de-queue of messages"); } _buildDequeueCommand.BuildCommand(selectCommand, commandString, _options.Value, query.Routes); using (var reader = await _readerAsync.ExecuteReaderAsync(selectCommand).ConfigureAwait(false)) { return(_messageDeQueue.HandleMessage(connection, transaction, reader, commandString)); } } } } }
/// <summary> /// Handles the specified query. /// </summary> /// <param name="query">The query.</param> /// <returns></returns> public IReceivedMessageInternal Handle(ReceiveMessageQuery <IDbConnection, IDbTransaction> query) { if (!_databaseExists.Exists(_connectionInformation.ConnectionString)) { return(null); } using (var connection = _dbFactory.CreateConnection(_connectionInformation.ConnectionString, false)) { connection.Open(); using (var transaction = _dbFactory.CreateTransaction(connection).BeginTransaction()) { using (var selectCommand = connection.CreateCommand()) { selectCommand.Transaction = transaction; CommandString commandString = GetDeQueueCommand(_tableNameHelper.MetaDataName, _tableNameHelper.QueueName, _tableNameHelper.StatusName, query.Routes); _buildDequeueCommand.BuildCommand(selectCommand, commandString, _options.Value, query.Routes); using (var reader = selectCommand.ExecuteReader()) { return(_messageDeQueue.HandleMessage(connection, transaction, reader, commandString)); } } } } }
public async Task <string> Execute(CommandString cmd, MessageEventArgs messageEventArgs) { if (cmd.Parameters.Length < 1) { return(null); } var msg = messageEventArgs.Message; if (msg.Chat.Type != ChatType.Private) { return(null); } string name = cmd.Parameters[0]; string descr = name; if (cmd.Parameters.Length > 1) { descr = string.Join(' ', cmd.Parameters.Skip(1)); } try { var topic = await db.CreateTopic(NamespacedId.Telegram(msg.From.Id), name, descr); return($"created {topic.Name}\n" + $"readToken\n{topic.ReadToken}\n" + $"writeToken\n{topic.WriteToken}\n" + $"adminToken\n{topic.AdminToken}\n"); } catch (MySqlException myDuplicate) when(myDuplicate.Number == 1062) { return($"topic {name} already exists"); } }
internal void BuildCommand(SQLiteCommand selectCommand, IMessageId messageId, CommandString commandString, SqLiteMessageQueueTransportOptions options, List<string> routes ) { if (messageId != null && messageId.HasValue) { selectCommand.CommandText = commandString.CommandText; selectCommand.Parameters.Add("@QueueID", DbType.Int64); selectCommand.Parameters.Add("@CurrentDateTime", DbType.Int64); selectCommand.Parameters["@QueueID"].Value = messageId.Id.Value; selectCommand.Parameters["@CurrentDateTime"].Value = _getTime.GetCurrentUtcDate().Ticks; } else { selectCommand.CommandText = commandString.CommandText; selectCommand.Parameters.Add("@CurrentDateTime", DbType.Int64); selectCommand.Parameters["@CurrentDateTime"].Value = _getTime.GetCurrentUtcDate().Ticks; } if (options.EnableRoute && routes != null && routes.Count > 0) { var routeCounter = 1; foreach (var route in routes) { selectCommand.Parameters.Add("@Route" + routeCounter.ToString(), DbType.AnsiString); selectCommand.Parameters["@Route" + routeCounter.ToString()].Value = route; routeCounter++; } } }
internal void BuildCommand(IDbCommand selectCommand, CommandString commandString, SqLiteMessageQueueTransportOptions options, List <string> routes) { selectCommand.CommandText = commandString.CommandText; var paramDate = selectCommand.CreateParameter(); paramDate.ParameterName = "@CurrentDateTime"; paramDate.DbType = DbType.Int64; paramDate.Value = _getTime.GetCurrentUtcDate().Ticks; selectCommand.Parameters.Add(paramDate); if (options.EnableRoute && routes != null && routes.Count > 0) { var routeCounter = 1; foreach (var route in routes) { var param = selectCommand.CreateParameter(); param.ParameterName = "@Route" + routeCounter; param.DbType = DbType.AnsiString; param.Value = route; selectCommand.Parameters.Add(param); routeCounter++; } } }
public void sendInvite(string uri) { CommandString invite = new CommandString("", SipCommandString.invite, uri); CommandString resp = getCallback().handleCommandResp("sip", invite); Console.WriteLine("Calling: " + resp.getString()); callId = resp.get("destination_id"); }
public void Create_Command() { var commands = new List <string>(); var test = new CommandString("testing", commands); Assert.Equal("testing", test.CommandText); Assert.Equal(commands, test.AdditionalCommands); }
protected override void Add(GatewayCommandBase command) { CommandString commandsString = new CommandString() { CommandType = command.GetType().ToString() }; commandsString.CommandText = serializer.SerializeToString(command); commands.Add(commandsString); }
/// <summary> /// Gets the inferred language for Highlight.js, e.g. "sql" for SQL. /// </summary> /// <returns>The specific highlight.js language to use, or empty if unknown or inferred well already.</returns> public string GetHighlightLanguage() { // URLs if (CommandString?.StartsWith("http://") == true || CommandString?.StartsWith("https://") == true) { return("html"); } // Languages that are inferred well: //if (Type.Contains("SQL")) return "sql"; //if (CommandString?.StartsWith("{") == true && CommandString?.EndsWith("}") == true) return "json"; //if (CommandString?.StartsWith("[") == true && CommandString?.EndsWith("]") == true) return "json"; return(string.Empty); }
public async Task <string> Execute(CommandString cmd, MessageEventArgs messageEventArgs) { if (!await CommandHelper.CheckAdministrator(bot, messageEventArgs.Message)) { return(null); } var msg = messageEventArgs.Message; var chatid = msg.Chat.Id; var topics = await db.GetTopicsForChat(NamespacedId.Telegram(chatid)); return(topics.Any() ? "Topics:\n" + string.Join("\n", topics) : "No subscriptions active."); }
public override void run() { for (;;) { //Console.WriteLine("Before waitCommand"); CommandString cmd = waitCommand(); //Console.WriteLine("After waitCommand"); if (cmd.getOp() == "stop") { //Console.Writ eLine("Return thread"); return; } handleCommand(cmd); } }
public string Execute(object sender, MessageEventArgs args) { var text = args.Message.Text; if (CommandString.TryParse(text, out var cmd)) { if (cmd.UserName != null && cmd.UserName != Username) { return(null); } if (Commands.ContainsKey(cmd.Command)) { return(Commands[cmd.Command].Execute(cmd, args)); } } return(null); }
public override bool Check(CommandString command) { if (base.Check(command)) { return(true); } if (!command.IsAuthorized) { return(false); } if (command.State != State) { return(false); } return(command.CommandName != null && command.CommandName.StartsWith(Name)); }
void BotOnMessageReceived(object sender, MessageEventArgs args) { var message = args.Message; if (message == null || message.Type != MessageType.Text) { return; } if (!CommandString.TryParse(args.Message.Text, out var cmd)) { return; } if (cmd.UserName != null && cmd.UserName != Commands.Me.Username) { return; } RequestContext ctx = new RequestContext(Client, args, cmd); _ = Chain.Handle(ctx); }
public async Task <string> Execute(CommandString cmd, MessageEventArgs args) { if (cmd.Parameters.Length < 1) { return(null); } if (!await CommandHelper.CheckAdministrator(bot, args.Message)) { return(null); } var chat = NamespacedId.Telegram(args.Message.Chat.Id); var token = cmd.Parameters[0]; var topic = await db.GetTopicForSub(token, chat); if (topic == null) { return("topic not found"); } else if (topic.Chat == chat) { return($"already subscribed to {topic.Name}"); } else if (topic.ReadToken != token) { return("token mismatch"); } else { await db.CreateSubscription(topic.TopicId, chat); return($"subscribed to {topic.Name}"); } }
public override void handleCommand(CommandString command) { switch( command.getOp() ){ case "incoming_available": { callId = command.get("destination_id"); Console.WriteLine("Incoming call!: " + callId); CommandString cmd = new CommandString(callId, SipCommandString.accept_invite, ""); sendCommand("sip", cmd); break; } case "remote_cancelled_invite": Console.WriteLine("Missed call!"); break; case "invite_ok": { CommandString cmd = new CommandString(callId, MediaCommandString.set_session_sound_settings, "senders", "ON"); sendCommand("media", cmd); Console.WriteLine("Activated media"); break; } case "remote_hang_up": Console.WriteLine("Hangup"); break; default: Console.WriteLine("My handleCommand: " + command.getString()); break; } }
/// <summary> /// Returns a snippet of the sql command and the duration. /// </summary> public override string ToString() { return(CommandString.Truncate(30) + " (" + DurationMilliseconds + " ms)"); }
/// <summary> /// Generates a hash code that can be used to quickly identify whether two commands are not /// equal. Uses the default string hashing on the command string. /// </summary> /// <returns>An integer denoting the hash code.</returns> public override int GetHashCode() { return(CommandString.GetHashCode()); }
internal IReceivedMessageInternal HandleMessage(SQLiteConnection connection, SQLiteTransaction transaction, System.Data.Common.DbDataReader reader, CommandString commandString) { if (!reader.Read()) { return null; } //load up the message from the DB long id = 0; var correlationId = Guid.Empty; byte[] headerPayload = null; byte[] messagePayload = null; try { id = (long)reader["queueid"]; var cId = (string)reader["CorrelationID"]; headerPayload = (byte[])reader["Headers"]; messagePayload = (byte[])reader["body"]; correlationId = new Guid(cId); var headers = _serialization.InternalSerializer .ConvertBytesTo<IDictionary<string, object>>( headerPayload); var messageGraph = (MessageInterceptorsGraph) headers[_headers.StandardHeaders.MessageInterceptorGraph.Name]; var message = _serialization.Serializer.BytesToMessage<MessageBody>( messagePayload, messageGraph).Body; var newMessage = _messageFactory.Create(message, headers); foreach (var additionalCommand in commandString.AdditionalCommands) { using (var command = connection.CreateCommand()) { command.Transaction = transaction; command.CommandText = additionalCommand; command.ExecuteNonQuery(); } } transaction.Commit(); return _receivedMessageFactory.Create(newMessage, new SqLiteMessageQueueId(id), new SqLiteMessageQueueCorrelationId(correlationId)); } catch (Exception err) { //at this point, the record has been de-queued, but it can't be processed. throw new PoisonMessageException( "An error has occured trying to re-assemble a message de-queued from SQLite", err, new SqLiteMessageQueueId(id), new SqLiteMessageQueueCorrelationId(correlationId), messagePayload, headerPayload); } }
internal IReceivedMessageInternal HandleMessage(IDbConnection connection, IDbTransaction transaction, IDataReader reader, CommandString commandString) { if (!reader.Read()) { return(null); } //load up the message from the DB long id = 0; var correlationId = Guid.Empty; byte[] headerPayload = null; byte[] messagePayload = null; try { id = (long)reader["QueueID"]; var cId = (string)reader["CorrelationID"]; headerPayload = (byte[])reader["Headers"]; messagePayload = (byte[])reader["Body"]; //before we continue, run the commands and commit the transaction //otherwise, poison messages will conflict foreach (var additionalCommand in commandString.AdditionalCommands) { using (var command = connection.CreateCommand()) { command.Transaction = transaction; command.CommandText = additionalCommand; command.ExecuteNonQuery(); } } transaction.Commit(); correlationId = new Guid(cId); var headers = _serialization.InternalSerializer .ConvertBytesTo <IDictionary <string, object> >( headerPayload); var messageGraph = (MessageInterceptorsGraph) headers[_headers.StandardHeaders.MessageInterceptorGraph.Name]; var message = _serialization.Serializer.BytesToMessage <MessageBody>( messagePayload, messageGraph, headers).Body; var newMessage = _messageFactory.Create(message, headers); return(_receivedMessageFactory.Create(newMessage, new MessageQueueId <long>(id), new MessageCorrelationId <Guid>(correlationId))); } catch (Exception err) { //at this point, the record has been de-queued, but it can't be processed. throw new PoisonMessageException( "An error has occurred trying to re-assemble a message de-queued from SQLite", err, new MessageQueueId <long>(id), new MessageCorrelationId <Guid>(correlationId), messagePayload, headerPayload); } }
public static List <LogInfo> ExecuteCommand(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(); int curDepth = s.CurDepth; if (CodeCommand.DeprecatedCodeType.Contains(cmd.Type)) { logs.Add(new LogInfo(LogState.Warning, $"Command [{cmd.Type}] is deprecated")); } try { switch (cmd.Type) { #region 00 Misc case CodeType.None: logs.Add(new LogInfo(LogState.Ignore, string.Empty)); break; case CodeType.Comment: { if (s.LogComment) { logs.Add(new LogInfo(LogState.Ignore, string.Empty)); } } break; case CodeType.Error: { Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_Error)); CodeInfo_Error info = cmd.Info as CodeInfo_Error; logs.Add(new LogInfo(LogState.Error, info.ErrorMessage)); } break; #endregion #region 01 File case CodeType.FileCopy: logs.AddRange(CommandFile.FileCopy(s, cmd)); break; case CodeType.FileDelete: logs.AddRange(CommandFile.FileDelete(s, cmd)); break; case CodeType.FileRename: case CodeType.FileMove: logs.AddRange(CommandFile.FileRename(s, cmd)); break; case CodeType.FileCreateBlank: logs.AddRange(CommandFile.FileCreateBlank(s, cmd)); break; case CodeType.FileSize: logs.AddRange(CommandFile.FileSize(s, cmd)); break; case CodeType.FileVersion: logs.AddRange(CommandFile.FileVersion(s, cmd)); break; case CodeType.DirCopy: logs.AddRange(CommandFile.DirCopy(s, cmd)); break; case CodeType.DirDelete: logs.AddRange(CommandFile.DirDelete(s, cmd)); break; case CodeType.DirMove: logs.AddRange(CommandFile.DirMove(s, cmd)); break; case CodeType.DirMake: logs.AddRange(CommandFile.DirMake(s, cmd)); break; case CodeType.DirSize: logs.AddRange(CommandFile.DirSize(s, cmd)); break; case CodeType.PathMove: logs.AddRange(CommandFile.PathMove(s, cmd)); break; #endregion #region 02 Registry case CodeType.RegHiveLoad: logs.AddRange(CommandRegistry.RegHiveLoad(s, cmd)); break; case CodeType.RegHiveUnload: logs.AddRange(CommandRegistry.RegHiveUnload(s, cmd)); break; case CodeType.RegRead: logs.AddRange(CommandRegistry.RegRead(s, cmd)); break; case CodeType.RegWrite: logs.AddRange(CommandRegistry.RegWrite(s, cmd)); break; case CodeType.RegWriteLegacy: // WB082 Compatibility Shim logs.AddRange(CommandRegistry.RegWriteLegacy(s, cmd)); break; case CodeType.RegDelete: logs.AddRange(CommandRegistry.RegDelete(s, cmd)); break; case CodeType.RegMulti: logs.AddRange(CommandRegistry.RegMulti(s, cmd)); break; case CodeType.RegImport: logs.AddRange(CommandRegistry.RegImport(s, cmd)); break; case CodeType.RegExport: logs.AddRange(CommandRegistry.RegExport(s, cmd)); break; #endregion #region 03 Text case CodeType.TXTAddLine: logs.AddRange(CommandText.TXTAddLine(s, cmd)); break; case CodeType.TXTAddLineOp: logs.AddRange(CommandText.TXTAddLineOp(s, cmd)); break; case CodeType.TXTReplace: logs.AddRange(CommandText.TXTReplace(s, cmd)); break; case CodeType.TXTReplaceOp: logs.AddRange(CommandText.TXTReplaceOp(s, cmd)); break; case CodeType.TXTDelLine: logs.AddRange(CommandText.TXTDelLine(s, cmd)); break; case CodeType.TXTDelLineOp: logs.AddRange(CommandText.TXTDelLineOp(s, cmd)); break; case CodeType.TXTDelSpaces: logs.AddRange(CommandText.TXTDelSpaces(s, cmd)); break; case CodeType.TXTDelEmptyLines: logs.AddRange(CommandText.TXTDelEmptyLines(s, cmd)); break; #endregion #region 04 INI case CodeType.INIRead: logs.AddRange(CommandIni.IniRead(s, cmd)); break; case CodeType.INIReadOp: logs.AddRange(CommandIni.IniReadOp(s, cmd)); break; case CodeType.INIWrite: logs.AddRange(CommandIni.IniWrite(s, cmd)); break; case CodeType.INIWriteOp: logs.AddRange(CommandIni.IniWriteOp(s, cmd)); break; case CodeType.INIDelete: logs.AddRange(CommandIni.IniDelete(s, cmd)); break; case CodeType.INIDeleteOp: logs.AddRange(CommandIni.IniDeleteOp(s, cmd)); break; case CodeType.INIReadSection: logs.AddRange(CommandIni.IniReadSection(s, cmd)); break; case CodeType.INIReadSectionOp: logs.AddRange(CommandIni.IniReadSectionOp(s, cmd)); break; case CodeType.INIAddSection: logs.AddRange(CommandIni.IniAddSection(s, cmd)); break; case CodeType.INIAddSectionOp: logs.AddRange(CommandIni.IniAddSectionOp(s, cmd)); break; case CodeType.INIDeleteSection: logs.AddRange(CommandIni.IniDeleteSection(s, cmd)); break; case CodeType.INIDeleteSectionOp: logs.AddRange(CommandIni.IniDeleteSectionOp(s, cmd)); break; case CodeType.INIWriteTextLine: logs.AddRange(CommandIni.IniWriteTextLine(s, cmd)); break; case CodeType.INIWriteTextLineOp: logs.AddRange(CommandIni.IniWriteTextLineOp(s, cmd)); break; case CodeType.INIMerge: logs.AddRange(CommandIni.IniMerge(s, cmd)); break; #endregion #region 05 Archive case CodeType.Compress: logs.AddRange(CommandArchive.Compress(s, cmd)); break; case CodeType.Decompress: logs.AddRange(CommandArchive.Decompress(s, cmd)); break; case CodeType.Expand: logs.AddRange(CommandArchive.Expand(s, cmd)); break; case CodeType.CopyOrExpand: logs.AddRange(CommandArchive.CopyOrExpand(s, cmd)); break; #endregion #region 06 Network case CodeType.WebGet: case CodeType.WebGetIfNotExist: // Deprecated logs.AddRange(CommandNetwork.WebGet(s, cmd)); break; #endregion #region 07 Plugin case CodeType.ExtractFile: logs.AddRange(CommandPlugin.ExtractFile(s, cmd)); break; case CodeType.ExtractAndRun: logs.AddRange(CommandPlugin.ExtractAndRun(s, cmd)); break; case CodeType.ExtractAllFiles: logs.AddRange(CommandPlugin.ExtractAllFiles(s, cmd)); break; case CodeType.Encode: logs.AddRange(CommandPlugin.Encode(s, cmd)); break; #endregion #region 08 Interface case CodeType.Visible: logs.AddRange(CommandInterface.Visible(s, cmd)); break; case CodeType.VisibleOp: logs.AddRange(CommandInterface.VisibleOp(s, cmd)); break; case CodeType.Message: logs.AddRange(CommandInterface.Message(s, cmd)); break; case CodeType.Echo: logs.AddRange(CommandInterface.Echo(s, cmd)); break; case CodeType.EchoFile: logs.AddRange(CommandInterface.EchoFile(s, cmd)); break; case CodeType.UserInput: logs.AddRange(CommandInterface.UserInput(s, cmd)); break; case CodeType.AddInterface: logs.AddRange(CommandInterface.AddInterface(s, cmd)); break; #endregion #region 09 Hash case CodeType.Hash: logs.AddRange(CommandHash.Hash(s, cmd)); break; #endregion #region 10 String case CodeType.StrFormat: logs.AddRange(CommandString.StrFormat(s, cmd)); break; #endregion #region 11 Math case CodeType.Math: logs.AddRange(CommandMath.Math(s, cmd)); break; #endregion #region 12 System case CodeType.System: logs.AddRange(CommandSystem.SystemCmd(s, cmd)); break; case CodeType.ShellExecute: case CodeType.ShellExecuteEx: case CodeType.ShellExecuteDelete: case CodeType.ShellExecuteSlow: logs.AddRange(CommandSystem.ShellExecute(s, cmd)); break; #endregion #region 13 Branch case CodeType.Run: case CodeType.Exec: CommandBranch.RunExec(s, cmd); break; case CodeType.Loop: CommandBranch.Loop(s, cmd); break; case CodeType.If: CommandBranch.If(s, cmd); break; case CodeType.Else: CommandBranch.Else(s, cmd); break; case CodeType.Begin: throw new InternalParserException("CodeParser Error"); case CodeType.End: throw new InternalParserException("CodeParser Error"); #endregion #region 14 Control case CodeType.Set: logs.AddRange(CommandControl.Set(s, cmd)); break; case CodeType.SetMacro: logs.AddRange(CommandControl.SetMacro(s, cmd)); break; case CodeType.AddVariables: logs.AddRange(CommandControl.AddVariables(s, cmd)); break; case CodeType.Exit: logs.AddRange(CommandControl.Exit(s, cmd)); break; case CodeType.Halt: logs.AddRange(CommandControl.Halt(s, cmd)); break; case CodeType.Wait: logs.AddRange(CommandControl.Wait(s, cmd)); break; case CodeType.Beep: logs.AddRange(CommandControl.Beep(s, cmd)); break; case CodeType.GetParam: logs.AddRange(CommandControl.GetParam(s, cmd)); break; case CodeType.PackParam: logs.AddRange(CommandControl.PackParam(s, cmd)); break; #endregion #region 15 External Macro case CodeType.Macro: CommandMacro.Macro(s, cmd); break; #endregion #region Error // Error default: logs.Add(new LogInfo(LogState.Error, $"Cannot execute [{cmd.Type}] command")); break; #endregion } } catch (CriticalErrorException) { // Stop Building logs.Add(new LogInfo(LogState.CriticalError, "Critical Error!", cmd, curDepth)); throw new CriticalErrorException(); } catch (InvalidCodeCommandException e) { logs.Add(new LogInfo(LogState.Error, e, e.Cmd, curDepth)); } catch (Exception e) { logs.Add(new LogInfo(LogState.Error, e, cmd, curDepth)); } // If ErrorOffCount is on, ignore LogState.Error and LogState.Warning ProcessErrorOff(s, cmd, logs); // Stop build on error if (StopBuildOnError) { if (0 < logs.Count(x => x.State == LogState.Error)) { s.ErrorHaltFlag = true; } } s.Logger.Build_Write(s, LogInfo.AddCommandDepth(logs, cmd, curDepth)); // Increase only if cmd resides in CurrentPlugin. // So if a setion is from Macro, it will not be count. if (!s.ProcessedSectionHashes.Contains(cmd.Addr.Section.GetHashCode()) && s.CurrentPlugin.Equals(cmd.Addr.Plugin)) { s.MainViewModel.BuildPluginProgressBarValue += 1; } // Return logs, used in unit test return(logs); }
public BasicCommand(CommandString command, string[] positionalParams) : this(command, null, positionalParams) { }
public BasicCommand(CommandString command, Player player, string[] positionalParams) { this.commStr = command; this.player = player; this.positionalParams = positionalParams; }
public RequestContext(ITelegramBotClient client, MessageEventArgs args, CommandString cmd) { Client = client; EventArgs = args; Command = cmd; }
public override void ReplaceInTemplate(string toBeReplaced, MatlabCommand toReplace) { CommandString = CommandString.Replace(toBeReplaced, toReplace.ToString()); }
public Command Find(CommandString commandString) => commands.Find(command => command.Check(commandString));
public void sendInvite(string uri) { CommandString invite = new CommandString("", SipCommandString.invite, uri); CommandString resp = getCallback().handleCommandResp("sip", invite); Console.WriteLine("Calling: " + resp.getString()); callId = resp.get("destination_id"); }
public override void ReplaceInTemplate(string toBeReplaced, string toReplace) { CommandString = CommandString.Replace(toBeReplaced, toReplace); }