Esempio n. 1
0
        public static string BuildNewsFeed(UserEntity entity)
        {
            StringBuilder sb = new StringBuilder();

            IList <EventEntity>       list   = EventFeed.ListEvent(entity.id, 100, 0);
            IEnumerable <EventEntity> stick  = from e in list where e.type == EventType.Important select e;
            IEnumerable <EventEntity> normal = from e in list where e.type == EventType.Normal select e;


            //stick 消息
            if (stick != null && stick.Count() > 0)
            {
                sb.Append("<div class=\"s_story\"><div class=\"s_title\">重要的消息</div>");
                foreach (EventEntity se in stick)
                {
                    EventTemplateData ede = new EventTemplateData(se);
                    sb.Append(EventTemplate.Build(ede));
                }
                sb.Append("</div>");
            }

            //普通消息
            if (normal != null && normal.Count() > 0)
            {
                foreach (EventEntity ee in normal)
                {
                    EventTemplateData ede = new EventTemplateData(ee);
                    sb.Append("<div class=\"s_story\"><div class=\"ef\">");
                    sb.Append(EventTemplate.Build(ede));
                    sb.Append("</div></div>");
                }
            }

            return(sb.ToString());
        }
Esempio n. 2
0
        //TODO:移到存储过程里
        /// <summary>
        ///  完成注册及用户初始化相关操作
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <param name="email"></param>
        /// <param name="code"></param>
        /// <param name="srcid"></param>
        /// <returns></returns>
        public static bool Signup(string name, string pwd, string email, string code, string sid)
        {
            string www = UserAccount.GetWWW(name); //normal signup
            int    id  = -1;

            if (string.IsNullOrEmpty(code))
            {
                id = UserAccount.Create(name, pwd, email, www);
                if (id > 0)
                {
                    UserData.Initialize(name, www, id, sid, null);
                }
            }
            else
            {
                if (UserData.LockCode(code, sid)) //invited signup
                {
                    id = UserAccount.Create(name, pwd, email, www);
                    if (id > 0)
                    {
                        UserData.Initialize(name, www, id, sid, code);
                    }
                    else
                    {
                        UserData.UnLockCode(code);
                    }
                }
            }

            if (id > 0)
            {
                //create feed of signup event
                EventFeed.CreateEvent(0, 5, id, -1, "signup", "");

                //添加默认好友


                //write cookie
                string nid = id.ToString();
                QA.SetCookie(FormsAuthentication.FormsCookieName,
                             FormsAuthentication.Encrypt(new FormsAuthenticationTicket(1, nid, DateTime.Now, DateTime.Now.AddDays(1.0), true, nid, FormsAuthentication.FormsCookiePath))
                             , DateTime.MaxValue); //设置永久保留登录信息,之后版本可考虑进行配置
                QA.SetCookie(SC.CN.A_NAME, HttpUtility.UrlEncode(name), DateTime.MaxValue);
                string cookie = QA.GetCookie(SC.CN.FROM);

                return(true);
            }

            return(false);
        }