Ejemplo n.º 1
0
        void statDownload(Uri url, string localfilename)
        {
            if (NeedBackupDb)
            {
                UploadDbHelper.BackupDatabase();
            }

            WebClient myWebClient = new WebClient();

            myWebClient.DownloadProgressChanged += MyWebClient_DownloadProgressChanged;
            myWebClient.DownloadFileCompleted   += MyWebClient_DownloadFileCompleted;
            Thread.Sleep(50);
            try {
                myWebClient.DownloadFileAsync(url, localfilename);
            } catch (Exception ex) {
                filename = "";
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 2
0
//		void BackupDatabase ()
//		{
//			var sdcard = Path.Combine (Android.OS.Environment.ExternalStorageDirectory.Path, "erpdata");
//			if (!Directory.Exists (sdcard)) {
//				Directory.CreateDirectory (sdcard);
//			}
//			string filename = Path.Combine (sdcard,"erplite"+ DateTime.Now.ToString("yyMMddHHmm") +".db");
//			if (File.Exists (pathToDatabase)) {
//				File.Copy (pathToDatabase, filename, true);
//				filename = ZipHelper.GetZipFileName(filename);
//				UploadToErpHostForSupport (filename);
//			}
//		}
//
//		private void UploadToErpHostForSupport(string filename)
//		{
//			WebClient myWebClient = new WebClient ();
//			try {
//
//				myWebClient.QueryString ["COMP"] = COMPCODE;
//				myWebClient.QueryString ["BRAN"] = BRANCODE;
//				myWebClient.QueryString ["USER"] = USERID;
//				if (filename.ToLower().Contains(".zip"))
//				{
//					//upload zip db file and extract
//					byte[] responseArray = myWebClient.UploadFile (@"http://www.wincomcloud.com/UploadDb/uploadDbEx.aspx", filename);
//				}else{
//					//upload db file
//					byte[] responseArray = myWebClient.UploadFile (@"http://www.wincomcloud.com/UploadDb/uploadDb.aspx", filename);
//				}
//
//			} catch {
//
//			}
//		}

        void butBackUpDb(object sender, EventArgs e)
        {
            UploadDbHelper.BackupDatabase();
        }