Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var command = context.Request.Form["command"];

            if (!string.IsNullOrEmpty(command))
            {
                switch (command)
                {
                    #region getPicInfo
                case "getPicInfo":
                {
                    string catalogId = context.Request.Form["cateID"];
                    PicBLL objDal    = new PicBLL();
                    if (catalogId.Equals("全部分类"))
                    {
                        catalogId = "0";
                    }
                    var count = objDal.GetNeedClearPicCount(Convert.ToInt64(catalogId)).ToString();
                    context.Response.Write(count);
                    context.Response.End();
                }
                break;
                    #endregion

                    #region clearPics
                case "clearPics":
                {
                    Int64  canSavedSize = 0;
                    PicBLL objDal       = new PicBLL();
                    if (objDal.DeleleUnusedPic(ref canSavedSize))
                    {
                        //lbCleardCount.Text = lbClearCount.Text;
                        //Tr1.Visible = true;
                        //Tr2.Visible = true;
                    }
                    SavedSpace space = new SavedSpace();
                    space.SellerNick      = Users.Nick;
                    space.TotalSavedSpace = canSavedSize;
                    if (!PicBLL.CheckSpace(space))
                    {
                        PicBLL.AddSpace(space);
                    }
                    else
                    {
                        PicBLL.UpdateSpace(space);
                    }
                    //将节约的空间累计到DB
                    var count = Utility.FormatFileSize(canSavedSize);
                    context.Response.Write(count);
                    context.Response.End();
                }
                break;
                    #endregion
                }
            }
        }
Example #2
0
        public static bool AddSpace(SavedSpace entity)
        {
            try
            {
                string query = @"INSERT INTO SavedSpace(totalSavedSpace,sellerNick,createDate)
                                VALUES(@totalSavedSpace,@sellerNick,getdate())";

                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@totalSavedSpace", entity.TotalSavedSpace),
                    new SqlParameter("@sellerNick", entity.SellerNick)
                };
                DataBase.ExecuteSql(query, param);
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                return(false);
            }
        }
Example #3
0
        public static bool UpdateSpace(SavedSpace entity)
        {
            try
            {
                string query = @"update SavedSpace 
                                set totalSavedSpace = totalSavedSpace + @totalSavedSpace, updateDate = getdate()
                                where sellerNick = @sellerNick";

                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@totalSavedSpace", entity.TotalSavedSpace),
                    new SqlParameter("@sellerNick", entity.SellerNick)
                };
                DataBase.ExecuteSql(query, param);
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                return(false);
            }
        }
Example #4
0
 public static Boolean CheckSpace(SavedSpace entity)
 {
     try
     {
         string         query = @"SELECT 1 as result FROM SavedSpace WHERE sellerNick = @sellerNick";
         SqlParameter[] param = new SqlParameter[]
         {
             new SqlParameter("@sellerNick", entity.SellerNick)
         };
         DataTable dt = DataBase.ExecuteDt(query, param, CommandType.Text);
         if (dt.Rows.Count > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
         return(false);
     }
 }
Example #5
0
 public static bool UpdateSpace(SavedSpace entity)
 {
     return(PicDAL.UpdateSpace(entity));
 }
Example #6
0
 public static bool AddSpace(SavedSpace entity)
 {
     return(PicDAL.AddSpace(entity));
 }
Example #7
0
 public static Boolean CheckSpace(SavedSpace entity)
 {
     return(PicDAL.CheckSpace(entity));
 }