private async void btnSendReview_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCarOvner.Text) || string.IsNullOrEmpty(txtReview.Text)) { MessageBox.Show(@"Поле Номер 'Имя владельца авто' и 'Отзыв' обязательны для заполнения"); return; } var currentStatus = PanelRefresh.StartRefresh(this, pbReview); await Task.Run(() => { var review = new Review { ReviewDateTime = DateTime.Now, SourceUrl = null, UserName = txtCarOvner.Text, UserReview = txtReview.Text }; history.Review = review; RequestExecutor.Execute(() => { var result = WCFServiceFactory.CreateVtecTeamService().UpdateReflashHistory(history); this.Invoke(() => pbReview.Image = !result ? Properties.Resources.Error : null); MessageBox.Show(result ? "Запрос успешно отправлен" : "Не удалось отправить запрос."); }); }); pbReview.Visible = false; PanelRefresh.StopRefresh(currentStatus); }
private async void btnSendComment_Click(object sender, EventArgs e) { var currentStatus = PanelRefresh.StartRefresh(this, pbSendComment); await Task.Run(() => { var comment = new Comment { CommentDate = DateTime.Now, CommentText = txtComment.Text, RequestId = request.Id, //UserId = Session.CurrentUser.Id, User = Session.CurrentUser }; RequestExecutor.Execute(() => { var savedComment = WCFServiceFactory.CreateVtecTeamService().SendComment(comment); this.Invoke(() => pbRefreshRequest.Image = !savedComment.Result ? Properties.Resources.Error : null); this.Invoke(() => { if (savedComment.Result) { AddNode(txtUserName.Text, comment.CommentText, comment.CommentDate); txtComment.Text = ""; comment.Id = savedComment.EntityId; // f*****g magic to add new item in fixed size array var commentsArray = request.Comments.ToArray(); Array.Resize(ref commentsArray, commentsArray.Length + 1); commentsArray[commentsArray.Length - 1] = comment; request.Comments = commentsArray; } else { MessageBox.Show("Не удалось отправить комментарий."); } }); }); }); pbSendComment.Visible = false; PanelRefresh.StopRefresh(currentStatus); }
private async void btnRefreshRequest_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtRequestCarDescription.Text)) { MessageBox.Show("Поле Номер Машина обязательно для заполнения"); return; } var currentStatus = PanelRefresh.StartRefresh(this, pbRefreshRequest); await Task.Run(() => { request.BinaryNumber = txtEcuBinaryNumber.Text; request.CarDescription = txtRequestCarDescription.Text; request.EcuNumber = txtEcuNumber.Text; request.RequestDetails = txtAdditionalInfo.Text; request.UserId = Session.CurrentUser.Id; request.RequestDate = DateTime.Now; request.Status = (int)RequestStatuses.New; if (File.Exists(txtEcuPhotoStatus.Text)) { request.EcuPhoto = File.ReadAllBytes(txtEcuPhotoStatus.Text); request.EcuPhotoFilename = Path.GetFileName(txtEcuPhotoStatus.Text); } RequestExecutor.Execute(() => { var result = WCFServiceFactory.CreateVtecTeamService().SendRequest(request); this.Invoke(() => pbRefreshRequest.Image = !result ? Properties.Resources.Error : null); MessageBox.Show(result ? "Запрос успешно отправлен" : "Не удалось отправить запрос."); }); }); pbRefreshRequest.Visible = false; PanelRefresh.StopRefresh(currentStatus); }