Esempio n. 1
0
        public IList<Core.Business.Favorites> GetAllFavorites()
        {
            IList<Core.Business.Favorites> favoriteslist = new List<Core.Business.Favorites>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllFavorites);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Favorites favorites = new Core.Business.Favorites();

                    if (!reader.IsDBNull(0)) favorites.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) favorites.DateCreated = reader.GetDateTime(1);
                    if (!reader.IsDBNull(2)) favorites.AccountId = reader.GetInt64(2);
                    if (!reader.IsDBNull(3)) favorites.AuthorId = reader.GetInt64(3);
                    if (!reader.IsDBNull(4)) favorites.AccountName = reader.GetString(4);
                    if (!reader.IsDBNull(5)) favorites.AuthorName = reader.GetString(5);
                    if (!reader.IsDBNull(6)) favorites.Url = reader.GetString(6);
                    if (!reader.IsDBNull(7)) favorites.Type = reader.GetString(7);
                    if (!reader.IsDBNull(8)) favorites.Content = reader.GetString(8);
                    if (!reader.IsDBNull(9)) favorites.InstanceId = reader.GetString(9);
                    if (!reader.IsDBNull(10)) favorites.ReplyNum = reader.GetInt32(10);

                    favorites.MarkOld();
                    favoriteslist.Add(favorites);
                }
                reader.Close();
            }
            return favoriteslist;
        }
Esempio n. 2
0
        /// <summary>
        /// 绑定收藏
        /// </summary>
        private void BindFavorites()
        {
            string LoadType = Core.Business.Favorites.FavoriteTypeEnum.all.ToString();
            Core.Business.Favorites favorite = new Core.Business.Favorites();
            favorite.AccountId = spaceAccount.Id;

            FavoritesListStr = new System.Text.StringBuilder();
            IList<CY.UME.Core.Business.Favorites> FavoritesList = CY.UME.Core.Business.Favorites.GetAllFavoritesByType(favorite, new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = 4 },
                LoadType);

            //RPT_FavoritesList.DataSourceID = "";
            //RPT_FavoritesList.DataSource = FavoritesList;
            //RPT_FavoritesList.DataBind();

            CY.UME.Web.Favorites.Index favIndex = new Favorites.Index();

            foreach (CY.UME.Core.Business.Favorites fav in FavoritesList)
            {
                FavoritesListStr.Append("<tr>");
                FavoritesListStr.Append("<td width=\"68%\" height=\"24\" align=\"left\">");
                FavoritesListStr.Append("收藏 <span>");
                FavoritesListStr.Append("<a href=\"?uid=" + fav.AuthorId + "\">" + fav.AuthorName + "</a>");
                FavoritesListStr.Append("</span> 的");
                switch (fav.Type)
                {
                    case "Blog":
                        CY.UME.Core.Business.Blog blog = Core.Business.Blog.Load(
                            CY.Utility.Common.ConvertUtility.ConvertToLong(fav.InstanceId, 0));
                        FavoritesListStr.Append("</span> 的日志:<a target=\"_blank\" href=\"" + SiteUrl + "/BlogDetailInfo.aspx?blogId=" + blog.Id + "\">" + blog.Subject + "</a>");
                        break;
                    case "MiniBlog":
                        CY.UME.Core.Business.MiniBlog miniBlog = Core.Business.MiniBlog.Load(
                            CY.Utility.Common.ConvertUtility.ConvertToLong(fav.InstanceId, 0));
                        FavoritesListStr.Append("</span> 的微博:" + miniBlog.Content);
                        break;
                    case "Topic":
                        CY.UME.Core.Business.Topic topic = Core.Business.Topic.Load(new Guid(fav.InstanceId));
                        FavoritesListStr.Append("</span> 的话题:<a target=\"_blank\" href=\"" + SiteUrl + "/Group/TopicDetailInfo.aspx?TopicId=" + topic.Id + "\">" + topic.Title + "</a>");
                        break;
                    case "Pic":
                        CY.UME.Core.Business.Picture pic = Core.Business.Picture.Load(
                            CY.Utility.Common.ConvertUtility.ConvertToLong(fav.InstanceId, 0));
                        FavoritesListStr.Append("</span> 的照片:<a target=\"_blank\" href=\"" + SiteUrl + "/Album/PictureDetailInfo.aspx?pictureId=" + pic.Id + "\">" + pic.Name + "</a>");
                        break;
                    default:
                        break;
                }
                //FavoritesListStr.Append("</span> 的" + favIndex.GetContentByTypeAndId(fav.Type, fav.InstanceId));
                FavoritesListStr.Append("</td>");
                FavoritesListStr.Append("<td width=\"17%\" align=\"left\">");
                FavoritesListStr.Append(fav.DateCreated.ToString("yyyy年MM月dd"));
                FavoritesListStr.Append("</td>");
                FavoritesListStr.Append("<td width=\"15%\" align=\"center\">");
                FavoritesListStr.Append(fav.ReplyNum + "个回复");
                FavoritesListStr.Append("</td>");
                FavoritesListStr.Append("</tr>");
            }

            lblFavNumber.InnerText = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite, LoadType).ToString();
        }
Esempio n. 3
0
        /// <summary>
        /// 绑定所有收藏
        /// </summary>
        public void SetFavoritesListByAll()
        {
            Core.Business.Favorites favorite = new Core.Business.Favorites();
            favorite.AccountId = SpaceAccount.Id;

            CY.UME.Core.PagingInfo pageinfo = new Core.PagingInfo
            {
                CurrentPage = 1,
                PageSize =
                    CY.Utility.Common.ConvertUtility.ConvertToInt(
                    HF_PageSize.Value, 30)
            };

            if (LoadType == Core.Business.Favorites.FavoriteTypeEnum.all.ToString())
            {
                BindFavoritesList(favorite, pageinfo, LoadType);

                HF_TotalRecords.Value = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite, LoadType).ToString();
            }
            else if (LoadType == Core.Business.Favorites.FavoriteTypeEnum.blog.ToString())
            {
                BindFavoritesList(favorite, pageinfo, LoadType);
                HF_TotalRecords.Value = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite, LoadType).ToString();
            }
            else if (LoadType == Core.Business.Favorites.FavoriteTypeEnum.miniblog.ToString())
            {
                BindFavoritesList(favorite, pageinfo, LoadType);
                HF_TotalRecords.Value = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite, LoadType).ToString();
            }
            else if (LoadType == Core.Business.Favorites.FavoriteTypeEnum.pubtopic.ToString())
            {
                BindFavoritesList(favorite, pageinfo, LoadType);
                HF_TotalRecords.Value = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite, LoadType).ToString();
            }
            else if (LoadType == Core.Business.Favorites.FavoriteTypeEnum.picture.ToString())
            {
                BindFavoritesList(favorite, pageinfo, LoadType);
                HF_TotalRecords.Value = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite, LoadType).ToString();
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadType = HF_Load_Type.Value;

            if (!IsPostBack)
            {
                long AccountId;

                //获取自己的收藏
                if (CurrentAccount != null && Request.QueryString["uid"] == null)
                {
                    AccountId = CurrentAccount.Id;
                    SpaceAccount = CurrentAccount;
                }
                else if (Request.QueryString["uid"] != null && long.TryParse(Request.QueryString["uid"], out AccountId))
                {//外来户
                    SpaceAccount = CY.UME.Core.Business.Account.Load(AccountId);
                }

                if (SpaceAccount == null)
                {
                    //转到404页面
                    Response.Redirect(SiteUrl + "/Login");
                    return;
                }

                HF_SiteUrl.Value = SiteUrl;
                HF_CurrentAccount_Id.Value = SpaceAccount.Id.ToString();//当前访问页面的用户
                UserInfo1.SpaceAccount = SpaceAccount;
                favoritesFollower.CurrentFollower = SpaceAccount;

                Core.Business.Favorites favorite = new Core.Business.Favorites();
                favorite.AccountId = SpaceAccount.Id;

                //绑定收藏总数(All)
                FavTotal = CY.UME.Core.Business.Favorites.GetFavoritesCount(favorite,
                    Core.Business.Favorites.FavoriteTypeEnum.all.ToString()).ToString();

                if (Request.QueryString["t"] != null)
                {
                    LoadType = Request.QueryString["t"].ToString();

                    if (Request.QueryString["i"] != null) { HF_Select_Index.Value = Request.QueryString["i"].ToString(); }
                }

                SetFavoritesListByAll();
            }
        }
Esempio n. 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            StringBuilder sb = new StringBuilder();
            long AccountId = 0;
            int pageNum, pageSize = 0;
            bool IsShowDel = false;

            string PageSize = context.Request.QueryString["PageSize"];
            string LoadType = context.Request.QueryString["LoadType"];
            string strPageSize = context.Request.QueryString["pageSize"].ToString();
            string strPageNum = context.Request.QueryString["currentNum"].ToString();

            if (!long.TryParse(context.Request.QueryString["AccountId"].ToString(), out AccountId) ||
                !int.TryParse(strPageNum, out pageNum) || !int.TryParse(strPageSize, out pageSize))
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            Core.Business.Favorites favorite = new Core.Business.Favorites();
            favorite.AccountId = AccountId;

            CY.UME.Core.PagingInfo pageinfo = new Core.PagingInfo
            {
                CurrentPage = pageNum,
                PageSize = pageSize
            };

            IList<Core.Business.Favorites> FavoritesList = CY.UME.Core.Business.Favorites.GetAllFavoritesByType(favorite, pageinfo, LoadType);

            CY.UME.Web.Favorites.Index index = new Web.Favorites.Index();//收藏首页上的代码

            CY.UME.Core.Business.Account CurrentAccount = CY.UME.Core.Global.GetCurrentAccount();

            if (CurrentAccount != null)
                IsShowDel = true;

            foreach (Core.Business.Favorites fav in FavoritesList)
            {
                sb.Append("<div>");
                sb.Append("<div class=\"collect_main\">");
                sb.Append("<div class=\"collect_main_rizhi\">");
                sb.Append(fav.TypeName + "</div>");
                sb.Append("<div class=\"collect_main_time\">");
                sb.Append(fav.DateCreated.ToString("yyyy-MM-dd HH:mm"));
                sb.Append("</div>");
                sb.Append("<div class=\"collect_main_list\">");
                sb.Append("<ul>");
                sb.Append("<li class=\"tm\">");
                sb.Append(index.GetContentByTypeAndId(fav.Type, fav.InstanceId));
                sb.Append("</li>");
                sb.Append("<li><span>来自:</span><a target=\"_blank\" href=\"../Home.aspx?uid=" + fav.AuthorId + "\">" + fav.AuthorName + "</a></li>");
                sb.Append("<!--<li><span>》继续阅读</span></li>-->");
                sb.Append("<li><span>");
                sb.Append(fav.Content == "" ? "" : "“" + fav.Content + "”");
                sb.Append("</span></li>");
                sb.Append("<li><span><a class=\"reply\" fid=\"" + fav.Id + "\" href=\"javascript:void(0);\">评论(<span id=\"ReplyNum\">" + fav.ReplyNum + "</span>)</a></span></li>");
                sb.Append("</ul>");
                sb.Append("</div>");
                if (IsShowDel && CurrentAccount.Id == fav.AccountId)
                {//用户在线切是自己的收藏,才显示删除按钮
                    sb.Append("<a href=\"javascript:void(0);\" class=\"delete\"><img src=\"../Theme/V3/images/Index/index_icon13.gif\" title=\"删除信息\"></a>");
                }
                sb.Append("<div id=\"replylist\"></div>");
                sb.Append("</div>");
                sb.Append("<div class=\"fengexian\"></div>");
                sb.Append("<div class=\"clear\"></div>");
                sb.Append("</div>");
            }

            context.Response.Write("{success:true,fav:'" + sb.ToString() + "'}");
        }
Esempio n. 6
0
        //根据收藏类型获取收藏列表(分页)
        public IList<Core.Business.Favorites> GetAllFavoritesByType(Core.Business.Favorites favorite, CY.UME.Core.PagingInfo pageInfo, String Type)
        {
            IList<Core.Business.Favorites> favoriteslist = new List<Core.Business.Favorites>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string strFilter = SetStrFilter(favorite, Type);

            sql.AddParameter("@Tables", SqlDbType.VarChar, "Favorites");
            sql.AddParameter("@PK", SqlDbType.VarChar, "Id");
            sql.AddParameter("@Filter", SqlDbType.VarChar, strFilter);
            sql.AddParameter("@Fields", SqlDbType.VarChar, "[Id], [DateCreated],[AccountId],[AuthorId],[AccountName],[AuthorName],[Url],[Type],[Content],[InstanceId],[ReplyNum]");
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageInfo.CurrentPage);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageInfo.PageSize);
            sql.AddParameter("@Sort", SqlDbType.NVarChar, "Id DESC");
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Favorites favorites = new Core.Business.Favorites();

                    if (!reader.IsDBNull(0)) favorites.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) favorites.DateCreated = reader.GetDateTime(1);
                    if (!reader.IsDBNull(2)) favorites.AccountId = reader.GetInt64(2);
                    if (!reader.IsDBNull(3)) favorites.AuthorId = reader.GetInt64(3);
                    if (!reader.IsDBNull(4)) favorites.AccountName = reader.GetString(4);
                    if (!reader.IsDBNull(5)) favorites.AuthorName = reader.GetString(5);
                    if (!reader.IsDBNull(6)) favorites.Url = reader.GetString(6);
                    if (!reader.IsDBNull(7))
                    {
                        favorites.Type = reader.GetString(7);
                        favorites.TypeName = CY.UME.Core.Business.Favorites.GetTypeName(favorites.Type);
                    }
                    if (!reader.IsDBNull(8)) favorites.Content = reader.GetString(8);
                    if (!reader.IsDBNull(9)) favorites.InstanceId = reader.GetString(9);
                    if (!reader.IsDBNull(10)) favorites.ReplyNum = reader.GetInt32(10);

                    favorites.MarkOld();
                    favoriteslist.Add(favorites);
                }
                reader.Close();
            }
            return favoriteslist;
        }
Esempio n. 7
0
        public Core.Business.Favorites Select(Int64 id)
        {
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            sql.AddParameter("@Id", SqlDbType.BigInt, id);
            SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectFavoritesById);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.Favorites favorites = new Core.Business.Favorites();

                if (!reader.IsDBNull(0)) favorites.Id = reader.GetInt64(0);
                if (!reader.IsDBNull(1)) favorites.DateCreated = reader.GetDateTime(1);
                if (!reader.IsDBNull(2)) favorites.AccountId = reader.GetInt64(2);
                if (!reader.IsDBNull(3)) favorites.AuthorId = reader.GetInt64(3);
                if (!reader.IsDBNull(4)) favorites.AccountName = reader.GetString(4);
                if (!reader.IsDBNull(5)) favorites.AuthorName = reader.GetString(5);
                if (!reader.IsDBNull(6)) favorites.Url = reader.GetString(6);
                if (!reader.IsDBNull(7)) favorites.Type = reader.GetString(7);
                if (!reader.IsDBNull(8)) favorites.Content = reader.GetString(8);
                if (!reader.IsDBNull(9)) favorites.InstanceId = reader.GetString(9);
                if (!reader.IsDBNull(10)) favorites.ReplyNum = reader.GetInt32(10);

                reader.Close();
                return favorites;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
Esempio n. 8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            long AuthorId = CY.Utility.Common.ConvertUtility.ConvertToLong(context.Request["authorid"], 0);
            string Url = context.Request["url"];
            string Type = context.Request["type"].ToLower();
            string InstanceId = context.Request["instanceid"];
            string Content = context.Request["content"];

            CY.UME.Core.Business.Account CurrentAccount = CY.UME.Core.Global.GetCurrentAccount();

            if (CurrentAccount == null)
            {
                context.Response.Write("{success:false,msg:'请先登录'}");
                return;
            }
            else if (CurrentAccount.Id == AuthorId)
            {
                context.Response.Write("{success:false,msg:'这东东已经是你的了(*^__^*)'}");
                return;
            }

            CY.UME.Core.Business.Account AuthorAccount = CY.UME.Core.Business.Account.Load(AuthorId);

            if (AuthorAccount == null)
            {
                context.Response.Write("{success:false,msg:'好像什么地方出错了,等会儿在来吧。'}");
                return;
            }

            CY.UME.Core.Business.Favorites favorite = new Core.Business.Favorites();

            favorite.AccountId = CurrentAccount.Id;
            favorite.InstanceId = InstanceId;
            favorite.Url = Url;

            if (CY.UME.Core.Business.Favorites.Load(favorite) != null)
            {
                context.Response.Write("{success:false,msg:'这东东上次你已经收藏了(*^__^*)'}");
                return;
            }

            favorite.AccountName = CurrentAccount.Name;
            favorite.AuthorId = AuthorAccount.Id;
            favorite.AuthorName = AuthorAccount.Name;
            favorite.Type = Type;
            favorite.Content = Content;
            favorite.DateCreated = DateTime.Now;
            favorite.Save();

            //CurrentAccount.SendNoticeToAllFriendAndFollower(Type,
            //    "收藏了" + AuthorAccount.Name + "的" +
            //    CY.UME.Core.Business.Favorites.GetTypeName(Type), InstanceId);

            CY.UME.Core.Business.Account account = new Core.Business.Account();

            IList<CY.UME.Core.Business.Friendship> friendList = account.GetFriendships();

            CurrentAccount.SendNoticeToAllFriendAndFollower(Type,
                "收藏了" + AuthorAccount.Name + "的" + CY.UME.Core.Business.Favorites.GetTypeName(Type),
                InstanceId);

            context.Response.Write("{success:true,msg:'成功加入收藏。'}");
        }