Ejemplo n.º 1
0
        /// <summary>
        /// 创建标签
        /// </summary>
        /// <param name="tag">待创建的标签</param>
        /// <param name="logoStream">标题图文件流</param>
        /// <returns>创建成功返回true,否则返回false</returns>
        public bool Create(T tag, Stream logoStream = null)
        {
            //创建数据前,触发相关事件
            EventBus <T> .Instance().OnBefore(tag, new CommonEventArgs(EventOperationType.Instance().Create()));

            long tagId = Convert.ToInt64(tagRepository.Insert(tag));

            if (tagId > 0)
            {
                AddTagInOwner(tag.TagName, tag.TenantTypeId, tag.OwnerId);
                if (logoStream != null)
                {
                    //上传Logo
                    LogoService logoService = new LogoService(TenantTypeIds.Instance().Tag());
                    tag.FeaturedImage = logoService.UploadLogo(tagId, logoStream);
                    tagRepository.Update(tag);
                }
                //若创建成功,触发创建后相关事件
                EventBus <T> .Instance().OnAfter(tag, new CommonEventArgs(EventOperationType.Instance().Create()));

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除标签
        /// </summary>
        /// <param name="tagId">标签Id</param>
        /// <returns>删除成功返回true,否则返回false</returns>
        public bool Delete(long tagId)
        {
            T tag = tagRepository.Get(tagId);

            int affectCount = 0;

            if (tag != null)
            {
                //删除数据前,触发相关事件
                EventBus <T> .Instance().OnBefore(tag, new CommonEventArgs(EventOperationType.Instance().Delete()));

                affectCount = tagRepository.Delete(tag);
                if (affectCount > 0)
                {
                    //删除Logo
                    LogoService logoService = new LogoService(TenantTypeIds.Instance().Tag());
                    logoService.DeleteLogo(tagId);

                    //若删除成功,触发删除后相关事件
                    EventBus <T> .Instance().OnAfter(tag, new CommonEventArgs(EventOperationType.Instance().Delete()));

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 上传示意图
 /// </summary>
 /// <param name="position">广告位</param>
 /// <param name="stream">图片流</param>
 private void UploadPositionImage(AdvertisingPosition position, Stream stream)
 {
     if (stream != null)
     {
         LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition());
         position.FeaturedImage = logoService.UploadLogo(position.PositionId, stream);
         advertisingPositionRepository.Update(position);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 上传广告图片
 /// </summary>
 /// <param name="advertising">广告实体</param>
 /// <param name="stream">图片流</param>
 private void UploadAdvertisingImage(Advertising advertising, Stream stream)
 {
     if (stream != null)
     {
         LogoService logoService = new LogoService(TenantTypeIds.Instance().Advertising());
         advertising.AttachmentUrl = logoService.UploadLogo(advertising.AdvertisingId, stream);
         advertisingRepository.Update(advertising);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 上传Logo
 /// </summary>
 /// <param name="recommendId">推荐Id</param>
 /// <param name="stream">Logo文件流</param>
 public void UploadLogo(long recommendId, Stream stream)
 {
     if (stream != null)
     {
         RecommendItem recommend   = this.Get(recommendId);
         LogoService   logoService = new LogoService(TenantTypeIds.Instance().Recommend());
         recommend.FeaturedImage = logoService.UploadLogo(recommendId, stream);
         this.Update(recommend);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 删除广告位示意图
        /// </summary>
        /// <param name="positionId">广告位Id</param>
        public void DeletePositionImage(string positionId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition());

            logoService.DeleteLogo(positionId);

            AdvertisingPosition position = GetPosition(positionId);

            if (position == null)
            {
                return;
            }

            position.FeaturedImage = string.Empty;
            advertisingPositionRepository.Update(position);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 删除广告位
        /// </summary>
        /// <param name="positionId"></param>
        /// <returns></returns>
        public bool DeletePosition(string positionId)
        {
            AdvertisingPosition position = advertisingPositionRepository.Get(positionId);
            int result = advertisingPositionRepository.Delete(position);

            if (result > 0)
            {
                LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition());
                logoService.DeleteLogo(positionId);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新标签
        /// </summary>
        /// <param name="tag">待创建的标签</param>
        /// <param name="logoStream">标题图文件流</param>
        /// <returns></returns>
        public void Update(T tag, Stream logoStream = null)
        {
            //若更新据前,触发相关事件
            EventBus <T> .Instance().OnBefore(tag, new CommonEventArgs(EventOperationType.Instance().Update()));

            //上传Logo
            if (logoStream != null)
            {
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Tag());
                tag.FeaturedImage = logoService.UploadLogo(tag.TagId, logoStream);
            }

            tagRepository.Update(tag);

            //若更新成功,触发创建后相关事件
            EventBus <T> .Instance().OnAfter(tag, new CommonEventArgs(EventOperationType.Instance().Update()));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 删除广告示意图
        /// </summary>
        /// <param name="advertisingId">广告Id</param>
        public void DeleteAdvertisingImage(long advertisingId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().Advertising());

            logoService.DeleteLogo(advertisingId);

            Advertising advertising = GetAdvertising(advertisingId);

            if (advertising == null)
            {
                return;
            }
            if (advertising.AdvertisingType == AdvertisingType.Image)
            {
                advertising.AttachmentUrl = string.Empty;
            }

            advertisingRepository.Update(advertising);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 删除广告
        /// </summary>
        /// <param name="advertisingId">广告Id</param>
        /// <returns></returns>
        public bool DeleteAdvertising(long advertisingId)
        {
            Advertising advertising = advertisingRepository.Get(advertisingId);
            int         result      = advertisingRepository.Delete(advertising);

            if (result > 0)
            {
                ClearPositionsFromAdvertising(advertisingId);

                LogoService logoService = new LogoService(TenantTypeIds.Instance().Advertising());
                logoService.DeleteLogo(advertisingId);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
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;
        }
Ejemplo n.º 14
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()));
        }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
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);
 }
Ejemplo n.º 17
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()));
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 删除广告
        /// </summary>
        /// <param name="advertisingId">广告Id</param>
        /// <returns></returns>
        public bool DeleteAdvertising(long advertisingId)
        {
            Advertising advertising = advertisingRepository.Get(advertisingId);
            int result = advertisingRepository.Delete(advertising);
            if (result > 0)
            {
                ClearPositionsFromAdvertising(advertisingId);

                LogoService logoService = new LogoService(TenantTypeIds.Instance().Advertising());
                logoService.DeleteLogo(advertisingId);

                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 删除Logo
        /// </summary>
        /// <param name="recommendId">推荐Id</param>
        public void DeleteLogo(long recommendId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().Recommend());

            logoService.DeleteLogo(recommendId);
        }
Ejemplo n.º 20
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;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 上传示意图
 /// </summary>
 /// <param name="position">广告位</param>
 /// <param name="stream">图片流</param>
 private void UploadPositionImage(AdvertisingPosition position, Stream stream)
 {
     if (stream != null)
     {
         LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition());
         position.FeaturedImage = logoService.UploadLogo(position.PositionId, stream);
         advertisingPositionRepository.Update(position);
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 删除Logo
 /// </summary>
 /// <param name="recommendId">推荐Id</param>
 public void DeleteLogo(long recommendId)
 {
     LogoService logoService = new LogoService(TenantTypeIds.Instance().Recommend());
     logoService.DeleteLogo(recommendId);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 删除广告位
 /// </summary>
 /// <param name="positionId"></param>
 /// <returns></returns>
 public bool DeletePosition(string positionId)
 {
     AdvertisingPosition position = advertisingPositionRepository.Get(positionId);
     int result = advertisingPositionRepository.Delete(position);
     if (result > 0)
     {
         LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition());
         logoService.DeleteLogo(positionId);
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// 删除广告示意图
        /// </summary>
        /// <param name="advertisingId">广告Id</param>
        public void DeleteAdvertisingImage(long advertisingId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().Advertising());
            logoService.DeleteLogo(advertisingId);

            Advertising advertising = GetAdvertising(advertisingId);
            if (advertising == null)
                return;
            if (advertising.AdvertisingType == AdvertisingType.Image)
                advertising.AttachmentUrl = string.Empty;

            advertisingRepository.Update(advertising);
        }
Ejemplo n.º 25
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;
        }
Ejemplo n.º 26
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));
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 删除广告位示意图
        /// </summary>
        /// <param name="positionId">广告位Id</param>
        public void DeletePositionImage(string positionId)
        {
            LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition());
            logoService.DeleteLogo(positionId);

            AdvertisingPosition position = GetPosition(positionId);
            if (position == null)
                return;

            position.FeaturedImage = string.Empty;
            advertisingPositionRepository.Update(position);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 创建认证标识
        /// </summary>
        /// <param name="identificationType">认证标识实体</param>
        /// <returns></returns>
        public bool CreateIdentificationType(IdentificationType identificationType, Stream logoStream)
        {
            EventBus<IdentificationType>.Instance().OnBefore(identificationType, new CommonEventArgs(EventOperationType.Instance().Create()));

            identificationType.IdentificationTypeLogo = string.Empty;
            identificationTypeRepository.Insert(identificationType);

            //创建认证标识图片
            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().Create()));
            return true;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 上传Logo
 /// </summary>
 /// <param name="recommendId">推荐Id</param>
 /// <param name="stream">Logo文件流</param>
 public void UploadLogo(long recommendId, Stream stream)
 {
     if (stream != null)
     {
         RecommendItem recommend = this.Get(recommendId);
         LogoService logoService = new LogoService(TenantTypeIds.Instance().Recommend());
         recommend.FeaturedImage = logoService.UploadLogo(recommendId, stream);
         this.Update(recommend);
     }
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 上传广告图片
 /// </summary>
 /// <param name="advertising">广告实体</param>
 /// <param name="stream">图片流</param>
 private void UploadAdvertisingImage(Advertising advertising, Stream stream)
 {
     if (stream != null)
     {
         LogoService logoService = new LogoService(TenantTypeIds.Instance().Advertising());
         advertising.AttachmentUrl = logoService.UploadLogo(advertising.AdvertisingId, stream);
         advertisingRepository.Update(advertising);
     }
 }