Exemplo n.º 1
0
        /// <summary>
        /// 获取用户下的所有标签和文章分类
        /// </summary>
        /// <returns></returns>
        public UserTagTypesOutput GetUserTagTypes()
        {
            UserTagTypesOutput userTagTypes = new UserTagTypesOutput();

            userTagTypes.BlogTags  = GetDataHelper.GetAllTag(BLLSession.UserInfoSessioin.Id).ToList();
            userTagTypes.BlogTypeS = GetDataHelper.GetAllType(BLLSession.UserInfoSessioin.Id).ToList();
            return(userTagTypes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 公共数据存储(从数据缓存中取 如何以后数据量大的话 再考虑是否实时查询)
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="name"></param>
        private void SetDic(Dictionary <string, object> dic, string name)
        {
            var user = GetDataHelper.GetAllUser().FirstOrDefault(t => t.UserName == name);

            //dic.Add("blogName", name);
            dic.Add(Constant.blogUser, user);
            dic.Add(Constant.userBlogTag, GetDataHelper.GetAllTag(user.Id).ToList());
            dic.Add(Constant.userBlogType, GetDataHelper.GetAllType().Where(t => t.BlogUser.Id == user.Id).ToList());
            dic.Add(Constant.SessionUser, BLL.Common.BLLSession.UserInfoSessioin);
        }
        //static string siteUrl = string.Empty;// "blog.haojima.net";

        /// <summary>
        /// 站内搜索地址
        /// </summary>
        //public string GetSiteUrl()
        //{
        //    if (string.IsNullOrEmpty(siteUrl))
        //        siteUrl = Request.Url.Host;
        //    return siteUrl;
        //}

        /// <summary>
        /// 登录
        /// </summary>
        public void Login()
        {
            var    data     = Request.QueryString["mydata"];
            string callback = Request.QueryString["callback"];
            JavaScriptSerializer        jss = new JavaScriptSerializer();
            Dictionary <string, string> dic = jss.Deserialize <Dictionary <string, string> >(data);
            var    name     = dic["username"].Trim();
            var    pass     = dic["password"].Trim();
            var    userinfo = GetDataHelper.GetAllUser().Where(t => t.UserName == name && t.UserPass == pass.MD5().MD5()).FirstOrDefault();
            object tyeList  = null;

            if (userinfo != null)
            {
                tyeList = GetDataHelper.GetAllType().Where(t => t.BlogUser.Id == userinfo.Id).Select(t => new
                {
                    TypeName = t.TypeName,
                    Id       = t.Id
                }).ToList();
            }
            var cc = callback + "('" + tyeList.ToJson() + "')";

            Response.ContentType = "application/json";
            Response.Write(cc);
        }