private bool forceActToEnd;  // 當前動作一定會做完,不會被其他動作中斷(依舊會被外力影響中斷)

    public Operation(string name, IEnumerator action = null, float delay = 0)
    {
        this.name   = name;
        this.action = action;
        this.delay  = delay;
        stateType   = OperationStateType.None;
    }
 private void ParseResult(OperationStatusResultResponseRoot responseData)
 {
     if (responseData.status == OperationStatusResponseMessages.StatusBadRequest)
     {
         OperationState = OperationStateType.BadRequest;
         return;
     }
     OperationState = responseData.status.ToOperationStatus();
 }
        private void AddResultToCollection()
        {
            if (ApiCallResult == null)
            {
                ResponseData = new OperationStatusResultResponseRoot {
                    status = OperationStatusResponseMessages.StatusFailed, message = "No data returned."
                };
                ActionSubmittedSuccessfully = false;
                return;
            }

            if (!ApiCallResult.Successfull)
            {
                ActionSubmittedSuccessfully = false;
                return;
            }

            try
            {
                ResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject <OperationStatusResultResponseRoot>(ApiCallResult.Data);
                if (ResponseData == null || string.IsNullOrWhiteSpace(ResponseData.status))
                {
                    ActionSubmittedSuccessfully = false;
                    OperationState = OperationStateType.BadRequest;
                    return;
                }

                ParseResult(ResponseData);
                ActionSubmittedSuccessfully = true;
            } catch (Exception ex)
            {
                OperationState = OperationStateType.Failed;
                ResponseData   = new OperationStatusResultResponseRoot {
                    status = OperationStatusResponseMessages.StatusFailed, message = $"Error parsing results: {ex.Message}"
                };
                ActionSubmittedSuccessfully = false;
            }
        }
 /// <summary>
 /// 設置動作狀態 (以對應下一個動作)
 /// </summary>
 public void SetOperationState(OperationStateType stateType)
 {
     this.stateType = stateType;
 }
示例#5
0
 private static bool HasOperationEnded(OperationStateType operationState)
 {
     return(operationState == OperationStateType.BadRequest ||
            operationState == OperationStateType.CompletedSuccessfully ||
            operationState == OperationStateType.Failed);
 }