private void UpdateTotalsRow() { if (m_TotalsItem == null) { return; } m_TotalsItem.ItemData = CreateSpecialItem_Totals(); m_TotalsItem.Quantity = 0; ItemRecord totalRecord = m_TotalsItem.ItemData; foreach (MainListItem listItem in m_ItemList) { if (listItem.TypeID == SpecialTypeID_Totals) { continue; } ItemRecord currRecord = listItem.ItemData; lock (currRecord) { m_TotalsItem.Quantity += listItem.Quantity; m_TotalsItem.ItemData.Volume += listItem.Quantity * currRecord.Volume; bool isPriceExpired = !currRecord.IsPricesOk(m_Engine.m_Settings.PriceLoad.Items.ExpiryDays); bool isZeroPrice = (currRecord.Price == 0); if (!isPriceExpired && !isZeroPrice) { totalRecord.Price += listItem.Quantity * currRecord.Price; } for (int i = 0; i < currRecord.MaterialAmount.Count(); i++) { double currAmount = m_Engine.GetPerfectRefiningQuota(currRecord, listItem.Quantity, (Materials)i); totalRecord.MaterialAmount[i] += currAmount; } } } }
private void LoadMineralCompositions(Hashtable a_Items) { String sqlText = "SELECT * FROM " + Tables.invTypeMaterials; SQLiteCommand sqlCommand = new SQLiteCommand(sqlText, m_DbConnection); SQLiteDataReader dataReader = sqlCommand.ExecuteReader(); // Optimization: accessing columns by index (saves over 1 sec) bool idx_Inited = false; int idx_typeID = 0, idx_materialTypeID = 0, idx_Quantity = 0; while (dataReader.Read()) { if (!idx_Inited) { idx_Inited = true; idx_typeID = dataReader.GetOrdinal("typeID"); idx_materialTypeID = dataReader.GetOrdinal("materialTypeID"); idx_Quantity = dataReader.GetOrdinal("Quantity"); } UInt32 currTypeID = (UInt32)dataReader.GetInt32(idx_typeID); UInt32 currMaterialID = (UInt32)dataReader.GetInt32(idx_materialTypeID); UInt32 currQuantity = (UInt32)dataReader.GetInt32(idx_Quantity); if (!a_Items.ContainsKey(currTypeID)) { a_Items.Add(currTypeID, new ItemRecord(currTypeID)); } ItemRecord currItem = (ItemRecord)a_Items[currTypeID]; Materials currMaterial = LookupMaterial(currMaterialID); if (Materials.Unknown == currMaterial) { currItem.HasUnknownMaterials = true; } else { currItem.MaterialAmount[(UInt32)currMaterial] = currQuantity; } } }
/// <summary> /// Gets various prices and colors for an item /// </summary> /// <param name="a_Item">Item in question</param> /// <param name="a_Quantity">Quantity of the item</param> /// <param name="a_QuantityOK">true means that quantity is valid (ie assets mode + use quantities enabled)</param> /// <returns>Prices and color</returns> public ItemPrice GetItemPrices(ItemRecord a_Item, RefiningMutators a_Mutators, UInt32 a_Quantity) { ItemPrice result = new ItemPrice(); result.RefinedCost = GetItemRefinedPrice(a_Item, a_Mutators, a_Quantity); result.MarketPrice = a_Quantity * a_Item.Price; bool isError = false; if (0 == a_Item.MarketGroupID) { result.MarketPrice = ItemPrice.NonMarket; isError = true; } else if (0 == result.MarketPrice) { result.MarketPrice = ItemPrice.Unknown; isError = true; } else if (!a_Item.IsPricesOk(m_Settings.PriceLoad.Items.ExpiryDays)) { result.MarketPrice = ItemPrice.Outdated; isError = true; } else { result.PriceDelta = result.RefinedCost - result.MarketPrice; } if (isError) { result.PriceDelta = ItemPrice.Empty; } return(result); }
private void LoadItemsProperties(Hashtable a_Items) { ////////////////////////////////////////////////////////////////////////// // Optimization: do everything in one super-query (saves over 2.5 sec) // unfortunately Data.SQLite has tremendous per-query overhead String[] typeIDs = new String[a_Items.Count]; int typeIdIndex = 0; foreach (Object currKey in a_Items.Keys) { typeIDs[typeIdIndex++] = ((UInt32)currKey).ToString(); } String typeIdList = String.Join(",", typeIDs); ////////////////////////////////////////////////////////////////////////// // Load .ItemName, .IsPublished, .GroupID, .MarketGroupID, .BatchSize, .Volume { String tableMetaLevel = "MetaLevel"; String tableRefineSkill = "RefineSkill"; String sqlText = "SELECT\n" + " "+ DbField(Tables.invTypes, "typeID") + ",\n" + // 0 " "+ DbField(Tables.invTypes, "typeName") + ",\n" + // 1 " "+ DbField(Tables.invTypes, "published") + ",\n" + // 2 " "+ DbField(Tables.invTypes, "groupID") + ",\n" + // 3 " "+ DbField(Tables.invTypes, "marketGroupID") + ",\n" + // 4 " "+ DbField(Tables.invTypes, "portionSize") + ",\n" + // 5 " "+ DbField(Tables.invTypes, "volume") + ",\n" + // 6 " "+ DbField(Tables.invCategories, "CategoryName") + ",\n" + // 7 " "+ DbField(Tables.invGroups, "GroupName") + ",\n" + // 8 " "+ DbField(tableMetaLevel, "valueInt") + ",\n" + // 9 " "+ DbField(tableMetaLevel, "valueFloat") + ",\n" + // 10 " "+ DbField(tableRefineSkill, "valueInt") + ",\n" + // 11 " "+ DbField(tableRefineSkill, "valueFloat") + "\n" + // 12 "FROM \n" + " "+ Tables.invTypes + "\n" + " INNER JOIN "+ Tables.invGroups + " ON (" + DbField(Tables.invGroups, "GroupID") + " = " + DbField(Tables.invTypes, "GroupID") + ")\n" + " INNER JOIN "+ Tables.invCategories + " ON (" + DbField(Tables.invCategories, "CategoryID") + " = " + DbField(Tables.invGroups, "CategoryID") + ")\n" + " LEFT JOIN "+ Tables.dgmTypeAttributes + " " + tableMetaLevel + " ON ((" + DbField(tableMetaLevel, "typeID") + " = " + DbField(Tables.invTypes, "typeID") + ") AND (" + DbField(tableMetaLevel, "attributeID") + " = " + (int)EveAttributes.MetaLevel + "))\n" + " LEFT JOIN "+ Tables.dgmTypeAttributes + " " + tableRefineSkill + " ON ((" + DbField(tableRefineSkill, "typeID") + " = " + DbField(Tables.invTypes, "typeID") + ") AND (" + DbField(tableRefineSkill, "attributeID") + " = " + (int)EveAttributes.ReprocessingSkill + "))\n" + "WHERE\n" + " ("+ Tables.invTypes + ".typeID IN (" + typeIdList + "))\n" + ""; SQLiteCommand sqlCommand = new SQLiteCommand(sqlText, m_DbConnection); SQLiteDataReader dataReader = sqlCommand.ExecuteReader(); while (dataReader.Read()) { UInt32 currTypeID = (UInt32)dataReader.GetInt32(0); ItemRecord currItem = (ItemRecord)a_Items[currTypeID]; currItem.ItemName = (String)dataReader[1]; currItem.IsPublished = (0 != dataReader.GetInt32(2)); currItem.GroupID = (UInt32)dataReader.GetInt32(3); currItem.MarketGroupID = dataReader.IsDBNull(4) ? 0 : (UInt32)dataReader.GetInt32(4); currItem.BatchSize = (UInt32)dataReader.GetInt32(5); currItem.Volume = dataReader.GetDouble(6); String categoryName = dataReader.GetString(7); String groupName = dataReader.GetString(8); currItem.TypeSortString = categoryName + " " + groupName + " " + currItem.ItemName; if (!dataReader.IsDBNull(9)) { currItem.MetaLevel = (UInt32)dataReader.GetInt32(9); } else if (!dataReader.IsDBNull(10)) { currItem.MetaLevel = (UInt32)dataReader.GetFloat(10); } if (!dataReader.IsDBNull(11)) { currItem.RefineSkill = (UInt32)dataReader.GetInt32(11); } else if (!dataReader.IsDBNull(12)) { currItem.RefineSkill = (UInt32)dataReader.GetFloat(12); } } } }
/// <summary> /// Gets amount of material after refining with your efficiency and skill /// Refines incomplete batches too /// </summary> public double GetEffectiveRefineQuota(ItemRecord a_Item, RefiningMutators a_Mutators, UInt32 a_Quantity, Materials a_Material) { double perfectRefinedAmount = GetPerfectRefiningQuota(a_Item, a_Quantity, a_Material); return(GetEffectiveRefineQuota(a_Item, a_Mutators, perfectRefinedAmount)); }
/// <summary> /// Gets amount of material after perfect refining /// Refines incomplete batches too /// </summary> public double GetPerfectRefiningQuota(ItemRecord a_Item, UInt32 a_Quantity, Materials a_Material) { return((a_Quantity * a_Item.MaterialAmount[(UInt32)a_Material]) / a_Item.BatchSize); }
public double GetEffectiveRefineQuota(ItemRecord a_Item, RefiningMutators a_Mutators, double a_PerfectAmount) { return(a_PerfectAmount * GetEffectiveYield(a_Item, a_Mutators)); }
public double GetEffectiveYield(ItemRecord a_Item, RefiningMutators a_Mutators) { double skillBonus = GetRefiningSkillBonus(a_Item, a_Mutators); return(m_Settings.Refining.BaseYield * skillBonus * m_Settings.Refining.TaxMultiplier); }
private static void DbRecordToItemRecord(ItemPrices.PricesRow a_DbRecord, ItemRecord a_ItemRecord) { lock (a_ItemRecord) { a_ItemRecord.PriceDate = DateTime.FromFileTimeUtc(Convert.ToInt64(a_DbRecord.UpdateTime)); a_ItemRecord.Price = a_DbRecord.Price; } }