private async Task UploadFile() { string serverDirPath = AppEnvironment.dataService.ServerUserDataDirPath + "/"; await Task.Delay(10); try { UploadButton.IsEnabled = false; UploadButton.Text = AppResources.Uploading; if (!FTPService.CheckDirExist(serverDirPath)) { FTPService.CreateDir(serverDirPath); } isUploaded = FTPService.UploadFile(recordFilePath, Path.Combine(serverDirPath, Path.GetFileName(recordFilePath))); if (!isUploaded) { throw new Exception("Cannot upload file"); } } catch (Exception ex) { #if DEBUG DependencyService.Get <IToast>().Show(ex.ToString()); #endif DependencyService.Get <IToast>().Show(AppResources.UploadFail_ReUpload); UploadButton.IsEnabled = true; } finally { UploadButton.Text = AppResources.Upload; RecordButton.IsEnabled = true; RecordButton.Text = File.Exists(recordFilePath) ? AppResources.Re_Record : AppResources.Record; } try { (BindingContext as VoiceRecordDetailViewModel).UpdateItemInfo(isRecorded, isUploaded); DependencyService.Get <IToast>().Show(AppResources.Upload_Success); } catch (Exception) { DependencyService.Get <IToast>().Show("Cannot update info"); } finally { UploadButton.IsEnabled = true; UploadButton.Text = isUploaded ? AppResources.ReUpload : AppResources.Upload; UpdateButtonStatus(); recorder = null; } }
public bool UploadTable() { if (!FTPService.CheckDirExist(ServerUserDataDirPath)) { FTPService.CreateDir(ServerUserDataDirPath); } return(FTPService.UploadFile(LocalDataFilePath, Path.Combine(ServerUserDataDirPath, serverFile))); }
public bool UploadFirstVoiceStatus() { string filePath = Path.Combine(LocalDataPath, firstVoiceSetStatusFile); string serverPath = Path.Combine(ServerUserDataDirPath, firstVoiceSetStatusFile); if (!FTPService.CheckDirExist(ServerUserDataDirPath)) { FTPService.CreateDir(ServerUserDataDirPath); } return(FTPService.UploadFile(filePath, serverPath)); }
public bool DownloadTable() { string serverPath = Path.Combine(FTPService.CheckDirExist(ServerUserDataDirPath) ? ServerUserDataDirPath : ServerDefaultDataDirPath, serverFile); return(FTPService.DownloadFile(LocalDataFilePath, serverPath)); }