Пример #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
        }
        public async Task LoadAsync()
        {
            Friends.Clear();

            var lookup = await _friendLookupDataService.GetFriendLookupAsync();

            foreach (var friend in lookup)
            {
                Friends.Add(new NavigationItemViewModel(friend.Id, friend.DisplayMember,
                                                        nameof(FriendDetailViewModel),
                                                        _eventAggregator));
            }



            Meetings.Clear();

            lookup = await _meetingLookUpService.GetMeetingLookupAsync();

            foreach (var meeting in lookup)
            {
                Meetings.Add(new NavigationItemViewModel(meeting.Id, meeting.DisplayMember,
                                                         nameof(MeetingDetailViewModel),
                                                         _eventAggregator));
            }
        }
Пример #3
0
        public async Task LoadAsync()
        {
            var lookup = await _friendLookupService.GetFrienLookupAsync();

            Friends.Clear();
            foreach (var item in lookup)
            {
                Friends.Add(new NavigationItemViewModel(
                                item.Id,
                                item.DisplayMember,
                                nameof(FriendDetailViewModel),
                                _eventAggregator));
            }

            lookup = await _meetingLookupService.GetMeetingLookupAsync();

            Meetings.Clear();
            foreach (var item in lookup)
            {
                Meetings.Add(new NavigationItemViewModel(
                                 item.Id,
                                 item.DisplayMember,
                                 nameof(MeetingDetailViewModel),
                                 _eventAggregator));
            }
        }
Пример #4
0
        public Meeting AddMeeting(Meeting meeting)
        {
            meeting.Group = this;

            Meetings.Add(meeting);

            return(meeting);
        }
Пример #5
0
        public Meeting AddMeeting(string name, string description, List <User> members)
        {
            Meeting meeting = new Meeting(name, description, members, this);

            Meetings.Add(meeting);

            return(meeting);
        }
Пример #6
0
        private void GetAppointments(IEnumerable <Appointment> appointments)
        {
            for (int i = 0; i < appointments.Count(); i++)
            {
                ScheduleAppointment appointment = new ScheduleAppointment();
                appointment.Subject   = appointments.ElementAt(i).DescricaoConsultation;
                appointment.Color     = appointments.ElementAt(i).Cor;
                appointment.StartTime = appointments.ElementAt(i).StartTime;
                appointment.EndTime   = appointments.ElementAt(i).EndTime;


                if (appointments.ElementAt(i).Repeat)
                {
                    RecurrenceProperties recurrenceProperties = new RecurrenceProperties();
                    recurrenceProperties.RecurrenceType  = RecurrenceType.Weekly;
                    recurrenceProperties.RecurrenceRange = RecurrenceRange.Count;
                    recurrenceProperties.RecurrenceCount = 10;
                    recurrenceProperties.StartDate       = appointment.StartTime;

                    switch (appointment.StartTime.DayOfWeek)
                    {
                    case DayOfWeek.Monday:
                        recurrenceProperties.WeekDays = WeekDays.Monday;
                        break;

                    case DayOfWeek.Tuesday:
                        recurrenceProperties.WeekDays = WeekDays.Tuesday;
                        break;

                    case DayOfWeek.Wednesday:
                        recurrenceProperties.WeekDays = WeekDays.Wednesday;
                        break;

                    case DayOfWeek.Thursday:
                        recurrenceProperties.WeekDays = WeekDays.Thursday;
                        break;

                    case DayOfWeek.Friday:
                        recurrenceProperties.WeekDays = WeekDays.Friday;
                        break;
                    }

                    appointment.RecurrenceRule = Xamarin.Forms.DependencyService.Get <IRecurrenceBuilder>().RRuleGenerator(recurrenceProperties, appointment.StartTime, appointment.EndTime);
                }

                Meetings.Add(appointment);
            }
        }
Пример #7
0
        private async Task LoadNavigationMeetings()
        {
            var meetingsLookupServiceCall = await this._meetingService
                                            .GetAllAsync();

            Meetings.Clear();

            foreach (var meeting in meetingsLookupServiceCall)
            {
                Meetings.Add(
                    new NavigationViewItemModel(
                        meeting.Id,
                        meeting.Title,
                        this._eventAggregator,
                        nameof(MeetingDetailViewModel)));
            }
        }
        private async void GetInformation()
        {
            var httpClient = new HttpClient();
            var response   = await httpClient.GetStringAsync("https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData");

            jsonDataCollection = JsonConvert.DeserializeObject <List <JSONData> >(response);
            this.Meetings      = new ObservableCollection <Meeting>();
            foreach (var data in jsonDataCollection)
            {
                Meetings.Add(new Meeting()
                {
                    EventName = data.Subject,
                    From      = Convert.ToDateTime(data.StartTime),
                    To        = Convert.ToDateTime(data.EndTime),
                    Color     = Color.Red
                });
            }
        }
        private void LoadTestData()
        {
            House house = new House(Guid.NewGuid(), "г. Оренбург, ул. Чкалова, д. 32", "*****@*****.**", "admin");

            Person person = new Person(Guid.NewGuid(), "Данил", "Кушмухаметов", "*****@*****.**", "user", house);

            CreatePersonRequest request1 = new CreatePersonRequest(Guid.NewGuid(), "Пользователь", "1", "*****@*****.**", "user", house);
            CreatePersonRequest request2 = new CreatePersonRequest(Guid.NewGuid(), "Пользователь", "2", "*****@*****.**", "user", house);

            NewsPost newsPost1 = new NewsPost(Guid.NewGuid(), "В Оренбурге завершены поиски без вести пропавшего пенсионера",
                                              "О том, что Андрей Боженков найден, сообщили в ПСО «ОренСпас» со ссылкой на родственников.\n" +
                                              "Накануне, 12 июня, мужчина сам вернулся домой. С ним все в порядке. Жизни и здоровью пенсионера ничто не угрожает." +
                                              " В причинах его ухода из дома разбираются сотрудники полиции. Проводится проверка.",
                                              null, DateTime.UtcNow, house);
            NewsPost newsPost2 = new NewsPost(Guid.NewGuid(), "В Оренбурге завершены поиски без вести пропавшего пенсионера",
                                              "О том, что Андрей Боженков найден, сообщили в ПСО «ОренСпас» со ссылкой на родственников.\n" +
                                              "Накануне, 12 июня, мужчина сам вернулся домой. С ним все в порядке. Жизни и здоровью пенсионера ничто не угрожает." +
                                              " В причинах его ухода из дома разбираются сотрудники полиции. Проводится проверка.",
                                              null, DateTime.UtcNow, house);
            NewsPost newsPost3 = new NewsPost(Guid.NewGuid(), "В Оренбурге завершены поиски без вести пропавшего пенсионера",
                                              "О том, что Андрей Боженков найден, сообщили в ПСО «ОренСпас» со ссылкой на родственников.\n" +
                                              "Накануне, 12 июня, мужчина сам вернулся домой. С ним все в порядке. Жизни и здоровью пенсионера ничто не угрожает." +
                                              " В причинах его ухода из дома разбираются сотрудники полиции. Проводится проверка.",
                                              null, DateTime.UtcNow, house);

            Meeting meeting = new Meeting(Guid.NewGuid(), "Уборка прилегающей территории", DateTime.UtcNow.AddHours(5), "Описание мероприятия", null, house);

            Voting  voting   = new Voting(Guid.NewGuid(), "Голосование 1", house);
            Variant variant1 = new Variant(Guid.NewGuid(), "Первый вариант", voting);
            Variant variant2 = new Variant(Guid.NewGuid(), "Второй вариант", voting);
            Variant variant3 = new Variant(Guid.NewGuid(), "Третий вариант", voting);

            Houses.Add(house);
            People.Add(person);
            CreatePersonRequests.AddRange(new CreatePersonRequest[] { request1, request2 });
            News.AddRange(new NewsPost[] { newsPost1, newsPost2, newsPost3 });
            Meetings.Add(meeting);
            Votings.Add(voting);
            Variants.AddRange(new Variant[] { variant1, variant2, variant3 });

            SaveChanges();
        }
Пример #10
0
        public async Task LoadAsync()
        {
            // LOAD Friends
            var lookup = await _friendLookupService.GetFriendLookupAsync();

            Friends.Clear();        // To be sure to call this async method multiple times, clear befoere look again over recived friends
            foreach (var item in lookup)
            {
                Friends.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, nameof(FriendDetailViewModel), _eventAggregator));
            }

            // LOAD Meetings
            lookup = await _meetingLookupService.GetMeetingLookupAsync();

            Meetings.Clear();
            foreach (var item in lookup)
            {
                Meetings.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, nameof(MeetingDetailViewModel), _eventAggregator));
            }
        }
Пример #11
0
        private void CreateAppointments()
        {
            Random       randomTime           = new Random();
            List <Point> randomTimeCollection = GettingTimeRanges();
            DateTime     date;
            DateTime     DateFrom       = DateTime.Now.AddDays(-10);
            DateTime     DateTo         = DateTime.Now.AddDays(10);
            DateTime     dataRangeStart = DateTime.Now.AddDays(-3);
            DateTime     dataRangeEnd   = DateTime.Now.AddDays(3);

            for (date = DateFrom; date < DateTo; date = date.AddDays(1))
            {
                if ((DateTime.Compare(date, dataRangeStart) > 0) && (DateTime.Compare(date, dataRangeEnd) < 0))
                {
                    for (int AdditionalAppointmentIndex = 0; AdditionalAppointmentIndex < 3; AdditionalAppointmentIndex++)
                    {
                        MeetingModel meeting = new MeetingModel();
                        int          hour    = (randomTime.Next((int)randomTimeCollection[AdditionalAppointmentIndex].X, (int)randomTimeCollection[AdditionalAppointmentIndex].Y));
                        meeting.From      = new DateTime(date.Year, date.Month, date.Day, hour, 0, 0);
                        meeting.To        = (meeting.From.AddHours(1));
                        meeting.EventName = eventNameCollection[randomTime.Next(9)];
                        meeting.color     = colorCollection[randomTime.Next(6)];
                        if (AdditionalAppointmentIndex % 3 == 0)
                        {
                            meeting.AllDay = true;
                        }
                        Meetings.Add(meeting);
                    }
                }
                else
                {
                    MeetingModel meeting = new MeetingModel();
                    meeting.From = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(9, 11), 0, 0);

                    meeting.To        = (meeting.From.AddHours(1));
                    meeting.EventName = eventNameCollection[randomTime.Next(9)];
                    meeting.color     = colorCollection[randomTime.Next(6)];
                    Meetings.Add(meeting);
                }
            }
        }
        public void AddMeeting(object obj)
        {
            var meeting = new Meeting
            {
                Description      = Description,
                Agenda           = Agenda,
                MeetingStartTime = MeetingStartTime,
                MeetingEndTime   = MeetingEndTime,
                RoomId           = RoomId,
                RoomName         = RoomName,
                MeetingAttendees = _attendees,
                OrganizerLogin   = _organizerLogin
            };

            if (_meetingManager.Add(meeting))
            {
                Meetings.Add(meeting);
            }
            else
            {
                MessageBox.Show("Meeting already booked");
            }
        }
Пример #13
0
        private void AddPreBookMeetings()
        {
            var today  = DateTime.Now.Date;
            var random = new Random();

            for (int month = -1; month < 2; month++)
            {
                for (int day = -5; day < 5; day++)
                {
                    for (int hour = 9; hour < 18; hour += 5)
                    {
                        var meeting = new Meeting()
                        {
                            From      = today.AddMonths(month).AddDays(day).AddHours(hour),
                            To        = today.AddMonths(month).AddDays(day).AddHours(hour + 2),
                            EventName = currentDayMeetings[random.Next(7)],
                            color     = colorCollection[random.Next(10)]
                        };
                        Meetings.Add(meeting);
                    }
                }
            }
        }
Пример #14
0
        private void GetFreeSchedules(IEnumerable <ScheduleAction> schedulesDisponiveis)
        {
            RecurrenceProperties recurrenceProperties = new RecurrenceProperties();

            recurrenceProperties.RecurrenceType  = RecurrenceType.Weekly;
            recurrenceProperties.RecurrenceRange = RecurrenceRange.EndDate;
            recurrenceProperties.EndDate         = DateTime.Now.AddYears(1);
            recurrenceProperties.StartDate       = DateTime.Now;

            for (int i = 0; i < schedulesDisponiveis.Count(); i++)
            {
                ScheduleAppointment appointment = new ScheduleAppointment();
                appointment.Subject = "";
                appointment.Color   = schedulesDisponiveis.ElementAt(i).Cor;

                DateTime startWeek = DateTime.Now.StartOfWeek(schedulesDisponiveis.ElementAt(i).StartTime.DayOfWeek);
                DateTime endWeek   = DateTime.Now.StartOfWeek(schedulesDisponiveis.ElementAt(i).EndTime.DayOfWeek);

                appointment.StartTime = new DateTime(
                    startWeek.Year,
                    startWeek.Month,
                    startWeek.Day,
                    schedulesDisponiveis.ElementAt(i).StartTime.Hour, schedulesDisponiveis.ElementAt(i).StartTime.Minute, 0);

                appointment.EndTime = new DateTime(
                    endWeek.Year,
                    endWeek.Month,
                    endWeek.Day,
                    schedulesDisponiveis.ElementAt(i).EndTime.Hour, schedulesDisponiveis.ElementAt(i).EndTime.Minute, 0);


                switch (schedulesDisponiveis.ElementAt(i).StartTime.DayOfWeek)
                {
                case DayOfWeek.Monday:
                    recurrenceProperties.WeekDays = WeekDays.Monday;
                    break;

                case DayOfWeek.Tuesday:
                    recurrenceProperties.WeekDays = WeekDays.Tuesday;
                    break;

                case DayOfWeek.Wednesday:
                    recurrenceProperties.WeekDays = WeekDays.Wednesday;
                    break;

                case DayOfWeek.Thursday:
                    recurrenceProperties.WeekDays = WeekDays.Thursday;
                    break;

                case DayOfWeek.Friday:
                    recurrenceProperties.WeekDays = WeekDays.Friday;
                    break;
                }

                //if (Meetings.FirstOrDefault(x => x.StartTime == appointment.StartTime) != null)
                //    continue;

                appointment.RecurrenceRule = Xamarin.Forms.DependencyService.Get <IRecurrenceBuilder>().RRuleGenerator(recurrenceProperties, appointment.StartTime, appointment.EndTime);
                Meetings.Add(appointment);
            }
        }
Пример #15
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;
            }
        }
Пример #16
0
        private async Task RefreshMeetings(bool forceRefresh)
        {
            IsBusy = true;
            try
            {
                Meetings.PauseNotifications();
                var meetings = await _meetingService.GetMeetingsAsync(forceRefresh, CancellationToken.None);

                Meetings.Clear();

                var flatMeetings = new List <MeetingViewModel>();
                foreach (var meeting in meetings)
                {
                    var currentDate = meeting.StartDate;
                    while (currentDate < meeting.EndDate)
                    {
                        flatMeetings.Add(new MeetingViewModel(meeting, currentDate));
                        currentDate = currentDate.AddDays(1);
                    }
                }

                var groupedMeetings = flatMeetings.GroupBy(m => m.Date).
                                      ToDictionary(m => m.Key, m => m.ToList());

                var finalDate          = DateTime.Now.Date.AddMonths(4);
                var currentGroupedDate = DateTime.Now.Date;
                while (currentGroupedDate <= finalDate)
                {
                    if (groupedMeetings.ContainsKey(currentGroupedDate))
                    {
                        var currentGroup = groupedMeetings[currentGroupedDate];
                        Meetings.Add(new GroupedMeetingViewModel(currentGroupedDate, currentGroup.ToList()));
                    }
                    else
                    {
                        var noMeeting = new Meeting();
                        noMeeting.AllDayEvent = true;
                        noMeeting.EndDate     = currentGroupedDate;
                        noMeeting.StartDate   = currentGroupedDate;
                        // TODO : localisation
                        noMeeting.Title = "Aucun événement";
                        noMeeting.Type  = MeetingType.Unknown;

                        var noMeetings = new List <MeetingViewModel>();
                        noMeetings.Add(new MeetingViewModel(noMeeting, currentGroupedDate));

                        Meetings.Add(new GroupedMeetingViewModel(currentGroupedDate, noMeetings));
                    }

                    currentGroupedDate = currentGroupedDate.AddDays(1);
                }

                _lastUpdate = _meetingService.GetLastUpdateTime();

                RaisePropertyChanged(nameof(Meetings));
                RaisePropertyChanged(nameof(LastUpdate));
            }
            catch (System.Exception ex)
            {
                await Mvx.Resolve <IMessageService>()
                .ShowErrorToastAsync(ex, "Erreur lors de la récupération des rendez-vous.");
            }
            finally
            {
                Meetings.ResumeNotifications();
                IsBusy = false;
            }
        }