private DataRow findRow(DataRowCollection rows, Type type, string keyvalue) { DataRow row = null; if (type != typeof(Guid)) { row = rows.Find(Convert.ChangeType(keyvalue, type)); } else { row = rows.Find(new Guid(keyvalue)); } return row; }
private IPropertyCollection GetPropertiesFromDataRows(DataRowCollection rows, IContext context, ITransaction transaction) { var schema = (context == null || string.IsNullOrEmpty(context.Name) ? GetDefaultContextSchema() : GetContextSchema(context.Name, transaction)); var propertyList = new List<IProperty>(); foreach(var pd in schema) { string propertyValue = null; var propertyName = pd.PropertyName; var propertyType = pd.PropertyType; var currentField = (rows != null ? rows.Find(pd.PropertyName) : null); if(currentField != null) { if(!currentField.IsNull("PropertyValue")) { propertyValue = (string)currentField["PropertyValue"]; } else { propertyValue = (string)currentField["ExtendedPropertyValue"]; } } var property = PropertyFactory.Create(propertyName, propertyValue, propertyType, context); if(property != null) { propertyList.Add(property); } } return new PropertyCollection(propertyList, schema); }
private void ParseAccountData(XmlNode accountsData, DataRowCollection orders, Dictionary<Guid, Transaction> exectuedTransactions, out AccountBalance[] accountBalances, out AccountCurrency[] accountCurrencies, out Contract[] contracts) { accountBalances = null; accountCurrencies = null; contracts = null; if (accountsData != null) { accountBalances = new AccountBalance[accountsData.ChildNodes.Count]; List<AccountCurrency> accountCurrencyList = new List<AccountCurrency>(); List<Contract> contractList = new List<Contract>(); int index = 0; foreach (XmlElement account in accountsData.ChildNodes) { AccountBalance accountBalance = new AccountBalance(); accountBalance.Initialize(account); accountBalances[index++] = accountBalance; foreach (XmlElement xmlChild in account.ChildNodes) { if (xmlChild.Name == "Currency") { AccountCurrency accountCurrency = new AccountCurrency(); accountCurrency.AccountId = accountBalance.AccountId; accountCurrency.Initialize(xmlChild); accountCurrencyList.Add(accountCurrency); } else if (xmlChild.Name == "Orders") { foreach (XmlElement orderNode in xmlChild.ChildNodes) { Guid orderId = XmlConvert.ToGuid(orderNode.Attributes["ID"].Value); DataRow orderRow = orders.Find(new object[] { orderId }); if (orderRow != null) { Guid transactionId = (Guid)(orderRow["TransactionID"]); if (exectuedTransactions.ContainsKey(transactionId)) { Contract contract = new Contract(); contract.Initialize(orderRow); contract.Initialize(orderNode); contractList.Add(contract); } } } } } } contracts = contractList.ToArray(); accountCurrencies = accountCurrencyList.ToArray(); } }
public static DataRow FindRow(DataRowCollection rows, string type, string keyvalue) { DataRow row = null; if (type == "system.uint" || type == "system.uint32") { row = rows.Find(Convert.ToUInt32(keyvalue)); } else if (type == "system.uint16") { row = rows.Find(Convert.ToUInt16(keyvalue)); } else if (type == "system.uint64") { row = rows.Find(Convert.ToUInt64(keyvalue)); } else if (type == "system.int" || type == "system.int32") { row = rows.Find(Convert.ToInt32(keyvalue)); } else if (type == "system.int16") { row = rows.Find(Convert.ToInt16(keyvalue)); } else if (type == "system.int64") { row = rows.Find(Convert.ToInt64(keyvalue)); } else if (type == "system.single") { row = rows.Find(Convert.ToSingle(keyvalue)); } else if (type == "system.double") { row = rows.Find(Convert.ToDouble(keyvalue)); } else if (type == "system.decimal") { row = rows.Find(Convert.ToDecimal(keyvalue)); } else if (type == "system.datetime") { row = rows.Find(Convert.ToDateTime(keyvalue)); } else { row = rows.Find(keyvalue); } return row; }