Пример #1
0
        public async Task <BandDataViewModel> GetBandDataAsync()
        {
            try
            {
                ConditionalValue <BandActorState> BandActorStateResult = await this.StateManager.TryGetStateAsync <BandActorState>("BandActorState");

                if (BandActorStateResult.HasValue)
                {
                    BandActorState state = BandActorStateResult.Value;

                    HealthIndexCalculator ic = this.indexCalculator;
                    HealthIndex           hi = state.HealthIndex;

                    int healthIndex = ic.ComputeIndex(hi);

                    return(new BandDataViewModel(
                               state.DoctorId,
                               this.Id.GetGuidId(),
                               state.PatientName,
                               state.CountyInfo,
                               healthIndex,
                               state.HeartRateHistory));
                }
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Exception inside band actor {0}|{1}|{2}", this.Id, this.Id.Kind, e));
            }

            throw new ArgumentException(string.Format("No band actor state {0}|{1}|{2}", this.Id, this.Id.Kind));
        }
Пример #2
0
        public async Task NewAsync(BandInfo info)
        {
            ConditionalValue <BandActorState> BandActorStateResult = await this.StateManager.TryGetStateAsync <BandActorState>("BandActorState");

            if (!BandActorStateResult.HasValue)
            {
                BandActorState state = new BandActorState();
                state.CountyInfo  = info.CountyInfo;
                state.DoctorId    = info.DoctorId;
                state.HealthIndex = info.HealthIndex;
                state.PatientName = info.PersonName;

                await this.StateManager.SetStateAsync <BandActorState>("BandActorState", state);

                await this.RegisterReminders();

                ActorEventSource.Current.ActorMessage(this, "Band created. ID: {0}, Name: {1}, Doctor ID: {2}", this.Id, state.PatientName, state.DoctorId);
            }
        }