//public void move(int srcState, string action) public Task move(Message m, SessionData currentBotData) { return(Task.Run(() => { string action = m.Text; // بدست آوردن وضعیت بعدی، با توجه به وضعیت فعلی و حرکت انجام شده BotState nextState = getNextState(currentBotData.botState, action); // ذخیره کردن وضعیت فعلی ، در متغیر وضعیت قبلی currentBotData.preBotState = currentBotData.botState; // به روز رسانی وضعیت فعلی به وضعیت بعدی currentBotData.botState = nextState; // گرفتن کار مشخص شده پس از رسیدن به وضعیت جدید PostFunction postFunction = getPostFunction(currentBotData.preBotState, nextState); // انجام کار مشخص شده برای وضعیت جدید postFunction(new PostFunctionData(m, currentBotData)); })); }
/// <summary> /// Process SUT Control Command /// </summary> /// <param name="requestMessage"></param> /// <returns></returns> public static SUT_Control_Response_Message ProcessCommand(SUT_Control_Request_Message requestMessage) { PostOperation = null; if (requestMessage == null) { throw new ArgumentNullException("SUT_Control_Request_Message inputed is null"); } if (requestMessage.messageType != SUTControl_MessageType.SUT_CONTROL_REQUEST || requestMessage.testsuiteId != SUTControl_TestsuiteId.RDP_TESTSUITE) { throw new ArgumentException("Not available request message." + requestMessage.messageType + "," + requestMessage.testsuiteId); } RDPSUTControl_CommandId commandId = (RDPSUTControl_CommandId)requestMessage.commandId; byte[] payload = null; string errorMessage = null; uint resultCode = 1; try { switch (commandId) { case RDPSUTControl_CommandId.START_RDP_CONNECTION: RDP_Connection_Payload rdpPayload = new RDP_Connection_Payload(); int index = 0; if (rdpPayload.Decode(requestMessage.payload, (int)requestMessage.payloadLength, ref index)) { if (rdpPayload.type == RDP_Connect_Payload_Type.RDP_FILE) { if (Start_RDP_Connection(rdpPayload.rdpFileConfig) > 0) { resultCode = (uint)SUTControl_ResultCode.SUCCESS; } } else { if (Start_RDP_Connection(rdpPayload.configureParameters) > 0) { resultCode = (uint)SUTControl_ResultCode.SUCCESS; } } } break; case RDPSUTControl_CommandId.CLOSE_RDP_CONNECTION: if (Close_RDP_Connection() > 0) { resultCode = (uint)SUTControl_ResultCode.SUCCESS; } break; case RDPSUTControl_CommandId.AUTO_RECONNECT: resultCode = (uint)SUTControl_ResultCode.SUCCESS; PostOperation = AUTO_RECONNECT; break; case RDPSUTControl_CommandId.SCREEN_SHOT: if (TAKE_SCREEN_SHOT(out payload) > 0) { resultCode = (uint)SUTControl_ResultCode.SUCCESS; } break; default: errorMessage = "SUT control agent doesn't support this command:" + commandId; break; } } catch (Exception e) { errorMessage = "Exception found when process " + commandId + "," + e.Message; } SUT_Control_Response_Message responseMessage = new SUT_Control_Response_Message(SUTControl_TestsuiteId.RDP_TESTSUITE, (ushort)commandId, requestMessage.caseName, requestMessage.requestId, resultCode, errorMessage, payload); return(responseMessage); }
public RulePostFunction(BotState newState, BotState preState, PostFunction function) { this.nextState = newState; this.preState = preState; this.function = function; }
public void addRulePostFunction(BotState newState, PostFunction function) { rulePostFunctions.Add(new RulePostFunction(newState, BotStates.Invalid, function)); }
public void addRulePostFunction(BotState newState, BotState preState, PostFunction function) { rulePostFunctions.Add(new RulePostFunction(newState, preState, function)); }