private int GetAggregatedPosition(DealerPositionInfo info, int sum, PositionType type) { if (null == info) { return(0); } string positionString = null; switch (type) { case PositionType.Buy: positionString = info.BuyDealers; break; case PositionType.Sell: positionString = info.SellDealers; break; } if (string.IsNullOrWhiteSpace(positionString)) { return(0); } var dealers = positionString.Split(new char[] { ';' }); int length = dealers.Length < sum ? dealers.Length : sum; int result = 0; for (int i = 0; i < length; i++) { var pair = dealers[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (pair.Length < 2) { continue; } result = result + Convert.ToInt32(pair[1]); } return(result); }
public bool ExistIn(DealerPositionInfo another) { if (null == another) { return(false); } string date1 = TransactionDate.ToString(GlobalDefinition.DateFormat, GlobalDefinition.FormatProvider); string date2 = another.TransactionDate.ToString(GlobalDefinition.DateFormat, GlobalDefinition.FormatProvider); bool result = date1.Equals(date2) && Commodity.Equals(another.Commodity) && Month.Equals(another.Month); string dealerList = ""; if (result) { switch (DealerInformationType) { case InformationType.VolumeInfo: dealerList = another.VolumeDealers; break; case InformationType.BuyInfo: dealerList = another.BuyDealers; break; case InformationType.SellInfo: dealerList = another.SellDealers; break; } string dealer; int amount; ExtractDealer(Rank, dealerList, out dealer, out amount); result = DealerName.Equals(dealer) && Amount == amount; } return(result); }