Example #1
0
    /// <summary>객체리스트 삭제</summary>
    private DeleteObjectsResponse FileListDelete(List<string> pKeyList)
    {
        try
        {
            AwsS3 s3 = new AwsS3();

            return s3.DeleteObjectList(pKeyList);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Example #2
0
    /// <summary>객체 삭제</summary>
    private bool FileDelete(string pKey)
    {
        try
        {
            AwsS3 s3 = new AwsS3();

            if (!string.IsNullOrEmpty(pKey))
            {
                if (s3.DeleteObject(pKey))
                {
                    return true;
                }
            }

            return false;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Example #3
0
    /// <summary>
    /// 파일 업로드
    /// </summary>
    /// <param name="pFile">객체</param>
    /// <param name="pKey">저장될 경로</param>
    /// <returns></returns>
    private bool FileUpload(HttpPostedFile pFile, string pKey)
    {
        try
        {
            //if (Request.UrlReferrer.Segments[0] == "내도메인") { }
            //else { 로그(Request.UrlReferrer.AbsolutePath) }

            HttpPostedFile file = pFile;

            AwsS3 s3 = new AwsS3();

            if (file.ContentLength > 0)
            {
                //업로드
                if (s3.WritingAnObject(pKey, file.InputStream))
                {
                    return true;
                }
            }
            return false;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Example #4
0
        /// <summary>상품 이미지 리스트 삭제</summary>
        /// <returns>삭제 성공 카운트</returns>
        public int DeleteItemImgList(List<BmItemImg> pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            int iResult = 0;
                            AwsS3 aws = new AwsS3();
                            List<string> keyList = pDataRq.Select(o => o.Img).ToList<string>();

                            if (keyList.Count > 0)
                            {
                                DeleteObjectsResponse result = aws.DeleteObjectList(keyList);

                                SqlConn.Open();

                                //모두삭제 성공
                                if (result.DeletedObjects.Count == pDataRq.Count)
                                {
                                    //모든 이미지DB 삭제
                                    if (dac.DeleteItemImgList(pDataRq))
                                    {
                                        scope.Complete();
                                    }
                                }
                                //모두삭제 실패
                                else if (result.DeletedObjects.Count == 0)
                                {
                                }
                                //일부 성공, 일부 실패
                                else
                                {
                                    List<BmItemImg> deleteList = new List<BmItemImg>();

                                    foreach (DeletedObject data in result.DeletedObjects)
                                    {
                                        deleteList.Add(pDataRq.FirstOrDefault(o => o.Img.Equals(data.Key)));
                                    }

                                    if (dac.DeleteItemImgList(deleteList))
                                    {
                                        scope.Complete();
                                    }
                                }

                                iResult = result.DeletedObjects.Count;
                            }

                            return iResult;
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog("Exception", ex.Message);
                throw ex;
            }
        }