Esempio n. 1
0
        private static void ExportOrders()
        {
            try
            {
                var path         = (Settings.Default.ExportPath + @"\").Replace(@"\\", @"\");
                var timestamp    = DateTime.Now.ToString(FILE_DATE_FORMAT);
                var accountsFile = path + "account_" + timestamp + ".csv";
                var ordersFile   = path + "orders_" + timestamp + ".csv";

                var client = new ExportDataServiceClient(_url, _token.SessionId, null, null);

                var orders   = Export(client, DataType.Orders);
                var accounts = Export(client, DataType.Accounts);

                File.WriteAllText(ordersFile, orders);
                File.WriteAllText(accountsFile, accounts);
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem when trying to export data");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                return;
            }
        }
Esempio n. 2
0
        private static string Export(ExportDataServiceClient client, DataType type)
        {
            var start = DateTime.Now.Date.Subtract(TimeSpan.FromDays(1)).Subtract(TimeSpan.FromSeconds(1));
            var end   = DateTime.Now.Date.Subtract(TimeSpan.FromSeconds(1));

            var request = new ExportDataRequest()
            {
                StartDate = start, EndDate = end, Target = type
            };
            var resultTask = client.GetOrders(request);

            resultTask.Wait();
            return(resultTask.Result.ToString());
        }