コード例 #1
0
 void SetStatusInvitationnForJoinGroupEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve<InvitationService>();
         Invitation invitation = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember member=GroupMember.New();
             member.GroupId=sender.RelativeObjectId;
             member.UserId = sender.UserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember member = GroupMember.New();
             member.GroupId = sender.RelativeObjectId;
             member.UserId = sender.SenderUserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
             IEnumerable<long> a= groupService.GetGroupMemberApplies(sender.RelativeObjectId,GroupMemberApplyStatus.Pending,20,1).Where(n=>n.UserId==sender.SenderUserId).Select(m=>m.Id);
             groupService.ApproveGroupMemberApply(a,true);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Refuse)
         {
             GroupService groupService = new GroupService();
             IEnumerable<long> a = groupService.GetGroupMemberApplies(sender.RelativeObjectId, GroupMemberApplyStatus.Pending, 20, 1).Where(n => n.UserId == sender.SenderUserId).Select(m => m.Id);
             groupService.ApproveGroupMemberApply(a,false);
         }
     }
 }
コード例 #2
0
 void SetStatusInvitationEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve<InvitationService>();
         Invitation invitation = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteFollow() && invitation.Status == InvitationStatus.Accept)
         {
             FollowService followService = new FollowService();
             followService.Follow(invitation.UserId, invitation.SenderUserId);
         }
     }
 }
コード例 #3
0
ファイル: InvitationRepository.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 创建请求的方法
        /// </summary>
        /// <param name="entity">请求实体</param>
        /// <returns>刚插入数据的id</returns>
        public override object Insert(Tunynet.Common.Invitation entity)
        {
            base.Insert(entity);

            //确定已经将数据插入到数据库因为id已经更改
            if (entity.Id > 0)
            {
                string cacheKey = GetCacheKey_UnhandledInvitationCount(entity.UserId);
                int?   count    = cacheService.Get(cacheKey) as int?;
                if (count != null)
                {
                    count++;
                    cacheService.Set(cacheKey, count, CachingExpirationType.SingleObject);
                }
            }
            return(entity.Id);
        }
コード例 #4
0
ファイル: Invitation.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        public static Invitation New()
        {
            Invitation invitation = new Invitation()
            {
                InvitationTypeKey = string.Empty,
                Sender = string.Empty,
                RelativeObjectName = string.Empty,
                RelativeObjectUrl = string.Empty,
                DateCreated = DateTime.UtcNow

            };
            return invitation;
        }
コード例 #5
0
 /// <summary>
 /// 创建请求
 /// </summary>
 /// <param name="invitation">请求实体</param>
 /// <remarks>已检查请求设置</remarks>
 public void Create(Invitation invitation)
 {
     if (!IsAllowedSend(invitation.UserId, invitation.InvitationTypeKey))
         return;
     //触发事件
     EventBus<Invitation>.Instance().OnBefore(invitation, new CommonEventArgs(EventOperationType.Instance().Create(), invitation.ApplicationId));
     invitationRepository.Insert(invitation);
     //触发事件
     EventBus<Invitation>.Instance().OnAfter(invitation, new CommonEventArgs(EventOperationType.Instance().Create(), invitation.ApplicationId));
 }