Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        public bool UploadTable()
        {
            if (!FTPService.CheckDirExist(ServerUserDataDirPath))
            {
                FTPService.CreateDir(ServerUserDataDirPath);
            }

            return(FTPService.UploadFile(LocalDataFilePath, Path.Combine(ServerUserDataDirPath, serverFile)));
        }
Ejemplo n.º 3
0
        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));
        }