Beispiel #1
0
        /// <summary>
        /// 插入评论
        /// ok: 成功,err:失败
        /// 
        /// 创建标识:一木鱼 20080507
        /// </summary>
        private void InsertComment()
        {
            String strMsg = "";
            Result lastresult = Result.Null;
            string body = XYRequest.GetQueryString("CommentBody").Trim();
            string newsId = XYRequest.GetQueryString("NewsID").Trim();
            string isHiddenIP = XYRequest.GetQueryString("IsHiddenIP").Trim();
            string vcode = XYRequest.GetQueryString("code").Trim();

            long _newsId = XYECOM.Core.MyConvert.GetInt64(newsId);

            if (body.Equals("") || _newsId == 0)
            {
                strMsg = "评论失败";
                lastresult = Result.Failed;
            }

            //如果启用验证码
            if (XYECOM.Configuration.Security.Instance.IsEnabledValidateCode(XYECOM.Configuration.ValidateCodeItem.Comment))
            {
                if (!CheckCode(vcode))
                {
                    ResponseXML(Result.Failed, "验证码不正确!");
                }
            }

            XYECOM.Model.NewsDiscussInfo info = new XYECOM.Model.NewsDiscussInfo();

            info.IpAddress = XYECOM.Core.XYRequest.GetIP();
            info.IpIsShow = isHiddenIP.Equals("1") ? false : true;
            info.ND_Content = content.Server.HtmlEncode(body);
            info.NS_ID = _newsId;
            info.U_ID = 0;
            info.U_Name = "游客";

            if (Business.CheckUser.CheckUserLogin())
            {
                info.U_ID = Business.CheckUser.UserInfo.userid;
                info.U_Name = Business.CheckUser.UserInfo.LoginName;
            }

            info.ND_IsShow = true;

            int result = new XYECOM.Business.NewsDiscuss().Insert(info);

            if (result <= 0)
            {
                strMsg = "评论失败";
                lastresult = Result.Failed;
                ResponseXML(lastresult, strMsg);
            }
            else
            {
                XYECOM.Core.Utils.ClearSession("VNum");
                strMsg = "评论成功";
                lastresult = Result.Success;
                ResponseXML(lastresult, strMsg);
            }
        }
Beispiel #2
0
        private void GetNewsComment()
        {
            string strdata = "";

            Result result = Result.Null;

            XYECOM.Business.NewsDiscuss newsDiscussBLL = new XYECOM.Business.NewsDiscuss();

            string newsId = XYECOM.Core.XYRequest.GetQueryString("value");
            if (newsId.Equals(""))
            {
                ResponseXML(Result.Null, "数据不完整!");
            }

            string strColumuName = " ND_ID, U_Name,U_Flag, U_ID, ND_Content, ND_AddTime,IPIsShow,IPAddress ";

            int topNum = 4;
            int clikcNum = 0;

            clikcNum = XYECOM.Core.Function.Updateinfo(" where NS_ID=" + XYECOM.Core.XYRequest.GetQueryString("value"), "n_News", "NS_Count");
            DataTable tableDiscuss = newsDiscussBLL.GetDataTable(newsId, "", strColumuName, topNum);

            if (tableDiscuss.Rows.Count <= 0)
            {
                ResponseXML(Result.Failed, "没有评论信息!");
            }

            string userType = "";
            string userName = "";
            string shopUrl = "";

            for (int i = 0; i < tableDiscuss.Rows.Count; i++)
            {
                userName = tableDiscuss.Rows[i]["U_Name"].ToString();

                if (tableDiscuss.Rows[i]["U_ID"].ToString() == "0")
                {
                    userType = "guest";
                    shopUrl = "";
                }
                else
                {
                    if (tableDiscuss.Rows[i]["U_Flag"].ToString().ToLower().Equals("true"))
                    {
                        userType = "user";

                        if (webInfo.IsDomain)
                            shopUrl = "http://" + tableDiscuss.Rows[i]["U_Name"].ToString() + HttpContext.Current.Request.ServerVariables["HTTP_HOST"].Substring(HttpContext.Current.Request.ServerVariables["HTTP_HOST"].IndexOf(".")) + "/";
                        else
                            shopUrl = webInfo.WebDomain + "shop/" + tableDiscuss.Rows[i]["U_Name"].ToString() + "/index." + webInfo.WebSuffix;
                    }
                    else
                    {
                        userType = "person";
                        shopUrl = "";
                    }
                }

                strdata += "<comment>"
                                + "<user>"
                                + "  <name>" + userName + "</name>"
                                + "  <shopurl>" + shopUrl + "</shopurl>"
                                + "  <type>" + userType + "</type>"
                                + "</user>"
                                + "<sendtime>" + tableDiscuss.Rows[i]["ND_AddTime"].ToString() + "</sendtime>"
                                + "<content>" + content.Server.HtmlEncode(XYECOM.Business.FiltrateKeyWord.LeachKeyWord(tableDiscuss.Rows[i]["ND_Content"].ToString())) + "</content>"
                            + "</comment>";
            }
            result = Result.Success;
            ResponseXML(result, "", strdata);
        }