public string GenerateOneLeaveMsg(Visitor visitor, LeaveMsg lvm)
        {
            //先根据visitor.HeadiconId查出visitor的头像
            HeadIcon icon = headService.GetEntity(visitor.VisitorIconId.Value);

            StringBuilder sbuilder = new StringBuilder();

            #region 临时回复模板
            // @*临时回复区域*@
            sbuilder.Append("<li id=\"li-comment-" + lvm.Id + "\" class=\"comment byuser " + visitor.VisitorName + "  even thread-even depth-1\">");
            sbuilder.Append("<article class=\"comment-body\" id=\"div-comment-" + lvm.Id + "\">");
            sbuilder.Append("<footer class=\"comment-meta\">");
            sbuilder.Append("<div class=\"comment-author vcard\">");
            //此处最好再在基础类里加一个获取默认值的方法:默认头像,默认博文封面图片,
            string defaultIconPath = ConfigurationManager.AppSettings["DefaultHeadIcon"];
            sbuilder.Append("<img width=\"60\" height=\"60\" class=\"avatar avatar-70 photo\" src=\"" + ((icon != null) ? icon.IconURL : defaultIconPath) + "\" alt=\"" + visitor.VisitorName + "\">	");
            sbuilder.Append("<b class=\"fn\">" + visitor.VisitorName + "</b> <span class=\"says\">say :</span>");
            sbuilder.Append("</div>");
            sbuilder.Append("<div class=\"comment-metadata\">");
            sbuilder.Append("<a href=\"\">");
            sbuilder.Append(lvm.SubTime);
            sbuilder.Append("</a>");
            sbuilder.Append("</div>");
            sbuilder.Append("</footer>");
            sbuilder.Append("<div class=\"comment-content\">");
            sbuilder.Append("<p>" + lvm.LMessage + "</p>");
            sbuilder.Append("</div>");
            sbuilder.Append("</article>");
            sbuilder.Append("</li>");
            #endregion

            return(sbuilder.ToString());
        }
Esempio n. 2
0
        public ActionResult DoLeaveMsg(LeaveMsg leaveMsg_me)
        {
            Response response = new Response()
            {
                Code = 0
            };

            if (!CurrUser.IsLogin)
            {
                response.Message = "必须是登录用户才能留言";
                return(Json(response));
            }
            if (ModelState.IsValid)
            {
                Domain.Model.User.User user = new UserManager().Find(Convert.ToInt32(CurrUser.UserID));
                if (user == null)
                {
                    response.Message = "必须是注册前台用户才能留言";
                    return(Json(response));
                }
                Domain.Model.Blog.LeaveMsg leaveMsg = new LeaveMsg();
                leaveMsg.Msg        = leaveMsg_me.Msg;
                leaveMsg.CreateTime = DateTime.Now;
                leaveMsg.User       = user;
                response            = leaveMsgManager.Add(leaveMsg);
            }
            return(Json(response));
        }
Esempio n. 3
0
 public void OnLeave(LeaveMsg msg)
 {
     if (msg.index == player.index)
     {
         SceneManager.LoadSceneAsync("RoomScene");
         return;
     }
     if (msg.host == player.index)
     {
         player.isHost = true;
     }
     for (int i = 0; i < otherPlayers.Count; i++)
     {
         if (otherPlayers[i].index == msg.index)
         {
             otherPlayers.RemoveAt(i);
             GameObject obj = GameObject.Find(otherPlayers[i].playerInfo.userId);
             GameObject.Destroy(obj);
             usedIndex.Remove(msg.index);
         }
         if (otherPlayers[i].index == msg.host)
         {
             otherPlayers[i].isHost = true;
         }
     }
 }
        public ActionResult PublicLeaveMsg(int id)
        {
            LeaveMsg comment = new LeaveMsg()
            {
                Id     = id,
                Status = 1
            };

            int val = lvmService.Update(comment, "Status");

            return(Json(val));
        }
Esempio n. 5
0
        private LeaveMsg DReader(SqlDataReader dr)
        {
            LeaveMsg info = new LeaveMsg();

            info.Id      = dr.IsDBNull(0) ? 0 : dr.GetInt32(0);
            info.Name    = dr.IsDBNull(1) ? string.Empty : dr.GetString(1);
            info.Theme   = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
            info.Info    = dr.IsDBNull(3) ? string.Empty : dr.GetString(3);
            info.Time    = dr.IsDBNull(4) ? DateTime.Now : dr.GetDateTime(4);
            info.Link    = dr.IsDBNull(5) ? string.Empty : dr.GetString(5);
            info.IsReply = dr.IsDBNull(6) ? 0 : dr.GetInt32(6);
            return(info);
        }
Esempio n. 6
0
        /// <summary>
        /// 按id查找
        /// </summary>
        /// <returns></returns>
        public LeaveMsg GetleaveMsgById(int id)
        {
            string sql = "SELECT * FROM [tb_leaveMsg] where [id]=@id  order by [time] desc";

            using (SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, sql, new SqlParameter("@id", id)))
            {
                LeaveMsg leavemsg = new LeaveMsg();
                if (dr.HasRows && dr.Read())
                {
                    leavemsg = DReader(dr);
                }
                return(leavemsg);
            }
        }
        public ActionResult SetEditedEntity(int Id)
        {
            string   editedContent = Request["editinput"];
            LeaveMsg model         = new LeaveMsg()
            {
                Id = Id
            };

            model.LMessage = editedContent;
            model.AltTime  = DateTime.Now;

            int val = lvmService.Update(model, "LMessage", "AltTime");

            return(Json(val));
        }
        public JsonResult ReplyLeaveMsg(int Id)
        {
            string editedContent = Request["replyinput"];

            LeaveMsg model = new LeaveMsg()
            {
                ParentId  = Id,
                VisitorId = 197,  //博主我本身
                LMessage  = editedContent,
                Status    = 1,
                SubTime   = DateTime.Now
            };

            int val = lvmService.Add(model);

            return(Json(val));
        }
Esempio n. 9
0
        public ActionResult AddNewsReplyMsg()
        {
            string ip     = Request["ip"];
            string msg    = Request["msg"];
            string guid   = Request["userId"];
            var    user   = Common.CacheHelper.Get(guid) as PersonalUser;
            int    userId = 0;

            if (user != null)
            {
                userId = user.Id;
            }
            if (ForbiddenListBll.CheckBannd(msg))
            {
                return(Content("banned,提示:您所输入的信息包含禁用词!"));
            }
            if (BlackListIPBll.CheckBlackListIp(ip))
            {
                return(Content("ipNo,提示:您所在地IP已被受限!暂不能发表评论!如需操作,联系爽赞网管理人员"));
            }
            else
            {
                LeaveMsg levaemsg = new LeaveMsg()
                {
                    PersonalUserId = userId,
                    IP             = ip,
                    City           = Request["city"],
                    Msg            = msg,
                    MsgNum         = null,
                    InTime         = DateTime.Now,
                    ReplyId        = int.Parse(Request["replyId"]),  //变化点
                    UserRaidersId  = int.Parse(Request["raidersId"]) //变化点
                };
                if (LeaveMsgBll.Add(levaemsg) != null)
                {
                    return(Content("ok,恭喜:评论提交成功"));
                }
                else
                {
                    return(Content("no,提示:评论提交失败!"));
                }
            }
        }
Esempio n. 10
0
        ///<summary>
        ///增
        ///</summary>
        /// <param name="info"></param>
        /// <returns></returns>

        public bool Insert(LeaveMsg info)
        {
            string sql = "INSERT INTO [tb_leaveMsg] ([name], [theme], [info], [time], [link], [isReply]) VALUES(@name, @theme, @info, @time, @link, @isReply)";

            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@name", info.Name),
                new SqlParameter("@theme", info.Theme),
                new SqlParameter("@info", info.Info),
                new SqlParameter("@time", info.Time),
                new SqlParameter("@link", info.Link),
                new SqlParameter("@isReply", info.IsReply)
            };
            if (SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, sql, parms) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        ///<summary>
        ///改
        ///</summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool Update(LeaveMsg info)
        {
            string sql = "Update [tb_leaveMsg] SET [name]=@name,[theme]=@theme,[info]=@info,[time]=@time,[link]=@link,[isReply]=@isReply where [id]=@id";

            sql = String.Format(sql /*补充内容*/);
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@id", info.Id),
                new SqlParameter("@name", info.Name),
                new SqlParameter("@theme", info.Theme),
                new SqlParameter("@info", info.Info),
                new SqlParameter("@time", info.Time),
                new SqlParameter("@link", info.Link),
                new SqlParameter("@isReply", info.IsReply)
            };
            if (SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, sql, parms) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
    public static void ProcessMessage(string message)
    {
        Command command = JsonConvert.DeserializeObject <Command>(message);

        Debug.Log("Receive command " + command.action);
        switch (command.action)
        {
        case PLAYERS:
            List <Player> players = JsonConvert.DeserializeObject <List <Player> >(command.data);
            OnJoinEvent(players);
            break;

        case NEWPLAYER:
            Player player = JsonConvert.DeserializeObject <Player>(command.data);
            OnNewPlayerEvent(player);
            break;

        case LEAVE:
            LeaveMsg msg = JsonConvert.DeserializeObject <LeaveMsg>(command.data);
            OnLeaveEvent(msg);
            break;

        case CARDS:
            List <string> cards = JsonConvert.DeserializeObject <List <string> >(command.data);
            OnCardsEvent(cards);
            break;

        case PLAY:
        case FOLD:
            PlayData playData = JsonConvert.DeserializeObject <PlayData>(command.data);
            playData.action = command.action;
            OnPlayEvent(playData);
            break;

        case START:
            OnStartEvent(Convert.ToInt32(command.data));
            break;

        case ELIMINATED:
            List <int> disqualifiers = JsonConvert.DeserializeObject <List <int> >(command.data);
            OnEliminatedEvent(disqualifiers);
            break;

        case ERROR:
            int error = Convert.ToInt32(command.data);
            OnErrorEvent(error);
            break;

        case INFORM:
            OnInformEvent();
            break;

        case RESULT:
            List <ResultMsg> results = JsonConvert.DeserializeObject <List <ResultMsg> >(command.data);
            OnResultEvent(results);
            break;

        default:
            Debug.Log("Received unhandled event " + command.action);
            break;
        }
    }
Esempio n. 13
0
        public void SendBlogLvmEmail(LeaveMsg lvm)
        {
            //7.1 获取系统邮件Key Secret
            IBLL.IWebSettingService wService = OperateHelper.Current.serviceSession.WebSettingService;
            WebSetting keySeting             = wService.GetDataListBy(w => w.ConfigKey == "SystemEmailKey").FirstOrDefault();
            WebSetting secretSeting          = wService.GetDataListBy(w => w.ConfigKey == "SystemEmailSecret").FirstOrDefault();

            string systemEmailName   = keySeting.ConfigValue;    //系统邮箱
            string systemEmailSecret = secretSeting.ConfigValue; //系统邮箱密码

            //7.2 先取到这条留言的最根上的留言Id
            int      rootlvmId = 0;
            int      parentId  = 0;
            LeaveMsg parentLvm = leaveService.GetDataListBy(c => c.Id == lvm.ParentId).FirstOrDefault();
            LeaveMsg tempLvm   = parentLvm;

            if (parentLvm != null)
            {
                //7.3 父Id
                parentId = parentLvm.Id;
                while (tempLvm != null)
                {
                    tempLvm = leaveService.GetDataListBy(c => c.Id == tempLvm.ParentId).FirstOrDefault();
                    if (tempLvm != null)
                    {
                        parentLvm = tempLvm;
                    }
                }
                rootlvmId = parentLvm.Id;
            }
            else
            {
                rootlvmId = lvm.Id;
            }

            //7.4 url参数;最终这些参数将发送到前台js进行锚点定位、高亮处理
            string url = "http://127.0.0.1:8081/LeaveMsg/Index/"
                         + "?Flag=" + Common.Security.Base64UTF8Encode("1")
                         + "&AnchorLvmRootId=" + Common.Security.Base64UTF8Encode(rootlvmId.ToString())
                         + "&AnchorLvmParentId=" + Common.Security.Base64UTF8Encode(parentId.ToString())
                         + "&AnchorLvmId=" + Common.Security.Base64UTF8Encode(lvm.Id.ToString());//Ajax加载完数据后定位到锚点

            //7.5 构造邮件主题、内容、发送邮件
            Visitor visitor = visitorService.GetEntity(lvm.VisitorId);

            if (lvm.ParentId == 0)
            {
                //给博主的留言
                string subject = "[您的博客有新留言]Re:留言板";

                url += "&Vid=" + Common.Security.Base64UTF8Encode("1");

                Visitor blogger = visitorService.GetEntity(1); //Id=3的是博主=我

                string emailBody = @"#Re: 留言板"
                                   + "<br/>"
                                   + "新留言:"
                                   + "<br/>"
                                   + "内容:" + lvm.LMessage
                                   + "<hr/>"
                                   + "留言者:<a href='#' >" + visitor.VisitorName + "</a>"
                                   + "<br/>"
                                   + "URL:"
                                   + "<a href='" + url + "' title='链接地址'>" + url + "</a>"
                                   + "<br/>"
                                   + "(系统通知,请勿回复)";

                SendMail.SendEMail("smtp.126.com", systemEmailName, systemEmailSecret, blogger.VisitorEmail, subject, emailBody);
            }
            else
            {
                //游客给其它留言者的回复
                LeaveMsg parentlvm = leaveService.GetEntity(lvm.ParentId);

                string toEmail = parentlvm.Visitor.VisitorEmail;
                string subject = "[zynblog留言新回复]Re:";

                url += "&Vid=" + parentlvm.Visitor.Id;

                string emailBody = @"#Re: zynblog留言板"
                                   + "<br/>"
                                   + "<a href='#'>@ </a>" + parentlvm.Visitor.VisitorName
                                   + "<br/>"
                                   + "内容:" + lvm.LMessage
                                   + "<hr/>"
                                   + "回复者:<a href='#' >" + visitor.VisitorName + "</a>"
                                   + "<br/>"
                                   + "URL:"
                                   + "<a href='" + url + "' title='链接地址'>" + url + "</a>"
                                   + "<br/>"
                                   + "(系统通知,请勿回复)";

                SendMail.SendEMail("smtp.126.com", systemEmailName, systemEmailSecret, toEmail, subject, emailBody);
            }
        }
Esempio n. 14
0
        public ActionResult PostLvm(LeaveMsg lvm)
        {
            //当每次进入Archives/Index时,就根据cookie或者session将用户信息绑定到留言框上的input标签中
            //然后,提交的时候,这儿就获取标签里面的游客信息
            string visitorId    = Request["VId"];
            string visitorName  = Request["VName"];
            string visitorEmail = Request["VEmail"];

            JsonModel jsonData;

            #region 1.0 如果能取到隐藏域中的visitorId,证明游客存在;则直接将留言入库
            if (!String.IsNullOrEmpty(visitorId))
            {
                //1.0 执行 model验证 并 插入库中
                //ParentId和LMessage已进行模型绑定
                lvm.VisitorId = int.Parse(visitorId);
                lvm.LMessage  = StringHelper.ClearHtml(lvm.LMessage); //清除html
                lvm.Status    = 1;
                lvm.SubTime   = DateTime.Now;

                int val = leaveService.Add(lvm);//入库
                if (val == 1)
                {
                    int vid = int.Parse(visitorId);
                    //构造json数据
                    jsonData = new JsonModel()
                    {
                        CoreData = GenerateOneLeaveMsg(visitorService.GetDataListBy(v => v.Id == vid)[0], lvm),
                        Status   = 1,
                        Message  = visitorId,
                    };
                }
                else
                {
                    //构造json数据
                    jsonData = new JsonModel()
                    {
                        CoreData = "",
                        Status   = 0,
                        Message  = "留言失败,请重试",
                        GotoUrl  = Request.UrlReferrer.AbsoluteUri  //获取上一级url
                    };
                }

                SetVisitorCookie(visitorId);
                SendBlogLvmEmail(lvm);
                return(Json(jsonData));
            }
            #endregion
            #region 2.0 如果取不到隐藏域中的访客信息,则先生成一个访客(根据输入信息判断是否为老游客),再生成留言
            else
            {
                //检验visitorName、visitorEmail。放到前台验证是否为空,邮箱格式是否正确
                visitorName  = visitorName.Trim();
                visitorEmail = visitorEmail.Trim();
                List <Visitor> checkVisitor = visitorService.GetDataListBy(v => v.VisitorName == visitorName);
                if (checkVisitor != null && checkVisitor.Count != 0)
                {
                    Visitor vi = checkVisitor.Find(c => c.VisitorEmail == visitorEmail);
                    if (vi != null)
                    {
                        lvm.VisitorId = vi.Id;
                        lvm.LMessage  = StringHelper.ClearHtml(lvm.LMessage);
                        lvm.Status    = 1;
                        lvm.SubTime   = DateTime.Now;

                        int val = leaveService.Add(lvm);//入库
                        if (val == 1)
                        {
                            //构造json数据
                            jsonData = new JsonModel()
                            {
                                CoreData = GenerateOneLeaveMsg(visitorService.GetDataListBy(v => v.Id == vi.Id)[0], lvm),
                                Status   = 1,
                                Message  = vi.Id.ToString(),
                            };
                            //发邮件
                            SendBlogLvmEmail(lvm);
                        }
                        else
                        {
                            //构造json数据
                            jsonData = new JsonModel()
                            {
                                CoreData = "",
                                Status   = 0,
                                Message  = "留言失败,请重试",
                                GotoUrl  = Request.UrlReferrer.AbsoluteUri  //获取上一级url
                            };
                        }

                        SetVisitorCookie(vi.Id.ToString());
                    }
                    else
                    {
                        //如果昵称一样,邮箱不一样,则认为是新注册用户,这是提示它昵称已被抢注,请换个昵称
                        jsonData = new JsonModel()
                        {
                            CoreData = lvm.LMessage,
                            Status   = 2,
                            Message  = "该昵称已被占用,再起个吧~"
                        };
                    }
                }
                else
                {
                    //Add新游客
                    if (String.IsNullOrEmpty(visitorEmail))
                    {
                        //构造json数据
                        jsonData = new JsonModel()
                        {
                            CoreData = "",
                            Status   = 2, //此处要根据错误类型定制弹出消息,以便js进行弹出框类型处理
                            //0:留言失败,请刷新后重试;1:成功;2:邮箱错误
                            Message = "请输入邮箱后再发表留言",
                        };
                    }
                    else
                    {
                        //将新游客和游客的留言入库
                        //用户头像,从头像表中随机抽取一个
                        int             iconId   = 0;
                        List <HeadIcon> headList = headService.GetDataListBy(h => h.Status == 1);
                        Random          rom      = new Random();
                        if (headList.Count != 0)
                        {
                            iconId = headList[rom.Next(headList.Count)].Id;
                        }

                        Visitor newVisitor = new Visitor()
                        {
                            VisitorName   = visitorName,
                            VisitorEmail  = visitorEmail,
                            VisitorQQ     = "",
                            VisitorIconId = iconId,  //随机选一个用户头像
                            Status        = 1,
                            SubTime       = DateTime.Now
                        };

                        //lvmArtId ParentId和lvmText已进行模型绑定
                        lvm.LMessage = lvm.LMessage = StringHelper.ClearHtml(lvm.LMessage);;
                        lvm.Status   = 1;
                        lvm.SubTime  = DateTime.Now;

                        //向Visitor model的导航属性实体集中追加一个model
                        newVisitor.LeaveMsgs.Add(lvm);

                        //根据导航属性同时向数据库插入两条数据
                        int val = visitorService.Add(newVisitor);
                        if (val == 2)
                        {
                            jsonData = new JsonModel()
                            {
                                CoreData = GenerateOneLeaveMsg(newVisitor, lvm),
                                Status   = 1,
                                Message  = (newVisitor.Id).ToString(),
                            };

                            SetVisitorCookie((newVisitor.Id).ToString());
                            SendBlogLvmEmail(lvm);
                        }
                        else
                        {
                            jsonData = new JsonModel()
                            {
                                Status  = 0,
                                Message = "留言失败,请刷新后重试",
                                GotoUrl = Request.UrlReferrer.AbsoluteUri   //获取上一级url
                            };
                        }
                    }
                }

                return(Json(jsonData));
            }
            #endregion
        }