예제 #1
0
        private static void AddFAA2ndClassItems(List <CurrencyStatusItem> lst, DateTime lastMedical, bool fWas40AtExam)
        {
            CurrencyStatusItem cs = StatusForDate(lastMedical.AddCalendarMonths(12), Resources.Currency.NextMedical2ndClass, CurrencyStatusItem.CurrencyGroups.Medical);

            lst.Add(cs);
            if (cs.Status == CurrencyState.NotCurrent)
            {
                lst.Add(StatusForDate(lastMedical.AddCalendarMonths(fWas40AtExam ? 24 : 60), Resources.Currency.NextMedical3rdClassPrivs, CurrencyStatusItem.CurrencyGroups.Medical));
            }
        }
예제 #2
0
 private void DoOnCurrencyStatusChange(CurrencyStatusItem aCurrencyStatusItem)
 {
     try
     {
         this.SynchronizingObject?.Invoke(OnCurrencyStatusChange, new object[] { this, aCurrencyStatusItem });
     }
     catch (Exception e)
     {
         DoErrorHandler(e);
     }
 }
    public void RefreshCurrencyTable()
    {
        gvCurrency.DataSource = CurrencyStatusItem.GetCurrencyItemsForUser(String.IsNullOrEmpty(UserName) ? Page.User.Identity.Name : UserName);
        gvCurrency.DataBind();

        // HACK - We do this here because Page_Load may not be called if this is for an RSS feed.
        if (lnkDisclaimer.NavigateUrl.Contains("~"))
        {
            lnkDisclaimer.NavigateUrl = "http://" + MyFlightbook.Branding.CurrentBrand.HostName + VirtualPathUtility.ToAbsolute(lnkDisclaimer.NavigateUrl);
        }
    }
예제 #4
0
        private static void AddFAA1stClassItems(List <CurrencyStatusItem> lst, DateTime lastMedical, bool fWas40AtExam)
        {
            CurrencyStatusItem cs = StatusForDate(lastMedical.AddCalendarMonths(fWas40AtExam ? 6 : 12), Resources.Currency.NextMedical1stClass, CurrencyStatusItem.CurrencyGroups.Medical);

            lst.Add(cs);
            if (cs.Status == CurrencyState.NotCurrent)
            {
                if (fWas40AtExam)   // may still have some non-ATP commercial time left
                {
                    lst.Add(StatusForDate(lastMedical.AddCalendarMonths(12), Resources.Currency.NextMedical1stClassCommercial, CurrencyStatusItem.CurrencyGroups.Medical));
                }
                lst.Add(StatusForDate(lastMedical.AddCalendarMonths(fWas40AtExam ? 24 : 60), Resources.Currency.NextMedical3rdClassPrivs, CurrencyStatusItem.CurrencyGroups.Medical));
            }
        }
예제 #5
0
        /// <summary>
        /// If any currencies exist call this method to inform the object
        /// what currencies are not considered new while running.
        ///
        /// This call will cause this object to fire the OnUpdateCurrency,
        /// OnCurrencyStatusChange and OnNewCurrency
        /// </summary>
        /// <param name="aCurrencyItem">Id of the existing currency</param>
        /// <param name="aLastCurrencyStatusItem">Id of the last known status Item recived</param>
        public void AddExistingCurrency(CurrencyItem aCurrencyItem, CurrencyStatusItem aLastCurrencyStatusItem, long aCurrentBlockHeight)
        {
            CheckIfNotifierIsExecuting();
            var lId           = (uint)aCurrencyItem.Id;
            var lCurrencyInfo = new CurrencyInfo()
            {
                CurrencyItem           = aCurrencyItem,
                LastCurrencyStatusItem = aLastCurrencyStatusItem,
                BlockHeight            = aCurrentBlockHeight
            };

            FCurrencyInventory.Add(lId, lCurrencyInfo);
            FTransactionTrackers.Add(lId, new TransactionTracker(lCurrencyInfo));
            if (lId > LastNotifiedCurrencyId)
            {
                LastNotifiedCurrencyId = lId;
            }
        }
예제 #6
0
        public void PandoraServerTest()
        {
            TestServer = new PandorasServer(Path.Combine(Directory.GetCurrentDirectory(), "DBTEST"), "localhost", 20159);

            Assert.IsTrue(TestServer.Logon("*****@*****.**", "quality", "quality"));

            TestServer.OnTransactions += NewTransactionTestHandler;

            var TestUserStatus = (TestServer.GetUserStatus());

            Assert.IsTrue(TestUserStatus.Active && TestUserStatus.ExtendedInfo == "Quality Testing User");

            CurrencyItem[] Currencies = TestServer.GetCurrencyList();

            Assert.IsTrue(Currencies.Count() > 0 && Currencies[0].Name == "Bitcoin");

            CurrencyStatusItem Result2 = TestServer.GetCurrencyStatus(1);

            Assert.IsTrue(Result2.Status == CurrencyStatus.Active && Result2.ExtendedInfo == "The coin is working fine with 3 servers running with consensus.");

            CurrencyAccount[] Accounts = TestServer.MonitoredAccounts.GetById(1);

            Assert.AreEqual(Accounts[0].Address, "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5");

            TestServer.StartTxUpdatingTask();

            while (!Records.Any())
            {
                Records = TestServer.GetTransactions(1);
                System.Threading.Thread.Sleep(1000);
            }

            TransactionRecord Record = Records.FirstOrDefault();

            Assert.IsTrue(Record.TxId == "30c8e2f7f5cf8b00f8b8bff127a8ceb726e30ab354dda361199fc435c22275b9");

            Assert.IsTrue(Record.Block == 1355565);

            Assert.IsTrue(Record.Outputs.Count() == 2);

            var Outputs = Record.Outputs.ToList();

            Assert.IsTrue(Outputs.Exists(x => x.Address == "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5" && x.Amount == 150000000));
            Assert.IsTrue(Outputs.Exists(x => x.Address == "2MwqZdwPUrmBACjacg8uwEZ8rVoCUX7GD2h" && x.Amount == 111418554));

            var Transaction = new CurrencyTransaction();

            Transaction.AddInput(150000000, "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5", 10151);
            Transaction.AddOutput(100000000, "mtCFoNLWbgHnB1SG7R7VqiDizGUP8K2uae");
            Transaction.AddOutput(50000000, "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5");

            Transaction.TxFee = 250000;

            Transaction.CurrencyId = 1;

            //var Response = TestServer.CreateTransaction(1, Transaction);

            //Assert.IsTrue(Response == "0100000001b97522c235c49f1961a3dd54b30ae326b7cea827f1bfb8f8008bcff5f7e2c830010000001976a91431ca57b301db0088e2d5912cff743210364b126c88acffffffff0200e1f505000000001976a9148b10583ecc2a455ab21342b3b34943ec711e694888ac80f0fa02000000001976a91431ca57b301db0088e2d5912cff743210364b126c88ac00000000");

            TestServer.Logoff();
        }
예제 #7
0
 public CurrencyInfo()
 {
     MonitoredCurrency      = false;
     NextReadTime           = DateTime.Now;
     LastCurrencyStatusItem = new CurrencyStatusItem();
 }
예제 #8
0
        /// <summary>
        /// Sends the nightly/monthly emails for users that have requested it.
        /// </summary>
        private void SendNightlyEmails()
        {
            // Find all users who qualify for expiring currency notifications - they may trigger an early email.
            List <EarnedGratuity> lstUsersWithExpiringCurrencies = EarnedGratuity.GratuitiesForUser(null, Gratuity.GratuityTypes.CurrencyAlerts);

            if (!String.IsNullOrEmpty(UserRestriction))
            {
                lstUsersWithExpiringCurrencies.RemoveAll(eg => eg.Username.CompareCurrentCultureIgnoreCase(UserRestriction) != 0);
            }

            // And the list of people who have a subscription to expiring currencies
            List <Profile> lstUsersSubscribedForExpiration = new List <Profile>(Profile.UsersWithSubscriptions(EmailSubscription.FlagForType(SubscriptionType.Expiration), DateTime.Now.AddDays(-7)));

            // get the list of people who have a subscription OTHER than simple monthly or expiration
            List <Profile> lstUsersToSend = new List <Profile>(Profile.UsersWithSubscriptions(~(EmailSubscription.FlagForType(SubscriptionType.MonthlyTotals) | EmailSubscription.FlagForType(SubscriptionType.Expiration)), DateTime.Now.AddDays(-7)));

            if (!String.IsNullOrEmpty(UserRestriction))
            {
                lstUsersToSend.RemoveAll(pf => pf.UserName.CompareOrdinalIgnoreCase(UserRestriction) != 0);
            }

            // See who has expiring currencies that require notification.
            foreach (EarnedGratuity eg in lstUsersWithExpiringCurrencies)
            {
                // Skip over anybody that's not also subscribed for expiration notices
                Profile pf = lstUsersSubscribedForExpiration.Find(profile => profile.UserName.CompareCurrentCultureIgnoreCase(eg.Username) == 0);
                if (pf == null)
                {
                    continue;
                }

                IEnumerable <CurrencyStatusItem> expiringCurrencies = CurrencyStatusItem.CheckForExpiringCurrencies(eg.State, eg.Username, out string newState);
                if (newState.CompareOrdinal(eg.State) != 0)
                {
                    eg.State = newState;
                    eg.Commit();
                }
                if (expiringCurrencies.Any())
                {
                    if (SendMailForUser(pf, Resources.Profile.EmailCurrencyExpiringMailSubject, string.Empty))
                    {
                        // Don't send the weekly mail, since we just pre-empted it.
                        lstUsersToSend.RemoveAll(p => pf.UserName.CompareCurrentCultureIgnoreCase(eg.Username) == 0);
                        pf.LastEmailDate = DateTime.Now;
                        pf.FCommit();
                    }
                }
            }

            foreach (Profile pf in lstUsersToSend)
            {
                if (SendMailForUser(pf, Resources.Profile.EmailWeeklyMailSubject, String.Empty))
                {
                    pf.LastEmailDate = DateTime.Now;
                    pf.FCommit();
                }
            }

            // Now do the monthly/annual emails
            if (DateTime.Now.Day == 1)
            {
                lstUsersToSend = new List <Profile>(Profile.UsersWithSubscriptions(EmailSubscription.FlagForType(SubscriptionType.MonthlyTotals), DateTime.Now.AddDays(1)));

                // We don't update the last-email sent on this because this email is asynchronous - i.e., not dependent on any other mail that was sent.
                foreach (Profile pf in lstUsersToSend)
                {
                    SendMailForUser(pf, String.Format(CultureInfo.CurrentCulture, Resources.Profile.EmailMonthlySubject, DateTime.Now.AddMonths(-1).ToString("MMMM", CultureInfo.InvariantCulture)), "monthly");
                }
            }
        }