private async void StartSearchAppointments()
        {
            listLog.Items.Add("Searching  Appointments...");
            listLog.SelectedIndex = listLog.Items.Count - 1;

            AppointmentStore appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            FindAppointmentsOptions options = new FindAppointmentsOptions();

            options.FetchProperties.Add(AppointmentProperties.Subject);
            options.FetchProperties.Add(AppointmentProperties.Location);
            options.FetchProperties.Add(AppointmentProperties.Invitees);
            options.FetchProperties.Add(AppointmentProperties.Details);
            options.FetchProperties.Add(AppointmentProperties.StartTime);
            options.FetchProperties.Add(AppointmentProperties.ReplyTime);
            options.FetchProperties.Add(AppointmentProperties.Duration);
            options.FetchProperties.Add(AppointmentProperties.IsCanceledMeeting);
            options.FetchProperties.Add(AppointmentProperties.IsOrganizedByUser);
            options.FetchProperties.Add(AppointmentProperties.OnlineMeetingLink);
            options.FetchProperties.Add(AppointmentProperties.Organizer);
            options.FetchProperties.Add(AppointmentProperties.OriginalStartTime);
            options.FetchProperties.Add(AppointmentProperties.Sensitivity);


            var utcDateTime = new DateTime(DateTime.Now.Year, 01, 01, 00, 00, 0, DateTimeKind.Utc);
            IReadOnlyList <Appointment> apointments = await appointmentStore.FindAppointmentsAsync(utcDateTime, TimeSpan.FromDays(365), options);

            listLog.Items.Add("Total appointments from : " + utcDateTime + " to " + utcDateTime.AddDays(365).ToUniversalTime() + " is: " + apointments.Count.ToString());
            Save_Appointements(apointments);
        }
Example #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            navigationHelper.OnNavigatedTo(e);
            try
            {
                appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

                if (appointmentStore != null)
                {
                    status.Log(LocalizableStrings.CALENDAR_APPOINTMENTSTORE_FIND_SUCCESS);
                    ShowAllCalendars();
                    ShowAllAppointments();
                    Add.IsEnabled     = true;
                    Refresh.IsEnabled = true;
                }
                else
                {
                    status.Log(LocalizableStrings.CALENDAR_APPOINTMENTSTORE_FIND_FAIL);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("CalendarPage.OnNavigatedTo: " + ex.ToString());
                status.Log(ex.GetType().ToString());
            }
        }
Example #3
0
 private static async Task EnsureAvailabilityAsync()
 {
     if (_store == null)
     {
         _store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
     }
 }
Example #4
0
        async Task GetStoreAsync()
        {
            try
            {
                IReadOnlyList <User> users = await User.FindAllAsync();

                User ActiveUser = users[0];
                try
                {
                    AppointmentManagerForUser appointmentManager = AppointmentManager.GetForUser(ActiveUser);
                    appointmentStore = await appointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
                }
                catch (Exception ex)
                {
                    appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
                }

                if (appointmentStore == null)
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #5
0
 private static async Task SetAppointmentStore()
 {
     if (_appointmentStore == null)
     {
         _appointmentStore =
             await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);
     }
 }
Example #6
0
        public async Task <List <CalendarEvent> > GetEventsAsync()
        {
            // why this method stops here?

            AppointmentStore store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            return(new List <CalendarEvent>());
        }
Example #7
0
        private async Task CalendarCall(object sender, RoutedEventArgs e)
        {
            AppointmentStore calendar = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            options1.FetchProperties.Add(AppointmentProperties.Subject);
            options1.FetchProperties.Add(AppointmentProperties.Details);
            options1.FetchProperties.Add(AppointmentProperties.DetailsKind);

            int DaysToCheckForAppointments;

            objTextBox.Text = questionForDaysAppointments;
            await  Speak(sender, e);

            Debug.WriteLine("endiamesooooooooooooooooooooooooooo \n");
            await Task.Delay(TimeSpan.FromSeconds(3));

            await SpeakToComputer(sender, e);

            Debug.WriteLine("I said " + objTextBox.Text);
            if (!(Int32.TryParse(objTextBox.Text.Split(' ').First(), out DaysToCheckForAppointments)))
            {
                Debug.WriteLine(DaysToCheckForAppointments);
                DaysToCheckForAppointments = 1;
            }

            var iteratingAppointments = await calendar.FindAppointmentsAsync(DateTimeOffset.Now, TimeSpan.FromDays(DaysToCheckForAppointments), options1);

            if (!iteratingAppointments.Any())
            {
                objTextBox.Text = "Δεν υπάρχουν ραντεβού για τις επόμενες " + DaysToCheckForAppointments + " μέρες.";

                return;
            }
            foreach (var i in iteratingAppointments)
            {
                var eventName     = i.Subject;
                var eventDay      = i.StartTime.DayOfWeek;
                var eventPlace    = i.Location;
                var timeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("hour minute");
                var eventTime     = timeFormatter.Format(i.StartTime.DateTime);

                objTextBox.Text = "Έχεις " + eventName + " στις " + eventDay + " την " + eventPlace + " την " + eventTime;
                if (i == iteratingAppointments.ElementAt(iteratingAppointments.Count() - 1))
                {
                    return;
                }
                stream = await synth.SynthesizeTextToStreamAsync(objTextBox.Text);


                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
                await Task.Delay(TimeSpan.FromSeconds(5));
            }

            return;
        }
Example #8
0
        private async Task EnsureInitializedAsync()
        {
            if (_apptStore == null)
            {
                _apptStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly).ConfigureAwait(false);
            }

            if (_localApptStore == null)
            {
                _localApptStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite).ConfigureAwait(false);
            }
        }
Example #9
0
    private async Task <IReadOnlyList <Appointment> > ListAppointmentsAsync(DateTimeOffset start, TimeSpan range)
    {
        AppointmentStore store = await Store();

        if (store != null)
        {
            AppointmentCalendar calendar = await GetAsync();

            if (calendar != null)
            {
                return(await calendar.FindAppointmentsAsync(start, range));
            }
        }
        return(null);
    }
        private async Task CreateOrOpenCalendarAsync()
        {
            const string _calendarName = "Sample Calendar";

            AppointmentStore store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);

            var calendars = await store.FindAppointmentCalendarsAsync();

            if (!calendars.Any(i => i.DisplayName == _calendarName))
            {
                calendar = await store.CreateAppointmentCalendarAsync(_calendarName);
            }
            else
            {
                calendar = calendars.First(i => i.DisplayName == _calendarName);
            }
        }
Example #11
0
        /// <summary>
        /// Initializes the calendar. If it is the application's first run, the calendar is created.
        /// </summary>
        /// <returns></returns>
        private static async Task InitializeCalendarImpl()
        {
            if (!_initialized)
            {
                _appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
                throw new NotImplementedException();
                //if (BaseSettings.IsFirstRun)
                //{
                //    await CheckForAndCreateAppointmentCalendars();

                //    BaseSettings.IsFirstRun = false;
                //}
                //else
                //{
                //    await CheckForAndCreateAppointmentCalendars();
                //}
                //_initialized = true;
            }
        }
Example #12
0
    private async Task <AppointmentCalendar> GetAsync()
    {
        AppointmentCalendar result = null;
        AppointmentStore    store  = await Store();

        if (store != null)
        {
            IReadOnlyList <AppointmentCalendar> list = await store.FindAppointmentCalendarsAsync();

            if (list.Count == 0)
            {
                result = await store.CreateAppointmentCalendarAsync(app_title);
            }
            else
            {
                result = list.FirstOrDefault(s => s.DisplayName == app_title);
            }
        }
        return(result);
    }
        private async void init()
        {
            this.appointmentStore = await AppointmentManager.RequestStoreAsync
                                        (AppointmentStoreAccessType.AppCalendarsReadWrite);

            IReadOnlyList <AppointmentCalendar> appCalendars =
                await this.appointmentStore.FindAppointmentCalendarsAsync(FindAppointmentCalendarsOptions.IncludeHidden);

            // Apps can create multiple calendars. This example creates only one.
            if (appCalendars.Count == 0)
            {
                this.appCalendar = await appointmentStore.CreateAppointmentCalendarAsync("Example App Calendar");
            }
            else
            {
                this.appCalendar = appCalendars[0];
            }
            this.appCalendar.OtherAppReadAccess  = AppointmentCalendarOtherAppReadAccess.Full;
            this.appCalendar.OtherAppWriteAccess = AppointmentCalendarOtherAppWriteAccess.SystemOnly;
            // This app will show the details for the appointment. Use System to let the system show the details.
            this.appCalendar.SummaryCardView = AppointmentSummaryCardView.App;
        }
Example #14
0
        //Load Calendar Event
        async Task LoadCalendarEvent()
        {
            try
            {
                Debug.WriteLine("Loading current calendar event.");

                AppointmentStore AppointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

                IReadOnlyList <Appointment> Appointments = await AppointmentStore.FindAppointmentsAsync(DateTimeNow, TimeSpan.FromDays(1));

                if (Appointments.Any())
                {
                    DateTimeOffset CalendarAppoStartTime = Appointments[0].StartTime;
                    if (!String.IsNullOrEmpty(Appointments[0].Subject))
                    {
                        CalendarAppoName = Appointments[0].Subject;
                    }
                    else
                    {
                        CalendarAppoName = "Unknown event";
                    }
                    if (!String.IsNullOrEmpty(Appointments[0].Location))
                    {
                        CalendarAppoLocation = Appointments[0].Location;
                    }

                    if (Appointments[0].AllDay)
                    {
                        if (CalendarAppoStartTime.Date >= DateTimeNow.AddDays(1).Date)
                        {
                            if (!String.IsNullOrEmpty(CalendarAppoLocation))
                            {
                                CalendarAppoSummary = "(T All day) " + CalendarAppoLocation;
                            }
                            else
                            {
                                CalendarAppoSummary = "Tomorrow all the day";
                            }
                            CalendarAppoDateTime = "Tomorrow all day";
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(CalendarAppoLocation))
                            {
                                CalendarAppoSummary = "(All day) " + CalendarAppoLocation;
                            }
                            else
                            {
                                CalendarAppoSummary = "Today all the day";
                            }
                            CalendarAppoDateTime = "Today all day";
                        }
                    }
                    else
                    {
                        if (CalendarAppoStartTime.Date >= DateTimeNow.AddDays(1).Date)
                        {
                            if (!String.IsNullOrEmpty(CalendarAppoLocation))
                            {
                                if (setDisplay24hClock)
                                {
                                    CalendarAppoSummary  = "(T " + CalendarAppoStartTime.ToString("HH:mm") + ") " + CalendarAppoLocation;
                                    CalendarAppoDateTime = "(T " + CalendarAppoStartTime.ToString("HH:mm") + ")";
                                }
                                else
                                {
                                    CalendarAppoSummary  = "(T " + CalendarAppoStartTime.ToString("h:mm tt", vCultureInfoEng) + ") " + CalendarAppoLocation;
                                    CalendarAppoDateTime = "(T " + CalendarAppoStartTime.ToString("h:mm tt", vCultureInfoEng) + ")";
                                }
                            }
                            else
                            {
                                if (setDisplay24hClock)
                                {
                                    CalendarAppoSummary  = "Tomorrow at " + CalendarAppoStartTime.ToString("HH:mm");
                                    CalendarAppoDateTime = "Tomorrow at " + CalendarAppoStartTime.ToString("HH:mm");
                                }
                                else
                                {
                                    CalendarAppoSummary  = "Tomorrow at " + CalendarAppoStartTime.ToString("h:mm tt", vCultureInfoEng);
                                    CalendarAppoDateTime = "Tomorrow at " + CalendarAppoStartTime.ToString("h:mm tt", vCultureInfoEng);
                                }
                            }
                        }
                        else
                        {
                            //Check if event is active or needs to start
                            if (DateTimeNow >= CalendarAppoStartTime)
                            {
                                TimeSpan EventRemaining = CalendarAppoStartTime.Add(Appointments[0].Duration).Subtract(DateTimeNow);
                                int      RemainDays = EventRemaining.Days; int RemainHours = EventRemaining.Hours; int RemainMinutes = EventRemaining.Minutes;

                                string EventRemainingTime = "";
                                if (RemainDays != 0)
                                {
                                    EventRemainingTime = EventRemainingTime + RemainDays + "d ";
                                }
                                if (RemainHours != 0)
                                {
                                    EventRemainingTime = EventRemainingTime + RemainHours + "h ";
                                }
                                if (RemainMinutes != 0)
                                {
                                    EventRemainingTime = EventRemainingTime + RemainMinutes + "m ";
                                }
                                if (String.IsNullOrEmpty(EventRemainingTime))
                                {
                                    EventRemainingTime = "a minute ";
                                }

                                CalendarAppoEstimated = "Ends in " + EventRemainingTime;
                            }
                            else
                            {
                                //Set event start time
                                if (!String.IsNullOrEmpty(CalendarAppoLocation))
                                {
                                    if (setDisplay24hClock)
                                    {
                                        CalendarAppoSummary = "(" + CalendarAppoStartTime.ToString("HH:mm") + ") " + CalendarAppoLocation;
                                    }
                                    else
                                    {
                                        CalendarAppoSummary = "(" + CalendarAppoStartTime.ToString("h:mm tt", vCultureInfoEng) + ") " + CalendarAppoLocation;
                                    }
                                }
                                else
                                {
                                    if (setDisplay24hClock)
                                    {
                                        CalendarAppoSummary = "Today at " + CalendarAppoStartTime.ToString("HH:mm");
                                    }
                                    else
                                    {
                                        CalendarAppoSummary = "Today at " + CalendarAppoStartTime.ToString("h:mm tt", vCultureInfoEng);
                                    }
                                }

                                //Set time till start
                                TimeSpan EventStart = CalendarAppoStartTime.Subtract(DateTimeNow);
                                int      StartDays = EventStart.Days; int StartHours = EventStart.Hours; int StartMinutes = EventStart.Minutes;

                                string EventStartTime = "";
                                if (StartDays != 0)
                                {
                                    EventStartTime = EventStartTime + StartDays + "d ";
                                }
                                if (StartHours != 0)
                                {
                                    EventStartTime = EventStartTime + StartHours + "h ";
                                }
                                if (StartMinutes != 0)
                                {
                                    EventStartTime = EventStartTime + StartMinutes + "m ";
                                }
                                if (String.IsNullOrEmpty(EventStartTime))
                                {
                                    EventStartTime = "a minute ";
                                }

                                CalendarAppoEstimated = "Starts in " + EventStartTime;
                            }
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("No calendar event has been found.");
                }
            }
            catch { }
        }
 private async Task RequestStore()
 {
     _appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadWrite);
 }
Example #16
0
        public static async Task <String> GetResponse(string question)
        {
            //AIService aiService;
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(URL);

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", clientAccessToken);
            string query = question;

            urlParameters += "?v=" + v + queryString + query + language + sessionId;
            HttpResponseMessage response = client.GetAsync(urlParameters).Result;

            string responseBody = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                dynamic json = JObject.Parse(responseBody);
                answer = json.result.fulfillment.speech;

                if ((string)json["result"]["action"] == "ScheduleEvent")
                {
                    if ((string)json["result"]["parameters"]["startTime"] != null)
                    {
                        startTime = (string)json["result"]["parameters"]["startTime"];
                    }

                    if ((string)json["result"]["parameters"]["endTime"] != null)
                    {
                        endTime = (string)json["result"]["parameters"]["endTime"];
                    }

                    if ((string)json["result"]["parameters"]["title"] != null)
                    {
                        title = (string)json["result"]["parameters"]["title"];
                    }

                    if ((string)json["result"]["parameters"]["date"] != null)
                    {
                        date = (string)json["result"]["parameters"]["date"];
                    }
                }

                if ((string)json["result"]["action"] == "getCalendarEvents")
                {
                    if ((string)json["result"]["parameters"]["date"] != null)
                    {
                        date = (string)json["result"]["parameters"]["date"];
                    }
                }

                if ((bool)json["result"]["actionIncomplete"] == false && (string)json["result"]["action"] == "ScheduleEvent")
                {
                    // Create an Appointment that should be added the user' s appointments provider app.
                    var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                    string   dateTime = AiResponse.date + " " + AiResponse.startTime;
                    DateTime myDate   = DateTime.ParseExact(dateTime, "yyyy-MM-dd HH:mm:ss",
                                                            System.Globalization.CultureInfo.InvariantCulture) + TimeSpan.FromDays(1);
                    appointment.StartTime = myDate;

                    if (AiResponse.endTime != "")
                    {
                        DateTime dt = DateTime.Parse(endTime);
                        endTime = dt.ToString("HH:mm");
                        string start    = startTime.Substring(0, 2);
                        string end      = endTime.Substring(0, 2);
                        int    startT   = Convert.ToInt32(start);
                        int    endT     = Convert.ToInt32(end);
                        int    duration = endT - startT;
                        appointment.Duration = TimeSpan.FromHours(duration);
                    }
                    else
                    {
                        appointment.Duration = TimeSpan.FromHours(1);
                    }

                    appointment.Subject  = AiResponse.title;
                    appointment.Reminder = TimeSpan.FromMinutes(20);

                    String appointmentId = await AppointmentManager.ShowEditNewAppointmentAsync(appointment);

                    //if (appointmentId != String.Empty)
                    //{
                    //    appoint = "Appointment Id: " + appointmentId;
                    //}
                    //else
                    //{
                    //    appoint = "Appointment not added.";
                    //}
                }

                if ((bool)json["result"]["actionIncomplete"] == false && (string)json["result"]["action"] == "getCalendarEvents")
                {
                    AppointmentStore appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

                    //var dateToShow = DateTime.Now.AddDays(0);
                    string   dateT  = AiResponse.date;
                    DateTime myDate = DateTime.ParseExact(dateT, "yyyy-MM-dd",
                                                          System.Globalization.CultureInfo.InvariantCulture) + TimeSpan.FromDays(0);
                    var duration = TimeSpan.FromHours(24);

                    var appCalendars = await appointmentStore.FindAppointmentsAsync(myDate, duration);
                }
            }

            urlParameters = "";
            return(answer);
        }
        private async Task EnsureInitializedAsync()
        {
            if (_apptStore == null)
            {
                _apptStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly).ConfigureAwait(false);
            }

            if (_localApptStore == null)
            {
                _localApptStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite).ConfigureAwait(false);
            }
        }
Example #18
0
 public async Task SetupAsync()
 {
     appointStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadWrite).AsTask().ConfigureAwait(false);
 }
 public AppointmentStoreEvents(AppointmentStore This)
 {
     this.This = This;
 }
Example #20
0
        public static async Task <String> GetResponse(string question)
        {
            //AIService aiService;
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(URL);
            //AppointmentStore appointmentStore;
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", clientAccessToken);
            string query = question;

            urlParameters += "?v=" + v + queryString + query + language + sessionId;
            HttpResponseMessage response = client.GetAsync(urlParameters).Result;

            string responseBody = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                dynamic json = JObject.Parse(responseBody);
                answer = json.result.fulfillment.speech;
                string temp = (string)json["result"]["parameters"]["createEvent"];

                if (temp == "create" || temp == "make" || temp == "new" || temp == "put in" || temp == "add an" || temp == "put on" || temp == "I will be busy" || temp == "can I schedule" || temp == "I have an event")
                {
                    if ((bool)json["result"]["actionIncomplete"] == false && (string)json["result"]["action"] == "ScheduleEvent")
                    {
                        if ((string)json["result"]["parameters"]["startTime"] != null)
                        {
                            startTime = (string)json["result"]["parameters"]["startTime"];
                        }

                        if ((string)json["result"]["parameters"]["endTime"] != null)
                        {
                            endTime = (string)json["result"]["parameters"]["endTime"];
                        }

                        if ((string)json["result"]["parameters"]["title"] != null)
                        {
                            title = (string)json["result"]["parameters"]["title"];
                        }

                        if ((string)json["result"]["parameters"]["date"] != null)
                        {
                            date = (string)json["result"]["parameters"]["date"];
                        }
                        var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                        if (AiResponse.startTime == "in the morning" || AiResponse.startTime == "morning")
                        {
                            startTime = "08:00:00";
                        }
                        else if (AiResponse.startTime == "in the afternoon" || AiResponse.startTime == "afternoon")
                        {
                            startTime = "12:00:00";
                        }
                        else if (AiResponse.startTime == "in the evening" || AiResponse.startTime == "evening")
                        {
                            startTime = "17:00:00";
                        }
                        else if (AiResponse.startTime == "night")
                        {
                            startTime = "20:00:00";
                        }

                        string   dateTime = AiResponse.date + " " + AiResponse.startTime;
                        DateTime myDate   = DateTime.ParseExact(dateTime, "yyyy-MM-dd HH:mm:ss",
                                                                System.Globalization.CultureInfo.InvariantCulture) + TimeSpan.FromDays(1);
                        appointment.StartTime = myDate;

                        if (AiResponse.endTime != "")
                        {
                            DateTime dt = DateTime.Parse(endTime);
                            endTime = dt.ToString("HH:mm");
                            string start    = startTime.Substring(0, 2);
                            string end      = endTime.Substring(0, 2);
                            int    startT   = Convert.ToInt32(start);
                            int    endT     = Convert.ToInt32(end);
                            int    duration = endT - startT;
                            appointment.Duration = TimeSpan.FromHours(duration);
                        }
                        else
                        {
                            appointment.Duration = TimeSpan.FromHours(1);
                        }

                        appointment.Subject  = AiResponse.title;
                        appointment.Reminder = TimeSpan.FromMinutes(20);

                        String appointmentId = await AppointmentManager.ShowEditNewAppointmentAsync(appointment);
                    }
                    else if ((bool)json["result"]["actionIncomplete"] == false && (string)json["result"]["action"] == "getCalendarEvents")
                    {
                        if ((string)json["result"]["parameters"]["date"] != null)
                        {
                            date = (string)json["result"]["parameters"]["date"];
                        }

                        AppointmentStore appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

                        //var dateToShow = DateTime.Now.AddDays(0);
                        string   dateT  = AiResponse.date;
                        DateTime myDate = DateTime.ParseExact(dateT, "yyyy-MM-dd",
                                                              System.Globalization.CultureInfo.InvariantCulture) + TimeSpan.FromDays(0);
                        var duration = TimeSpan.FromHours(24);

                        //appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);
                        var appCalendars = await appointmentStore.FindAppointmentsAsync(myDate, duration);

                        //answer = appCalendars.ToString();
                        if (appCalendars.Count == 0)
                        {
                            answer = "You have no events on that date";
                        }
                        else
                        {
                            answer += "\n";
                            foreach (var item in appCalendars)
                            {
                                string dur = "";
                                dur     = item.Duration.TotalMinutes + " minutes";
                                answer += "Event Start Time: " + item.StartTime.LocalDateTime.TimeOfDay + "\nDuration: " + dur + "\n";
                            }
                        }
                    }
                }
                else
                {
                    List <string> responses = new List <string>();
                    //answer = "I am not sure if I understand the question or request";
                    string four  = "I am not sure if I understand the question or request";
                    string one   = "I am a bit confused";
                    string two   = " Not sure if I am understanding";
                    string three = "I did not understand that";
                    responses.Add(four);
                    responses.Add(one);
                    responses.Add(two);
                    responses.Add(three);

                    Random rnd   = new Random();
                    int    n     = rnd.Next(0, 4);
                    var    value = responses.ElementAt(n);
                    answer        = value;
                    urlParameters = "";
                    return(answer);
                }
            }

            urlParameters = "";
            return(answer);
        }
Example #21
0
 public static async Task GetAppointments()
 {
     appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);
 }
 private static async Task EnsureAvailabilityAsync()
 {
     if (_store == null)
         _store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
 }