Esempio n. 1
0
        protected void AddTopic_OnClick(object sender, EventArgs e)
        {
            if (TBXTopicName.Text.Trim().Length == 0)
            {
                ShowAlert("提示", "话题名不能为空");
                return;
            }
            else if (TBXTopicName.Text.Trim().Length > 100)
            {
                ShowAlert("提示", "话题名长度不能超过100");
                return;
            }
            if (type == "add")
            {
                int groupId = 0;
                if (ViewState["GroupId"] == null || !int.TryParse(ViewState["GroupId"].ToString(), out groupId))
                {
                    throw new Exception("参数错误");
                }

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

                if (group == null)
                {
                    throw new Exception("参数错误");
                }

                CY.UME.Core.Business.Topic topic = new CY.UME.Core.Business.Topic();

                topic.Id = System.Guid.NewGuid();
                topic.Title = TBXTopicName.Text.Trim();

                topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                topic.DateCreated = DateTime.Now;
                topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
                topic.Level = 0;
                topic.ReplyNum = 0;
                topic.AccountId = CurrentAccount.Id;
                topic.LastReplyDate = topic.DateCreated;
                topic.LastAuthorId = CurrentAccount.Id;

                topic.Save();

                CY.UME.Core.Business.TopicExtend te = new CY.UME.Core.Business.TopicExtend();

                te.AccountId = topic.AccountId;
                te.Id = topic.Id;
                te.InstanceId = group.Id.ToString();
                te.Type = "group";

                te.Save();

                //发送通知
                CurrentAccount.SendNoticeToAllFriendAndFollower("pubtopic","发表了新话题", topic.Id.ToString());

                #region 添加积分

                int addTopicCredit;
                if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditAddTopic", out addTopicCredit) &&
                    (addTopicCredit != 0))
                {
                    DateTime now = DateTime.Now;
                    DateTime startOfDay = new DateTime(now.Year, now.Month, now.Day);
                    int crediteGainCountTodayInSpecificalTopic = CY.UME.Core.Business.CreditHistory.GetCreditHistoryCount(
                        "addtopic", group.CreatorId, CurrentAccount.Id, topic.Id.ToString(), startOfDay, startOfDay.AddDays(1)); // TODO

                    if (crediteGainCountTodayInSpecificalTopic == 0)
                    {
                        CY.UME.Core.Business.Account creator = CY.UME.Core.Business.Account.Load(group.CreatorId);

                        if (creator != null)
                        {
                            int orgCredit = creator.Credit;
                            int modifiedCredit = orgCredit + addTopicCredit;
                            creator.Credit = modifiedCredit;
                            creator.Save();

                            CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();
                            ch.AccountId = creator.Id;
                            ch.DateCreated = DateTime.Now;
                            ch.Id = Guid.NewGuid();
                            ch.InstanceId = topic.Id.ToString();
                            ch.Original = orgCredit;
                            ch.Modified = modifiedCredit;
                            ch.Variation = addTopicCredit;
                            ch.Type = "addtopic";
                            ch.AssistAccountId = CurrentAccount.Id;
                            ch.Description = "用户 " + CurrentAccount.Name + "发表了话题 "+topic.Title;
                            ch.Save();
                        }
                    }
                }
                #endregion

                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '发起成功' });window.location.href='Topic.aspx?groupId=" + group.Id + "'</script>");
            }
            else if (type == "edit")
            {
                CY.UME.Core.Business.Topic topic = CY.UME.Core.Business.Topic.Load(topicId);

                topic.Title = TBXTopicName.Text.Trim();
                topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                topic.DateCreated = DateTime.Now;
                topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
                topic.AccountId = CurrentAccount.Id;
                topic.LastAuthorId = CurrentAccount.Id;
                topic.Save();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '编辑成功' });window.location.href='TopicDetailInfo.aspx?TopicId=" + topicId + "'</script>");
            }
        }
Esempio n. 2
0
        private void SendTopicPermission(CY.UME.Core.Business.Group group)
        {
            CY.UME.Core.Business.Topic topic = new CY.UME.Core.Business.Topic();

            topic.Id = System.Guid.NewGuid();
            topic.Title = TBXTopicName.Text.Trim();

            topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
            topic.DateCreated = DateTime.Now;
            topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
            topic.Level = 0;
            topic.ReplyNum = 0;
            topic.AccountId = CurrentAccount.Id;
            topic.LastReplyDate = topic.DateCreated;
            topic.LastAuthorId = CurrentAccount.Id;

            topic.Save();

            CY.UME.Core.Business.TopicExtend te = new CY.UME.Core.Business.TopicExtend();

            string pubType = "pubtopic";

            te.AccountId = topic.AccountId;
            te.Id = topic.Id;

            int.TryParse(Request.QueryString["activeID"], out activeId);
            if (activeId == 0)
            {//群组话题
                te.InstanceId = group.Id.ToString();
                te.Type = "group";
                pubType = "pubtopic";
            }
            else
            {//活动话题
                te.InstanceId = activeId.ToString();
                te.Type = "active";
                pubType = "activeTopic";
            }

            te.Save();

            //发送通知
            CurrentAccount.SendNoticeToAllFriendAndFollower(pubType, "发表了新话题", topic.Id.ToString());

            #region 添加积分

            int addTopicCredit;
            if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditAddTopic", out addTopicCredit) &&
                (addTopicCredit != 0) && (1 == 2))//2010.12.26 由于效率太低,暂时不用了
            {
                DateTime now = DateTime.Now;
                DateTime startOfDay = new DateTime(now.Year, now.Month, now.Day);
                int crediteGainCountTodayInSpecificalTopic = CY.UME.Core.Business.CreditHistory.GetCreditHistoryCount(
                    "addtopic", group.CreatorId, CurrentAccount.Id, topic.Id.ToString(), startOfDay, startOfDay.AddDays(1)); // TODO

                if (crediteGainCountTodayInSpecificalTopic == 0)
                {
                    CY.UME.Core.Business.Account creator = CY.UME.Core.Business.Account.Load(group.CreatorId);

                    if (creator != null)
                    {
                        int orgCredit = creator.Credit;
                        int modifiedCredit = orgCredit + addTopicCredit;
                        creator.Credit = modifiedCredit;
                        creator.Save();

                        CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();
                        ch.AccountId = creator.Id;
                        ch.DateCreated = DateTime.Now;
                        ch.Id = Guid.NewGuid();
                        ch.InstanceId = topic.Id.ToString();
                        ch.Original = orgCredit;
                        ch.Modified = modifiedCredit;
                        ch.Variation = addTopicCredit;
                        ch.Type = "addtopic";
                        ch.AssistAccountId = CurrentAccount.Id;
                        ch.Description = "用户 " + CurrentAccount.Name + "发表了话题 " + topic.Title;
                        ch.Save();
                    }
                }
            }
            #endregion

            if (pubType == "pubtopic")
            { //群组
                base.ShowAlert("提示", "发起话题成功<span>3</span>秒后将自动跳转。", true, "Topic.aspx?groupId=" + group.Id, true);
            }
            else
            {//活动
                base.ShowAlert("提示", "发起话题成功<span>3</span>秒后将自动跳转。", true, "Topic.aspx?activeid=" + activeId, true);
                //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('发起成功');window.location.href='Topic.aspx?groupId=" + group.Id + "'</script>");
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Guid topicId = new Guid();

                if (Request.QueryString["TopicId"] == null)
                {
                    throw new Exception("您所访问的页面不存在");
                }

                if (Request.QueryString["TopicId"].ToString().Trim().Length == 0)
                {
                    throw new Exception("您所访问的页面不存在");
                }
                else
                {
                    topicId = new Guid(Request.QueryString["TopicId"].ToString().Trim());
                }

                CY.UME.Core.Business.Account author = new CY.UME.Core.Business.Account();

                topic = CY.UME.Core.Business.Topic.Load(topicId);

                CY.UME.Core.Business.TopicExtend te = new CY.UME.Core.Business.TopicExtend();
                CY.UME.Core.Business.Group group = new CY.UME.Core.Business.Group();

                if (topic == null)
                {
                    topic = new CY.UME.Core.Business.Topic();
                    AuthorName = "无";
                    topic.AccountId = 0;
                    topic.Content = "<div style='font-size:18px;'>该话题所属群不存在或已被组长删除。</div>";

                    groupId = 3;//返回默认群,3为Ume创造者。
                }
                else
                {
                    author = CY.UME.Core.Business.Account.Load(topic.AccountId);
                    if (author != null) AuthorName = author.Name;

                    if (CurrentAccount != null)
                    {
                        tdi_HiddenCurrentAccountId.Value = CurrentAccount.Id.ToString();
                    }
                    else
                    {
                        tdi_HiddenCurrentAccountId.Value = "0";
                    }

                    topic.ViewNum += 1;
                    topic.Save();
                    te = CY.UME.Core.Business.TopicExtend.Load(topic.Id);
                    if (te != null) group = CY.UME.Core.Business.Group.Load(int.Parse(te.InstanceId));
                    //if (group == null)
                    //{
                    //    throw new Exception("该话题所属群不存在或已被删除");
                    //}

                    if (group != null) uc_NewestTopices.group = group;

                    bool ismember = group.CheckIsGroupMember(CurrentAccount);
                    bool ismanage = group.CheckIsManager(CurrentAccount);

                    if (group.AddTopicReplyPermission == 0)
                    {
                        topicreply = true;
                    }
                    else if (group.AddTopicReplyPermission == 1)
                    {
                        if (ismember)
                        {
                            topicreply = true;
                        }
                    }
                    groupId = group.Id;
                    AuthorId = te.AccountId;
                    GroupName = group.Name;
                    HF_GroupId.Value = groupId.ToString();

                    int pageSize = 20;
                    int pageNum = 1;

                    CY.UME.Core.PagingInfo pageInfo = new CY.UME.Core.PagingInfo();
                    pageInfo.CurrentPage = pageNum;
                    pageInfo.PageSize = pageSize;
                    topicReplyList = CY.UME.Core.Business.TopicReply.GetReplyByTopicIdAndPages(topicId, pageInfo);
                    int topicreplycount = CY.UME.Core.Business.TopicReply.GetReplyCountByTopicId(topic.Id);

                    uc_GroupInfo.group = group;
                    tdi_HiddenPageSize.Value = pageSize.ToString();
                    tdi_HiddenRecordsCount.Value = topicreplycount.ToString();
                    tdi_HiddenSiteUrl.Value = SiteUrl;
                    tdi_HiddenTopicId.Value = topic.Id.ToString();

                    int activeId = 0;
                    if (int.TryParse(Request.QueryString["activeId"], out activeId))
                    {//活动
                        CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(activeId);

                        if (active != null) GroupName = active.Name;
                        HF_ActiveId.Value = activeId.ToString();
                    }
                    SetTitle(GroupName + " - 话题");
                }
            }
        }
Esempio n. 4
0
        protected void AddTopic_OnClick(object sender, EventArgs e)
        {
            if (TBXTopicName.Text.Trim().Length == 0)
            {
                ShowAlert("提示", "话题名不能为空");
                return;
            }
            else if (TBXTopicName.Text.Trim().Length > 100)
            {
                ShowAlert("提示", "话题名长度不能超过100");
                return;
            }

            if (ViewState["topicId"] == null)
            {
                //新增
                CY.UME.Core.Business.Topic topic = new CY.UME.Core.Business.Topic();

                topic.Id = System.Guid.NewGuid();
                topic.Title = TBXTopicName.Text.Trim();

                topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                topic.DateCreated = DateTime.Now;
                topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
                topic.Level = 0;
                topic.ReplyNum = 0;
                topic.AccountId = CurrentAccount.Id;
                topic.LastReplyDate = DateTime.Now;
                topic.LastAuthorId = CurrentAccount.Id;

                topic.Save();

                CY.UME.Core.Business.TopicExtend te = new CY.UME.Core.Business.TopicExtend();

                te.AccountId = topic.AccountId;
                te.Id = topic.Id;
                te.InstanceId = ViewState["ActiveID"].ToString();
                te.Type = "active";

                te.Save();

                //发送通知
                CurrentAccount.SendNoticeToAllFriendAndFollower("activeTopic", "发表了新话题", topic.Id.ToString());
                string activeID = ViewState["ActiveID"].ToString();
                //window.location.href='Topic.aspx?activeId=" + activeID + "'
                //cy.ume.ui.window({ title: '提示', content: '发起成功' });
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '发起成功' });window.location.href='Topic.aspx?activeId=" + activeID + "'</script>");
            }
            else
            {
                //编辑
                Guid topicId = new Guid(ViewState["topicId"].ToString());
                CY.UME.Core.Business.Topic topicEdit = CY.UME.Core.Business.Topic.Load(topicId);
                if (topicEdit != null)
                {
                    topicEdit.Title = TBXTopicName.Text.Trim();
                    topicEdit.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                    topicEdit.Save();

                    //发送通知
                    //CurrentAccount.SendNoticeToAllFriend("activeTopic", "发表了新话题", topic.Id.ToString());
                    //cy.ume.ui.window({ title: '提示', content: '修改成功' });
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '修改成功' });window.location.href='TopDetail.aspx?TopicId=" + topicId + "'</script>");
                    //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '修改成功' });</script>");
                }
            }
        }