示例#1
0
文件: App.xaml.cs 项目: dmsl/rayzit
        private static async Task <bool> RegisterUser()
        {
            if (!Settings.LocationToggleSwitchSetting)
            {
                return(false);
            }

            if (await LocFinder.GeolocationAvailableAsync(true))
            {
                await Rsc.UpdatePosition(LocFinder.Info.Latitude, LocFinder.Info.Longitude, LocFinder.Info.Accuracy);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override async void OnInvoke(ScheduledTask task)
        {
            // Nothing to be done without Internet Connectivity
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                NotifyComplete();
                return;
            }

            var appSettings = IsolatedStorageSettings.ApplicationSettings;

            var enabled = appSettings.Contains("LocationToggleSwitchSetting") && (bool)appSettings["LocationToggleSwitchSetting"];

            if (!enabled)
            {
                NotifyComplete();
                return;
            }

            var rsc = new Rsc("<API ID>", MDeviceUniqueId);

            Geolocation = await new LocationFinderBG().GetLocation();

            // Problem occured with Geolocation
            if (Geolocation == null)
            {
                NotifyComplete();
                return;
            }

            // Update User's Position
            await rsc.UpdatePosition(Geolocation.Latitude, Geolocation.Longitude, Geolocation.Accuracy);

            // Request User's LiveFeed with one random (latest) rayz
            var reply = await rsc.GetLiveFeedRandom();

            await ParseLiveFeed(reply);

            //ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));

            NotifyComplete();
        }