private void UpdateButton_Click(object sender, EventArgs e)
        {
            var waitForm = new WaitFormFunc();

            waitForm.Show(this);

            _notificationService.DeleteAllRead();
            Principal?.UpdatedUnreadNotification();
            LoadNotification(_pageIndex, _pageSize);

            waitForm.Close();
        }
        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 guna2Button4_Click(object sender, EventArgs e)
        {
            var waitForm = new WaitFormFunc();

            waitForm.Show(this);
            var active = StatusComboBox.SelectedItem != null && StatusComboBox?.SelectedItem.ToString() == "Active";
            var check  = _customerService.Update(Customer.Id, active);

            waitForm.Close();
            if (check)
            {
                MessageBox.Show(@"Update success!");
                Patient.Instance.ReLoadData();
                this.Close();
            }
            else
            {
                MessageBox.Show(@"Update failed!");
            }
        }
Example #4
0
        private void guna2Button4_Click(object sender, EventArgs e)
        {
            var active = StatusComboBox.SelectedItem != null && StatusComboBox?.SelectedItem.ToString() == "Active";
            //var url = UrlTextBox.Text;
            var entity = new WeightVersionEntity
            {
                Id             = WeightVersionModel.Id,
                IsActive       = active,
                ClassVersionId = WeightVersionModel.ClassVersionId
            };
            var waitForm = new WaitFormFunc();

            waitForm.Show(this);
            _dataSetService.ApplyWeight(WeightVersionModel.Url);
            var updateStatus = false;
            var count        = 0;

            while (count < 10)
            {
                if (_weightService.GetWeightVersion(ClassVersionModel.Id) != null)
                {
                    updateStatus = _weightService.Update(entity);
                    break;
                }
                Thread.Sleep(500);
                count++;
            }

            waitForm.Close();
            if (updateStatus)
            {
                MessageBox.Show(@"Update success!");
                Version.Instance.ReLoadData();
                this.Close();
            }
            else
            {
                MessageBox.Show(@"Update 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.");
            }
        }