コード例 #1
0
        private Task <bool> ShowNotificationToSend(IsolatedStorageFile store, string[] filenames)
        {
            var tcs = new TaskCompletionSource <bool>();

            Scheduler.Dispatcher.Schedule(() =>
            {
                NotificationTool.Show(
                    LocalizedStrings.LocalizedResources.CrashData,
                    LocalizedStrings.LocalizedResources.SendCrashQuestion,
                    new NotificationAction(LocalizedStrings.LocalizedResources.Send, (Action)(async() =>
                {
                    tcs.TrySetResult(true);
                    await SendCrashesAsync(store, filenames);
                })),
                    new NotificationAction(LocalizedStrings.LocalizedResources.Delete, (Action)(() =>
                {
                    tcs.TrySetResult(false);
                    foreach (string filename in filenames)
                    {
                        try
                        {
                            store.DeleteFile(Path.Combine(Constants.CrashDirectoryName, filename));
                        }
                        catch (Exception e)
                        {
                            HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e);
                        }
                    }
                }))
                    );
            });
            return(tcs.Task);
        }
コード例 #2
0
        public void HandleCrashes()
        {
            try
            {
                IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
                if (store.DirectoryExists(CrashDirectoryName))
                {
                    string[] filenames = store.GetFileNames(CrashDirectoryName + "\\crash*.log");
                    Debugger.Log(0, "HockeyApp", filenames.ToString());

                    if (filenames.Length > 0)
                    {
                        Scheduler.Dispatcher.Schedule(() =>
                        {
                            NotificationTool.Show(
                                "Crash Data",
                                "The app quit unexpectedly. Would you like to send information about this to the developer?",
                                new NotificationAction("Send", () =>
                            {
                                SendCrashes(store, filenames);
                            }),
                                new NotificationAction("Delete", () =>
                            {
                                DeleteCrashes(store, filenames);
                            })
                                );
                        });
                    }
                }
            }
            catch (Exception)
            {
                // Ignore all exceptions
            }
        }
コード例 #3
0
ファイル: LoginViewModel.cs プロジェクト: phamy/WP7-Official
        /// <summary>
        /// Starts intialization of view model.
        /// </summary>
        private void InitializeViewModeExecute()
        {
            if (!this.wasInitialization)
            {
                this.wasInitialization = true;
                using (var settingsRepository = new SettingsRepository())
                {
                    if (!IsolatedStorageSettings.ApplicationSettings.Contains(_firstLaunchKey))
                    {
                        IsolatedStorageSettings.ApplicationSettings[_firstLaunchKey] = wasInitialization;
                        var result          = MessageBox.Show("Would you like this application to use your phone's GPS function?", "GPS", MessageBoxButton.OKCancel);
                        var currentSettings = settingsRepository.GetCurrentSettings();
                        currentSettings.IsGpsEnabled = result == MessageBoxResult.OK;
                        settingsRepository.UpdateCurrentSettings(currentSettings);
                    }

                    bool userAcceptedEula = false;
                    var  store            = IsolatedStorageSettings.ApplicationSettings;
                    if (store.Contains(EULA_KEY))
                    {
                        userAcceptedEula = (bool)store[EULA_KEY];
                    }

                    if (!userAcceptedEula)
                    {
                        NotificationTool.Show(
                            "Privacy Policy",
                            "NDG",
                            new NotificationAction("Accept", () => { AcceptedPrivacy(); }),
                            new NotificationAction("Decline", () => { DeclinedPrivacy(); }));
                    }

                    GpsTracker.Instance.GpsAllowed = settingsRepository.GetCurrentSettings().IsGpsEnabled;
                    GpsTracker.Instance.StartTracking();
                }
            }

            if (Membership.CurrentUser == null)
            {
                this.Login    = string.Empty;
                this.Password = string.Empty;
                using (var settingsRepository = new SettingsRepository())
                    this.ServerPath = settingsRepository.GetCurrentSettings().Server.Address;
            }

            var pageParameters = NavigationProvider.GetNavigationParameters();

            if (pageParameters.ContainsKey(SEVER_PATH_PARAMETER))
            {
                this.ServerPath = pageParameters[SEVER_PATH_PARAMETER];
            }
        }
コード例 #4
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var    def      = taskInstance.GetDeferral();
            string _access  = AppTool.GetLocalSetting(Settings.AccessToken, "");
            string _refresh = AppTool.GetLocalSetting(Settings.RefreshToken, "");
            int    _expiry  = Convert.ToInt32(AppTool.GetLocalSetting(Settings.TokenExpiry, "0"));

            if (!string.IsNullOrEmpty(_access))
            {
                var    _client    = new BiliBiliClient(_access, _refresh, _expiry);
                string lastId     = AppTool.GetLocalSetting(Settings.LastSeemDynamicId, "0");
                var    newDynamic = await _client.Topic.GetNewDynamicAsync(lastId.ToString());

                if (newDynamic.update_num > 0)
                {
                    var toastItems = new List <NotificationModel>();
                    var lastItem   = newDynamic.cards.Where(p => p.desc.dynamic_id_str == lastId.ToString()).FirstOrDefault();
                    int lastStamp  = 0;
                    if (lastItem != null)
                    {
                        lastStamp = lastItem.desc.timestamp;
                    }
                    foreach (var item in newDynamic.cards)
                    {
                        if (item.desc.timestamp > lastStamp && (item.desc.type == 8 || item.desc.type == 512))
                        {
                            if (item.desc.type == 8)
                            {
                                var video = JsonConvert.DeserializeObject <VideoDynamic>(item.card);
                                toastItems.Add(new NotificationModel(video.title, video.desc, video.pic, $"action=video&aid={video.aid}", video.owner.face));
                            }
                            else
                            {
                                var anime = JsonConvert.DeserializeObject <AnimeDynamic>(item.card);
                                toastItems.Add(new NotificationModel(anime.show_title, anime.season.type_name, anime.cover, $"action=bangumi&epid={anime.episode_id}"));
                            }
                        }
                    }
                    if (toastItems.Count > 0)
                    {
                        NotificationTool.SendDynamicToast(toastItems);
                    }
                }
            }
            def.Complete();
        }
コード例 #5
0
 protected void ShowUpdateNotification(Version currentVersion, IEnumerable <IAppVersion> appVersions, UpdateCheckSettings updateCheckSettings)
 {
     Scheduler.Dispatcher.Schedule(() =>
     {
         NotificationTool.Show(
             LocalizedStrings.LocalizedResources.UpdateNotification,
             LocalizedStrings.LocalizedResources.UpdateAvailable,
             new NotificationAction(LocalizedStrings.LocalizedResources.Show, (Action)(() =>
         {
             ShowVersionPopup(currentVersion, appVersions, updateCheckSettings);
         })),
             new NotificationAction(LocalizedStrings.LocalizedResources.Dismiss, (Action)(() =>
         {
             //DO nothing
         }))
             );
     });
 }
コード例 #6
0
        private Task <bool> ShowNotificationToSend(IsolatedStorageFile store, string[] filenames)
        {
            var tcs = new TaskCompletionSource <bool>();

            Scheduler.Dispatcher.Schedule(() =>
            {
                NotificationTool.Show(
                    SdkResources.CrashData,
                    SdkResources.SendCrashQuestion,
                    new NotificationAction(SdkResources.Send, () =>
                {
                    tcs.TrySetResult(true);
                    SendCrashes(store, filenames);
                }),
                    new NotificationAction(SdkResources.Delete, () =>
                {
                    tcs.TrySetResult(false);
                    DeleteCrashes(store, filenames);
                })
                    );
            });
            return(tcs.Task);
        }