Example #1
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>");
            }
        }
Example #2
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>");
            }
        }
Example #3
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>");
                }
            }
        }