예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //没登录,或则登录失效
                // Request.QueryString["groupId"].ToString() == "undefined"
                if (Request.QueryString["groupId"] == null
                    && Request.QueryString["urlName"] == null)
                {
                    //throw new Exception("页面不存在");
                }

                int groupId = 0;
                string urlName = String.Empty;

                if (Request.QueryString["groupId"] == null || !int.TryParse(Request.QueryString["groupId"].ToString(), out groupId))
                {
                    urlName = Request.Params["urlName"].ToString();
                    if (urlName.Trim().Length > 0)
                    {
                        group = CY.UME.Core.Business.Group.Load(urlName);

                        groupId = group.Id;
                        string CurrentUrl = SiteUrl + "/Group/" + urlName;//用户登录后转到之前的页面

                        CY.UME.Core.Business.Account.SetCurrentUrl(CurrentUrl);
                    }
                }
                else
                {
                    group = CY.UME.Core.Business.Group.Load(groupId);
                }

                if (group == null)
                {
                    group = new CY.UME.Core.Business.Group();
                    group.Id = 3;
                    throw new Exception("该群组不存在或已被删除");
                }

                if (group.Slogan.Length == 0)
                {
                    //groupSlogn.Text = "为群组和平,为阿凡达的核心理论而结群。我们要团结一心 为争取成为Ume第一群组而努力。加油!加油!加油!";
                    //groupSlogn.Text = "这里显示的是群组精神 赶快让你们的群主把你们的群组精神Show出来!";
                }
                else
                {
                    groupSlogn.Value = group.Slogan;
                }

                string grouphead = String.Empty;
                if (group.HeadPicPath.Length == 0)
                {
                    grouphead = SiteUrl + "/Theme/default/imgs/group_2/topbanner.jpg";
                }
                else
                {
                    grouphead = SiteUrl + group.HeadPicPath;
                }
                //imgGroupHead.ImageUrl = grouphead;

                if (group.UrlName.Length != 0)
                {
                    TxtGroupUrl.Value = group.UrlName;
                }
                else if (CurrentAccount != null && group.CreatorId == CurrentAccount.Id)
                {
                    TxtGroupUrl.Value = "设置自定义域名";
                }

                ismember = group.CheckIsGroupMember(CurrentAccount);
                ismanage = group.CheckIsManager(CurrentAccount);
                HF_IsManager.Value = ismanage.ToString();
                HF_IsMember.Value = ismember.ToString();

                if (CurrentAccount != null && CurrentAccount.Id == group.CreatorId)
                {
                    g_HiddenIsCreator.Value = "1";
                }

                if (group.ViewPermission == 0 && !ismember)
                {
                    //base.ShowAlert("提示","你无权进入"+group.Name+"群!",false,"",false);
                    //Response.Write("<script language='javascript'>alert('你无权进入该群')</script>");
                    Response.Redirect(SiteUrl + "/Group/MyGroups.aspx");
                }

                if (ismember)
                {
                    CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();

                    ag.AddVisit(CurrentAccount, group);
                }

                if (group.MemberNum >= group.MaxMemberNum)
                {
                    hdCaninviteFriend.Value = "false";
                }
                else
                {
                    hdCaninviteFriend.Value = "true";
                }

                if (group.ViewPermission == 1)
                {
                    viewpermission = true;
                }
                else
                {
                    if (!ismember)
                        viewpermission = false;
                    else
                        viewpermission = true;
                }

                if (group.AddPermission == 1 || group.AddPermission == 0)
                {
                    addpermission = true;
                }
                else
                {
                    addpermission = false;
                }

                //群组信息
                LblCreatedDate.Text = group.DateCreated.ToString("yyyy-MM-dd");

                CY.UME.Core.Business.Account creator = CY.UME.Core.Business.Account.Load(group.CreatorId);

                if (creator != null)
                {
                    LblGroupCreator.Text = "<a href='" + SiteUrl + "/Home.aspx?uid=" + creator.Id + "' style='color: rgb(243, 126, 0);' target='_blank'>" + creator.Name + "</a>";
                }

                CY.UME.Core.Business.AccountGroup agroup = new CY.UME.Core.Business.AccountGroup();
                IList<CY.UME.Core.Business.AccountGroup> agList = agroup.GetAccountGroupByGroupIdAndRoleAndAccountId(group, -2, 1, null, new CY.UME.Core.PagingInfo { PageSize = int.MaxValue, CurrentPage = 1 });
                string strGroupManagers = String.Empty;

                foreach (CY.UME.Core.Business.AccountGroup agTemp in agList)
                {
                    strGroupManagers += "<a href='" + SiteUrl + "/Home.aspx?uid=" + agTemp.AccountId + "' style='color: rgb(243, 126, 0);' rel='Next' target='_blank'>" + agTemp.Name + "</a>" + " ";
                }

                LblGroupManager.Text = strGroupManagers;

                LblGroupMemberNum.Text = agroup.GetGroupMemberCount(group).ToString();
                LblGroupType.Text = group.TypeName;                     //群组类型
                LblGroupName.Text = CY.Utility.Common.StringUtility.CutString(group.Name, 18, "...");
                LblGroupName.ToolTip = group.Name;

                LblTopicCount.Text = group.GetGroupTopicesNum().ToString();

                //群组头像
                ImgGroupCover.Text = "<img src='" + SiteUrl + "/Ajax/Group/GetGroupCover.ashx?gid=" + group.Id.ToString() + "' alt='" + group.Name + "' title='" + group.Name + "' />";

                //群组话题
                topicList = CY.UME.Core.Business.Topic.GetTopicesByGroup(group.Id.ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = CY.Utility.Common.ConvertUtility.ConvertToInt(HF_DefaultTopicNum.Value, 22) });
                RPT_TopicList.DataSourceID = "";
                RPT_TopicList.DataSource = topicList;
                RPT_TopicList.DataBind();

                //友情小组
                groupList = group.GetRelativeGroup();
                BindFriendList(groupList);

                //群组成员
                groupMemberList = CY.UME.Core.Business.Account.GetAllAccountByGroupId(group.Id, new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = 12 });
                if (groupMemberList != null)
                {
                    BindGroupMemberList(groupMemberList, 6, 3);
                }

                //好友
                if (CurrentAccount != null)
                {
                    accountList = GetInvitingFriend(groupId);
                }
                string univerSityName = String.Empty;
                StringBuilder sb = new StringBuilder();

                sb.Append("{SiteUrl:'" + SiteUrl + "'");
                sb.Append(",GroupId:" + groupId);
                sb.Append(",Accounts:[");

                int i = 0;
                foreach (CY.UME.Core.Business.Account account in accountList)
                {
                    sb.Append("{Index:" + i);
                    sb.Append(",Name:'" + account.Name + "'");
                    sb.Append(",AccountId:" + account.Id);
                    if (account.UniversityInfo != null)
                    {
                        univerSityName = account.UniversityInfo.Name;
                    }
                    sb.Append(",UniversityName:'" + univerSityName + "'");
                    sb.Append("},");

                    i++;
                }

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

                sb.Append("]}");
                if_HiddenAccountJson.Value = sb.ToString();

                //群组相册
                int albumViewPer = 1;
                if (ismember)
                {
                    albumViewPer = 0;
                }
                albumList = group.GetGroupAlbum(albumViewPer, new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = 12 });

                if(albumList!=null)
                {
                    BindAlbumList(albumList, 6, 3);
                }

                //群组留言
                Comments = group.GetGroupLevelWords(new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = CY.Utility.Common.ConvertUtility.ConvertToInt(HF_DefaultCommentsNum.Value, 22) });
                GroupLeaveWords.Comments = Comments;
                GroupLeaveWords.group = group;
                GroupLeaveWords.CurrentAccount = CurrentAccount;

                if (group.LeaveWordsPermission == 1)
                {
                    if (!ismember)
                    {
                        leavwordshow = false;
                    }
                }

                g_HiddenSiteUrl.Value = SiteUrl;
                g_HiddenGroupId.Value = group.Id.ToString();
                g_HiddenIsCreator.Value = CurrentAccount == null ? "0" : (CurrentAccount.Id == group.CreatorId) ? "1" : "0";

                SetTitle(group.Name);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (CurrentAccount == null)
            //{
            //    Response.Redirect("~/Login2.aspx");
            //    return;
            //}

            if (!IsPostBack)
            {
                if (Request.QueryString["groupId"] == null)
                {
                    throw new Exception("页面不存在");
                }

                int groupId = 0;
                if (!int.TryParse(Request.QueryString["groupId"].ToString(), out groupId))
                {
                    throw new Exception("页面不存在");
                }

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

                if (group == null)
                {
                    throw new Exception("该班级或群组不存在或已被删除");
                }

                bool ismember = CurrentAccount == null ? false : group.CheckIsGroupMember(CurrentAccount);
                bool ismanage = CurrentAccount == null ? false : group.CheckIsManager(CurrentAccount);
                if (ismember)
                {
                    CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();

                    ag.AddVisit(CurrentAccount, group);
                }

                if (group.MemberNum >= group.MaxMemberNum)
                {
                    hdCaninviteFriend.Value= "false";
                }
                else
                {
                    hdCaninviteFriend.Value = "true";
                }

                placard.group = group;//公告
                newestTopices1.Group = group;//新话题
                newestTopices1.PageSize = 10;
                hotTopices1.group = group;//最热话题
                groupStatistics1.group = group;//群组概况
                groupMembers1.group = group;//群组成员
                groupLeaveWords1.group = group;//群组留言
                if (ismanage)
                {
                    groupNavigation1.IsShowActiveBtn = true;//发起新活动
                }
                if (!ismanage)
                {
                    membersWaitForHandled1.Visible = false;
                }
                if (CurrentAccount != null)
                {
                    hotPictures1.group = group;//热门图片
                }
                membersWaitForHandled1.group = group;//待处理成员列表

                if (CurrentAccount != null)
                {
                    groupMenu1.IsManager = ismanage;
                    groupMenu1.IsGroupMember = ismember;
                    groupMenu1.IsClass = (group.Type == 0);
                }

                groupNavigation1.groupId = group.Id;
                if (group.Type == 0)
                {
                    groupNavigation1.IsShowAddGroupBtn = false;
                    groupNavigation1.IsShowApp = false;
                    groupMenu1.IsShowAddTopicBtn = false;//GroupMenu.ascx页面的 发贴连接
                }
                switch (group.AddPicturePermission)
                {
                    case 0: groupNavigation1.IsShowAddImgBtn = true; break;
                    case 1: if (ismember)
                        {
                            groupNavigation1.IsShowAddImgBtn = true;
                        } break;
                    case 2: if (ismanage)
                        {
                            groupNavigation1.IsShowAddImgBtn = true;
                        } break;
                }
                switch (group.AddTopicPermission)
                {
                    case 0: groupNavigation1.IsShowAddTopicBtn = true; break;
                    case 1: if (ismember)
                        {
                            groupNavigation1.IsShowAddTopicBtn = true;
                        } break;
                    case 2: if (ismanage)
                        {
                            groupNavigation1.IsShowAddTopicBtn = true;
                        } break;
                }

                if (CurrentAccount != null)
                {
                    groupLeaveWords1.CurrentAccount = CurrentAccount;//群组留言
                    groupLeaveWords1.IsGroupHome = true;
                }
                if (group.ViewPermission == 1)
                {
                    viewpermission = true;
                }
                else
                {
                    if (!ismember)
                    {
                        viewpermission = false; hotPictures1.group = null; this.groupNavigation1.IsShowNav = false;
                    }
                    else
                    {
                        viewpermission = true;
                    }
                }
                if (group.AddPermission == 1 || group.AddPermission ==0)
                {
                    addpermission = true;
                }
                else
                {
                    addpermission = false; if (!ismember) { this.groupMenu1.Visible = false; }
                }
                g_HiddenSiteUrl.Value = SiteUrl;
                g_HiddenGroupId.Value = group.Id.ToString();
                g_HiddenIsCreator.Value = CurrentAccount == null ? "0" : (CurrentAccount.Id == group.CreatorId) ? "1" : "0";

                SetTitle(group.Name);
            }
        }