Example #1
0
        public static DataTable LoadRates(string currencyFrom, string currencyTo, string orderBy, string refreshFromWeb)
        {
            //should refresh from web?
            bool refreshWeb = string.IsNullOrEmpty(refreshFromWeb);

            ds.RatesDataTable rdt;
            loadRatesFromWeb(out rdt, refreshWeb);

            //filter by from
            if (!string.IsNullOrEmpty(currencyFrom))
            {
                var arr = rdt.WhereFrom(currencyFrom);
                rdt = TableTools.ImportRows(rdt, arr) as ds.RatesDataTable;
            }
            //filter by to
            if (!string.IsNullOrEmpty(currencyTo))
            {
                var arr = rdt.WhereTo(currencyTo);
                rdt = TableTools.ImportRows(rdt, arr) as ds.RatesDataTable;
            }

            //order by
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "from";
            }
            rdt = TableTools.SortBy(orderBy.Trim(), rdt) as ds.RatesDataTable;


            return(rdt);
        }
Example #2
0
        public static DataTable LoadTransactions(string desiredCurrency, string desiredSKU, string justTotals, string orderByColumn, string refreshFromWeb)
        {
            //should refresh from web?
            bool refreshWeb = string.IsNullOrEmpty(refreshFromWeb);

            ds.TransactionsDataTable tdt;
            loadTransactionsFromWeb(out tdt, refreshWeb);

            //filter by SKU
            desiredSKU = desiredSKU.Trim();
            if (!string.IsNullOrEmpty(desiredSKU))
            {
                var arr = tdt.WhereSKU(desiredSKU);
                tdt = TableTools.ImportRows(tdt, arr) as ds.TransactionsDataTable;
            }

            //order
            if (string.IsNullOrEmpty(orderByColumn.Trim()))
            {
                orderByColumn = "sku, currency";
            }
            tdt = TableTools.SortBy(orderByColumn.Trim(), tdt) as ds.TransactionsDataTable;


            desiredCurrency = desiredCurrency.Trim();
            bool fillTotals = !string.IsNullOrEmpty(justTotals);

            ds.RatesDataTable rdt = LoadRates(string.Empty, string.Empty, string.Empty, "n") as ds.RatesDataTable;

            DataTable dtResult = convertTransactionsRates(desiredCurrency, ref tdt, ref rdt, fillTotals);


            return(dtResult);
        }
Example #3
0
        private static void loadTransactionsFromWeb(out ds.TransactionsDataTable tdt, bool refreshFromWeb)
        {
            if (refreshFromWeb)
            {
                TableTools.GetTableFromWebAndStoreFile(txUri, currentTxFile);
            }

            DataTable txsRaw = TableTools.LoadTableFromFile(currentTxFile);

            tdt = new ds.TransactionsDataTable();
            TableTools.SerializeTableAs(tdt, ref txsRaw);
        }
Example #4
0
        private static void loadRatesFromWeb(out ds.RatesDataTable rdt, bool refreshFromWeb)
        {
            if (refreshFromWeb)
            {
                TableTools.GetTableFromWebAndStoreFile(rtxUri, currentRatesFile);
            }

            DataTable ratesRaw = TableTools.LoadTableFromFile(currentRatesFile);

            rdt = new ds.RatesDataTable();
            TableTools.SerializeTableAs(rdt, ref ratesRaw);

            if (refreshFromWeb)
            {
                fillMissingRates(ref rdt);
                rdt.AcceptChanges();
                rdt.WriteXml(currentRatesFile, XmlWriteMode.IgnoreSchema);
            }
        }
Example #5
0
        private void loadTables(string from, string desiredSKU, string refreshfromWebRts, string refreshfromWebTxs)
        {
            dataset = new ds();
            client  = new localhost.SPWS();

            //load rates
            DataTable dt      = client.LoadRates(from, string.Empty, string.Empty, refreshfromWebRts);
            DataTable destiny = dataset.Rates;

            TableTools.Merge(dt, destiny);

            //load txs
            DataTable txs = client.LoadTransactions(from, desiredSKU, string.Empty, string.Empty, refreshfromWebTxs);

            destiny = dataset.Transactions;
            TableTools.Merge(txs, destiny);

            //load totals
            txs     = client.LoadTransactions(from, desiredSKU, "y", string.Empty, "n");
            destiny = dataset.TransactionsTotals;
            TableTools.Merge(txs, destiny);
        }