/// <summary> /// 填充页面列表 /// </summary> /// <param name="source">数据源</param> /// <param name="viewCount">显示总数,显示所有为null</param> /// <param name="rowCount">每行显示数量,默认null,显示6条</param> /// <returns></returns> public static String GetList(IList<CY.UME.Core.Business.Group> source, Int32 viewCount, Int32 rowCount) { if (viewCount == -1) viewCount = source.Count; if (rowCount == -1) rowCount = 6; String result = ""; if (viewCount > source.Count) viewCount = source.Count; StringBuilder bulder = new StringBuilder(); for (int i = 1; i <= viewCount; i++) { CY.UME.Core.Business.AccountGroup agroup = new CY.UME.Core.Business.AccountGroup(); CY.UME.Core.Business.Group group = source[i - 1]; if ((i - 1) % rowCount == 0) bulder = new StringBuilder();//new row if (group != null) bulder.Append("<li><a href='Group.aspx?groupId=" + group.Id + "' title='" + group.Name + "' >" + "<img src='" + SiteUrl() + "/Ajax/Group/GetGroupCover.ashx?gid=" + group.Id + "' style='width:60px; height:60px; margin:0 auto;'/></a>" + "<br/><a href='Group.aspx?groupId=" + group.Id + "' title='" + group.Name + "' >" + CY.Utility.Common.StringUtility.CutString(group.Name, 14, "...") + "</a>(" + agroup.GetGroupMemberCount(group) + ")</li>"); if (i % rowCount == 0) { result = result + "<div style='width:690px; margin:0 auto; height:100px'><ul class='pic'>" + bulder.ToString() + "</ul></div>"; } else { if (i == viewCount) result = result + "<div style='width:690px; margin:0 auto; height:100px'><ul class='pic'>" + bulder.ToString() + "</ul></div>"; } } return result; }
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); } }