Exemple #1
0
        public async Task <bool> SyncFromServer(int method)
        {
            timeStart        = DateTime.Now;
            totalRowInserted = 0;
            totalRowUpdated  = 0;

            Debug.WriteLine("Sync Product From Server Started!");

            var response = await restClient.GetStringAsync(ApiURI.URL_BASE(CurrentAccount) + ApiURI.URL_GET_PRODUCTS(CurrentUserName, Settings.CurrentPassword, Settings.LastSyncInvoice));

            if (!string.IsNullOrWhiteSpace(response) && !response.Equals("[]") && !(response.Contains("SUCCESS\":\"No result") || response.Equals("{\"SUCCESS\":\"No result\"}")))
            {
                ProcessData(response);
            }
            else
            {
                SetLastSyncProduct();
            }

            Debug.WriteLine("Sync Product Time: " + DateTime.Now.Subtract(timeStart).TotalSeconds);
            Debug.WriteLine("Total Product Inserted: " + totalRowInserted);
            Debug.WriteLine("Total Product Updated: " + totalRowUpdated);

            Debug.WriteLine("Sync Product From Server Ended!");

            return(await Task.FromResult(true));
        }