예제 #1
0
 protected override void ProcessSub(HttpContext context, string fileName)
 {
     HttpRequest request = context.Request;
     if (!string.IsNullOrWhiteSpace(request.Params["album"]))
     {
         string s = request.Params["album"];
         if (!string.IsNullOrWhiteSpace(request.Params["userId"]))
         {
             string str2 = request.Params["userId"];
             string str3 = context.Request.Params["folder"];
             Maticsoft.BLL.CMS.Photo photo = new Maticsoft.BLL.CMS.Photo();
             HttpPostedFile file = context.Request.Files["Filedata"];
             Maticsoft.Model.CMS.Photo photo3 = new Maticsoft.Model.CMS.Photo {
                 PhotoName = file.FileName,
                 ImageUrl = str3 + "/" + fileName,
                 Description = "",
                 AlbumID = int.Parse(s),
                 State = 1,
                 CreatedUserID = int.Parse(str2),
                 CreatedDate = DateTime.Now,
                 PVCount = 0,
                 ClassID = 1,
                 ThumbImageUrl = str3 + "/T_" + fileName,
                 NormalImageUrl = str3 + "/N_" + fileName,
                 Sequence = new int?(photo.GetMaxSequence()),
                 IsRecomend = false,
                 CommentCount = 0,
                 Tags = ""
             };
             Maticsoft.Model.CMS.Photo model = photo3;
             int num = photo.Add(model);
             context.Response.Write(num.ToString());
         }
     }
 }
예제 #2
0
 public ActionResult Detail(int id)
 {
     Maticsoft.BLL.CMS.Photo photo = new Maticsoft.BLL.CMS.Photo();
     Maticsoft.Model.CMS.Photo model = new Maticsoft.Model.CMS.Photo();
     model = photo.GetModel(id);
     if (model == null)
     {
         return new EmptyResult();
     }
     List<Maticsoft.Model.CMS.Photo> list = photo.GetListAroundPhotoId(10, id, model.ClassID);
     return base.View(list);
 }
예제 #3
0
 public ActionResult AjaxLikePhoto(int PhotoId)
 {
     Maticsoft.BLL.CMS.Photo photo = new Maticsoft.BLL.CMS.Photo();
     Maticsoft.Model.CMS.Photo model = new Maticsoft.Model.CMS.Photo();
     if (photo.Exists(PhotoId))
     {
         model = photo.GetModel(PhotoId);
         model.FavouriteCount++;
         if (photo.Update(model))
         {
             return base.Content("True");
         }
     }
     return base.Content("False");
 }
예제 #4
0
 public Maticsoft.Model.CMS.Photo GetModel(int PhotoID)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 CMSP.*,AU.UserName AS CreatedUserName from CMS_Photo CMSP ");
     builder.Append(" LEFT JOIN Accounts_Users AU ON CMSP.CreatedUserID=AU.UserID ");
     builder.Append(" where PhotoID=@PhotoID");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@PhotoID", SqlDbType.Int, 4) };
     cmdParms[0].Value = PhotoID;
     Maticsoft.Model.CMS.Photo photo = new Maticsoft.Model.CMS.Photo();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["PhotoID"] != null) && (set.Tables[0].Rows[0]["PhotoID"].ToString() != ""))
     {
         photo.PhotoID = int.Parse(set.Tables[0].Rows[0]["PhotoID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["PhotoName"] != null) && (set.Tables[0].Rows[0]["PhotoName"].ToString() != ""))
     {
         photo.PhotoName = set.Tables[0].Rows[0]["PhotoName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ImageUrl"] != null) && (set.Tables[0].Rows[0]["ImageUrl"].ToString() != ""))
     {
         photo.ImageUrl = set.Tables[0].Rows[0]["ImageUrl"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Description"] != null) && (set.Tables[0].Rows[0]["Description"].ToString() != ""))
     {
         photo.Description = set.Tables[0].Rows[0]["Description"].ToString();
     }
     if ((set.Tables[0].Rows[0]["AlbumID"] != null) && (set.Tables[0].Rows[0]["AlbumID"].ToString() != ""))
     {
         photo.AlbumID = int.Parse(set.Tables[0].Rows[0]["AlbumID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["State"] != null) && (set.Tables[0].Rows[0]["State"].ToString() != ""))
     {
         photo.State = int.Parse(set.Tables[0].Rows[0]["State"].ToString());
     }
     if ((set.Tables[0].Rows[0]["CreatedUserID"] != null) && (set.Tables[0].Rows[0]["CreatedUserID"].ToString() != ""))
     {
         photo.CreatedUserID = int.Parse(set.Tables[0].Rows[0]["CreatedUserID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["CreatedDate"] != null) && (set.Tables[0].Rows[0]["CreatedDate"].ToString() != ""))
     {
         photo.CreatedDate = DateTime.Parse(set.Tables[0].Rows[0]["CreatedDate"].ToString());
     }
     if ((set.Tables[0].Rows[0]["PVCount"] != null) && (set.Tables[0].Rows[0]["PVCount"].ToString() != ""))
     {
         photo.PVCount = int.Parse(set.Tables[0].Rows[0]["PVCount"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ClassID"] != null) && (set.Tables[0].Rows[0]["ClassID"].ToString() != ""))
     {
         photo.ClassID = int.Parse(set.Tables[0].Rows[0]["ClassID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ThumbImageUrl"] != null) && (set.Tables[0].Rows[0]["ThumbImageUrl"].ToString() != ""))
     {
         photo.ThumbImageUrl = set.Tables[0].Rows[0]["ThumbImageUrl"].ToString();
     }
     if ((set.Tables[0].Rows[0]["NormalImageUrl"] != null) && (set.Tables[0].Rows[0]["NormalImageUrl"].ToString() != ""))
     {
         photo.NormalImageUrl = set.Tables[0].Rows[0]["NormalImageUrl"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Sequence"] != null) && (set.Tables[0].Rows[0]["Sequence"].ToString() != ""))
     {
         photo.Sequence = new int?(int.Parse(set.Tables[0].Rows[0]["Sequence"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["IsRecomend"] != null) && (set.Tables[0].Rows[0]["IsRecomend"].ToString() != ""))
     {
         photo.IsRecomend = new bool?((set.Tables[0].Rows[0]["IsRecomend"].ToString() == "1") || (set.Tables[0].Rows[0]["IsRecomend"].ToString().ToLower() == "true"));
     }
     if ((set.Tables[0].Rows[0]["CommentCount"] != null) && (set.Tables[0].Rows[0]["CommentCount"].ToString() != ""))
     {
         photo.CommentCount = new int?(int.Parse(set.Tables[0].Rows[0]["CommentCount"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Tags"] != null) && (set.Tables[0].Rows[0]["Tags"].ToString() != ""))
     {
         photo.Tags = set.Tables[0].Rows[0]["Tags"].ToString();
     }
     if ((set.Tables[0].Rows[0]["CreatedUserName"] != null) && (set.Tables[0].Rows[0]["CreatedUserName"].ToString() != ""))
     {
         photo.CreatedUserName = set.Tables[0].Rows[0]["CreatedUserName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["FavouriteCount"] != null) && (set.Tables[0].Rows[0]["FavouriteCount"].ToString() != ""))
     {
         photo.FavouriteCount = int.Parse(set.Tables[0].Rows[0]["FavouriteCount"].ToString());
     }
     return photo;
 }
예제 #5
0
 public List<Maticsoft.Model.CMS.Photo> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.CMS.Photo> list = new List<Maticsoft.Model.CMS.Photo>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.CMS.Photo item = new Maticsoft.Model.CMS.Photo();
             if ((dt.Rows[i]["PhotoID"] != null) && (dt.Rows[i]["PhotoID"].ToString() != ""))
             {
                 item.PhotoID = int.Parse(dt.Rows[i]["PhotoID"].ToString());
             }
             if ((dt.Rows[i]["PhotoName"] != null) && (dt.Rows[i]["PhotoName"].ToString() != ""))
             {
                 item.PhotoName = dt.Rows[i]["PhotoName"].ToString();
             }
             if ((dt.Rows[i]["ImageUrl"] != null) && (dt.Rows[i]["ImageUrl"].ToString() != ""))
             {
                 item.ImageUrl = dt.Rows[i]["ImageUrl"].ToString();
             }
             if ((dt.Rows[i]["Description"] != null) && (dt.Rows[i]["Description"].ToString() != ""))
             {
                 item.Description = dt.Rows[i]["Description"].ToString();
             }
             if ((dt.Rows[i]["AlbumID"] != null) && (dt.Rows[i]["AlbumID"].ToString() != ""))
             {
                 item.AlbumID = int.Parse(dt.Rows[i]["AlbumID"].ToString());
             }
             if ((dt.Rows[i]["State"] != null) && (dt.Rows[i]["State"].ToString() != ""))
             {
                 item.State = int.Parse(dt.Rows[i]["State"].ToString());
             }
             if ((dt.Rows[i]["CreatedUserID"] != null) && (dt.Rows[i]["CreatedUserID"].ToString() != ""))
             {
                 item.CreatedUserID = int.Parse(dt.Rows[i]["CreatedUserID"].ToString());
             }
             if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != ""))
             {
                 item.CreatedDate = DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString());
             }
             if ((dt.Rows[i]["PVCount"] != null) && (dt.Rows[i]["PVCount"].ToString() != ""))
             {
                 item.PVCount = int.Parse(dt.Rows[i]["PVCount"].ToString());
             }
             if ((dt.Rows[i]["ClassID"] != null) && (dt.Rows[i]["ClassID"].ToString() != ""))
             {
                 item.ClassID = int.Parse(dt.Rows[i]["ClassID"].ToString());
             }
             if ((dt.Rows[i]["ThumbImageUrl"] != null) && (dt.Rows[i]["ThumbImageUrl"].ToString() != ""))
             {
                 item.ThumbImageUrl = dt.Rows[i]["ThumbImageUrl"].ToString();
             }
             if ((dt.Rows[i]["NormalImageUrl"] != null) && (dt.Rows[i]["NormalImageUrl"].ToString() != ""))
             {
                 item.NormalImageUrl = dt.Rows[i]["NormalImageUrl"].ToString();
             }
             if ((dt.Rows[i]["Sequence"] != null) && (dt.Rows[i]["Sequence"].ToString() != ""))
             {
                 item.Sequence = new int?(int.Parse(dt.Rows[i]["Sequence"].ToString()));
             }
             if ((dt.Rows[i]["IsRecomend"] != null) && (dt.Rows[i]["IsRecomend"].ToString() != ""))
             {
                 if ((dt.Rows[i]["IsRecomend"].ToString() == "1") || (dt.Rows[i]["IsRecomend"].ToString().ToLower() == "true"))
                 {
                     item.IsRecomend = true;
                 }
                 else
                 {
                     item.IsRecomend = false;
                 }
             }
             if ((dt.Rows[i]["CommentCount"] != null) && (dt.Rows[i]["CommentCount"].ToString() != ""))
             {
                 item.CommentCount = new int?(int.Parse(dt.Rows[i]["CommentCount"].ToString()));
             }
             if ((dt.Rows[i]["FavouriteCount"] != null) && (dt.Rows[i]["FavouriteCount"].ToString() != ""))
             {
                 item.FavouriteCount = int.Parse(dt.Rows[i]["FavouriteCount"].ToString());
             }
             if ((dt.Rows[i]["Tags"] != null) && (dt.Rows[i]["Tags"].ToString() != ""))
             {
                 item.Tags = dt.Rows[i]["Tags"].ToString();
             }
             list.Add(item);
         }
     }
     return list;
 }