예제 #1
0
        public static string CalculateWinner(string ActivityId = "")
        {
            string result = "0";

            if (Monitor.TryEnter(OneyuanTaoHelp.Calculate))
            {
                try
                {
                    IList <OneyuanTaoInfo> list;
                    if (string.IsNullOrEmpty(ActivityId))
                    {
                        list = new OneyuanTaoDao().GetOneyuanTaoInfoNotCalculate();
                    }
                    else
                    {
                        list = new List <OneyuanTaoInfo>();
                        list.Add(OneyuanTaoHelp.GetOneyuanTaoInfoById(ActivityId));
                    }
                    foreach (OneyuanTaoInfo current in list)
                    {
                        result = "1";
                        if (current.FinishedNum == 0)
                        {
                            OneyuanTaoHelp.SetOneyuanTaoHasCalculate(current.ActivityId);
                        }
                        else if (current.HasCalculate)
                        {
                            result = "success";
                        }
                        else if ((current.ReachType == 1 && current.FinishedNum >= current.ReachNum) || current.ReachType == 2 || (current.ReachType == 3 && current.FinishedNum >= current.ReachNum))
                        {
                            result = OneyuanTaoHelp.DoOneTaoDrawLottery(current);
                        }
                        else
                        {
                            result = "未满足开奖条件,开奖失败";
                            OneyuanTaoHelp.DoOneTaoRefund(current);
                        }
                    }
                }
                catch (Exception var_3_134)
                {
                    result = "0";
                }
                finally
                {
                    Monitor.Exit(OneyuanTaoHelp.Calculate);
                }
            }
            else
            {
                result = "计算工作已启动,请等待计算开奖结果!";
            }
            return(result);
        }
예제 #2
0
 private static void DoOneTaoRefund(OneyuanTaoInfo WItem)
 {
     OneyuanTaoHelp.SetOneyuanTaoHasCalculate(WItem.ActivityId);
 }