예제 #1
0
 /// <summary>
 /// 保存书签和更新书签夹到数据库(异步)
 /// </summary>
 /// <param name="dicHashcodeToModel"></param>
 /// <param name="lstBizHrefInfo"></param>
 private static void AsyncSaveBookmarkAndUpdataWebfolderToDB(Dictionary <int, BizUserWebFolder> dicHashcodeToModel, List <BizBookmarkInfo> lstBizHrefInfo)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             UserWebFolderBo.BatchUpdateWebfolder(dicHashcodeToModel.Values.ToList());
         }
         catch (Exception ex)
         {
             LogHelper.WriteException("BatchUpdateWebfolder Exception", ex,
                                      new { DicHashcodeToModel = dicHashcodeToModel, });
         }
     });
     Task.Factory.StartNew(() =>
     {
         try
         {
             BookmarkInfoBo.BatchSaveToDB(lstBizHrefInfo);
         }
         catch (Exception ex)
         {
             LogHelper.WriteException("BookmarkInfo BatchSaveToDB Exception", ex,
                                      new
             {
                 BizHrefInfoList = lstBizHrefInfo
             });
         }
     });
 }
예제 #2
0
        /// <summary>
        /// 获取推荐用户ID(通过用户书签的host记录)
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static List <long> GetRecommendUserIDListDependHost(long userID)
        {
            var userBookmarkList = BookmarkInfoBo.LoadByUID(userID);

            if (userBookmarkList == null)
            {
                return(new List <long>());
            }
            var hosts       = userBookmarkList.Select(model => model.Host).Distinct().ToList();
            var lstBookmark = new BookmarkInfoDAL().GetListByHosts(hosts, userID);

            return(lstBookmark.Select(model => model.UserInfoID).Distinct().ToList());//获取用户ID
        }
예제 #3
0
        public static List <BizBookmarkInfo> GetRecommendBookmarkList(long userID, int starIndex = 0, int length = 0)
        {
            var userBookmarkList = BookmarkInfoBo.LoadByUID(userID);

            if (userBookmarkList == null)
            {
                return(new List <BizBookmarkInfo>());
            }
            var hosts = userBookmarkList.Select(model => model.Host).Distinct().ToList();

            hosts = Extend.GetRandomList(hosts);
            if (hosts.Count > 10)
            {
                hosts = hosts.Take(10).ToList();
            }

            var lstBookmark = new BookmarkInfoDAL().GetListByHosts(hosts, userID, starIndex, length);

            return(lstBookmark.Select(model => new BizBookmarkInfo(model)).ToList());
        }
예제 #4
0
        /// <summary>
        /// 加载书签夹数据
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public static BizResultInfo LoadWebfolderByUID(long uid)
        {
            var result = new BizResultInfo();

            try
            {
                var lstWebFolder = BizUserWebFolder.LoadAllByUID(uid);
                var lstBookmark  = BookmarkInfoBo.LoadByUID(uid);
                Dictionary <long, List <BizBookmarkInfo> >  dicWebfolderIDToBookmarkList    = new Dictionary <long, List <BizBookmarkInfo> >();
                Dictionary <long, List <BizUserWebFolder> > dicParentWebfolderIDToWebfolder = new Dictionary <long, List <BizUserWebFolder> >();

                FillDictionary(lstWebFolder, lstBookmark, dicWebfolderIDToBookmarkList, dicParentWebfolderIDToWebfolder);

                foreach (var webfolder in lstWebFolder)
                {
                    if (dicWebfolderIDToBookmarkList.ContainsKey(webfolder.UserWebFolderID))
                    {
                        webfolder.BizBookmarkInfoList = dicWebfolderIDToBookmarkList[webfolder.UserWebFolderID];
                    }
                    if (dicParentWebfolderIDToWebfolder.ContainsKey(webfolder.UserWebFolderID))
                    {
                        webfolder.ChildrenFolderList = dicParentWebfolderIDToWebfolder[webfolder.UserWebFolderID];
                    }
                }

                result.IsSuccess = true;
                result.Target    = lstWebFolder;
            }catch (Exception ex)
            {
                result.IsSuccess    = false;
                result.ErrorMessage = "加载数据失败了,可能是网络挂了,可能这就是命吧。";
                result.Target       = null;
                LogHelper.WriteException("LoadWebfolderByUID Exception", ex, new { UID = uid });
            }

            return(result);
        }
예제 #5
0
 public static bool DeleteWebfolder(long webFolderID)
 {
     return(BookmarkInfoBo.DeleteByWebFolderID(webFolderID) && webFolderDAL.DeleteByUserWebFolderID(webFolderID) > 0);
 }