/// <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; }
public ActionResult InsertMemberContent(string permissions, string interestids, string lat, string lng, string type) { String userID = User.Identity.Name; userID = userID == "" ? null : userID; if (userID != "" && permissions != "" && interestids != "" && lat != "" && lng != "" && type != "") { //创建兴趣操作内容对象 BiZ.Content.MemberContent imageContent = new BiZ.Content.MemberContent(userID, getContentPerMissions(permissions), interestids.Split(',').ToList(), Double.Parse(lat), Double.Parse(lng), type); //保存兴趣操作内容对象 imageContent = imageContent.Save(imageContent); return Json(new JavaScriptSerializer().Serialize(true)); } else return Json(new JavaScriptSerializer().Serialize(false)); }
public ActionResult getLastMemberContent(String toObjectID, String type) { BiZ.Member.MemberToNewType types = (BiZ.Member.MemberToNewType)Enum.Parse(typeof(BiZ.Member.MemberToNewType), type); if (types == BiZ.Member.MemberToNewType.ImageContent) { BiZ.Content.MemberContent memberobj = new BiZ.Content.MemberContent(toObjectID); return Json(new JavaScriptSerializer().Serialize(memberobj)); } else { return Json(new JavaScriptSerializer().Serialize(null)); } }
/// <summary> /// 添加内容相关动态 /// </summary> /// <param name="contentobj">内容对象</param> /// <param name="comment">评论文本</param> /// <param name="userid">用户编号</param> /// <param name="type">对内容的操作类别</param> /// <returns>操作状态</returns> internal static CBB.ExceptionHelper.OperationResult addActivityToContent( BiZ.Content.PublicContent contentobj, BiZ.Comment.Comment comment, String userid, string type) { CBB.ExceptionHelper.OperationResult result = null; if (contentobj.MemberID != userid) { string answercontent = comment != null ? comment.Content : ""; BiZ.Content.ContentType contenttype = contentobj.ContentType; String activityTitle = "", activityContent = "", imagesStr = "", strContent = ""; BiZ.Member.Activity.ActivityType activityType = new BiZ.Member.Activity.ActivityType(); //获取内容图片地址,拼接成字符串。 imagesStr = GetMemberActivityContentImages(contentobj); switch (contenttype) { case BiZ.Content.ContentType.CallFor: //imagesStr = GetMemberActivityContentImages(contentobj); strContent = ((BiZ.Content.CallForContent)contentobj).Content; switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_CallForContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_CallForContentBeenLiked( "", "", contentobj.ID, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.CallForBeenLiked; break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_CallForContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_CallForContentBeenCommented( comment.ID, comment.Content, contentobj.ID, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.CallForBeenCommented; break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_CallForContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_CallForContentBeenLikeAndCommented( comment.ID, comment.Content, contentobj.ID, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.CallForBeenLikeAndCommented; break; default: break; } break; case BiZ.Content.ContentType.Image: //imagesStr = GetMemberActivityContentImages(contentobj); strContent = ((BiZ.Content.ImageContent)contentobj).Content; switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_ImageContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_ImageContentBeenLiked( "", "", imagesStr, contentobj.ID, strContent); activityType = BiZ.Member.Activity.ActivityType.ImageBeenLiked; break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_ImageContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_ImageContentBeenCommented( comment.ID, comment.Content, imagesStr, contentobj.ID, strContent); activityType = BiZ.Member.Activity.ActivityType.ImageBeenCommented; break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_ImageContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_ImageContentBeenLikeAndCommented( comment.ID, comment.Content, imagesStr, contentobj.ID, strContent); activityType = BiZ.Member.Activity.ActivityType.ImageBeenLikeAndCommented; break; default: break; } break; case BiZ.Content.ContentType.Interest: BiZ.Content.InterestContent interContent = new BiZ.Content.InterestContent(contentobj.ID); strContent = ((BiZ.Content.InterestContent)contentobj).Content; switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_InterestContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_InterestContentBeenLiked( "", "", contentobj.ID, interContent.Interest.ID, Common.Comm.getImagePath(interContent.Interest.ICONPath, Common.ImageType.Middle), interContent.Interest.Title, strContent); activityType = BiZ.Member.Activity.ActivityType.InterestBeenLiked; break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_InterestContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_InterestContentBeenCommented( comment.ID, comment.Content, contentobj.ID, interContent.Interest.ID, Common.Comm.getImagePath(interContent.Interest.ICONPath, Common.ImageType.Middle), interContent.Interest.Title, strContent); activityType = BiZ.Member.Activity.ActivityType.InterestBeenCommented; break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_InterestContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_InterestContentBeenLikeAndCommented( comment.ID, comment.Content, contentobj.ID, interContent.Interest.ID, Common.Comm.getImagePath(interContent.Interest.ICONPath, Common.ImageType.Middle), interContent.Interest.Title, strContent); activityType = BiZ.Member.Activity.ActivityType.InterestBeenLikeAndCommented; break; default: break; } break; case BiZ.Content.ContentType.InterView: switch (type) { case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_InterViewContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_InterViewContentBeenCommented( comment.ID, comment.Content, contentobj.ID); activityType = BiZ.Member.Activity.ActivityType.InterViewBeenCommented; break; case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_InterViewContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_InterViewContentBeenLiked("", "", contentobj.ID); activityType = BiZ.Member.Activity.ActivityType.InterViewBeenLiked; break; } break; case BiZ.Content.ContentType.IWant: BiZ.Content.IWantContent iWantContent = new BiZ.Content.IWantContent(contentobj.ID); //imagesStr = GetMemberActivityContentImages(contentobj); strContent = ((BiZ.Content.IWantContent)contentobj).Content; switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_IWantContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_IWantContentBeenLiked( "", "", contentobj.ID, iWantContent.Content, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.IWantBeenLiked; break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_IWantContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_IWantContentBeenCommented( comment.ID, comment.Content, contentobj.ID, iWantContent.Content, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.IWantBeenCommented; break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_IWantContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_IWantContentBeenLikeAndCommented( comment.ID, comment.Content, contentobj.ID, iWantContent.Content, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.IWantBeenLikeAndCommented; break; default: break; } break; case BiZ.Content.ContentType.Member: string statusMember = ((BiZ.Content.MemberContent)contentobj).Type; String strStatusMember = "", strStatusMemberContent = "", addition = ""; BiZ.Content.MemberContent memberContent = new BiZ.Content.MemberContent(contentobj.ID); switch (statusMember) { case "0": strStatusMemberContent = "新位置"; strStatusMember = "mo"; addition = memberContent.Lat + "&" + memberContent.Lng; break; case "1": strStatusMemberContent = "新头像"; strStatusMember = "mo"; addition = Common.Comm.getImagePath(memberContent.Creater.ICONPath, Common.ImageType.Middle); break; default: break; } switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_MemberContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_MemberContentBeenLiked( "", "", contentobj.ID, strStatusMemberContent, strStatusMember, addition); switch (statusMember) { case "0": activityType = BiZ.Member.Activity.ActivityType.MembeSetLocationBeenLiked; break; case "1": activityType = BiZ.Member.Activity.ActivityType.MembeSetAvatarBeenLiked; break; default: break; } break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_MemberContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_MemberContentBeenCommented( comment.ID, comment.Content, contentobj.ID, strStatusMemberContent, strStatusMember, addition); switch (statusMember) { case "0": activityType = BiZ.Member.Activity.ActivityType.MemberSetLocationBeenCommented; break; case "1": activityType = BiZ.Member.Activity.ActivityType.MemberSetAvatarBeenCommented; break; default: break; } break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_MemberContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_MemberContentBeenLikeAndCommented( comment.ID, comment.Content, contentobj.ID, strStatusMemberContent, strStatusMember, addition); switch (statusMember) { case "0": activityType = BiZ.Member.Activity.ActivityType.MemberSetLocationBeenLikeAndCommented; break; case "1": activityType = BiZ.Member.Activity.ActivityType.MemberSetAvatarBeenLikeAndCommented; break; default: break; } break; default: break; } break; case BiZ.Content.ContentType.Mood: BiZ.Content.MoodContent moodContent = new BiZ.Content.MoodContent(contentobj.ID); string statusMood = ((BiZ.Content.MoodContent)contentobj).Type; String strStatusMood = "", strMood = ""; switch (statusMood) { case "0": strMood = "好心情"; strStatusMood = "羡慕"; break; case "1": strMood = "坏心情"; strStatusMood = "安慰"; break; default: break; } switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_MoodContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_MoodContentBeenLiked( "", "", strMood, strStatusMood, contentobj.ID, moodContent.Content); activityType = BiZ.Member.Activity.ActivityType.MoodBeenLiked; switch (statusMood) { case "0": activityType = BiZ.Member.Activity.ActivityType.MoodBeenLiked; break; case "1": activityType = BiZ.Member.Activity.ActivityType.BadMoodBeenLiked; break; default: break; } break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_MoodContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_MoodContentBeenCommented( comment.ID, comment.Content, strMood, strStatusMood, contentobj.ID, moodContent.Content); switch (statusMood) { case "0": activityType = BiZ.Member.Activity.ActivityType.MoodBeenCommented; break; case "1": activityType = BiZ.Member.Activity.ActivityType.BadMoodBeenCommented; break; default: break; } break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_MoodContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_MoodContentBeenLikeAndCommented( comment.ID, comment.Content, strMood, strStatusMood, contentobj.ID, moodContent.Content); switch (statusMood) { case "0": activityType = BiZ.Member.Activity.ActivityType.MoodBeenLikeAndCommented; break; case "1": activityType = BiZ.Member.Activity.ActivityType.BadMoodBeenLikeAndCommented; break; default: break; } break; default: break; } break; case BiZ.Content.ContentType.SuiSuiNian: BiZ.Content.SuiSuiNianContent talkAbout = new BiZ.Content.SuiSuiNianContent(contentobj.ID); //imagesStr = GetMemberActivityContentImages(contentobj); strContent = ((BiZ.Content.SuiSuiNianContent)contentobj).Content; switch (type) { case "addLike": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_TalkAboutContentBeenLiked_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_TalkAboutContentBeenLiked( "", "", contentobj.ID, talkAbout.Content, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.TalkAboutBeenLiked; break; case "addComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_TalkAboutContentBeenCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_TalkAboutContentBeenCommented( comment.ID, comment.Content, contentobj.ID, talkAbout.Content, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.TalkAboutBeenCommented; break; case "addLikeToComment": activityTitle = BiZ.Member.Activity.ActivityController.GetActivityContent_TalkAboutContentBeenLikeAndCommented_Title(); activityContent = BiZ.Member.Activity.ActivityController.GetActivityContent_TalkAboutContentBeenLikeAndCommented( comment.ID, comment.Content, contentobj.ID, talkAbout.Content, imagesStr, strContent); activityType = BiZ.Member.Activity.ActivityType.TalkAboutBeenLikeAndCommented; break; default: break; } break; default: break; } result = BiZ.Member.Activity.ActivityController.AddActivityRelatedToMe( contentobj.MemberID, userid, activityType, activityTitle, activityContent, false); } return result; }