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;
        }
Ejemplo n.º 2
0
        public bool Update(WeightVersionEntity entity)
        {
            var url     = CommonService.GetUrlApi();
            var client  = new RestClient(url);
            var request = new RestRequest($"versions/{entity.ClassVersionId}/weights/{entity.Id}", Method.PUT);

            request.AddHeader("Authorization", UserLoginModel.AccessToken);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Charset", "utf-8");
            request.AddHeader("Connection", "close");
            var body = JObject.FromObject(entity);

            request.AddJsonBody(body.ToString());
            var response = client.Execute(request);

            if (response.StatusCode == System.Net.HttpStatusCode.NoContent)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
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!");
            }
        }