Exemplo n.º 1
0
 private static bool CheckMarketerData()
 {
     EsiDataInterface.RequestMarketOrders();
     return(EoiDataInterface.CheckMarketOrders());
     //MarketerDataInterface.RequestBlueprints();
     //return EoiDataInterface.CheckMarketerData();
 }
Exemplo n.º 2
0
        public static void GetUserAccessToken(string code)
        {
            var token = WebDataReader.GetUserAccessToken(code);

            if (token != null)
            {
                EoiDataInterface.AuthenticateUser(token);
            }
        }
Exemplo n.º 3
0
        private static bool SynchronizeBlueprints()
        {
            var updated = false;

            if (EoiDataInterface.SynchronizeBlueprints())
            {
                updated = true;
            }

            return(updated);
        }
Exemplo n.º 4
0
        internal static void RequestMarketHistory()
        {
            if (EveSwaggerInterface.Working())
            {
                return;
            }

            var failedRequests = EveSwaggerInterface.GetFailedHistoryRequests();

            foreach (var failedRequest in failedRequests)
            {
                var esiType = EveSwaggerInterface.GetType(failedRequest.Id);
                if (esiType == null || !esiType.published)
                {
                    var product = EoiDataInterface.GetTypeById(failedRequest.Id);
                    if (product != null)
                    {
                        product.Invalid = true;
                        EoiDataInterface.CheckInvalid();
                    }
                }
            }

            EveSwaggerInterface.ClearFailedHistoryRequests();

            var blueprints = EoiDataInterface.GetBlueprints();

            foreach (var blueprint in blueprints)
            {
                foreach (var product in blueprint.Products)
                {
                    RawEsiPriceHistory marketHistory = null;

                    var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub));

                    marketHistory = EveSwaggerInterface.GetMarketHistory(product.Id, region);
                    if (marketHistory != null)
                    {
                        var esiDataMarketHistory = _marketHistory.FirstOrDefault(x => Equals(x.History, marketHistory));
                        if (esiDataMarketHistory == null)
                        {
                            var oldEsiDataMarketHistory = _marketHistory.FirstOrDefault(x => x.Id == marketHistory.typeId && x.Region == marketHistory.regionId);
                            if (oldEsiDataMarketHistory != null)
                            {
                                _marketHistory.Remove(oldEsiDataMarketHistory);
                            }

                            _marketHistory.Add(new EsiDataMarketHistory(marketHistory));
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private static void Initialize()
        {
            _eoiBlueprints = new ObservableCollection <EoiBlueprint>();

            var blueprints = EoiDataInterface.GetBlueprints();

            foreach (var blueprint in blueprints)
            {
                _eoiBlueprints.Add(blueprint.GetEoiBlueprint());
            }

            _eoiUsers = new ObservableCollection <EoiUser>();

            var users = EoiDataInterface.GetUsers();

            foreach (var user in users)
            {
                _eoiUsers.Add(user.GetEoiUser());
            }

            _eoiContracts = new ObservableCollection <EoiContract>();
            var contracts = EoiDataInterface.GetContracts();

            foreach (var contract in contracts)
            {
                _eoiContracts.Add(contract.GetEoiContract());
            }

            _eoiAssets = new ObservableCollection <EoiAsset>();
            var eoiDataAssets = EoiDataInterface.GetAssets();

            foreach (var eoiDataAsset in eoiDataAssets)
            {
                foreach (var eoiAsset in eoiDataAsset.GetEoiAssets())
                {
                    _eoiAssets.Add(eoiAsset);
                }
            }

            _eoiSolarSystems = new ObservableCollection <EoiSolarSystem>();
            var solarSystems = EoiDataInterface.GetSolarSystems();

            if (solarSystems != null)
            {
                foreach (var solarSystem in solarSystems)
                {
                    _eoiSolarSystems.Add(solarSystem.GetEoiSolarSystem());
                }
            }
        }
Exemplo n.º 6
0
 public static bool AcceptIndustryContract(EoiContract contract, int selectedVolume)
 {
     return(EoiDataInterface.AcceptContract(contract, selectedVolume));
 }
Exemplo n.º 7
0
 public static void Close()
 {
     EoiDataInterface.Close();
 }
Exemplo n.º 8
0
        public static bool CreateIndustryContract(EoiBlueprint blueprint, int volume, decimal price, string orderType, bool materialIncluded, bool blueprintIncluded, string description, bool enablePartition)
        {
            var success = EoiDataInterface.CreateContract(blueprint.Id, volume, price, orderType, materialIncluded, blueprintIncluded, description, enablePartition);

            return(success);
        }
Exemplo n.º 9
0
 public bool CanFinish()
 {
     return(EoiDataInterface.CanFinish(this));
 }
Exemplo n.º 10
0
 public void Finish()
 {
     EoiDataInterface.Finish(this);
 }
Exemplo n.º 11
0
 private static void CheckUserAccessTokens()
 {
     EoiDataInterface.CheckUserAccessTokens();
 }
Exemplo n.º 12
0
 public bool CanAccept()
 {
     return(EoiDataInterface.CanAccept(this));
 }
Exemplo n.º 13
0
 private static void SynchronizeAssets()
 {
     EoiDataInterface.SynchronizeAssets();
 }
Exemplo n.º 14
0
 public void Delete()
 {
     EoiDataInterface.Delete(this);
 }
Exemplo n.º 15
0
        internal static void RequestMarketOrders()
        {
            if (EveSwaggerInterface.Working())
            {
                return;
            }

            var failedRequests = EveSwaggerInterface.GetFailedOrdersRequests();

            foreach (var failedRequest in failedRequests)
            {
                var esiType = EveSwaggerInterface.GetType(failedRequest.Id);
                if (esiType == null || !esiType.published)
                {
                    var type = EoiDataInterface.GetTypeById(failedRequest.Id);
                    if (type != null)
                    {
                        type.Invalid = true;
                        EoiDataInterface.CheckInvalid();
                    }
                }
            }

            EveSwaggerInterface.ClearFailedOrdersRequests();

            var assets = EoiDataInterface.GetAssets();

            foreach (var asset in assets)
            {
                RawEsiMarketOrders marketOrders = null;

                var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub));

                marketOrders = EveSwaggerInterface.GetMarketOrders(asset.Id, region);
                if (marketOrders != null)
                {
                    var esiDataMarketOrders = _marketOrders.FirstOrDefault(x => Equals(x.Orders, marketOrders));
                    if (esiDataMarketOrders == null)
                    {
                        var oldEsiDataMarketOrders = _marketOrders.FirstOrDefault(x => x.Id == marketOrders.typeId && x.Region == marketOrders.regionId);
                        if (oldEsiDataMarketOrders != null)
                        {
                            _marketOrders.Remove(oldEsiDataMarketOrders);
                        }

                        _marketOrders.Add(new EsiDataMarketOrders(marketOrders));
                    }
                }
            }

            var blueprints = EoiDataInterface.GetBlueprints();

            foreach (var blueprint in blueprints)
            {
                {
                    RawEsiMarketOrders marketOrders = null;

                    var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub));

                    marketOrders = EveSwaggerInterface.GetMarketOrders(blueprint.Id, region);
                    if (marketOrders != null)
                    {
                        var esiDataMarketOrders = _marketOrders.FirstOrDefault(x => Equals(x.Orders, marketOrders));
                        if (esiDataMarketOrders == null)
                        {
                            var oldEsiDataMarketOrders = _marketOrders.FirstOrDefault(x => x.Id == marketOrders.typeId && x.Region == marketOrders.regionId);
                            if (oldEsiDataMarketOrders != null)
                            {
                                _marketOrders.Remove(oldEsiDataMarketOrders);
                            }

                            _marketOrders.Add(new EsiDataMarketOrders(marketOrders));
                        }
                    }
                }

                foreach (var materials in blueprint.Materials)
                {
                    RawEsiMarketOrders marketOrders = null;

                    var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub));

                    marketOrders = EveSwaggerInterface.GetMarketOrders(materials.Id, region);
                    if (marketOrders != null)
                    {
                        var esiDataMarketOrders = _marketOrders.FirstOrDefault(x => Equals(x.Orders, marketOrders));
                        if (esiDataMarketOrders == null)
                        {
                            var oldEsiDataMarketOrders = _marketOrders.FirstOrDefault(x => x.Id == marketOrders.typeId && x.Region == marketOrders.regionId);
                            if (oldEsiDataMarketOrders != null)
                            {
                                _marketOrders.Remove(oldEsiDataMarketOrders);
                            }

                            _marketOrders.Add(new EsiDataMarketOrders(marketOrders));
                        }
                    }

                    if (region != Regions.TheForge)
                    {
                        marketOrders = EveSwaggerInterface.GetMarketOrders(materials.Id, Regions.TheForge);
                        if (marketOrders != null)
                        {
                            var esiDataMarketOrders = _marketOrders.FirstOrDefault(x => Equals(x.Orders, marketOrders));
                            if (esiDataMarketOrders == null)
                            {
                                var oldEsiDataMarketOrders = _marketOrders.FirstOrDefault(x => x.Id == marketOrders.typeId && x.Region == marketOrders.regionId);
                                if (oldEsiDataMarketOrders != null)
                                {
                                    _marketOrders.Remove(oldEsiDataMarketOrders);
                                }

                                _marketOrders.Add(new EsiDataMarketOrders(marketOrders));
                            }
                        }
                    }
                }

                foreach (var product in blueprint.Products)
                {
                    RawEsiMarketOrders marketOrders = null;

                    var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub));

                    marketOrders = EveSwaggerInterface.GetMarketOrders(product.Id, region);
                    if (marketOrders != null)
                    {
                        var esiDataMarketOrders = _marketOrders.FirstOrDefault(x => Equals(x.Orders, marketOrders));
                        if (esiDataMarketOrders == null)
                        {
                            var oldEsiDataMarketOrders = _marketOrders.FirstOrDefault(x => x.Id == marketOrders.typeId && x.Region == marketOrders.regionId);
                            if (oldEsiDataMarketOrders != null)
                            {
                                _marketOrders.Remove(oldEsiDataMarketOrders);
                            }

                            _marketOrders.Add(new EsiDataMarketOrders(marketOrders));
                        }
                    }

                    if (region != Regions.TheForge)
                    {
                        marketOrders = EveSwaggerInterface.GetMarketOrders(product.Id, Regions.TheForge);
                        if (marketOrders != null)
                        {
                            var esiDataMarketOrders = _marketOrders.FirstOrDefault(x => Equals(x.Orders, marketOrders));
                            if (esiDataMarketOrders == null)
                            {
                                var oldEsiDataMarketOrders = _marketOrders.FirstOrDefault(x => x.Id == marketOrders.typeId && x.Region == marketOrders.regionId);
                                if (oldEsiDataMarketOrders != null)
                                {
                                    _marketOrders.Remove(oldEsiDataMarketOrders);
                                }

                                _marketOrders.Add(new EsiDataMarketOrders(marketOrders));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
 private static void SynchronizeCharacterOrders()
 {
     EoiDataInterface.SynchronizeCharacterOrders();
 }
Exemplo n.º 17
0
        internal static void Start(Thread mainThread)
        {
            if (mainThread == null)
            {
                return;
            }

            MainThread = mainThread;

            while (!_stop)
            {
                CheckUserAccessTokens();

                if (SettingsInterface.GlobalSettings.EnableAutoUpdater)
                {
                    var updated = false;

                    if (SynchronizeBlueprints())
                    {
                        updated = true;
                    }

                    CheckUpdated(updated, EoiInterface.BlueprintPropertyChanged);
                    updated = false;

                    Status = new BackgroundWorkerStatus("Synchronisiere Assets", -1);
                    SynchronizeAssets();
                    SynchronizeWallet();
                    CheckUpdated(true, EoiInterface.AssetPropertyChanged);

                    Status = new BackgroundWorkerStatus("Synchronisiere Markt Orders", -1);
                    SynchronizeCharacterOrders();
                    CheckUpdated(true, EoiInterface.BlueprintPropertyChanged);

                    if (SettingsInterface.GlobalSettings.EnableCorporationContractsUpdates && !_stop)
                    {
                        Status = new BackgroundWorkerStatus("Synchronisiere Corporation Verträge", -1);
                        if (SynchronizeCorporationContracts())
                        {
                            updated = true;
                        }

                        CheckUpdated(updated, EoiInterface.ContractsPropertyChanged);
                        updated = false;
                    }

                    if (SettingsInterface.GlobalSettings.EnableMarketerUpdates && !_stop)
                    {
                        Status = new BackgroundWorkerStatus("Aktualisiert Markt Preise", -1);
                        if (CheckMarketerData())
                        {
                            updated = true;
                        }

                        CheckUpdated(true, EoiInterface.AssetPropertyChanged);
                        CheckUpdated(updated, EoiInterface.BlueprintPropertyChanged);
                        updated = false;
                    }

                    if (SettingsInterface.GlobalSettings.EnableMarketHistoryUpdates && !_stop)
                    {
                        Status = new BackgroundWorkerStatus("Aktualisiert Markt Verkaufszahlen", -1);
                        if (CheckMarketHistory())
                        {
                            updated = true;
                        }

                        CheckUpdated(updated, EoiInterface.BlueprintPropertyChanged);
                        updated = false;
                    }
                }

                var preStop = false;
                for (int i = 0; i < 30; i++)
                {
                    if (!_stop)
                    {
                        CheckUserAccessTokens();

                        if (_calculateBlueprints)
                        {
                            Status = new BackgroundWorkerStatus("Berechne Blueprints", -1);
                            _calculateBlueprints = false;
                            EoiDataInterface.CalculateAllBlueprints();
                            CheckUpdated(true, EoiInterface.BlueprintPropertyChanged);
                        }

                        if (EveSwaggerInterface.Working())
                        {
                            var state = EveSwaggerInterface.GetProgressState();
                            Status  = new BackgroundWorkerStatus("Download vom Eve Online Server: " + state.FinishedOperations + " / " + state.Operations, state.Progress);
                            preStop = true;
                        }
                        else
                        {
                            Status = new BackgroundWorkerStatus("", 0);
                        }

                        Thread.Sleep(SettingsInterface.GlobalSettings.AutoUpdaterInterval / 30);

                        if (preStop && !EveSwaggerInterface.Working())
                        {
                            i = 30;
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
 private static void SynchronizeWallet()
 {
     EoiDataInterface.SynchronizeWallet();
 }
Exemplo n.º 19
0
 private static bool CheckMarketHistory()
 {
     EsiDataInterface.RequestMarketHistory();
     return(EoiDataInterface.CheckMarketHistory());
 }
Exemplo n.º 20
0
 public static void Init()
 {
     EoiDataInterface.Init();
     Initialize();
     EoiDataInterface.CalculateAllBlueprints();
 }
Exemplo n.º 21
0
 public bool CanDelete()
 {
     return(EoiDataInterface.CanDelete(this));
 }
Exemplo n.º 22
0
        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;
            }
        }
Exemplo n.º 23
0
 private static bool SynchronizeCorporationContracts()
 {
     return(EoiDataInterface.SynchronizeCorporationContracts());
 }