/// <summary>
        /// 导出进行中活动的库存数据到Redis
        /// </summary>
        /// <param name="setEntityList"></param>
        private void ExportCacheData(List <SignPointSetEntity> setEntityList, int originalId)
        {
            //Parallel.ForEach(setEntityList, item =>
            //{

            //    if (item.WxHbID > 0)//红包
            //    {
            //        int prizeType = 0;
            //        int activityType = item.IsSpecial == 0 ? 2 : 3;
            //        string hbStockCountKey = string.Format(SignKeys.signactprizegrantnum_key, item.ID, prizeType);
            //        hbStockCountKey = "B200016:" + hbStockCountKey;
            //        int hbGrantCount = _eventAwardRecordsRepository.Count(" where MemberLogin=@Memberlogin and ActivityID=@ActID  and ActivityType=@ActivityType and (PrizeType=@PrizeType or  PrizeType=@PrizeType2 )  and AwardSetId = @AwardSetId",
            //            new { Memberlogin = item.Memberlogin, ActID = originalId, ActivityType = activityType, PrizeType = 5, PrizeType2 = 6, AwardSetId = item.ID });
            //        bool flag = _redisHelper.StringSet(hbStockCountKey, hbGrantCount.ToString(), 180 * 60 * 60 * 24);
            //        //_redisHelper.StringIncrement(hbStockCountKey, hbGrantCount);

            //    }
            //    if (item.ProductID > 0)//产品
            //    {
            //        int prizeType = 1;
            //        int activityType = item.IsSpecial == 0 ? 2 : 3;
            //        string productStockCountKey = string.Format(SignKeys.signactprizegrantnum_key, item.ID, prizeType);
            //        productStockCountKey = "B200016:" + productStockCountKey;
            //        int prizeTypeDB = 0;
            //        int productStockCount = _eventAwardRecordsRepository.Count("where MemberLogin=@Memberlogin and ActivityID=@ActID  and ActivityType=@ActivityType and PrizeType=@PrizeType  and AwardSetId = @AwardSetId",
            //            new { Memberlogin = item.Memberlogin, ActID = originalId, ActivityType = activityType, PrizeType = prizeTypeDB, AwardSetId = item.ID });
            //        bool flag = _redisHelper.StringSet(productStockCountKey, productStockCount.ToString(), 180 * 60 * 60 * 24);
            //        //_redisHelper.StringIncrement(productStockCountKey, productStockCount);
            //    }

            //});

            foreach (var item in setEntityList)
            {
                if (item.WxHbID > 0)//红包
                {
                    //time.Marke("42.红包");
                    int    prizeType       = 0;
                    int    activityType    = item.IsSpecial == 0 ? 2 : 3;
                    string hbStockCountKey = string.Format(SignKeys.signactprizegrantnum_key, item.ID, prizeType);
                    hbStockCountKey = "B200016:" + hbStockCountKey;
                    int hbGrantCount = _eventAwardRecordsRepository.Count(" where MemberLogin=@Memberlogin and ActivityID=@ActID  and ActivityType=@ActivityType and (PrizeType=@PrizeType or  PrizeType=@PrizeType2 )  and AwardSetId = @AwardSetId",
                                                                          new { Memberlogin = item.Memberlogin, ActID = originalId, ActivityType = activityType, PrizeType = 5, PrizeType2 = 6, AwardSetId = item.ID });
                    bool flag = _redisHelper.StringSet(hbStockCountKey, hbGrantCount.ToString(), 180 * 60 * 60 * 24);
                    //_redisHelper.StringIncrement(hbStockCountKey, hbGrantCount);

                    //time.Marke("43.红包结束");
                }
                if (item.ProductID > 0)//产品
                {
                    //time.Marke("44.产品");
                    int    prizeType            = 1;
                    int    activityType         = item.IsSpecial == 0 ? 2 : 3;
                    string productStockCountKey = string.Format(SignKeys.signactprizegrantnum_key, item.ID, prizeType);
                    productStockCountKey = "B200016:" + productStockCountKey;
                    int prizeTypeDB       = 0;
                    int productStockCount = _eventAwardRecordsRepository.Count("where MemberLogin=@Memberlogin and ActivityID=@ActID  and ActivityType=@ActivityType and PrizeType=@PrizeType  and AwardSetId = @AwardSetId",
                                                                               new { Memberlogin = item.Memberlogin, ActID = originalId, ActivityType = activityType, PrizeType = prizeTypeDB, AwardSetId = item.ID });
                    bool flag = _redisHelper.StringSet(productStockCountKey, productStockCount.ToString(), 180 * 60 * 60 * 24);
                    //_redisHelper.StringIncrement(productStockCountKey, productStockCount);

                    //time.Marke("45.产品");
                }
            }
        }
        public void IsSuccessfullyInsertData()
        {
            var actIdList = _signPointActivityRepository.Query <int>("select distinct top 1 id  from  SignPointActivity");
            var watch     = new Stopwatch();

            watch.Start();
            //数据库应该有数据
            actIdList.ShouldNotBeNull();
            //条目不为空
            actIdList.Any().ShouldBe(true);

            var node = actIdList.FirstOrDefault();
            var boo  = _actuatorAppService.ExportAct(node);

            boo.ShouldBe(true);
            //检测mongodb的字段
            List <IEnumerable <object> > queryList = _signPointActivityRepository.QueryMultiple(
                "select top 1 * from SignPointActivity where  ID=@id;select  * from   SignPointSet where  ActivityID=@id",
                new { id = node }, typeof(SignPointActivityDto), typeof(SignPointSetDto));
            SignPointActivityDto signAct = (SignPointActivityDto)queryList[0].FirstOrDefault();

            signAct.ShouldNotBeNull();
            List <SignPointSetDto> actSetList = new List <SignPointSetDto>();

            foreach (var item in queryList[1])
            {
                actSetList.Add((SignPointSetDto)item);
            }
            actSetList.Any().ShouldBe(true);

            SignActivity signMongo = _signActivityRepository.FirstOrDefault(x => x.Id == signAct.ActID.ToString());

            signMongo.ShouldNotBeNull();
            signMongo.Title.ShouldBe(signAct.Title);
            signMongo.BackGroundImg.ShouldBe(signAct.BackGroundImg);
            signMongo.BtnName.ShouldBe(signAct.BtnName);
            signMongo.BtnUrl.ShouldBe(signAct.BtnUrl);
            signMongo.BtnUrlName.ShouldBe(signAct.BtnUrlName);
            signMongo.CssStyle.ShouldBe(signAct.CssStyle);
            signMongo.FreeChance.ShouldBe(signAct.FreeChance);
            signMongo.RegistrationRemark.ShouldBe(signAct.RegistrationRemark);
            signMongo.Memberlogin.ShouldBe(signAct.Memberlogin);
            signMongo.SignPointSet.Count().ShouldBe(actSetList.Count());
            string timePattern = "yyyyMMdd";

            signMongo.BeginTime.ToString(timePattern).ShouldBe(signAct.BeginTime.ToString(timePattern));
            signMongo.EndTime.ToString(timePattern).ShouldBe(signAct.EndTime.ToString(timePattern));

            //检查奖项库存
            foreach (var item in signMongo.SignPointSet)
            {
                if (item.WxHbID > 0)//红包
                {
                    int    prizeType       = 0;
                    int    activityType    = item.IsSpecial == 0 ? 2 : 3;
                    string hbStockCountKey = string.Format(SignKeys.signactprizegrantnum_key, item.ID, prizeType);
                    hbStockCountKey = "B200016:" + hbStockCountKey;
                    int hbGrantCount = _eventAwardRecordsRepository.Count(" where MemberLogin=@Memberlogin and ActivityID=@ActID  and ActivityType=@ActivityType and (PrizeType=@PrizeType or  PrizeType=@PrizeType2 )  and AwardSetId = @AwardSetId",
                                                                          new { Memberlogin = item.Memberlogin, ActID = node, ActivityType = activityType, PrizeType = 5, PrizeType2 = 6, AwardSetId = item.ID });
                    int count = Convert.ToInt32(_redisHelper.StringGet(hbStockCountKey));
                    count.ShouldBe(hbGrantCount);
                }
                if (item.ProductID > 0)//产品
                {
                    int    prizeType            = 1;
                    int    activityType         = item.IsSpecial == 0 ? 2 : 3;
                    string productStockCountKey = string.Format(SignKeys.signactprizegrantnum_key, item.ID, prizeType);
                    productStockCountKey = "B200016:" + productStockCountKey;
                    int prizeTypeDB       = 0;
                    int productStockCount = _eventAwardRecordsRepository.Count("where MemberLogin=@Memberlogin and ActivityID=@ActID  and ActivityType=@ActivityType and PrizeType=@PrizeType  and AwardSetId = @AwardSetId",
                                                                               new { Memberlogin = item.Memberlogin, ActID = node, ActivityType = activityType, PrizeType = prizeTypeDB, AwardSetId = item.ID });
                    int count = Convert.ToInt32(_redisHelper.StringGet(productStockCountKey));
                    count.ShouldBe(productStockCount);
                }
            }


            //检查用户数据
            IEnumerable <string> openIdList = _signRecordsRepository
                                              .Query <string>("select distinct  openid  from   SignRecords where  ActivityID=@actID ",
                                                              new { actID = node });

            if (openIdList == null || !openIdList.Any())
            {
                return;                                         //无人参加
            }
            string openid = openIdList.FirstOrDefault();
            List <IEnumerable <object> > queryList2 = _signPointActivityRepository.QueryMultiple(
                "select  *   from   SignRecords where  ActivityID=@actID and Openid=@openId order by ID desc; " +
                "select  *   from   SignSpecialRecords where  ActivityID=@actID and Openid=@openId; " +
                "select  *   from   MemberSignatureCard where  ActivityID=@actID and Openid=@openId; " +
                //"select  *   from   EventAwardRecords where  ActivityID=@actID and Openid=@openId and (ActivityType=@actType or ActivityType=@actSpecialType ",
                "select  *   from   EventAwardRecords where  ActivityID=@actID and Openid=@openId and ActivityType=@actType union  select  *   from   EventAwardRecords where  ActivityID=@actID and Openid=@openId and ActivityType=@actSpecialType ",
                new { actID = node, openId = openid, actType = 2, actSpecialType = 3 }, new Type[] { typeof(SignRecordsDto), typeof(SignSpecialRecordsDto), typeof(MemberSignatureCardDto), typeof(EventAwardRecordsDto) });

            //签到记录
            UserSignActivity userSignMongo = _userSignActRepositoryMongo.FirstOrDefault(UserSignActivity.GetId(openid, signMongo.Id));

            userSignMongo.ShouldNotBeNull();
            if (queryList2[0].Any())
            {
                List <SignRecordsDto> records = new List <SignRecordsDto>();
                foreach (var item in queryList2[0])
                {
                    records.Add((SignRecordsDto)item);
                }
                userSignMongo.SignRecords.Count().ShouldBe(records.Count());
                var recordDB    = records.OrderBy(m => m.Addtime).FirstOrDefault();
                var recordMongo = userSignMongo.SignRecords.OrderBy(t => t.Addtime).FirstOrDefault();
                userSignMongo.Id.ShouldBe(UserSignActivity.GetId(openid, signMongo.Id));
                recordMongo.CustomerID.ShouldBe(recordDB.CustomerID);
                recordMongo.Day.ShouldBe(recordDB.Day);
                recordMongo.IsContinue.ShouldBe(recordDB.IsContinue);
                recordMongo.IsSignature.ShouldBe(recordDB.IsSignature);
                recordMongo.memberlogin.ShouldBe(recordDB.memberlogin);
            }
            //特殊
            if (queryList2[1].Any())
            {
                List <SignSpecialRecordsDto> specials = new List <SignSpecialRecordsDto>();
                foreach (var item in queryList2[1])
                {
                    specials.Add((SignSpecialRecordsDto)item);
                }
                userSignMongo.SignSpecialRecords.Count().ShouldBe(specials.Count);
                var recordDB    = specials.OrderBy(m => m.Addtime).FirstOrDefault();
                var recordMongo = userSignMongo.SignSpecialRecords.OrderBy(t => t.Addtime).FirstOrDefault();
                recordMongo.SpecialSDate.ShouldBe(recordDB.SpecialSDate);
                recordMongo.CustomerID.ShouldBe(recordDB.CustomerID);
            }
            //补签卡
            if (queryList2[2].Any())
            {
                List <MemberSignatureCardDto> cards = new List <MemberSignatureCardDto>();
                foreach (var item in queryList2[2])
                {
                    cards.Add((MemberSignatureCardDto)item);
                }
                userSignMongo.MemberSignatureCard.Count().ShouldBe(cards.Count());
                userSignMongo.MemberSignatureCard.Count(m => m.IsUse == 1).ShouldBe(cards.Count(m => m.IsUse == 1));
            }
            //奖项
            if (queryList2[3].Any())
            {
                List <EventAwardRecordsDto> awards = new List <EventAwardRecordsDto>();
                foreach (var item in queryList2[3])
                {
                    awards.Add((EventAwardRecordsDto)item);
                }
                userSignMongo.EventAwardRecords.Count().ShouldBe(awards.Count());
            }

            //检测完删掉mongodb的测试数据
            //   _signActivityRepository.Delete

            foreach (var user in openIdList)
            {
                _userSignActRepositoryMongo.Delete(UserSignActivity.GetId(user, signMongo.Id));
            }

            _signActivityRepository.Delete(signMongo.Id);


            watch.Stop();
            watch.ElapsedMilliseconds.ShouldBeLessThan(10000);
        }