Пример #1
0
        /// <summary>상품 이미지 삭제</summary>
        public bool DeleteItemImg(BmItemImg pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            SqlConn.Open();

                            var result = dac.DeleteItemImg(pDataRq);

                            scope.Complete();
                            return result;
                        }
                        catch (Exception ex)
                        {

                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog("Exception", ex.Message);
                return false;
            }
        }
Пример #2
0
        /// <summary>아이템 이미지 삭제</summary>
        public bool DeleteItemImg(BmItemImg pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"DELETE tbItemImg WHERE Seq = @Seq";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;

                #endregion Set Parameters

                result = cmd.ExecuteNonQuery();

                cmd.Dispose();

                if (result == 1)
                {
                    WriteHistory(pDataRq, HistoryCommandType.DELETE);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
    /// <summary>
    /// ItemImgUpload
    /// </summary>
    private void ItemImageUpload()
    {
        List<string> KeyList = new List<string>();

        try
        {
            string strFilePath = Request.QueryString["path"].ToString();
            int iItemSeq = Convert.ToInt32(Request.QueryString["item"].ToString());

            if (!string.IsNullOrEmpty(strFilePath) && !string.IsNullOrEmpty(strBucketName) && iItemSeq > 0)
            {
                BizItem bizItem = new BizItem();

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFile file = Request.Files[i];

                    if (file.ContentLength > 0)
                    {
                        string strFileName = DateTime.Now.ToString("yyMMddHHmmssms") + "_" + file.FileName;
                        KeyList.Add(strFilePath + strFileName);

                        //업로드
                        if (FileUpload(file, KeyList[i]))
                        {
                            BmItemImg img = new BmItemImg();
                            img.ItemSeq = iItemSeq;
                            img.Img = KeyList[i];
                            img.Registrant = LoginMgr.Id;

                            //DB Insert
                            if (bizItem.InsertItemImg(img))
                            {
                                Response.Write("{}");
                            }
                            else
                            {
                                if (!FileDelete(KeyList[i]))
                                {
                                    cLib.WriteLog("Failed", "삭제 실패 - Key : " + KeyList[i]);
                                }
                                Response.Write("{'error' : 'Db Insert Error'}");
                            }
                        }
                        else
                        {
                            Response.Write("{'error' : 'Aws Upload Error'}");
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //실패시 등록된 파일리스트 삭제
            var deleteResult = FileListDelete(KeyList);

            Response.Write(string.Format("{error : '{0}'}", ex.Message));
        }
    }
Пример #4
0
        /// <summary>아이템 이미지 조회</summary>
        public List<BmItemImg> GetItemImgList(BmItemImg pDataRq)
        {
            try
            {
                #region SetQuery

                StringBuilder sbQuery = new StringBuilder("SELECT * FROM tbItemImg WHERE 1=1");

                if (pDataRq.Seq > 0)
                    sbQuery.AppendLine(" AND Seq = @Seq");
                if (pDataRq.ItemSeq > 0)
                    sbQuery.AppendLine(" AND ItemSeq = @ItemSeq");

                sbQuery.AppendLine(" ORDER BY DisplayOrder, RegDt ASC");

                #endregion SetQuery

                List<BmItemImg> result = new List<BmItemImg>();
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = sbQuery.ToString();

                #region Set Parameters

                if (pDataRq.Seq > 0)
                    cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;
                if (pDataRq.ItemSeq > 0)
                    cmd.Parameters.Add("@ItemSeq", SqlDbType.Int, 0).Value = pDataRq.ItemSeq;

                #endregion Set Parameters

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    DataTable dt = new DataTable();

                    dt.Load(reader);
                    result = ConvertToBmItemImg(dt);
                }

                reader.Dispose();
                cmd.Dispose();

                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        /// <summary>아이템 이미지 Convert DataTable -> BmItemImg</summary>
        private List<BmItemImg> ConvertToBmItemImg(DataTable dt)
        {
            List<BmItemImg> list = new List<BmItemImg>();

            foreach (DataRow dr in dt.Rows)
            {
                BmItemImg data = new BmItemImg();

                data.Seq = (int)dr["Seq"];
                data.ItemSeq = (int)dr["ItemSeq"];
                data.Img = dr["Img"].ToString();
                data.DisplayOrder = (int)dr["DisplayOrder"];
                data.Registrant = dr["Registrant"].ToString();
                data.RegDt = (DateTime)dr["RegDt"];
                data.Modifyer = dr["Modifyer"].ToString();
                data.ModifyDt = string.IsNullOrEmpty(dr["ModifyDt"].ToString()) ? null : (DateTime?)dr["ModifyDt"];

                list.Add(data);
            }

            return list;
        }
Пример #6
0
        /// <summary>아이템 이미지 수정</summary>
        public bool UpdateItemImg(BmItemImg pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"UPDATE tbItemImg SET
                                        DisplayOrder = @DisplayOrder,
                                        Modifyer = @Modifyer,
                                        ModifyDt = dbo.getkordate()
                                    WHERE
                                        Seq = @Seq";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;
                cmd.Parameters.Add("@DisplayOrder", SqlDbType.Int, 0).Value = pDataRq.DisplayOrder;
                cmd.Parameters.Add("@Modifyer", SqlDbType.VarChar, 20).Value = pDataRq.Modifyer;

                #endregion Set Parameters

                result = cmd.ExecuteNonQuery();

                cmd.Dispose();

                if (result == 1)
                {
                    WriteHistory(pDataRq, HistoryCommandType.UPDATE);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #7
0
        /// <summary>아이템 이미지 등록</summary>
        public bool InsertItemImg(BmItemImg pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"INSERT INTO tbItemImg
                                        (ItemSeq
                                        , Img
                                        , DisplayOrder
                                        , Registrant
                                        )
                                    Values
                                        (@ItemSeq
                                        , @Img
                                        , (ISNULL((SELECT TOP 1 DisplayOrder FROM tbItemImg WHERE ItemSeq = @ItemSeq ORDER BY DisplayOrder DESC), 0) + 1)
                                        , @Registrant)
                                    SELECT @@Identity";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@ItemSeq", SqlDbType.Int, 0).Value = pDataRq.ItemSeq;
                cmd.Parameters.Add("@Img", SqlDbType.VarChar).Value = pDataRq.Img;
                cmd.Parameters.Add("@Registrant", SqlDbType.VarChar, 20).Value = pDataRq.Registrant;

                #endregion Set Parameters

                result = Convert.ToInt32(cmd.ExecuteScalar());

                cmd.Dispose();

                if (result > 0)
                {
                    pDataRq.Seq = result;
                    WriteHistory(pDataRq, HistoryCommandType.INSERT);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #8
0
 public BmItemImgPagingRq()
 {
     Item = new BmItemImg();
     Paging = new BmPaging();
 }