Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetTitle("群组照片 ");

            #region 判断验证
            long pictureId = 0;
            int groupId = 0;

            if (Request.QueryString["pictureId"] == null)
            {
                throw new Exception("参数不存在");
            }
            else if (!long.TryParse(Request.QueryString["pictureId"].ToString(), out pictureId))
            {
                throw new Exception("参数不合法");
            }

            picture = CY.UME.Core.Business.Picture.Load(pictureId);

            if (picture == null)
            {
                throw new Exception("图片不存在或已被删除");
            }

            album = CY.UME.Core.Business.Album.Load(picture.AlbumId);

            albumExtend = CY.UME.Core.Business.AlbumExtend.Load(album.Id);

            SpaceAccount = CY.UME.Core.Business.Account.Load(albumExtend.AccountId);

            if (SpaceAccount == null)
            {
                throw new Exception("访问页面不存在");
            }

            if (Request.QueryString["groupId"] == null)
            {
                throw new Exception("参数不存在");
            }

            if (!int.TryParse(Request.QueryString["groupId"].ToString(), out groupId))
            {
                throw new Exception("参数不合法");
            }

            group = CY.UME.Core.Business.Group.Load(groupId);
            al_HiddenGroupId.Value = groupId.ToString();
            if (CurrentAccount == null || CurrentAccount.Id != SpaceAccount.Id)
            {
                if (album.ViewPermission == 1)//仅好友才能访问
                {
                    if (CurrentAccount == null || !SpaceAccount.HasFriendshipWith(CurrentAccount))//判断是否是好友
                    {
                        Response.Write("您无权访问该页面");
                        return;
                    }
                }
                else if (album.ViewPermission == 2)//密码访问
                {
                    if (Session["AlbumPassword"] == null)
                    {
                        Response.Redirect("ViewEnAlbum.aspx?uid=" + SpaceAccount.Id + "&albumId=" + album.Id);
                        return;
                    }
                    else
                    {
                        string password = Session["AlbumPassword"].ToString();
                        if (password != album.ViewPassword)//判断密码是否正确
                        {
                            Response.Redirect("ViewEnAlbum.aspx?uid=" + SpaceAccount.Id + "&albumId=" + album.Id);
                            return;
                        }
                    }
                }
                else if (album.ViewPermission == 3)
                {
                    Response.Write("您无权访问该页面");
                    return;
                }
            }

            #endregion

            if (!IsPostBack)
            {
                if (CurrentAccount != null)
                {
                    HF_CurrentAccount_Id.Value = CurrentAccount.Id.ToString();
                }

                LblTitleName.Text = group.Name;
                picInfoMana.Visible = true;

                LblAlbumName.Text = album.Name;

                if (album.IsAvatar)
                {//头像相册
                    uploadPic.Visible = false;
                    UploadAvatar.Visible = true;
                }
                else
                {//普通相册
                    uploadPic.Visible = true;
                    UploadAvatar.Visible = false;
                }

                LBLAlbumNameAndLink.Text = "<a href=\"PictureList.aspx?albumId=" + album.Id + "&spaceId=" + CurrentAccount.Id + "\">" + LblAlbumName.Text + "</a>";

                //UserInfo1.SpaceAccount = SpaceAccount;//个人信息
                FollowerListId.CurrentFollower = SpaceAccount;

                CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo();
                pagingInfo.CurrentPage = 1;
                pagingInfo.PageSize = int.MaxValue;

                IList<CY.UME.Core.Business.Picture> picList = CY.UME.Core.Business.Picture.GetAllPicture(album, pagingInfo);

                StringBuilder sb = new StringBuilder();

                sb.Append("{");
                sb.Append("TotalRecords:'" + album.PhotoCount.ToString() + "'");
                sb.Append(",AccountId:'" + SpaceAccount.Id.ToString() + "'");
                sb.Append(",CurrentId:'" + (CurrentAccount == null ? "0" : CurrentAccount.Id.ToString()) + "'");
                sb.Append(",AlbumId:'" + album.Id.ToString() + "'");
                sb.Append(",PictureId:'" + pictureId.ToString() + "'");
                sb.Append(",SiteUrl:'" + SiteUrl + "'");
                sb.Append(",Pictures:[");

                int Num = 1;
                bool IsCheck = false;

                foreach (CY.UME.Core.Business.Picture pic in picList)
                {
                    if (pic.Id == picture.Id)
                    {
                        IsCheck = true;
                    }
                    if (!IsCheck)
                    {
                        Num++;
                    }

                    sb.Append("{");
                    sb.Append("Id:'" + pic.Id + "'");
                    sb.Append(",Remark:'" + pic.Remark + "'");
                    sb.Append(",DateCreated:'" + pic.DateCreated.ToString("yyyy年MM月dd") + "'");
                    sb.Append(",Name:'" + pic.Name + "'");
                    sb.Append(",AlbumViewPermission:'" + album.ViewPermission + "'");
                    sb.Append("},");
                }

                sb.Remove(sb.Length - 1, 1);
                sb.Append("],CurrentNum:'" + Num.ToString() + "'");
                sb.Append("}");

                HiddenJson.Value = sb.ToString();
                HF_SiteUrl.Value = SiteUrl;
                HF_Album_Id.Value = album.Id.ToString();
                HF_TotalRecords.Value = CY.UME.Core.Business.Picture.GetAllPicture(album, pagingInfo).Count.ToString();//该相册照片数量
                //HiddenAccountDiff.Value = accountDiff;

                //绑定评论
                pictureCommentList = CY.UME.Core.Business.PictureComment.GetPicCommentByPagesAndPicId(picture);

                RPT_PicCommentList.DataSourceID = "";
                RPT_PicCommentList.DataSource = pictureCommentList;
                RPT_PicCommentList.DataBind();
            }
        }
Ejemplo n.º 2
0
        private CY.UME.Core.Business.Album GetActivityAlbum(string type, string instanceId, string albumName)
        {
            IList<CY.UME.Core.Business.AlbumExtend> aeList = CY.UME.Core.Business.AlbumExtend.GetAlbumExtend(CurrentAccount.Id, type, instanceId);
            long aId = 0;
            CY.UME.Core.Business.Album album = new CY.UME.Core.Business.Album();

            if (aeList.Count != 0)
            {
                aId = aeList[0].Id;
            }

            //创建活动相册
            if (aId == 0)
            {
                album.AccountId = CurrentAccount.Id;
                album.DateCreated = DateTime.Now;
                album.IsAvatar = false;
                album.LastModifiedTime = DateTime.Now;
                album.Name = albumName;
                album.ViewPermission = 0;

                album.Save();

                CY.UME.Core.Business.AlbumExtend ae = new CY.UME.Core.Business.AlbumExtend();
                ae.Type = type;
                ae.InstanceId = instanceId;
                ae.AccountId = album.AccountId;
                ae.Id = album.Id;

                ae.Save();
                aId = album.Id;
            }
            else
            {
                album = CY.UME.Core.Business.Album.Load(aId);
            }

            return album;
        }
Ejemplo n.º 3
0
        private void CompressImg(string appPath, string fileName, string imgExtention, int activeId, long albumID)
        {
            string bImgName = appPath + fileName + "_big" + imgExtention;
            string mImgName = appPath + fileName + "_middle" + imgExtention;
            string sImgName = appPath + fileName + "_small" + imgExtention;

            #region 压缩图片
            Bitmap bmp = new Bitmap(appPath + fileName + imgExtention);
            int width = bmp.Width;
            int height = bmp.Height;

            bmp.Dispose();

            width = 200;
            height = 200;

            // 将原始图压缩为大缩略图
            using (StreamReader reader = new StreamReader(appPath + fileName + imgExtention))
            {
                CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, bImgName, width, height);
            }

            // 生成中图片(好友上传图片最新通知中显示)200*200
            using (StreamReader reader = new StreamReader(appPath + fileName + imgExtention))
            {
                CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, mImgName, width, height);
            }

            if (height <= width && width >= 100)
            {
                height = Convert.ToInt32(width > 100 ? (100f / width) * height : height);
                width = 100;
            }
            else if (width < height && height > 100)
            {
                width = Convert.ToInt32(height > 100 ? (100f / height) * width : height);
                height = 100;
            }

            // 将大图片压缩为小缩略图
            using (StreamReader reader = new StreamReader(appPath + fileName + imgExtention))
            {
                CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, sImgName, width, height);
            }

            try
            {
                File.Delete(appPath + fileName + imgExtention);
            }
            catch
            {
                ;
            }
            #endregion

            //更换活动海报
            CY.UME.Core.Business.Activities ac = CY.UME.Core.Business.Activities.Load(activeId);
            if (ac != null)
            {
                fileName = fileName.Replace("\\", "/");
                ac.Pic = fileName + "_small" + imgExtention;
                ac.Save();
            }

            //更换相册封面
            CY.UME.Core.Business.Album album = CY.UME.Core.Business.Album.Load(albumID);
            if (album.PhotoCount == 0 || album.CoverPath.Trim().Length == 0)
            {
                album.CoverPath = fileName.Replace("\\", "/") + "_small" + imgExtention;
                album.Save();
            }

            CY.UME.Core.Business.AlbumExtend albumExtend = new CY.UME.Core.Business.AlbumExtend();
            albumExtend.Id = albumID;//相册ID
            albumExtend.InstanceId = activeId.ToString();//活动ID
            albumExtend.AccountId = CurrentAccount.Id;//用户ID
            albumExtend.Type = "active";
            albumExtend.Save();

            ////将路径及图片信息保存到数据库
            //CY.UME.Core.Business.Picture pic = new CY.UME.Core.Business.Picture();

            //pic.AlbumId = albumID;//相册ID
            //fileName = fileName.Replace("\\", "/");
            //pic.BigPath = fileName + "_big" + imgExtention;
            //pic.DateCreated = DateTime.Now;
            //pic.MiddlePath = fileName + "_middle" + imgExtention;
            //pic.Name = CY.Utility.Common.StringUtility.HTMLEncode(ac.Name.Substring(0, ac.Name.Length > 30 ? 30 : ac.Name.Length));
            //pic.SmallPath = fileName + "_small" + imgExtention;

            //pic.Save();
        }