public bool SendCommand(IClientCommand o) { MemoryStream ms = new MemoryStream(); try { BinaryWriter writer = new BinaryWriter(ms); // write packet ID. currently a byte. NetworkPacketId[] npi = (NetworkPacketId[])o.GetType().GetCustomAttributes(typeof(NetworkPacketId), false); if (npi.Length != 0) { writer.Write(npi[0].PacketID); Serializer.Serialize(ms, o); return(SendPacket(ms.ToArray())); } Debug.LogFormat("ERROR: Can't send commands without ID! (type = {0})", o.GetType().Name); return(false); } catch (Exception) { return(false); } finally { ms.Close(); } }
public void ProcessCommand(string text, NetConnection sender) { var args = new List <string>(); CommandParsing.ParseArguments(text, args); if (args.Count == 0) { return; } string cmd = args[0]; try { IClientCommand command = AvailableCommands[cmd]; args.RemoveAt(0); var client = IoCManager.Resolve <ISS14Server>().GetClient(sender); command.Execute(this, client, args.ToArray()); } catch (KeyNotFoundException) { SendConsoleReply(string.Format("Unknown command: '{0}'", cmd), sender); } catch (Exception e) { SendConsoleReply(string.Format("There was an error while executing the command: {0}", e.Message), sender); } }
/// <summary> /// execute all pending commands - create the equivalent local commands and invoke its' execute method /// </summary> /// <param name="sendingInstruction"></param> /// <param name="sessionStage"></param> /// <param name="res"></param> internal override void Execute(SendingInstruction sendingInstruction, SessionStage sessionStage, IResultValue res) { MGDataCollection mgDataTab = MGDataCollection.Instance; // loop on all MGData for (int i = 0; i < mgDataTab.getSize(); i++) { MGData mgd = mgDataTab.getMGData(i); if (mgd != null && !mgd.IsAborting) { CommandsTable commands = mgd.CmdsToServer; // go over all commands while (commands.getSize() > 0) { // extract command from CmdsToServer IClientCommand command = commands.ExtractCommand(0); LocalRunTimeCommandBase localRunTimeCommand = _localRunTimeCommandFactory.CreateLocalRunTimeCommand(command); localRunTimeCommand.Execute(); } Debug.Assert(mgd.CmdsToClient.getSize() == 0, "Not all commands were executed"); } } }
/// <summary> Stops the specified task and all the tasks which are invoked by it. </summary> /// <param name="task"></param> /// <returns></returns> private bool StopTaskTree(Task task) { bool taskStopped = false; if (task.hasSubTasks()) { for (int i = 0; i < task.SubTasks.getSize();) { //If the task was not stopped, then only increment the counter, because, if //the task was stopped, it is removed from task.SubTasks and so, the next //task is available at the same index. if (!StopTaskTree(task.SubTasks.getTask(i))) { i++; } } } //Do not execute abort command for the subform. Subform task are stopped //when its container task will be aborted. if (!task.IsSubForm) { MGData mgData = task.getMGData(); IClientCommand abortCommand = CommandFactory.CreateAbortCommand(task.getTaskTag()); mgData.CmdsToClient.Add(abortCommand); // execute the command mgData.CmdsToClient.Execute(null); taskStopped = true; } return(taskStopped); }
/// <summary> /// /// </summary> internal override void Execute() { IClientCommand cmd = null; bool canExecute = ClientManager.Instance.LocalManager.ApplicationDefinitions.TaskDefinitionIdsManager.CanExecuteTask(TaskDefinitionId); if (canExecute) { // create the command string taskUrl = getXmlTaskURL(ClientManager.Instance.LocalManager.ApplicationDefinitions.TaskDefinitionIdsManager, TaskDefinitionId); if (taskUrl != null) { cmd = CommandFactory.CreateOpenTaskCommand(taskUrl, ArgList, ReturnValueField, ForceModal, CallingTaskTag, PathParentTaskTag, SubformDitIdx, SubformCtrlName); } else { // TODO - inform of error } base.Execute(cmd); } else { // User is not authorized - show message in statusbar. Task task = (Task)MGDataCollection.Instance.GetTaskByID(CallingTaskTag); Manager.WriteToMessagePanebyMsgId((Task)task.GetContextTask(), MsgInterface.CSTIO_STR_ERR2, ClientManager.StartedFromStudio); } }
/// <summary> /// get linked record /// </summary> /// <param name="curRec"></param> /// <returns></returns> internal override bool getLinkedRecord(Record curRec) { IClientCommand dataViewCommand = CommandFactory.CreateRecomputeUnitDataViewCommand(_task.getTaskTag(), RecomputeIdFactory.GetRecomputeId(this), curRec.getId()); ReturnResult result = _task.DataviewManager.Execute(dataViewCommand); return(result.Success); }
/// <summary> /// send a command to server to update dataview to datasource. /// </summary> internal bool UpdateDataViewToRemoteDataSource() { if (dataViewContent != null) { IClientCommand cmd = CommandFactory.CreateUpdateDataViewToDataSourceCommand(Task.getTaskTag(), command.TaskVarNames, command.DestinationDataSourceNumber, command.DestinationDataSourceName, command.DestinationColumns, dataViewContent.ToString(), null, null); Task.getMGData().CmdsToServer.Add(cmd); ResultValue res = new ResultValue(); // Do not serialize flow monitor messages along with MG_ACT_UPDATE_DATAVIEW_TO_DATASOURCE command bool origVal = FlowMonitorQueue.Instance.ShouldSerialize; FlowMonitorQueue.Instance.ShouldSerialize = false; //Execute MG_ACT_UPDATE_DATAVIEW_TO_DATASOURCE command. RemoteCommandsProcessor.GetInstance().Execute(CommandsProcessorBase.SendingInstruction.ONLY_COMMANDS, CommandsProcessorBase.SessionStage.NORMAL, res); FlowMonitorQueue.Instance.ShouldSerialize = origVal; return(res.Value.Equals("1") ? true : false); } return(true); }
/// <summary> /// a factory method that creates an data view command from the send command /// </summary> /// <param name="command"></param> /// <returns></returns> internal LocalDataViewCommandBase CreateLocalDataViewCommand(IClientCommand command) { LocalDataViewCommandBase localDataViewCommandBase = null; if (command is TransactionCommand) { localDataViewCommandBase = new CommitTransactionLocalDataViewCommand((TransactionCommand)command); } else if (command is DataviewCommand) { localDataViewCommandBase = CreateDataViewCommand((DataviewCommand)command); } else if (command is EventCommand) { localDataViewCommandBase = CreateEventCommand((EventCommand)command); } else if (command is ExecOperCommand) { ExecOperCommand execOperCommand = (ExecOperCommand)command; if (execOperCommand.Operation != null && execOperCommand.Operation.getType() == ConstInterface.MG_OPER_UPDATE) { localDataViewCommandBase = new LocalDataViewCommandUpdateNonModifiable(execOperCommand); } } if (localDataViewCommandBase != null) { localDataViewCommandBase.DataviewManager = LocalDataviewManager; localDataViewCommandBase.LocalManager = ClientManager.Instance.LocalManager; } return(localDataViewCommandBase); }
/// <summary> /// ctor /// </summary> /// <param name="command"></param> internal LocalDataViewFetchViewCommandBase(IClientCommand command) : base(command) { clientRecId = 0; PerformUpdateAfterFetch = true; ClientIdsToCompute = new List <int>(); }
/// <summary> /// /// </summary> /// <param name="dataviewmanager"></param> /// <param name="reversibleExit"></param> /// <param name="level"></param> /// <param name="oper"></param> /// <returns></returns> internal bool checkAndCommitPerDataview(DataviewManagerBase dataviewmanager, bool reversibleExit, char level, char oper, ref ReturnResult result) { result = new ReturnResult(); bool returnValue = false; Transaction currentTransaction = dataviewmanager.Transaction; if (currentTransaction != null && !task.isAborting() && currentTransaction.isOpened() && currentTransaction.isOwner(task) && currentTransaction.getLevel() == level) { IClientCommand cmd = CommandFactory.CreateTransactionCommand(oper, task.getTaskTag(), reversibleExit, level); try { task.TryingToCommit = true; result = dataviewmanager.Execute(cmd); } finally // Don't catch any exception here. Just turn off the "tryingToCommit" flag. { task.TryingToCommit = false; } returnValue = true; } return(returnValue); }
public void ProcessCommand(MsgConCmd message) { string text = message.Text; INetChannel sender = message.MsgChannel; var args = new List <string>(); CommandParsing.ParseArguments(text, args); if (args.Count == 0) { return; } string cmd = args[0]; try { IClientCommand command = AvailableCommands[cmd]; args.RemoveAt(0); command.Execute(this, sender, args.ToArray()); } catch (KeyNotFoundException) { SendConsoleReply(string.Format("Unknown command: '{0}'", cmd), sender); } catch (Exception e) { SendConsoleReply(string.Format("There was an error while executing the command: {0}", e.Message), sender); } }
/// <summary> /// extract and remove a command from the table /// </summary> /// <param name="commandIndex"> index of command in the table</param> /// <returns></returns> internal IClientCommand ExtractCommand(int commandIndex) { IClientCommand command = getCmd(commandIndex); _cmds.RemoveAt(commandIndex); return(command); }
/// <summary> /// execute the local updfates command /// </summary> /// <returns></returns> internal ReturnResult ExecuteLocalUpdatesCommand() { // execute local command IClientCommand dataViewExecuteLocalUpdatesCommand = CommandFactory.CreateDataViewCommand(task.getTaskTag(), DataViewCommandType.ExecuteLocalUpdates); ReturnResult result = task.DataviewManager.Execute(dataViewExecuteLocalUpdatesCommand); return(result); }
/// <summary> /// execute the command by pass requests to the server /// </summary> /// <param name="command"></param> internal override ReturnResult Execute(IClientCommand command) { base.Execute(command); RemoteDataViewCommandBase remoteDataViewCommandBase = _remoteDataViewCommandFactory.CreateDataViewCommand((ClientOriginatedCommand)command); ReturnResultBase gatewayResult = remoteDataViewCommandBase.Execute(); return(new ReturnResult(gatewayResult)); }
public void RunAll(List <byte> data) { IClientCommand socketcommand = ProtocolRule.GetClientCommand(data); socketcommand._AfterDecodeData = data; socketcommand._AfterDecodeData.RemoveAt(0); socketcommand._AfterDecodeData.RemoveAt(0); socketcommand._AfterDecodeData.RemoveAt(socketcommand._AfterDecodeData.Count - 1); socketcommand.Analysis(); }
public void OnDataReceived(ProtocolBase <TTransportDestType> protocol, IClientCommand action, Type actiontype) { var data = protocol.ProtocolName != _protocol.ProtocolName ? _protocol.CleanData(protocol.GetDataToSend()) : protocol.GetBody(); var obj = DeSerializer.Deserialize(actiontype, data); action.Execute(this, obj as IClientCommand); }
public override void Execute(rt.IResultValue res) { MGDataCollection mgDataTab = MGDataCollection.Instance; Task task = (Task)mgDataTab.GetTaskByID(TaskTag); IClientCommand command = CommandFactory.CreateDataViewCommand(TaskTag, DataViewCommandType.ResetUserSort); task.DataviewManager.Execute(command); }
/// <summary> /// CTOR /// </summary> /// <param name="command"></param> public LocalDataViewCommandLocate(IClientCommand command) : base(command) { RefreshEventCommand refreshEventCommand = command as RefreshEventCommand; if (refreshEventCommand != null) { clientRecId = refreshEventCommand.ClientRecId; } }
public override void Process(IClientCommand clientCommand, IWorld world, IPlayer player) { base.Process(clientCommand, world, player); var casted = H.Cast <IMovePlayerClientCommand>(clientCommand); player.MoveToX = casted.ToX; player.MoveToY = casted.ToY; player.IsMoving = true; }
/// <summary> /// /// </summary> /// <param name="resType"></param> /// <returns></returns> internal ExpressionEvaluator.ExpVal evaluate(StorageAttribute resType) { ExpressionEvaluator.ExpVal expVal = null; String retVal; bool isNull = false; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); } else { RunTimeEvent rtEvt = ClientManager.Instance.EventsManager.getLastRtEvent(); Task mprgCreator = null; if (rtEvt != null) { mprgCreator = rtEvt.getMainPrgCreator(); } // create a new command object only when necessary if (resType != _prevResType) { _cmdToServer = CommandFactory.CreateEvaluateCommand(_task.getTaskTag(), resType, _id, 0, mprgCreator); } ClientManager.Instance.execRequestWithSubformRecordCycle(_cmdsToServer, _cmdToServer, this, _task); if (resType != StorageAttribute.BLOB && resType != StorageAttribute.BLOB_VECTOR) { retVal = _resultValue; } else if (_resultValue != null && _resultValue.Equals(" ")) { retVal = ""; } else { retVal = RecordUtils.byteStreamToString(_resultValue); } if (retVal == null) { isNull = true; } // If we don't know what result type we got, and want to keep it, as in ExpCalc if (resType == StorageAttribute.NONE) { resType = _type; } expVal = new ExpressionEvaluator.ExpVal(resType, isNull, retVal); } _prevResType = resType; return(expVal); }
public bool Recompute(Task task, Record record) { IClientCommand dataViewCommand = CommandFactory.CreateRecomputeUnitDataViewCommand(task.getTaskTag(), unitId, record.getId()); ReturnResult result = task.DataviewManager.Execute(dataViewCommand); if (result.Success) { control.RefreshDisplay(); } return(result.Success); }
public static ClientCommandEntity Map(IClientCommand c, WorldEntity world, PlayerEntity player) { if (c.Type == H.Get <IPing>()) { return(Map(c as IPing, world, player)); } if (c.Type == H.Get <IMovePlayerClientCommand>()) { return(Map(c as IMovePlayerClientCommand, world, player)); } throw new Exception($"Unexpected client command type='{c.Type}'"); }
/// <summary> /// Execute subform refresh that is sent from the server /// </summary> private void ExecuteClientRefreshCommand() { MGDataTable mgDataTab = MGDataTable.Instance; Task task = (Task)mgDataTab.GetTaskByID(TaskTag); Debug.Assert(task.IsSubForm); if (task.AfterFirstRecordPrefix && !task.isInEndTask()) { IClientCommand command = CommandFactory.CreateSubformRefreshCommand(((Task)task).getParent().getTaskTag(), task.getTaskTag(), true); ((Task)task).DataviewManager.Execute(command); } }
private void ReceiveClientCommand(NetPacketReader reader, int clientNetId) { IClientCommand command = m_clientCommandDict[(NetworkToServerDataType)reader.GetByte()]; if (command.m_DataType != NetworkToServerDataType.SET_POSITION) { Console.WriteLine("CC: " + command.m_DataType); } try { command.Execute(reader, clientNetId); } catch (Exception e) { Console.WriteLine(e); } }
public void Dispatcher(IClientCommand command) { //与实际接收到的_fullrecvdata信息做对比 TcpClientDispatcher clientdispatcher = new TcpClientDispatcher(command); //漏洞:_fullrecvdata有可能已经过滤了有效数据,两帧数据合并的现象 List <byte> fullrecvdata = _fullrecvdata.ToList <byte>(); fullrecvdata.RemoveAt(0); fullrecvdata.RemoveAt(0); fullrecvdata.RemoveAt(fullrecvdata.Count - 1); command._AfterDecodeData = fullrecvdata; //command//此处添加属性 clientdispatcher.Run(); }
public static IClientCommand CreateClientCommandObject( TProtocol tprotocol) { #region IClientCommand orgdata = null; switch (tprotocol) { case TProtocol.RecvChatContent: orgdata = new RecvChatContent(); break; } return(orgdata); #endregion }
/// <summary> /// This function finds all subform controls and opens their tasks. /// </summary> /// <param name="task"></param> private void Callsubforms(Task task) { IList <MgControlBase> list = task.getForm().CtrlTab.GetControls(IsSubformWithTask); foreach (MgControl ctrl in list) { // may be the subform task was opened from call with destination from the RP of the previous subform if (ctrl.getSubformTask() == null) { IClientCommand cmd = CommandFactory.CreateSubformOpenCommand(task.getTaskTag(), ctrl.getDitIdx()); task.getMGData().CmdsToServer.Add(cmd); task.CommandsProcessor.Execute(CommandsProcessorBase.SendingInstruction.ONLY_COMMANDS); } } }
public NetworkService() { // 初始化LiteNet m_serverNetManager = new NetManager(this); m_serverNetManager.Start(c_serverPort); // 实例化所有 ClientCommand 接口的实现类 var ccType = typeof(IClientCommand); var ccImplTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Where(p => p.IsClass && ccType.IsAssignableFrom(p)); foreach (var type in ccImplTypes) { IClientCommand cc = type.GetConstructor(Type.EmptyTypes).Invoke(null) as IClientCommand; m_clientCommandDict.Add(cc.m_DataType, cc); } }
/// <summary> /// CTOR /// </summary> /// <param name="taskDefinitionId"></param> /// <param name="command"></param> public LocalRunTimeCommandSelectProgram(TaskDefinitionId taskDefinitionId, IClientCommand command) : base(taskDefinitionId) { ExecOperCommand cmd = command as ExecOperCommand; Debug.Assert(cmd != null); Task task = Manager.MGDataTable.GetTaskByID(cmd.TaskTag) as Task; MgForm form = task.getForm() as MgForm; mgControl = form.CtrlTab.getCtrl(cmd.DitIdx) as MgControl; CallingTaskTag = cmd.TaskTag; PathParentTaskTag = CallingTaskTag; ForceModal = true; }
/// <summary> /// create and execute command rollback transaction by send the RollbackType /// </summary> /// <param name="rollbackType"> if it is cancel we refresh the all open tasks under the same transaction /// if it is rollback we close the all open tasks under the same transaction /// </param> /// <returns></returns> internal ReturnResult CreateAndExecuteRollbackLocalTransaction(RollbackEventCommand.RollbackType rollbackType) { ReturnResult ReturnResult = new ReturnResult(); // if local transaction exist on the task take it from the transaction.ownerTask ; string taskTag = task.DataviewManager.LocalDataviewManager.Transaction != null?task.DataviewManager.LocalDataviewManager.Transaction.OwnerTask.getTaskTag() : task.getTaskTag(); // execute the rollback event command on the opened local transaction if (TaskTransactionManager.LocalOpenedTransactionsCount > 0) { IClientCommand command = CommandFactory.CreateRollbackEventCommand(taskTag, rollbackType); ReturnResult = ((Task)task).DataviewManager.LocalDataviewManager.Execute(command); } return(ReturnResult); }
public ClientCommandEventArgs(IClient Client, IClientCommand cmd, string[] tokens) : base(Client) { this.Command = cmd; this.Tokens = tokens; }
public CommandEventArgs(Client client, IClientCommand command, string[] tokens) { Client = client; Tokens = tokens; Command = command; }
internal void OnCommand(Client client, IClientCommand cmd, string[] tokens) { if (Command != null) Command.Invoke(client, new CommandEventArgs(client, cmd, tokens)); }
public void SendToServer(IClientCommand command) { lock (_fakeClientCommands) _fakeClientCommands.Enqueue(command); }