Esempio n. 1
0
        public static void CheckForPreviousException(bool startingUp)
        {
            string contents = null;

            try
            {
                contents = IsolatedStorage.ReadAllText(ErrorReportFile);
                IsolatedStorage.Delete(ErrorReportFile);
            }
            catch { }
            if (contents != null)
            {
                var text = "A problem occurred" + (startingUp ? " the last time you ran this application" : "") + ". Would you like to send an email to report it?";
                if (Extensions.ShowMessageBox("Problem Report", text, "Send report", "No thanks"))
                {
                    var email = new EmailComposeTask();
                    email.To      = AppMetadata.Current.Email;
                    email.Subject = AppMetadata.Current.Name + " " + AppMetadata.Current.Version + " auto-generated problem report";
                    email.Body    = GetMailBody(contents);
                    email.Show();
                }
            }
        }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
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 { }
        }