Ejemplo n.º 1
0
        public ActionResult SaveBookmarkTag(long bookmarkID, long tagInfoID = 0, string tagName = "")
        {
            BizResultInfo result       = new BizResultInfo();
            var           bookmarkInfo = BizBookmarkInfo.LoadByID(bookmarkID);

            if (bookmarkInfo == null || bookmarkInfo.BookmarkInfoID == 0)
            {
                result.ErrorMessage = "书签数据为空,不要逗我玩啦...";
                return(Json(result));
            }
            bookmarkInfo.LoadBookmarkTagInfo();

            if (tagInfoID != 0 && bookmarkInfo.BizBookmarkTagInfoList.All(mode => mode.TagInfoID != tagInfoID))
            {
                bookmarkInfo.AddBookmarkTag(tagInfoID);
            }
            var errorMessage = string.Empty;

            if (!string.IsNullOrEmpty(tagName))
            {
                errorMessage = bookmarkInfo.AddBookmarkTag(tagName);
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                result.ErrorMessage = errorMessage;
                result.IsSuccess    = false;
            }
            else
            {
                result.SuccessMessage = "保存成功!";
                result.IsSuccess      = true;
            }
            return(Json(result));
        }
Ejemplo n.º 2
0
        public ActionResult ShowBookmarkHTML(long bookmarkID, string url)
        {
            UIBookmarkInfo model = null;

            if (bookmarkID == 0 || string.IsNullOrEmpty(url))
            {
                return(PartialView("ShowBookmarkHTML", model));
            }


            var bookmarkInfo = BizBookmarkInfo.LoadByID(bookmarkID);

            if (bookmarkInfo == null)
            {
                return(PartialView("ShowBookmarkHTML", model));
            }
            model = new UIBookmarkInfo();
            model.IsShowWithiframe = bookmarkInfo.IsShowWithiframe == 1;//是否可在iframe中展示

            if (string.IsNullOrEmpty(bookmarkInfo.HTML))
            {
                var result = HTTPHelper.GetHTML(url);
                if (string.IsNullOrEmpty(result.Item1))
                {
                    model                = new UIBookmarkInfo();
                    model.HTML           = bookmarkInfo.HTML;
                    model.Href           = bookmarkInfo.Href;
                    model.UserInfoID     = bookmarkInfo.UserInfoID;
                    model.Host           = bookmarkInfo.Host;
                    model.BookmarkName   = bookmarkInfo.BookmarkName;
                    model.BookmarkInfoID = bookmarkInfo.BookmarkInfoID;
                    return(PartialView("ShowBookmarkHTML", model));
                }

                bookmarkInfo.HTML = result.Item1;

                if (string.IsNullOrEmpty(result.Item2) || result.Item2.ToUpper() == "ALLOW-FROM")
                {
                    bookmarkInfo.IsShowWithiframe = 1;
                    model.IsShowWithiframe        = true;
                }

                bookmarkInfo.Save();
            }

            model.HTML           = bookmarkInfo.HTML;
            model.Href           = bookmarkInfo.Href;
            model.UserInfoID     = bookmarkInfo.UserInfoID;
            model.Host           = bookmarkInfo.Host;
            model.BookmarkName   = bookmarkInfo.BookmarkName;
            model.BookmarkInfoID = bookmarkInfo.BookmarkInfoID;
            return(PartialView("ShowBookmarkHTML", model));
        }
Ejemplo n.º 3
0
        //
        // GET: /ShowBookmarkInfo/

        public ActionResult Index(long bookmarkID)
        {
            if (bookmarkID == 0)
            {
                return(View());
            }

            UIBookmarkInfo model        = null;
            var            bookmarkInfo = BizBookmarkInfo.LoadByID(bookmarkID);

            if (bookmarkInfo != null)
            {
                bookmarkInfo.LoadBookmarkTagInfo();
                bookmarkInfo.LoadLikeLog();
                model = new UIBookmarkInfo();

                model.LikeCount   = bookmarkInfo.LikeCount;
                model.LikeLogList = bookmarkInfo.LikeLogList;

                Dictionary <long, BizTagInfo> dicTagInfo = BizTagInfo.LoadByUserID(bookmarkInfo.UserInfoID).ToDictionary(tag => tag.TagInfoID, tag => tag);

                model.BookmarkInfoID  = bookmarkInfo.BookmarkInfoID;
                model.BookmarkName    = bookmarkInfo.BookmarkName;
                model.Host            = bookmarkInfo.Host;
                model.Href            = bookmarkInfo.Href;
                model.UserInfoID      = bookmarkInfo.UserInfoID;
                model.UserWebFolderID = bookmarkInfo.UserWebFolderID;
                //model.HTML = bookmarkInfo.HTML;
                model.CreateTime = bookmarkInfo.CreateTime;
                var bookmarkUserInfo = BizUserInfo.LoadByUserInfoID(bookmarkInfo.UserInfoID);
                model.UserInfo = new UIUserInfo()
                {
                    UserName   = bookmarkUserInfo.UserName,
                    UserEmail  = bookmarkUserInfo.UserEmail,
                    UserInfoID = bookmarkUserInfo.UserInfoID,
                };
                model.TagInfoList = bookmarkInfo.BizBookmarkTagInfoList.Select(btg => new UIBookmarkTagInfo()
                {
                    BookmarkTagInfoID = btg.BookmarkTagInfoID,
                    BookmarkInfoID    = btg.BookmarkInfoID,
                    TagInfoID         = btg.TagInfoID,
                    CreateTime        = btg.CreateTime,
                    TagInfo           = dicTagInfo.ContainsKey(btg.TagInfoID) ? dicTagInfo[btg.TagInfoID] : null,
                }).ToList();
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        private static void NewBookmarkComment(long userID, object info)
        {
            var            bookmarkComment = info as BizBookmarkComment;
            var            bookmarkInfo    = BizBookmarkInfo.LoadByID(bookmarkComment.BookmarkInfoID);
            var            criticsUser     = BizUserInfo.LoadByUserInfoID(bookmarkComment.CriticsUserID);
            BizMessageInfo messageInfo     = new BizMessageInfo();

            messageInfo.CreateTime     = DateTime.Now;
            messageInfo.IsRead         = (int)MessageReadStatus.NotRead;
            messageInfo.MessageTitle   = string.Format("书签:【{0}】评论", bookmarkInfo.BookmarkName);
            messageInfo.MessageContent = string.Format("书签:【{0}】 新增来自【{1}】的评论,点击下面的链接去查看评论啦。^-^",
                                                       bookmarkInfo.BookmarkName, criticsUser.UserName);
            messageInfo.MessageURL      = "~/ShowBookmarkInfo?bookmarkID=" + bookmarkInfo.BookmarkInfoID;
            messageInfo.UserInfoID      = userID;
            messageInfo.MessageInfoType = (int)MessageTypeEnum.NewBookmarkComment;
            messageInfo.Save();
        }
Ejemplo n.º 5
0
        public ActionResult AddBookmarkLikeLog(long bookmarkID)
        {
            BizResultInfo result   = new BizResultInfo();
            var           loginUID = UILoginHelper.GetUIDFromHttpContext(HttpContext);

            var bookmarkInfo = BizBookmarkInfo.LoadByID(bookmarkID);

            if (bookmarkInfo != null)
            {
                var likelog = BizLikeLog.LoadUserIDAndBookmarkID(loginUID, bookmarkID);
                if (likelog != null)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = "你已经点赞过了呀,不要重复点赞了。";
                }
                else
                {
                    likelog            = new BizLikeLog();
                    likelog.InfoID     = bookmarkID;
                    likelog.InfoType   = (int)InfoTypeEnum.Bookmark;
                    likelog.UserInfoID = loginUID;
                    likelog.Save();

                    bookmarkInfo.LoadLikeLog();
                    result.Target         = bookmarkInfo.LikeCount;
                    result.IsSuccess      = true;
                    result.SuccessMessage = "点赞成功。";

                    UserDynamicInfoBo.CreateDynamicInfoMessage(loginUID, DynamicInfoType.NewLikeBookmark, bookmarkInfo);
                    MessageBo.CreateMessage(loginUID, MessageTypeEnum.NewLikeBookmarkLog, bookmarkInfo);
                }
            }
            else
            {
                result.IsSuccess    = false;
                result.ErrorMessage = "找不到书签呀,刷新一下再来试试?";
            }


            return(Json(result));
        }
Ejemplo n.º 6
0
        public ActionResult CollectBookmarkToUserDefaultFolder(long bookmarkID)
        {
            BizResultInfo result       = new BizResultInfo();
            var           bookmarkInfo = BizBookmarkInfo.LoadByID(bookmarkID);

            if (bookmarkInfo == null || bookmarkInfo.BookmarkInfoID == 0)
            {
                result.IsSuccess    = false;
                result.ErrorMessage = "书签数据有误,可能是数据库被怪兽吃掉了,也可能是你娃误操作给了一个错误的书签ID。建议刷新重试吧。";
                return(Json(result));
            }

            var loginUID = UILoginHelper.GetUIDFromHttpContext(HttpContext);

            if (bookmarkInfo.UserInfoID == loginUID)
            {
                result.IsSuccess    = false;
                result.ErrorMessage = "不用收藏自己的书签哦。";
                return(Json(result));
            }
            long folderID = GetUserDefaultFolderID(loginUID);

            BizBookmarkInfo newBookmark = new BizBookmarkInfo()
            {
                BookmarkName    = bookmarkInfo.BookmarkName,
                CreateTime      = DateTime.Now,
                Host            = bookmarkInfo.Host,
                Href            = bookmarkInfo.Href,
                UserInfoID      = loginUID,
                HTML            = bookmarkInfo.HTML,
                IElementJSON    = bookmarkInfo.IElementJSON,
                UserWebFolderID = folderID,
            };

            newBookmark.HashCode = newBookmark.GetHashCode();
            newBookmark.Save();
            result.IsSuccess = true;
            return(Json(result));
        }
Ejemplo n.º 7
0
        public ActionResult SaveBookmarkComment(long bookmarkID, string content)
        {
            BizResultInfo result = new BizResultInfo();

            try
            {
                var bookmark = BizBookmarkInfo.LoadByID(bookmarkID);
                if (bookmark == null || bookmark.BookmarkInfoID == 0)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = "序列化书签数据失败,目测你要重新加载页面。";
                    return(Json(result));
                }
                BizBookmarkComment comment = new BizBookmarkComment();
                comment.CriticsUserID  = UILoginHelper.GetUIDFromHttpContext(HttpContext);
                comment.CommentTitle   = "";
                comment.CommentContent = content;
                comment.BookmarkInfoID = bookmark.BookmarkInfoID;
                comment.CreateTime     = DateTime.Now;
                comment.BookmarkUserID = bookmark.UserInfoID;
                comment.Save();
                var loginUID = UILoginHelper.GetUIDFromHttpContext(HttpContext);
                MessageBo.CreateMessage(bookmark.UserInfoID, MessageTypeEnum.NewBookmarkComment, comment);
                UserDynamicInfoBo.CreateDynamicInfoMessage(loginUID, DynamicInfoType.NewBookmarkComment, bookmark);

                result.IsSuccess      = true;
                result.SuccessMessage = "提交成功。";
            }catch (Exception ex)
            {
                LogHelper.WriteException("SaveBookmarkComment", ex, new {
                    BookmarkID = bookmarkID,
                    SubmitUser = UILoginHelper.GetUIDFromHttpContext(HttpContext),
                    Content    = content,
                });
                result.ErrorMessage = "提交失败,目测网络挂了或者别的....";
                result.IsSuccess    = false;
            }
            return(Json(result));
        }
Ejemplo n.º 8
0
        public ActionResult RemoveBookmarkTag(long bookmarkID, long bookmarkTagInfoID = 0, string tagName = "")
        {
            BizResultInfo result       = new BizResultInfo();
            var           bookmarkInfo = BizBookmarkInfo.LoadByID(bookmarkID);

            if (bookmarkInfo == null || bookmarkInfo.BookmarkInfoID == 0)
            {
                result.ErrorMessage = "书签数据为空,不要逗我玩啦...";
                return(Json(result));
            }
            bookmarkInfo.LoadBookmarkTagInfo();
            if (!string.IsNullOrEmpty(tagName))
            {
                bookmarkInfo.RemoveByTagName(tagName);
            }

            if (bookmarkTagInfoID != 0)
            {
                bookmarkInfo.RemoveByBookmarkTagID(bookmarkTagInfoID);
            }
            result.SuccessMessage = "移除成功!";
            result.IsSuccess      = true;
            return(Json(result));
        }
Ejemplo n.º 9
0
        public ActionResult AddBookmark(string name, string href, long folderID, string type, long infoID)
        {
            BizResultInfo result = new BizResultInfo();

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(type))
            {
                result.ErrorMessage = "名称和类型必须填写呀。";
                result.IsSuccess    = false;
                return(Json(result));
            }
            var loginUid = UILoginHelper.GetUIDFromHttpContext(HttpContext);

            try
            {
                if (type == "bookmark")
                {
                    BizBookmarkInfo bookmark = new BizBookmarkInfo();

                    if (infoID != 0)
                    {
                        bookmark = BizBookmarkInfo.LoadByID(infoID);
                    }


                    bookmark.Href            = href;
                    bookmark.BookmarkName    = name;
                    bookmark.UserWebFolderID = folderID;
                    bookmark.CreateTime      = DateTime.Now;
                    bookmark.Host            = href.GetHost();
                    bookmark.UserInfoID      = loginUid;
                    bookmark.HashCode        = bookmark.GetHashCode();
                    bookmark.Save();
                }
                else
                {
                    BizUserWebFolder folder = new BizUserWebFolder();
                    if (infoID != 0)
                    {
                        folder = BizUserWebFolder.LoadByID(infoID);
                    }

                    folder.UserInfoID        = loginUid;
                    folder.WebFolderName     = name;
                    folder.ParentWebfolderID = folderID;
                    folder.IntroContent      = "";
                    folder.IElementJSON      = "";
                    folder.CreateTime        = DateTime.Now;
                    folder.IElementHashcode  = folder.GetHashCode();
                    folder.Save();
                }



                result.IsSuccess      = true;
                result.SuccessMessage = "保存成功了耶,刷新一下页面就能看到了哦。";
            }catch (Exception ex)
            {
                result.IsSuccess      = false;
                result.SuccessMessage = "保存失败,可能是数据库不开心了吧,重新保存试试。";
                LogHelper.WriteException("AddBookmark Exception", ex, new { Name = name, Href = href, FolderID = folderID });
            }
            return(Json(result));
        }