/// <summary>
        /// 提交案例卡信息
        /// </summary>
        /// <param name="caseFineDtos"></param>
        /// <returns></returns>
        public virtual async Task UpdateCard(CaseCardUpdateDto caseCardUpdateDto)
        {
            var caseCardManager = Resolve <CaseCardManager>();
            var caseCardDtos    = caseCardUpdateDto.CaseCards;
            var caseInitial     = await Resolve <CaseInitialManager>().GetAll().Include(o => o.CaseCards)
                                  .Where(o => o.Id == caseCardUpdateDto.CaseInitialId).SingleOrDefaultAsync();

            if (caseInitial == null)
            {
                throw new UserFriendlyException("不存在加工信息");
            }
            //删除
            var delIds = caseInitial.CaseCards.Where(o => !caseCardDtos.Select(c => c.Id).Contains(o.Id)).Select(o => o.Id);
            await caseCardManager.DeleteAsync(delIds);

            //增加
            foreach (var caseCardDto in caseCardDtos.Where(o => o.Id == 0))
            {
                var newCaseCard = caseCardDto.MapTo <CaseCard>();
                newCaseCard.CaseInitialId = caseInitial.Id;
                newCaseCard.CaseStatus    = CaseStatus.加工中;
                await caseCardManager.InsertAsync(newCaseCard);
            }
            //修改
            foreach (var caseCardDto in caseCardDtos.Where(o => o.Id > 0))
            {
                var oriCaseCard = await caseCardManager.GetByIdAsync(caseCardDto.Id);

                caseCardDto.MapTo(oriCaseCard);
                oriCaseCard.CaseStatus = CaseStatus.加工中;
            }
        }
        /// <summary>
        /// 发布案例卡
        /// </summary>
        /// <param name="caseInitialId"></param>
        /// <returns></returns>
        public virtual async Task PublishCard(CaseCardUpdateDto caseCardUpdateDto)
        {
            var caseInitial = await Resolve <CaseInitialManager>().GetAll().Include(o => o.CaseCards)
                              .Where(o => o.Id == caseCardUpdateDto.CaseInitialId).SingleOrDefaultAsync();

            if (caseInitial == null)
            {
                throw new UserFriendlyException("不存在加工信息");
            }
            if (caseInitial.CaseStatus != CaseStatus.展示中 && caseInitial.CaseStatus != CaseStatus.架)
            {
                throw new UserFriendlyException("请先完成本判例的初加工并发布后再进行案例卡发布,谢谢!您可点击保存按钮保留已做的成果");
            }

            await UpdateCard(caseCardUpdateDto);

            await CurrentUnitOfWork.SaveChangesAsync();

            var caseCards = await Resolve <CaseCardManager>().GetAll().Where(o => o.CaseInitialId == caseCardUpdateDto.CaseInitialId).ToListAsync();

            foreach (var caseCard in caseCards)
            {
                caseCard.CaseStatus = CaseStatus.展示中;
            }
        }
        /// <summary>
        /// 加工信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual async Task <object> GetCaseProcessInfo(int id)
        {
            var caseInitialManager = Resolve <CaseInitialManager>();
            var caseSource         = await Manager.GetAll()
                                     .Include(o => o.AnYou)
                                     .Include(o => o.City)
                                     .Include(o => o.Court1)
                                     .Include(o => o.Court2)
                                     .Where(o => o.Id == id)
                                     .SingleOrDefaultAsync();

            //if (caseSource.OwerId != AbpSession.UserId)
            //{
            //    throw new UserFriendlyException("无权查看此判例加工信息");
            //}

            var caseInitial = await caseInitialManager.GetAll()
                              .Include(o => o.CaseNodes)
                              .Include(o => o.CaseLabels)
                              .Include(o => o.CaseFines)
                              .Include(o => o.CaseCards)
                              .Where(o => o.CaseSourceId == id /*&& o.CreatorUserId == caseSource.OwerId*/)
                              .FirstOrDefaultAsync();

            #region 初加工数据
            CaseInitialUpdateDto caseInitialUpdateDto = new CaseInitialUpdateDto();
            if (caseInitial == null)
            {
                //如果没有初加工,直接产生初加工记录
                caseInitial = new CaseInitial()
                {
                    CaseSourceId = id,
                    CaseStatus   = CaseStatus.加工中
                };
                await caseInitialManager.InsertAndGetIdAsync(caseInitial);
            }
            caseInitial.MapTo(caseInitialUpdateDto);
            #endregion

            #region 精加工数据
            CaseFineUpdateDto caseFineUpdateDto = new CaseFineUpdateDto()
            {
                CaseInitialId = caseInitial.Id
            };
            caseFineUpdateDto.CaseFines = caseInitial.CaseFines.MapTo <List <CaseFineDto> >();
            #endregion

            #region 案例卡数据
            CaseCardUpdateDto caseCardUpdateDto = new CaseCardUpdateDto()
            {
                CaseInitialId = caseInitial.Id
            };
            caseCardUpdateDto.CaseCards = caseInitial.CaseCards.MapTo <List <CaseCardDto> >();
            #endregion

            return(new
            {
                Source = new
                {
                    caseSource.SourceSN,
                    caseSource.AnYouId,
                    AnYou = caseSource.AnYou?.DisplayName,
                    caseSource.CityId,
                    City = caseSource.City?.DisplayName,
                    caseSource.Court1Id,
                    Court1 = caseSource.Court1?.DisplayName,
                    caseSource.Court2Id,
                    Court2 = caseSource.Court2?.DisplayName,
                    caseSource.LawyerFirms,
                    TrialPeople = caseSource.TrialPeople.Select(o => new { o.Name, TrialRole = o.TrialRole.ToString() }),
                    caseSource.SourceFile,
                    caseSource.ValidDate
                },
                caseInitialUpdateDto,
                caseFineUpdateDto,
                caseCardUpdateDto
            });
        }