コード例 #1
0
ファイル: PhotoEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 照片圈人通知
        /// </summary>
        /// <param name="photoLabel"></param>
        /// <param name="eventArgs"></param>
        public void PhotoLabelNotice_After(PhotoLabel photoLabel, CommonEventArgs eventArgs)
        {
            if (photoLabel.Photo == null)
            {
                return;
            }
            //圈人的操作人
            IUser user = DIContainer.Resolve <UserService>().GetUser(photoLabel.UserId);

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //排除掉照片主人自己
                if (photoLabel.UserId == photoLabel.Photo.UserId)
                {
                    return;
                }
                //通知照片作者
                Notice notice = Notice.New();
                notice.UserId             = photoLabel.Photo.UserId;
                notice.ApplicationId      = PhotoConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Hint();
                notice.LeadingActor       = user.DisplayName;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().Home(user.UserName));
                notice.RelativeObjectName = photoLabel.Photo.Description;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().PhotoDetail(photoLabel.Photo.PhotoId));
                notice.TemplateName       = NoticeTemplateNames.Instance().PhotoLabelNotice();
                noticeService.Create(notice);
            }
        }
コード例 #2
0
        public ActionResult GetPhotoLabel(long labelId)
        {
            PhotoLabel label = photoService.GetLabel(labelId);

            if (label == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "没有找到圈人信息"), JsonRequestBehavior.AllowGet));
            }

            return(Json(label.AsPhotoEditModel(), JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public ActionResult CreatPhotoLabel(string userId, double height, double width, double left, double top, long photoId)
        {
            Photo photo = photoService.GetPhoto(photoId);

            if (!authorizer.PhotoLabel_Creat(photo))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您可能没有权限在这张照片上圈人")));
            }

            long userIdLong = 0;

            string[] listUserId = userId.Split(new char[] { ',', ',' }, System.StringSplitOptions.RemoveEmptyEntries);

            if (listUserId == null || listUserId.Length == 0)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到用户")));
            }

            foreach (var item in listUserId)
            {
                if (long.TryParse(item, out userIdLong))
                {
                    break;
                }
            }

            IUser user = DIContainer.Resolve <UserService>().GetUser(userIdLong);

            if (user == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到用户")));
            }

            PhotoLabel label = PhotoLabel.New();

            label.AreaHeight   = (int)height;
            label.AreaWidth    = (int)width;
            label.AreaX        = (int)left;
            label.AreaY        = (int)top;
            label.ObjetId      = userIdLong;
            label.ObjectName   = user.DisplayName;
            label.TenantTypeId = TenantTypeIds.Instance().User();
            label.PhotoId      = photoId;
            label.Description  = string.Empty;
            label.UserId       = UserContext.CurrentUser.UserId;

            bool isCreat = photoService.CreateLabel(label);

            if (isCreat)
            {
                return(Json(new { messageType = StatusMessageType.Success, id = label.LabelId }));
            }
            return(Json(new StatusMessageData(StatusMessageType.Error, "创建失败")));
        }
コード例 #4
0
        public ActionResult DeletePhotoLabel(long labelId)
        {
            PhotoLabel label = photoService.GetLabel(labelId);

            if (!authorizer.PhotoLabel_Delete(label))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您可能没有权限删除此圈人")));
            }

            photoService.DeleteLabel(label);

            return(Json(new StatusMessageData(StatusMessageType.Success, "删除成功")));
        }
コード例 #5
0
ファイル: PhotoEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 圈人动态处理
        /// </summary>
        private void LabelPhotoActivityModule_After(PhotoLabel photoLabel, CommonEventArgs eventArgs)
        {
            Photo photo = photoService.GetPhoto(photoLabel.PhotoId);

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //初始化Owner为用户的动态
                Activity activity = Activity.New();
                activity.ActivityItemKey       = ActivityItemKeys.Instance().LabelPhoto();
                activity.ApplicationId         = PhotoConfig.Instance().ApplicationId;
                activity.HasImage              = true;
                activity.HasMusic              = false;
                activity.HasVideo              = false;
                activity.IsOriginalThread      = true;
                activity.IsPrivate             = photoLabel.Photo.PrivacyStatus == PrivacyStatus.Private ? true : false;
                activity.UserId                = photo.UserId;
                activity.ReferenceId           = photoLabel.PhotoId;
                activity.ReferenceTenantTypeId = TenantTypeIds.Instance().Photo();
                activity.SourceId              = photoLabel.LabelId;
                activity.TenantTypeId          = TenantTypeIds.Instance().PhotoLabel();
                activity.OwnerId               = photo.UserId;
                activity.OwnerName             = photo.Author;
                activity.OwnerType             = ActivityOwnerTypes.Instance().User();

                //是否是公开的(用于是否推送站点动态)
                bool isPublic = photoLabel.Photo.PrivacyStatus == PrivacyStatus.Public ? true : false;

                activityService.Generate(activity, true, isPublic);

                //再为被圈用户生成动态
                new ActivityRepository().InsertUserInboxs(activity.ActivityId, new long[] { photoLabel.ObjetId });
            }
            else
            {
                activityService.DeleteSource(TenantTypeIds.Instance().PhotoLabel(), photoLabel.LabelId);
            }
        }
コード例 #6
0
        /// <summary>
        /// 创建圈人动态
        /// </summary>
        /// <param name="ActivityId"></param>
        /// <returns></returns>
        //[DonutOutputCache(CacheProfile = "Frequently")]
        public ActionResult _CreatePhotoLabel(long ActivityId)
        {
            //实例化动态
            Activity activity = activityService.Get(ActivityId);

            if (activity == null)
            {
                return(Content(string.Empty));
            }
            ViewData["Activity"] = activity;

            //实例化圈人
            PhotoLabel photoLabel = photoService.GetLabel(activity.SourceId);

            if (photoLabel == null)
            {
                return(Content(string.Empty));
            }

            //实例化评论
            PagingDataSet <Comment> commentPaging = commentService.GetRootComments(TenantTypeIds.Instance().Photo(), photoLabel.PhotoId, 1, SortBy_Comment.DateCreatedDesc);
            int commentCount = 0;

            if (commentPaging == null)
            {
                commentCount = 0;
            }
            else
            {
                commentCount = commentPaging.Count;
            }
            ViewData["CommentCount"] = commentCount;
            ViewData["User"]         = DIContainer.Resolve <UserService>().GetUser(photoLabel.UserId);

            return(View(photoLabel));
        }
コード例 #7
0
ファイル: PhotoEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 照片圈人积分
        /// </summary>
        public void PhotoLabelEventModule_After(PhotoLabel photoLabel, CommonEventArgs eventArgs)
        {
            string pointItemKey       = string.Empty;
            string eventOperationType = string.Empty;

            //加积分
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                pointItemKey       = PointItemKeys.Instance().Photo_BeLabelled();
                eventOperationType = EventOperationType.Instance().Create();
            }
            //减积分
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                pointItemKey       = PointItemKeys.Instance().Photo_BeLabelled_Delete();
                eventOperationType = EventOperationType.Instance().Delete();
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                string description = string.Format("照片圈人", "", HtmlUtility.TrimHtml(photoLabel.Description, 64));
                pointService.GenerateByRole(photoLabel.ObjetId, pointItemKey, description);
            }
        }