public async void BackupStorageFileList() { nlog.Warn("BackupStorageFileList Started"); workBackupStorage = true; StatusUpdate(Status.Working); try { ConfigSaveAllItem(); updateRestoreStatus(); Task <string> result = getObjectStorageBackupListAync(textInternalFolder.Text); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; string getObjectStorageBackupListResult = await result; if (getObjectStorageBackupListResult.Contains("server does not exists")) { throw new Exception("There is no corresponding server. Perform the Configuration steps again."); } if (getObjectStorageBackupListResult.Contains("totalRows")) { getObjectStorageBackupList getObjectStorageBackupList = JsonConvert.DeserializeObject <getObjectStorageBackupList>(getObjectStorageBackupListResult, settings); List <DmsFileList> files = getObjectStorageBackupList.getObjectStorageBackupListResponse.dmsFileList; long uiRefresh = 0; dgvBackupStorage.InvokeIfRequired(s => { s.Rows.Clear(); s.RowHeadersVisible = false; s.BackgroundColor = Color.White; }); foreach (var file in files) { if ((System.Text.RegularExpressions.Regex.IsMatch(file.fileName, textFilterString.Text, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) || textFilterString.Text.Length == 0) { string RequestNo = string.Empty; string RequestReturnCode = string.Empty; string ReturnCode = string.Empty; string ReturnCodeName = string.Empty; if (apiResponses.ContainsKey(new Tuple <string, string, string>(config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo), config.GetEnumValue(Category.Upload, Key.NewDatabaseName), file.fileName))) { RequestNo = apiResponses[new Tuple <string, string, string>(config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo), config.GetEnumValue(Category.Upload, Key.NewDatabaseName), file.fileName)].requestNo; RequestReturnCode = apiResponses[new Tuple <string, string, string>(config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo), config.GetEnumValue(Category.Upload, Key.NewDatabaseName), file.fileName)].requestReturnCode; ReturnCode = apiResponses[new Tuple <string, string, string>(config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo), config.GetEnumValue(Category.Upload, Key.NewDatabaseName), file.fileName)].returnCode; ReturnCodeName = apiResponses[new Tuple <string, string, string>(config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo), config.GetEnumValue(Category.Upload, Key.NewDatabaseName), file.fileName)].returnCodeName; } dgvBackupStorage.InvokeIfRequired(s => { int n = s.Rows.Add(); s.Rows[n].Cells[0].Value = "false"; s.Rows[n].Cells[1].Value = file.fileName; s.Rows[n].Cells[2].Value = file.fileLength; s.Rows[n].Cells[3].Value = String.Format("{0:yyyy-MM-dd HH:mm:ss}", System.DateTime.Parse(file.lastWriteTime)); s.Rows[n].Cells[4].Value = RequestNo; s.Rows[n].Cells[5].Value = RequestReturnCode; s.Rows[n].Cells[6].Value = ReturnCode; s.Rows[n].Cells[7].Value = ReturnCodeName; }); if (uiRefresh % 100 == 0) { StatusUpdate(Status.Working); } uiRefresh++; } } } else if (getObjectStorageBackupListResult.Contains("errorCode")) { var responseError = JsonConvert.DeserializeObject <Error>(getObjectStorageBackupListResult, settings); string errorMessage = $@"errorMessage : {responseError.responseError.message}, errorCode : {responseError.responseError.errorCode}, details : {responseError.responseError.details}"; throw new Exception(errorMessage); } else { var responseError = JsonConvert.DeserializeObject <ResponseError>(getObjectStorageBackupListResult, settings); string errorMessage = $@"returnMessage : {responseError.responseError.returnMessage}, returnCode : {responseError.responseError.returnCode}"; throw new Exception(errorMessage); } } catch (Exception ex) { nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); MessageBox.Show($@"ex.Message : {ex.Message}"); } finally { workBackupStorage = false; } StatusUpdate(Status.Completed); nlog.Warn("BackupStorageFileList Completed"); }
public async void InternalStorageFileList() { nlog.Warn("InternalStorageFileList Started"); workInternalStorage = true; StatusUpdate(Status.Working); try { ConfigSaveAllItem(); dgvInternalStorage.InvokeIfRequired(s => { s.Rows.Clear(); s.RowHeadersVisible = false; s.BackgroundColor = Color.White; }); string getObjectStorageBackupListResult = await getObjectStorageBackupListAsync(); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (getObjectStorageBackupListResult.Contains("server does not exists")) { throw new Exception("There is no corresponding server. Perform the Configuration steps again."); } if (getObjectStorageBackupListResult.Contains("totalRows")) { getObjectStorageBackupList getObjectStorageBackupList = JsonConvert.DeserializeObject <getObjectStorageBackupList>(getObjectStorageBackupListResult, settings); List <DmsFileList> files = getObjectStorageBackupList.getObjectStorageBackupListResponse.dmsFileList; foreach (var file in files) { if ( (System.Text.RegularExpressions.Regex.IsMatch ( file.fileName , textFilterString.Text , System.Text.RegularExpressions.RegexOptions.IgnoreCase ) ) || textFilterString.Text.Length == 0 ) { string RequestNo = string.Empty; string RequestReturnCode = string.Empty; string ReturnCode = string.Empty; string ReturnCodeName = string.Empty; dgvInternalStorage.InvokeIfRequired(s => { int n = s.Rows.Add(); s.Rows[n].Cells[0].Value = "false"; s.Rows[n].Cells[1].Value = file.fileName; s.Rows[n].Cells[2].Value = file.fileLength; s.Rows[n].Cells[3].Value = String.Format("{0:yyyy-MM-dd HH:mm:ss}", System.DateTime.Parse(file.lastWriteTime)); }); } } } else { var responseError = JsonConvert.DeserializeObject <ResponseError>(getObjectStorageBackupListResult, settings); string errorMessage = $@"returnMessage : {responseError.responseError.returnMessage}, returnCode : {responseError.responseError.returnCode}"; throw new Exception(errorMessage); } } catch (Exception ex) { nlog.Error(string.Format("{0},{1}", ex.Message, ex.StackTrace)); workInternalStorage = false; MessageBox.Show(ex.Message); } StatusUpdate(Status.Completed); workInternalStorage = false; nlog.Warn("InternalStorageFileList Completed"); }