public void AddEntry(Transaction ta)
 {
     ListViewItem entry = new ListViewItem();
     entry.Content = ta.TypeName;
     this.ItemList.Items.Add(entry);
     this.taBinding.Add(ta.TypeName, ta);
 }
Example #2
0
        private async void LoadData(object sender, EVE_SaleTools.Templates.ItemSelectedEventArgs args)
        {
            var sqlite = new SQLiteAsyncConnection(activeCharacter.CharID + ".sqlite");
            List<Transaction> mexallonSalesPerDay = await sqlite.QueryAsync<Transaction>("SELECT Time, AVG(PricePerUnit) AS PricePerUnit FROM 'Transaction' WHERE TypeName = '" + args.transaction.TypeName + "' AND BuyOrder = 0 GROUP BY strftime('%d-%m-%Y',Time) ORDER BY Time ASC");

            (LineChart.Series[0] as LineSeries).ItemsSource = null;
            (LineChart.Series[1] as LineSeries).ItemsSource = null;
            (LineChart.Series[2] as LineSeries).ItemsSource = null;
            (LineChart.Series[3] as LineSeries).ItemsSource = null;

            if (mexallonSalesPerDay.Count > 0)
            {
                LineSeries sales = new LineSeries();
                (LineChart.Series[0] as LineSeries).ItemsSource = mexallonSalesPerDay;

                List<Transaction> mexallonSalesAveragePrice = await sqlite.QueryAsync<Transaction>("SELECT Time, AVG(PricePerUnit) AS PricePerUnit FROM 'Transaction' WHERE TypeName = '" + args.transaction.TypeName + "' AND BuyOrder = 0 GROUP BY TypeName");
                Transaction begin = new Transaction();
                begin.Time = mexallonSalesPerDay.Last().Time;
                begin.PricePerUnit = mexallonSalesAveragePrice.First().PricePerUnit;
                Transaction end = new Transaction();
                end.Time = mexallonSalesPerDay.First().Time;
                end.PricePerUnit = mexallonSalesAveragePrice.First().PricePerUnit;
                (LineChart.Series[1] as LineSeries).ItemsSource = new List<Transaction>() { begin, end };

            }


            List<Transaction> mexallonBuysPerDay = await sqlite.QueryAsync<Transaction>("SELECT Time, AVG(PricePerUnit) AS PricePerUnit FROM 'Transaction' WHERE TypeName = '" + args.transaction.TypeName + "' AND BuyOrder = 1 GROUP BY strftime('%d-%m-%Y',Time) ORDER BY Time ASC");
            if (mexallonBuysPerDay.Count > 0)
            {
                (LineChart.Series[2] as LineSeries).ItemsSource = mexallonBuysPerDay;


                List<Transaction> mexallonBuysAveragePrice = await sqlite.QueryAsync<Transaction>("SELECT Time, AVG(PricePerUnit) AS PricePerUnit FROM 'Transaction' WHERE TypeName = '" + args.transaction.TypeName + "' AND BuyOrder = 1 GROUP BY TypeName");
                Transaction begin = new Transaction();
                begin.Time = mexallonBuysPerDay.Last().Time;
                begin.PricePerUnit = mexallonBuysPerDay.First().PricePerUnit;
                Transaction end = new Transaction();
                end.Time = mexallonBuysPerDay.First().Time;
                end.PricePerUnit = mexallonBuysPerDay.First().PricePerUnit;
                (LineChart.Series[3] as LineSeries).ItemsSource = new List<Transaction>() { begin, end };

            }


            TransactionInformation meta = await TransactionInformation.Load(args.transaction.TypeID);
            this.ItemTitle.Text = args.transaction.TypeName;
            this.ItemDescription.Text = System.Text.RegularExpressions.Regex.Replace(meta.Description, "<.*?>", String.Empty);


            List<Transaction> mexallonAll = await sqlite.QueryAsync<Transaction>("SELECT * FROM 'Transaction' WHERE TypeName = '" + args.transaction.TypeName + "' ORDER BY Time");
            this.ListViewTransactions.ItemsSource = mexallonAll;
        }
Example #3
0
        /// <summary>
        /// Load transaction data and store in local sqlite db
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="vCode"></param>
        /// <param name="charID"></param>
        /// <returns></returns>
        public async static Task<bool> Parse(string apiKey, string vCode, string charID)
        {
            // open DB
            var sqliteTransactionData = new SQLiteAsyncConnection(charID + ".sqlite");
            await sqliteTransactionData.CreateTableAsync<Transaction>();

            //await sqliteTransactionData.ExecuteAsync("ATTACH DATABASE '" + Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\Assets\\Data\\static.sqlite' AS Static");

            // build request string
            String request = "https://api.eveonline.com/char/WalletTransactions.xml.aspx";
            request += "?keyID=" + apiKey;
            request += "&vCode=" + vCode;
            request += "&characterID=" + charID;

            // load data as xml string
            HttpResponseMessage response = await new HttpClient().GetAsync(request);
            string xml_data = await response.Content.ReadAsStringAsync();

            // parse as xml and fetch data
            XDocument transactiondata = XDocument.Parse(xml_data);
            var transactions = from transaction in transactiondata.Descendants("row")
                             select new
                             {
                                 TransactionDateTime = transaction.Attribute("transactionDateTime").Value ?? "",
                                 TransactionID = transaction.Attribute("transactionID").Value ?? "",
                                 Quantity = transaction.Attribute("quantity").Value ?? "",
                                 TypeName = transaction.Attribute("typeName").Value ?? "",
                                 TypeID = transaction.Attribute("typeID").Value ?? "",
                                 Price = transaction.Attribute("price").Value ?? "",
                                 ClientID = transaction.Attribute("clientID").Value ?? "",
                                 ClientName = transaction.Attribute("clientName").Value ?? "",
                                 StationID = transaction.Attribute("stationID").Value ?? "",
                                 StationName = transaction.Attribute("stationName").Value ?? "",
                                 TransactionType = transaction.Attribute("transactionType").Value ?? "",
                                 TransactionFor = transaction.Attribute("transactionFor").Value ?? "",
                                 JournalTransactionID = transaction.Attribute("journalTransactionID").Value ?? "",
                                 ClientTypeID = transaction.Attribute("clientTypeID").Value ?? ""
                             };
            
            // create new transaction for each record
            foreach (var transaction in transactions)
            {
                Transaction ta = new Transaction();

                ta.Time = DateTime.Parse(transaction.TransactionDateTime);
                ta.TransactionID = Int64.Parse(transaction.TransactionID);
                ta.Quantity = Int32.Parse(transaction.Quantity);
                ta.TypeName = transaction.TypeName;
                ta.TypeID = Int32.Parse(transaction.TypeID);
                ta.PricePerUnit = double.Parse(transaction.Price);
                ta.ClientID = Int32.Parse(transaction.ClientID);
                ta.ClientName = transaction.ClientName;
                ta.StationID = Int32.Parse(transaction.StationID);
                ta.StationName = transaction.StationName;
                ta.BuyOrder = transaction.TransactionType.Equals("buy") ? true : false;
                ta.TaFor = transaction.TransactionFor;
                ta.JournalTransactionID = Int64.Parse(transaction.JournalTransactionID);
                ta.ClientTypeID = Int32.Parse(transaction.ClientTypeID);

                TransactionInformation info = await TransactionInformation.Load(ta.TypeID);

                ta.MarketGroupID = info.MarketGroupIDTopLevel;
                ta.MarketGroupName = info.MarketGroupNameTopLevel;

                //TODO: Insert or ignore to make it faster?
                await sqliteTransactionData.InsertOrReplaceAsync(ta);
            }

            return false;
        }