public static SGCommand ConvertFromCommand(Command command) { if (command == null) { return(null); } SGCommand sgcmd = null; if (!command.Parameters.ContainsKey("command")) { return(null); } SGCMD cmd = SGCMD.NONE; if (!Enum.TryParse <SGCMD>(command.Parameters["command"].ToString().Trim().ToUpper(), out cmd)) { return(null); } if (cmd == SGCMD.NONE) { return(null); } sgcmd = new SGCommand(cmd, command.Requestor.ID); foreach (string key in command.Parameters.Keys) { if ((!string.IsNullOrWhiteSpace(key)) && (!"command".Equals(key.Trim()))) { sgcmd.Parameters.Add(key.Trim(), command.Parameters[key]); } } return(sgcmd); }
public SGCommand(SGCMD command, string id) { if (string.IsNullOrWhiteSpace(id)) { throw new Exception(string.Format(Messager.ERR_NULL_OR_EMPTY, "RequestorID")); } Command = command; RequestorID = id.Trim(); Parameters = new Dictionary <string, object>(); SetContinuous(); }
private void Proc_CANCEL(SGCommand command) { var lx_temp = (command.Parameters.ContainsKey("cmd")) ? command.Parameters["cmd"] : null; var ls_cmd = (lx_temp != null) ? lx_temp.ToString().Trim().ToUpper() : null; if (string.IsNullOrWhiteSpace(ls_cmd)) { return; } SGCMD lsg_cmd = SGCMD.NONE; if (!Enum.TryParse <SGCMD>(ls_cmd, out lsg_cmd) || lsg_cmd == SGCMD.NONE) { return; } var lsg_ccmd = ContinuousCommands.FirstOrDefault(cmd => cmd.Command == lsg_cmd && cmd.RequestorID.Equals(command.RequestorID)); if (lsg_ccmd != null) { ContinuousCommands.Remove(lsg_ccmd); } }