Esempio n. 1
0
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static BizResultInfo RegisterUser(BizUserInfo userInfo)
        {
            var result = new BizResultInfo();

            try
            {
                userInfo.Save();
                var newUserInfo = BizUserInfo.LoadByUserEmailOrUserLoginName(userInfo.UserEmail);
                if (newUserInfo != null && newUserInfo.UserInfoID != 0)
                {
                    result.IsSuccess      = true;
                    result.ResultID       = newUserInfo.UserInfoID.ConvertToCiphertext();
                    result.SuccessMessage = "注册成功,请登录注册邮箱查收激活账号邮件完成注册操作。";
                    MessageBo.CreateMessage(newUserInfo.UserInfoID, MessageTypeEnum.WelcomeToWebBookmark, newUserInfo);
                }
                else
                {
                    result.IsSuccess      = false;
                    result.SuccessMessage = "注册失败,请重试。";
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess    = false;
                result.ErrorMessage = ex.ToString();
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        ///  遍历书签数据,构建bookmark和webfolder 对应关系,落地到库
        /// </summary>
        /// <param name="path">绝对地址</param>
        /// <param name="uid">用户UID</param>
        /// <returns></returns>
        public static BizResultInfo ImportBookmarkDataToDB(string path, long uid)
        {
            Dictionary <int, IElement> dicWebfolderElement = new Dictionary <int, IElement>();
            Dictionary <IElement, List <IElement> > dicWebfolderToBookmarkList = new Dictionary <IElement, List <IElement> >();
            Dictionary <int, BizUserWebFolder>      dicHashcodeToModel         = new Dictionary <int, BizUserWebFolder>();
            List <BizBookmarkInfo> lstBizHrefInfo = new List <BizBookmarkInfo>();

            if (!System.IO.File.Exists(path))
            {
                return(new BizResultInfo()
                {
                    IsSuccess = false, ErrorMessage = "文件不存在哦。"
                });
            }

            var allText = System.IO.File.ReadAllText(path);

            if (string.IsNullOrEmpty(allText))
            {
                return(new BizResultInfo()
                {
                    IsSuccess = false, ErrorMessage = "书签文件是空的,换一个文件呀。"
                });
            }

            try
            {
                allText = allText.Replace("\n", "").Replace("<p>", "");
                var tree = new HtmlParser().Parse(allText);

                FillDictionarydicWebfolderAndBookmarkList(tree.FirstElementChild,
                                                          dicWebfolderElement, dicWebfolderToBookmarkList);

                SaveWebFolderToDBAndFillHashModel(uid, dicWebfolderElement, ref dicHashcodeToModel);

                FillBookmarkModelAndWebfolderInfo(tree.FirstElementChild, uid, lstBizHrefInfo, dicHashcodeToModel);

                AsyncSaveBookmarkAndUpdataWebfolderToDB(dicHashcodeToModel, lstBizHrefInfo);
                MessageBo.CreateMessage(uid, MessageTypeEnum.ImportBookmarkSuccess, null);
            }
            catch (Exception ex)
            {
                MessageBo.CreateMessage(uid, MessageTypeEnum.ImportBookmarkFail, null);
                LogHelper.WriteException("遍历书签文件失败", ex, new { UserInfoID = uid, Path = path });
                return(new BizResultInfo()
                {
                    IsSuccess = false, ErrorMessage = "发生了一些意外,反正你是看不懂的...."
                });
            }


            return(new BizResultInfo()
            {
                IsSuccess = true, SuccessMessage = "保存成功耶,你可以到别的地方玩了。"
            });
        }