Beispiel #1
0
        private IRestResponse ChangeState(TimeWarpCommand command, TimeWarpAgent timeWarpAgent)
        {
            var request =
                new RestRequest(
                    string.Format("userstate/?command={0}&agent={1}", (int)command, (int)timeWarpAgent),
                    Method.POST);

            request.AddHeader("login-token", LoginToken);
            var response = Client.Execute(request);

            return(response);
            // Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Beispiel #2
0
        private void OnUserStateChanged(TimeWarpStateUserMessage updatedState, TimeWarpAgent timeWarpAgent)
        {
            SendOrPostCallback callback = delegate
            {
                EventHandler <UserMessageEventArgs> handler = UserStateChanged;
                if (handler != null)
                {
                    handler(this, new UserMessageEventArgs(updatedState, timeWarpAgent));
                }
            };

            RunCallback(callback);
        }
 public UserStateInfoResponse(long accountId, string username, DateTime queryTime, TimeWarpState state, DateTime periodStartTime,
                              TimeSpan timeLeft, double progress, bool isQuickLoginUser, TimeWarpAgent timeWarpAgent)
 {
     AccountId        = accountId;
     QueryTime        = queryTime;
     State            = state;
     PeriodStartTime  = periodStartTime;
     TimeLeft         = timeLeft;
     Progress         = progress;
     Username         = username;
     IsQuickLoginUser = isQuickLoginUser;
     TimeWarpAgent    = timeWarpAgent;
 }
        // PUT api/values/5
        public void Post(HttpRequestMessage request, TimeWarpCommand command, TimeWarpAgent agent = TimeWarpAgent.Unknown)
        {
            long id;

            if (!_authenticationManager.TryAuthenticateForWriteOperation(request.GetToken(), out id))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }

            if (Log.IsDebugEnabled)
            {
                Log.DebugFormat("updating userState for account ({0}) with command ({1})", id, command);
            }

            var requestTime = _nowProvider.Now;

            var account = _accountRepository.Get(id);

            if (account == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NoContent));
            }

            switch (command)
            {
            case (TimeWarpCommand.Work):
                _userStateManager.StartWork(account, requestTime, (int)agent);
                break;

            case (TimeWarpCommand.Rest):
                _userStateManager.StartRest(account, requestTime, (int)agent);
                break;

            default:
                throw new InvalidEnumArgumentException("command", (int)command, typeof(TimeWarpCommand));
            }
        }
Beispiel #5
0
 public AgentTypeProvider(TimeWarpAgent agent)
 {
     Agent = agent;
 }
Beispiel #6
0
 public IRestResponse StartRest(TimeWarpAgent timeWarpAgent = TimeWarpAgent.Unknown)
 {
     return(ChangeState(TimeWarpCommand.Rest, timeWarpAgent));
 }
 public UserMessageEventArgs(TimeWarpStateUserMessage updatedState, TimeWarpAgent timeWarpAgent)
 {
     TimeWarpAgent = timeWarpAgent;
     _updatedState = updatedState;
 }