コード例 #1
0
        private int DeleteBoard()
        {
            try
            {
                Board_Tx_Dac  oWS         = new Board_Tx_Dac();
                Board_NTx_Dac oWSN        = new Board_NTx_Dac();
                int           RemoveIdx   = IntegerUtil.intValid(WebUtil.SCRequestFormString("hdfIdx", string.Empty), 0);
                int           ReturnValue = 0;

                DataSet ds         = oWSN.TOTALBBS_BOARD_VIEW_FILE_INFO_SEL(RemoveIdx);
                int     FileDelCnt = ds.Tables[0].Rows.Count;

                ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_VIEW_DEL(RemoveIdx, FileDelCnt);
                if (ReturnValue > 0)
                {
                    DataTable dt = ds.Tables[0];
                    foreach (DataRow dr in dt.Rows)
                    {
                        LocalFileControls.FileDelete(FileUploadPath, dr["strFileName"].ToString());
                    }
                }
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                #region [Error Logger] 로그인을 한경우
                //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex, admin.MemberId, admin.MemberNm);
                #endregion

                return(0);
            }
        }
コード例 #2
0
        private int UpdateBoard()
        {
            try
            {
                Board_Tx_Dac  oWS  = new Board_Tx_Dac();
                Board_NTx_Dac oWSN = new Board_NTx_Dac();

                int    ModIdx           = IntegerUtil.intValid(WebUtil.SCRequestFormString("hdfIdx", string.Empty), 0);
                int    intBoardCategory = Convert.ToInt32(WebUtil.SCRequestFormString("ddlBoardCategory", "1"));
                int    intWriteCategory = Convert.ToInt32(WebUtil.SCRequestFormString("ddlWriteCategory", "1"));
                string strUserId        = WebUtil.SCRequestFormString("txtUserId", string.Empty);
                string strWriter        = WebUtil.SCRequestFormString("txtWriter", string.Empty);
                string strSubject       = WebUtil.SCRequestFormString("txtSubject", string.Empty);
                string strContent       = WebUtil.SCRequestFormString("txtContent", string.Empty);

                string ChkBoxListData = string.Empty;

                DataSet   ds              = null;
                DataTable dt              = null; // 삭제할 목록 조회
                DataTable dt1             = null; // 삭제하지 않는 목록 조회
                int       NoDeleteFileCnt = 0;    // 삭제하지 않는 파일 수

                //파일 리스트 조회(삭제할 목록과 삭제 하지 않을 목록 분리하여 가져옴)
                //체크박스 선택 여부
                if (ModIdx > 0 && Request.Form["chkAttached_" + ModIdx + ""] != null)
                {
                    ChkBoxListData = Request.Form["chkAttached_" + ModIdx + ""].ToString();
                    ds             = oWSN.TOTALBBS_BOARD_FILE_INFO_SEL(ModIdx, ChkBoxListData);
                }
                else
                {
                    ChkBoxListData = "0";
                    ds             = oWSN.TOTALBBS_BOARD_FILE_INFO_SEL(ModIdx, ChkBoxListData);
                }

                string OldFileName    = string.Empty;
                string NewFileName    = string.Empty;
                string FileUploadPath = string.Empty;

                if (ds != null)
                {
                    dt  = ds.Tables[0];   // 삭제할 목록 조회
                    dt1 = ds.Tables[1];   // 삭제하지 않는 목록 조회
                    if (dt1.Rows.Count > 0)
                    {
                        NoDeleteFileCnt = dt1.Rows.Count;
                    }
                }

                int             iData           = 0;
                List <FileBean> GecAttachedList = new List <FileBean>();
                if (ds != null)
                {
                    //삭제 하지 않을 목록을 조회 하여 처리
                    foreach (DataRow dr in dt1.Rows)
                    {
                        if (iData == 0)
                        {
                            OldFileName    = dr["strRealFileName"].ToString();
                            NewFileName    = dr["strFileName"].ToString();
                            FileUploadPath = dr["strFilePath"].ToString();
                        }
                        iData = iData + 1;
                        FileBean AFBean = new FileBean();
                        AFBean.strRealFileName = dr["strRealFileName"].ToString();  // 파일 원본 이름
                        AFBean.strFileName     = dr["strFileName"].ToString();      // 파일 업로드후 생성된 새이름
                        AFBean.strFilePath     = dr["strFilePath"].ToString();      // 파일 업로드 경로 디비에 넣지 않는경우 /FileUpload/  + FileUploadPath경로 수동 입력 해도됨
                        AFBean.intFileSort     = iData;
                        GecAttachedList.Add(AFBean);
                    }
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            for (int i = 0; i < 1; i++)
                            {
                                FileUploadPath = dr["strFilePath"].ToString();
                            }
                        }
                    }
                }

                HttpFileCollection files = HttpContext.Current.Request.Files;

                int FileTotalCnt = files.Count;
                int FileSort     = 0;


                // 웹 취약성 추가 파일 첨부시 aspx 에서 검사 후 cs 단에서 한번 더 검사
                string[] ContentType = null;        // 첨부파일 타입 구분배열 변수

                #region [파일 업로드 정보를 조회]
                if (FileTotalCnt > 0)
                {
                    for (int i = 0; i < FileTotalCnt; i++)
                    {
                        HttpPostedFile postedFile = files[i];
                        FileBean       AFBean     = new FileBean();

                        FileSort = iData + i;
                        string[] FilesInfo1 = new string[3];

                        ContentType = postedFile.ContentType.Split('/');
                        //빈파일일때
                        if (postedFile.ContentLength > 1)
                        {
                            FilesInfo1 = FileName(postedFile);

                            if (FilesInfo1 != null)
                            {
                                if (FileSort == 0)
                                {
                                    OldFileName    = FilesInfo1[0];
                                    NewFileName    = FilesInfo1[1];
                                    FileUploadPath = FilesInfo1[2];
                                }
                                AFBean.strRealFileName = FilesInfo1[0];     // 파일 원본 이름
                                AFBean.strFileName     = FilesInfo1[1];     // 파일 업로드후 생성된 새이름
                                AFBean.strFilePath     = FilesInfo1[2];     // 파일 업로드 경로 디비에 넣지 않는경우 /FileUpload/  + FileUploadPath경로 수동 입력 해도됨
                                AFBean.intFileSort     = FileSort + 1;
                                GecAttachedList.Add(AFBean);
                            }
                            else
                            {
                                FileTotalCnt = 0;
                            }
                        }
                        else
                        {
                            FileTotalCnt = 0;
                        }
                    }
                }
                #endregion

                int MasterReturnValue = 0;
                int ReturnValue       = 0;

                MasterReturnValue = oWS.TOTALBBS_BOARD_INFO_UPD(ModIdx, intBoardCategory, intWriteCategory, strUserId, strWriter, strSubject, strContent);

                if (MasterReturnValue > 0)
                {
                    if (GecAttachedList.Count > 0)
                    {
                        foreach (FileBean Item in GecAttachedList)
                        {
                            ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_UPD(ModIdx, Item.strRealFileName, Item.strFileName, Item.strFilePath, Item.intFileSort);
                        }
                    }
                    else
                    {
                        //전체 제크 및 한개만 있을때 체크 했을때
                        ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_DEL_SELECTED(ChkBoxListData);
                    }
                }

                //첨부파일 등록이 하나도 없을시
                if (GecAttachedList.Count.Equals(0))
                {
                    ReturnValue = -10;
                }
                //체크박스 선택 파일 삭제 시키기
                if (!ChkBoxListData.Equals("0"))
                {
                    //삭제
                    foreach (DataRow dr in dt.Rows)
                    {
                        //경로를 넘기는데 \\ 수가 맞지 않아 메서드 추가함 수정시 삭제에 사용
                        LocalFileControls.FileDelete_New(FileUploadPath, dr["strFileName"].ToString());
                    }
                }
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                #region [Error Logger] 로그인을 한경우
                //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex, admin.MemberId, admin.MemberNm);
                #endregion

                return(0);
            }
        }