private void Profile_Load(object sender, EventArgs e)
        {
            var createdDate       = DateTime.Now;
            var lastWeightVersion = _weightService.GetWeightVersion(ClassVersionModel.Id);

            _weightVersionEntity = new WeightVersionEntity()
            {
                CreatedDate    = createdDate,
                ClassVersionId = ClassVersionModel.Id,
                Version        = (int.Parse(lastWeightVersion?.Version ?? "0") + 1).ToString()
            };
            CreatedDateTextBox.Text   = createdDate.ToString("dd/MM/yyyy");
            VersionTextBox.Text       = ClassVersionModel.Version;
            WeightVersionTextBox.Text = _weightVersionEntity.Version;
        }
Esempio n. 2
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!");
            }
        }