Ejemplo n.º 1
0
        private bool validateState(PersonState state)
        {
            var valid = state != null &&
                !string.IsNullOrWhiteSpace(state.name) &&
                state.lastLeft.ToUniversalTime() < DateTime.UtcNow && state.lastSeen.ToUniversalTime() < DateTime.UtcNow &&
                ((state.IsPresent && state.lastLeft < state.lastSeen) ||
                (!state.IsPresent && (state.lastLeft > state.lastSeen || (state.lastLeft == state.lastSeen && state.lastSeen == DateTime.MinValue.ToUniversalTime()))));

            if (valid)
            {
                state.lastLeft = state.lastLeft.ToUniversalTime();
                state.lastSeen = state.lastSeen.ToUniversalTime();
            }
            else
            {
                log.DebugFormat("Invalid state for {0}", state);
            }
            return valid;
        }
Ejemplo n.º 2
0
 //[IdentityBasicAuthentication]
 //[Authorize]
 // POST: api/State
 public async Task<IEnumerable<PersonState>> Get()
 {
     var id = new
     {
         Realm = "Default",
         Group = "Morad",
         Location = "Home"
     };
  
     log.DebugFormat("Getting state");
     IEnumerable<PersonState> res = null;
     try
     {
         res = stateReport.GetLocationState(id.Realm, id.Group, id.Location);
     }
     catch (Exception e)
     {
         res = new PersonState[] {};
     }
     return res;
 }
Ejemplo n.º 3
0
 private Person CreatePerson(PersonState personState)
 {
     return new Person(personState.name, personState.lastSeen, personState.lastLeft, personState.IsPresent);
 }