예제 #1
0
파일: Form1.cs 프로젝트: Plus3531/sitmil
        private async void buttonUpdateProg_Click(object sender, EventArgs e)
        {
            if (_milestoneTasks == null)
            {
                button1_Click(sender, e);
            }
            if (_milestoneTasks == null) return;
            var progTask = _milestoneTasks.FirstOrDefault(m => m.Name.ToLower().Contains("prog"));
            if (progTask == null) return;

            var ticks = dateTimePickerDateProg.Value.Ticks;
            var url = string.Format("{0}/odata/DTasks({1})/UpdateEndTime", PreparedHttpClient.GetSituatorWebApiUrl(), progTask.Id);
            var progComment = new PrognoseDTaskEventComment
            {
                Duur = Convert.ToInt32(comboBoxProgDuur.SelectedItem),
                HandmatigGezetIndicatie = comboBoxProgHGI.SelectedItem.ToString(),
                Type = comboBoxProgType.SelectedItem.ToString(),
                RedenWijziging = textBoxProgRedenWijziging.Text,
                DatumTijd = DateTime.Now.ToUniversalTime()
            };
            var httpClient = await PreparedHttpClient.GetInstance();
            var json = JsonConvert.SerializeObject(progComment, new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fffZ" });
            var umt = new UpdateMilestoneTask { Comment = json, PlannedEndTime = ticks.ToString() };
            var formatter = new JsonMediaTypeFormatter { SerializerSettings = { NullValueHandling = NullValueHandling.Ignore } };
            var content = new ObjectContent<UpdateMilestoneTask>(umt, formatter);
            var response = await httpClient.PostAsync(url, content);
            Console.WriteLine(response);
            if (!response.IsSuccessStatusCode)
            {
                MessageBox.Show(response.Content.ReadAsStringAsync().Result);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: Plus3531/sitmil
        private async void buttonUpdateTis_Click(object sender, EventArgs e)
        {
            if (_milestoneTasks == null)
            {
                button1_Click(sender, e);
            }
            if (_milestoneTasks == null) return;
            var tisTask = _milestoneTasks.FirstOrDefault(m => m.Name.ToLower().Contains("scenario"));
            if (tisTask == null) return;

            var ticks = dateTimePickerDateTis.Value.Ticks;
            var url = string.Format("{0}/odata/DTasks({1})/UpdateEndTime", PreparedHttpClient.GetSituatorWebApiUrl(), tisTask.Id);

            var commentScenario = new ScenarioDTaskEventComment
            {
                Tis = comboBoxTis.SelectedItem.ToString(),
                WijzigingsType = comboBoxTisWijzigingsType.SelectedItem.ToString()
            };
            var httpClient = await PreparedHttpClient.GetInstance();
            var json = JsonConvert.SerializeObject(commentScenario);
            var umt = new UpdateMilestoneTask { Comment = json, PlannedEndTime = ticks.ToString() };
            var formatter = new JsonMediaTypeFormatter { SerializerSettings = { NullValueHandling = NullValueHandling.Ignore } };
            var content = new ObjectContent<UpdateMilestoneTask>(umt, formatter);
            var response = await httpClient.PostAsync(url, content);
            Console.WriteLine(response);
            if (!response.IsSuccessStatusCode)
            {
                MessageBox.Show(response.Content.ReadAsStringAsync().Result);
            }
        }