Exemplo n.º 1
0
 /// <summary>
 /// 记录新访问者的信息
 /// </summary>
 /// <param name="visitor">访问者信息</param>
 /// <returns></returns>
 public static long InsertNewVisitor(VisitorRecord visitor)
 {
     var newVisitor = new tbl_VisitRecord()
     {
         VisitorIP = visitor.VisitorIP,
         UserAgent = visitor.UserAgent,
         VisitTime = visitor.VisitTime
     };
     XwgWebDBEntities db = new XwgWebDBEntities();
     db.tbl_VisitRecord.Add(newVisitor);
     var count = db.SaveChanges();
     return count > 0 ? newVisitor.VisitorId : -1;
 }
Exemplo n.º 2
0
 /// <summary>
 /// 保存聊天记录
 /// </summary>
 /// <param name="visitorId">访问者Id</param>
 /// <param name="nickname">昵称</param>
 /// <param name="message">发送的消息</param>
 /// <returns></returns>
 public static long SaveChatMessage(long visitorId, string nickname, string message)
 {
     var newMessage = new tbl_ChatRecord()
     {
         VisitorId = visitorId,
         Message = message,
         NickName = nickname,
         SendTime = DateTime.Now
     };
     XwgWebDBEntities db = new XwgWebDBEntities();
     db.tbl_ChatRecord.Add(newMessage);
     var count = db.SaveChanges();
     return count > 0 ? newMessage.RecordId : -1;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 添加新的评论
        /// </summary>
        /// <param name="record">评论记录</param>
        /// <returns></returns>
        public static CommentRecord AddNew(CommentRecord record, long pageId)
        {
            var newComment = new tbl_CommentRecord
            {
                Comment = record.Comment,
                CommentTime = record.CommentTime,
                NickName = record.Nickname,
                PageId = pageId,
                VisitorId = record.VisitorId
            };

            XwgWebDBEntities entities = new XwgWebDBEntities();
            entities.tbl_CommentRecord.Add(newComment);
            var count = entities.SaveChanges();

            record.RecordId = newComment.RecordId;
            return count > 0 ? record : null;
        }