Example #1
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()));
        }
Example #2
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()));
     }
 }
Example #3
0
        /// <summary>
        /// 删除Logo
        /// </summary>
        /// <param name="recommendId">群组Id</param>
        public void DeleteLogo(long groupId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().Group());

            logoService.DeleteLogo(groupId);
            GroupEntity group = Get(groupId);

            if (group == null)
            {
                return;
            }
            group.Logo = string.Empty;
            groupRepository.Update(group);
        }
Example #4
0
        /// <summary>
        /// 删除Logo
        /// </summary>
        /// <param name="sectionId">帖吧Id</param>
        public void DeleteLogo(long sectionId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().BarSection());

            logoService.DeleteLogo(sectionId);
            BarSection section = barSectionRepository.Get(sectionId);

            if (section == null)
            {
                return;
            }
            section.LogoImage = string.Empty;
            barSectionRepository.Update(section);
        }
Example #5
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);
        }
Example #6
0
 public TwitchController(
     IOptions <AppSettings> settings,
     IPlayerManager playerManager,
     IGameData gameData,
     ISessionInfoProvider sessionInfoProvider,
     IAuthManager authManager,
     LogoService logoService)
 {
     this.playerManager       = playerManager;
     this.gameData            = gameData;
     this.sessionInfoProvider = sessionInfoProvider;
     this.authManager         = authManager;
     this.logoService         = logoService;
     this.settings            = settings.Value;
 }
Example #7
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);
        }
Example #8
0
        public void TestCreate()
        {
            // Arrange
            ILogoService logo = new LogoService();
            LogoData     data = new LogoData
            {
                BatchNr    = "3",
                Production = DateTime.Today
            };

            // Act
            logo.Create(data);

            // Assert
            WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open("BearFoods.BL.Logo.docx", false);
            var textPath = wordprocessingDocument.MainDocumentPart.Document.Body.ChildElements[0].ChildElements[2].ChildElements[1].ChildElements[1].ChildElements[3].ChildElements[1].ChildElements[1].ChildElements[3];

            Assert.AreEqual(BATCH_3, textPath.GetAttributes().Last().Value);
        }
Example #9
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);
        }
Example #10
0
        /// <summary>
        /// 删除认证标识
        /// </summary>
        /// <param name="identificationTypeId">认证标识ID</param>
        /// <returns></returns>
        public bool DeleteIdentificationType(long identificationTypeId)
        {
            IdentificationType identificationType = identificationTypeRepository.Get(identificationTypeId);

            if (identificationType != null)
            {
                EventBus <IdentificationType> .Instance().OnBefore(identificationType, new CommonEventArgs(EventOperationType.Instance().Delete()));

                //删除认证标识和该认证标识下的所有申请
                IdentificationTypeRepository typeRepository = new IdentificationTypeRepository();
                typeRepository.DeleteIdentificationTypes(identificationTypeId);

                //删除认证标识图
                LogoService logoService = new LogoService(TenantTypeIds.Instance().IdentificationType());
                logoService.DeleteLogo(identificationTypeId);

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

                return(true);
            }
            return(false);
        }
Example #11
0
        /// <summary>
        /// 删除身份认证申请
        /// </summary>
        /// <param name="identificationId">身份认证ID</param>
        /// <returns></returns>
        public bool DeleteIdentification(long identificationId)
        {
            Identification identification = iIdentificationRepository.Get(identificationId);

            if (identification != null)
            {
                EventBus <Identification> .Instance().OnBefore(identification, new CommonEventArgs(EventOperationType.Instance().Delete()));

                //删除身份认证
                iIdentificationRepository.Delete(identification);

                //删除身份认证图片
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Identification());
                logoService.DeleteLogo(identificationId);

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

                return(true);
            }

            return(false);
        }
Example #12
0
        /// <summary>
        /// 删除群组
        /// </summary>
        /// <param name="groupId">群组Id</param>
        public void Delete(long groupId)
        {
            //设计要点
            //1、需要删除:群组成员、群组申请、Logo;
            GroupEntity group = groupRepository.Get(groupId);

            if (group == null)
            {
                return;
            }

            CategoryService categoryService = new CategoryService();

            categoryService.ClearCategoriesFromItem(groupId, null, TenantTypeIds.Instance().Group());


            EventBus <GroupEntity> .Instance().OnBefore(group, new CommonEventArgs(EventOperationType.Instance().Delete()));

            int affectCount = groupRepository.Delete(group);

            if (affectCount > 0)
            {
                //删除访客记录
                new VisitService(TenantTypeIds.Instance().Group()).CleanByToObjectId(groupId);
                //用户的创建群组数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(group.UserId, OwnerDataKeys.Instance().CreatedGroupCount(), -1);
                //删除Logo
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Group());
                logoService.DeleteLogo(groupId);
                //删除群组下的成员
                DeleteMembersByGroupId(groupId);
                EventBus <GroupEntity> .Instance().OnAfter(group, new CommonEventArgs(EventOperationType.Instance().Delete()));

                EventBus <GroupEntity, AuditEventArgs> .Instance().OnAfter(group, new AuditEventArgs(group.AuditStatus, null));
            }
        }
Example #13
0
        public void Setup()
        {
            var connection = ServiceTestHelper.GetDatabaseConnection();

            logoService = new LogoService(connection);
        }
Example #14
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);
        }