Exemple #1
0
        private async Task <List <Device> > GetRemoDevices(Models.Auth.UserBase user)
        {
            var devices = new List <Device>();

            try
            {
                var remoClient = new NatureRemoClient(user.Token);
                devices.AddRange(await remoClient.GetDevicesAsync());
            }
            catch (Exception ex)
            {
                Debugger.WriteErrorLog("Error occured while retrieving Nature Remo status. User="******". User="******".", "Error occured while retrieving Nature Remo status.").ShowAsync();
            }

            return(devices);
        }
Exemple #2
0
        private async Task <List <Models.Common.EventBase> > GetGoogleEvents(DateTime datetime, Models.Auth.UserBase user)
        {
            var events       = new List <Models.Common.EventBase>();
            var googleClient = new GoogleClient(user);

            if (AppGlobalVariables.Colors == null)
            {
                AppGlobalVariables.Colors = await googleClient.GetColors();
            }

            if (user.Calendars.Count == 0)
            {
                var calendars = await googleClient.GetCalendarList();

                var calCache = new CalendarCacheHelper();
                await calCache.Init();

                foreach (var calendar in calendars.items)
                {
                    calCache.CheckIfEnabled(calendar);
                }
                user.Calendars.AddRange(calendars.items);
            }

            if (user.Calendars.Count > 0)
            {
                foreach (var item in user.Calendars)
                {
                    if (item.IsEnabled)
                    {
                        try
                        {
                            var tmp = await googleClient.GetEventList(item, datetime);

                            if (tmp != null)
                            {
                                events.AddRange(tmp.items);
                            }
                        }
                        catch (Exception ex)
                        {
                            Debugger.WriteErrorLog("Error occured while retrieving Google Events. User="******". Calendar=" + item.Name + ".", ex);
                            await new MessageDialog(ex.Message + ". User="******". Calendar=" + item.Name + ". Please consider excluding this calendar.", "Error occured while retrieving Google Events.").ShowAsync();
                        }
                    }
                }
            }

            return(events);
        }
Exemple #3
0
        private async Task <List <Models.Common.EventBase> > GetMicrosoftEvents(DateTime datetime, Models.Auth.UserBase user)
        {
            var events   = new List <Models.Common.EventBase>();
            var msClient = new MicrosoftClient(user);

            if (user.Calendars.Count == 0)
            {
                var calendars = await msClient.GetCalendarList();

                var calCache = new CalendarCacheHelper();
                await calCache.Init();

                foreach (var calendar in calendars.value)
                {
                    calCache.CheckIfEnabled(calendar);
                }
                user.Calendars.AddRange(calendars.value);
            }

            if (user.Calendars.Count > 0)
            {
                foreach (var calendar in user.Calendars)
                {
                    if (calendar.IsEnabled)
                    {
                        try
                        {
                            var msevents = await msClient.GetEventList(calendar, datetime);

                            events.AddRange(msevents.value);
                        }
                        catch (Exception ex)
                        {
                            Debugger.WriteErrorLog("Error occured while retrieving Microsoft Events. User="******". Calendar=" + calendar.Name + ".", ex);
                            await new MessageDialog(ex.Message + ". User="******". Calendar=" + calendar.Name + ". Please consider excluding this calendar.", "Error occured while retrieving Microsoft Events.").ShowAsync();
                        }
                    }
                }
            }

            return(events);
        }