Example #1
0
        /// <summary>
        /// Refresh today's meetings
        /// </summary>
        private void RefreshMeetings()
        {
#if DEBUG
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
#endif
            // Execute the action on the main application thread
            if (System.Windows.Application.Current != null)
            {
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    var selected = SelectedMeeting;
                    Meetings.Clear();

                    foreach (var client in m_meetingsBL.GetTodaysMeetings().OrderByDescending(m => m.MeetingDate))
                    {
                        Meetings.Add(client);
                    }

                    if (selected != null)
                    {
                        SelectedMeeting = Meetings.FirstOrDefault(c => c.ClientId == selected.ClientId);
                    }
                }));
            }
#if DEBUG
            sw.Stop();
            System.Diagnostics.Debug.WriteLine("Refresh meetings List Time: " + sw.ElapsedMilliseconds + "ms");
#endif
        }
Example #2
0
        protected override async Task LoadItemsAsync()
        {
            try
            {
                // Make async request to obtain data
                var client  = new RestClient(GlobalConstants.EndPointURL);
                var request = new RestRequest
                {
                    Timeout = GlobalConstants.RequestTimeout
                };
                request.Resource = GlobalConstants.MeetingEndPointRequestURL;
                UserManager.Current.AddAuthorization(request);

                try
                {
                    DataAvailable = false;

                    var response = await client.ExecuteCachedAPITaskAsync(request, GlobalConstants.MaxCacheMeetings, false, true);

                    ErrorMessage = response.ErrorMessage;
                    IsError      = !response.IsSuccessful;

                    if (response.IsSuccessful)
                    {
                        var items = JsonConvert.DeserializeObject <List <Meeting> >(response.Content) ?? new List <Meeting>();

                        foreach (var meeting in items)
                        {
                            // only adds meeting from backend if it matches the meeting type of the page and if it's in the future
                            if (meeting.Type == type && meeting.From >= DateTime.Now)
                            {
                                var existingMeeting = Meetings.FirstOrDefault(m => m.MeetingId == meeting.MeetingId);

                                if (existingMeeting != null)
                                {
                                    existingMeeting.AllDay      = meeting.AllDay;
                                    existingMeeting.Capacity    = meeting.Capacity;
                                    existingMeeting.Color       = meeting.Color;
                                    existingMeeting.ContactId   = meeting.ContactId;
                                    existingMeeting.Description = meeting.Description;
                                    existingMeeting.EventName   = meeting.EventName;
                                    existingMeeting.From        = meeting.From;
                                    existingMeeting.MeetingId   = meeting.MeetingId;
                                    existingMeeting.Organizer   = meeting.Organizer;
                                    existingMeeting.To          = meeting.To;
                                    existingMeeting.Type        = meeting.Type;
                                    existingMeeting.MeetingAttendees.Clear();
                                    foreach (var attendee in meeting.MeetingAttendees)
                                    {
                                        existingMeeting.MeetingAttendees.Add(attendee);
                                    }
                                    existingMeeting.OnPropertyChanged("MeetingAttendees");
                                }
                                else
                                {
                                    Meetings.Add(meeting);
                                }
                            }
                        }

                        OnPropertyChanged("Meetings");

                        DataAvailable = Meetings.Count > 0;
                    }
                }
                catch (Exception e)
                {
                    var properties = new Dictionary <string, string> {
                        { "Category", "Meetings" }
                    };
                    Crashes.TrackError(e, properties);
                }
            }
            catch (Exception)
            {
                // An exception occurred
                DataAvailable = false;
            }
        }