internal static bool CheckMarketOrders() { if (EsiDataInterface.Working()) { return(false); } var updated = false; var blueprints = GetBlueprints(); foreach (var blueprint in blueprints) { if (blueprint.CheckMarketOrders()) { updated = true; } } var assets = GetAssets(); foreach (var asset in assets) { asset.CheckMarketOrders(); } return(updated); }
internal bool CheckMarketOrders(string region) { var updated = false; var esiMarketOrders = EsiDataInterface.GetMarketOrders(Id, region); if (esiMarketOrders == null) { return(updated); } var oldEsiMarketOrders = _esiMarketOrders.FirstOrDefault(x => x.Id == Id && x.Region == region); if (oldEsiMarketOrders == null) { _esiMarketOrders.Add(esiMarketOrders); updated = true; return(updated); } if (Equals(oldEsiMarketOrders, esiMarketOrders)) { return(updated); } _esiMarketOrders.Remove(oldEsiMarketOrders); _esiMarketOrders.Add(esiMarketOrders); updated = true; return(updated); }
private bool CheckMarketOrdersImpl() { var updated = false; var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub)); var esiMarketOrders = EsiDataInterface.GetMarketOrders(Id, region); if (esiMarketOrders == null) { return(updated); } var oldEsiMarketOrders = _esiMarketOrders.FirstOrDefault(x => x.Id == Id && x.Region == region); if (oldEsiMarketOrders == null) { _esiMarketOrders.Add(esiMarketOrders); updated = true; return(updated); } if (Equals(oldEsiMarketOrders, esiMarketOrders)) { return(updated); } _esiMarketOrders.Remove(oldEsiMarketOrders); _esiMarketOrders.Add(esiMarketOrders); updated = true; return(updated); }
internal bool CheckMarketHistory() { var updated = false; var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub)); var esiMarketHistory = EsiDataInterface.GetMarketHistory(Id, region); if (esiMarketHistory == null) { return(updated); } if (_esiMarketHistory == null) { _esiMarketHistory = esiMarketHistory; updated = true; return(updated); } if (Equals(_esiMarketHistory, esiMarketHistory)) { return(updated); } _esiMarketHistory = esiMarketHistory; updated = true; OnMarketHistoryUpdated(); return(updated); }
private static bool CheckMarketerData() { EsiDataInterface.RequestMarketOrders(); return(EoiDataInterface.CheckMarketOrders()); //MarketerDataInterface.RequestBlueprints(); //return EoiDataInterface.CheckMarketerData(); }
internal void Authenticate(RawAccessTokenResponse token) { var verifyResult = EsiDataInterface.Verify(token.access_token); if (verifyResult != null) { VerifyUser(verifyResult, token); } }
public static void Init() { StaticDataInterface.Init(); FileSystemDataInterface.Init(); InitializeEoiData(); EsiDataInterface.Init(); InitEoiDataContent(); }
internal void CheckMarketOrders() { var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub)); var esiMarketOrders = EsiDataInterface.GetMarketOrders(this.Id, region); if (esiMarketOrders == null) { return; } if (_esiMarketOrders == null) { _esiMarketOrders = esiMarketOrders; } else { //if (Equals(_esiMarketOrders, esiMarketOrders)) // return; _esiMarketOrders = esiMarketOrders; } decimal tradeHubPrice = 0; if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Buy) { if (esiMarketOrders != null) { var materialMarketPricesBuyOrders = esiMarketOrders.Orders.Where(x => x.is_buy_order && x.system_id.ToString() == SettingsInterface.GlobalSettings.TradeHub); if (materialMarketPricesBuyOrders.Any()) { tradeHubPrice = materialMarketPricesBuyOrders.Max(x => x.price); } } } else if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Sell) { if (esiMarketOrders != null) { var materialMarketPricesBuyOrders = esiMarketOrders.Orders.Where(x => !x.is_buy_order && x.system_id.ToString() == SettingsInterface.GlobalSettings.TradeHub); if (materialMarketPricesBuyOrders.Any()) { tradeHubPrice = materialMarketPricesBuyOrders.Min(x => x.price); } } } foreach (var eoiAsset in _eoiAssets) { eoiAsset.TradeHubPrice = tradeHubPrice; eoiAsset.PriceChange = eoiAsset.TradeHubPrice - eoiAsset.Price; } }
internal static void Close() { FileSystemDataReader.ExportGlobalSettings(); FileSystemDataReader.ExportUsers(_users); FileSystemDataReader.ExportAssets(_assets); FileSystemDataReader.ExportMarketData(MarketerDataInterface.ExportMarketerDataRequests()); FileSystemDataReader.ExportBlueprints(_blueprints); FileSystemDataReader.ExportMarketHistory(EsiDataInterface.ExportMarketHistory()); FileSystemDataReader.ExportMarketOrders(EsiDataInterface.ExportMarketOrders()); FileSystemDataReader.ExportSolarSystems(EsiDataInterface.ExportSolarSystems()); }
internal void Init() { var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub)); var marketOrders = EsiDataInterface.GetMarketOrders(Id, region); if (marketOrders != null) { _esiMarketOrders.Add(marketOrders); } _fileSystemBlueprint = FileSystemDataInterface.GetBlueprintById(Id); if (_fileSystemBlueprint != null && _fileSystemBlueprint.IsCopy) { this.IsCopy = true; } }
internal static void AuthenticateUser(RawAccessTokenResponse token) { var verifyResult = EsiDataInterface.Verify(token.access_token); if (verifyResult != null) { var user = GetUser(verifyResult.CharacterName); if (user != null) { user.VerifyUser(verifyResult, token); } else { var defaultUser = GetDefaultUser(); if (defaultUser != null) { defaultUser.VerifyUser(verifyResult, token); CreateDefaultUser(); } } } }
internal void Init() { _esiPrice = EsiDataInterface.GetPriceById(Id); if (_esiPrice != null) { AdjustedPrice = _esiPrice.AdjustedPrice; } else { Invalid = true; } var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub)); _esiMarketHistory = EsiDataInterface.GetMarketHistory(Id, region); var esiMarketOrders = EsiDataInterface.GetMarketOrders(Id, region); if (esiMarketOrders != null) { _esiMarketOrders.Add(esiMarketOrders); } }
internal static void Init() { FileSystemDataReader.ImportGlobalSettings(); _users = FileSystemDataReader.ImportUsers(); if (_users == null) { _users = new List <FileSystemDataUser>(); } MarketerDataInterface.ImportMarketerDataRequests(FileSystemDataReader.ImportMarketData()); var fileSystemBlueprints = FileSystemDataReader.ImportBlueprints(); if (fileSystemBlueprints != null) { _blueprints = fileSystemBlueprints; } EsiDataInterface.ImportMarketHistory(FileSystemDataReader.ImportMarketHistory()); EsiDataInterface.ImportMarketOrders(FileSystemDataReader.ImportMarketOrders()); EsiDataInterface.ImportSolarSystems(FileSystemDataReader.ImportSolarSystems()); _assets = FileSystemDataReader.ImportAssets(); if (_assets == null) { _assets = new List <FileSystemDataAsset>(); } if (!_users.Any(x => x.Name == "Default")) { CreateDefaultUser(); } }
internal static bool SynchronizeBlueprints() { var updated = false; if (SettingsInterface.GlobalSettings.EnableEsiBlueprintsUpdates) { BackgroundWorker.Status = new BackgroundWorkerStatus("Synchronisiere Eve Online Blueprints", -1); var users = GetUsers(); if (users.Any(x => x.GetAccessToken() != null)) { EsiDataInterface.ClearBlueprints(); foreach (var user in users) { var token = user.GetAccessToken(); if (token != null && user.Id != 0) { EsiDataInterface.UpdateBlueprints(token, user.Id); } } var blueprints = EsiDataInterface.GetBlueprints(); foreach (var blueprint in _eoiDataBlueprints) { var esiDataBlueprint = blueprints.FirstOrDefault(x => x.Id == blueprint.Id); if (esiDataBlueprint != null) { if (blueprint.Synchronize(esiDataBlueprint)) { updated = true; } } else { if (blueprint.SynchronizedReset()) { updated = true; } } } foreach (var blueprint in _eoiDataBlueprints) { blueprint.UpdateInventable(); } } if (SettingsInterface.GlobalSettings.EnableCorporationBlueprintsUpdates) { BackgroundWorker.Status = new BackgroundWorkerStatus("Synchronisiere Corporation Blueprints", -1); var user = users.FirstOrDefault(x => x.GetAccessToken() != null); if (user != null) { var eoiDataBlueprints = GetBlueprints(); foreach (var blueprint in eoiDataBlueprints) { var bp = blueprint.GetCorporationBlueprint(); if (bp != null) { var success = CorporationWebInterface.SetBlueprint(user.Name, bp); if (!success) { } } } var corpBlueprints = CorporationWebInterface.GetBlueprints(user.Name, user.Name); foreach (var corpBp in corpBlueprints) { var eoiDataBlueprint = eoiDataBlueprints.FirstOrDefault(x => x.Id == corpBp.Id); if (eoiDataBlueprint != null && eoiDataBlueprint.GetCorporationBlueprint() == null) { // Blueprint on Server that should not be there -> Delete CorporationWebInterface.DeleteBlueprint(user.Name, corpBp.Id); } } corpBlueprints = CorporationWebInterface.GetBlueprints(user.Name); _eoiDataBlueprints.Where(x => x.CorporationOwned).ToList().ForEach(x => x.UnsetCorporationBlueprint()); foreach (var bp in corpBlueprints) { var eoiDataBlueprint = _eoiDataBlueprints.FirstOrDefault(x => x.Id == bp.Id); if (eoiDataBlueprint != null) { if (eoiDataBlueprint.SetCorporationBlueprint(bp)) { updated = true; } } } } } } return(updated); }
private static bool CheckMarketHistory() { EsiDataInterface.RequestMarketHistory(); return(EoiDataInterface.CheckMarketHistory()); }
internal static void Calculate(EoiDataBlueprint blueprint) { decimal profit = 0; decimal investment = 0; decimal investmentJita = 0; decimal income = 0; decimal taxes = 0; decimal materialInvestment = 0; decimal materialInvestmentJita = 0; decimal baseTaxInvestment = 0; decimal corporationTaxInvestment = 0; var eoiBlueprint = blueprint.GetEoiBlueprint(); int manufacturingTime = blueprint.GetManufacturingTime(); eoiBlueprint.ProfitPerHour = 0; eoiBlueprint.ExpensesPerHour = 0; eoiBlueprint.IncomePerHour = 0; eoiBlueprint.ProfitPerRun = 0; eoiBlueprint.ExpensesPerRun = 0; eoiBlueprint.IncomePerRun = 0; eoiBlueprint.ProfitPerUnit = 0; eoiBlueprint.ExpensesPerUnit = 0; eoiBlueprint.IncomePerUnit = 0; eoiBlueprint.ExpectedProfitPerHour = 0; eoiBlueprint.Taxes = 0; eoiBlueprint.SalesTaxesPerRun = 0; eoiBlueprint.ProductionBaseTaxPerRun = 0; eoiBlueprint.ProductionBaseTaxPerUnit = 0; eoiBlueprint.ProductionCorporationTaxPerRun = 0; eoiBlueprint.ProductionCorporationTaxPerUnit = 0; eoiBlueprint.MaterialExpensesPerRun = 0; eoiBlueprint.MaterialExpensesPerUnit = 0; eoiBlueprint.BrokerFeesPerRun = 0; eoiBlueprint.SalesPricePerRun = 0; eoiBlueprint.SalesPricePerUnit = 0; eoiBlueprint.BuyPrice = 0; eoiBlueprint.SellPrice = 0; eoiBlueprint.OptimalPrice = 0; eoiBlueprint.OptimalMarketPrice = 0; if (!SettingsInterface.GlobalSettings.EnableAutoUpdater) { return; } var solarSystemCostIndices = EsiDataInterface.GetSolarSystemCostIndices(SolarSystems.Miakie.SolarSysteId); if (solarSystemCostIndices == null) { return; } var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub)); foreach (var material in blueprint.Materials) { var eoiType = eoiBlueprint.Materials.FirstOrDefault(x => material.GetEoiType(x) != null); eoiType.Produced = false; var possible = false; var possibleJita = false; decimal productionCost = 0; decimal productionCostJita = 0; decimal baseTaxCost = 0; decimal corporationTaxCost = 0; decimal materialCost = 0; decimal materialCostJita = 0; taxes += material.AdjustedPrice * blueprint.GetCalculatedMaterialQuantity(1, material); var materialMarketPrices = material.GetMarketPrices().FirstOrDefault(x => x.Region == region); if (SettingsInterface.GlobalSettings.ImportOrderType == OrderType.Buy) { if (materialMarketPrices != null) { var materialMarketPricesBuyOrders = materialMarketPrices.Orders.Where(x => x.is_buy_order && x.system_id.ToString() == SettingsInterface.GlobalSettings.TradeHub); if (materialMarketPricesBuyOrders.Any()) { productionCost = materialMarketPricesBuyOrders.Max(x => x.price); possible = true; } } if (productionCost == 0) { // TODO No Buy Price ... } } else if (SettingsInterface.GlobalSettings.ImportOrderType == OrderType.Sell) { if (materialMarketPrices != null) { var materialMarketOrders = materialMarketPrices.Orders.Where(x => !x.is_buy_order && x.system_id.ToString() == SettingsInterface.GlobalSettings.TradeHub).ToList(); if (materialMarketOrders.Any()) { productionCost = materialMarketOrders.Min(x => x.price); possible = true; } } } var materialMarketPricesJita = material.GetMarketPrices().FirstOrDefault(x => x.Region == Regions.TheForge); if (SettingsInterface.GlobalSettings.ImportOrderType == OrderType.Buy) { if (materialMarketPricesJita != null) { var materialMarketPricesBuyOrders = materialMarketPricesJita.Orders.Where(x => x.is_buy_order && x.system_id.ToString() == SolarSystems.Jita.SolarSysteId.ToString()); if (materialMarketPricesBuyOrders.Any()) { productionCostJita = materialMarketPricesBuyOrders.Max(x => x.price); possibleJita = true; } } if (productionCost == 0) { // TODO No Buy Price ... } } else if (SettingsInterface.GlobalSettings.ImportOrderType == OrderType.Sell) { if (materialMarketPricesJita != null) { var materialMarketOrders = materialMarketPricesJita.Orders.Where(x => !x.is_buy_order && x.system_id.ToString() == SolarSystems.Jita.SolarSysteId.ToString()).ToList(); if (materialMarketOrders.Any()) { productionCostJita = materialMarketOrders.Min(x => x.price); possibleJita = true; } } } if (possible) { materialCost = productionCost; } if (possibleJita) { materialCostJita = productionCostJita; } // Check if Material can be produced var bp = EoiDataInterface.GetBlueprintByProduct(material.Id); if (bp != null && bp.GetMarketPrices().Any(y => y?.Orders.Any(x => !x.is_buy_order) == true)) { BlueprintCalculator.Calculate(bp); var subEoiBlueprint = bp.GetEoiBlueprint(); var blueprintExpenses = subEoiBlueprint.ExpensesPerUnit; if (blueprintExpenses > 0 && productionCost > blueprintExpenses) { materialCost = subEoiBlueprint.MaterialExpensesPerUnit; baseTaxCost = subEoiBlueprint.ProductionBaseTaxPerUnit; corporationTaxCost = subEoiBlueprint.ProductionCorporationTaxPerUnit; taxes += subEoiBlueprint.Taxes; productionCost = subEoiBlueprint.ExpensesPerUnit; possible = true; eoiType.Produced = true; } } if (!possible) { return; } var calculatedMaterialQuantity = blueprint.GetCalculatedMaterialQuantity(1, material); eoiType.Quantity = calculatedMaterialQuantity; eoiType.PricePerUnit = productionCost; eoiType.Price = productionCost * calculatedMaterialQuantity; profit -= productionCost * calculatedMaterialQuantity; investment += productionCost * calculatedMaterialQuantity; investmentJita += productionCostJita * calculatedMaterialQuantity; materialInvestmentJita += materialCostJita * calculatedMaterialQuantity; materialInvestment += materialCost * calculatedMaterialQuantity; baseTaxInvestment += baseTaxCost * calculatedMaterialQuantity; corporationTaxInvestment = +corporationTaxCost * calculatedMaterialQuantity; } eoiBlueprint.MaterialExpensesPerRun = materialInvestment; eoiBlueprint.MaterialExpensesPerRunJita = materialInvestmentJita; if (solarSystemCostIndices != null) { var solarSystemTax = Math.Round(Math.Round(taxes) * solarSystemCostIndices.GetManufacturingCostIndex()); var structureBonus = Math.Floor(solarSystemTax * (SettingsInterface.GlobalSettings.StructureTaxBonus / 100)); solarSystemTax -= structureBonus; baseTaxInvestment += solarSystemTax; var corpTax = solarSystemTax * (SettingsInterface.GlobalSettings.IndustryTax / 100); corporationTaxInvestment += corpTax; eoiBlueprint.Taxes = Math.Round(solarSystemTax + corpTax); investment += eoiBlueprint.Taxes; investmentJita += eoiBlueprint.Taxes; profit -= eoiBlueprint.Taxes; } eoiBlueprint.ExpensesPerRun = investment; eoiBlueprint.ProductionBaseTaxPerRun = baseTaxInvestment; eoiBlueprint.ProductionCorporationTaxPerRun = corporationTaxInvestment; foreach (var product in blueprint.Products) { decimal productPrice = 0; var productMarketPrices = product.GetMarketPrices().FirstOrDefault(x => x.Region == region); // var productMarketPrices = product.GetMarketPrices().FirstOrDefault(x => x.Region == Regions.TashMurkon); if (productMarketPrices != null) { // var productMarketBuyOrders = productMarketPrices.Orders.Where(x => x.is_buy_order && x.system_id.ToString() == SolarSystems.Mani.SolarSysteId.ToString()).ToList(); var productMarketBuyOrders = productMarketPrices.Orders.Where(x => x.is_buy_order && x.system_id.ToString() == SettingsInterface.GlobalSettings.TradeHub).ToList(); if (SettingsInterface.GlobalSettings.TradeHub == SolarSystems.Amarr.SolarSysteId.ToString()) { productMarketBuyOrders.AddRange(productMarketPrices.Orders.Where(x => x.is_buy_order && x.system_id.ToString() == SolarSystems.Ashab.SolarSysteId.ToString()).ToList()); } if (productMarketBuyOrders.Any()) { eoiBlueprint.BuyPrice = productMarketBuyOrders.Max(x => x.price); } // var productMarketSellOrders = productMarketPrices.Orders.Where(x => !x.is_buy_order && x.system_id.ToString() == SolarSystems.Mani.SolarSysteId.ToString()).ToList(); var productMarketSellOrders = productMarketPrices.Orders.Where(x => !x.is_buy_order && x.system_id.ToString() == SettingsInterface.GlobalSettings.TradeHub).ToList(); if (productMarketSellOrders.Any()) { eoiBlueprint.SellPrice = productMarketSellOrders.Min(x => x.price); } } if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Buy) { if (eoiBlueprint.BuyPrice > 0) { productPrice = eoiBlueprint.BuyPrice; } } else if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Sell) { if (eoiBlueprint.SellPrice > 0) { productPrice = eoiBlueprint.SellPrice; } } eoiBlueprint.SalesPricePerUnit = productPrice; eoiBlueprint.SalesPricePerRun = productPrice * blueprint.GetProductQuantity(product); var salesTax = eoiBlueprint.SalesPricePerRun * (SettingsInterface.GlobalSettings.SaleTax / 100); decimal brokerFee = 0; if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Sell) { brokerFee = eoiBlueprint.SalesPricePerRun * (SettingsInterface.GlobalSettings.BrokerFee / 100); } eoiBlueprint.SalesTaxesPerRun = salesTax; profit += eoiBlueprint.SalesPricePerRun - salesTax; income += eoiBlueprint.SalesPricePerRun - salesTax; eoiBlueprint.BrokerFeesPerRun = brokerFee; profit -= brokerFee; income -= brokerFee; eoiBlueprint.IncomePerRun = income; } eoiBlueprint.ProfitPerRun = profit; if (blueprint.Products.Count == 1) { var productQuantity = blueprint.GetProductQuantity(blueprint.Products[0]); eoiBlueprint.MaterialExpensesPerUnit = eoiBlueprint.MaterialExpensesPerRun / productQuantity; eoiBlueprint.ProductionBaseTaxPerUnit = eoiBlueprint.ProductionBaseTaxPerRun / productQuantity; eoiBlueprint.ProductionCorporationTaxPerUnit = eoiBlueprint.ProductionCorporationTaxPerRun / productQuantity; eoiBlueprint.ExpensesPerUnit = investment / productQuantity; eoiBlueprint.ExpensesPerUnitJita = investmentJita / productQuantity; eoiBlueprint.IncomePerUnit = income / productQuantity; eoiBlueprint.ProfitPerUnit = profit / productQuantity; var history = blueprint.Products[0].GetMarketHistory(); if (history != null) { if (history.UnitsPerSecond <= 0 || productQuantity <= 0) { eoiBlueprint.ExpectedProfitPerHour = 0; } else { var manufacturingTimePerUnit = manufacturingTime / productQuantity; if (manufacturingTimePerUnit <= 0) { eoiBlueprint.ExpectedProfitPerHour = 0; } else { eoiBlueprint.ExpectedProfitPerHour = ((eoiBlueprint.ProfitPerUnit / manufacturingTimePerUnit) * history.UnitsPerSecond) * 3600; } } } else { eoiBlueprint.ExpectedProfitPerHour = 0; } } eoiBlueprint.ProfitPerHour = (profit / manufacturingTime) * 3600; eoiBlueprint.ExpensesPerHour = (investment / manufacturingTime) * 3600; eoiBlueprint.IncomePerHour = (income / manufacturingTime) * 3600; var optimalProfit = (200000 / 3600) * manufacturingTime; if (blueprint.Products.Count == 1) { var productQuantity = blueprint.GetProductQuantity(blueprint.Products[0]); var optimalProfitPerUnit = optimalProfit / productQuantity; eoiBlueprint.OptimalPrice = eoiBlueprint.ExpensesPerUnit + optimalProfitPerUnit; if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Buy) { var salesTax = eoiBlueprint.OptimalPrice * (SettingsInterface.GlobalSettings.SaleTax / 100); eoiBlueprint.OptimalMarketPrice = eoiBlueprint.ExpensesPerUnit + optimalProfitPerUnit + salesTax; } else if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Sell) { var salesTax = eoiBlueprint.OptimalPrice * (SettingsInterface.GlobalSettings.SaleTax / 100); decimal brokerFee = 0; if (SettingsInterface.GlobalSettings.ExportOrderType == OrderType.Sell) { brokerFee = eoiBlueprint.OptimalPrice * (SettingsInterface.GlobalSettings.BrokerFee / 100); } eoiBlueprint.OptimalMarketPrice = eoiBlueprint.ExpensesPerUnit + optimalProfitPerUnit + salesTax + brokerFee; } } if (eoiBlueprint.ExpectedProfitPerHour > eoiBlueprint.ProfitPerHour) { eoiBlueprint.ExpectedProfitPerHour = eoiBlueprint.ProfitPerHour; } }