示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["tid"] != null)
                {
                    Guid TopicId = new Guid(Request.QueryString["tid"]);

                    // 获取话题
                    CY.UME.Core.Business.Topic topic = CY.UME.Core.Business.Topic.Load(TopicId);

                    lblTitle.Text = topic.Title;
                    lblAccountName.Text = CY.UME.Core.Business.Account.GetAccountNameById(topic.AccountId.ToString());
                    lblContent.Text = topic.Content;
                    lblDateCreated.Text = topic.DateCreated.ToString();

                    // 绑定回复
                    CY.UME.Core.Business.TopicReply topicReply = new CY.UME.Core.Business.TopicReply();

                    IList<Core.Business.TopicReply> topicReplyList = topicReply.GetReplyByTopicId(TopicId);

                    if (topicReplyList.Count >= 1)
                    {
                        Repeater1.DataSourceID = "";
                        Repeater1.DataSource = topicReplyList;
                        Repeater1.DataBind();
                    }
                    else
                    {
                        lblTopicReply.Text = "暂无评论。";
                    }
                }
            }
        }
示例#2
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     string result = string.Empty;
     if (context.Request.Params["Topicid"] == null)
     {
         result = "{success:false,msg:'请选择要删除的话题'}";
         return;
     }
     else
     {
         string temp = context.Request.Params["Topicid"].ToString();
         string[] topicID = temp.Split(',');
         if (topicID != null && topicID.Count() > 0)
         {
             for (int i = 0; i < topicID.Count(); i++)
             {
                 CY.UME.Core.Business.Topic topic = CY.UME.Core.Business.Topic.Load(new Guid(topicID[i]));
                 if (topic != null)
                 {
                     CY.UME.Core.Business.TopicReply topReply = new CY.UME.Core.Business.TopicReply();
                     topReply.DelTopicReplyByInstanceId(new Guid(topicID[i]));
                     topic.DeleteOnSave();
                     topic.Save();
                     CY.UME.Core.Business.TopicExtend topE = CY.UME.Core.Business.TopicExtend.Load(new Guid(topicID[i]));
                     if (topE != null)
                     {
                         topE.DeleteOnSave();
                         topE.Save();
                     }
                     else
                     {
                         result = "{success:false,msg:'此话题不存在或已经被删除'}";
                         return;
                     }
                 }
             }
             result = "{success:true}";
         }
     }
     context.Response.Write(result);
 }
示例#3
0
        protected void BindData(CY.UME.Core.Business.Activities active)
        {
            CY.UME.Core.PagingInfo pageInfo = new CY.UME.Core.PagingInfo();

            pageInfo.CurrentPage = 1;
            pageInfo.PageSize = 20;

            if (active != null)
            {
                CY.UME.Core.Business.TopicReply tr = new CY.UME.Core.Business.TopicReply();

                topicReplyList = tr.GetTopicReplyByActiveId(active,pageInfo);
            }

            int count = active.GetActiveTopicReplyCount();

            trm_HiddenPageSize.Value = "20";
            trm_HiddenRecordCount.Value = count.ToString();
            trm_HiddenSiteUrl.Value = SiteUrl;
            trm_HiddenActiveId.Value = active.Id.ToString();
        }
        protected void BindData(CY.UME.Core.Business.Group group)
        {
            CY.UME.Core.PagingInfo pageInfo = new CY.UME.Core.PagingInfo();

            pageInfo.CurrentPage = 1;
            pageInfo.PageSize = 20;

            if (group != null)
            {
                CY.UME.Core.Business.TopicReply tr = new CY.UME.Core.Business.TopicReply();

                topicReplyList = tr.GetTopicReplyByGroupId(group, pageInfo);
            }

            int count = group.GetGroupTopicReplyCount();

            DDLGroup.SelectedValue = group.Id.ToString();

            trm_HiddenPageSize.Value = "20";
            trm_HiddenRecordCount.Value = count.ToString();
            trm_HiddenSiteUrl.Value = SiteUrl;
            trm_HiddenGroupId.Value = group.Id.ToString();
        }
示例#5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "applicaiton/json";
            Guid topicId = Guid.Empty;
            long referedId = 0;
            string content = String.Empty;
            CY.UME.Core.Business.Topic topic;
            CY.UME.Core.Business.Account currentAccount;

            if (context.Request.Form["topicId"] == null
                || context.Request.Form["content"] == null)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            content = context.Request.Form["content"].ToString();

            if (context.Request.Form["topicId"].ToString().Length == 0)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            topicId = new Guid(context.Request.Form["topicId"].ToString().Trim());

            currentAccount = CY.UME.Core.Global.GetCurrentAccount();

            if (currentAccount == null)
            {
                context.Response.Write("{success:false,msg:'用户登录超时失败,请重新登录'}");
                return;
            }

            if (context.Request.Form["referedId"] != null)
            {
                long.TryParse(context.Request.Form["referedId"].ToString(), out referedId);
            }
            if (referedId != 0)
            {
                CY.UME.Core.Business.TopicReply tReply = CY.UME.Core.Business.TopicReply.Load(referedId);

                if (tReply == null)
                {
                    context.Response.Write("{success:false,msg:'您所回复的话题评论不存在或已被删除'}");
                    return;
                }
            }
            topic = CY.UME.Core.Business.Topic.Load(topicId);

            if (topic == null)
            {
                context.Response.Write("{success:false,msg:'您所回复的话题评论不存在或已被删除'}");
                return;
            }

            CY.UME.Core.Business.TopicExtend teTemp = CY.UME.Core.Business.TopicExtend.Load(topic.Id);
            int groupId = 0;
            if (context.Request.Form["TypeInfo"] == null)
            {
                if (!int.TryParse(teTemp.InstanceId, out groupId))
                {
                    context.Response.Write("{success:false,msg:'您无权回复此话题'}");
                    return;
                }

                CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId);

                if (group == null)
                {
                    context.Response.Write("{success:false,msg:'您无权回复此话题'}");
                    return;
                }

                if (group.AddTopicReplyPermission == 1 && !group.CheckIsGroupMember(currentAccount))
                {
                    context.Response.Write("{success:false,msg:'您无权回复此话题'}");
                    return;
                }
            }

            try
            {
                //修改最后更新
                topic.LastAuthorId = currentAccount.Id;
                topic.LastReplyDate = DateTime.Now;//最后回复时间
                topic.Save();

                CY.UME.Core.Business.TopicReply topicReply = new CY.UME.Core.Business.TopicReply();

                topicReply.AccountId = topic.AccountId;
                topicReply.AuthorId = currentAccount.Id;
                topicReply.Content = content;
                topicReply.DateCreated = DateTime.Now;
                topicReply.InstanceId = topic.Id;
                topicReply.IP = CY.Utility.Common.RequestUtility.ClientIP;
                if (referedId != 0)
                {
                    topicReply.ReferedId = referedId;
                }
                topicReply.Save();

                context.Response.Write("{success:true,Id:" + topicReply.Id + ",AccountName:'" + currentAccount.Name + "',AccountId:" + currentAccount.Id + ",PubDate:'" + topicReply.DateCreated.ToString("yy-MM-dd HH:mm") + "',r:'" + (topic.ReplyNum + 1) + "'}");

                CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice();

                notice.AuthorId = currentAccount.Id;
                notice.DateCreated = DateTime.Now;
                notice.InstanceId = topic.Id.ToString();
                notice.IsReaded = false;
                string typeName = string.Empty;
                if (context.Request.Form["TypeInfo"] != null)
                {
                    typeName = "activeTopicReply";
                }
                else
                {
                    typeName = "topicreply";
                }
                notice.Type = typeName;
                if (referedId != 0)//回复话题评论
                {
                    CY.UME.Core.Business.TopicReply te = CY.UME.Core.Business.TopicReply.Load(topicReply.ReferedId);

                    if (te == null)
                    {
                        return;
                    }
                    notice.AccountId = te.AuthorId;
                    notice.Content = "回复了您的回帖";
                }
                else
                {
                    notice.AccountId = topic.AccountId;
                    notice.Content = "回复了您的话题";
                }
                if (notice.AccountId != notice.AuthorId)
                {
                    notice.Save();
                }
            }
            catch
            {
                context.Response.Write("{success:false,msg:'系统忙,请稍后再试'}");
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int groupId = 0;
            int activeId = 0;
            int pageSize = 0;
            int pageNum = 0;
            string content = String.Empty;
            string title = String.Empty;
            string authorName = String.Empty;
            DateTime minDate = CY.UME.Core.Global.MinDateTime;
            DateTime maxDate = DateTime.MaxValue;
            string TYPE = string.Empty;
            #region validate

            if (context.Request.Params["type"] != null && context.Request.Params["type"] == "active")
            {
                if (context.Request.QueryString["activeId"] == null
                                    || context.Request.QueryString["pageSize"] == null
                                    || context.Request.QueryString["pageNum"] == null
                                    || context.Request.QueryString["content"] == null
                                    || context.Request.QueryString["title"] == null
                                    || context.Request.QueryString["authorName"] == null
                                    || context.Request.QueryString["minDate"] == null
                                    || context.Request.QueryString["maxDate"] == null)
                {
                    context.Response.Write("{success:false,msg:'参数错误'}");
                    return;
                }

                if (!int.TryParse(context.Request.QueryString["activeId"].ToString(), out activeId)
                    || !int.TryParse(context.Request.QueryString["pageSize"].ToString(), out pageSize)
                    || !int.TryParse(context.Request.QueryString["pageNum"].ToString(), out pageNum))
                {
                    context.Response.Write("{success:false,msg:'参数错误'}");
                    return;
                }

                if ((context.Request.QueryString["minDate"].ToString().Length > 0 && !DateTime.TryParse(context.Request.QueryString["minDate"].ToString(), out minDate))
                    || (context.Request.QueryString["minDate"].ToString().Length > 0 && !DateTime.TryParse(context.Request.QueryString["maxDate"], out maxDate)))
                {
                    context.Response.Write("{success:false,msg:'参数错误'}");
                    return;
                }
                TYPE = "active";

                content = context.Request.QueryString["content"].ToString().Trim();
                title = context.Request.QueryString["title"].ToString().Trim();
                authorName = context.Request.QueryString["authorName"].ToString().Trim();

                if (DateTime.Compare(minDate, maxDate) > 0)
                {
                    DateTime dateTimeTemp = minDate;
                    minDate = maxDate;
                    maxDate = dateTimeTemp;
                }
            }
            else
            {
                if (context.Request.QueryString["groupId"] == null
                    || context.Request.QueryString["pageSize"] == null
                    || context.Request.QueryString["pageNum"] == null
                    || context.Request.QueryString["content"] == null
                    || context.Request.QueryString["title"] == null
                    || context.Request.QueryString["authorName"] == null
                    || context.Request.QueryString["minDate"] == null
                    || context.Request.QueryString["maxDate"] == null)
                {
                    context.Response.Write("{success:false,msg:'参数错误'}");
                    return;
                }

                if (!int.TryParse(context.Request.QueryString["groupId"].ToString(), out groupId)
                    || !int.TryParse(context.Request.QueryString["pageSize"].ToString(), out pageSize)
                    || !int.TryParse(context.Request.QueryString["pageNum"].ToString(), out pageNum))
                {
                    context.Response.Write("{success:false,msg:'参数错误'}");
                    return;
                }

                if ((context.Request.QueryString["minDate"].ToString().Length > 0 && !DateTime.TryParse(context.Request.QueryString["minDate"].ToString(), out minDate))
                    || (context.Request.QueryString["minDate"].ToString().Length > 0 && !DateTime.TryParse(context.Request.QueryString["maxDate"], out maxDate)))
                {
                    context.Response.Write("{success:false,msg:'参数错误'}");
                    return;
                }

                content = context.Request.QueryString["content"].ToString().Trim();
                title = context.Request.QueryString["title"].ToString().Trim();
                authorName = context.Request.QueryString["authorName"].ToString().Trim();

                if (DateTime.Compare(minDate, maxDate) > 0)
                {
                    DateTime dateTimeTemp = minDate;
                    minDate = maxDate;
                    maxDate = dateTimeTemp;
                }
            }
            #endregion

            try
            {
                CY.UME.Core.PagingInfo pageInfo = new CY.UME.Core.PagingInfo();
                pageInfo.CurrentPage = pageNum;
                pageInfo.PageSize = pageSize;
                CY.UME.Core.Business.TopicReply tr = new CY.UME.Core.Business.TopicReply();
                List<CY.UME.Core.Business.TopicReply> trList = new List<CY.UME.Core.Business.TopicReply>();
                if (TYPE == "active")
                {
                    CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(activeId);
                    trList = tr.SearchTopicReply(active, content, title, authorName, minDate, maxDate, pageInfo);
                }
                else
                {
                    CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId);
                    trList = tr.SearchTopicReply(group, content, title, authorName, minDate, maxDate, pageInfo);
                }

                StringBuilder sb = new StringBuilder();

                sb.Append("{success:true,TopicReplys:[");

                string aName =String.Empty;
                foreach (CY.UME.Core.Business.TopicReply topicReply in trList)
                {
                    CY.UME.Core.Business.Topic topic =CY.UME.Core.Business.Topic.Load(topicReply.InstanceId);

                    if(topic==null)
                    {
                        CY.UME.Core.Business.TopicReply trTemp = CY.UME.Core.Business.TopicReply.Load(topicReply.Id);
                        trTemp.DeleteOnSave();
                        trTemp.Save();
                        continue;
                    }
                    else
                    {
                        CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(topic.AccountId);

                        if(account==null)
                        {
                            aName = "该用户已被删除";
                        }
                        else
                        {
                            aName = account.Name;
                        }
                    }

                    sb.Append("{");
                    sb.Append("Id:" + topicReply.Id);
                    sb.Append(",TopicId:'" + topic.Id+"'");
                    sb.Append(",Title:'" + CY.Utility.Common.StringUtility.EscapeString(topic.Title)+"'");
                    sb.Append(",Content:'" + CY.Utility.Common.StringUtility.EscapeString(topicReply.Content) + "'");
                    sb.Append(",AuthorId:" + topicReply.AuthorId);
                    sb.Append(",Name:'" + aName + "'");
                    sb.Append(",Date:'" + topicReply.DateCreated.ToString("yyyy-MM-dd HH:mm") + "'");
                    sb.Append("},");
                }

                if (trList.Count > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                }

                sb.Append("]}");

                context.Response.Write(sb.ToString());

            }
            catch
            {
                context.Response.Write("{success:false,msg:'系统忙,请稍后再试'}");
                return;
            }
        }