예제 #1
0
 public ActionResult InsertTopic(String interestid, String pattern)
 {
     SetMetasVersion();
     String userid = HttpContext.User.Identity.Name;
     String fileName = string.Empty;
     String imgstr = string.Empty;
     HttpFileCollectionBase files = Request.Files;
     if (files != null && files.Count > 0)
     {
         for (int i = 0; i < files.Count; i++)
         {
             fileName = string.Empty;
             HttpPostedFileBase fileobj = files[i];
             if (fileobj.FileName != "")
             {
                 fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + CBB.Security.MD5Helper.getMd5Hash(fileobj.FileName) + ".jpg";
                 Moooyo.BiZ.Photo.Photo topicimgobj = new UpController().SavePhoto(userid, (int)BiZ.Photo.PhotoType.TopicImage, fileobj.InputStream, fileName);
                 imgstr += topicimgobj.FileName + ",";
             }
         }
     }
     String title = pattern.Length > 10 ? pattern.Substring(0, 10) + "..." : pattern;
     BiZ.WenWen.WenWen obj = BiZ.Member.Activity.ActivityController.AddQuestToMyInterest(userid, interestid, title, pattern, imgstr);
     return RedirectToAction("InterestFans", "InterestCenter", new { iid = interestid });
 }
예제 #2
0
        /// <summary>
        /// 剪裁图片
        /// </summary>
        /// <param name="memberID">用户编号</param>
        /// <param name="x">剪裁区域X坐标</param>
        /// <param name="y">剪裁区域Y坐标</param>
        /// <param name="w">剪裁区域宽</param>
        /// <param name="h">剪裁区域高</param>
        /// <param name="uploadPhoto">图片名称</param>
        /// <param name="phototype">图片类型</param>
        /// <param name="skintype">用户皮肤类型</param>
        /// <param name="photoRelativePath">图片虚拟路径</param>
        /// <returns>操作状态</returns>
        private String CustomPicture(
            String memberID, String x, String y, String w, String h, String uploadPhoto,
            String phototype, String skintype, String photoRelativePath
            //, String contentId
            )
        {
            CBB.ExceptionHelper.OperationResult result = null;
            Moooyo.BiZ.Photo.Photo myp = new BiZ.Photo.Photo();
            ViewData["photoRelativePath"] = photoRelativePath != null ? photoRelativePath : "";
            ViewData["phototype"] = phototype;
            ViewData["skinType"] = skintype;

            if (x != null && y != null && w != null && h != null && uploadPhoto != null && phototype != null)
            {
                int photType = Convert.ToInt32(phototype);

                int xCoord = int.Parse(x);
                int yCoord = int.Parse(y);
                int width = int.Parse(w);
                int height = int.Parse(h);
                //裁图并保存图片
                String photoPath = CropImage(uploadPhoto, width, height, xCoord, yCoord, memberID);
                if (photoPath == "error")
                {
                    //return new CBB.ExceptionHelper.OperationResult(false, "图片有误");
                    return "";
                }

                //uploadPhoto = uploadPhoto.Replace("original", "modifiedsize");
                String strPhotoPath = System.Web.Hosting.HostingEnvironment.MapPath(photoPath);
                //用文件流的方式打开该张图片
                System.IO.FileStream tfs = System.IO.File.Open(strPhotoPath, System.IO.FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                String strRelativePath = "/temp_up_file/";
                int strRelativePathLength = strRelativePath.Length;
                UpController upControl = new UpController();

                //保存图片数据到数据库
                myp = upControl.SavePhoto(memberID, Convert.ToInt32(phototype), tfs, photoPath.Substring(strRelativePathLength, photoPath.Length - strRelativePathLength));
                //图片类型是用户头像类型
                if (photType == 1)
                {
                    BiZ.Member.ModifyPicturePath.ModifyPicturePathHandler modiPicPathHand =
                        new BiZ.Member.ModifyPicturePath.ModifyPicturePathHandler();
                    modiPicPathHand.MemberId = memberID;
                    modiPicPathHand.PictureId = myp.ID;
                    modiPicPathHand.PicturePath = myp.FileName;
                    modiPicPathHand.ModifyPicPathEvent +=
                        new BiZ.Member.ModifyPicturePath.ModifyPicturePathHandler.ModifyPicPathEventHandler(
                            new BiZ.Member.ModifyPicturePath.ModifyPicturePathProvider().ModifyMemberAvatarPicPath
                            ); //注册方法
                    modiPicPathHand.ModifyPicPath(); //自动调用注册过对象的方法

                    //同步发布说说
                    IList<BiZ.InterestCenter.Interest> interestList = BiZ.InterestCenter.InterestFactory.GetMemberInterest(memberID, 0, 0);
                    String interestIds = "";
                    if (interestList != null)
                    {
                        foreach (BiZ.InterestCenter.Interest interest in interestList)
                        {
                            interestIds += interest.ID + ",";
                        }
                    }
                    String userID = memberID, permissions = "0", interestids = interestIds, lat = "0", lng = "0", type = "修改个人头像";
                    BiZ.Content.MemberContent imageContent = null;
                    if (userID != "" && permissions != "" && interestids != "" && lat != "" && lng != "" && type != "")
                    {
                        //创建兴趣操作内容对象
                        imageContent = new BiZ.Content.MemberContent(userID, ContentController.getContentPerMissions(permissions), interestids.Split(',').ToList(), Double.Parse(lat), Double.Parse(lng), type);
                        //保存兴趣操作内容对象
                        imageContent = imageContent.Save(imageContent);
                        //判断是否是新用户
                        Boolean ifnewmember = BiZ.MemberManager.MemberManager.getMemberToNew(userID) != null ? false : true;
                        if (ifnewmember)
                        {
                            BiZ.Member.MemberToNew newmember = new BiZ.Member.MemberToNew(userID, imageContent.ID, BiZ.Member.MemberToNewType.ImageContent);
                            newmember.Save(newmember);
                        }
                    }

                    BiZ.Member.Member member = BiZ.MemberManager.MemberManager.GetMember(memberID);

                    //增加动态
                    BiZ.Member.Activity.ActivityController.AddActivity(
                        memberID,
                        BiZ.Member.Activity.ActivityType.SetICON,
                        BiZ.Member.Activity.ActivityController.GetActivityContent_SetICON_Title(),
                        BiZ.Member.Activity.ActivityController.GetActivityContent_SetICON(member),
                        true);

                    //增加用户动态到后台
                    string operateUrl = "";
                    if (member.UniqueNumber != null)
                        operateUrl = "/u/" + member.UniqueNumber.ConvertedID;
                    else
                        operateUrl = "/Content/TaContent/" + member.ID;
                    BiZ.Sys.MemberActivity.MemberActivityProvider.CreateMemberActivity(
                        member.ID,
                        "",
                        BiZ.Sys.MemberActivity.MemberActivityType.UploadAvatar,
                        operateUrl);

                    string filename = UploadPictureToTemporary(memberID, member.MemberInfomation.IconPath);
                    Session["shareWeiBoImage"] = filename;

                    ////上传头像分享到外部平台
                    //string bindedPlatforms = Models.DisplayObjProvider.MemberBindingPlatform(member.ID);
                    //MicroConnController mcc = new MicroConnController();
                    //mcc.PlatformShareInfo(
                    //    member.ID,
                    //    bindedPlatforms,
                    //    member.MemberInfomation.NickName,
                    //    Server.MapPath(strPhotoPath.Replace("modifiedsize", "original")),
                    //    "/Content/ContentDetail/" + imageContent.ID
                    //    );

                }
                ////图片类型内容图片
                //if (photType >= 201 && photType <= 203 && contentId != null)
                //{
                //    List<BiZ.Content.Image> listImage = new List<BiZ.Content.Image>();
                //    BiZ.Content.Image image = new BiZ.Content.Image(myp.FileName);
                //    listImage.Add(image);
                //    BiZ.TopImagePush.ImagePush imagePush = new BiZ.TopImagePush.ImagePush(contentId, memberID, listImage,
                //}

                //构造源图片成FileInfo对象
                System.IO.FileInfo fileOriginalPhoto = new System.IO.FileInfo(strPhotoPath.Replace("modifiedsize", "original"));
                tfs.Dispose();
                tfs.Close();
                System.GC.Collect(); //强制对所有代码进行即时垃圾回收*(不回收就会被iis进程占用文件)
                //如果文件已存在,则删除
                if (fileOriginalPhoto.Exists) fileOriginalPhoto.Delete(); //删除单个文件(original)

                //{
                //    System.IO.File.Delete(strPhotoPath.Replace("modifiedsize", "original"));
                //}
                System.IO.File.Delete(strPhotoPath); //删除临时文件夹的剪裁后的图片(modifiedsize)

                //设置个性图片
                if (photType == 11 || photType == 12)
                {
                    if (skintype != null && skintype != "")
                    {
                        //设置个性图片
                        AddMemberSkinPicture(memberID, skintype, myp);
                    }
                }
            }

            return myp.ID + "|" + myp.FileName;
        }
예제 #3
0
 public ActionResult SaveInterestClassIcon(FormCollection postFormColl)
 {
     string memberID = HttpContext.User.Identity.Name;
     int holderNo = 30;
     if (Request.Files == null || Request.Files.Count == 0)
     {
         //上传文件为空,返回
         return Json(new int[] { -1 });
     }
     UpController uc = new UpController();
     HttpPostedFileBase httpFile = Request.Files[0];
     Moooyo.BiZ.Photo.Photo myp = uc.SavePhoto(memberID, holderNo, httpFile.InputStream, httpFile.FileName);
     return Content(myp.FileName);
 }
예제 #4
0
        public ActionResult AddMemberSkin(FormCollection postFormColl, string kidneyPicture, string kidneyBgPicture)
        {
            if((kidneyPicture == null || kidneyPicture == "") && (kidneyBgPicture == null || kidneyBgPicture == ""))
                return RedirectToAction("Error", "Error", new { errorno = "0" });

            String userId = HttpContext.User.Identity.Name;

            int ppHolderNo = 11, pbpHolderNo = 12;
            if (Request.Files == null || Request.Files.Count == 0)
            {
                //上传文件为空,返回
                return Json(new int[] { -1 });
            }
            UpController uc = new UpController();
            HttpPostedFileBase ppHttpFile = null;
            HttpPostedFileBase pbpHttpFile = null;
            BiZ.Photo.Photo ppPhoto = null;
            BiZ.Photo.Photo pbpPhoto = null;

            if ((kidneyPicture != null || kidneyPicture != "") && (kidneyBgPicture == null || kidneyBgPicture == ""))
            {
                ppHttpFile = Request.Files["personalityPicture"];
                ppPhoto = uc.SavePhoto(userId, ppHolderNo, ppHttpFile.InputStream, ppHttpFile.FileName);
            }
            else if ((kidneyPicture == null || kidneyPicture == "") && (kidneyBgPicture != null || kidneyBgPicture != ""))
            {
                pbpHttpFile = Request.Files["personalityBackgroundPicture"];
                pbpPhoto = uc.SavePhoto(userId, pbpHolderNo, pbpHttpFile.InputStream, pbpHttpFile.FileName);
            }
            else if ((kidneyPicture != null || kidneyPicture != "") && (kidneyBgPicture != null || kidneyBgPicture != ""))
            {
                ppHttpFile = Request.Files["personalityPicture"];
                pbpHttpFile = Request.Files["personalityBackgroundPicture"];

                ppPhoto = uc.SavePhoto(userId, ppHolderNo, ppHttpFile.InputStream, ppHttpFile.FileName);
                pbpPhoto = uc.SavePhoto(userId, pbpHolderNo, pbpHttpFile.InputStream, pbpHttpFile.FileName);
            }

            string personalityPicture = ppPhoto != null ? ppPhoto.FileName : "";
            string personalityBackgroundPicture = pbpPhoto != null ? pbpPhoto.FileName : "";

            JavaScriptSerializer jsSerial = new JavaScriptSerializer();
            CBB.ExceptionHelper.OperationResult result = null;

            ////按用户编号获取用户皮肤
            //BiZ.Member.MemberSkin.MemberSkin ms = BiZ.Member.MemberSkin.MemberSkinProvider.GetEmptyMemberSkin(null, userId);
            //if (ms != null)
            //{
            //    if ((ms.PersonalityPicture == null || ms.PersonalityPicture == "") && (ms.PersonalityBackgroundPicture != null || ms.PersonalityBackgroundPicture != "") && (personalityPicture != null && personalityPicture != "") && (personalityBackgroundPicture == null && personalityBackgroundPicture == ""))
            //    {
            //        //更新用户皮肤
            //        result = BiZ.Member.MemberSkin.MemberSkinProvider.UpdateMemberSkin(
            //            ms.ID,
            //            userId,
            //            personalityPicture,
            //            personalityBackgroundPicture);
            //    }
            //    else if ((ms.PersonalityPicture != null || ms.PersonalityPicture != "") && (ms.PersonalityBackgroundPicture == null || ms.PersonalityBackgroundPicture == "") && (personalityPicture == null && personalityPicture == "") && (personalityBackgroundPicture != null && personalityBackgroundPicture != ""))
            //    {
            //        //更新用户皮肤
            //        result = BiZ.Member.MemberSkin.MemberSkinProvider.UpdateMemberSkin(
            //            ms.ID,
            //            userId,
            //            personalityPicture,
            //            personalityBackgroundPicture);
            //    }
            //    else
            //    {
            //        //添加用户皮肤
            //        result = BiZ.Member.MemberSkin.MemberSkinProvider.AddMemberSkin(
            //            userId,
            //            BiZ.Comm.UserType.Administrator,
            //            personalityPicture,
            //            personalityBackgroundPicture
            //            );
            //    }
            //}
            //else
            //{

            //添加用户皮肤
            BiZ.Member.MemberSkin.MemberSkin ms = BiZ.Member.MemberSkin.MemberSkinProvider.AddMemberSkin(
                userId,
                BiZ.Comm.UserType.Administrator,
                personalityPicture,
                personalityBackgroundPicture
                );
            if (ms != null)
                result = new CBB.ExceptionHelper.OperationResult(true);
            else
                result = new CBB.ExceptionHelper.OperationResult(false);

            //}

            ////按用户编号获取用户皮肤
            //BiZ.Member.MemberSkin.MemberSkin ms = BiZ.Member.MemberSkin.MemberSkinProvider.GetEmptyMemberSkin2(userId, personalityPicture, personalityBackgroundPicture);
            //if (ms != null)
            //{

            //}

            if (result.ok)
                return Content("{\"ok\":\"true\"}");
            else
                return Content("{\"ok\":\"false\"}");
        }
예제 #5
0
        public ActionResult UpdateWenWen(String wwid, String wwcontenthidden, String wwcontentimghidden)
        {
            String userid = HttpContext.User.Identity.Name;
            String title = wwcontenthidden.Length > 10 ? wwcontenthidden.Substring(0, 10) + "..." : wwcontenthidden;
            String fileName = string.Empty;
            String upimgstr = string.Empty;
            HttpFileCollectionBase files = Request.Files;
            if (files != null && files.Count > 0)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    fileName = string.Empty;
                    HttpPostedFileBase fileobj = files[i];
                    if (fileobj.FileName != "")
                    {
                        fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + CBB.Security.MD5Helper.getMd5Hash(fileobj.FileName) + ".jpg";
                        Moooyo.BiZ.Photo.Photo topicimgobj = new UpController().SavePhoto(userid, (int)BiZ.Photo.PhotoType.TopicImage, fileobj.InputStream, fileName);
                        upimgstr += topicimgobj.FileName + ",";
                    }
                }
            }
            upimgstr = upimgstr + wwcontentimghidden;

            CBB.ExceptionHelper.OperationResult obj = BiZ.WenWen.WenWenProvider.UpdateWenWen(wwid, title, wwcontenthidden, upimgstr);
            Models.PageModels.InterestWenWenModel model = new Models.PageModels.InterestWenWenModel();
            model.wenwen = BiZ.WenWen.WenWenProvider.GetWenWen(wwid);
            return RedirectToAction("ShowWenWen", "WenWen", new { wwid = wwid });
        }