private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.btnSave.Content = "修改";
            var awards = service.FindAll();

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < awards.Count; i++)
            {
                var award = awards[i];
                sb.Append(string.Format("{0} {1} {2}\r\n", award.Mark, award.Name, award.Number));
            }
            this.tbAwardList.Text = sb.ToString();
        }
 public IActionResult Get()
 {
     _logger.LogInformation($"{nameof(AwardController)} : {nameof(Get)} was called.");
     try
     {
         var awards = _awardService.FindAll();
         return(Ok(awards));
     }
     catch (DbException exception)
     {
         _logger.LogError(exception.Message);
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         _logger.LogError(exception.Message);
         throw;
     }
 }
        private void Run()
        {
            var awards    = awardService.FindAll();
            var emps      = employeeService.FindAll();
            var awardEmps = awardEmpService.FindAll();

            var showCount = Context.setting.PageShowCount;

            thread = new Thread(() =>
            {
                //开场白
                this.Dispatcher.Invoke(() => { ShowOpening(awards); });

                runStatus = 0;
                wait.WaitOne();

                awardEmpService.Clear();
                var awardIndex = 0;

                do
                {
                    var award = new AwardViewModel(awards[awardIndex]);
                    while (award.CurrentCycle * showCount < award.Number)
                    {
                        award.CurrentCycle++;
                        var gridCount    = showCount;
                        var tmpGridCount = award.Number - (award.CurrentCycle - 1) * showCount;
                        if (tmpGridCount < showCount)
                        {
                            gridCount = tmpGridCount;
                        }

                        this.Dispatcher.Invoke(() =>
                        {
                            this.player.Volume = 0;
                            this.tbAward.Text  = string.Format("{0}      {1}", award.Mark, award.Name);
                            if (award.Number <= showCount)
                            {
                                this.tbAwardTip.Text = string.Format("({0}/{0})", award.Number);
                            }
                            else
                            {
                                this.tbAwardTip.Text = string.Format("第{0}轮({1}~{2}/{3})",
                                                                     award.CurrentCycle,
                                                                     (award.CurrentCycle - 1) * showCount + 1,
                                                                     (award.CurrentCycle - 1) * showCount + gridCount, award.Number);
                            }

                            if (gridCount > 3)
                            {
                                SetGrid((int)Math.Ceiling(gridCount / 2.0), 2, gridCount, true);
                            }
                            else
                            {
                                SetGrid(gridCount, 1, gridCount, true);
                            }
                        });


                        for (var i = 0; i < gridCount; i++)
                        {
                            RemainTimes[i] = Context.setting.IsOneByOne ? (i * showCount + 1) : 1;
                            this.EmpUCs[i].Update(new Employee());
                        }
                        ready_sp.Play();


                        runStatus = 1;
                        wait.WaitOne();
                        runStatus = 2;

                        ready_sp.Stop();
                        going_sp.PlayLooping();

                        isFrushing = true;
                        var t      = new Thread(() =>
                        {
                            while ((runStatus == 2 || runStatus == 3) && RemainTimes.Count(o => o > 0) > 0 && isRunning)
                            {
                                for (var i = 0; i < this.EmpUCs.Count && isRunning; i++)
                                {
                                    if (RemainTimes[i] > 0)
                                    {
                                        var index    = this.random.Next(0, emps.Count);
                                        var employee = emps[index];

                                        this.EmpUCs[i].Update(employee);

                                        if (runStatus == 3)
                                        {
                                            RemainTimes[i]--;
                                        }
                                    }

                                    if (RemainTimes[i] <= 0)
                                    {
                                        var emp = emps.FirstOrDefault(o => o.Id == this.EmpUCs[i].employeeVM.Id);
                                        if (emp != null)
                                        {
                                            awardEmpService.Add(new AwardEmp(0, award.Id, emp.Id));
                                            emps.Remove(emp);
                                        }
                                    }
                                }

                                Thread.Sleep(Context.setting.RefreshInterval);
                            }
                            isFrushing = false;
                        });

                        t.Priority = ThreadPriority.Highest;
                        t.Start();

                        wait.WaitOne();


                        going_sp.Stop();
                        finished_sp.Play();
                        runStatus = 3;
                        wait.WaitOne();

                        finished_sp.Stop();
                        //runStatus = 4;
                    }

                    awardIndex++;
                }while (awardIndex < awards.Count);

                ShowFinalList();
                runStatus = 5;
            });
            thread.Priority = ThreadPriority.Highest;
            thread.Start();
        }