public void Test_KeyExists_Method() { History h = History.InstanceNoFileWrite; h.AddEntry("http://www.duckduckgo.com", "DuckDuckGo", false); h.AddEntry("http://www.duckduckgo.com", "DuckDuckGo", false); Assert.AreEqual(h.GetList()[0].Title, "DuckDuckGo"); Assert.AreEqual(h.GetList()[1].Title, "DuckDuckGo (2)"); }
/// <summary> /// Performs the transition. /// </summary> /// <param name="stateName">Name of the state.</param> /// <param name="reason">The reason.</param> /// <param name="comment">The comment.</param> /// <returns></returns> public virtual bool PerformTransition(TStateName stateName, string reason = null, string comment = null) { // If there are NOT history entries and we're dealing with the initial state then proceed... if (!History.Entries.Any() && stateName.Equals(initialStateName)) { Status = stateName; var historyEntry = BuildHistoryEntry(Status, reason, comment); History.AddEntry(historyEntry); } else // Otherwise (we do have entries or we're NOT dealing with the initial state then... { if (!IsValidTransition(Status, stateName)) { return(false); } Status = stateName; var historyEntry = BuildHistoryEntry(Status, reason, comment); History.AddEntry(historyEntry); } return(true); }
private void FinancesTreeList_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { DeleteItemBtn.Enabled = false; ExecuteItemBtn.Enabled = false; EditItemBtn.Enabled = false; CopyItemBtn.Enabled = false; PrintItemBtn.Enabled = false; cur_wtype = focused_tree_node.WType != null ? focused_tree_node.WType.Value : 0; RefrechItemBtn.PerformClick(); wbContentTab.SelectedTabPageIndex = focused_tree_node.GType.Value; if (focused_tree_node.FunId != null) { History.AddEntry(new HistoryEntity { FunId = focused_tree_node.FunId.Value, MainTabs = 3 }); if (FinancesTreeList.ContainsFocus) { Settings.Default.LastFunId = focused_tree_node.FunId.Value; } } }
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) { History.AddEntry(new HistoryEntity { FunId = 0, MainTabs = xtraTabControl1.SelectedTabPageIndex }); Properties.Settings.Default.LastTabPage = xtraTabControl1.SelectedTabPageIndex; }
public string Convert() { var result = Converter.Convert(editor.number, originalBase, resultBase); history.AddEntry($"{editor.number}({originalBase}) = {result}({resultBase})"); return(result); }
/// <summary> /// Requires Save() on Member after using this metod /// </summary> /// <param name="user"></param> /// <param name="chances"></param> public static void AddChances(Member user) { var chances = new Random(); int chancesWon = chances.Next(AppSettings.SlotMachine.SlotMachineMinChancesGiven, AppSettings.SlotMachine.SlotMachineMaxChancesGiven + 1); if (chancesWon > 0) { user.SlotMachineChances += chancesWon; History.AddEntry(user.Name, HistoryType.SlotChancesWon, chancesWon.ToString()); } }
public void SetTile(ushort x, ushort y, byte tileID, byte flags) { int index = y * Width + x; if (x < 0 || x >= Width || y < 0 || y >= Height) { return; } History.AddEntry(x, y, tileID, flags); Tiles[index].TileID = tileID; Tiles[index].Flags = flags; }
private void mainForm_Load(object sender, EventArgs e) { CurDateEditBarItem.EditValue = DateTime.Now; repositoryItemLookUpEdit1.DataSource = DBHelper.EnterpriseList; if (barEditItem3.EditValue == null || barEditItem3.EditValue == DBNull.Value || (barEditItem3.EditValue != null && barEditItem3.EditValue != DBNull.Value && !DBHelper.EnterpriseList.Any(a => a.KaId == Convert.ToInt32(barEditItem3.EditValue)))) { barEditItem3.EditValue = DBHelper.EnterpriseList.Select(s => s.KaId).FirstOrDefault(); } History.AddEntry(new HistoryEntity { FunId = 0, MainTabs = xtraTabControl1.SelectedTabPageIndex }); }
private static void TryToSpeedUpReferrer(int referrerId, Money planPrice, string username) { //ONLY Referrals //Matrix - TODO if (AppSettings.InvestmentPlatform.InvestmentPlatformSpeedUpOption != SpeedUpOptions.Referrals) { return; } var query = string.Format(@" WITH CTE AS (SELECT TOP 1 * FROM InvestmentUsersPlans WHERE UserId = {0} AND Status = {1} ORDER BY PurchasedDate ASC) UPDATE InvestmentUsersPlans SET MoneyInSystem += (SELECT BinaryEarning FROM InvestmentPlatformPlans WHERE Id = (SELECT PlanId FROM CTE)) * {2} WHERE Id = (SELECT Id FROM CTE)", referrerId, (int)PlanStatus.Active, planPrice / 100); TableHelper.ExecuteRawCommandNonQuery(query); var bonusQuery = string.Format(@" WITH CTE AS (SELECT TOP 1 * FROM InvestmentUsersPlans WHERE UserId = {0} AND Status = {1} ORDER BY PurchasedDate ASC) SELECT BinaryEarning FROM InvestmentPlatformPlans WHERE Id = (SELECT PlanId FROM CTE)", referrerId, (int)PlanStatus.Active); try { var user = new Member(referrerId); var bonus = (int)TableHelper.SelectScalar(bonusQuery) * planPrice / 100; var historyNote = string.Empty; if (bonus <= Money.Zero) { return; } if (TitanFeatures.IsRetireYoung) { historyNote = string.Format("Investment Plan SpeedUp [ref - {0}] ({1}/{2})", username, bonus.ToString(), RetireyoungManager.GetAggregate(user.Id)); } else { historyNote = string.Format("Investment Plan SpeedUp [ref - {0}] ({1})", username, bonus.ToString()); } History.AddEntry(user.Name, HistoryType.InvestmentPlatformSpeedUpBonus, historyNote); } catch (Exception e) { } }
public void UpdateLocal(IList <IEveCharacter> characters) { Application.Current.Dispatcher.Invoke(new Action(() => { History.AddEntry(characters, _currentSolarSystem); MoveToNewestInHistory(); Characters.SetContent( _characterSorter.Sorted(characters .Select( character => new EveCharacterViewModel (character, Statistics)))); BusyIndicator.IsBusy = false; })); }
private void WHTreeList_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { DeleteItemBtn.Enabled = false; ExecuteItemBtn.Enabled = false; EditItemBtn.Enabled = false; CopyItemBtn.Enabled = false; PrintItemBtn.Enabled = false; focused_tree_node = WHTreeList.GetDataRecordByNode(e.Node) as GetWhTree_Result; cur_wtype = focused_tree_node.WType != null ? focused_tree_node.WType.Value : 0; /* if (focused_tree_node.GType.Value == 1 && wh_mat_list != null && ByGrpBtn.Down && wh_mat_list.Any()) * { * if (ViewDetailTree.Down && ByGrpBtn.Down && focused_tree_node.Num != 0) * { * var grp = DB.SkladBase().GetMatGroupTree(focused_tree_node.Num).ToList().Select(s => s.GrpId); * WhMatGetBS.DataSource = wh_mat_list.Where(w => grp.Contains(w.OutGrpId)); * } * else * { * WhMatGetBS.DataSource = wh_mat_list.Where(w => w.OutGrpId == focused_tree_node.Num || focused_tree_node.Num == 0); * } * } * else * { * RefrechItemBtn.PerformClick(); * }*/ RefrechItemBtn.PerformClick(); whContentTab.SelectedTabPageIndex = focused_tree_node.GType.Value; if (focused_tree_node.FunId != null) { History.AddEntry(new HistoryEntity { FunId = focused_tree_node.FunId.Value, MainTabs = 2 }); if (WHTreeList.ContainsFocus) { Settings.Default.LastFunId = focused_tree_node.FunId.Value; } } }
public void Finish(bool isSave = true) { FinishDate = AppSettings.ServerTime; Status = PlanStatus.Finished; if (!AppSettings.InvestmentPlatform.InvestmentPlatformDailyLimitsEnabled) { var user = Member.CurrentInCache; var crediter = new InvestmentPlanCrediter(user); var platformPlan = new InvestmentPlatformPlan(PlanId); var note = string.Format("Finished plan: {0}", platformPlan.Name); if (TitanFeatures.IsRetireYoung) { crediter.CreditPlan(MoneyInSystem + platformPlan.Price, BalanceType.MainBalance, note, BalanceLogType.InvestmentPlatformWithdrawal); } else { crediter.CreditPlan(MoneyInSystem, BalanceType.MainBalance, note, BalanceLogType.InvestmentPlatformWithdrawal); } //BONUS if (MoneyInSystem >= MoneyToReturn && LastWithdrawalDate == null) { var bonus = platformPlan.EndBonus; if (bonus > Money.Zero) { note = string.Format(U6010.BONUSFORFINISHEDPLAN, platformPlan.Name); crediter.CreditPlan(bonus, BalanceType.MainBalance, note, BalanceLogType.InvestmentPlatformWithdrawal); var historyNote = string.Format("{0} ({1}/{2})", note, bonus.ToString(), RetireyoungManager.GetAggregate(user.Id)); History.AddEntry(user.Name, HistoryType.InvestmentPlatformBonus, historyNote); } } MoneyInSystem = Money.Zero; } if (isSave) { Save(); } }
private void DirTreeList_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { focused_tree_node = DirTreeList.GetDataRecordByNode(e.Node) as GetServiceTree_Result; RefrechItemBtn.PerformClick(); mainContentTab.SelectedTabPageIndex = focused_tree_node.GType.Value; if (focused_tree_node.FunId != null) { History.AddEntry(new HistoryEntity { FunId = focused_tree_node.FunId.Value, MainTabs = 6 }); if (DirTreeList.ContainsFocus) { Settings.Default.LastFunId = focused_tree_node.FunId.Value; } } }
public static void TryMarkAccountActivationFeeAsPaid(Member user, Money amount, string from, string transId, string cryptoCurrencyInfo) { bool Successful = false; try { String Message = String.Format(" {0} money for account activation. ", amount); if (amount < AppSettings.Registration.AccountActivationFee) { Message += "Amount is lower than expected! Account not activated."; History.AddEntry(Member.CurrentName, HistoryType.Transfer, Message); PoolDistributionManager.AddProfit(ProfitSource.AccountActivationFee, amount); throw new Exception(String.Format("Account activation fee is lower than expected! ({0})", amount)); } AccountActivationFeeCrediter Crediter = (AccountActivationFeeCrediter)CrediterFactory.Acquire(user, CreditType.AccountActivationFee); var moneyLeftForPools = Crediter.CreditReferer(amount); //Pools PoolDistributionManager.AddProfit(ProfitSource.AccountActivationFee, moneyLeftForPools); user.IsAccountActivationFeePaid = true; user.Save(); Message += "Account activated."; History.AddEntry(Member.CurrentName, HistoryType.Transfer, Message); Successful = true; } catch (Exception ex) { ErrorLogger.Log(ex); } PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from); CompletedPaymentLog.Create(PP, "Activation Fee", transId, false, user.Name, amount, Money.Zero, Successful, cryptoCurrencyInfo); }
public static bool PullTheLever(out int points) { points = 0; if (Member.IsLogged) { var user = Member.CurrentInCache; if (user.SlotMachineChances == 0) { return(false); } points = givePoints(); user.SlotMachineChances--; user.AddToPointsBalance(points, "Slot machine reward"); user.Save(); if (points >= AppSettings.SlotMachine.SlotMachineMinWinToDisplayInLatestActivity) { History.AddEntry(user.Name, HistoryType.SlotMachinePayout, points.ToString()); } return(true); } else { if ((int)HttpContext.Current.Session["anonymousSlotChances"] == 0) { return(false); } else { points = givePoints(); HttpContext.Current.Session["anonymousSlotChances"] = 0; HttpContext.Current.Session["anonymousSlotMachinePoints"] = points; return(true); } } }
private void DocsTreeList_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { focused_tree_node = DocsTreeList.GetDataRecordByNode(e.Node) as GetManufactureTree_Result; NewItemBtn.Enabled = (focused_tree_node != null && focused_tree_node.CanInsert == 1); CopyItemBtn.Enabled = false; DeleteItemBtn.Enabled = false; ExecuteItemBtn.Enabled = false; EditItemBtn.Enabled = false; PrintItemBtn.Enabled = false; AddTechProcBtn.Enabled = false; DelTechProcBtn.Enabled = false; EditTechProcBtn.Enabled = false; AddIntermediateWeighing.Enabled = false; EditIntermediateWeighing.Enabled = false; DelIntermediateWeighing.Enabled = false; _cur_wtype = focused_tree_node.WType != null ? focused_tree_node.WType.Value : 0; RefrechItemBtn.PerformClick(); wbContentTab.SelectedTabPageIndex = focused_tree_node.GType.Value; if (focused_tree_node.FunId != null) { History.AddEntry(new HistoryEntity { FunId = focused_tree_node.FunId.Value, MainTabs = 1 }); if (DocsTreeList.ContainsFocus) { Settings.Default.LastFunId = focused_tree_node.FunId.Value; } } }
public static void CRON() { try { if (AppSettings.InvestmentPlatform.InvestmentPlatformEnabled) { var activePlans = GetAllActivePlans(); foreach (var plan in activePlans) { var usersPlans = GetAllUsersActivePlans().FindAll(x => x.PlanId == plan.Id); if (usersPlans.Count == 0 || plan.Roi == 0 || plan.Time == 0 || plan.Price == Money.Zero) { continue; } var note = plan.Name + " credit"; foreach (var userPlan in usersPlans) { if (userPlan.PurchaseDate.AddDays(plan.EarningDaysDelay) > DateTime.Now) { continue; } var dailyPool = userPlan.Price * plan.Roi / 100 / plan.Time; //start userPlan.TakeMoneyFromFinishedPlans(); userPlan.MoneyReturned += dailyPool; userPlan.MoneyInSystem += dailyPool; Member user = new Member(userPlan.UserId); if (AppSettings.InvestmentPlatform.InvestmentPlatformCreditingPolicy == CreditingPolicy.Automatic && userPlan.MoneyInSystem > GetMembershipMinAmountToCredit(user)) { Money creditAmount; //Monthly check if (userPlan.CurrentMonthPayout > DateTime.Now.Day * plan.DailyLimit) { userPlan.CurrentMonthPayout = Money.Zero; } if (!AppSettings.InvestmentPlatform.InvestmentPlatformDailyLimitsEnabled || userPlan.CurrentMonthPayout < plan.MonthlyLimit) { if (AppSettings.InvestmentPlatform.InvestmentPlatformDailyLimitsEnabled && userPlan.MoneyInSystem > plan.DailyLimit) { creditAmount = plan.DailyLimit; userPlan.MoneyInSystem -= plan.DailyLimit; } else { creditAmount = userPlan.MoneyInSystem; userPlan.MoneyInSystem = Money.Zero; } //Monthly limit var leftInMonth = plan.MonthlyLimit - userPlan.CurrentMonthPayout; if (AppSettings.InvestmentPlatform.InvestmentPlatformDailyLimitsEnabled && creditAmount > leftInMonth) { userPlan.MoneyInSystem += (creditAmount - leftInMonth); creditAmount = leftInMonth; } userPlan.CurrentMonthPayout += creditAmount; var crediter = new InvestmentPlanCrediter(user); crediter.CreditPlan(creditAmount, BalanceType.MainBalance, note, BalanceLogType.InvestmentPlatformPlanCrediting); //TO DO AFTER ENABLE INVESTMENT BALANCE //if (AppSettings.InvestmentPlatform.CreditToInvestmentBalanceEnabled) // user.AddToInvestmentBalance(creditAmount, note); //else // user.AddToMainBalance(creditAmount, note); user.SaveBalances(); } } if (userPlan.MoneyReturned >= userPlan.MoneyToReturn) { var overPlus = userPlan.MoneyReturned - userPlan.MoneyToReturn; userPlan.MoneyInSystem += overPlus; userPlan.MoneyReturned = userPlan.MoneyToReturn; userPlan.Finish(false); } userPlan.Save(); string historyNote; if (TitanFeatures.IsRetireYoung) { historyNote = string.Format("{0} ({1}/{2}) ", note, dailyPool.ToString(), RetireyoungManager.GetAggregate(user.Id)); } else { historyNote = string.Format("{0}: {1}", note, dailyPool.ToString()); } History.AddEntry(user.Name, HistoryType.InvestmentPlatformDailyCredit, historyNote); //end } } } } catch (Exception e) { ErrorLogger.Log(e); } }