Пример #1
0
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            EventsResult res      = e.State as EventsResult;
            double       hours    = double.Parse(res.duration);
            DateTime     original = DateTime.Parse(res.event_date);

            original = original.AddSeconds(-original.Second);
            string desc = System.Text.RegularExpressions.Regex.Replace(res.description, "(?<!\r)\n", "\r\n");

            if (e.Results.Count() != 0)
            {
                foreach (Appointment appointment in e.Results)
                {
                    if (appointment.StartTime == original &&
                        appointment.EndTime == original.Add(TimeSpan.FromHours(hours)) &&
                        appointment.Subject == res.name &&
                        appointment.Location == res.address &&
                        appointment.Details.Length == desc.Length)
                    {
                        res.isInCalendar = true;
                    }
                }
            }
            if (!res.isInCalendar)
            {
                data.CalendarData.result.Remove(res);
                EmsApi.SaveToPhone(JsonConvert.SerializeObject(data.CalendarData), EventsData.calendarDataKey);
            }
        }
Пример #2
0
        private void reorginizeDates(EventsResult res)
        {
            CultureInfo culture = new CultureInfo("en-US");
            double      hours   = double.Parse(res.duration, culture);

            Duration.Content = EmsApi.GetTimeSpan(DateTime.Now.AddHours(-hours), true);

            CreatedAt.Content = DateTime.Parse(res.created_at).ToLongDateString();

            Date.Content = DateTime.Parse(res.event_date).ToLongDateString();
        }
Пример #3
0
        private void checkEvent(EventsResult res)
        {
            Appointments appts = new Appointments();

            //Identify the method that runs after the asynchronous search completes.
            appts.SearchCompleted += appts_SearchCompleted;

            DateTime start = DateTime.Parse(res.event_date);
            DateTime end   = DateTime.Parse(res.event_date).Add(TimeSpan.FromHours(double.Parse(res.duration)));
            int      max   = 20;

            //Start the asynchronous search.
            appts.SearchAsync(start, end, max, res);
        }
Пример #4
0
        private void CalendarsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LongListSelector lls = sender as LongListSelector;

            if (lls == null || lls.SelectedItem == null)
            {
                return;
            }

            EventsResult item = lls.SelectedItem as EventsResult;

            NavigationService.Navigate(new Uri("/EventDetails.xaml?id=" + item.id + "&isCalendar=true", UriKind.RelativeOrAbsolute));

            lls.SelectedItem = null;
        }
Пример #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            EventsResult res = DataContext as EventsResult;

            Appointments appts = new Appointments();

            //Identify the method that runs after the asynchronous search completes.
            appts.SearchCompleted += appts_SearchCompleted;

            DateTime start = DateTime.Parse(res.event_date);
            DateTime end   = DateTime.Parse(res.event_date).Add(TimeSpan.FromHours(double.Parse(res.duration)));
            int      max   = 20;

            //Start the asynchronous search.
            appts.SearchAsync(start, end, max, res);
        }
Пример #6
0
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            EventsResult res      = e.State as EventsResult;
            double       hours    = double.Parse(res.duration);
            DateTime     original = DateTime.Parse(res.event_date);

            original = original.AddSeconds(-original.Second);
            string desc = System.Text.RegularExpressions.Regex.Replace(res.description, "(?<!\r)\n", "\r\n");

            if (e.Results.Count() != 0)
            {
                foreach (Appointment appointment in e.Results)
                {
                    if (appointment.StartTime == original &&
                        appointment.EndTime == original.Add(TimeSpan.FromHours(hours)) &&
                        appointment.Subject == res.name &&
                        appointment.Location == res.address &&
                        appointment.Details.Length == desc.Length)
                    {
                        MessageBox.Show(AppResources.AlreadyInTheCalendar, AppResources.InfoTitle, MessageBoxButton.OK);
                        return;
                    }
                }

                if (MessageBox.Show(AppResources.CalendarPrompt, AppResources.CalenderPromptTitle, MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();

            saveAppointmentTask.StartTime         = original;
            saveAppointmentTask.EndTime           = original.Add(TimeSpan.FromHours(hours));
            saveAppointmentTask.Subject           = res.name;
            saveAppointmentTask.Location          = res.address;
            saveAppointmentTask.Details           = res.description;
            saveAppointmentTask.IsAllDayEvent     = false;
            saveAppointmentTask.Reminder          = Reminder.EighteenHours;
            saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;

            saveAppointmentTask.Show();

            MainPage.data.CalendarData.result.Add(res);
            EmsApi.SaveToPhone(Newtonsoft.Json.JsonConvert.SerializeObject(MainPage.data.CalendarData), EventsData.calendarDataKey);
        }
Пример #7
0
        void EventDetails_Loaded(object sender, RoutedEventArgs e)
        {
            if (_isSearch)
            {
                DataContext = (EventsResult)Search.SearchData.result.Where <EventsResult>(item => item.id == _eventId).First <EventsResult>();
            }
            else if (_isCalendar)
            {
                DataContext = (EventsResult)MainPage.data.CalendarData.result.Where <EventsResult>(item => item.id == _eventId).First <EventsResult>();
            }
            else
            {
                DataContext = (EventsResult)MainPage.data.EventsData.result.Where <EventsResult>(item => item.id == _eventId).First <EventsResult>();
            }

            EventsResult res = DataContext as EventsResult;

            reorginizeDates(res);
        }
Пример #8
0
        private void checkEvent(EventsResult res)
        {
            Appointments appts = new Appointments();

            //Identify the method that runs after the asynchronous search completes.
            appts.SearchCompleted += appts_SearchCompleted;

            DateTime start = DateTime.Parse(res.event_date);
            DateTime end = DateTime.Parse(res.event_date).Add(TimeSpan.FromHours(double.Parse(res.duration)));
            int max = 20;

            //Start the asynchronous search.
            appts.SearchAsync(start, end, max, res);
        }
Пример #9
0
        private void reorginizeDates(EventsResult res)
        {
            CultureInfo culture = new CultureInfo("en-US");
            double hours = double.Parse(res.duration, culture);

            Duration.Content = EmsApi.GetTimeSpan(DateTime.Now.AddHours(-hours), true);

            CreatedAt.Content = DateTime.Parse(res.created_at).ToLongDateString();

            Date.Content = DateTime.Parse(res.event_date).ToLongDateString();
        }