/// <summary> /// 分享新视频 /// </summary> /// <param name="model">新视频模型</param> public void NewVideo(NewVideoModel model) { ShareThread st = null; VideoShareProvider.ParseHtml(model.RawUrl, ref st); string identify = DateTime.Now.Ticks.ToString(); //如果评论为空则用视频默认标题 string subject = string.IsNullOrEmpty(model.Comment) ? st.Subject : model.Comment; string finalSubject = "<a href='##' onclick=\"playVideo('" + identify + "')\" >" + subject + "</a>"; //视频内容html string content = "<div class='video' id='prev_" + identify + "' style='background-image: url(" + st.ThumbnailUrl + ");'><a onclick=\"playVideo('" + identify + "')\" href='###'>播放</a></div>"; content += "<div class='blogPicOri' id='disp_" + identify + "' style='visibility: visible; display: none; '><p><cite><a onclick=\"stopVideo('" + identify + "')\" title='收起' href='###'>收起</a></cite><cite class='MIB_line_l'>|</cite><cite class='MIB_line_l'>|</cite></p>"; //播放器脚本 content += "<embed id='JSONP_167HAG6ED_9' height='356' allowscriptaccess='always' style='visibility: visible;' pluginspage='http://get.adobe.com/cn/flashplayer/' flashvars='playMovie=true&auto=1&adss=0' width='380' allowfullscreen='true' quality='hight' src='" + st.PlayUrl + "' type='application/x-shockwave-flash' wmode='transparent'></div>"; NewFeedModel fmodel = new NewFeedModel() { Sharer = model.Sharer, Type = FeedType.NewVideo, Subject = finalSubject, Content = content }; BlogService bservice = new BlogService(); ShareThreadService shareservice = new ShareThreadService(); NewShareThreadModel sharemodel = new NewShareThreadModel() { Body = st.Body, PlayUrl = st.PlayUrl, RawUrl = model.RawUrl, ShareTime = DateTime.Now, Source = "博客", Subject = st.Subject, ThumbnailUrl = st.ThumbnailUrl }; shareservice.CreateShareThread(sharemodel); bservice.CreateFeed(fmodel); }
public HttpResponseMessage ListComment(decimal REPLYING_TO_MESSAGE_FEED_ID, int page, int pageSize) { var model = new NewFeedModel(); var list = model.getListActivityFeedComment(REPLYING_TO_MESSAGE_FEED_ID, page, pageSize); return(ResponseSuccess(StringResource.Success, list)); }
public HttpResponseMessage ListNewFeedOfUser(string userNameLogin, int conferenceId, decimal conference_session_id, int page, int pageSize) { var listResult = (db.CONFERENCE_ATTENDEE_IN_REGISTERED_CONFERENCE_SESSION .Join(db.ACCOUNTs, attendee => attendee.PERSON_ID, acc => acc.PERSON_ID, (attendee, acc) => new { attendee, acc })) .Where(x => x.attendee.CONFERENCE_SESSION_ID == conference_session_id) .AsEnumerable() .ToList() .Select(x => new UserOfSession() { UserName = x.acc.UserName, Image = x.acc.Image, CURRENT_FIRST_NAME = x.acc.CURRENT_FIRST_NAME, CURRENT_MIDDLE_NAME = x.acc.CURRENT_MIDDLE_NAME, CURRENT_LAST_NAME = x.acc.CURRENT_LAST_NAME }); var activityFeeds = new List <ActivityFeed>(); var model = new NewFeedModel(); foreach (UserOfSession item in listResult) { var list = model.getListActivityFeedOfUser(item.UserName, conferenceId, page, pageSize); foreach (ActivityFeed feed in list) { var commemts = model.getListActivityFeedComment(feed.MESSAGE_FEED_ID); feed.ListComment = commemts; var likes = model.listLike(feed.MESSAGE_FEED_ID); feed.ListLike = likes; feed.IS_LIKED = model.checkIsLiked(userNameLogin, feed.MESSAGE_FEED_ID); activityFeeds.AddRange(list); } } return(ResponseSuccess(StringResource.Success, activityFeeds)); }
public HttpResponseMessage DeleteAllMessage(string UserName, string RECIPIENT_UserName_1, int conferenceId) { try { var list = db.MESSAGE_FEED.Where(x => (x.UserName == UserName && x.RECIPIENT_UserName_1 == RECIPIENT_UserName_1) || (x.UserName == RECIPIENT_UserName_1 && x.RECIPIENT_UserName_1 == UserName) && (x.DELETED_UserName != UserName) && x.CONFERENCE_ID == conferenceId && (x.DELETED == false || x.DELETED == null)); var model = new NewFeedModel(); foreach (MESSAGE_FEED item in list) { if (item.DELETED_UserName == null || item.DELETED_UserName == UserName) { var itemUpdate = db.MESSAGE_FEED.SingleOrDefault(x => x.MESSAGE_FEED_ID == item.MESSAGE_FEED_ID); item.DELETED_UserName = UserName; item.DELETED_DATETIME = DateTime.Now; var result = model.updateMessageFeed(item); } else { var itemUpdate = db.MESSAGE_FEED.SingleOrDefault(x => x.MESSAGE_FEED_ID == item.MESSAGE_FEED_ID); item.DELETED_UserName = UserName; item.DELETED_DATETIME = DateTime.Now; item.DELETED = true; var result = model.updateMessageFeed(item); } } return(ResponseSuccess(StringResource.Success)); } catch (Exception) { return(ResponseFail(StringResource.Delete_list_message_fail)); } }
public NewFeedModel getNewFeedModel(string id) { List <PostModel> postModelList = getPostModelsForNewFeed(id); List <UserAvatarModel> UnfollowUsers = relationshipService.getSuggestUnFollowUser(id); NewFeedModel newFeedModel = new NewFeedModel() { PostModelList = postModelList, UnfollowUsers = UnfollowUsers }; return(newFeedModel); }
/// <summary> /// 关注某人 /// </summary> /// <param name="uid">用户编号</param> /// <param name="follow">关注对象编号</param> public void FollowSomeBody(AddFolloweeModel model) { IRepository <UserFollow> followRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>(); IRepository <UserProperty> userProRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>(); IRepository <ShortMessage> smRep = Factory.Factory <IRepository <ShortMessage> > .GetConcrete <ShortMessage>(); UserProperty userProperty = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == model.UserID)); UserProperty followProperty = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == model.FolloweeID)); //新建用户关注实例 UserFollow newUserFollow = new UserFollow(model.UserID, model.UserName, model.UserHead, model.FolloweeID, model.FolloweeName, model.FolloweeHead); //加入仓储 followRep.Add(newUserFollow); //持久化 followRep.PersistAll(); //增加关注数 userProperty.AddFolloweesCount(); //增加粉丝数 followProperty.AddFollowersCount(); userProRep.Update(userProperty); userProRep.Update(followProperty); userProRep.PersistAll(); //发送消息 string subject = model.UserName + "关注了你"; string content = "<a href='" + Utils.UrlFactory.CreateUrl(FBS.Utils.UrlFactory.PageName.UserHome, model.UserID.ToString()) + "' target='_blank'>" + model.UserName + "</a>关注了你 <span>" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "</span>"; ShortMessage newMsg = new ShortMessage(model.UserID, model.UserName, model.UserHead, model.FolloweeID, model.FolloweeName, model.FolloweeHead, subject, content); //UserEntryService k = new UserEntryService(); UserStateModel me = this.GetUserInfo(model.UserID); UserStateModel follow = this.GetUserInfo(model.FolloweeID); NewFeedModel feedModel = new NewFeedModel() { Content = "", Sharer = me, SourceUser = follow, Subject = "", Type = FeedType.Support }; BlogService my = new BlogService(); my.CreateFeed(feedModel); smRep.Add(newMsg); smRep.PersistAll(); }
public ActionResult Index() { LoginedUser loginedUser = getUserInSession(); UserAvatarModel userAvatarModel = new UserAvatarModel() { Id = loginedUser.Id, Avatar = loginedUser.Avatar, Username = loginedUser.UserName }; NewFeedModel model = newFeedService.getNewFeedModel(loginedUser.Id); model.UserAvatar = userAvatarModel; return(View(model)); }
public HttpResponseMessage ListNewFeed(string userName, decimal conferenceId, int page, int pageSize) { var model = new NewFeedModel(); var activityFeeds = model.getListActivityFeed(conferenceId, page, pageSize); foreach (ActivityFeed item in activityFeeds) { var list = model.getListActivityFeedComment(item.MESSAGE_FEED_ID); item.ListComment = list; var listLike = model.listLike(item.MESSAGE_FEED_ID); item.ListLike = listLike; item.IS_LIKED = model.checkIsLiked(userName, item.MESSAGE_FEED_ID); } return(ResponseSuccess(StringResource.Success, activityFeeds)); }
/// <summary> /// 分享视频 /// </summary> /// <param name="model">分享模型</param> public void ShareVideo(SiteShareModel model) { IRepository <Feed> feedRep = Factory.Factory <IRepository <Feed> > .GetConcrete <Feed>(); Feed feed = feedRep.GetByKey(model.FeedID); BlogService bservice = new BlogService(); string subject = feed.Subject.Substring(feed.Subject.LastIndexOf("<a")); NewFeedModel fmodel = new NewFeedModel() { Sharer = model.Sharer, SourceUser = model.SourceUser, Type = FeedType.ShareVideo, Content = feed.Content, Subject = subject }; bservice.CreateFeed(fmodel); }
/// <summary> /// 分享新闻 /// </summary> /// <param name="model"></param> public void ShareOneNews(SiteShareModel model) { IRepository <Feed> feedRep = Factory.Factory <IRepository <Feed> > .GetConcrete <Feed>(); Feed feed = feedRep.GetByKey(model.FeedID); string subject = feed.Subject; subject = subject.Substring(subject.LastIndexOf("<a")); NewFeedModel newFeed = new NewFeedModel() { SourceUser = model.SourceUser, Sharer = model.Sharer, Subject = subject, Content = feed.Content, Type = FeedType.ShareStory }; new BlogService().CreateFeed(newFeed); }
public HttpResponseMessage ListPhotoFeed(string userName, decimal conferenceId, int page, int pageSize) { var model = new NewFeedModel(); var photoFeeds = model.getListPhotoFeed(conferenceId, page, pageSize); var result = new List <PhotoResponse>(); foreach (PhotoFeed item in photoFeeds) { var itemFeed = new PhotoResponse(); itemFeed.Date = item.Date; itemFeed.ListFeed = new List <ActivityFeed>(); foreach (MESSAGE_FEED feed in item.ListFeed) { var account = new AccountModel().GetUserByUserName(feed.UserName); var f = new ActivityFeed(); f.MESSAGE_FEED_ID = feed.MESSAGE_FEED_ID; f.UserName = feed.UserName; f.PERSON_ID = account.PERSON_ID; f.CURRENT_LAST_NAME = feed.CURRENT_LAST_NAME; f.CURRENT_MIDDLE_NAME = feed.CURRENT_MIDDLE_NAME; f.CURRENT_FIRST_NAME = feed.CURRENT_FIRST_NAME; f.REPLYING_TO_MESSAGE_FEED_ID = feed.REPLYING_TO_MESSAGE_FEED_ID; f.MESSAGE_CONTENT = feed.MESSAGE_CONTENT; f.ATTACHED_PHOTO_FILENAME = feed.ATTACHED_PHOTO_FILENAME; f.ATTACHED_PHOTO_NOTE = feed.ATTACHED_PHOTO_NOTE; f.ATTACHED_PHOTO_LONGITUDE = feed.ATTACHED_PHOTO_LONGITUDE; f.ATTACHED_PHOTO_LATITUDE = feed.ATTACHED_PHOTO_LATITUDE; f.Image = account.Image; f.Time = DateTimeFormater.GetTimeAgo(feed.FROM_DATE.Value); f.FROM_DATE = feed.FROM_DATE; f.THRU_DATE = feed.THRU_DATE; f.ListComment = model.getListActivityFeedComment(feed.MESSAGE_FEED_ID); f.IS_LIKED = model.checkIsLiked(userName, feed.MESSAGE_FEED_ID); f.ListLike = model.listLike(feed.MESSAGE_FEED_ID); itemFeed.ListFeed.Add(f); } result.Add(itemFeed); } return(ResponseSuccess(StringResource.Success, result)); }
public HttpResponseMessage ListConversation(string UserName, int conferenceId) { var acccount = db.ACCOUNTs.SingleOrDefault(x => x.UserName == UserName); if (acccount == null) { return(ResponseFail(StringResource.Account_does_not_exist)); } else { var list = from f in db.MESSAGE_FEED where (f.UserName == UserName || f.RECIPIENT_UserName_1 == UserName) && f.PUBLIC_OR_PRIVATE_MESSAGE == "PRIVATE" && f.CONFERENCE_ID == conferenceId && f.DELETED_UserName != UserName && (f.DELETED == null || f.DELETED == false) group f by new { f.UserName, f.RECIPIENT_UserName_1 } into x select new Conversation() { UserName = x.Key.UserName, RECIPIENT_UserName_1 = x.Key.RECIPIENT_UserName_1 }; var listConversation = new List <Conversation>(); foreach (Conversation item in list) { if (!listConversation.Any(x => (x.UserName == item.UserName && x.RECIPIENT_UserName_1 == item.RECIPIENT_UserName_1) || (x.UserName == item.RECIPIENT_UserName_1 && x.RECIPIENT_UserName_1 == item.UserName))) { var ac = new AccountModel().GetUserByUserName(item.UserName != UserName ? item.UserName : item.RECIPIENT_UserName_1); if (ac != null) { item.Name = Utils.GetFullName(ac.CURRENT_FIRST_NAME, ac.CURRENT_MIDDLE_NAME, ac.CURRENT_LAST_NAME); item.Image = ac.Image; var lastMessage = new NewFeedModel().getLastMessage(UserName, (item.UserName != UserName ? item.UserName : item.RECIPIENT_UserName_1), conferenceId); if (lastMessage != null) { item.Message = lastMessage.MESSAGE_CONTENT; } listConversation.Add(item); } } } return(ResponseSuccess(StringResource.Success, listConversation)); } }
public HttpResponseMessage NewFeedDetail(int MESSAGE_FEED_ID, string userName) { var account = new AccountModel().GetUserByUserName(userName); if (account == null) { return(ResponseFail(StringResource.Account_does_not_exist)); } else { var model = new NewFeedModel(); var result = db.MESSAGE_FEED.Find(MESSAGE_FEED_ID); if (result != null) { var activityFeed = new ActivityFeed(); activityFeed.MESSAGE_FEED_ID = result.MESSAGE_FEED_ID; activityFeed.UserName = result.UserName; activityFeed.MESSAGE_CONTENT = result.MESSAGE_CONTENT; activityFeed.CURRENT_LAST_NAME = result.CURRENT_LAST_NAME; activityFeed.CURRENT_FIRST_NAME = result.CURRENT_FIRST_NAME; activityFeed.REPLYING_TO_MESSAGE_FEED_ID = result.REPLYING_TO_MESSAGE_FEED_ID; activityFeed.ATTACHED_PHOTO_FILENAME = result.ATTACHED_PHOTO_FILENAME; activityFeed.ATTACHED_PHOTO_NOTE = result.ATTACHED_PHOTO_NOTE; activityFeed.ATTACHED_PHOTO_LONGITUDE = result.ATTACHED_PHOTO_LONGITUDE; activityFeed.ATTACHED_PHOTO_LATITUDE = result.ATTACHED_PHOTO_LATITUDE; activityFeed.Time = DateTimeFormater.GetTimeAgo(result.FROM_DATE.Value); activityFeed.Image = account.Image; activityFeed.FROM_DATE = result.FROM_DATE; activityFeed.THRU_DATE = result.THRU_DATE; activityFeed.ListComment = model.getListActivityFeedComment(MESSAGE_FEED_ID); activityFeed.ListLike = model.listLike(MESSAGE_FEED_ID); activityFeed.IS_LIKED = model.checkIsLiked(userName, MESSAGE_FEED_ID); return(ResponseSuccess(StringResource.Success, activityFeed)); } else { return(ResponseFail(StringResource.Can_not_load_detail)); } } }
/// <summary> /// 取消对某人的关注 /// </summary> /// <param name="uid">用户编号</param> /// <param name="follow">关注对象编号</param> public void CancelFollow(Guid uid, Guid follow) { IRepository <UserFollow> followRep = Factory.Factory <IRepository <UserFollow> > .GetConcrete <UserFollow>(); IRepository <UserProperty> userProRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>(); UserProperty userProperty = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == uid)); UserProperty followProperty = userProRep.Find(new Specification <UserProperty>(uf => uf.UserID == follow)); UserFollow userFollow = followRep.Find(new Specification <UserFollow>(uf => uf.UserID == uid && uf.Followee == follow)); //取消关注 followRep.Remove(userFollow); //持久化 followRep.PersistAll(); //减少关注数 userProperty.ReduceFolloweesCount(); //减少粉丝数 followProperty.ReduceFollowersCount(); userProRep.Update(userProperty); userProRep.Update(followProperty); userProRep.PersistAll(); //短消息 UserInfoService k = new UserInfoService(); UserStateModel me = k.GetUserInfo(uid); UserStateModel follower = k.GetUserInfo(follow); NewFeedModel feedModel = new NewFeedModel() { Content = "", Sharer = me, SourceUser = follower, Subject = "", Type = FeedType.CancelSupport }; BlogService my = new BlogService(); my.CreateFeed(feedModel); }