private void Create_Click(object sender, EventArgs e) { var waitForm = new WaitFormFunc(); waitForm.Show(this); var check = _weightService.Create(ClassVersionModel.Id, _weightPath, "", ""); waitForm.Close(); if (check) { MessageBox.Show(@"Create success!"); Version.Instance.ReLoadData(); this.Close(); } else { MessageBox.Show(@"Create failed!"); } }
private void DownloadWeightBtn_Click(object sender, EventArgs e) { if (NotificationGridView.CurrentRow?.DataBoundItem is NotificationModel currentNotification) { if (!string.IsNullOrEmpty(currentNotification.Url)) { using (var fbd = new FolderBrowserDialog()) { DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) { if (Directory.GetFiles(fbd.SelectedPath).Length != 0) { MessageBox.Show(@"Folder is not empty. Please choose another folder.", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Warning); return; } if (currentNotification.IsSuccess && (currentNotification.Message?.ToLower().Contains(ApplicationConstant.NotificationSuccess) ?? false)) { var waitForm = new WaitFormFunc(); waitForm.Show(this); var downloadSuccess = _dataSetService.DownloadWeight(currentNotification, fbd.SelectedPath); if (downloadSuccess) { Task.Run(() => _notificationService.UpdateDownloadedNotification(currentNotification.Id)); currentNotification.IsSuccess = false; var weightPath = Path.Combine(fbd.SelectedPath, Path.GetFileName(currentNotification.Url)); var logPath = Path.Combine(fbd.SelectedPath, Path.GetFileName(currentNotification.LogPath)); var lossPath = Path.Combine(fbd.SelectedPath, Path.GetFileName(currentNotification.LossFunctionPath)); var lastClass = _classVersionService.GetLastClassVersion(); var check = _weightService.Create(lastClass.Id, weightPath, lossPath, logPath); waitForm.Close(); if (check) { MessageBox.Show($@"Model save at: {fbd.SelectedPath}", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information); MessageBox.Show(@"Create new model version successfully", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information); DownloadWeightBtn.Enabled = false; } else { MessageBox.Show($@"Model save at: {fbd.SelectedPath}\n Create new weight version successfully", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information); MessageBox.Show(@"Fail to create new model version", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); } } else { waitForm.Close(); MessageBox.Show(@"The model could not be downloaded. Please try again later.", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); } } else { if (currentNotification.Message?.ToLower().Contains(ApplicationConstant.NotificationError) ?? false) { var waitForm = new WaitFormFunc(); waitForm.Show(this); var downloadSuccess = _dataSetService.DownloadLog(currentNotification, fbd.SelectedPath); if (downloadSuccess) { waitForm.Close(); MessageBox.Show($@"Log save at: {fbd.SelectedPath}", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information); } else { waitForm.Close(); MessageBox.Show(@"Training log could not be downloaded. Please try again later.", @"Message", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); } } //MessageBox.Show(@"Training failed and doesn't have model to download"); } } } } else { MessageBox.Show(@"There is no model to download."); } } else { MessageBox.Show(@"Please select 1 row."); } }