Beispiel #1
0
        private async void menu_DeleteComment_Clicked(object sender, EventArgs e)
        {
            if (dgv_CommentList.SelectedRows == null || dgv_CommentList.SelectedRows.Count == 0)
            {
                return;
            }

            DeleteInformationRow row    = (dgv_CommentList.SelectedRows[0] as DeleteInformationRow);
            CommentInformation   target = row.CommentInformation;

            if (currentTask != CleanerTask.None)
            {
                return;
            }

            SetStatusMessage("리플을 삭제하는 중입니다...");

            currentTask = CleanerTask.DeleteGallogComments;

            try
            {
                await conn.DeleteComment(target, true);
            }
            catch
            {
                return;
            }

            // 갤로그와 갤러리 둘다 삭제 되었을 경우
            if (target.IsGalleryDeleted && target.IsGallogDeleted)
            {
                if (row.DataGridView != null)
                {
                    row.DataGridView.Rows.Remove(row);
                }
                gb_CommentGroup.Text = "내가 쓴 리플 [" + dgv_CommentList.Rows.Count.ToString() + "]";
                SetStatusMessage("리플을 삭제하였습니다.");
            }
            else
            {
                string rmErrMsg = "";
                if (!target.IsGalleryDeleted)
                {
                    rmErrMsg = "리플을 삭제하는데 실패하였습니다. - 갤러리 삭제 실패";
                }
                else
                {
                    rmErrMsg = "리플을 삭제하는데 실패하였습니다. - 갤로그 삭제 실패";
                }

                SetStatusMessage(rmErrMsg);
            }

            currentTask = CleanerTask.None;
        }
Beispiel #2
0
        /// <summary>
        /// 댓글 목록 삭제 함수
        /// </summary>
        /// <param name="both">True : 갤로그도 False : 갤러리만</param>
        private void RemoveComments(bool both)
        {
            if (commentList == null || commentList.Count == 0)
            {
                return;
            }

            if (loadingThread != null && loadingThread.IsAlive)
            {
                return;
            }

            loadingThread = new Thread(new ThreadStart(delegate()
            {
                int rmIdx  = 0; // 삭제 인덱스. 0부터 위로
                int delCnt = commentList.Count;

                for (int i = 0; i < delCnt; i++)
                {
                    CommentInfo info = commentList[rmIdx];
                    CommentInfo res  = null;
                    try
                    {
                        res = conn.DeleteComment(info, both);
                    }
                    catch (ThreadAbortException) { throw; }
                    catch
                    {
                        // 삭제 못한 리플은 무시
                        rmIdx++;
                        continue;
                    }

                    if (!res.ActualDelete || (both && !res.GallogDelete))
                    {
                        for (int j = 0; j < 1; j++)
                        {
                            // 실패시, Sleep 후 1회 재시도
                            Thread.Sleep(100);
                            res = conn.DeleteComment(info, both);
                            if (res.ActualDelete && (!both || res.GallogDelete))
                            {
                                break;
                            }
                        }
                    }

                    // 재시도에도 삭제 실패했을 경우,
                    if (!res.ActualDelete || (both && !res.GallogDelete))
                    {
                        rmIdx++;
                        continue;   // 무시
                    }

                    info.ActualDelete  = res.ActualDelete;
                    info.GallogDelete  = res.GallogDelete;
                    info.DeleteMessage = res.DeleteMessage;

                    commentList[rmIdx] = info;

                    // 갤로그도 삭제일 경우에만 화면 지움
                    if (both)
                    {
                        commentList.RemoveAt(rmIdx);
                        this.Invoke(new Action(() =>
                        {
                            dgv_CommentList.Rows.RemoveAt(rmIdx);
                            gb_CommentGroup.Text = "내가 쓴 리플 [" + commentList.Count.ToString() + "]";
                        }));
                    }
                }

                if (both)
                {
                    SetStatusMessage("쓴 리플 - 갤로그도 삭제 완료");
                }
                else
                {
                    SetStatusMessage("쓴 리플 - 갤러리만 삭제 완료");
                }
            }));

            if (both)
            {
                SetStatusMessage("쓴 리플 - 갤로그도 삭제중...");
            }
            else
            {
                SetStatusMessage("쓴 리플 - 갤러리만 삭제중...");
            }

            loadingThread.Start();
        }