Exemplo n.º 1
0
        public static void CheckForReview(Page page)
        {
            var installationDate = Settings.GetDateTime(Setting.InstallationDate);

            if (!installationDate.HasValue)
            {
                Settings.Set(Setting.InstallationDate, DateTime.UtcNow);
            }
            else if (!Settings.GetBool(Setting.RatingDone))
            {
                bool shouldAskForReview;
                var  daysSinceInstallation = (DateTime.UtcNow - installationDate.Value).TotalDays;
                var  lastAskForReviewDate  = Settings.GetDateTime(Setting.LastAskForReviewDate);
                // ask on day 2^n + 1, for n >= 0 (2, 3, 5, 9, 17, 33, etc...)
                if (!lastAskForReviewDate.HasValue)
                {
                    shouldAskForReview = daysSinceInstallation >= 1;
                }
                else
                {
                    var daysSinceLastAskForReview = (DateTime.UtcNow - lastAskForReviewDate.Value).TotalDays;
                    shouldAskForReview = daysSinceLastAskForReview * 2 >= daysSinceInstallation;
                }
                if (shouldAskForReview)
                {
                    Settings.Set(Setting.LastAskForReviewDate, DateTime.UtcNow);
                    if (Extensions.ShowMessageBox("Enjoying " + AppMetadata.Current.Name + "?", "If you find this app useful please rate it. Reviews encourage me to keep improving.",
                                                  "Rate and Review", "Maybe later"))
                    {
                        ErrorReporting.Log("MarketplaceReviewTaskShow from Prompt");
                        new MarketplaceReviewTask().Show();
                        Settings.Set(Setting.RatingDone, true);
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void OnRateAndReviewClick(object sender, EventArgs e)
 {
     ErrorReporting.Log("OnRateAndReviewClick");
     new MarketplaceReviewTask().Show();
     Settings.Set(Setting.RatingDone, true);
 }
Exemplo n.º 3
0
 private void Application_RunningInBackground(object sender, RunningInBackgroundEventArgs args)
 {
     ErrorReporting.Log("RunningInBackground");
     AppMetadata.Current.RunningInBackground = true;
 }
Exemplo n.º 4
0
 private void Application_Closing(object sender, ClosingEventArgs e)
 {
     ErrorReporting.Log("Closing");
 }
Exemplo n.º 5
0
 private void Application_Deactivated(object sender, DeactivatedEventArgs e)
 {
     ErrorReporting.Log("Deactivated Reason=" + e.Reason);
 }
Exemplo n.º 6
0
 private void Application_Activated(object sender, ActivatedEventArgs e)
 {
     ErrorReporting.Log("Activated IsApplicationInstancePreserved=" + e.IsApplicationInstancePreserved);
     AppMetadata.Current.RunningInBackground = false;
 }
Exemplo n.º 7
0
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     ErrorReporting.Log("Launching");
 }
Exemplo n.º 8
0
        public static void CheckForNewVersion()
        {
#if DEBUG
            return;
#endif
            var lastNewVersionCheck = Settings.GetDateTime(Setting.LastNewVersionCheck);
            if (!lastNewVersionCheck.HasValue)
            {
                Settings.Set(Setting.LastNewVersionCheck, DateTime.UtcNow);
                return;
            }
            if ((DateTime.UtcNow - lastNewVersionCheck.Value).TotalDays < 7)
            {
                //only check once a week
                return;
            }
            try
            {
                var cultureInfoName = CultureInfo.CurrentUICulture.Name;

                var url = string.Format("http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/{0}?os={1}&cc={2}&oc=&lang={3}​",
                                        AppMetadata.Current.AppId.ToString("D"),
                                        Environment.OSVersion.Version,
                                        cultureInfoName.Substring(cultureInfoName.Length - 2).ToUpperInvariant(),
                                        cultureInfoName);

                var request = WebRequest.Create(url);
                request.BeginGetResponse(result =>
                {
                    try
                    {
                        var response = (HttpWebResponse)request.EndGetResponse(result);
                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            using (var outputStream = response.GetResponseStream())
                            {
                                using (var reader = XmlReader.Create(outputStream))
                                {
                                    reader.MoveToContent();

                                    var aNamespace = reader.LookupNamespace("a");

                                    reader.ReadToFollowing("entry", aNamespace);

                                    reader.ReadToDescendant("version");

                                    var updatedVersion = new Version(reader.ReadElementContentAsString());
                                    var currentVersion = new Version(AppMetadata.Current.Version);

                                    Settings.Set(Setting.LastNewVersionCheck, DateTime.UtcNow);

                                    if (updatedVersion > currentVersion)
                                    {
                                        AppMetadata.RootFrame.Dispatcher.BeginInvoke(() =>
                                        {
                                            if (Extensions.ShowMessageBox("Update Available", "A new version of " + AppMetadata.Current.Name + " is available. Do you want to install it now?", "Install Update", "Maybe later"))
                                            {
                                                ErrorReporting.Log("MarketplaceDetailTaskShow from Prompt");
                                                new MarketplaceDetailTask().Show();
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    }
                    catch { }
                },
                                         null);
            }
            catch { }
        }
Exemplo n.º 9
0
 private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     ErrorReporting.ReportException(e.Exception, "NavigationFailed: " + e.Uri);
 }