Ejemplo n.º 1
0
 public List<PostContent> GetAlbumImgListByPage(int albumID, int startIndex, int endIndex, int type = -1)
 {
     List<PostContent> list = new List<PostContent>();
     DataSet set = this.dal.GetAlbumImgListByPage(albumID, "", startIndex, endIndex, type);
     List<string> values = new List<string>();
     Maticsoft.BLL.SNS.Comments comments = new Maticsoft.BLL.SNS.Comments();
     if ((set != null) && (set.Tables.Count > 0))
     {
         Action<PostContent> action = null;
         DataTable table = set.Tables[0];
         foreach (DataRow row in table.Rows)
         {
             PostContent item = new PostContent {
                 TargetId = Convert.ToInt32(row["TargetID"]),
                 TargetName = row["TargetName"].ToString(),
                 TargetDescription = (row["Description"] != null) ? row["Description"].ToString() : "",
                 CommentCount = Convert.ToInt32(row["CommentCount"]),
                 FavouriteCount = Convert.ToInt32(row["FavouriteCount"]),
                 ThumbImageUrl = row["ThumbImageUrl"].ToString(),
                 Price = Globals.SafeDecimal(row["Price"].ToString(), (decimal) -1M),
                 Type = (int) row["Type"],
                 TopCommentsId = (row["TopCommentsId"] != null) ? row["TopCommentsId"].ToString() : ""
             };
             list.Add(item);
             if (!string.IsNullOrEmpty(item.TopCommentsId))
             {
                 values.Add(item.TopCommentsId);
             }
         }
         List<Maticsoft.Model.SNS.Comments> commentList = comments.GetCommentByIds(string.Join(",", values).TrimEnd(new char[] { ',' }), 1);
         if (commentList == null)
         {
             return list;
         }
         if (action == null)
         {
             action = delegate (PostContent img) {
                 List<Maticsoft.Model.SNS.Comments> list = commentList.FindAll(xx => (xx.TargetId == img.TargetId) && (xx.Type == ((img.Type == 0) ? 1 : 2)));
                 if (list != null)
                 {
                     img.CommentList = list;
                 }
             };
         }
         list.ForEach(action);
     }
     return list;
 }
Ejemplo n.º 2
0
 public List<PostContent> GetPhotoListByPage(int type, int categoryId, string address, string orderby, int startIndex, int endIndex)
 {
     List<PostContent> list = new List<PostContent>();
     DataSet set = this.dal.GetListByPageEx(type, categoryId, address, orderby, startIndex, endIndex);
     List<string> values = new List<string>();
     Maticsoft.BLL.SNS.Comments comments = new Maticsoft.BLL.SNS.Comments();
     if ((set != null) && (set.Tables.Count > 0))
     {
         Action<PostContent> action = null;
         DataTable table = set.Tables[0];
         foreach (DataRow row in table.Rows)
         {
             PostContent item = new PostContent {
                 Type = 0,
                 TargetId = Convert.ToInt32(row["PhotoID"]),
                 TargetName = row["PhotoName"].ToString(),
                 TargetDescription = (row["Description"] != null) ? row["Description"].ToString() : "",
                 CommentCount = Convert.ToInt32(row["CommentCount"]),
                 FavouriteCount = Convert.ToInt32(row["FavouriteCount"]),
                 ThumbImageUrl = row["ThumbImageUrl"].ToString(),
                 TopCommentsId = (row["TopCommentsId"] != null) ? row["TopCommentsId"].ToString() : ""
             };
             list.Add(item);
             if (!string.IsNullOrEmpty(item.TopCommentsId))
             {
                 values.Add(item.TopCommentsId);
             }
         }
         List<Maticsoft.Model.SNS.Comments> commentList = comments.GetCommentByIds(string.Join(",", values).TrimEnd(new char[] { ',' }), 1);
         if (commentList == null)
         {
             return list;
         }
         if (action == null)
         {
             action = delegate (PostContent img) {
                 List<Maticsoft.Model.SNS.Comments> list = commentList.FindAll(xx => (xx.TargetId == img.TargetId) && (xx.Type == 1));
                 if (list != null)
                 {
                     img.CommentList = list;
                 }
             };
         }
         list.ForEach(action);
     }
     return list;
 }
Ejemplo n.º 3
0
 public List<PostContent> GetListByKeyWord(string q, string orderby, int startIndex, int endIndex, string area = "")
 {
     DataSet set;
     new List<Maticsoft.Model.SNS.Photos>();
     StringBuilder builder = new StringBuilder();
     builder.Append(" Status =1 ");
     if (!string.IsNullOrEmpty(q))
     {
         builder.Append(" and (Tags Like '%" + q + "%' or  Description like '%" + q + "%')");
     }
     if (!string.IsNullOrEmpty(area))
     {
         builder.Append(" and (PhotoAddress like '%" + area + "%' )");
     }
     string str = orderby;
     if (str != null)
     {
         if (!(str == "popular"))
         {
             if (str == "new")
             {
                 orderby = "CreatedDate";
                 goto Label_00D0;
             }
             if (str == "hot")
             {
                 orderby = "CommentCount";
                 goto Label_00D0;
             }
         }
         else
         {
             orderby = "FavouriteCount";
             goto Label_00D0;
         }
     }
     orderby = "FavouriteCount";
 Label_00D0:
     set = this.dal.GetListByPage(builder.ToString(), orderby, startIndex, endIndex);
     List<PostContent> list = new List<PostContent>();
     List<string> values = new List<string>();
     Maticsoft.BLL.SNS.Comments comments = new Maticsoft.BLL.SNS.Comments();
     if ((set != null) && (set.Tables.Count > 0))
     {
         Action<PostContent> action = null;
         DataTable table = set.Tables[0];
         foreach (DataRow row in table.Rows)
         {
             PostContent item = new PostContent {
                 Type = 0,
                 TargetId = Convert.ToInt32(row["PhotoID"]),
                 TargetName = row["PhotoName"].ToString(),
                 TargetDescription = (row["Description"] != null) ? row["Description"].ToString() : "",
                 CommentCount = Convert.ToInt32(row["CommentCount"]),
                 FavouriteCount = Convert.ToInt32(row["FavouriteCount"]),
                 ThumbImageUrl = row["ThumbImageUrl"].ToString(),
                 TopCommentsId = (row["TopCommentsId"] != null) ? row["TopCommentsId"].ToString() : "",
                 StaticUrl = (row["StaticUrl"] != null) ? row["StaticUrl"].ToString() : ""
             };
             list.Add(item);
             if (!string.IsNullOrEmpty(item.TopCommentsId))
             {
                 values.Add(item.TopCommentsId);
             }
         }
         List<Maticsoft.Model.SNS.Comments> commentList = comments.GetCommentByIds(string.Join(",", values).TrimEnd(new char[] { ',' }), 1);
         if (commentList == null)
         {
             return list;
         }
         if (action == null)
         {
             action = delegate (PostContent img) {
                 List<Maticsoft.Model.SNS.Comments> list = commentList.FindAll(xx => (xx.TargetId == img.TargetId) && (xx.Type == 1));
                 if (list != null)
                 {
                     img.CommentList = list;
                 }
             };
         }
         list.ForEach(action);
     }
     return list;
 }