protected void KickOffRun() { // request came from this machine - make a request to ourselves and send it out in email EmailSubscriptionManager em = new EmailSubscriptionManager() { ActiveBrand = Branding.CurrentBrand }; if (util.GetIntParam(Request, "dbg", 0) != 0) { em.UserRestriction = Page.User.Identity.Name; } string szTasksToRun = util.GetStringParam(Request, "tasks"); if (!String.IsNullOrEmpty(szTasksToRun)) { em.TasksToRun = Int32.TryParse(szTasksToRun, out int tasks) ? (EmailSubscriptionManager.SelectedTasks)tasks : EmailSubscriptionManager.SelectedTasks.All; } new Thread(new ThreadStart(em.NightlyRun)).Start(); lblSuccess.Visible = true; }
protected void SetUpCurrencyAndTotalsForUser(string szAuthKey, string szParam) { try { ValidateAuthorization(szAuthKey); Profile pf = MyFlightbook.Profile.GetUser(Username); // Set up the correct decimal formatting for the user if (pf.PreferenceExists(MFBConstants.keyDecimalSettings)) { Session[MFBConstants.keyDecimalSettings] = pf.GetPreferenceForKey <DecimalFormat>(MFBConstants.keyDecimalSettings); } EmailSubscriptionManager em = new EmailSubscriptionManager(pf.Subscriptions); IEnumerable <CurrencyStatusItem> rgExpiringCurrencies = null; IEnumerable <CurrencyStatusItem> rgPrecomputedCurrencies = null; if (pf.AssociatedData.TryGetValue(CurrencyStatusItem.AssociatedDateKeyExpiringCurrencies, out object o)) { rgExpiringCurrencies = (IEnumerable <CurrencyStatusItem>)o; } if (pf.AssociatedData.TryGetValue(CurrencyStatusItem.AssociatedDataKeyCachedCurrencies, out object o2)) { rgPrecomputedCurrencies = (IEnumerable <CurrencyStatusItem>)o2; } pf.AssociatedData.Remove(CurrencyStatusItem.AssociatedDateKeyExpiringCurrencies); pf.AssociatedData.Remove(CurrencyStatusItem.AssociatedDataKeyCachedCurrencies); bool fHasCurrency = em.HasSubscription(SubscriptionType.Currency) || (em.HasSubscription(SubscriptionType.Expiration) && rgExpiringCurrencies != null && rgPrecomputedCurrencies != null); bool fHasTotals = em.HasSubscription(SubscriptionType.Totals); bool fHasMonthly = em.HasSubscription(SubscriptionType.MonthlyTotals); bool fMonthlySummary = (String.Compare(szParam, "monthly", StringComparison.OrdinalIgnoreCase) == 0); if (!fHasCurrency && !fHasTotals && !fMonthlySummary) { throw new MyFlightbookException("Email requested but no subscriptions found! User ="******"Monthly email requested but user does not subscribe to monthly email. User = "******"http://{0}{1}", Branding.CurrentBrand.HostName, VirtualPathUtility.ToAbsolute("~/Member/EditProfile.aspx/pftDonate")); mvDonations.SetActiveView(Payment.TotalPaidSinceDate(DateTime.Now.AddYears(-1), Username) > 0 ? vwThankyou : vwPleaseGive); // Fix up the unsubscribe link. lnkUnsubscribe.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "http://{0}{1}/{2}", Branding.CurrentBrand.HostName, VirtualPathUtility.ToAbsolute("~/Member/EditProfile.aspx"), tabID.pftPrefs.ToString()); lnkQuickUnsubscribe.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "http://{0}{1}?u={2}", Branding.CurrentBrand.HostName, VirtualPathUtility.ToAbsolute("~/Public/Unsubscribe.aspx"), HttpUtility.UrlEncode(new UserAccessEncryptor().Encrypt(Username))); bool fAnnual = (DateTime.Now.Month == 1 && DateTime.Now.Day == 1); // if it's January 1, show prior year; else show YTD mfbTotalsByTimePeriod.BindTotalsForUser(Username, !fMonthlySummary, !fMonthlySummary, true, true, !fAnnual, !fAnnual); if (fAnnual) { mfbRecentAchievements.Refresh(Username, new DateTime(DateTime.Now.Year - 1, 1, 1), new DateTime(DateTime.Now.Year - 1, 12, 31), true); } else { mfbRecentAchievements.Refresh(Username, new DateTime(DateTime.Now.Year, 1, 1), DateTime.Now, true); } lblRecentAchievementsTitle.Text = mfbRecentAchievements.Summary; lblRecentAchievementsTitle.Visible = mfbRecentAchievements.AchievementCount > 0; lblCurrency.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EmailCurrencyHeader, DateTime.Now.ToLongDateString()); pnlTotals.Visible = fHasTotals || fMonthlySummary; lblTotal.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EmailTotalsHeader, DateTime.Now.ToLongDateString()); lblIntroHeader.Text = String.Format(CultureInfo.CurrentCulture, fMonthlySummary ? Resources.Profile.EmailMonthlyMailIntro : Resources.Profile.EmailWeeklyMailIntro, Branding.CurrentBrand.AppName); if (fHasCurrency || fMonthlySummary) { mfbCurrency.UserName = pf.UserName; mfbCurrency.RefreshCurrencyTable(rgPrecomputedCurrencies); pnlCurrency.Visible = true; if (rgExpiringCurrencies != null && rgExpiringCurrencies.Any()) { pnlExpiringCurrencies.Visible = true; rptExpiring.DataSource = rgExpiringCurrencies; rptExpiring.DataBind(); } } } catch (Exception ex) when(ex is MyFlightbookException || ex is FormatException) { MyFlightbookException.NotifyAdminException(ex); throw; // ensure that the success tag doesn't show! } }