Пример #1
0
        private void AddRemainSeatData(Blocks blocks)
        {
            CurrentRemainSeats.Clear();

            if (blocks == null || blocks.data == null)
            {
                IsInProgress = false;
                return;
            }

            var remainBlocks = blocks.data.Where(block => block.remainCnt > 0);

            remainBlocks = TargetBlock == "0" ? remainBlocks : remainBlocks.Where(x => x.blockId.ToString() == TargetBlock);
            remainBlocks = TargetGrade == "0" ? remainBlocks : remainBlocks.Where(x => x.gradeId.ToString() == TargetGrade);
            foreach (Block item in remainBlocks)
            {
                RemainSeatData data = new RemainSeatData(TicketBuyExecute);
                data.blockId      = item.blockId;
                data.gradeId      = item.gradeId;
                data.blockName    = _meta.draw.blockInfo.Where(x => x.blockId == item.blockId).Select(x => x.blockName).First();
                data.gradeName    = _grades.Where(x => x.gradeId == item.gradeId)?.Select(x => x.name).FirstOrDefault();
                data.remainCnt    = item.remainCnt;
                data.registerTime = DateTime.Now;

                string[] remainSeats = GetRemainSeatsID(data);
                data.remainSeatsID = remainSeats.Length > 0 ? remainSeats[0] : null;
                for (int i = 1; i < remainSeats.Length; i++)
                {
                    data.remainSeatsID += $", {remainSeats[i]}";
                }

                RemainSeats.Add(data);
                CurrentRemainSeats.Add(data);

                if (AutoPopup && item.remainCnt >= int.Parse(Qty))
                {
                    TicketBuyExecute(data);
                    StopExecute(null);
                    return;
                }
            }
            Console.WriteLine(blocks.result.errorMessage);
        }
Пример #2
0
        private void AddRemainSeatData(Grades grades)
        {
            CurrentRemainSeats.Clear();

            if (grades == null || grades.data == null)
            {
                IsInProgress = false;
                return;
            }

            var remainGrades = grades.data.Where(grade => grade.remainCnt > 0);

            remainGrades = TargetGrade == "0" ? remainGrades : remainGrades.Where(x => x.gradeId.ToString() == TargetGrade);
            foreach (Grade item in remainGrades)
            {
                RemainSeatData data = new RemainSeatData(TicketBuyExecute);
                data.gradeId      = item.gradeId;
                data.remainCnt    = item.remainCnt;
                data.gradeName    = item.name;
                data.registerTime = DateTime.Now;

                string[] remainSeats = GetRemainSeatsID(data);
                data.remainSeatsID = remainSeats[0];
                for (int i = 1; i < remainSeats.Length; i++)
                {
                    data.remainSeatsID += $", {remainSeats[i]}";
                }

                RemainSeats.Add(data);
                CurrentRemainSeats.Add(data);

                if (AutoPopup && item.remainCnt >= int.Parse(Qty))
                {
                    TicketBuyExecute(data);
                    StopExecute(null);
                    return;
                }
            }
            Console.WriteLine(grades.result.errorMessage);
        }