private EMMADataSet.TransactionsRow BuildTransRow(long transID, EMMADataSet.TransactionsDataTable transData, XmlNode transEntry, short walletID, SortedList<long, string> nameIDs, bool rowInDatabase) { EMMADataSet.TransactionsRow newRow = transData.NewTransactionsRow(); newRow.ID = transID; // Set the simple data. i.e. direct conversion from XML field to database field. newRow.DateTime = DateTime.Parse(transEntry.SelectSingleNode("@transactionDateTime").Value); newRow.Quantity = int.Parse(transEntry.SelectSingleNode("@quantity").Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.ItemID = int.Parse(transEntry.SelectSingleNode("@typeID").Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.Price = Decimal.Parse(transEntry.SelectSingleNode("@price").Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.StationID = long.Parse(transEntry.SelectSingleNode("@stationID").Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.RegionID = Stations.GetStation(newRow.StationID).regionID; // Get the data to work out the more complicated fields.. string transType = transEntry.SelectSingleNode("@transactionType").Value; long clientID = long.Parse(transEntry.SelectSingleNode("@clientID").Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); XmlNode node = transEntry.SelectSingleNode("@characterID"); long charID = 0; if (node != null) { charID = long.Parse(node.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); } bool forCorp = transEntry.SelectSingleNode("@transactionFor").Value.Equals("personal") ? false : true; newRow.CalcProfitFromAssets = false; if (transType.ToLower().Equals("buy")) { newRow.BuyerID = forCorp ? _corpID : _charID; newRow.BuyerForCorp = forCorp; newRow.BuyerCharacterID = forCorp ? _charID : 0; newRow.BuyerWalletID = (walletID == 0 ? (short)1000 : walletID); newRow.SellerID = clientID; newRow.SellerForCorp = charID != 0; newRow.SellerCharacterID = charID; newRow.SellerWalletID = 0; newRow.SellerUnitProfit = 0; // Update asset quantities. if (!rowInDatabase) { Assets.BuyAssets(forCorp ? _corpID : _charID, newRow.StationID, newRow.ItemID, newRow.Quantity, newRow.Price, forCorp ? Settings.CorpAssetsEffectiveDate : Settings.CharAssetsEffectiveDate, newRow.DateTime); } } else { newRow.BuyerID = clientID; newRow.BuyerForCorp = charID != 0; newRow.BuyerCharacterID = charID; newRow.BuyerWalletID = 0; newRow.SellerID = forCorp ? _corpID : _charID; newRow.SellerForCorp = forCorp; newRow.SellerCharacterID = forCorp ? _charID : 0; newRow.SellerWalletID = (walletID == 0 ? (short)1000 : walletID); // Calculate transaction profit and update asset quantities. if (!rowInDatabase) { newRow.SellerUnitProfit = Transactions.CalcProfit(forCorp ? _corpID : _charID, transData, newRow, forCorp ? Settings.CorpAssetsEffectiveDate : Settings.CharAssetsEffectiveDate); } } // Get the IDs and associated names in this transaction. if (!nameIDs.ContainsKey(clientID)) { nameIDs.Add(clientID, transEntry.SelectSingleNode("@clientName").Value); } if (charID != 0 && !nameIDs.ContainsKey(charID)) { nameIDs.Add(charID, transEntry.SelectSingleNode("@characterName").Value); } return newRow; }
private EMMADataSet.TransactionsRow BuildTransRow(long transID, EMMADataSet.TransactionsDataTable table, XmlNode node, long corpID, long charID) { EMMADataSet.TransactionsRow newRow = table.NewTransactionsRow(); newRow.ID = transID; // Set the simple data. i.e. direct conversion from XML field to database field. newRow.DateTime = DateTime.Parse(node.SelectSingleNode("DateTime").FirstChild.Value); newRow.Quantity = int.Parse(node.SelectSingleNode("Quantity").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.ItemID = int.Parse(node.SelectSingleNode("ItemID").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.Price = Decimal.Parse(node.SelectSingleNode("Price").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.StationID = long.Parse(node.SelectSingleNode("StationID").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); newRow.RegionID = Stations.GetStation(newRow.StationID).regionID; // Get the data to work out the more complicated fields.. string transType = node.SelectSingleNode("TransactionType").FirstChild.Value; long clientID = long.Parse(node.SelectSingleNode("ClientID").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); XmlNode charNode = node.SelectSingleNode("CharacterID").FirstChild; long charID2 = 0; if (charNode != null) { charID2 = long.Parse(charNode.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat); } bool forCorp = bool.Parse(node.SelectSingleNode("ForCorp").FirstChild.Value); // bug fix newRow.CalcProfitFromAssets = false; newRow.SellerUnitProfit = 0; if (transType.Trim().ToLower().Equals("buy")) { newRow.BuyerID = forCorp ? corpID : charID; newRow.BuyerForCorp = forCorp; newRow.BuyerCharacterID = forCorp ? charID : 0; newRow.BuyerWalletID = short.Parse(node.SelectSingleNode("WalletID").FirstChild.Value); newRow.SellerID = clientID; newRow.SellerForCorp = charID2 != 0; newRow.SellerCharacterID = charID2; newRow.SellerWalletID = 0; } else { newRow.BuyerID = clientID; newRow.BuyerForCorp = charID2 != 0; newRow.BuyerCharacterID = charID2; newRow.BuyerWalletID = 0; newRow.SellerID = forCorp ? corpID : charID; newRow.SellerForCorp = forCorp; newRow.SellerCharacterID = forCorp ? charID : 0; newRow.SellerWalletID = short.Parse(node.SelectSingleNode("WalletID").FirstChild.Value); } return newRow; }