internal static List <AccountGroupGNP> GetGroupNetPosition(XmlNode netXmlNode) { if (netXmlNode == null) { return(null); } List <AccountGroupGNP> accountGroups = new List <AccountGroupGNP>(); foreach (XmlNode groupNode in netXmlNode.ChildNodes) { Guid groupId = new Guid(groupNode.Attributes["ID"].Value); string groupCode = groupNode.Attributes["Code"].Value; AccountGroupGNP accountGroupGNP = new AccountGroupGNP(groupId, groupCode); foreach (XmlNode accountNode in groupNode.ChildNodes[0].ChildNodes) { Guid accountId = new Guid(accountNode.Attributes["ID"].Value); string accountCode = accountNode.Attributes["Code"].Value; AccountType type = (AccountType)Enum.ToObject(typeof(AccountType), int.Parse(accountNode.Attributes["Type"].Value)); AccountGNP accountGNP = new AccountGNP(accountId, accountCode, type); foreach (XmlNode instrumentNode in accountNode.ChildNodes[0].ChildNodes) { Guid instrumentId = new Guid(instrumentNode.Attributes["ID"].Value); decimal lotBalance = decimal.Parse(instrumentNode.Attributes["LotBalance"].Value); decimal quantity = decimal.Parse(instrumentNode.Attributes["Quantity"].Value); decimal buyQuantity = decimal.Parse(instrumentNode.Attributes["BuyQuantity"].Value); string buyAveragePrice = instrumentNode.Attributes["BuyAveragePrice"].Value; decimal buyMultiplyValue = decimal.Parse(instrumentNode.Attributes["BuyMultiplyValue"].Value); decimal sellQuantity = decimal.Parse(instrumentNode.Attributes["SellQuantity"].Value); string sellAveragePrice = instrumentNode.Attributes["SellAveragePrice"].Value; decimal sellMultiplyValue = decimal.Parse(instrumentNode.Attributes["SellMultiplyValue"].Value); decimal sellLot = decimal.Parse(instrumentNode.Attributes["SellLot"].Value); decimal buyLot = decimal.Parse(instrumentNode.Attributes["BuyLot"].Value); decimal sellSumEl = decimal.Parse(instrumentNode.Attributes["SellSumEl"].Value); decimal buySumEl = decimal.Parse(instrumentNode.Attributes["BuySumEl"].Value); InstrumentGNP instrumentGNP = new InstrumentGNP(instrumentId); instrumentGNP.LotBalance = lotBalance; instrumentGNP.Quantity = quantity; instrumentGNP.BuyQuantity = buyQuantity; instrumentGNP.BuyAveragePrice = buyAveragePrice; instrumentGNP.BuyMultiplyValue = buyMultiplyValue; instrumentGNP.SellQuantity = sellQuantity; instrumentGNP.SellAveragePrice = sellAveragePrice; instrumentGNP.SellMultiplyValue = sellMultiplyValue; instrumentGNP.SellLot = sellLot; instrumentGNP.BuyLot = buyLot; instrumentGNP.SellSumEl = sellSumEl; instrumentGNP.BuySumEl = buySumEl; accountGNP.InstrumentGNPs.Add(instrumentGNP); } accountGroupGNP.AccountGNPs.Add(accountGNP); } accountGroups.Add(accountGroupGNP); } return(accountGroups); }
public static List<AccountGroupGNP> GetGroupNetPosition() { List<AccountGroupGNP> accountGroups = new List<AccountGroupGNP>(); try { string xmlPath = GetCommandXmlPath("NetPosition"); XmlDocument doc = new XmlDocument(); doc.Load(xmlPath); XmlNode netXmlNode = doc.ChildNodes[1].ChildNodes[0]; foreach (XmlNode groupNode in netXmlNode.ChildNodes) { Guid groupId = new Guid(groupNode.Attributes["ID"].Value); string groupCode = groupNode.Attributes["Code"].Value; AccountGroupGNP accountGroupGNP = new AccountGroupGNP(groupId, groupCode); foreach (XmlNode accountNode in groupNode.ChildNodes[0].ChildNodes) { Guid accountId = new Guid(accountNode.Attributes["ID"].Value); string accountCode = accountNode.Attributes["Code"].Value; AccountType type = (AccountType)Enum.ToObject(typeof(AccountType), int.Parse(accountNode.Attributes["Type"].Value)); AccountGNP accountGNP = new AccountGNP(accountId, accountCode, type); foreach (XmlNode instrumentNode in accountNode.ChildNodes[0].ChildNodes) { Guid instrumentId = new Guid(instrumentNode.Attributes["ID"].Value); decimal lotBalance = decimal.Parse(instrumentNode.Attributes["LotBalance"].Value); decimal quantity = decimal.Parse(instrumentNode.Attributes["Quantity"].Value); decimal buyQuantity = decimal.Parse(instrumentNode.Attributes["BuyQuantity"].Value); string buyAveragePrice = instrumentNode.Attributes["BuyAveragePrice"].Value; decimal buyMultiplyValue = decimal.Parse(instrumentNode.Attributes["BuyMultiplyValue"].Value); decimal sellQuantity = decimal.Parse(instrumentNode.Attributes["SellQuantity"].Value); string sellAveragePrice = instrumentNode.Attributes["SellAveragePrice"].Value; decimal sellMultiplyValue = decimal.Parse(instrumentNode.Attributes["SellMultiplyValue"].Value); InstrumentGNP instrumentGNP = new InstrumentGNP(instrumentId); instrumentGNP.LotBalance = lotBalance; instrumentGNP.Quantity = quantity; instrumentGNP.BuyQuantity = buyQuantity; instrumentGNP.BuyAveragePrice = buyAveragePrice; instrumentGNP.BuyMultiplyValue = buyMultiplyValue; instrumentGNP.SellQuantity = sellQuantity; instrumentGNP.SellAveragePrice = sellAveragePrice; instrumentGNP.SellMultiplyValue = sellMultiplyValue; accountGNP.InstrumentGNPs.Add(instrumentGNP); } accountGroupGNP.AccountGNPs.Add(accountGNP); } accountGroups.Add(accountGroupGNP); } } catch (Exception ex) { } return accountGroups; }
private Dictionary <Guid, AccountGroupGNP> BuildAccountGroupDict(DataSet dataSet, Guid[] instrumentIDs, string[] blotterCodeSelecteds) { DataRowCollection accountDataRowCollection = dataSet.Tables[0].Rows; Dictionary <Guid, AccountGroupGNP> accountgroupDict = new Dictionary <Guid, AccountGroupGNP>(accountDataRowCollection.Count); foreach (DataRow dataRow in accountDataRowCollection) { Guid accountID = (Guid)dataRow["AccountID"]; string accountCode = dataRow["AccountCode"].ToString(); Guid groupID = (Guid)dataRow["GroupID"]; string groupCode = dataRow["GroupCode"].ToString(); this.InitAccount(accountID); AccountGroupGNP group; if (accountgroupDict.ContainsKey(groupID)) { group = accountgroupDict[groupID]; } else { group = new AccountGroupGNP(groupID, groupCode); accountgroupDict.Add(groupID, group); } var account = AccountRepository.Default.Get(accountID); var trans = account.GetTrans(instrumentIDs); if (trans.Count > 0) { Dictionary <Guid, InstrumentGNP> instrumentGNPDict = this.BuildInstrumentGNPDict((Account)account, trans, blotterCodeSelecteds); if (instrumentGNPDict.Count > 0) { AccountGNP accountGNP = new AccountGNP(account.Id, account.Code, account.Type); accountGNP.instrumentGNPs = instrumentGNPDict; group.accountGNPs.Add(account.Id, accountGNP); } } } return(accountgroupDict); }