void openBalanceUpdateForm(BalanceType btype, int entry_index = 0) { UpdateBalanceForm balance_form = new UpdateBalanceForm(); //пополнение balance_form.entry_sum_direction.SelectedIndex = (int)btype; balance_form.btnApply.Click += (fSender, eSender) => { decimal bdata_amount = balance_form.entry_amount.Value; FundEntry entry = logic.getEntry(entry_index); decimal entry_balance = logic.calcEntryBalance(entry); bool can_continue = true; //если вычет средств, то проверяем баланс if (btype == BalanceType.Outcome && bdata_amount > entry_balance) { //запрашивается вычет баланса больше, чем есть can_continue = false; alert("Вы пытаетесь вычесть баланса больше, чем доступно в задаче"); } if (can_continue) { BalanceData bdata = new BalanceData(); bdata.amount = bdata_amount; bdata.comment = balance_form.textBox_comment.Text; bdata.type = btype; logic.addBalanceData(bdata, btype, entry_index); balance_form.Close(); rebuildTable(); } }; balance_form.ShowDialog(); }
private void ReadClosingBalance(ref Statement statement, BalanceType balanceType) { var value = _reader.ReadTo(out var nextKey, "\r\n:64:", "\r\n:65:", "\r\n:86:", "\r\n-"); switch (nextKey) { case "\r\n:64:": ReadClosingAvailableBalance(ref statement); break; case "\r\n:65:": ReadForwardAvailableBalance(ref statement); break; case "\r\n:86:": ReadStatementInformationToOwner(ref statement); break; case "\r\n-": break; // End of statement default: throw new InvalidDataException("The statement data ended unexpectedly. Expected field :62a: to be followed by :64:, :65:, :86: or the end of the statement"); } statement.ClosingBalance = _balanceParser.ReadBalance(value, balanceType); }
public IList<BalancePerCategory> GetBalancePerCategory(DateTime dateFrom, DateTime dateTo, BalanceType type) { using (var dbContext = new DatabaseContext()) { var transactions = dbContext.Transactions.Include(x => x.SubCategory.Category); return (from t in transactions where t.Date >= dateFrom && t.Date < dateTo group t by t.SubCategory.Category into gr select new { Category = gr.Key, Debit = gr.Sum(x => x.Debit), Credit = gr.Sum(x => x.Credit), }) .ToList() .Where(x => type == BalanceType.Credit ? x.Credit > 0 : x.Debit > 0) .Select(x => new BalancePerCategory { Category = x.Category ?? new Category { Name = "Uncategorized" }, Amount = type == BalanceType.Credit ? x.Credit : x.Debit }) .OrderBy(x => x.Category.DisplayOrder) .ToList(); } }
//private void Rebalance( bool stopAfterFirstRotate, bool stopAfterEvenBalanceFound ) private void Rebalance(BalanceType balanceType) { bool stopAfterFirstRotate = ((balanceType & BalanceType.StopAfterFirstRotate) != 0); bool stopAfterEvenBalanceFound = ((balanceType & BalanceType.StopAfterEvenBalanceFound) != 0); if (BalanceFactor > 1) { if (Left.BalanceFactor > 0) { RotateLL(); if (stopAfterFirstRotate) { return; } } else { RotateLR(); if (stopAfterFirstRotate) { return; } } } else if (BalanceFactor < -1) { if (Right.BalanceFactor < 0) { RotateRR(); if (stopAfterFirstRotate) { return; } } else { RotateRL(); if (stopAfterFirstRotate) { return; } } } else { if (stopAfterEvenBalanceFound) { return; } } if (Parent != null) { Parent.Rebalance(BalanceType.StopAfterFirstRotate); } }
public static void Add(Member User, BalanceType account, decimal difference, string Note, BalanceLogType balanceLogType) { if (difference != 0) { BalanceLog Entry = new BalanceLog(); Entry.DateOccured = AppSettings.ServerTime; Entry.UserId = User.Id; Entry.Type = account; Entry.Amount = difference; Entry.Note = Note; switch (account) { case BalanceType.MainBalance: Entry.AccountState = User.MainBalance; break; case BalanceType.PurchaseBalance: Entry.AccountState = User.PurchaseBalance; break; case BalanceType.TrafficBalance: Entry.AccountState = User.TrafficBalance; break; case BalanceType.CashBalance: Entry.AccountState = User.CashBalance; break; case BalanceType.CommissionBalance: Entry.AccountState = User.CommissionBalance; break; case BalanceType.InvestmentBalance: Entry.AccountState = User.InvestmentBalance; break; case BalanceType.BTC: Entry.AccountState = User.GetCryptocurrencyBalance(CryptocurrencyType.BTC); break; case BalanceType.XRP: Entry.AccountState = User.GetCryptocurrencyBalance(CryptocurrencyType.XRP); break; case BalanceType.ETH: Entry.AccountState = User.GetCryptocurrencyBalance(CryptocurrencyType.ETH); break; case BalanceType.Token: Entry.AccountState = User.GetCryptocurrencyBalance(CryptocurrencyType.ERC20Token); break; case BalanceType.FreezedToken: Entry.AccountState = User.GetCryptocurrencyBalance(CryptocurrencyType.ERCFreezed); break; } Entry.BalanceLogType = balanceLogType; Entry.Save(); } }
public InsufficientBalanceDialogViewModel(BalanceType type, BuildTransactionResult transaction, decimal usdExchangeRate) { var destinationAmount = transaction.CalculateDestinationAmount().ToDecimal(MoneyUnit.BTC); var fee = transaction.Fee; BtcAmountText = $"{destinationAmount} bitcoins "; FiatAmountText = $"(≈{(destinationAmount * usdExchangeRate).FormattedFiat()} USD) "; BtcFeeText = $"{fee.ToDecimal(MoneyUnit.Satoshi)} satoshis "; FiatFeeText = $"(≈{(fee.ToDecimal(MoneyUnit.BTC) * usdExchangeRate).FormattedFiat()} USD)"; switch (type) { case BalanceType.Private: Caption = $"There are not enough private funds to cover the transaction fee. Alternatively you could:"; break; case BalanceType.Pocket: Caption = $"There are not enough funds selected to cover the transaction fee. Alternatively you could:"; break; default: Caption = $"There are not enough funds available to cover the transaction fee. Alternatively you could:"; break; } NextCommand = ReactiveCommand.Create(() => Close(result: true)); CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel)); }
private void ReadOpeningBalance(ref Statement statement, BalanceType balanceType) { var value = _reader.ReadTo(out var nextKey, "\r\n:61:", "\r\n:62F:", "\r\n:62M:", "\r\n:86:"); switch (nextKey) { case "\r\n:61:": ReadStatementLine(ref statement); break; case "\r\n:62F:": ReadClosingBalance(ref statement, BalanceType.Closing); break; case "\r\n:62M:": ReadClosingBalance(ref statement, BalanceType.Intermediate); break; case "\r\n:86:": throw new InvalidDataException("The statement :86: should be preceeded by :61:"); default: throw new InvalidDataException("The statement data ended unexpectedly. Expected field :60a: to be followed by :61:, :62F: or :62M:"); } statement.OpeningBalance = _balanceParser.ReadBalance(value, balanceType); }
protected void TryPurchaseTokens(BalanceType balanceType) { SuccMessagePanel.Visible = false; ErrorMessagePanel.Visible = false; try { int numberOfTokens = Convert.ToInt32(NumberOfTokensTextBox.Text); Member user = Member.Current; ICOManager.TryPurchaseTokens(user, ICOStage.GetCurrentStage(), numberOfTokens, balanceType); SuccMessagePanel.Visible = true; SuccMessage.Text = String.Format(U6012.SUCCTOKENSPURCHASE, numberOfTokens, TokenCryptocurrency.Code); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } }
/// <summary> /// Internal constructor. /// </summary> protected Account(AccountType accountType, BalanceType defaultBalanceType) : base() { this.AccountID = Guid.NewGuid(); this.AccountType = accountType; this.DefaultBalanceType = defaultBalanceType; }
public static void TryBuyAdPack(BalanceType fromBalance, int advertId, AdPackType adPackType, int numberOfPacks, Member adPackOwner = null) { if (Member.Current.IsAnyBalanceIsNegative()) { throw new MsgException(U6013.YOUCANTPROCEED); } if (numberOfPacks <= 0) { throw new MsgException(String.Format("Can't buy 0 {0}s", AppSettings.RevShare.AdPack.AdPackNamePlural)); } if (fromBalance == BalanceType.PurchaseBalance) { AdPackManager.BuyPacks(numberOfPacks, advertId, Member.CurrentInCache, adPackType, PurchaseBalances.Purchase, adPackOwner: adPackOwner); } else if (fromBalance == BalanceType.CashBalance) { AdPackManager.BuyPacks(numberOfPacks, advertId, Member.CurrentInCache, adPackType, PurchaseBalances.Cash, adPackOwner: adPackOwner); } else if (fromBalance == BalanceType.Token) { AdPackManager.TryBuyAdPackForTokens(numberOfPacks, advertId, Member.CurrentInCache, adPackType, adPackOwner: adPackOwner); } else { AdPackManager.TryBuyAdPackFromAnotherBalance(numberOfPacks, advertId, Member.CurrentInCache, adPackType, fromBalance, adPackOwner: adPackOwner); } }
public static void BuyTickets(Jackpot jackpot, Member user, int numberOfTickets, BalanceType PurchaseBalanceType = BalanceType.PurchaseBalance) { if (!AppSettings.TitanFeatures.MoneyJackpotEnabled) { throw new MsgException("Jackpots unavailable"); } var totalPrice = jackpot.TicketPrice * numberOfTickets; if (PurchaseBalanceType == BalanceType.PurchaseBalance && user.PurchaseBalance < totalPrice) { throw new MsgException(L1.NOTENOUGHFUNDS); } if (PurchaseBalanceType == BalanceType.CashBalance && user.CashBalance < totalPrice) { throw new MsgException(L1.NOTENOUGHFUNDS); } if (PurchaseBalanceType == BalanceType.PurchaseBalance) { user.SubtractFromPurchaseBalance(totalPrice, string.Format("Purchased {0} Jackpot tickets", numberOfTickets), BalanceLogType.Other); } else if (PurchaseBalanceType == BalanceType.CashBalance) { user.SubtractFromCashBalance(totalPrice, string.Format("Purchased {0} Jackpot tickets", numberOfTickets), BalanceLogType.Other); } user.SaveBalances(); GiveTickets(jackpot, user, numberOfTickets); }
public void BuyTickets(BalanceType purchaseBalanceType) { EPanel.Visible = SPanel.Visible = false; try { int numberOfTickets; if (!Int32.TryParse(NumberOfTicketsTextBox.Text, out numberOfTickets) || numberOfTickets <= 0) { throw new MsgException(U5003.INVALIDNUMBEROFTICKETS); } user = Member.Current; JackpotManager.BuyTickets(Jackpot, user, numberOfTickets, purchaseBalanceType); NumberOfTicketsTextBox.Text = string.Empty; SPanel.Visible = true; SText.Text = U5003.TICKETPURCHASESUCCESS.Replace("%n%", numberOfTickets.ToString()); this.DataBind(); } catch (Exception ex) { if (ex is MsgException) { EPanel.Visible = true; EText.Text = ex.Message; } else { ErrorLogger.Log(ex); } } }
public static void AddRange(string dataTableCommand, string note, BalanceType target, BalanceLogType balanceLogType) { using (var parser = ParserPool.Acquire(Database.Client)) { AddRange(parser.Instance, dataTableCommand, note, target, balanceLogType); } }
public InsufficientBalanceDialogViewModel(BalanceType type, BuildTransactionResult transaction, decimal usdExchangeRate) { var destinationAmount = transaction.CalculateDestinationAmount().ToDecimal(MoneyUnit.BTC); var btcAmountText = $"{destinationAmount} bitcoins "; var fiatAmountText = destinationAmount.GenerateFiatText(usdExchangeRate, "USD"); AmountText = $"{btcAmountText}{fiatAmountText}"; var fee = transaction.Fee; var btcFeeText = $"{fee.ToDecimal(MoneyUnit.Satoshi)} satoshis "; var fiatFeeText = fee.ToDecimal(MoneyUnit.BTC).GenerateFiatText(usdExchangeRate, "USD"); FeeText = $"{btcFeeText}{fiatFeeText}"; switch (type) { case BalanceType.Private: Caption = $"There are not enough private funds to cover the transaction fee. Alternatively you could:"; break; case BalanceType.Pocket: Caption = $"There are not enough funds selected to cover the transaction fee. Alternatively you could:"; break; default: Caption = $"There are not enough funds available to cover the transaction fee. Alternatively you could:"; break; } NextCommand = ReactiveCommand.Create(() => Close(result: true)); CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel)); SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: true); }
private void ReadClosingBalance(ref Statement statement, BalanceType balanceType) { var value = _reader.ReadTo(out var nextKey, ":64:", ":65:", ":86:", "-").Trim(); switch (nextKey) { case ":64:": ReadClosingAvailableBalance(ref statement); break; case ":65:": ReadForwardAvailableBalance(ref statement); break; case ":86:": ReadStatementInformationToOwner(ref statement); break; case "-": default: break; // End of statement //it's ok if field :62a: is not followed by :64:, :65:, :86: but comes to an end or - as termination symbol } statement.ClosingBalance = _balanceParser.ReadBalance(value, balanceType); }
public String GetClearStringBalance(BalanceType type) { if (BalanceTypeHelper.IsCryptoBalance(type)) { return(UserCryptocurrencyBalance.Get(Member.CurrentId, CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(type)).ToClearString()); } return(GetBasicBalance(type).ToClearString()); }
public double GetBalance(BalanceType balanceType) { return(balanceType switch { BalanceType.Cash => Cash, BalanceType.Card => Card, _ => throw new Exception("Unknown balance type"), });
public FormBalance(BalanceType type) { InitializeComponent(); _type = type; InitControl(); }
public static String GetName(BalanceType balanceType) { switch (balanceType) { case BalanceType.MainBalance: if (TitanFeatures.IsTrafficThunder) { return(String.Format(U6012.WALLET, String.Format("{0} {1}", AppSettings.Site.CurrencyCode, U5004.MAIN))); } return(L1.MAINBALANCE); case BalanceType.PurchaseBalance: if (TitanFeatures.IsTrafficThunder) { return(String.Format(U6012.WALLET, AppSettings.Site.CurrencyCode)); } return(U6012.PURCHASEBALANCE); case BalanceType.TrafficBalance: return(U4200.TRAFFICBALANCE); case BalanceType.PointsBalance: return(String.Format("{0}", AppSettings.PointsName)); case BalanceType.CommissionBalance: return(U5004.COMMISSIONBALANCE); case BalanceType.PTCCredits: return(String.Format("{0} {1}", U6003.PTC, U6012.CREDITS)); case BalanceType.CashBalance: return(U5008.CASHBALANCE); case BalanceType.InvestmentBalance: return(U6006.INVESTMENTBALANCE); case BalanceType.MarketplaceBalance: return(U6008.MARKETPLACEBALANCE); case BalanceType.BTC: case BalanceType.ETH: case BalanceType.XRP: return(String.Format(U6012.WALLET, balanceType.ToString())); case BalanceType.Token: return(String.Format(U6012.WALLET, CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token).Code)); case BalanceType.FreezedToken: return(String.Format(U6012.WALLET, CryptocurrencyFactory.Get(CryptocurrencyType.ERCFreezed).Code)); case BalanceType.LoginAdsCredits: return(U5008.LOGINADSCREDITS); default: return(String.Empty); } }
public static String RecognizeCurrencyAndReturnString(bool asStock, decimal value) { BalanceType targetType = asStock ? AppSettings.InternalExchange.InternalExchangeStockType : AppSettings.InternalExchange.InternalExchangePurchaseVia; if (BalanceTypeHelper.IsCryptoBalance(targetType)) { return(new CryptocurrencyMoney(CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(targetType), value).ToString()); } return(new Money(value).ToString()); }
public static String GetBalanceCode(bool isStock) { BalanceType targetBalance = isStock == true ? AppSettings.InternalExchange.InternalExchangeStockType : AppSettings.InternalExchange.InternalExchangePurchaseVia; if (BalanceTypeHelper.IsCryptoBalance(targetBalance)) { return(CryptocurrencyFactory.Get(CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(targetBalance)).Code); } return(AppSettings.Site.CurrencyCode); }
public decimal GetDecimalBalance(BalanceType type) { if (BalanceTypeHelper.IsCryptoBalance(type)) { return(UserCryptocurrencyBalance.Get(Member.CurrentId, CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(type)).ToDecimal()); } else { return(GetBasicBalance(type).ToDecimal()); } }
public IvrBalanceInfo(BalanceInfo info, BalanceType type) { Amount = info.Amount; if (type == BalanceType.Available) Type = IvrBalanceType.Available; else if(type == BalanceType.Phone) Type = IvrBalanceType.Phone // here you have to handle the other values and set the default // values for the Type Property or it will take the default value // if you not set it }
public Balance ReadBalance(string buffer, BalanceType type) { _reader = new StringReader(buffer); var balance = new Balance { Type = type }; ReadDebitCreditMark(ref balance); return(balance); }
protected void WithdrawHistoryGridView_RowDataBound(object sender, GridViewRowEventArgs e) { WithdrawHistoryGridView.Columns[0].HeaderText = L1.DATE; WithdrawHistoryGridView.Columns[1].HeaderText = L1.AMOUNT; WithdrawHistoryGridView.Columns[2].HeaderText = U5004.PAYMENTPROCESSOR; WithdrawHistoryGridView.Columns[3].HeaderText = L1.ADDRESS; WithdrawHistoryGridView.Columns[4].HeaderText = L1.STATUS; WithdrawHistoryGridView.Columns[5].HeaderText = L1.TYPE; if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Text = Money.Parse(((DataBoundLiteralControl)e.Row.Cells[1].Controls[0]).Text.Trim()).ToString(); string PaymentProcessorOrRejected = ((DataBoundLiteralControl)e.Row.Cells[2].Controls[0]).Text.Trim(); if (PaymentProcessorOrRejected == "REJECTED") { e.Row.Cells[2].Text = "-"; } bool IsPaid = Convert.ToBoolean(((DataBoundLiteralControl)e.Row.Cells[4].Controls[0]).Text.Trim()); if (PaymentProcessorOrRejected == "REJECTED") { e.Row.Cells[4].Text = L1.REJECTED; e.Row.Cells[4].ForeColor = System.Drawing.Color.DarkRed; e.Row.Cells[6].Text = ""; } else if (IsPaid) { e.Row.Cells[4].Text = L1.FINISHED; e.Row.Cells[4].ForeColor = System.Drawing.Color.Green; e.Row.Cells[6].Text = ""; } else { e.Row.Cells[4].Text = L1.PENDING; e.Row.Cells[4].ForeColor = System.Drawing.Color.Purple; } BalanceType balance = (BalanceType)Convert.ToInt32(((DataBoundLiteralControl)e.Row.Cells[5].Controls[0]).Text.Trim()); if (balance == BalanceType.MainBalance) { e.Row.Cells[5].Text = L1.MAINBALANCE; } else if (balance == BalanceType.CommissionBalance) { e.Row.Cells[5].Text = U5004.COMMISSIONBALANCE; } } }
public void CreditPlan(Money amount, BalanceType balancetype, string note, BalanceLogType logType) { switch (balancetype) { case BalanceType.MainBalance: base.CreditMainBalance(amount, note, logType); break; case BalanceType.InvestmentBalance: //TO DO break; } }
public int Select(IList <Server> configs, int curIndex, BalanceType algorithm, FilterFunc filter, bool forceChange = false) { lastSelectIndex = SubSelect(configs, curIndex, algorithm, filter, forceChange); if (lastSelectIndex >= 0 && lastSelectIndex < configs.Count) { lastSelectID = configs[lastSelectIndex].Id; } else { lastSelectID = null; } return(lastSelectIndex); }
public static bool IsCryptoBalance(BalanceType type) { switch (type) { case BalanceType.BTC: case BalanceType.ETH: case BalanceType.Token: case BalanceType.XRP: case BalanceType.FreezedToken: return(true); } return(false); }
public static String GetBalanceSign(bool isStock) { BalanceType targetBalance = isStock == true ? AppSettings.InternalExchange.InternalExchangeStockType : AppSettings.InternalExchange.InternalExchangePurchaseVia; if (BalanceTypeHelper.IsCryptoBalance(targetBalance)) { Cryptocurrency crypto = CryptocurrencyFactory.Get(CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(targetBalance)); if (String.IsNullOrEmpty(crypto.CurrencyDisplaySignBefore)) { return(crypto.CurrencyDisplaySignAfter.Trim()); } return(crypto.CurrencyDisplaySignBefore.Trim()); } return(AppSettings.Site.CurrencySign.Trim()); }
public InsufficientBalanceDialogViewModel(BalanceType type) { Question = type switch { BalanceType.Private => $"There are not enough private funds to cover the transaction fee. Instead of an extra cost, Wasabi can subtract the transaction fee from the amount.", BalanceType.Pocket => $"There are not enough funds selected to cover the transaction fee. Instead of an extra cost, Wasabi can subtract the transaction fee from the amount.", _ => $"There are not enough funds available to cover the transaction fee. Instead of an extra cost, Wasabi can subtract the transaction fee from the amount.", }; Question += "\n\nWould you like to do this instead?"; NextCommand = ReactiveCommand.Create(() => Close(result: true)); CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel)); SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: false); }
public String GetStringBalance(BalanceType type) { if (BalanceTypeHelper.IsCryptoBalance(type)) { return(UserCryptocurrencyBalance.Get(Member.CurrentId, CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(type)).ToString().Trim()); } else { if (type == BalanceType.PTCCredits || type == BalanceType.PointsBalance) { return(GetBasicBalance(type).ToClearString().Trim()); } return(GetBasicBalance(type).ToString().Trim()); } }
public bool CanGetBalance(string address, BalanceType balanceType, out long calculatedBalance) { calculatedBalance = 0; // TODO: Filter transactions by "transfer successful" IEnumerable <PendingTransaction> transactions = null; if (balanceType == BalanceType.Pending) { transactions = this.GetAllTransactions(address); if (!transactions.Any()) { return(false); } } else if (balanceType == BalanceType.LastMined) { transactions = this.blockService.GetConfirmedTransactions(address); if (!transactions.Any()) { return(false); } } else if (balanceType == BalanceType.Confrimed) { transactions = this.blockService.GetConfrimedTransactions(address, blockConfirmationsCount); if (!transactions.Any()) { return(false); } } foreach (var tran in transactions) { if (tran.To == address) { calculatedBalance += tran.Value; } else if (tran.From == address) { calculatedBalance -= tran.Value; calculatedBalance -= tran.Fee; } } return(true); }
public IList<BalancePerSubCategory> GetBalancePerSubCategory(DateTime dateFrom, DateTime dateTo, BalanceType type, string categoryName) { using (var dbContext = new DatabaseContext()) { var category = dbContext.Category.FirstOrDefault(x => x.Name == categoryName); if (category == null) return new List<BalancePerSubCategory>(); var transactions = dbContext.Transactions.Include(x => x.SubCategory); return (from t in transactions where t.Date >= dateFrom && t.Date < dateTo && t.SubCategory.Category.Id == category.Id group t by t.SubCategory into gr select new { SubCategory = gr.Key, Debit = gr.Sum(x => x.Debit), Credit = gr.Sum(x => x.Credit) }) .ToList() .Where(x => type == BalanceType.Credit ? x.Credit > 0 : x.Debit > 0) .Select(x => new BalancePerSubCategory { SubCategory = x.SubCategory, Amount = type == BalanceType.Credit ? x.Credit : x.Debit }) .OrderBy(x => x.SubCategory.DisplayOrder) .ToList(); } }
/// <summary> /// /// </summary> /// <param name="balancec"></param> /// <param name="a"></param> /// <param name="w"></param> /// <param name="vl"></param> /// <param name="vr"></param> /// <param name="rconde"></param> /// <param name="rcondv"></param> public void EigenValsX(BalanceType balancec, NRealMatrix a, NComplexMatrix w, NComplexMatrix vl, NComplexMatrix vr, NRealMatrix rconde, NRealMatrix rcondv) { _lib.eigenValsX(Convert.ToInt16(balancec), a.ManagedMatrix, w.ManagedMatrix, vl.ManagedMatrix, vr.ManagedMatrix, rconde.ManagedMatrix, rcondv.ManagedMatrix); }
/// <summary> /// Returns the balance of this wallet as calculated by the provided balanceType. /// </summary> public ulong GetBalance(BalanceType balanceType) { lock (this) { var available = 0UL; foreach (var tx in Unspent.Values) { foreach (var output in tx.Outputs) { if (!output.IsMine(this)) continue; if (!output.IsAvailableForSpending) continue; available += output.Value; } } if (balanceType == BalanceType.Available) return available; Debug.Assert(balanceType == BalanceType.Estimated); // Now add back all the pending outputs to assume the transaction goes through. var estimated = available; foreach (var tx in Pending.Values) { foreach (var output in tx.Outputs) { if (!output.IsMine(this)) continue; estimated += output.Value; } } return estimated; } }
/// <summary> /// Returns the balance of this wallet as calculated by the provided balanceType. /// </summary> public ulong GetBalance(BalanceType balanceType) { lock (this) { var available = (from transaction in Unspent.Values from transactionOutput in transaction.TransactionOutputs where transactionOutput.IsMine(this) where transactionOutput.IsAvailableForSpending select transactionOutput).Aggregate(0UL, (current, transactionOutput) => current + transactionOutput.Value); if (balanceType == BalanceType.Available) return available; Debug.Assert(balanceType == BalanceType.Estimated); // Now add back all the pending outputs to assume the transaction goes through. return (from transaction in Pending.Values from transactionOutput in transaction.TransactionOutputs where transactionOutput.IsMine(this) select transactionOutput).Aggregate(available, (current, transactionOutput) => current + transactionOutput.Value); } }
private Element(Element e, bool UseClone) { this.id = e.id; this.prefix = e.prefix; this.nameWithNSPrefix = e.nameWithNSPrefix; this.name = e.name; this.type = e.type; this.origElementType = e.origElementType; this.substGroup = e.substGroup; this.attributeType = e.attributeType; this.isNull = e.isNull; this.tuple = e.tuple; this.nillable = e.nillable; this.perType = e.perType; this.balType = e.balType; this.abst = e.abst; this.typedDimensionId = e.typedDimensionId; //this.tupleChildren = e.tupleChildren; // need to do a deep copy - the IM taxonomy on .NET 2.0 children are pointing to the wrong parent // this didn't seem to make a difference, but I think it's a good thing, so I'm going to leave it in if (UseClone) { if (e.tupleChildren != null) { tupleChildren = new SortedList(); IDictionaryEnumerator enumer = e.tupleChildren.GetEnumerator(); while (enumer.MoveNext()) { this.AddChild((double)enumer.Key, (Element)((Element)enumer.Value).Clone()); } } if (e.tupleParentList != null) { tupleParentList = new List<Element>(); foreach( Element tp in e.tupleParentList ) { if (tp.id == this.id) { tupleParentList.Add(this); } else { tupleParentList.Add(tp.Clone() as Element); } } } } else { this.tupleChildren = e.tupleChildren; this.tupleParentList = e.tupleParentList; } this.labelInfo = e.labelInfo; this.referenceInfo = e.referenceInfo; this.taxonomyInfoId = e.taxonomyInfoId; this.markupValues = e.markupValues; this.EnumData = e.EnumData; this.IsAucentExtendedElement = e.IsAucentExtendedElement; this.HasCompleteTupleFamily = e.HasCompleteTupleFamily; this.isChoice = e.isChoice; this.UseChoiceIcon = e.UseChoiceIcon; this.ChoiceContainer = e.ChoiceContainer; this.childrenInfo = e.childrenInfo; }
/// <summary> /// Attempts to parse a Balance given a string and the type of balance expected. /// </summary> /// <param name="balanceText">The text to attempt to parse.</param> /// <param name="expectedBalanceType">The type of balance expected. If null, 'CR' or 'DR' must be specified in the balance text.</param> /// <param name="resultBalance">If parsing is sucessful, this will contain the parsed balance.</param> /// <returns>True if the text could be parsed, otherwise false.</returns> public static bool TryParse(string balanceText, BalanceType? expectedBalanceType, out Balance resultBalance) { bool result = true; decimal magnitude = 0M; BalanceType type = BalanceType.Credit; balanceText = (balanceText ?? string.Empty).Trim().ToUpper(); // What type of balance is it? if (balanceText.EndsWith("CR")) { type = BalanceType.Credit; balanceText = balanceText.Substring(0, balanceText.Length - 2); } else if (balanceText.EndsWith("DR")) { type = BalanceType.Debit; balanceText = balanceText.Substring(0, balanceText.Length - 2); } else { if (expectedBalanceType != null && expectedBalanceType.HasValue) { type = expectedBalanceType.Value; } else { result = false; } } // Get the value (magnitude) of the balance if (result == true) { result = decimal.TryParse(balanceText.Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out magnitude); magnitude = Math.Abs(magnitude); } resultBalance = new Balance(magnitude, type); return result; }
/// <summary> /// Constructor. /// </summary> /// <param name="value">The value of the balance.</param> /// <param name="type">The type of balance.</param> public Balance(decimal value, BalanceType type) { this.Magnitude = value; this.BalanceType = type; }
/// <summary> /// Populates optional properties for this <see cref="Element"/>. /// </summary> /// <param name="typeArg">The value to be assigned to this <see cref="Element"/>'s type property.</param> /// <param name="nillit">The value to be assigned to this <see cref="Element"/>'s nillable property.</param> /// <param name="pt">The value to be assigned to this <see cref="Element"/>'s period type property.</param> /// <param name="bt">The value to be assigned to this <see cref="Element"/>'s balance type property.</param> /// <param name="abs">The value to be assigned to this <see cref="Element"/>'s abstract property.</param> public void AddOptionals(string typeArg, bool nillit, PeriodType pt, BalanceType bt, bool abs) { this.type = typeArg; this.nillable = nillit; this.perType = pt; this.balType = bt; this.abst = abs; }
/// <summary> /// Replaces key properties of this <see cref="Element"/> with equivalent properties /// in a parameter-supplied <see cref="Element"/>. /// </summary> /// <param name="newElemInfo">The <see cref="Element"/> from which property values are /// to be copied.</param> /// <remarks> /// The following properties are copied: /// <bl> /// <li>Nillable.</li> /// <li>Period type.</li> /// <li>Balance type.</li> /// <li>Abstract.</li> /// <li>Type.</li> /// <li>Minimum occurrences.</li> /// <li>Maximum occurrences.</li> /// </bl> /// </remarks> public void Update(Element newElemInfo) { this.nillable = newElemInfo.nillable; this.perType = newElemInfo.perType; this.balType = newElemInfo.balType; this.abst = newElemInfo.abst; this.type = newElemInfo.type; this.origElementType = newElemInfo.origElementType; }
/// <summary> /// Parses a Balance given a string and the type of balance expected. /// </summary> /// <param name="balanceText">The text to attempt to parse.</param> /// <param name="expectedBalanceType">The type of balance expected. If null, 'CR' or 'DR' must be specified in the balance text.</param> /// <returns>The parsed balance.</returns> /// <exception cref="FormatException" /> public static Balance Parse(string balanceText, BalanceType? expectedBalanceType) { Balance result = null; if (!TryParse(balanceText, expectedBalanceType, out result)) { throw new FormatException(); } return result; }
/// <summary> /// Creates and returns a new monetary <see cref="Element"/>. /// </summary> /// <param name="name">The name to be assigned to the newly created <see cref="Element"/>.</param> /// <param name="nillable">Indicates if the newly-created <see cref="Element"/> is to be nillable.</param> /// <param name="perType">The period type to be assigned to the newly created <see cref="Element"/>.</param> /// <param name="balType">The balance type to be assigned to the newly created <see cref="Element"/>.</param> /// <returns>The newly-created <see cref="Element"/>.</returns> public static Element CreateMonetaryElement(string name, bool nillable, BalanceType balType, PeriodType perType) { Element e = new Element(name); e.substGroup = SUBST_ITEM_TYPE; e.type = MONETARY_ITEM_TYPE; e.nillable = nillable; e.PerType = perType; e.BalType = balType; e.attributeType = AttributeType.numeric; return e; }