Example #1
0
        public static void LoadData()
        {
            string RtmAuthToken = IsolatedStorageHelper.GetObject<string>("RtmAuthToken");
            int? Timeline = IsolatedStorageHelper.GetObject<int?>("RtmTimeline");
            ListsResponse = IsolatedStorageHelper.GetObject<Response>("ListsResponse");
            TasksResponse = IsolatedStorageHelper.GetObject<Response>("TasksResponse");

            if (!string.IsNullOrEmpty(RtmAuthToken))
            {
                RtmClient = new Rtm(RtmApiKey, RtmSharedKey, RtmAuthToken);
            }
            else
            {
                RtmClient = new Rtm(RtmApiKey, RtmSharedKey);
            }

            RtmClient.Client.UseHttps = true;

            if (Timeline.HasValue)
            {
                RtmClient.CurrentTimeline = Timeline.Value;
            }

            RtmClient.Resources = App.Current.Resources;
        }
Example #2
0
        public static async void LoadData()
        {
            string RtmAuthToken = IsolatedStorageHelper.GetObject<string>("RtmAuthToken");
            int? Timeline = IsolatedStorageHelper.GetObject<int?>("RtmTimeline");
            TasksResponse = IsolatedStorageHelper.GetObject<Response>("TasksResponse");
            ListsResponse = IsolatedStorageHelper.GetObject<Response>("ListsResponse");
            LocationsResponse = IsolatedStorageHelper.GetObject<Response>("LocationsResponse");
            SettingsResponse = IsolatedStorageHelper.GetObject<Response>("SettingsResponse");
            LastUpdated = IsolatedStorageHelper.GetObject<DateTime>("LastUpdated");

            if (!string.IsNullOrEmpty(RtmAuthToken))
            {
                RtmClient = new Rtm(RtmApiKey, RtmSharedKey, RtmAuthToken);
            }
            else
            {
                RtmClient = new Rtm(RtmApiKey, RtmSharedKey);
            }

            RtmClient.Client.UseHttps = true;

            if (Timeline.HasValue)
            {
                RtmClient.CurrentTimeline = Timeline.Value;
            }

            RtmClient.CacheTasksEvent += OnCacheTasks;
            RtmClient.CacheListsEvent += OnCacheLists;
            RtmClient.CacheLocationsEvent += OnCacheLocations;
            RtmClient.CacheUserSettingsEvent += OnCacheSettings;

            if (SettingsResponse != null)
            {
                RtmClient.LoadUserSettingsFromResponse(SettingsResponse);
            }
            if (LocationsResponse != null)
            {
                RtmClient.LoadLocationsFromResponse(LocationsResponse);
            }
            if (ListsResponse != null)
            {
                RtmClient.LoadListsFromResponse(ListsResponse);
            }
            if (TasksResponse != null)
            {
                RtmClient.LoadTasksFromResponse(TasksResponse);
            }

            RtmClient.Resources = App.Current.Resources;

            //await VoiceCommandService.InstallCommandSetsFromFileAsync(new Uri("ms-appx:///Commands.xml"));
        }
Example #3
0
        public static void DeleteData()
        {
            IsolatedStorageHelper.DeleteObject("RtmAuthToken");
            IsolatedStorageHelper.DeleteObject("ListsResponse");
            IsolatedStorageHelper.DeleteObject("TasksResponse");
            IsolatedStorageHelper.DeleteObject("RtmTimeline");

            RtmClient = new Rtm(RtmApiKey, RtmSharedKey);
            ListsResponse = null;
            TasksResponse = null;

            RtmClient.Resources = App.Current.Resources;
        }
Example #4
0
        public void LoadTasksFromResponse(Response response)
        {
            foreach (var list in response.Tasks)
            {
                TaskList taskList = TaskLists.GetById(list.Id);
                if (taskList != null)
                    taskList.InternalSync(list);
            }

            // reload every smart list
            foreach (var list in TaskLists)
            {
                if (list.IsSmart) list.SyncTasks(() => { });
            }
        }
Example #5
0
        public void LoadLocationsFromResponse(Response response)
        {
            LocationCollection temp = new LocationCollection(this);

            if (response.Locations != null)
            {
                foreach (var location in response.Locations)
                {
                    Location newLocation = new Location(location);
                    temp.Add(newLocation);
                }
            }

            System.Threading.Interlocked.Exchange(ref mLocations, temp);
        }
Example #6
0
        public void LoadListsFromResponse(Response response)
        {
            TaskListCollection temp = new TaskListCollection(this);

            if (response.Lists != null)
            {
                using (new UnsyncedScope(temp))
                {
                    foreach (var list in response.Lists)
                    {
                        if (list.Archived == 0 && list.Deleted == 0)
                        {
                            TaskList newList = new TaskList(list);
                            temp.Add(newList);
                        }
                    }

                    temp.Sort();
                }
            }

            System.Threading.Interlocked.Exchange(ref mTaskLists, temp);
        }
Example #7
0
 public static void OnCacheSettings(Response response)
 {
     SettingsResponse = response;
     LastUpdated = DateTime.Now;
 }
Example #8
0
 public static void OnCacheLocations(Response response)
 {
     LocationsResponse = response;
     LastUpdated = DateTime.Now;
 }
Example #9
0
 public static void OnCacheTasks(Response response)
 {
     TasksResponse = response;
     LastUpdated = DateTime.Now;
 }
Example #10
0
        public static void DeleteData()
        {
            IsolatedStorageHelper.DeleteObject("RtmAuthToken");
            IsolatedStorageHelper.DeleteObject("RtmTimeline");
            IsolatedStorageHelper.DeleteObject("TasksResponse");
            IsolatedStorageHelper.DeleteObject("ListsResponse");
            IsolatedStorageHelper.DeleteObject("LocationsResponse");
            IsolatedStorageHelper.DeleteObject("SettingsResponse");
            IsolatedStorageHelper.DeleteObject("LastUpdated");

            RtmClient = new Rtm(RtmApiKey, RtmSharedKey);
            TasksResponse = null;
            ListsResponse = null;
            LocationsResponse = null;
            SettingsResponse = null;

            RtmClient.Resources = App.Current.Resources;

            //NotificationsManager.ResetLiveTiles();

            //if (ScheduledActionService.Find("BackgroundTask") != null)
            //    ScheduledActionService.Remove("BackgroundTask");

            //ShellTile primaryTile = ShellTile.ActiveTiles.First();
            //if (primaryTile != null)
            //{
            //    StandardTileData data = new StandardTileData();
            //    primaryTile.Update(data);
            //}
        }
Example #11
0
 public void LoadUserSettingsFromResponse(Response response)
 {
     if (response.Settings != null)
     {
         UserSettings temp = new IronCow.UserSettings(response.Settings);
         System.Threading.Interlocked.Exchange(ref mUserSettings, temp);
     }
 }