Ejemplo n.º 1
0
        void DownlooadDb()
        {
            try {
                //backup db first before upload
                //	UploadDbHelper.BackupDatabase();

                WebClient myWebClient   = new WebClient();
                var       sdcard        = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "erpdata");
                string    filename      = COMPCODE + "_" + BRANCODE + "_" + USERID + "_erplite.db";
                string    url           = WCFHelper.GetDownloadDBUrl() + filename;
                string    localfilename = Path.Combine(sdcard, "erplite.db");
                if (File.Exists(localfilename))
                {
                    File.Delete(localfilename);
                }

                DownloadFileHelper downfile = new DownloadFileHelper(this);
                downfile.OnFinishDownloadHandle += Downfile_OnFinishDownloadDBHandle;
                downfile.StartDownload(url, localfilename);

//				myWebClient.DownloadFile (url, localfilename);
//				File.Copy (localfilename, pathToDatabase, true);
//
//				//delete the file after downloaded
//				string urldel = WCFHelper.GeUploadDBUrl()+"/afterdownload.aspx?ver=3&ID="+filename;
//				WebRequest request = HttpWebRequest.Create(urldel);
//				request.GetResponse();
//
//				Toast.MakeText (this, Resources.GetString(Resource.String.msg_successdowndb), ToastLength.Long).Show ();
            } catch (Exception ex)
            {
                Toast.MakeText(this, Resources.GetString(Resource.String.msg_faildowndb), ToastLength.Long).Show();
            }
        }