private void GeneratePercentTable(IncomeDistributionReport obj, List <Dataset> datasetList, List <Note> notes, DateTime[] paymentDates) { obj.PrincipalTable = new List <CashItem>(); var rowCount = Math.Min(datasetList.Count, paymentDates.Length); for (int i = 0; i < datasetList.Count; ++i) { var dataset = datasetList[i]; var cashItem = new CashItem(); var noteDatas = m_dbAdapter.Dataset.GetNoteDatas(dataset.DatasetId); cashItem.Date = dataset.PaymentDate.Value; cashItem.Percent = new Dictionary <string, decimal>(); foreach (var noteData in noteDatas) { var note = notes.Single(x => x.NoteId == noteData.NoteId); CommUtils.AssertNotNull(noteData.PrincipalPaid, "请核兑付日为[{0}]期的相关数据,才能够生成本期报告", dataset.PaymentDate.Value.ToString("yyyy-MM-dd")); cashItem.Percent[note.ShortName] = noteData.PrincipalPaid.Value / note.Notional.Value; } obj.PrincipalTable.Add(cashItem); } obj.PrincipalTable.Reverse(); obj.SumPrincipalTable = new CashItem(); obj.SumPrincipalTable.Percent = new Dictionary <string, decimal>(); foreach (var note in notes) { obj.SumPrincipalTable.Percent[note.ShortName] = obj.PrincipalTable.Sum(x => x.Percent[note.ShortName]); } }
public async Task <TValue> GetValue(TKey key) { lock (_items) { if (_items.ContainsKey(key)) { return(_items[key].Value); } } var newValue = await _getValue(key); lock (_items) { if (_items.ContainsKey(key)) { return(_items[key].Value); } _items.Add(key, CashItem.Create(newValue)); if (_maxSize > 0) { DeleteIfAlot(); } return(newValue); } }
public void AddCashItem(CashItem item) { if (capacity >= current + item.Value && GemItemsValue >= CashItemsValue + item.Value) { var cashItems = GetCashItems(); if (cashItems.Any(gi => gi.Key == item.Key)) { cashItems.Single(gi => gi.Key == item.Key).IncreaseValue(item.Value); } else { bag.Add(item); } current += item.Value; } }
public void CanCreateCashItem() { try { string name = "TestItem"; decimal value = 12m; CashItem item = new CashItem(name, value); Assert.IsNotNull(item); Assert.AreEqual(value, item.UnitValue); } catch { Assert.Fail(); } }
private static void InsertItem(string key, long value, Bag bag) { if (key.Length == 3) { CashItem cash = new CashItem(key, value); bag.AddCashItem(cash); } else if (key.Length >= 4 && key.ToLower().EndsWith("gem")) { GemItem gem = new GemItem(key, value); bag.AddGemItem(gem); } else if (key.ToLower().Equals("gold")) { GoldItem gold = new GoldItem(key, value); bag.AddGoldItem(gold); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); CashItem targetItem = (CashItem)target; serializedObject.Update(); SerializedProperty CashItemType = serializedObject.FindProperty("profile"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(CashItemType); if (EditorGUI.EndChangeCheck()) { // Code to execute if GUI.changed serializedObject.ApplyModifiedProperties(); foreach (CashItem target in targets) { ((CashItem)target).profile = targetItem.profile; ((CashItem)target).UpdateFromProfile(); } } }