public void updateDataBaseFromJson(DropboxNemiro dropboxNemiro)
        {
            String versionJsonPath = ConstantPath.jsonPath + ConstantPath.verJson;
            String productJsonPath = ConstantPath.jsonPath + ConstantPath.productJson;
            String orderJsonPath   = ConstantPath.jsonPath + ConstantPath.orderJson;

            dropboxNemiro.downloadFileFromDropbox();
            if (File.Exists(productJsonPath))
            {
                List <Product> products = JsonHelper.loadProductsFromJson(File.ReadAllText(productJsonPath));
                DBhelper.removeAllProduct();        //remove all db in local
                foreach (Product pro in products)   //add new db from json
                {
                    DBhelper.addProduct(pro);
                }
            }

            //if (File.Exists(orderJsonPath))
            //{
            //    List<Order> orders = JsonHelper.loadOrdersFromJson(File.ReadAllText(orderJsonPath));
            //foreach (Order ord in orders)
            //{
            //    DBhelper.updateProductByID(pro);
            //}
            //}

            //save version in local
            if (File.Exists(versionJsonPath))
            {
                VersionUpload versionUpload = JsonHelper.loadVersionUploadFromJson(File.ReadAllText(versionJsonPath));
                Properties.Settings.Default.FinalVersionUpload = Convert.ToString(versionUpload.time);
            }
        }
        public void prepareJsonFile()
        {
            //info file
            VersionUpload versionUpload = new VersionUpload(TimeUtils.getCurrentTimeInMilisecond(), System.Environment.MachineName);
            String        jsonVersion   = JsonHelper.ParseVersionUploadToJson(versionUpload);

            MainUtils.writeFileJson(jsonVersion, ConstantPath.jsonPath + ConstantPath.verJson);

            String json = JsonHelper.ParseProductsToJson(DBhelper.getAllProduct());

            MainUtils.writeFileJson(json, ConstantPath.jsonPath + ConstantPath.productJson);
            //json = JsonHelper.ParseOrdersToJson(DBhelper.getAllOrder());
            //MainUtils.writeFileJson(json, ConstantPath.jsonPath + ConstantPath.orderJson);

            //save version in local
            Properties.Settings.Default.FinalVersionUpload = Convert.ToString(versionUpload.time);
        }
        public bool checkVersionUpload(DropboxNemiro dropboxNemiro)      //true - new    false - old
        {
            String versionPath = ConstantPath.jsonPath + ConstantPath.verJson;

            {
                dropboxNemiro.downloadFileVersionFromDropbox();
                if (File.Exists(versionPath))
                {
                    double currentTime = TimeUtils.getCurrentTimeInMilisecond();

                    VersionUpload versionUpload = JsonHelper.loadVersionUploadFromJson(File.ReadAllText(versionPath));
                    if (versionUpload.time != Double.Parse(Properties.Settings.Default.FinalVersionUpload))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }