private void UpdateBrokerFee()
 {
     Dispatcher.Invoke(new Action(delegate
     {
         lblBrokerRelations.Content = String.Format("Broker fee: {0:n}%",
                                                    CalculateDataThread.NpcBroker(profile) * 100);
     }));
 }
 private void CbAccountingSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     profile.accounting = cbAccounting.SelectedIndex;
     Dispatcher.Invoke(
         new Action(delegate
     {
         lblSalesTax.Content = String.Format("Sales tax: {0:n}%", CalculateDataThread.SalesTax(profile.accounting) * 100);
     })
         );
 }
Esempio n. 3
0
 private void UpdateBrokerFee()
 {
     Dispatcher.Invoke(new Action(delegate
     {
         lblBrokerRelations.Content = String.Format("Broker fee: {0:n}%",
                                                    CalculateDataThread.
                                                    BrokerFee(
                                                        Settings.
                                                        BrokerRelations,
                                                        Settings.
                                                        CorpStanding,
                                                        Settings.
                                                        FactionStanding) *
                                                    100);
     }));
 }
        private void ProcessData(string s)
        {
            List <List <string> > table = CSVReader.GetTableFromCSV(s);

            if (table == null)
            {
                return;
            }

            if (profile.sellRange == (int)Profile.ranges.HUB)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && row[13] == "0" && hubIds.Contains(double.Parse(row[10]))
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else if (profile.sellRange == (int)Profile.ranges.SYSTEM)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && row[13] == "0"
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else if (profile.sellRange == (int)Profile.ranges.ONEJUMP)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && Int32.Parse(row[13]) < 2
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else if (profile.sellRange == (int)Profile.ranges.TWOJUMP)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && Int32.Parse(row[13]) < 3
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False"
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }

            if (profile.buyRange == (int)Profile.ranges.HUB)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && row[13] == "0" && hubIds.Contains(double.Parse(row[10]))
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else if (profile.buyRange == (int)Profile.ranges.SYSTEM)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && row[13] == "0"
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else if (profile.buyRange == (int)Profile.ranges.ONEJUMP)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && Int32.Parse(row[13]) < 2
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else if (profile.buyRange == (int)Profile.ranges.TWOJUMP)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && Int32.Parse(row[13]) < 3
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True"
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }


            IEnumerable <List <string> > aRow = from List <string> row in table
                                                select row;

            foreach (var list in aRow)
            {
                int i;
                _typeId = int.TryParse(list[2], out i) ? i : -1;
                break;
            }

            // extract item name from market log file name
            var fileNameParts = s.Split('-');
            // remove first and last entry of splittet string[] (location and typeid) and join rest since we can have a dash in the item name
            var _itemName = fileNameParts.Length <= 2 ? "" : String.Join("-", fileNameParts.Skip(1).Reverse().Skip(1).Reverse());

            Dispatcher.Invoke(new Action(delegate
            {
                lblItemName.Content = _itemName.Length != 0 ? _itemName : "Unkown";
                lblItemName.ToolTip = _itemName.Length != 0 ? _itemName : "Product not found";
            }));

            Dispatcher.Invoke(new Action(delegate
            {
                lblSell.Content = _sell >= 0
                                    ? String.Format("{0:n} ISK", _sell)
                                    : "No orders in range";
                lblBuy.Content = _buy >= 0
                                    ? String.Format("{0:n} ISK", _buy)
                                    : "No orders in range";
            }));

            var cdt = new CalculateDataThread(_sell, _buy, this);
            var calc = new Thread(cdt.Run);

            calc.Start();
        }
Esempio n. 5
0
        private void ProcessData(string s)
        {
            List <List <string> > table = CSVReader.GetTableFromCSV(s);

            if (table == null)
            {
                return;
            }


            IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                       where row[7] == "False" && row[13] == "0"
                                                       orderby
                                                       double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                       select row;

            string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";

            _sell = double.Parse(sss, CultureInfo.InvariantCulture);

            IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                      where row[7] == "True" && row[13] == "0"
                                                      orderby
                                                      double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                      select row;

            string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";

            _buy = double.Parse(bbb, CultureInfo.InvariantCulture);

            IEnumerable <List <string> > aRow = from List <string> row in table
                                                where row[13] == "0"
                                                select row;

            foreach (var list in aRow)
            {
                int i;
                _typeId = int.TryParse(list[2], out i) ? i : -1;
                break;
            }

            var setItemName = new BackgroundWorker();

            setItemName.DoWork += (sender, args) =>
            {
                var prod = new TypeName(new[] { _typeId.ToString(CultureInfo.InvariantCulture) });
                prod.Query();

                Dispatcher.Invoke(new Action(delegate
                {
                    if (prod.types.Count > 0)
                    {
                        TypeName.GameType type =
                            prod.types[0];
                        lblItemName.Content = type.typeName;
                        lblItemName.ToolTip = type.typeName;
                    }
                    else
                    {
                        lblItemName.Content = "Unknown";
                        lblItemName.ToolTip =
                            "Product not found";
                    }
                }));
            };
            setItemName.RunWorkerAsync();

            var getVolumes = new BackgroundWorker();

            getVolumes.DoWork += (sender, args) =>
            {
                var volumes = new Dictionary <string, long>();
                if (_typeId > 0)
                {
                    volumes = VolumeFetcher.GetVolumes(table);
                }


                Dispatcher.Invoke(new Action(delegate
                {
                    if (volumes.Count > 0)
                    {
                        long i, j;
                        if (
                            volumes.TryGetValue("sellvol",
                                                out i) &&
                            volumes.TryGetValue("sellmov",
                                                out j))
                        {
                            lblSellvols.Content =
                                string.Format(
                                    "{0:n0}/{1:n0}", i, j);
                        }

                        if (
                            volumes.TryGetValue("buyvol",
                                                out i) &&
                            volumes.TryGetValue("buymov",
                                                out j))
                        {
                            lblBuyvols.Content =
                                string.Format(
                                    "{0:n0}/{1:n0}", i, j);
                        }
                    }
                }));
            };
            getVolumes.RunWorkerAsync();

            Dispatcher.Invoke(new Action(delegate
            {
                lblSell.Content = _sell >= 0
                                                                       ? String.Format("{0:n} ISK", _sell)
                                                                       : "No orders in range";
                lblBuy.Content = _buy >= 0
                                                                      ? String.Format("{0:n} ISK", _buy)
                                                                      : "No orders in range";
            }));

            var cdt = new CalculateDataThread(_sell, _buy, this);
            var calc = new Thread(cdt.Run);

            calc.Start();
        }
Esempio n. 6
0
        private void ProcessData(string s)
        {
            List<List<string>> table = CSVReader.GetTableFromCSV(s);

            if (table == null) return;


            IOrderedEnumerable<List<string>> sell = from List<string> row in table
                                                    where row[7] == "False" && row[13] == "0"
                                                    orderby
                                                        double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                    select row;
            string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
            _sell = double.Parse(sss, CultureInfo.InvariantCulture);

            IOrderedEnumerable<List<string>> buy = from List<string> row in table
                                                   where row[7] == "True" && row[13] == "0"
                                                   orderby
                                                       double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                   select row;
            string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
            _buy = double.Parse(bbb, CultureInfo.InvariantCulture);

            IEnumerable<List<string>> aRow = from List<string> row in table
                                             where row[13] == "0"
                                             select row;

            foreach (var list in aRow)
            {
                int i;
                _typeId = int.TryParse(list[2], out i) ? i : -1;
                break;
            }

            var setItemName = new BackgroundWorker();
            setItemName.DoWork += (sender, args) =>
                                      {
                                          var prod = new TypeName(new[] {_typeId.ToString(CultureInfo.InvariantCulture)});
                                          prod.Query();

                                          Dispatcher.Invoke(new Action(delegate
                                                                           {
                                                                               if (prod.types.Count > 0)
                                                                               {
                                                                                   TypeName.GameType type =
                                                                                       prod.types[0];
                                                                                   lblItemName.Content = type.typeName;
                                                                                   lblItemName.ToolTip = type.typeName;
                                                                               }
                                                                               else
                                                                               {
                                                                                   lblItemName.Content = "Unknown";
                                                                                   lblItemName.ToolTip =
                                                                                       "Product not found";
                                                                               }
                                                                           }));
                                      };
            setItemName.RunWorkerAsync();

            var getVolumes = new BackgroundWorker();
            getVolumes.DoWork += (sender, args) =>
                                     {
                                         var volumes = new Dictionary<string, long>();
                                         if (_typeId > 0)
                                         {
                                             volumes = VolumeFetcher.GetVolumes(table);
                                         }


                                         Dispatcher.Invoke(new Action(delegate
                                                                          {
                                                                              if (volumes.Count > 0)
                                                                              {
                                                                                  long i, j;
                                                                                  if (
                                                                                      volumes.TryGetValue("sellvol",
                                                                                                          out i) &&
                                                                                      volumes.TryGetValue("sellmov",
                                                                                                          out j))
                                                                                      lblSellvols.Content =
                                                                                          string.Format(
                                                                                              "{0:n0}/{1:n0}", i, j);

                                                                                  if (
                                                                                      volumes.TryGetValue("buyvol",
                                                                                                          out i) &&
                                                                                      volumes.TryGetValue("buymov",
                                                                                                          out j))
                                                                                      lblBuyvols.Content =
                                                                                          string.Format(
                                                                                              "{0:n0}/{1:n0}", i, j);
                                                                              }
                                                                          }));
                                     };
            getVolumes.RunWorkerAsync();

            Dispatcher.Invoke(new Action(delegate
                                             {
                                                 lblSell.Content = _sell >= 0
                                                                       ? String.Format("{0:n} ISK", _sell)
                                                                       : "No orders in range";
                                                 lblBuy.Content = _buy >= 0
                                                                      ? String.Format("{0:n} ISK", _buy)
                                                                      : "No orders in range";
                                             }));

            var cdt = new CalculateDataThread(_sell, _buy, this);
            var calc = new Thread(cdt.Run);
            calc.Start();
        }
Esempio n. 7
0
        private void ProcessData(string s)
        {
            List <List <string> > table = CSVReader.GetTableFromCSV(s);

            if (table == null)
            {
                return;
            }

            if (profile.sellRange == (int)Profile.ranges.HUB)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && row[13] == "0" && hubIds.Contains(double.Parse(row[10]))
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else if (profile.sellRange == (int)Profile.ranges.SYSTEM)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && row[13] == "0"
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else if (profile.sellRange == (int)Profile.ranges.ONEJUMP)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && Int32.Parse(row[13]) < 2
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else if (profile.sellRange == (int)Profile.ranges.TWOJUMP)
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False" && Int32.Parse(row[13]) < 3
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }
            else
            {
                IOrderedEnumerable <List <string> > sell = from List <string> row in table
                                                           where row[7] == "False"
                                                           orderby
                                                           double.Parse(row[0], CultureInfo.InvariantCulture) ascending
                                                           select row;

                string sss = sell.Any() ? sell.ElementAt(0)[0] : "-1.0";
                _sell = double.Parse(sss, CultureInfo.InvariantCulture);
            }

            if (profile.buyRange == (int)Profile.ranges.HUB)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && row[13] == "0" && hubIds.Contains(double.Parse(row[10]))
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else if (profile.buyRange == (int)Profile.ranges.SYSTEM)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && row[13] == "0"
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else if (profile.buyRange == (int)Profile.ranges.ONEJUMP)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && Int32.Parse(row[13]) < 2
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else if (profile.buyRange == (int)Profile.ranges.TWOJUMP)
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True" && Int32.Parse(row[13]) < 3
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }
            else
            {
                IOrderedEnumerable <List <string> > buy = from List <string> row in table
                                                          where row[7] == "True"
                                                          orderby
                                                          double.Parse(row[0], CultureInfo.InvariantCulture) descending
                                                          select row;

                string bbb = buy.Any() ? buy.ElementAt(0)[0] : "-1.0";
                _buy = double.Parse(bbb, CultureInfo.InvariantCulture);
            }


            IEnumerable <List <string> > aRow = from List <string> row in table
                                                select row;

            foreach (var list in aRow)
            {
                int i;
                _typeId = int.TryParse(list[2], out i) ? i : -1;
                break;
            }

            var setItemName = new BackgroundWorker();

            setItemName.DoWork += (sender, args) =>
            {
                var prod = new TypeName(new[] { _typeId.ToString(CultureInfo.InvariantCulture) });
                prod.Query();

                Dispatcher.Invoke(new Action(delegate
                {
                    if (prod.types.Count > 0)
                    {
                        TypeName.GameType type = prod.types[0];
                        lblItemName.Content    = type.typeName;
                        lblItemName.ToolTip    = type.typeName;
                    }
                    else
                    {
                        lblItemName.Content = "Unknown";
                        lblItemName.ToolTip = "Product not found";
                    }
                }));
            };

            setItemName.RunWorkerAsync();

            Dispatcher.Invoke(new Action(delegate
            {
                lblSell.Content = _sell >= 0
                                    ? String.Format("{0:n} ISK", _sell)
                                    : "No orders in range";
                lblBuy.Content = _buy >= 0
                                    ? String.Format("{0:n} ISK", _buy)
                                    : "No orders in range";
            }));

            var cdt = new CalculateDataThread(_sell, _buy, this);
            var calc = new Thread(cdt.Run);

            calc.Start();
        }