Beispiel #1
0
 /// <summary>
 /// 上传Logo
 /// </summary>
 /// <param name="groupId">群组Id</param>
 /// <param name="stream">Logo文件流</param>
 public void UploadLogo(long groupId, Stream stream)
 {
     //按现在设计应该用LogoService,但是感觉LogoService没什么必要(重构Logo/Image直连后再定)
     if (stream != null)
     {
         GroupEntity group       = this.Get(groupId);
         LogoService logoService = new LogoService(TenantTypeIds.Instance().Group());
         group.Logo = logoService.UploadLogo(groupId, stream);
         groupRepository.Update(group);
         EventBus <GroupEntity> .Instance().OnAfter(group, new CommonEventArgs(EventOperationType.Instance().Update()));
     }
 }
Beispiel #2
0
        /// <summary>
        /// 更新帖吧
        /// </summary>
        /// <param name="section">帖吧</param>
        /// <param name="userId">当前操作人</param>
        /// <param name="managerIds">管理员用户Id</param>
        /// <param name="sectionedFile">帖吧标识图</param>
        public void Update(BarSection section, long userId, IEnumerable <long> managerIds, Stream sectionedFile)
        {
            EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Update()));



            //上传Logo
            if (sectionedFile != null)
            {
                LogoService logoService = new LogoService(TenantTypeIds.Instance().BarSection());
                section.LogoImage = logoService.UploadLogo(section.SectionId, sectionedFile);
            }

            auditService.ChangeAuditStatusForUpdate(userId, section);
            barSectionRepository.Update(section);

            if (managerIds != null && managerIds.Count() > 0)
            {
                List <long> mangagerIds_list = managerIds.ToList();
                mangagerIds_list.Remove(section.UserId);
                managerIds = mangagerIds_list;
            }
            barSectionRepository.UpdateManagerIds(section.SectionId, managerIds);

            if (section.TenantTypeId == TenantTypeIds.Instance().Bar())
            {
                SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection());

                //帖吧主、吧管理员自动关注本帖吧
                int  followedCount = 0;
                bool result        = subscribeService.Subscribe(section.SectionId, section.UserId);
                if (result)
                {
                    followedCount++;
                }
                if (managerIds != null && managerIds.Count() > 0)
                {
                    foreach (var managerId in managerIds)
                    {
                        result = subscribeService.Subscribe(section.SectionId, managerId);
                        if (result)
                        {
                            followedCount++;
                        }
                    }
                }

                //增加帖吧的被关注数
                CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                countService.ChangeCount(CountTypes.Instance().FollowedCount(), section.SectionId, section.UserId, followedCount, true);
            }
            EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Update()));
        }
Beispiel #3
0
        /// <summary>
        /// 更新认证标识
        /// </summary>
        /// <param name="identificationType">认证标识实体</param>
        /// <returns></returns>
        public bool UpdateIdentificationType(IdentificationType identificationType, Stream logoStream)
        {
            EventBus <IdentificationType> .Instance().OnBefore(identificationType, new CommonEventArgs(EventOperationType.Instance().Update()));

            if (logoStream != null)
            {
                LogoService logoService = new LogoService(TenantTypeIds.Instance().IdentificationType());
                identificationType.IdentificationTypeLogo = logoService.UploadLogo(identificationType.IdentificationTypeId, logoStream);
            }
            identificationTypeRepository.Update(identificationType);

            EventBus <IdentificationType> .Instance().OnAfter(identificationType, new CommonEventArgs(EventOperationType.Instance().Update()));

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// 更新身份认证申请
        /// </summary>
        /// <param name="identification">身份认证实体</param>
        /// <param name="stream">证件扫描件</param>
        /// <returns></returns>
        public bool UpdateIdentification(Identification identification, Stream stream = null)
        {
            EventBus <Identification> .Instance().OnBefore(identification, new CommonEventArgs(EventOperationType.Instance().Update()));

            if (stream != null)
            {
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Identification());

                logoService.DeleteLogo(identification.IdentificationId);
                identification.IdentificationLogo = logoService.UploadLogo(identification.IdentificationId, stream);
            }

            iIdentificationRepository.Update(identification);

            EventBus <Identification> .Instance().OnAfter(identification, new CommonEventArgs(EventOperationType.Instance().Update()));

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// 创建身份认证申请
        /// </summary>
        /// <param name="identification">身份认证实体</param>
        /// <param name="stream">证件扫描件</param>
        /// <returns></returns>
        public bool CreateIdentification(Identification identification, Stream stream = null)
        {
            EventBus <Identification> .Instance().OnBefore(identification, new CommonEventArgs(EventOperationType.Instance().Create()));

            //创建身份认证
            identification.IdentificationLogo = string.Empty;
            iIdentificationRepository.Insert(identification);

            //创建身份认证图片
            if (stream != null)
            {
                //上传Logo
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Identification());
                identification.IdentificationLogo = logoService.UploadLogo(identification.IdentificationId, stream);

                iIdentificationRepository.Update(identification);
            }

            EventBus <Identification> .Instance().OnAfter(identification, new CommonEventArgs(EventOperationType.Instance().Create()));

            return(true);
        }
Beispiel #6
0
        /// <summary>
        /// 创建帖吧
        /// </summary>
        /// <param name="section">帖吧</param>
        /// <param name="userId">当前操作人</param>
        /// <param name="managerIds">管理员用户Id</param>
        /// <param name="logoFile">帖吧标识图</param>
        /// <returns>是否创建成功</returns>
        public bool Create(BarSection section, long userId, IEnumerable <long> managerIds, Stream logoFile)
        {
            EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态
            auditService.ChangeAuditStatusForCreate(userId, section);

            if (!(section.SectionId > 0))
            {
                section.SectionId = IdGenerator.Next();
            }

            long id = 0;

            long.TryParse(barSectionRepository.Insert(section).ToString(), out id);

            if (id > 0)
            {
                if (managerIds != null && managerIds.Count() > 0)
                {
                    List <long> mangagerIds_list = managerIds.ToList();
                    mangagerIds_list.Remove(section.UserId);
                    managerIds = mangagerIds_list;
                    barSectionRepository.UpdateManagerIds(id, managerIds);
                }
                if (section.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //帖吧主、吧管理员自动关注本帖吧
                    SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection());
                    int  followedCount = 0;
                    bool result        = subscribeService.Subscribe(section.SectionId, section.UserId);
                    if (result)
                    {
                        followedCount++;
                    }
                    if (managerIds != null && managerIds.Count() > 0)
                    {
                        foreach (var managerId in managerIds)
                        {
                            result = subscribeService.Subscribe(section.SectionId, managerId);
                            if (result)
                            {
                                followedCount++;
                            }
                        }
                    }
                    //增加帖吧的被关注数
                    CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                    countService.ChangeCount(CountTypes.Instance().FollowedCount(), section.SectionId, section.UserId, followedCount, true);
                }



                //上传Logo
                if (logoFile != null)
                {
                    LogoService logoService = new LogoService(TenantTypeIds.Instance().BarSection());
                    section.LogoImage = logoService.UploadLogo(section.SectionId, logoFile);
                    barSectionRepository.Update(section);
                }
                EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Create()));

                EventBus <BarSection, AuditEventArgs> .Instance().OnAfter(section, new AuditEventArgs(section.AuditStatus, null));
            }
            return(id > 0);
        }