private static async Task <ScheduleResults> GetSchedules(string eventID)
        {
            APIService    srv             = new APIService();
            ScheduleModel model           = new ScheduleModel();
            Dictionary <string, string> p = new Dictionary <string, string>();

            p.Add("eventId", string.Format("'{0}'", eventID));

            model.CommandModel.SessionToken = await App.GetUsersSession();

            model.CommandModel.ServiceName = "Schedule";
            model.CommandModel.Action      = "GetSchedulesForEvent";
            model.CommandModel.Parameters  = p;

            ScheduleResults result = null;
            var             cache  = BlobCache.UserAccount;
            var             cachedSchedulesPromise = cache.GetAndFetchLatest(
                "schedules",
                () => srv.GetSchedulesForEvent(model.CommandModel),
                offset =>
            {
                TimeSpan elapsed = DateTimeOffset.Now - offset;
                return(elapsed > new TimeSpan(hours: 0, minutes: 10, seconds: 0));
            });

            cachedSchedulesPromise.Subscribe(subscribedSchedules =>
            {
                result = subscribedSchedules;
            });

            result = await cachedSchedulesPromise.FirstOrDefaultAsync();

            return(result);
        }
Exemple #2
0
 private void StartLoad()
 {
     ProgressRing.Hidden = false;
     ProgressRing.StartAnimating();
     Task.Run(async() =>
     {
         Schedule = null;
         await LoadScheduleAsync();
     });
 }
Exemple #3
0
        public OutputDayInfo(OutputDay day, IEnumerable <DayWorship> dayWorships
                             , ScheduleResults scheduleResults, IEnumerable <BusinessConstraint> constraints)
        {
            Day             = day ?? throw new ArgumentNullException(nameof(day));
            ScheduleResults = scheduleResults ?? throw new ArgumentNullException(nameof(scheduleResults));

            if (dayWorships != null)
            {
                _dayWorships = dayWorships.ToList();
            }

            if (constraints != null)
            {
                BrokenConstraints = constraints;
            }
        }
Exemple #4
0
        private async Task LoadScheduleAsync()
        {
            if (Schedule == null)
            {
                DataSource = new ScheduleDataSource();
                Appointment a = ApplicationData.Current.NewAppointment;
                DataServiceResponse <ScheduleResults> response = await DataSource.GetAvailableTimes(StartDate,
                                                                                                    EndDate, a.BranchNumber,
                                                                                                    a.AppointmentType.Value,
                                                                                                    a.AppointmentSubType.Value,
                                                                                                    a.AppointmentLanguage);

                if (response.Success)
                {
                    if (string.IsNullOrEmpty(response.Data.ErrorMessage))
                    {
                        Schedule = response.Data;
                        foreach (ScheduleResult r in Schedule.ScheduleDays)
                        {
                            if (r.ScheduleDate.Date.Equals(SelectedDay.Date))
                            {
                                ReloadTable(new TimeSlotSource(r.TimeSlots));
                                break;
                            }
                        }
                        InvokeOnMainThread(() =>
                        {
                            ProgressRing.StopAnimating();
                        });
                    }
                    else
                    {
                        //scheduling system error
                        InvokeOnMainThread(() =>
                        {
                            ProgressRing.StopAnimating();
                            var alert = UIAlertController.Create("Schedule Engine Error", $"{response.Data.ErrorMessage}", UIAlertControllerStyle.Alert);
                            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                            PresentViewController(alert, true, null);
                        });
                    }
                }
                else
                {
                    //error
                    InvokeOnMainThread(() =>
                    {
                        ProgressRing.StopAnimating();
                        var alert = UIAlertController.Create("Error", $"Load Error: {response.ErrorMessage}", UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                        PresentViewController(alert, true, null);
                    });
                }
            }
            else
            {
                foreach (ScheduleResult r in Schedule.ScheduleDays)
                {
                    if (r.ScheduleDate.Date.Equals(SelectedDay.Date))
                    {
                        ReloadTable(new TimeSlotSource(r.TimeSlots));
                        break;
                    }
                }
            }
        }