Beispiel #1
0
        //开奖派奖
        private void DrawingLottery(int LotteryID, string IsuseName, string WinNumber)
        {
            Log log = new Log("SystemGetLotteryOpenNumber");

            if (!new SLS.Lottery()[LotteryID].AnalyseWinNumber(WinNumber))
            {
                log.Write("开奖号码不正确!");

                return;
            }

            int    ReturnValue       = 0;
            string ReturnDescription = "";

            DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(conn, "top 1 [ID], IsOpened", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "' and IsOpened=0 and year(StartTime) = YEAR(GETDATE())", "");

            if (dtIsuse == null)
            {
                log.Write("数据读写错误001");

                return;
            }

            if (dtIsuse.Rows.Count <= 0)
            {
                //log.Write("暂无对应期号信息,彩种ID:" + LotteryID.ToString() + ", 期号:" + IsuseName);

                return;
            }

            if (Shove._Convert.StrToBool(dtIsuse.Rows[0]["IsOpened"].ToString(), false))
            {
                //log.Write("彩种ID:" + LotteryID + "第" + IsuseName + "期已开奖");

                return;
            }

            long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1);

            DataTable dtWin = null;

            dtWin = new DAL.Tables.T_Schemes().Open(conn, "ID", "IsuseID = " + IsuseID.ToString() + " and isOpened = 0", "");

            if (dtWin == null)
            {
                log.Write("数据读写错误002");

                return;
            }

            // 准备开奖,开奖之前,对出票不完整的方案进行出票处理
            ReturnValue       = 0;
            ReturnDescription = "";

            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(conn, "[DefaultMoney],[DefaultMoneyNoWithTax]", "LotteryID = " + LotteryID.ToString(), "[Order]");

            if (dtWinTypes == null)
            {
                log.Write("奖金读取数据读写错误");

                return;
            }

            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            for (int y = 0; y < dtWinTypes.Rows.Count; y++)
            {
                WinMoneyList[y * 2]     = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoney"].ToString(), 0);
                WinMoneyList[y * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoneyNoWithTax"].ToString(), 0);

                if (WinMoneyList[y * 2] < 0)
                {
                    log.Write("第 " + (y + 1).ToString() + " 项奖金输入错误!");

                    return;
                }
            }

            dtWin = null;

            #region 开奖第一步

            dtWin = new DAL.Tables.T_Schemes().Open(conn, "LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + IsuseID.ToString(), "[ID]");

            if (dtWin == null)
            {
                log.Write("方案数据读取错误");

                return;
            }

            for (int y = 0; y < dtWin.Rows.Count; y++)
            {
                string LotteryNumber = "";

                try
                {
                    LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString();
                }
                catch
                { }

                string Description       = "";
                double WinMoneyNoWithTax = 0;

                try
                {
                    double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList);

                    if (WinMoney > 0)
                    {
                        log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 中奖金额:" + WinMoney.ToString());
                    }

                    Shove.Database.MSSQL.ExecuteNonQuery(conn, "update T_Schemes set EditWinMoney = @p1, EditWinMoneyNoWithTax = @p2, WinDescription = @p3 where [ID] = " + dtWin.Rows[y]["ID"].ToString(),
                                                         new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p3", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));
                }
                catch
                {
                    log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 开奖号码出现错误");

                    continue;
                }
            }

            #endregion

            log.Write("开奖-----------------------------4");

            #region 开奖第三步

            string OpenAffiche = new OpenAfficheTemplates()[LotteryID];

            int  SchemeCount, QuashCount, WinCount, WinNoBuyCount;
            bool isEndOpen = false;

            while (!isEndOpen)
            {
                SchemeCount   = 0;
                QuashCount    = 0;
                WinCount      = 0;
                WinNoBuyCount = 0;
                //  总方案数,处理时撤单数,中奖数,中奖但未成功数

                ReturnValue       = 0;
                ReturnDescription = "";
                DataSet dsWin = null;

                P_Win(conn, ref dsWin,
                      IsuseID,
                      WinNumber,
                      OpenAffiche,
                      1,
                      true,
                      ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount,
                      ref isEndOpen,
                      ref ReturnValue, ref ReturnDescription);

                if ((dsWin == null) || (ReturnDescription != ""))
                {
                    log.Write(ReturnDescription);

                    return;
                }

                string Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖还未全部完成, 请继续操作第三步。";

                if (isEndOpen)
                {
                    Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖已全部完成。";
                }

                log.Write(String.Format(Message, LotteryID, WinNumber, SchemeCount, QuashCount, WinCount, WinNoBuyCount));
            }

            #endregion

            log.Write("开奖-----------------------------5");
        }
Beispiel #2
0
    public string BindHotAndCoolAndMiss(int sscBuyType)
    {
        //未结束的期
        string    CahceKey = "Lottery_Buy_CQSSC_BindHotAndCoolAndMiss";
        DataTable dt       = Shove._Web.Cache.GetCacheAsDataTable(CahceKey);

        if (dt == null)
        {
            dt = new DAL.Tables.T_Isuses().Open("Top 100 WinLotteryNumber", "LotteryID=28 and IsOpened = 1 and WinLotteryNumber <> ''", "[EndTime] desc");

            Shove._Web.Cache.SetCache(CahceKey, dt, 60);
        }

        string getMissingDetail = string.Empty;

        if (sscBuyType == 0)
        {
            //十位个位的大小单双
            int[] shiDXDS = new int[] { 100, 100, 100, 100 };
            int[] geDXDS  = new int[] { 100, 100, 100, 100 };


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string lostPrieod = dt.Rows[i]["WinLotteryNumber"].ToString().Trim();
                if (lostPrieod.Length != 5)
                {
                    continue;
                }
                int shi = int.Parse(lostPrieod.Substring(3, 1));
                int ge  = int.Parse(lostPrieod.Substring(4, 1));

                //十位大、小没出的期数
                if (shi > 4)
                {
                    if (shiDXDS[0] == 100)
                    {
                        shiDXDS[0] = i;
                    }
                }
                else
                {
                    if (shiDXDS[1] == 100)
                    {
                        shiDXDS[1] = i;
                    }
                }

                //个位大、小没出的期数
                if (ge > 4)
                {
                    if (geDXDS[0] == 100)
                    {
                        geDXDS[0] = i;
                    }
                }
                else
                {
                    if (geDXDS[1] == 100)
                    {
                        geDXDS[1] = i;
                    }
                }

                //十位单、双没出的期数
                if (shi % 2 == 1)
                {
                    if (shiDXDS[2] == 100)
                    {
                        shiDXDS[2] = i;
                    }
                }
                else
                {
                    if (shiDXDS[3] == 100)
                    {
                        shiDXDS[3] = i;
                    }
                }

                //个位单、双没出的期数
                if (ge % 2 == 1)
                {
                    if (geDXDS[2] == 100)
                    {
                        geDXDS[2] = i;
                    }
                }
                else
                {
                    if (geDXDS[3] == 100)
                    {
                        geDXDS[3] = i;
                    }
                }
            }

            getMissingDetail = shiDXDS[0] + ";" + shiDXDS[1] + ";" + shiDXDS[2] + ";" + shiDXDS[3] + ";"
                               + geDXDS[0] + ";" + geDXDS[1] + ";" + geDXDS[2] + ";" + geDXDS[3];
        }
        else
        {
            //百十个位从0到9有多少期没出
            int[] missingNumber = new int[50];
            for (int i = 0; i < missingNumber.Length; i++)
            {
                missingNumber[i] = 100;
            }

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string lostPrieod = dt.Rows[i]["WinLotteryNumber"].ToString().Trim();
                if (lostPrieod.Length != 5)
                {
                    continue;
                }
                int wan  = int.Parse(lostPrieod.Substring(0, 1));
                int qian = int.Parse(lostPrieod.Substring(1, 1));
                int bai  = int.Parse(lostPrieod.Substring(2, 1));
                int shi  = int.Parse(lostPrieod.Substring(3, 1));
                int ge   = int.Parse(lostPrieod.Substring(4, 1));

                for (int j = 0; j <= 9; j++)
                {
                    if (wan == j)
                    {
                        if (missingNumber[j] == 100)
                        {
                            missingNumber[j] = i;
                        }
                    }

                    if (qian == j)
                    {
                        if (missingNumber[10 + j] == 100)
                        {
                            missingNumber[10 + j] = i;
                        }
                    }

                    if (bai == j)
                    {
                        if (missingNumber[20 + j] == 100)
                        {
                            missingNumber[20 + j] = i;
                        }
                    }

                    if (shi == j)
                    {
                        if (missingNumber[30 + j] == 100)
                        {
                            missingNumber[30 + j] = i;
                        }
                    }

                    if (ge == j)
                    {
                        if (missingNumber[40 + j] == 100)
                        {
                            missingNumber[40 + j] = i;
                        }
                    }
                }
            }

            for (int i = 0; i < sscBuyType * 10; i++)
            {
                if (i == sscBuyType * 10 - 1)
                {
                    getMissingDetail = getMissingDetail + missingNumber[(5 - sscBuyType) * 10 + i];
                }
                else
                {
                    getMissingDetail = getMissingDetail + missingNumber[(5 - sscBuyType) * 10 + i] + ";";
                }
            }
        }
        return(getMissingDetail);
    }
Beispiel #3
0
        private void GetLotteryOpenNumber()     //获取开奖号码
        {
            //查询自动开奖的彩种的期号
            DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

            if ((AutomaticOpenLottery == null) || (AutomaticOpenLottery == ""))
            {
                new Log("SystemGetLotteryOpenNumber").Write("没有可自动开奖的彩种");

                return;
            }

            DataTable dt = null;

            try
            {
                dt = t_Isuses.Open(conn, "distinct LotteryID", "LotteryID in (" + AutomaticOpenLottery + ") and LotteryID in (28, 61) and IsOpened = 0 and EndTime < Getdate() and  day(Getdate()) = day(StartTime) and month(getdate()) = MONTH(StartTime) and YEAR(GETDATE()) = YEAR(StartTime) and isnull(WinLotteryNumber, '') = ''", "");
            }
            catch (Exception e)
            {
                new Log("SystemGetLotteryOpenNumber").Write(e.Message);
                return;
            }

            if (dt == null)
            {
                new Log("SystemGetLotteryOpenNumber").Write("数据读取错误." + AutomaticOpenLottery);

                return;
            }

            int LotteryID = -1;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                LotteryID = Shove._Convert.StrToInt(dt.Rows[i]["LotteryID"].ToString(), -1);

                switch (LotteryID)
                {
                case 28:
                    try
                    {
                        GetLotteryOpenNumberForCQSSC(LotteryID);
                    }
                    catch (Exception EM)
                    {
                        new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                        break;
                    }
                    break;

                case 61:
                    try
                    {
                        GetLotteryOpenNumberForJXSSC(LotteryID);
                    }
                    catch (Exception EM)
                    {
                        new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                        break;
                    }
                    break;
                }
            }
        }
Beispiel #4
0
    // 接收奖期通知
    private void IsuseNotice(string TransMessage)
    {
        System.Xml.XmlDocument XmlDoc     = new XmlDocument();
        System.Xml.XmlNodeList nodes      = null;
        System.Xml.XmlNodeList nodesIssue = null;

        try
        {
            XmlDoc.Load(new StringReader(TransMessage));

            nodes      = XmlDoc.GetElementsByTagName("*");
            nodesIssue = XmlDoc.GetElementsByTagName("issue");
        }
        catch { }

        if (nodes == null)
        {
            this.Response.End();

            return;
        }

        DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

        for (int i = 0; i < nodes.Count; i++)
        {
            if (!(nodes[i].Name.ToUpper() == "BODY" && nodes[i].FirstChild.Name.ToUpper() == "ISSUENOTIFY"))
            {
                continue;
            }

            for (int j = 0; j < nodesIssue.Count; j++)
            {
                string IsuseName   = nodesIssue[j].Attributes["number"].Value;
                string LotteryName = nodesIssue[j].Attributes["gameName"].Value;
                string Status      = nodesIssue[j].Attributes["status"].Value;
                string StartTime   = nodesIssue[j].Attributes["startTime"].Value;
                string EndTime     = nodesIssue[j].Attributes["stopTime"].Value;
                int    LotteryID   = GetLotteryID(LotteryName);
                string WinNumber   = "";

                try
                {
                    WinNumber = GetWinNumber(LotteryID, nodesIssue[j].Attributes["bonusCode"].Value);
                }
                catch { }

                if ((LotteryID < 0) || (String.IsNullOrEmpty(IsuseName)))
                {
                    continue;
                }

                if (t_Isuses.GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IsuseName) + "'") < 1)
                {
                    DateTime _StartTime = DateTime.Now;
                    DateTime _EndTime   = DateTime.Now;

                    try
                    {
                        _StartTime = DateTime.Parse(StartTime);
                        _EndTime   = DateTime.Parse(EndTime);
                    }
                    catch
                    {
                        continue;
                    }

                    long   IsuseID           = -1;
                    string ReturnDescription = "";

                    if (DAL.Procedures.P_IsuseAdd(LotteryID, IsuseName, _StartTime, _EndTime, "", ref IsuseID, ref ReturnDescription) < 0)
                    {
                        continue;
                    }

                    if (IsuseID < 0)
                    {
                        continue;
                    }
                }

                DataTable dtIsuse = t_Isuses.Open("ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IsuseName) + "' and LotteryID  in (select id from T_Lotteries where PrintOutType = 104)", "");

                if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
                {
                    continue;
                }

                if (Status == "4")
                {
                    int    ReturnValue      = 0;
                    string ReturnDescprtion = "";

                    if (DAL.Procedures.P_ElectronTicketAgentSchemeQuash(Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), 0), ref ReturnValue, ref ReturnDescprtion) < 0)
                    {
                        new Log("ElectronTicket\\HPSH").Write("电子票方案撤单错误_P_ElectronTicketAgentSchemeQuash");

                        continue;
                    }
                }

                bool isHasUpdate = false;

                if (dtIsuse.Rows[0]["State"].ToString() != Status)
                {
                    isHasUpdate = true;
                }

                if (!String.IsNullOrEmpty(WinNumber) && (dtIsuse.Rows[0]["WinLotteryNumber"].ToString() != WinNumber))
                {
                    if (LotteryID == SLS.Lottery.SHSSL.ID)
                    {
                        DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open("", "LotteryID =" + LotteryID.ToString(), "");

                        double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

                        for (int k = 0; k < dtWinTypes.Rows.Count; k++)
                        {
                            WinMoneyList[k * 2]     = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoney"].ToString(), 1);
                            WinMoneyList[k * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoneyNoWithTax"].ToString(), 1);
                        }

                        DataTable dtChaseTaskDetails = new DAL.Tables.T_ChaseTaskDetails().Open("", "IsuseID=" + dtIsuse.Rows[0]["ID"].ToString() + " and SchemeID IS NOT NULL", "");

                        for (int k = 0; k < dtChaseTaskDetails.Rows.Count; k++)
                        {
                            string LotteryNumber     = dtChaseTaskDetails.Rows[k]["LotteryNumber"].ToString();
                            string Description       = "";
                            double WinMoneyNoWithTax = 0;

                            double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtChaseTaskDetails.Rows[k]["PlayTypeID"].ToString()), WinMoneyList);

                            if (WinMoney < 1)
                            {
                                continue;
                            }

                            int    ReturnValue      = 0;
                            string ReturnDescprtion = "";

                            if (DAL.Procedures.P_ChaseTaskStopWhenWin(Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SiteID"].ToString(), 1), Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SchemeID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescprtion) < 0)
                            {
                                new Log("ElectronTicket\\HPSH").Write("电子票撤销追号错误_P_ChaseTaskStopWhenWin。");
                            }
                        }
                    }
                }

                if (isHasUpdate)
                {
                    int    ReturnValue      = 0;
                    string ReturnDescprtion = "";

                    if (DAL.Procedures.P_IsuseUpdate(LotteryID, Shove._Web.Utility.FilteSqlInfusion(IsuseName), Shove._Convert.StrToShort(Status, 1), Shove._Convert.StrToDateTime(StartTime, DateTime.Now.ToString()), Shove._Convert.StrToDateTime(EndTime, DateTime.Now.ToString()), DateTime.Now, WinNumber, ref ReturnValue, ref ReturnDescprtion) < 0)
                    {
                        new Log("ElectronTicket\\HPSH").Write("电子票撤销追号错误P_IsuseEdit。");
                    }

                    if (ReturnValue < 0)
                    {
                        new Log("ElectronTicket\\HPSH").Write(ReturnDescprtion);
                    }
                }
            }
        }

        string MessageID = nodes[0].Attributes["id"].Value;

        ReNotice(MessageID, "501");
    }
Beispiel #5
0
    //对返回的开奖号码,进行程序自动派奖
    private void BonusQuery(string TransMessage)
    {
        System.Xml.XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(new StringReader(TransMessage));

        System.Xml.XmlNodeList nodes = XmlDoc.GetElementsByTagName("*");

        string WinNumber   = "";
        string Issue       = "";
        string LotteryName = "";

        if (nodes == null)
        {
            return;
        }

        for (int i = 0; i < nodes.Count; i++)
        {
            if (nodes[i].Name.ToUpper() == "BONUSQUERYRESULT")
            {
                WinNumber = nodes[i].Attributes["bonusNumber"].Value.Replace(",", "");
            }

            if (nodes[i].Name.ToUpper() == "ISSUE")
            {
                Issue       = nodes[i].Attributes["number"].Value;
                LotteryName = nodes[i].Attributes["gameName"].Value;
            }
        }

        int LotteryID = GetLotteryID(LotteryName);

        if (LotteryID < 0)
        {
            return;
        }

        DataTable dtIssue = new DAL.Tables.T_Isuses().Open("top 1 *", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(Issue) + "' and isOpened = 0 and EndTime < GetDate()", "");

        if (dtIssue == null)
        {
            new Log("ElectronTicket\\HPCQ").Write("恒朋-重庆电子票网关自动开奖错误,彩种:" + LotteryName + ",期号:" + Issue);

            return;
        }

        if (dtIssue.Rows.Count < 1)
        {
            return;
        }

        // 准备开奖,开奖之前,对出票不完整的方案进行处理(按系统的设定:当作已出票,或者撤单处理)
        //int ReturnValue = 0;
        //string ReturnDescription = "";

        //DAL.Procedures.P_PrintOutNotFullHandle(LotteryID, "请电询", ref ReturnValue, ref ReturnDescription);


        DataTable dtWinMoneyList = new DAL.Tables.T_WinTypes().Open("DefaultMoney, DefaultMoneyNoWithTax", "LotteryID = " + LotteryID.ToString(), "[Order]");

        if (dtWinMoneyList == null)
        {
            new Log("ElectronTicket\\HPCQ").Write("恒朋-重庆电子票网关自动开奖错误,彩种:" + LotteryName + ",期号:" + Issue);

            return;
        }

        double[] WinMoneyList = new double[dtWinMoneyList.Rows.Count * 2];

        for (int i = 0; i < dtWinMoneyList.Rows.Count; i++)
        {
            WinMoneyList[i * 2]     = Shove._Convert.StrToDouble(dtWinMoneyList.Rows[i][0].ToString(), 0);
            WinMoneyList[i * 2 + 1] = Shove._Convert.StrToDouble(dtWinMoneyList.Rows[i][1].ToString(), 0);
        }

        DataTable dtScheme = new DAL.Tables.T_Schemes().Open("", "IsuseID = " + dtIssue.Rows[0]["ID"].ToString() + " and isOpened = 0", "");

        if (dtScheme == null)
        {
            new Log("ElectronTicket\\HPCQ").Write("恒朋-重庆电子票网关自动开奖错误,彩种:" + LotteryName + ",期号:" + Issue);

            return;
        }

        if (dtScheme.Rows.Count > 0)
        {
            for (int i = 0; i < dtScheme.Rows.Count; i++)
            {
                string LotteryNumber     = dtScheme.Rows[i]["LotteryNumber"].ToString();
                string Description       = "";
                double WinMoneyNoWithTax = 0;

                double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtScheme.Rows[i]["PlayTypeID"].ToString()), WinMoneyList);

                Shove.Database.MSSQL.ExecuteNonQuery("update T_Schemes set PreWinMoney = @p1, PreWinMoneyNoWithTax = @p2, EditWinMoney = @p3, EditWinMoneyNoWithTax = @p4, WinDescription = @p5 where [ID] = " + dtScheme.Rows[i]["ID"].ToString(),
                                                     new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtScheme.Rows[i]["Multiple"].ToString(), 1)),
                                                     new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtScheme.Rows[i]["Multiple"].ToString(), 1)),
                                                     new Shove.Database.MSSQL.Parameter("p3", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtScheme.Rows[i]["Multiple"].ToString(), 1)),
                                                     new Shove.Database.MSSQL.Parameter("p4", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtScheme.Rows[i]["Multiple"].ToString(), 1)),
                                                     new Shove.Database.MSSQL.Parameter("p5", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));
            }
        }

        //int SchemeCount = 0, QuashCount = 0, WinCount = 0, WinNoBuyCount = 0;
        //  总方案数,处理时撤单数,中奖数,中奖但未成功数

        //ReturnValue = 0;
        //ReturnDescription = "";

        DataSet ds = null;

        //DAL.Procedures.P_Win(ref ds,
        //     long.Parse(dtIssue.Rows[0]["ID"].ToString()),
        //     WinNumber,
        //     "暂无",
        //     1,
        //     true,
        //     ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount,
        //     ref ReturnValue, ref ReturnDescription);

        //if ((ds == null) || (ReturnDescription != ""))
        //{
        //    PF.GoError(ErrorNumber.DataReadWrite, ReturnDescription, this.GetType().BaseType.FullName);

        //    return;
        //}

        PF.SendWinNotification(ds);
    }
Beispiel #6
0
    // 接收奖期通知
    private void IsuseNotice(string TransMessage)
    {
        System.Xml.XmlDocument XmlDoc = new XmlDocument();

        try
        {
            XmlDoc.Load(new StringReader(TransMessage));
        }
        catch { }

        DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

        string Body = TransMessage.Substring(TransMessage.IndexOf("<elements"), TransMessage.LastIndexOf("</elements>") - TransMessage.IndexOf("<elements")) + "</elements>";

        DataSet ds = new DataSet();

        ds.ReadXml(new StringReader(Body));

        if (ds == null)
        {
            return;
        }

        if (ds.Tables.Count == 0)
        {
            return;
        }

        DataTable dt = ds.Tables[0];

        if (dt.Rows.Count < 1)
        {
            return;
        }

        string MessageID = "";

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow dr = dt.Rows[i];

            string LotteryName = dr["lotteryid"].ToString();
            int    LotteryID   = GetLotteryID(LotteryName);
            string IsuseName   = GetIsusesNameToCaiyou(LotteryID.ToString(), dr["issue"].ToString());
            string Status      = dr["status"].ToString();
            string StartTime   = dr["starttime"].ToString();
            string EndTime     = dr["endtime"].ToString();
            string WinNumber   = "";

            if (Shove._Convert.StrToInt(Status, 0) > 1)
            {
                try
                {
                    WinNumber = GetWinNumber(LotteryID, dr["bonuscode"].ToString());
                }
                catch { }
            }

            if ((LotteryID < 0) || (String.IsNullOrEmpty(IsuseName)))
            {
                continue;
            }

            if (t_Isuses.GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IsuseName) + "' and year(StartTime) = YEAR(GETDATE())") < 1)
            {
                DateTime _StartTime = DateTime.Now;
                DateTime _EndTime   = DateTime.Now;

                try
                {
                    _StartTime = DateTime.Parse(StartTime);
                    _EndTime   = DateTime.Parse(EndTime);
                }
                catch
                {
                    continue;
                }

                long   IsuseID           = -1;
                string ReturnDescription = "";

                if (DAL.Procedures.P_IsuseAdd(LotteryID, IsuseName, _StartTime, _EndTime, "", ref IsuseID, ref ReturnDescription) < 0)
                {
                    continue;
                }

                if (IsuseID < 0)
                {
                    continue;
                }
            }

            DataTable dtIsuse = t_Isuses.Open("ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IsuseName) + "' and year(StartTime) = YEAR(GETDATE())", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                continue;
            }

            if (Status == "1")
            {
                int    ReturnValue      = 0;
                string ReturnDescprtion = "";

                if (DAL.Procedures.P_ElectronTicketAgentSchemeQuash(Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), 0), ref ReturnValue, ref ReturnDescprtion) < 0)
                {
                    new Log("ElectronTicket\\ZCW").Write("电子票方案撤单错误_P_ElectronTicketAgentSchemeQuash");

                    continue;
                }
            }

            bool isHasUpdate = false;

            if (dtIsuse.Rows[0]["State"].ToString() != Status)
            {
                isHasUpdate = true;
            }

            if (isHasUpdate)
            {
                int    ReturnValue      = 0;
                string ReturnDescprtion = "";

                if (DAL.Procedures.P_IsuseUpdate(LotteryID, Shove._Web.Utility.FilteSqlInfusion(IsuseName), Shove._Convert.StrToShort(Status, 0), Shove._Convert.StrToDateTime(StartTime, DateTime.Now.ToString()), Shove._Convert.StrToDateTime(EndTime, DateTime.Now.ToString()), DateTime.Now, WinNumber, ref ReturnValue, ref ReturnDescprtion) < 0)
                {
                    new Log("ElectronTicket\\ZCW").Write("电子票撤销追号错误P_IsuseEdit。");
                }

                if (ReturnValue < 0)
                {
                    new Log("ElectronTicket\\ZCW").Write(ReturnDescprtion);
                }
            }

            if (!String.IsNullOrEmpty(WinNumber) && (dtIsuse.Rows[0]["WinLotteryNumber"].ToString() != WinNumber))
            {
                DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open("", "LotteryID =" + LotteryID.ToString(), "");

                double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

                for (int k = 0; k < dtWinTypes.Rows.Count; k++)
                {
                    if (Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoney"].ToString(), 1) < 1)
                    {
                        MessageID = GetFromXPath(TransMessage, "message/header/messengerid");
                        ReNotice(MessageID, "13008");

                        return;
                    }

                    WinMoneyList[k * 2]     = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoney"].ToString(), 1);
                    WinMoneyList[k * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoneyNoWithTax"].ToString(), 1);
                }

                #region 开奖第一步

                DataTable dtWin = null;

                dtWin = new DAL.Tables.T_Schemes().Open("LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + dtIsuse.Rows[0]["ID"].ToString(), "[ID]");

                if (dtWin == null)
                {
                    return;
                }

                for (int y = 0; y < dtWin.Rows.Count; y++)
                {
                    string LotteryNumber = "";

                    try
                    {
                        LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString();
                    }
                    catch
                    { }

                    string Description       = "";
                    double WinMoneyNoWithTax = 0;

                    try
                    {
                        double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList);

                        Shove.Database.MSSQL.ExecuteNonQuery("update T_Schemes set PreWinMoney = @p1, PreWinMoneyNoWithTax = @p2, EditWinMoney = @p3, EditWinMoneyNoWithTax = @p4, WinDescription = @p5 where [ID] = " + dtWin.Rows[y]["ID"].ToString(),
                                                             new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                             new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                             new Shove.Database.MSSQL.Parameter("p3", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                             new Shove.Database.MSSQL.Parameter("p4", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                             new Shove.Database.MSSQL.Parameter("p5", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));
                    }
                    catch
                    {
                        continue;
                    }
                }

                #endregion

                #region 开奖第二步

                string OpenAffiche = new OpenAfficheTemplates()[LotteryID];

                int  SchemeCount, QuashCount, WinCount, WinNoBuyCount;
                bool isEndOpen = false;

                int    ReturnValue       = 0;
                string ReturnDescription = "";

                while (!isEndOpen)
                {
                    SchemeCount   = 0;
                    QuashCount    = 0;
                    WinCount      = 0;
                    WinNoBuyCount = 0;
                    //  总方案数,处理时撤单数,中奖数,中奖但未成功数

                    ReturnValue       = 0;
                    ReturnDescription = "";
                    DataSet dsWin = null;

                    DAL.Procedures.P_Win(ref dsWin,
                                         Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), 0),
                                         WinNumber,
                                         OpenAffiche,
                                         1,
                                         true,
                                         ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount,
                                         ref isEndOpen,
                                         ref ReturnValue, ref ReturnDescription);
                }

                #endregion
            }
        }

        MessageID = GetFromXPath(TransMessage, "message/header/messengerid");
        ReNotice(MessageID, "13008");
    }
Beispiel #7
0
    private void GetSZPL3Miss()
    {
        string Key = "Home_Room_Buy_GetSZPL3Miss";

        lbMiss.Text = Shove._Web.Cache.GetCacheAsString(Key, "");

        if (lbMiss.Text == "")
        {
            DataTable dt = new DAL.Tables.T_Isuses().Open("top 100 EndTime,WinLotteryNumber", "LotteryID = 63 and GETDATE()>EndTime and ISNULL(WinLotteryNumber,'')<>'' and IsOpened=1", "EndTime desc");

            if (dt == null)
            {
                new Log("System").Write(this.GetType().FullName + "数据库繁忙,请重试(GetSZPL3Miss)");

                return;
            }

            int[,] SZPL3 = new int[3, 10];

            int    Zu3MissCount = 0;
            string WinLotteryNumber;
            int    WinNumber;

            DataRow[] drs = dt.Select("", "EndTime asc");

            foreach (DataRow dr in drs)
            {
                WinLotteryNumber = dr["WinLotteryNumber"].ToString();

                if (WinLotteryNumber.Length != 3)
                {
                    continue;
                }

                for (int i = 0; i < WinLotteryNumber.Length; i++)
                {
                    WinNumber = Shove._Convert.StrToInt(WinLotteryNumber.Substring(i, 1), 0);

                    for (int j = 0; j < 10; j++)
                    {
                        if (j == WinNumber)
                        {
                            SZPL3[i, j] = 0;
                        }
                        else
                        {
                            SZPL3[i, j]++;
                        }
                    }
                }
            }

            drs = dt.Select("1=1", "EndTime desc");

            foreach (DataRow dr in drs)
            {
                if (FilterRepeated(dr["WinLotteryNumber"].ToString()).Length == 2)
                {
                    break;
                }

                Zu3MissCount++;
            }

            lbMiss.Text = GetSZPL3Miss(SZPL3) + "|" + Zu3MissCount.ToString();

            Shove._Web.Cache.SetCache(Key, lbMiss.Text, 600);
        }
    }
Beispiel #8
0
        //向大赢家出票接口发送票  发送类型110(发送开奖号码请求)
        private void Send()
        {
            DataTable          SiteLoID           = new DAL.Tables.T_Lotteries().Open("[ID]", "[ID] in (2,3,5,6,9,13,15,28,29,39,61,63,64,65,70,74,75)", "[Order]");
            ElectronTicket_BLL ElectronTicket_BLL = new ElectronTicket_BLL();

            for (int i = 0; i < SiteLoID.Rows.Count; i++)
            {
                DataTable dt = GetIsusesInfo(SiteLoID.Rows[i]["ID"].ToString());
                if (dt.Rows.Count > 0)
                {
                    //上期期信息(未开奖)
                    string LastIsuseName = null;
                    string LastLotteryID = null;
                    string wMsgID        = null;
                    try
                    {
                        LastIsuseName = dt.Rows[0]["Name"].ToString();
                        LastLotteryID = dt.Rows[0]["LotteryID"].ToString();
                        wMsgID        = dt.Rows[0]["ID"].ToString();;
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    //wAgent=3821&wAction=110&wMsgID=1238494210&wSign=b7c289e65e00f5fb834f338e6b753e44&wParam=LotID=11_LotIssue=2008001
                    //wAgent+wAction+wMsgID+wParam+代理商密钥
                    string wParamStr = "";
                    string wSignStr  = "";

                    try
                    {
                        wParamStr = "LotID=" + ElectronTicket_BLL.GetLotteryID(LastLotteryID) + "_LotIssue=" + ElectronTicket_BLL.GetIsuse(Convert.ToInt32(LastLotteryID), LastIsuseName) + "";
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    try
                    {
                        wSignStr = Shove._Security.Encrypt.MD5(ElectronTicket_Agent_UserNumber + "110" + wMsgID + wParamStr + ElectronTicket_Agent_Key + "", "gb2312");
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }

                    string ReceiveString = "";
                    try
                    {
                        //log.Write(ElectronTicket_Getway + "wAgent=" + ElectronTicket_Agent_UserNumber + "&wAction=110&wMsgID=" + wMsgID + "&wSign=" + wSignStr + "&wParam=" + wParamStr);
                        System.Threading.Thread.Sleep(500);
                        ReceiveString = PublicFunction.Post(ElectronTicket_Getway, "wAgent=" + ElectronTicket_Agent_UserNumber + "&wAction=110&wMsgID=" + wMsgID + "&wSign=" + wSignStr + "&wParam=" + wParamStr + "", TimeoutSeconds);
                    }
                    catch
                    {
                        msg.Send("获取开奖号-110 发送失败");
                        log.Write("获取开奖号-110 发送失败");
                        continue;
                    }

                    // log.Write(ReceiveString);
                    System.Threading.Thread.Sleep(500);
                    string code = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xCode");
                    if (code == "0")
                    {
                        string xValue  = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xValue");
                        string IsuseID = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xMsgID");
                        var    arrInfo = xValue.Split('_');
                        DAL.Tables.T_Isuses T_Isuses = new DAL.Tables.T_Isuses();
                        T_Isuses.WinLotteryNumber.Value = arrInfo[1];

                        if (T_Isuses.Update("[ID] = " + IsuseID) < 0)
                        {
                            msg.Send("自动录入开奖号码失败 彩种ID:" + IsuseID);
                            log.Write("自动录入开奖号码失败 彩种ID:" + IsuseID);
                            continue;
                        }
                    }
                }
                continue;
            }
        }
Beispiel #9
0
        private void GetSprize(string IsuseID, string Transmessage)
        {
            System.Xml.XmlDocument XmlDoc = new XmlDocument();
            XmlDoc.Load(new StringReader(Transmessage));

            System.Xml.XmlNodeList nodes = XmlDoc.GetElementsByTagName("*");
            System.Xml.XmlNodeList nodesBonusItem = XmlDoc.GetElementsByTagName("bonusItem");
            System.Xml.XmlNodeList nodesIssue = XmlDoc.GetElementsByTagName("issue");

            string code = "";

            if (nodes == null)
            {
                return;
            }

            string BonusNumber = "";

            for (int j = 0; j < nodes.Count; j++)
            {
                if (nodes[j].Name.ToUpper() == "RESPONSE")
                {
                    code = nodes[j].Attributes["code"].Value;
                }

                if (nodes[j].Name.ToUpper() != "BONUSQUERYRESULT")
                {
                    continue;
                }

                BonusNumber = nodes[j].Attributes["bonusNumber"].InnerText;

            }

            if (code != "0000")
            {
                return;
            }

            if (nodesIssue == null)
            {
                return;
            }

            string number = nodesIssue[0].Attributes["number"].Value;
            string LotteryName = nodesIssue[0].Attributes["gameName"].Value;

            int LotteryID = GetLotteryID(LotteryName);
            string WinNumber = GetWinNumber(LotteryID, BonusNumber);

            DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(ConnectionString, "", "[ID] = " + IsuseID + " and [Name] = '" + number + "' and LotteryID = " + LotteryID.ToString() + " and IsOpened = 0", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                return;
            }

            DAL.Tables.T_Isuses T_Isuses = new DAL.Tables.T_Isuses();

            T_Isuses.WinLotteryNumber.Value = WinNumber;
            T_Isuses.OpenOperatorID.Value = 1;
            T_Isuses.Update(ConnectionString, "[ID] = " + IsuseID + " and [Name] = '" + number + "' and LotteryID = " + LotteryID.ToString());

            DataTable dtWinTypesSSL = new DAL.Tables.T_WinTypes().Open(ConnectionString, "", " LotteryID =" + LotteryID.ToString(), "");

            if ((dtWinTypesSSL != null) && dtWinTypesSSL.Rows.Count > 0)
            {
                double[] WinMoneyListSSL = new double[dtWinTypesSSL.Rows.Count * 2];

                double DefaultMoneySSL = 0;
                double DefaultMoneyNoWithTaxSSL = 0;

                for (int i = 0; i < dtWinTypesSSL.Rows.Count; i++)
                {
                    DefaultMoneySSL = Shove._Convert.StrToDouble(dtWinTypesSSL.Rows[i]["DefaultMoney"].ToString(), 0);
                    DefaultMoneyNoWithTaxSSL = Shove._Convert.StrToDouble(dtWinTypesSSL.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                    WinMoneyListSSL[i * 2] = DefaultMoneySSL == 0 ? 1 : DefaultMoneyNoWithTaxSSL;
                    WinMoneyListSSL[i * 2 + 1] = DefaultMoneyNoWithTaxSSL == 0 ? 1 : DefaultMoneyNoWithTaxSSL;
                }

                DataTable t_dtSchemes = new DAL.Tables.T_Schemes().Open(ConnectionString, "", "IsuseID = " + IsuseID + " and WinMoney = 0 and Buyed =1 and  isnull(Identifiers, '') = ''", "");

                string t_LotteryNumber = "";
                SLS.Lottery.LotteryBase t_lb = new SLS.Lottery()[LotteryID];

                string t_Description = "";
                double t_WinMoneyNoWithTax = 0;

                for (int i = 0; i < t_dtSchemes.Rows.Count; i++)
                {
                    t_LotteryNumber = t_dtSchemes.Rows[i]["LotteryNumber"].ToString();
                    t_Description = "";
                    t_WinMoneyNoWithTax = 0;

                    double WinMoney = t_lb.ComputeWin(t_LotteryNumber, WinNumber.Trim(), ref t_Description, ref t_WinMoneyNoWithTax, int.Parse(t_dtSchemes.Rows[i]["PlayTypeID"].ToString()), WinMoneyListSSL);

                    if (WinMoney > 0)
                    {
                        Shove.Database.MSSQL.ExecuteNonQuery(ConnectionString, "update T_Schemes set PreWinMoney = @p1, PreWinMoneyNoWithTax = @p2, WinMoney = @p3, WinMoneyNoWithTax = @p4, WinDescription = @p5 where [ID] = " + t_dtSchemes.Rows[i]["ID"].ToString(),
                            new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, t_WinMoneyNoWithTax * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p3", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p4", SqlDbType.Money, 0, ParameterDirection.Input, t_WinMoneyNoWithTax * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p5", SqlDbType.VarChar, 0, ParameterDirection.Input, t_Description));

                        continue;
                    }
                }
            }

            string BonusXML = "<Schemes>";

            if ((nodesBonusItem != null) && (nodesBonusItem.Count > 0))
            {
                string bonusItemXML = Transmessage.Substring(Transmessage.IndexOf("<bonusQueryResult"), Transmessage.LastIndexOf("</response>") - Transmessage.IndexOf("<bonusQueryResult"));
                DataSet dsXML = new DataSet();

                try
                {
                    dsXML.ReadXml(new StringReader(bonusItemXML));
                }
                catch (Exception e)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期解析开奖数据错误:" + e.Message);

                    return;
                }

                if ((dsXML == null) || (dsXML.Tables.Count < 3))
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期开奖数据格式不符合要求。");

                    return;
                }

                DataTable dtTickets = dsXML.Tables[2];
                DataTable dtSchemes = MSSQL.Select(ConnectionString, "SELECT SchemeID, 0 AS AgentID, SchemesMultiple as Multiple, Identifiers FROM V_SchemesSendToCenter WHERE (IsuseID = " + IsuseID + ")");

                if (dtSchemes == null)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期,读取本地方案错误。");

                    return;
                }

                try
                {
                    var query1 = from NewDtTickets in dtTickets.AsEnumerable()
                                 join NewdtScheme in dtSchemes.AsEnumerable()
                                 on NewDtTickets.Field<string>("ticketID") equals NewdtScheme.Field<string>("Identifiers")
                                 select new
                                 {
                                     ID = NewdtScheme.Field<long>("SchemeID"),
                                     AgentID = NewdtScheme.Field<long>("AgentID"),
                                     Multiple = NewdtScheme.Field<int>("Multiple"),
                                     Bonus = Shove._Convert.StrToDouble(NewDtTickets.Field<string>("money"), 0),
                                     BonusLevel = NewDtTickets.Field<string>("bonusLevel"),
                                     Size = Shove._Convert.StrToInt(NewDtTickets.Field<string>("size"), 1)
                                 };

                    var query2 = from NewDt in query1.AsQueryable()
                                 group NewDt by new { NewDt.ID, NewDt.BonusLevel, NewDt.AgentID, NewDt.Multiple } into gg
                                 select new
                                 {
                                     ID = gg.Key.ID,
                                     AgentID = gg.Key.AgentID,
                                     Multiple = gg.Key.Multiple,
                                     Bonus = gg.Sum(NewDt => NewDt.Bonus),
                                     BonusLevel = GetSchemeWinDescription(gg.Key.BonusLevel, LotteryID, (gg.Sum(NewDt => NewDt.Size) / gg.Key.Multiple))
                                 };

                    var query3 = from NewDt in query2.AsQueryable()
                                 group NewDt by new { NewDt.ID, NewDt.Multiple, NewDt.AgentID } into t_dtSchemes
                                 select new
                                 {
                                     SchemeID = t_dtSchemes.Key.ID,
                                     AgentID = t_dtSchemes.Key.AgentID,
                                     Multiple = t_dtSchemes.Key.Multiple,
                                     Bonus = t_dtSchemes.Sum(NewDt => NewDt.Bonus),
                                     BonusLevel = t_dtSchemes.Merge(NewDt => NewDt.BonusLevel) + ((t_dtSchemes.Key.Multiple != 1) ? "(" + t_dtSchemes.Key.Multiple.ToString() + "倍)" : "")
                                 };

                    foreach (var Scheme in query3)
                    {
                            BonusXML += "<Scheme SchemeID=\"" + Scheme.SchemeID.ToString() + "\" WinMoney=\"" + Scheme.Bonus.ToString() + "\" WinDescription=\"" + Scheme.BonusLevel + "\" />";
                    }
                }
                catch (Exception e)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期详细中奖数据解析错误:" + e.Message);

                    return;
                }
            }

            BonusXML += "</Schemes>";

            dtIsuse = new DAL.Tables.T_Isuses().Open(ConnectionString, "", "[ID] = " + IsuseID + " and IsOpened = 0", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                return;
            }

            int ReturnValue = 0;
            string ReturnDescription = "";

            DataSet ds = null;
            int Times = 0;
            int Result = -1;

            while ((Result < 0) && (Times < 5))
            {
                ReturnValue = 0;
                ReturnDescription = "";

                Result = DAL.Procedures.P_ElectronTicketWin(ConnectionString, ref ds, Shove._Convert.StrToLong(IsuseID, 0), BonusXML, ref ReturnValue, ref ReturnDescription);

                if (Result < 0)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票第 " + (Times + 1).ToString() + " 次派奖出现错误(IsuseOpenNotice) 期号为: " + number + ",彩种为: " + LotteryID.ToString());
                    Times++;

                    if (Times < 5)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }

                    continue;
                }
            }

            if (ReturnValue < 0)
            {
                log.Write(ReturnDescription);

                return;
            }

            //PublicFunction.SendWinNotification(ds);

            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(ConnectionString, "", " LotteryID =" + LotteryID.ToString(), "");

            if ((dtWinTypes == null) || dtWinTypes.Rows.Count < 1)
            {
                msg.Send("执行电子票--获取彩种: " + LotteryID.ToString() + ",奖金等级时出现错误!");
                log.Write("执行电子票--获取彩种: " + LotteryID.ToString() + ",奖金等级时出现错误!");

                return;
            }

            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            double DefaultMoney = 0;
            double DefaultMoneyNoWithTax = 0;

            for (int i = 0; i < dtWinTypes.Rows.Count; i++)
            {
                DefaultMoney = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoney"].ToString(), 0);
                DefaultMoneyNoWithTax = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                WinMoneyList[i * 2] = DefaultMoney == 0 ? 1 : DefaultMoneyNoWithTax;
                WinMoneyList[i * 2 + 1] = DefaultMoneyNoWithTax == 0 ? 1 : DefaultMoneyNoWithTax;
            }

            DataTable dtSchemesWithTaskDetails = new DAL.Views.V_Schemes().Open(ConnectionString, "", " IsuseName = '" + number + "' and LotteryID = " + LotteryID.ToString() + " and WinMoney = 0  and Buyed = 0 and ID in ( select ID from V_ChaseTaskDetails where IsuseName = '" + number + "' and LotteryID = " + LotteryID.ToString() + ")", "");

            string LotteryNumber = "";
            SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

            string Description = "";
            double WinMoneyNoWithTax = 0;

            for (int i = 0; i < dtSchemesWithTaskDetails.Rows.Count; i++)
            {
                LotteryNumber = dtSchemesWithTaskDetails.Rows[i]["LotteryNumber"].ToString();

                Description = "";
                WinMoneyNoWithTax = 0;

                double WinMoney = lb.ComputeWin(LotteryNumber, WinNumber.Trim(), ref Description, ref WinMoneyNoWithTax, int.Parse(dtSchemesWithTaskDetails.Rows[i]["PlayTypeID"].ToString()), WinMoneyList);

                if (WinMoney > 0)
                {
                    if (DAL.Procedures.P_ChaseTaskStopWhenWin(ConnectionString, Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["SiteID"].ToString(), 0), Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["ID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescription) < 0)
                    {
                        msg.Send("执行电子票--判断是否停止追号的时候出现错误");
                        log.Write("执行电子票--判断是否停止追号的时候出现错误");

                        continue;
                    }
                }
            }
        }
Beispiel #10
0
    //中奖明细对账文件生成通知
    private void AwardResultNotice(string TransMessage)
    {
        System.Xml.XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(new StringReader(TransMessage));

        string elements = TransMessage.Substring(TransMessage.IndexOf("<body"), TransMessage.LastIndexOf("</body>") - TransMessage.IndexOf("<body")) + "</body>";

        DataSet ds = new DataSet();

        ds.ReadXml(new StringReader(elements));

        if (ds == null)
        {
            return;
        }

        if (ds.Tables.Count == 0)
        {
            return;
        }

        DataTable dtFile = ds.Tables[0];

        if (dtFile.Rows.Count < 1)
        {
            return;
        }

        int    LotteryID = 0;
        string IssueName = "";
        string FileName  = "";

        string Body = "";

        DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

        string BonusXML      = "<Schemes>";
        string AgentBonusXML = "<Schemes>";


        DataTable dtIsuse = null;

        foreach (DataRow dr in dtFile.Rows)
        {
            LotteryID = GetLotteryID(dr["lotteryId"].ToString());
            IssueName = dr["issue"].ToString();
            FileName  = dr["fileName"].ToString();

            if (t_Isuses.GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "' and year(getdate()) = year(StartTime) and LotteryID  in (select id from T_Lotteries where PrintOutType = 108)") < 1)
            {
                continue;
            }

            dtIsuse = t_Isuses.Open("ID, StartTime, EndTime, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IssueName) + "' and LotteryID  in (select id from T_Lotteries where PrintOutType = 108) and year(getdate()) = year(StartTime) and IsOpened = 0", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                continue;
            }

            string DownLoadFileNameUrl = ElectronTicket_CTTCSD_DownloadGetway + "/" + ElectronTicket_CTTCSD_UserName + "/" + dr["lotteryId"].ToString() + "/Award/" + FileName;

            string Html = PF.GetHtml(DownLoadFileNameUrl, "utf-8", 120);

            if (Html == "")
            {
                Body = "<body><result>100004</result></body>";

                new Log("ElectronTicket\\CTTCSD").Write("没有获取到中奖信息:期号为:" + IssueName);
            }

            if (Html.IndexOf("<body/>") >= 0)
            {
                continue;
            }

            elements = Html.Substring(Html.IndexOf("<head>"), Html.LastIndexOf("</body>") - Html.IndexOf("<head>")) + "</body>";

            DataSet ds1 = new DataSet();

            ds1.ReadXml(new StringReader(Html));

            if (ds1 == null)
            {
                Body = "<body><result>100004</result></body>";

                new Log("ElectronTicket\\CTTCSD").Write("中奖文件获取异常:读取内容为:" + Html);

                continue;
            }

            if (Shove._Security.Encrypt.MD5(elements).ToLower() != ds1.Tables[0].Rows[0]["sign"].ToString().ToLower())
            {
                Body = "<body><result>100004</result></body>";

                new Log("ElectronTicket\\CTTCSD").Write("校验错误:" + Shove._Security.Encrypt.MD5(elements).ToLower() + "----------" + ds1.Tables[0].Rows[0]["sign"].ToString().ToLower());

                continue;
            }

            DataTable dtTicket = ds1.Tables[ds1.Tables.Count - 1];

            if (dtTicket.Rows.Count < 1)
            {
                Body = "<body><result>0</result></body>";

                continue;
            }

            LotteryID = GetLotteryID(ds1.Tables[1].Rows[0]["lotteryId"].ToString());
            IssueName = ds1.Tables[1].Rows[0]["issue"].ToString();

            string[] StrTickets = null;

            DataTable dtTicketTemp = new DataTable();

            dtTicketTemp.Columns.Add("ID", typeof(System.String));
            dtTicketTemp.Columns.Add("AwardValue", typeof(System.String));

            DataRow drTicketTemp = null;

            foreach (DataRow drTicket in dtTicket.Rows)
            {
                StrTickets = drTicket[0].ToString().Split(',');

                if (StrTickets.Length != 7)
                {
                    continue;
                }

                drTicketTemp = dtTicketTemp.NewRow();

                drTicketTemp["ID"]         = StrTickets[0].ToString();
                drTicketTemp["AwardValue"] = StrTickets[3].ToString().Insert(StrTickets[3].ToString().Length - 2, ".");

                dtTicketTemp.Rows.Add(drTicketTemp);
                dtTicketTemp.AcceptChanges();
            }

            DataTable dtSchemes = MSSQL.Select("SELECT SchemeID, SchemesMultiple as Multiple, Identifiers FROM V_SchemesSendToCenter WHERE (IsuseID = " + dtIsuse.Rows[0]["ID"].ToString() + ")");

            if (dtSchemes == null)
            {
                new Log("ElectronTicket\\CTTCSD").Write("电子票开奖,第 " + IssueName + " 期,读取本地方案错误。");

                this.Response.End();

                return;
            }

            try
            {
                var query1 = from NewDtTickets in dtTicketTemp.AsEnumerable()
                             join NewdtScheme in dtSchemes.AsEnumerable()
                             on NewDtTickets.Field <string>("ID") equals NewdtScheme.Field <string>("Identifiers")
                             select new
                {
                    ID       = NewdtScheme.Field <long>("SchemeID"),
                    Multiple = NewdtScheme.Field <int>("Multiple"),
                    Bonus    = Shove._Convert.StrToDouble(NewDtTickets.Field <string>("AwardValue"), 0)
                };

                var query2 = from NewDt in query1.AsQueryable()
                             group NewDt by new { NewDt.ID, NewDt.Multiple } into gg
                    select new
                {
                    ID       = gg.Key.ID,
                    Multiple = gg.Key.Multiple,
                    Bonus    = gg.Sum(NewDt => NewDt.Bonus)
                };

                var query3 = from NewDt in query2.AsQueryable()
                             group NewDt by new { NewDt.ID, NewDt.Multiple } into t_dtSchemes
                    select new
                {
                    SchemeID = t_dtSchemes.Key.ID,
                    Multiple = t_dtSchemes.Key.Multiple,
                    Bonus    = t_dtSchemes.Sum(NewDt => NewDt.Bonus)
                };

                foreach (var Scheme in query3)
                {
                    BonusXML += "<Scheme SchemeID=\"" + Scheme.SchemeID.ToString() + "\" WinMoney=\"" + Scheme.Bonus.ToString() + "\" WinDescription=\"\" />";
                }
            }
            catch (Exception e)
            {
                new Log("ElectronTicket\\CTTCSD").Write("电子票开奖,第 " + IssueName + " 期详细中奖数据解析错误:" + e.Message);

                this.Response.End();

                return;
            }
        }

        BonusXML      += "</Schemes>";
        AgentBonusXML += "</Schemes>";

        if (dtIsuse.Rows.Count > 0)
        {
            int    ReturnValue       = 0;
            string ReturnDescription = "";

            int Times  = 0;
            int Result = -1;

            while ((Result < 0) && (Times < 5))
            {
                ReturnValue       = 0;
                ReturnDescription = "";

                Result = DAL.Procedures.P_ElectronTicketWin(Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), 0), BonusXML, AgentBonusXML, ref ReturnValue, ref ReturnDescription);

                if (Result < 0)
                {
                    new Log("ElectronTicket\\CTTCSD").Write("电子票第 " + (Times + 1).ToString() + " 次派奖出现错误(IsuseOpenNotice) 期号为: " + IssueName + ",彩种为: " + LotteryID.ToString());
                    Times++;

                    if (Times < 5)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }

                    continue;
                }
            }

            if (ReturnValue < 0)
            {
                new Log("ElectronTicket\\CTTCSD").Write("电子票派奖出现错误(IsuseOpenNotice) 期号为: " + IssueName + ",彩种为: " + LotteryID.ToString() + ",错误:" + ReturnDescription);

                this.Response.End();

                return;
            }
        }

        if (string.IsNullOrEmpty(Body))
        {
            Body = "<body><result>0</result></body>";
        }

        ReNotice("1301", Body);
    }
Beispiel #11
0
        private void WinScoreScale()
        {
            DataTable dt = MSSQL.Select(ConnectionString, "select id, PlayTypeID, WinMoney, LotteryNumber, IsuseID, Multiple from T_Schemes where not exists (select 1 from T_SchemeIsCalcuteScore where ScoreType = 2 and T_Schemes.ID = T_SchemeIsCalcuteScore.SchemeID) and ID > isnull((select max(SchemeID) - 10000 from T_SchemeIsCalcuteScore where ScoreType = 2), 0) and exists (select 1 from T_Isuses where LotteryID in (6, 28, 29, 60, 61, 62, 63, 64, 68, 70) and T_Isuses.ID = T_Schemes.IsuseID) and isOpened = 1 order by IsuseID desc");

            if (dt == null)
            {
                log.Write("Exec WinScoreScale: DataTable \"WinScoreScale\" Fail.");

                return;
            }

            if (dt.Rows.Count < 1)
            {
                return;
            }

            DAL.Tables.T_SchemeIsCalcuteScore t_SchemeIsCalcuteScore = new DAL.Tables.T_SchemeIsCalcuteScore();

            DataTable dtIsuses = null;
            DataTable dtWinMoney = null;

            foreach (DataRow dr in dt.Rows)
            {
                if (Shove._Convert.StrToDouble(dr["WinMoney"].ToString(), 0) == 0)
                {
                    t_SchemeIsCalcuteScore.SchemeID.Value = dr["ID"].ToString();
                    t_SchemeIsCalcuteScore.ScoreType.Value = 2;
                    t_SchemeIsCalcuteScore.Insert(ConnectionString);

                    continue;
                }

                dtIsuses = new DAL.Tables.T_Isuses().Open(ConnectionString, "WinLotteryNumber, LotteryID", "ID=" + dr["IsuseID"].ToString(), "");

                if (dtIsuses == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"T_Isuses\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

                if (dtIsuses.Rows.Count < 1)
                {
                    continue;
                }

                dtWinMoney = MSSQL.Select(ConnectionString, "select DefaultMoney * a.ScoreScale as DefaultMoney, DefaultMoneyNoWithTax * a.ScoreScale as DefaultMoneyNoWithTax, a.WinMoney as WinMoney from T_WinTypes inner join T_WinScoreScale a on T_WinTypes.ID = a.WinTypeID where exists (select * from T_PlayTypes where ID = " + dr["PlayTypeID"].ToString() + " and T_WinTypes.LotteryID = T_PlayTypes.LotteryID)  order by [Order]");

                if (dtWinMoney == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"dtWinMoney\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

                if (dtWinMoney.Rows.Count < 1)
                {
                    continue;
                }

                double[] WinMoneyList = new double[dtWinMoney.Rows.Count * 2];

                double MaxMoney = 0;

                for (int i = 0; i < dtWinMoney.Rows.Count; i++)
                {
                    WinMoneyList[i * 2] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoney"].ToString(), 0);
                    WinMoneyList[i * 2 + 1] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                    if (Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0) > MaxMoney)
                    {
                        MaxMoney = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0);
                    }
                }

                string LotteryNumber = dr["LotteryNumber"].ToString();
                string Description = "";

                double WinMoneyNoWithTax = 0;
                double WinMoney = 0;

                try
                {
                    WinMoney = new SLS.Lottery()[int.Parse(dtIsuses.Rows[0]["LotteryID"].ToString())].ComputeWin(LotteryNumber, dtIsuses.Rows[0]["WinLotteryNumber"].ToString(), ref Description, ref WinMoneyNoWithTax, int.Parse(dr["PlayTypeID"].ToString()), WinMoneyList);
                }
                catch
                {
                    WinMoney = 0;
                }

                log.Write("方案号:" + dr["ID"].ToString() + "-------中奖金额:" + (Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney).ToString() + "-----------最大金额:" + MaxMoney.ToString());

                if (DAL.Procedures.P_SchemeWinCalculatedScore(ConnectionString, Shove._Convert.StrToLong(dr["ID"].ToString(), 0), Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney, MaxMoney) < 0)
                {
                    log.Write("Exec WinScoreScale: Procedures \"P_SchemeWinCalculatedScore\" Fail.");

                    continue;
                }
            }

        #endregion
        }
Beispiel #12
0
    //投注结果对账文件生成通知
    private void BetResultNotice(string TransMessage)
    {
        System.Xml.XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(new StringReader(TransMessage));

        string elements = TransMessage.Substring(TransMessage.IndexOf("<body"), TransMessage.LastIndexOf("</body>") - TransMessage.IndexOf("<body")) + "</body>";

        DataSet ds = new DataSet();

        ds.ReadXml(new StringReader(elements));

        if (ds == null)
        {
            return;
        }

        if (ds.Tables.Count == 0)
        {
            return;
        }

        DataTable dtFile = ds.Tables[0];

        if (dtFile.Rows.Count < 1)
        {
            return;
        }

        int    LotteryID = 0;
        string IssueName = "";
        string FileName  = "";

        string Body = "";

        DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

        foreach (DataRow dr in dtFile.Rows)
        {
            LotteryID = GetLotteryID(dr["lotteryId"].ToString());
            IssueName = dr["issue"].ToString();
            FileName  = dr["fileName"].ToString();

            if (t_Isuses.GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "' and year(getdate()) = year(StartTime) and LotteryID  in (select id from T_Lotteries where PrintOutType = 108)") < 1)
            {
                continue;
            }

            DataTable dtIsuse = t_Isuses.Open("ID, StartTime, EndTime, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IssueName) + "' and LotteryID  in (select id from T_Lotteries where PrintOutType = 108) and year(getdate()) = year(StartTime)", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                continue;
            }

            string DownLoadFileNameUrl = ElectronTicket_CTTCSD_DownloadGetway + "/" + ElectronTicket_CTTCSD_UserName + "/" + dr["lotteryId"].ToString() + "/" + "Reports/" + FileName;

            string Html = PF.GetHtml(DownLoadFileNameUrl, "utf-8", 120);

            if (Html == "")
            {
                Body = "<body><result>100004</result></body>";
            }

            elements = Html.Substring(Html.IndexOf("<head>"), Html.LastIndexOf("</body>") - Html.IndexOf("<head>")) + "</body>";

            ds = new DataSet();

            ds.ReadXml(new StringReader(Html));

            if (ds == null)
            {
                Body = "<body><result>100004</result></body>";

                continue;
            }

            if (ds.Tables.Count != 4)
            {
                Body = "<body><result>100004</result></body>";

                continue;
            }

            if (Shove._Security.Encrypt.MD5(elements) != ds.Tables[0].Rows[0]["sign"].ToString())
            {
                Body = "<body><result>100004</result></body>";

                continue;
            }

            DataTable dtTicket = ds.Tables[3];

            if (dtTicket.Rows.Count < 1)
            {
                Body = "<body><result>0</result></body>";

                continue;
            }

            LotteryID = GetLotteryID(ds.Tables[1].Rows[0]["lotteryId"].ToString());
            IssueName = ds.Tables[1].Rows[0]["issue"].ToString();

            string[] StrTickets = null;
            string   TicketID   = "";

            foreach (DataRow drTicket in dtTicket.Rows)
            {
                StrTickets = drTicket[0].ToString().Split(',');

                if (StrTickets.Length != 8)
                {
                    continue;
                }

                TicketID = StrTickets[0].ToString();

                int    ReturnValue       = 0;
                string ReturnDescription = "";

                int Result = DAL.Procedures.P_SchemesSendToCenterHandle(TicketID, DateTime.Now, true, "", ref ReturnValue, ref ReturnDescription);

                if ((Result < 0) || ((ReturnValue < 0) && (ReturnValue != -2)))
                {
                    new Log("ElectronTicket\\CTTCSD").Write("对彩通天成电子票网所发送的电子票数据处理出错:部分票更新错误。票号:" + TicketID.ToString());

                    continue;
                }
            }
        }

        if (string.IsNullOrEmpty(Body))
        {
            Body = "<body><result>0</result></body>";
        }

        ReNotice("1300", Body);
    }
Beispiel #13
0
    //对开奖号码通知进行处理
    private void ReceiveWinNumberNotice(string TransMessage)
    {
        string elements = TransMessage.Substring(TransMessage.IndexOf("<body"), TransMessage.LastIndexOf("</body>") - TransMessage.IndexOf("<body")) + "</body>";

        DataSet ds = new DataSet();

        ds.ReadXml(new StringReader(elements));

        if (ds == null)
        {
            return;
        }

        if (ds.Tables.Count == 0)
        {
            return;
        }

        if (ds.Tables.Count < 1)
        {
            return;
        }

        DataTable dtLottery = ds.Tables[0];
        DataTable dtIssue   = ds.Tables[1];

        DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

        string number      = dtLottery.Rows[0]["issue"].ToString();
        string LotteryName = dtLottery.Rows[0]["lotteryId"].ToString();

        string BonusNumber = dtIssue.Rows[0]["baseCode"].ToString() + " " + dtIssue.Rows[0]["specialCode"].ToString();

        int    LotteryID = GetLotteryID(LotteryName);
        string WinNumber = GetWinNumber(LotteryID, BonusNumber);

        string Body = "";

        DataTable dtIsuse = new DAL.Tables.T_Isuses().Open("", "[Name] = '" + number + "' and LotteryID = " + LotteryID.ToString() + " and IsOpened = 0", "");

        if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
        {
            Body = "<body><result>0</result></body>";

            ReNotice("1202", Body);

            return;
        }

        long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), 0);

        DAL.Tables.T_Isuses T_Isuses = new DAL.Tables.T_Isuses();

        T_Isuses.WinLotteryNumber.Value = WinNumber;
        T_Isuses.OpenOperatorID.Value   = 1;
        T_Isuses.Update("[ID] = " + IsuseID + " and [Name] = '" + number + "' and LotteryID = " + LotteryID.ToString());


        DAL.Tables.T_IsuseInfo t_IsuseInfo = new DAL.Tables.T_IsuseInfo();

        t_IsuseInfo.TotalSaleMoney.Value       = Shove._Convert.StrToDouble(dtLottery.Rows[0]["totalSaleMoney"].ToString(), -1);
        t_IsuseInfo.PoolOut.Value              = Shove._Convert.StrToDouble(dtLottery.Rows[0]["poolOut"].ToString(), -1);
        t_IsuseInfo.TotalAwardMoney.Value      = Shove._Convert.StrToDouble(dtLottery.Rows[0]["totalAwardMoney"].ToString(), -1);
        t_IsuseInfo.TotalSaleMoneyLocal.Value  = Shove._Convert.StrToDouble(dtLottery.Rows[0]["totalSaleMoneyLocal"].ToString(), -1);
        t_IsuseInfo.TotalAwardMoneyLocal.Value = Shove._Convert.StrToDouble(dtLottery.Rows[0]["totalAwardMoneyLocal"].ToString(), -1);
        t_IsuseInfo.IssueID.Value              = IsuseID;

        if (new DAL.Tables.T_IsuseInfo().GetCount("IssueID=" + IsuseID.ToString()) < 1)
        {
            t_IsuseInfo.Insert();
        }
        else
        {
            t_IsuseInfo.Update("IssueID=" + IsuseID.ToString());
        }

        DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open("", " LotteryID =" + LotteryID.ToString(), "");

        if ((dtWinTypes == null) || dtWinTypes.Rows.Count < 1)
        {
            //log.Write("执行电子票--获取彩种: " + LotteryID.ToString() + ",奖金等级时出现错误!");

            Body = "<body><result>0</result></body>";

            ReNotice("1202", Body);

            return;
        }

        double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

        double DefaultMoney          = 0;
        double DefaultMoneyNoWithTax = 0;

        for (int i = 0; i < dtWinTypes.Rows.Count; i++)
        {
            DefaultMoney          = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoney"].ToString(), 0);
            DefaultMoneyNoWithTax = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

            WinMoneyList[i * 2]     = DefaultMoney == 0 ? 1 : DefaultMoneyNoWithTax;
            WinMoneyList[i * 2 + 1] = DefaultMoneyNoWithTax == 0 ? 1 : DefaultMoneyNoWithTax;
        }

        DataTable dtSchemesWithTaskDetails = new DAL.Views.V_Schemes().Open("", " IsuseName = '" + number + "' and LotteryID = " + LotteryID.ToString() + " and WinMoney = 0  and Buyed = 0 and ID in ( select ID from V_ChaseTaskDetails where IsuseName = '" + number + "' and LotteryID = " + LotteryID.ToString() + ")", "");

        string LotteryNumber = "";

        SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

        int    ReturnValue       = 0;
        string ReturnDescription = "";
        string Description       = "";
        double WinMoneyNoWithTax = 0;

        for (int i = 0; i < dtSchemesWithTaskDetails.Rows.Count; i++)
        {
            LotteryNumber = dtSchemesWithTaskDetails.Rows[i]["LotteryNumber"].ToString();

            Description       = "";
            WinMoneyNoWithTax = 0;

            double WinMoney = lb.ComputeWin(LotteryNumber, WinNumber.Trim(), ref Description, ref WinMoneyNoWithTax, int.Parse(dtSchemesWithTaskDetails.Rows[i]["PlayTypeID"].ToString()), WinMoneyList);

            if (WinMoney > 0)
            {
                if (DAL.Procedures.P_ChaseTaskStopWhenWin(Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["SiteID"].ToString(), 0), Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["ID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescription) < 0)
                {
                    //log.Write("执行电子票--判断是否停止追号的时候出现错误");

                    continue;
                }
            }
        }

        Body = "<body><result>0</result></body>";

        ReNotice("1202", Body);
    }
Beispiel #14
0
    //对停售通知进行处理
    private void StopIssueNotice(string TransMessage)
    {
        System.Xml.XmlDocument XmlDoc = new XmlDocument();
        XmlDoc.Load(new StringReader(TransMessage));

        string elements = TransMessage.Substring(TransMessage.IndexOf("<body"), TransMessage.LastIndexOf("</body>") - TransMessage.IndexOf("<body")) + "</body>";

        DataSet ds = new DataSet();

        ds.ReadXml(new StringReader(elements));

        if (ds == null)
        {
            return;
        }

        if (ds.Tables.Count == 0)
        {
            return;
        }

        DataTable dtIsuses = ds.Tables[0];

        if (dtIsuses.Rows.Count < 1)
        {
            return;
        }

        int    LotteryID = 0;
        string IssueName = "";

        DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

        foreach (DataRow dr in dtIsuses.Rows)
        {
            LotteryID = GetLotteryID(dr["lotteryId"].ToString());
            IssueName = dr["issue"].ToString();

            if (t_Isuses.GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "' and year(getdate()) = year(StartTime) and LotteryID  in (select id from T_Lotteries where PrintOutType = 108)") < 1)
            {
                continue;
            }

            DataTable dtIsuse = t_Isuses.Open("ID, StartTime, EndTime, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IssueName) + "' and LotteryID  in (select id from T_Lotteries where PrintOutType = 108) and year(getdate()) = year(StartTime)", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                continue;
            }

            int    ReturnValue      = 0;
            string ReturnDescprtion = "";

            if (DAL.Procedures.P_IsuseUpdate(LotteryID, IssueName, 5, Shove._Convert.StrToDateTime(dr["startTime"].ToString().Insert(12, ":").Insert(10, ":").Insert(8, " ").Insert(6, "-").Insert(4, "-"), DateTime.Now.ToString()), Shove._Convert.StrToDateTime(dr["endTime"].ToString().Insert(12, ":").Insert(10, ":").Insert(8, " ").Insert(6, "-").Insert(4, "-"), DateTime.Now.ToString()), DateTime.Now, "", ref ReturnValue, ref ReturnDescprtion) < 0)
            {
                new Log("ElectronTicket\\CTTCSD").Write("电子票期号截止更新错误_P_IsuseUpdate");

                continue;
            }
        }

        string Body = "<body><result>0</result></body>";

        ReNotice("1204", Body);
    }
Beispiel #15
0
    private void BindData()
    {
        DataTable dt = new DAL.Tables.T_Isuses().Open("", "[ID]=" + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "");

        if ((dt == null) || (dt.Rows.Count < 1))
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

            return;
        }

        tbIsuse.Text     = dt.Rows[0]["Name"].ToString();
        tbStartTime.Text = Shove._Convert.StrToDateTime(dt.Rows[0]["StartTime"].ToString(), "0000-00-00 00:00:00").ToString("yyyy-MM-dd HH:mm:ss");
        tbEndTime.Text   = Shove._Convert.StrToDateTime(dt.Rows[0]["EndTime"].ToString(), "0000-00-00 00:00:00").ToString("yyyy-MM-dd HH:mm:ss");

        if (tbLotteryID.Text == SLS.Lottery.SFC.sID || tbLotteryID.Text == SLS.Lottery.ZCSFC.sID || tbLotteryID.Text == SLS.Lottery.ZCRJC.sID)
        {
            dt = new DAL.Tables.T_IsuseForSFC().Open("", "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "[No]");

            if (dt == null)
            {
                PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

                return;
            }

            if (dt.Rows.Count != 14)
            {
                return;
            }

            for (int i = 0; i < 14; i++)
            {
                TextBox tb   = (TextBox)this.FindControl("tbSFC" + (i + 1).ToString());
                TextBox tb_1 = (TextBox)this.FindControl("tbSFC" + (i + 1).ToString() + "_1");
                TextBox tb_2 = (TextBox)this.FindControl("tbSFC" + (i + 1).ToString() + "_2");

                tb.Text   = dt.Rows[i]["HostTeam"].ToString();
                tb_1.Text = dt.Rows[i]["QuestTeam"].ToString();
                tb_2.Text = dt.Rows[i]["DateTime"].ToString();
            }
        }

        if (tbLotteryID.Text == SLS.Lottery.JQC.sID)
        {
            dt = new DAL.Tables.T_IsuseForJQC().Open("", "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "[No]");

            if ((dt == null) || (dt.Rows.Count < 8))
            {
                PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

                return;
            }

            for (int i = 0; i < 8; i++)
            {
                TextBox tb   = (TextBox)this.FindControl("tbJQC" + (i + 1).ToString());
                TextBox tb_2 = (TextBox)this.FindControl("tbJQC" + (i + 1).ToString() + "_2");

                tb.Text   = dt.Rows[i]["Team"].ToString();
                tb_2.Text = dt.Rows[i]["DateTime"].ToString();
            }
        }

        if (tbLotteryID.Text == SLS.Lottery.LCBQC.sID)
        {
            dt = new DAL.Tables.T_IsuseForLCBQC().Open("", "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "[No]");

            if ((dt == null) || (dt.Rows.Count < 6))
            {
                PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

                return;
            }

            for (int i = 0; i < 6; i++)
            {
                TextBox tb   = (TextBox)this.FindControl("tbLCBQC" + (i + 1).ToString());
                TextBox tb_1 = (TextBox)this.FindControl("tbLCBQC" + (i + 1).ToString() + "_1");
                TextBox tb_2 = (TextBox)this.FindControl("tbLCBQC" + (i + 1).ToString() + "_2");

                tb.Text   = dt.Rows[i]["HostTeam"].ToString();
                tb_1.Text = dt.Rows[i]["QuestTeam"].ToString();
                tb_2.Text = dt.Rows[i]["DateTime"].ToString();
            }
        }

        if (tbLotteryID.Text == SLS.Lottery.LCDC.sID)
        {
            dt = new DAL.Tables.T_IsuseForLCDC().Open("", "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "[No]");

            if ((dt == null) || (dt.Rows.Count < 1))
            {
                PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

                return;
            }

            for (int i = 0; i < 1; i++)
            {
                TextBox tb   = (TextBox)this.FindControl("tbLCDC" + (i + 1).ToString());
                TextBox tb_1 = (TextBox)this.FindControl("tbLCDC" + (i + 1).ToString() + "_1");
                TextBox tb_2 = (TextBox)this.FindControl("tbLCDC" + (i + 1).ToString() + "_2");

                tb.Text   = dt.Rows[i]["HostTeam"].ToString();
                tb_1.Text = dt.Rows[i]["QuestTeam"].ToString();
                tb_2.Text = dt.Rows[i]["DateTime"].ToString();
            }
        }

        DataTable dtTestNumber = new DAL.Tables.T_TestNumber().Open("", "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "");

        DataTable dtTotalMoney = new DAL.Tables.T_TotalMoney().Open("", "IsuseID= " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "");


        if (dtTestNumber == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

            return;
        }
        if (dtTotalMoney == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);
            return;
        }
        if (dtTestNumber.Rows.Count > 0)
        {
            tbTestNumber.Text = dtTestNumber.Rows[0]["TestNumber"].ToString();
            hidID.Value       = dtTestNumber.Rows[0]["ID"].ToString();
        }
        if (dtTotalMoney.Rows.Count > 0)
        {
            tbMoney.Text  = dtTotalMoney.Rows[0]["TotalMoney"].ToString();
            moneyID.Value = dtTotalMoney.Rows[0]["ID"].ToString();
        }
    }
Beispiel #16
0
        // 查询奖期状态
        private void QueryIsuseState()
        {
            // 查询的几组条件说明:
            //  1 有效期内未开奖、未开启的
            //  2 已截止未开奖的
            DataTable dt = new DAL.Views.V_Isuses().Open(ConnectionString, "[ID], LotteryID, [Name]", "((isOpened = 0 and (Getdate() between StartTime and EndTime) and State = 0) or (isOpened = 0 and Getdate() > EndTime and State < 5)) and PrintOutType = 102", "EndTime");

            if (dt == null)
            {
                msg.Send("期号状态查询错误(QueryIsuseState)。");
                log.Write("期号状态查询错误(QueryIsuseState)。");

                return;
            }

            if (dt.Rows.Count < 1)
            {
                return;
            }

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (i % 100 == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }

                #region 查询奖期

                string LotteryName = GetLotteryName(Shove._Convert.StrToInt(dt.Rows[i]["LotteryID"].ToString(), 0));
                string IsuseName = dt.Rows[i]["Name"].ToString();
                DateTime Now = DateTime.Now;

                string MessageID = ElectronTicket_HPSH_UserName + Now.ToString("yyyyMMdd") + Now.ToString("HHmmss") + (i % 100).ToString().PadLeft(2, '0');
                string Body = "<body><issueQuery><issue gameName=\"" + LotteryName + "\" number=\"" + IsuseName + "\"/></issueQuery></body>";
                string TimeStamp = Now.ToString("yyyyMMdd") + Now.ToString("HHmmss");

                string Message = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
                Message += "<message version=\"1.0\" id=\"" + MessageID + "\">";
                Message += "<header>";
                Message += "<messengerID>" + ElectronTicket_HPSH_UserName + "</messengerID>";
                Message += "<timestamp>" + TimeStamp + "</timestamp>";
                Message += "<transactionType>102</transactionType>";
                Message += "<digest>" + Shove._Security.Encrypt.MD5(MessageID + TimeStamp + ElectronTicket_HPSH_UserPassword + Body, "gb2312") + "</digest>";
                Message += "</header>";
                Message += Body;
                Message += "</message>";

                WriteElectronTicketLog(true, "102", "transType=102&transMessage=" + Message);

                string ReceiveString = "";

                try
                {
                    ReceiveString = PublicFunction.Post(ElectronTicket_HPSH_Getway, "transType=102&transMessage=" + Message, TimeoutSeconds);
                }
                catch
                {
                    continue;
                }

                if (ReceiveString.Length <= 10)
                {
                    continue;
                }

                string[] t_strs = ReceiveString.Split('&');

                if ((t_strs == null) || (t_strs.Length < 2))
                {
                    continue;
                }

                string TransType = t_strs[0];
                string TransMessage = t_strs[1];

                TransType = TransType.Substring(10);
                TransMessage = TransMessage.Substring(13);

                WriteElectronTicketLog(false, TransType, ReceiveString);

                #endregion

                #region 处理结果

                System.Xml.XmlDocument XmlDoc = new XmlDocument();
                System.Xml.XmlNodeList nodes = null;
                System.Xml.XmlNodeList nodesIssue = null;

                try
                {
                    XmlDoc.Load(new StringReader(TransMessage));

                    nodes = XmlDoc.GetElementsByTagName("response");
                    nodesIssue = XmlDoc.GetElementsByTagName("issue");
                }
                catch
                {
                    continue;
                }

                if (nodes == null)
                {
                    continue;
                }

                if (nodes[0].Attributes["code"].Value != "0000")
                {
                    continue;
                }

                if (nodesIssue == null)
                {
                    continue;
                }

                DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

                for (int j = 0; j < nodesIssue.Count; j++)
                {
                    LotteryName = nodesIssue[j].Attributes["gameName"].Value;
                    IsuseName = nodesIssue[j].Attributes["number"].Value;
                    string Status = nodesIssue[j].Attributes["status"].Value;
                    int LotteryID = GetLotteryID(LotteryName);
                    string WinNumber = "";

                    try
                    {
                        WinNumber = GetWinNumber(LotteryID, nodesIssue[j].Attributes["bonusCode"].Value);
                    }
                    catch
                    {

                    }

                    if ((LotteryID < 0) || (String.IsNullOrEmpty(IsuseName)))
                    {
                        continue;
                    }

                    DataTable dtIsuse = t_Isuses.Open(ConnectionString, "ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "'", "");

                    if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
                    {
                        continue;
                    }

                    bool isHasUpdate = false;

                    if (dtIsuse.Rows[0]["State"].ToString() != Status)
                    {
                        t_Isuses.State.Value = Status;
                        t_Isuses.StateUpdateTime.Value = DateTime.Now;

                        isHasUpdate = true;
                    }

                    if (!String.IsNullOrEmpty(WinNumber) && (dtIsuse.Rows[0]["WinLotteryNumber"].ToString() != WinNumber))
                    {
                        t_Isuses.WinLotteryNumber.Value = WinNumber;

                        isHasUpdate = true;

                        if (LotteryID == SLS.Lottery.SHSSL.ID)
                        {
                            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(ConnectionString, "", "LotteryID =" + LotteryID.ToString(), "");

                            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

                            for (int k = 0; k < dtWinTypes.Rows.Count; k++)
                            {
                                WinMoneyList[k * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoney"].ToString(), 1);
                                WinMoneyList[k * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoneyNoWithTax"].ToString(), 1);
                            }

                            DataTable dtChaseTaskDetails = new DAL.Tables.T_ChaseTaskDetails().Open(ConnectionString, "", "IsuseID=" + dtIsuse.Rows[0]["ID"].ToString() + " and SchemeID IS NOT NULL", "");

                            for (int k = 0; k < dtChaseTaskDetails.Rows.Count; k++)
                            {
                                string LotteryNumber = dtChaseTaskDetails.Rows[k]["LotteryNumber"].ToString();

                                string Description = "";
                                double WinMoneyNoWithTax = 0;

                                double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtChaseTaskDetails.Rows[k]["PlayTypeID"].ToString()), WinMoneyList);

                                if (WinMoney < 1)
                                {
                                    continue;
                                }

                                int ReturnValue = 0;
                                string ReturnDescprtion = "";

                                if (DAL.Procedures.P_ChaseTaskStopWhenWin(ConnectionString, Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SiteID"].ToString(), 1), Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SchemeID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescprtion) < 0)
                                {
                                    msg.Send("电子票撤销追号错误_P_ChaseTaskStopWhenWin。");
                                    log.Write("电子票撤销追号错误_P_ChaseTaskStopWhenWin。");
                                }
                            }
                        }
                    }

                    if (isHasUpdate)
                    {
                        t_Isuses.Update(ConnectionString, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "'");
                    }
                }

                #endregion
            }
        }
Beispiel #17
0
    protected void btnAdd_Click(object sender, System.EventArgs e)
    {
        string Isuse = "";

        try
        {
            Isuse = Shove._Web.Utility.FilteSqlInfusion(tbIsuse.Text.Trim());
        }
        catch { }

        if (Isuse == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "期号不能为空!");

            return;
        }

        DataTable dt = new DAL.Tables.T_Isuses().Open("[ID]", "[Name] = '" + Isuse + "' and LotteryID = " + Shove._Web.Utility.FilteSqlInfusion(tbLotteryID.Text), "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAdd");

            return;
        }

        if (dt.Rows.Count > 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "期号已经存在,请不要输入重名期号!");

            return;
        }

        System.DateTime StartTime, EndTime;

        object time = PF.ValidLotteryTime(tbStartTime.Text);

        if (time == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "开始时间格式输入错误!");
            return;
        }

        StartTime = (DateTime)time;

        time = PF.ValidLotteryTime(tbEndTime.Text);

        if (time == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "截止时间格式输入错误!");
            return;
        }

        EndTime = (DateTime)time;

        if (EndTime <= StartTime)
        {
            Shove._Web.JavaScript.Alert(this.Page, "截止时间应该在开始时间之后!");

            return;
        }

        string AdditionasXml = "";

        if ((tbLotteryID.Text == SZJS.Lottery.SFC.sID || tbLotteryID.Text == SZJS.Lottery.ZCSFC.sID || tbLotteryID.Text == SZJS.Lottery.ZCRJC.sID) && (BuildAdditionasXmlForSFC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.JQC.sID) && (BuildAdditionasXmlForJQC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.LCBQC.sID) && (BuildAdditionasXmlForLCBQC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.LCDC.sID) && (BuildAdditionasXmlForLCDC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.ZCDC.sID) && (BuildAdditionasXmlForZCDC(ref AdditionasXml) < 0))
        {
            return;
        }

        int LotteryID = int.Parse(tbLotteryID.Text);

        long   NewIsuseID        = -1;
        string ReturnDescription = "";

        int Result = DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, StartTime, EndTime, AdditionasXml, ref NewIsuseID, ref ReturnDescription);



        if (Result < 0)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAdd");

            return;
        }

        if (NewIsuseID < 0)
        {
            PF.GoError(ErrorNumber.Unknow, ReturnDescription, "Admin_IsuseAdd");

            return;
        }

        DAL.Tables.T_TotalMoney dtTotalMoney = new DAL.Tables.T_TotalMoney();

        dtTotalMoney.IsuseID.Value    = NewIsuseID;
        dtTotalMoney.TotalMoney.Value = this.tbMoney.Text;

        if (dtTotalMoney.Insert() < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "添加奖池奖金失败!");
            return;
        }

        if (cbAutoNext10Isuse.Visible && cbAutoNext10Isuse.Checked && (AdditionasXml == ""))
        {
            string IsuseYear = Isuse.Substring(0, Isuse.Length - 3);
            int    IsuseNum  = Shove._Convert.StrToInt(Isuse.Substring(Isuse.Length - 3, 3), 0);

            for (int i = 1; i <= 9; i++)
            {
                IsuseNum++;
                string NextIsuse = IsuseYear + IsuseNum.ToString().PadLeft(3, '0');
                StartTime = StartTime.AddDays(1);
                EndTime   = EndTime.AddDays(1);
                int Results = -1;
                Results = DAL.Procedures.P_IsuseAdd(LotteryID, NextIsuse, StartTime, EndTime, "", ref NewIsuseID, ref ReturnDescription);
                if (Result < 0)
                {
                    break;
                }

                if (NewIsuseID < 0)
                {
                    continue;
                }
            }
        }
        Shove._Web.Cache.ClearCache(CacheKey.LotteryCalendar);
        Shove._Web.Cache.ClearCache(DataCache.IsusesInfo + tbLotteryID.Text.Trim());
        this.Response.Redirect("Isuse.aspx?LotteryID=" + tbLotteryID.Text, true);
    }
Beispiel #18
0
        private void WinScoreScale()
        {
            DataTable dt = MSSQL.Select(ConnectionString, "select id, PlayTypeID, WinMoney, LotteryNumber, IsuseID, Multiple from T_Schemes where not exists (select 1 from T_SchemeIsCalcuteScore where ScoreType = 2 and T_Schemes.ID = T_SchemeIsCalcuteScore.SchemeID) and ID > isnull((select max(SchemeID) - 10000 from T_SchemeIsCalcuteScore where ScoreType = 2), 0) and exists (select 1 from T_Isuses where LotteryID in (6, 28, 29, 60, 61, 62, 63, 64, 68, 70) and T_Isuses.ID = T_Schemes.IsuseID) and isOpened = 1 order by IsuseID desc");

            if (dt == null)
            {
                log.Write("Exec WinScoreScale: DataTable \"WinScoreScale\" Fail.");

                return;
            }

            if (dt.Rows.Count < 1)
            {
                return;
            }

            DAL.Tables.T_SchemeIsCalcuteScore t_SchemeIsCalcuteScore = new DAL.Tables.T_SchemeIsCalcuteScore();

            DataTable dtIsuses   = null;
            DataTable dtWinMoney = null;

            foreach (DataRow dr in dt.Rows)
            {
                if (Shove._Convert.StrToDouble(dr["WinMoney"].ToString(), 0) == 0)
                {
                    t_SchemeIsCalcuteScore.SchemeID.Value  = dr["ID"].ToString();
                    t_SchemeIsCalcuteScore.ScoreType.Value = 2;
                    t_SchemeIsCalcuteScore.Insert(ConnectionString);

                    continue;
                }

                dtIsuses = new DAL.Tables.T_Isuses().Open(ConnectionString, "WinLotteryNumber, LotteryID", "ID=" + dr["IsuseID"].ToString(), "");

                if (dtIsuses == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"T_Isuses\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

                if (dtIsuses.Rows.Count < 1)
                {
                    continue;
                }

                dtWinMoney = MSSQL.Select(ConnectionString, "select DefaultMoney * a.ScoreScale as DefaultMoney, DefaultMoneyNoWithTax * a.ScoreScale as DefaultMoneyNoWithTax, a.WinMoney as WinMoney from T_WinTypes inner join T_WinScoreScale a on T_WinTypes.ID = a.WinTypeID where exists (select * from T_PlayTypes where ID = " + dr["PlayTypeID"].ToString() + " and T_WinTypes.LotteryID = T_PlayTypes.LotteryID)  order by [Order]");

                if (dtWinMoney == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"dtWinMoney\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

                if (dtWinMoney.Rows.Count < 1)
                {
                    continue;
                }

                double[] WinMoneyList = new double[dtWinMoney.Rows.Count * 2];

                double MaxMoney = 0;

                for (int i = 0; i < dtWinMoney.Rows.Count; i++)
                {
                    WinMoneyList[i * 2]     = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoney"].ToString(), 0);
                    WinMoneyList[i * 2 + 1] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                    if (Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0) > MaxMoney)
                    {
                        MaxMoney = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0);
                    }
                }

                string LotteryNumber = dr["LotteryNumber"].ToString();
                string Description   = "";

                double WinMoneyNoWithTax = 0;
                double WinMoney          = 0;

                try
                {
                    WinMoney = new SLS.Lottery()[int.Parse(dtIsuses.Rows[0]["LotteryID"].ToString())].ComputeWin(LotteryNumber, dtIsuses.Rows[0]["WinLotteryNumber"].ToString(), ref Description, ref WinMoneyNoWithTax, int.Parse(dr["PlayTypeID"].ToString()), WinMoneyList);
                }
                catch
                {
                    WinMoney = 0;
                }

                log.Write("方案号:" + dr["ID"].ToString() + "-------中奖金额:" + (Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney).ToString() + "-----------最大金额:" + MaxMoney.ToString());

                if (DAL.Procedures.P_SchemeWinCalculatedScore(ConnectionString, Shove._Convert.StrToLong(dr["ID"].ToString(), 0), Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney, MaxMoney) < 0)
                {
                    log.Write("Exec WinScoreScale: Procedures \"P_SchemeWinCalculatedScore\" Fail.");

                    continue;
                }
            }

            #endregion
        }
Beispiel #19
0
    private void Get3DBaoDianMiss()
    {
        string Key = "Home_Room_Buy_Get3DBaoDianMiss";

        lbMiss.Text = Shove._Web.Cache.GetCacheAsString(Key, "");
        lbMiss.Text = "";
        if (lbMiss.Text == "")
        {
            DataTable dt = new DAL.Tables.T_Isuses().Open("EndTime,WinLotteryNumber", "LotteryID = 6 and GETDATE()>EndTime and ISNULL(WinLotteryNumber,'')<>'' and IsOpened=1", "EndTime asc");

            if (dt == null)
            {
                new Log("System").Write(this.GetType().FullName + "数据库繁忙,请重试(Get3DBaoDianMiss)");

                return;
            }

            int[]  Miss      = new int[28];
            int[]  LiLunMiss = new int[] { 1000, 333, 167, 100, 67, 48, 36, 28, 22, 18, 16, 14, 14, 13, 13, 14, 14, 16, 18, 22, 28, 36, 48, 67, 100, 167, 333, 1000 };
            string WinLotteryNumber;
            int    WinNumber;

            foreach (DataRow dr in dt.Rows)
            {
                WinLotteryNumber = dr["WinLotteryNumber"].ToString();
                WinNumber        = 0;

                if (WinLotteryNumber.Length != 3)
                {
                    continue;
                }

                for (int i = 0; i < WinLotteryNumber.Length; i++)
                {
                    WinNumber += Shove._Convert.StrToInt(WinLotteryNumber.Substring(i, 1), 0);
                }

                for (int i = 0; i < Miss.Length; i++)
                {
                    if (i == WinNumber)
                    {
                        Miss[i] = 0;
                    }
                    else
                    {
                        Miss[i]++;
                    }
                }
            }

            double scaleMax = 0;
            double scale    = 0;

            for (int i = 0; i < 28; i++)
            {
                scale = Shove._Convert.StrToDouble(Miss[i].ToString(), 0);

                if (scale / LiLunMiss[i] >= scaleMax)
                {
                    scaleMax = scale / LiLunMiss[i];
                }
            }

            StringBuilder sb = new StringBuilder();

            int count = Miss.Length / 14;

            for (int i = 0; i < count; i++)
            {
                sb.Append(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">")
                .Append("<tr>")
                .Append("<td class='blue' width='80px' align='center'>")
                .Append("本期遗漏")
                .Append("</td>");

                for (int j = i * 14; j < (i + 1) * 14; j++)
                {
                    if (Shove._Convert.StrToDouble(Miss[j].ToString(), 0) / LiLunMiss[j] >= scaleMax)
                    {
                        sb.Append("<td class='red12'>");
                    }
                    else
                    {
                        sb.Append("<td class='hui12'>");
                    }

                    sb.Append(Miss[j].ToString())
                    .Append("</td>");
                }

                sb.Append("</tr>")
                .Append("<tr>")
                .Append("<td class='blue' width='80px' align='center'>")
                .Append("理论遗漏")
                .Append("</td>");

                for (int j = i * 14; j < (i + 1) * 14; j++)
                {
                    if (Shove._Convert.StrToDouble(Miss[j].ToString(), 0) / LiLunMiss[j] >= scaleMax)
                    {
                        sb.Append("<td class='red12'>");
                    }
                    else
                    {
                        sb.Append("<td class='hui12'>");
                    }

                    sb.Append(LiLunMiss[j].ToString())
                    .Append("</td>");
                }

                sb.Append("</tr>")
                .Append("</table>-");
            }


            lbMiss.Text = sb.ToString();

            Shove._Web.Cache.SetCache(Key, lbMiss.Text, 600);
        }
    }
Beispiel #20
0
    private void BindBet()
    {
        double summoney = Shove._Convert.StrToDouble(Shove._Web.Utility.GetRequest("summoney"), 0);
        int    isuseid  = Shove._Convert.StrToInt(Shove._Web.Utility.GetRequest("isuseid"), 0);
        string lotid    = Shove._Web.Utility.GetRequest("lotid");
        string playid   = Shove._Web.Utility.GetRequest("playid");
        string zhushu   = Shove._Web.Utility.GetRequest("zhushu");
        string beishu   = Shove._Web.Utility.GetRequest("beishu");
        string codes    = Shove._Web.Utility.GetRequest("codes").Replace("#", "+");

        if (string.IsNullOrEmpty(zhushu) || string.IsNullOrEmpty(beishu) || string.IsNullOrEmpty(codes) || string.IsNullOrEmpty(lotid))
        {
            return;
        }

        if (summoney < 2 || isuseid == 0)
        {
            return;
        }

        StringBuilder sb = new StringBuilder();

        string Number = codes;

        if (lotid == "74" || lotid == "75")
        {
            if (summoney == 2)
            {
                playid = lotid + "01";
            }
            else
            {
                playid = lotid + "02";
            }

            if (Number.Length < 9)
            {
                return;
            }

            DataTable dtMatch = new DAL.Tables.T_IsuseForSFC().Open("", "IsuseID=" + isuseid.ToString(), "No");

            if (dtMatch == null || dtMatch.Rows.Count != 14)
            {
                return;
            }

            sb.Append("<table bgcolor=\"#afcea4\" border=\"0\" cellpadding=\"4\" cellspacing=\"1\">")
            .Append("<tbody><tr class=\"gg_form_trt_02\"><td width=\"80\">场次</td><td width=\"270\">比赛对阵</td><td width=\"140\" align=\"center\">比赛时间</td><td width=\"100\" align=\"center\">投注结果</td></tr></tbody>")
            .Append("<tbody id=\"matchList\">");

            for (int i = 0; i < 14; i++)
            {
                sb.Append("<tr class=\"dg_trbg1\"><td>").Append(dtMatch.Rows[i]["NO"].ToString())
                .Append("</td><td>").Append(dtMatch.Rows[i]["HostTeam"].ToString()).Append(" VS ").Append(dtMatch.Rows[i]["QuestTeam"].ToString())
                .Append("</td><td>").Append(dtMatch.Rows[i]["DateTime"].ToString())
                .Append("</td><td>");
                if (Number.Substring(0, 1).Equals("("))
                {
                    sb.Append(Number.Substring(1, Number.IndexOf(")") - 1));
                    Number = Number.Substring(Number.IndexOf(")") + 1);
                }
                else
                {
                    sb.Append(Number.Substring(0, 1));
                    Number = Number.Substring(1);
                }
                sb.Append("</td></tr>");
            }

            sb.Append("</tbody></table>");
        }
        else if (lotid == "15")
        {
            if (summoney == 2)
            {
                playid = lotid + "01";
            }
            else
            {
                playid = lotid + "02";
            }

            if (Number.Length < 12)
            {
                return;
            }

            DataTable dtMatch = new DAL.Tables.T_IsuseForLCBQC().Open("", "IsuseID=" + isuseid.ToString(), "No");

            if (dtMatch == null || dtMatch.Rows.Count != 6)
            {
                return;
            }

            sb.Append("<table bgcolor=\"#afcea4\" border=\"0\" cellpadding=\"4\" cellspacing=\"1\">")
            .Append("<tbody><tr class=\"gg_form_trt_02\"><td width=\"80\">场次</td><td width=\"270\">比赛对阵</td><td width=\"140\" align=\"center\">比赛时间</td><td width=\"100\" align=\"center\">投注结果</td></tr></tbody>")
            .Append("<tbody id=\"matchList\">");

            for (int i = 0; i < 6; i++)
            {
                sb.Append("<tr class=\"dg_trbg1\"><td>").Append(dtMatch.Rows[i]["NO"].ToString())
                .Append("</td><td>").Append(dtMatch.Rows[i]["HostTeam"].ToString()).Append(" VS ").Append(dtMatch.Rows[i]["QuestTeam"].ToString())
                .Append("</td><td>").Append(dtMatch.Rows[i]["DateTime"].ToString())
                .Append("</td><td>");
                if (Number.Substring(0, 1).Equals("("))
                {
                    sb.Append(Number.Substring(1, Number.IndexOf(")") - 1));
                    Number = Number.Substring(Number.IndexOf(")") + 1);
                }
                else
                {
                    sb.Append(Number.Substring(0, 1));
                    Number = Number.Substring(1);
                }
                sb.Append("</td></tr>");
            }

            sb.Append("</tbody></table>");
        }
        else if (lotid == "2")
        {
            if (summoney == 2)
            {
                playid = lotid + "01";
            }
            else
            {
                playid = lotid + "02";
            }

            if (Number.Length < 8)
            {
                return;
            }

            DataTable dtMatch = new DAL.Tables.T_IsuseForJQC().Open("", "IsuseID=" + isuseid.ToString(), "No");

            if (dtMatch == null || dtMatch.Rows.Count != 8)
            {
                return;
            }

            sb.Append("<table bgcolor=\"#afcea4\" border=\"0\" cellpadding=\"4\" cellspacing=\"1\">")
            .Append("<tbody><tr class=\"gg_form_trt_02\"><td width=\"80\">场次</td><td width=\"270\">比赛对阵</td><td width=\"140\" align=\"center\">比赛时间</td><td width=\"100\" align=\"center\">投注结果</td></tr></tbody>")
            .Append("<tbody id=\"matchList\">");

            for (int i = 0; i < 8; i = i + 2)
            {
                sb.Append("<tr class=\"dg_trbg1\"><td>").Append(dtMatch.Rows[i]["NO"].ToString())
                .Append("</td><td>").Append(dtMatch.Rows[i]["Team"].ToString()).Append(" VS ").Append(dtMatch.Rows[i + 1]["Team"].ToString())
                .Append("</td><td>").Append(dtMatch.Rows[i]["DateTime"].ToString())
                .Append("</td><td>");
                if (Number.Substring(0, 1).Equals("("))
                {
                    sb.Append(Number.Substring(1, Number.IndexOf(")") - 1));
                    Number = Number.Substring(Number.IndexOf(")") + 1);
                }
                else
                {
                    sb.Append(Number.Substring(0, 1));
                    Number = Number.Substring(1);
                }
                sb.Append("</td></tr>");
            }

            sb.Append("</tbody></table>");
        }
        else if ((new SLS.Lottery.JCLQ().CheckPlayType(Shove._Convert.StrToInt(playid, -1))) || (new SLS.Lottery.JCZQ().CheckPlayType(Shove._Convert.StrToInt(playid, -1))))
        {
            codes = PF.GetScriptResTable(codes);
            sb.Append(codes);
        }
        else
        {
            codes = Shove._Convert.ToHtmlCode(codes) + "&nbsp;";
            sb.Append(codes);
        }

        labLotteryNumber.Text = sb.ToString();
        labMultiple.Text      = beishu;
        labSchemeMoney.Text   = summoney.ToString();
        labNum.Text           = zhushu;

        DataTable dt = new DAL.Tables.T_Isuses().Open("", "ID=" + isuseid.ToString(), "");

        if (dt == null || dt.Rows.Count != 1)
        {
            return;
        }

        labEndTime.Text = Shove._Convert.StrToDateTime(dt.Rows[0]["EndTime"].ToString(), DateTime.Now.AddHours(1).ToString()).ToString("yyyy-MM-dd HH:mm");

        hidplayid.Value       = playid.ToString();
        hidlotid.Value        = lotid;
        hidSchemeMoney.Value  = summoney.ToString();
        hidMultiple.Value     = beishu;
        hidisuseid.Value      = isuseid.ToString();
        hidcodes.Value        = codes;
        hidSumNum.Value       = zhushu;
        HidIsuseEndTime.Value = dt.Rows[0]["EndTime"].ToString();
    }
Beispiel #21
0
        private void Betting()  // 解析,投注
        {
            DAL.Tables.T_SmsBettings t_SmsBettings = new DAL.Tables.T_SmsBettings();
            DataTable dt = t_SmsBettings.Open(ConnectionString, "", "HandleResult = 0", "[ID]");

            if (dt == null)
            {
                msg.Send("Read SMS fail.");
                log.Write("Read SMS fail.");

                return;
            }

            foreach (DataRow dr in dt.Rows)
            {
                string ID      = dr["ID"].ToString();
                string Mobile  = dr["From"].ToString().Trim();
                string Content = Shove._Convert.ToDBC(dr["Content"].ToString()).Trim();

                if ((Mobile == "") || (Content == ""))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1000)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                string[] Contents = Content.Split(';');

                if ((Contents == null) || (Contents.Length != 6))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1001)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 1;501;1;1;010203040506+01|010203040506+01;#2                          站点ID;玩法ID;总份数;认购份数;号码|号码;#倍数

                long SiteID = Shove._Convert.StrToLong(Contents[0], -1);

                if (SiteID < 0)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1002)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                if (new DAL.Tables.T_Sites().GetCount(ConnectionString, "[ID] = " + SiteID.ToString()) < 0)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1003)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                #region 投注

                if (!Contents[5].StartsWith("#"))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1004)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                int    PlayTypeID    = Shove._Convert.StrToInt(Contents[1], -1);
                int    Share         = Shove._Convert.StrToInt(Contents[2], -1);
                int    BuyShare      = Shove._Convert.StrToInt(Contents[3], -1);
                string LotteryNumber = Contents[4].Trim();
                int    Multiple      = Shove._Convert.StrToInt(Contents[5].Substring(1, Contents[5].Length - 1), -1);

                if ((PlayTypeID < 0) || (BuyShare < 0) || (Share < BuyShare) || (LotteryNumber == "") || (Multiple < 0))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1005)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 根据手机获取用户
                DataTable dtUsers = new DAL.Tables.T_Users().Open(ConnectionString, "[ID], Balance", "SiteID = " + SiteID.ToString() + " and Mobile = '" + Mobile + "' and isMobileValided = 1", "");

                if ((dtUsers == null) || (dtUsers.Rows.Count != 1))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "用户不存在(1006)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                long   UserID  = Shove._Convert.StrToLong(dtUsers.Rows[0]["ID"].ToString(), -1);
                double Balance = Shove._Convert.StrToDouble(dtUsers.Rows[0]["Balance"].ToString(), 0);

                if (UserID < 0)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "用户不存在(1007)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 获取彩种、同时也校验了玩法
                DataTable dtLottery = new DAL.Tables.T_PlayTypes().Open(ConnectionString, "LotteryID, Price, MaxMultiple", "[ID] = " + PlayTypeID.ToString(), "");

                if ((dtLottery == null) || (dtLottery.Rows.Count < 1))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1008)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                int    LotteryID   = Shove._Convert.StrToInt(dtLottery.Rows[0]["LotteryID"].ToString(), -1);
                double Price       = Shove._Convert.StrToDouble(dtLottery.Rows[0]["Price"].ToString(), -1);
                int    MaxMultiple = Shove._Convert.StrToInt(dtLottery.Rows[0]["MaxMultiple"].ToString(), -1);

                if ((LotteryID < 0) || (Price < 2) || (Multiple > MaxMultiple))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(10090)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 校验投注号码,计算注数、金额
                int Num = 0;
                LotteryNumber = GetLotteryNumber(LotteryID, PlayTypeID, LotteryNumber, ref Num);

                if (Num < 1)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "投注号码错误(1010)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                double Money = Num * Price * Multiple;

                // 获取期号
                DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(ConnectionString, "top 1 [ID]", "LotteryID = " + LotteryID.ToString() + " and GetDate() between StartTime and dbo.F_GetIsuseSystemEndTime([ID], " + PlayTypeID.ToString() + ") and IsOpened = 0", "");

                if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "奖期未开启(1011)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1);

                if (IsuseID < 0)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "奖期未开启(1012)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 校验余额
                if (Balance < Money)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = "投注卡账户余额不足(1013)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 投注
                string ReturnDescription = "";
                long   SchemeID          = InitiateScheme(SiteID, UserID, IsuseID, PlayTypeID, "本方案由用户手动编写短信代码投注(系统)", "短信ID:" + ID + "\r\n短信内容:" + Content, LotteryNumber, "", Multiple, Money, 0, Share, BuyShare, "", 0, ref ReturnDescription);

                if (SchemeID < 0)
                {
                    t_SmsBettings.HandleResult.Value      = -1;
                    t_SmsBettings.HandleDescription.Value = ReturnDescription + "(1015)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                t_SmsBettings.SchemeID.Value     = SchemeID;
                t_SmsBettings.HandleResult.Value = 1;
                t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                #endregion
            }
        }
Beispiel #22
0
    private void BindBet()
    {
        long BuyID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("BuyID"), 0);

        string FileName = Request.Cookies["ASP.NET_SessionId"].Value;

        string LotteryNumber = "";

        DataTable dt = null;

        int    Multiple     = 0;
        double SumMoney     = 0;
        long   IsuseID      = 0;
        int    Count        = 0;
        int    LotID        = 0;
        int    PlayID       = 0;
        int    Share        = 1;
        int    BuyShare     = 1;
        double AssureMoney  = 0;
        short  SecrecyLevel = 0;

        if (BuyID > 0)
        {
            dt = new DAL.Tables.T_AlipayBuyTemp().Open("", "ID=" + BuyID.ToString(), "");

            if (dt == null || dt.Rows.Count == 0)
            {
                return;
            }

            hidBuyID.Value = BuyID.ToString();

            DataRow dr = dt.Rows[0];

            string HidIsuseID          = dr["IsuseID"].ToString();
            string playType            = dr["PlayTypeID"].ToString();
            string tb_Share            = dr["Share"].ToString();
            string tb_BuyShare         = dr["BuyShare"].ToString();
            string tb_AssureShare      = dr["AssureShare"].ToString();
            string tb_OpenUserList     = dr["OpenUsers"].ToString();
            string tb_Title            = dr["Title"].ToString();
            string tb_Description      = dr["Description"].ToString();
            string tbSecrecyLevel      = dr["SecrecyLevel"].ToString();
            string tb_LotteryNumber    = dr["LotteryNumber"].ToString();
            string tb_hide_SumMoney    = dr["SumMoney"].ToString();
            string tb_hide_AssureMoney = dr["AssureMoney"].ToString();
            string HidLotteryID        = dr["LotteryID"].ToString();
            string tb_Multiple         = dr["Multiple"].ToString();

            if (tb_Multiple == "")
            {
                tb_Multiple = "1";
            }

            try
            {
                Share        = int.Parse(tb_Share);
                BuyShare     = int.Parse(tb_BuyShare);
                AssureMoney  = double.Parse(tb_hide_AssureMoney);
                Multiple     = int.Parse(tb_Multiple);
                SecrecyLevel = short.Parse(tbSecrecyLevel);
                PlayID       = int.Parse(playType);
                LotID        = int.Parse(HidLotteryID);
                IsuseID      = long.Parse(HidIsuseID);
            }
            catch { }

            if ((BuyShare == Share) && (AssureMoney == 0))
            {
                Share    = 1;
                BuyShare = 1;
            }

            double BuyMoney = BuyShare * (SumMoney / Share) + AssureMoney;

            LotteryNumber = tb_LotteryNumber;

            if (!string.IsNullOrEmpty(LotteryNumber) && LotteryNumber[LotteryNumber.Length - 1] == '\n')
            {
                LotteryNumber = LotteryNumber.Substring(0, LotteryNumber.Length - 1);
            }

            hidLotteryNumber.Value = LotteryNumber;
        }
        else
        {
            try
            {
                LotteryNumber = File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory + "Temp\\" + FileName + ".txt");
            }
            catch { }
        }

        if (string.IsNullOrEmpty(LotteryNumber))
        {
            Shove._Web.JavaScript.Alert(this.Page, "传递的参数错误,请重新发起操作!");

            return;
        }

        dt = new DAL.Tables.T_PassRate().Open("MatchID, MatchNumber, StopSellTime", "", "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count < 1)
        {
            return;
        }

        hidMatchID.Value = "";

        foreach (DataRow dr in dt.Rows)
        {
            hidMatchID.Value += dr["MatchID"].ToString() + ",";
        }

        if (hidMatchID.Value.EndsWith(","))
        {
            hidMatchID.Value = hidMatchID.Value.Substring(0, hidMatchID.Value.Length - 1);
        }

        StringBuilder sb = new StringBuilder();

        sb.Append("<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" class=\"BgBlue\">");
        sb.Append("<tr align=\"center\" bgcolor=\"#FFFFFF\" class=\"BlueLightBg WhiteWords\">");
        sb.Append("<td width=\"8%\"><strong>序号</strong></td>");
        sb.Append("<td><strong>过关场次</strong></td>");
        sb.Append("<td width=\"10%\"><strong>过关方式</strong></td>");
        sb.Append("<td width=\"10%\"><strong>注数</strong></td>");
        sb.Append("<td width=\"10%\"><strong>投注金额(元)</strong></td></tr>");

        string[] LotteryNumbers = LotteryNumber.Replace("\r", "").Split('\n');
        string   Number         = "";
        int      No             = 0;
        string   BuyWays        = "";

        StringBuilder sbMatchIDs = new StringBuilder();

        PlayID = Shove._Convert.StrToInt(LotteryNumbers[0].Split(';')[0], 7201);
        LotID  = Shove._Convert.StrToInt(PlayID.ToString().Substring(0, 2), 72);

        DateTime EndTime = DateTime.Now;

        if (BuyID > 0)
        {
            foreach (string str in LotteryNumbers)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                try
                {
                    Multiple = int.Parse(str.Split(';')[2].Substring(1, str.Split(';')[2].Length - 2).Substring(2));
                }
                catch
                {
                    Multiple = Shove._Convert.StrToInt(str.Split(';')[2].Substring(1, str.Split(';')[2].IndexOf(',') - 1).Substring(2), 1);
                }

                if (No > 10)
                {
                    continue;
                }

                sb.Append("<tr align=\"center\" class=\"" + ((No % 2 == 0) ? "BlueWord WhiteBg" : "BlueLightBg2 BlueWord") + "\">");
                sb.Append("<td>" + No.ToString() + "</td>");

                Number = str.Split(';')[1].Substring(1, str.Split(';')[1].Length - 2);
                string[] Numbers = Number.Split('|');

                if (Numbers.Length < 2)
                {
                    continue;
                }

                sb.Append("<td height=\"20\">");

                BuyWays = PF.GetPassWay(str);

                long MatchID = 0;

                for (int i = 0; i < Numbers.Length; i++)
                {
                    if (Numbers[i].IndexOf("(") < 0)
                    {
                        continue;
                    }

                    MatchID = Shove._Convert.StrToLong(Numbers[i].Substring(0, Numbers[i].IndexOf("(")), 1);

                    DataRow[] dr = dt.Select("MatchID=" + MatchID.ToString());

                    if (dr.Length < 1)
                    {
                        continue;
                    }

                    sbMatchIDs.Append(Numbers[i].Substring(0, Numbers[i].IndexOf("(")) + ",");

                    sb.Append(dr[0]["MatchNumber"].ToString() + "->" + PF.Getesult(PlayID.ToString(), Numbers[i].Substring(Numbers[i].IndexOf("(") + 1, Numbers[i].IndexOf(")") - Numbers[i].IndexOf("(") - 1)) + ";");
                }

                int ValidNum = 0;

                SLS.Lottery slsLottery  = new SLS.Lottery();
                string      temp_Number = slsLottery[LotID].AnalyseScheme(str, PlayID);

                if (string.IsNullOrEmpty(temp_Number))
                {
                    continue;
                }

                string[] str_s = temp_Number.Split('|');

                if (str_s == null || str_s.Length < 1)
                {
                    continue;
                }

                ValidNum += Shove._Convert.StrToInt(str_s[str_s.Length - 1], 0);

                sb.Append("</td>");
                sb.Append("<td height=\"20\">" + BuyWays + "</td>");
                sb.Append("<td>" + ValidNum.ToString() + "</td>");
                sb.Append("<td>" + (2 * Multiple * ValidNum).ToString() + "</td></tr>");

                SumMoney += 2 * Multiple * ValidNum;
                Count    += ValidNum;
            }

            sb.Append("</table>");
            labLotteryNumber.Text = sb.ToString();
        }
        else
        {
            foreach (string str in LotteryNumbers)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                No++;
                Count++;

                if (str.Split(';').Length < 3)
                {
                    continue;
                }

                try
                {
                    Multiple = Shove._Convert.StrToInt(str.Split(';')[2].Substring(1, str.Split(';')[2].Length - 2).Substring(2), 1);
                }
                catch
                { }

                SumMoney += 2 * Multiple;

                if (No > 10)
                {
                    continue;
                }

                sb.Append("<tr align=\"center\" class=\"" + ((No % 2 == 0) ? "BlueWord WhiteBg" : "BlueLightBg2 BlueWord") + "\">");
                sb.Append("<td>" + No.ToString() + "</td>");

                Number = str.Split(';')[1].Substring(1, str.Split(';')[1].Length - 2);
                string[] Numbers = Number.Split('|');

                if (Numbers.Length < 2)
                {
                    continue;
                }

                sb.Append("<td height=\"20\">");

                BuyWays = Numbers.Length.ToString() + "串1";

                long MatchID = 0;

                for (int i = 0; i < Numbers.Length; i++)
                {
                    if (Numbers[i].IndexOf("(") < 0)
                    {
                        continue;
                    }

                    MatchID = Shove._Convert.StrToLong(Numbers[i].Substring(0, Numbers[i].IndexOf("(")), 1);

                    DataRow[] dr = dt.Select("MatchID=" + MatchID.ToString());

                    if (dr.Length < 1)
                    {
                        continue;
                    }

                    sbMatchIDs.Append(Numbers[i].Substring(0, Numbers[i].IndexOf("(")) + ",");

                    sb.Append(dr[0]["MatchNumber"].ToString() + "->" + PF.Getesult(PlayID.ToString(), Numbers[i].Substring(Numbers[i].IndexOf("(") + 1, Numbers[i].IndexOf(")") - Numbers[i].IndexOf("(") - 1)) + ";");
                }

                sb.Append("</td>");
                sb.Append("<td height=\"20\">" + BuyWays + "</td>");
                sb.Append("<td>1</td>");
                sb.Append("<td>" + (2 * Multiple).ToString() + "</td></tr>");
            }

            sb.Append("</table>");
            labLotteryNumber.Text = sb.ToString();
        }

        labShare.Text       = Share.ToString();
        labBuyShare.Text    = BuyShare.ToString();
        labAssureMoney.Text = AssureMoney.ToString();

        string MatchIDs = sbMatchIDs.ToString();

        if (MatchIDs.EndsWith(","))
        {
            MatchIDs = MatchIDs.Substring(0, MatchIDs.Length - 1);
        }

        DataRow[] drTime = dt.Select("MatchID in (" + MatchIDs + ")", "StopSellTime");

        if (drTime.Length > 0)
        {
            EndTime = Shove._Convert.StrToDateTime(drTime[0]["StopSellTime"].ToString(), DateTime.Now.AddHours(1).ToString());
        }

        labEndTime.Text       = EndTime.ToString("yyyy-MM-dd HH:mm:ss");
        HidIsuseEndTime.Value = EndTime.ToString();

        labMultiple.Text    = Multiple.ToString();
        labSchemeMoney.Text = SumMoney.ToString();
        labNum.Text         = Count.ToString();

        dt = new DAL.Tables.T_Isuses().Open("ID", "LotteryID= " + LotID.ToString(), "EndTime desc");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count < 1)
        {
            PF.GoError(ErrorNumber.NoIsuse, "请添加期号", this.GetType().BaseType.FullName);

            return;
        }

        IsuseID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), 0);

        hidSchemeMoney.Value = SumMoney.ToString();
        hidMultiple.Value    = Multiple.ToString();
        hidlotid.Value       = LotID.ToString();
        hidplayid.Value      = PlayID.ToString();
        hidSumNum.Value      = Count.ToString();
        hidisuseid.Value     = IsuseID.ToString();
    }
Beispiel #23
0
    // 接收开奖通知
    private void IsuseOpenNotice(string Transmessage)
    {
        System.Xml.XmlDocument XmlDoc         = new XmlDocument();
        System.Xml.XmlNodeList nodes          = null;
        System.Xml.XmlNodeList nodesBonusItem = null;
        System.Xml.XmlNodeList nodesIssue     = null;

        try
        {
            XmlDoc.Load(new StringReader(Transmessage));

            nodes          = XmlDoc.GetElementsByTagName("*");
            nodesBonusItem = XmlDoc.GetElementsByTagName("bonusItem");
            nodesIssue     = XmlDoc.GetElementsByTagName("issue");
        }
        catch { }

        if (nodes == null)
        {
            return;
        }

        string BonusNumber = "";

        for (int j = 0; j < nodes.Count; j++)
        {
            if (!(nodes[j].Name.ToUpper() == "BODY" && nodes[j].FirstChild.Name.ToUpper() == "BONUSNOTIFY"))
            {
                continue;
            }

            BonusNumber = nodes[j].FirstChild.Attributes["bonusNumber"].InnerText;
        }

        if (nodesIssue == null)
        {
            this.Response.End();

            return;
        }

        string MessageID   = nodes[0].Attributes["id"].Value;
        string number      = nodesIssue[0].Attributes["number"].Value;
        string LotteryName = nodesIssue[0].Attributes["gameName"].Value;

        int LotteryID = GetLotteryID(LotteryName);

        string WinNumber = GetWinNumber(LotteryID, BonusNumber);

        DataTable dtIsuse = new DAL.Tables.T_Isuses().Open("", " [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(number) + "' and LotteryID = " + LotteryID.ToString() + " and IsOpened = 0 and LotteryID  in (select id from T_Lotteries where PrintOutType = 104)", "");

        if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
        {
            this.Response.End();

            return;
        }

        string IsuseID = dtIsuse.Rows[0]["ID"].ToString();

        DAL.Tables.T_Isuses T_Isuses = new DAL.Tables.T_Isuses();

        T_Isuses.WinLotteryNumber.Value = WinNumber;
        T_Isuses.OpenOperatorID.Value   = 1;
        T_Isuses.Update(" ID = " + IsuseID);

        int    ReturnValue       = 0;
        string ReturnDescription = "";

        DataTable dtWinTypesSSL = new DAL.Tables.T_WinTypes().Open("", " LotteryID =" + LotteryID.ToString(), "");

        if ((dtWinTypesSSL != null) && dtWinTypesSSL.Rows.Count > 0)
        {
            double[] WinMoneyList = new double[dtWinTypesSSL.Rows.Count * 2];

            double DefaultMoney          = 0;
            double DefaultMoneyNoWithTax = 0;

            for (int i = 0; i < dtWinTypesSSL.Rows.Count; i++)
            {
                DefaultMoney          = Shove._Convert.StrToDouble(dtWinTypesSSL.Rows[i]["DefaultMoney"].ToString(), 0);
                DefaultMoneyNoWithTax = Shove._Convert.StrToDouble(dtWinTypesSSL.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                WinMoneyList[i * 2]     = DefaultMoney == 0 ? 1 : DefaultMoneyNoWithTax;
                WinMoneyList[i * 2 + 1] = DefaultMoneyNoWithTax == 0 ? 1 : DefaultMoneyNoWithTax;
            }

            DataTable dtSchemesWithTaskDetails = new DAL.Tables.T_Schemes().Open("", "IsuseID = " + IsuseID + " and WinMoney = 0  and Buyed = 1 and isnull(Identifiers, '') = ''", "");

            string LotteryNumber       = "";
            SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

            string Description       = "";
            double WinMoneyNoWithTax = 0;

            for (int i = 0; i < dtSchemesWithTaskDetails.Rows.Count; i++)
            {
                LotteryNumber     = dtSchemesWithTaskDetails.Rows[i]["LotteryNumber"].ToString();
                Description       = "";
                WinMoneyNoWithTax = 0;

                double WinMoney = lb.ComputeWin(LotteryNumber, WinNumber.Trim(), ref Description, ref WinMoneyNoWithTax, int.Parse(dtSchemesWithTaskDetails.Rows[i]["PlayTypeID"].ToString()), WinMoneyList);

                if (WinMoney > 0)
                {
                    Shove.Database.MSSQL.ExecuteNonQuery("update T_Schemes set PreWinMoney = @p1, PreWinMoneyNoWithTax = @p2, WinMoney = @p3, WinMoneyNoWithTax = @p4, WinDescription = @p5 where [ID] = " + dtSchemesWithTaskDetails.Rows[i]["ID"].ToString(),
                                                         new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtSchemesWithTaskDetails.Rows[i]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtSchemesWithTaskDetails.Rows[i]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p3", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtSchemesWithTaskDetails.Rows[i]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p4", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtSchemesWithTaskDetails.Rows[i]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p5", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));

                    continue;
                }
            }
        }

        string BonusXML      = "<Schemes>";
        string AgentBonusXML = "<Schemes>";

        if ((nodesBonusItem != null) && (nodesBonusItem.Count > 0))
        {
            string  bonusItemXML = Transmessage.Substring(Transmessage.IndexOf("<bonusNotify"), Transmessage.LastIndexOf("</body>") - Transmessage.IndexOf("<bonusNotify"));
            DataSet dsXML        = new DataSet();

            try
            {
                dsXML.ReadXml(new StringReader(bonusItemXML));
            }
            catch (Exception e)
            {
                new Log("ElectronTicket\\HPSD").Write("电子票开奖,第 " + number + " 期解析开奖数据错误:" + e.Message);

                this.Response.End();

                return;
            }

            if ((dsXML == null) || (dsXML.Tables.Count < 3))
            {
                new Log("ElectronTicket\\HPSD").Write("电子票开奖,第 " + number + " 期开奖数据格式不符合要求。");

                this.Response.End();

                return;
            }

            DataTable dtTickets = dsXML.Tables[2];
            DataTable dtSchemes = MSSQL.Select("SELECT SchemeID, 0 AS AgentID, SchemesMultiple as Multiple, Identifiers FROM V_SchemesSendToCenter WHERE (IsuseID = " + IsuseID + ")");

            if (dtSchemes == null)
            {
                new Log("ElectronTicket\\HPSD").Write("电子票开奖,第 " + number + " 期,读取本地方案错误。");

                this.Response.End();

                return;
            }

            try
            {
                var query1 = from NewDtTickets in dtTickets.AsEnumerable()
                             join NewdtScheme in dtSchemes.AsEnumerable()
                             on NewDtTickets.Field <string>("ticketID") equals NewdtScheme.Field <string>("Identifiers")
                             select new
                {
                    ID         = NewdtScheme.Field <long>("SchemeID"),
                    AgentID    = 0,          //NewdtScheme.Field<long>("AgentID"),
                    Multiple   = NewdtScheme.Field <int>("Multiple"),
                    Bonus      = Shove._Convert.StrToDouble(NewDtTickets.Field <string>("money"), 0),
                    BonusLevel = NewDtTickets.Field <string>("bonusLevel"),
                };

                var query2 = from NewDt in query1.AsQueryable()
                             group NewDt by new { NewDt.ID, NewDt.BonusLevel, NewDt.AgentID, NewDt.Multiple } into gg
                    select new
                {
                    ID         = gg.Key.ID,
                    AgentID    = gg.Key.AgentID,
                    Multiple   = gg.Key.Multiple,
                    Bonus      = gg.Sum(NewDt => NewDt.Bonus),
                    BonusLevel = GetWinDescription(LotteryID, gg.Key.BonusLevel)
                };

                var query3 = from NewDt in query2.AsQueryable()
                             group NewDt by new { NewDt.ID, NewDt.Multiple, NewDt.AgentID } into t_dtSchemes
                    select new
                {
                    SchemeID   = t_dtSchemes.Key.ID,
                    AgentID    = t_dtSchemes.Key.AgentID,
                    Multiple   = t_dtSchemes.Key.Multiple,
                    Bonus      = t_dtSchemes.Sum(NewDt => NewDt.Bonus),
                    BonusLevel = "中奖金额:" + t_dtSchemes.Sum(NewDt => NewDt.Bonus).ToString() + ((t_dtSchemes.Key.Multiple != 1) ? "(" + t_dtSchemes.Key.Multiple.ToString() + "倍)" : "")
                };

                foreach (var Scheme in query3)
                {
                    if (Scheme.AgentID == 0)
                    {
                        BonusXML += "<Scheme SchemeID=\"" + Scheme.SchemeID.ToString() + "\" WinMoney=\"" + Scheme.Bonus.ToString() + "\" WinDescription=\"" + Scheme.BonusLevel + "\" />";
                    }
                    else
                    {
                        AgentBonusXML += "<Scheme SchemeID=\"" + Scheme.SchemeID.ToString() + "\" WinMoney=\"" + Scheme.Bonus.ToString() + "\" WinDescription=\"" + Scheme.BonusLevel + "\" />";
                    }
                }
            }
            catch (Exception e)
            {
                new Log("ElectronTicket\\HPSD").Write("电子票开奖,第 " + number + " 期详细中奖数据解析错误:" + e.Message);

                this.Response.End();

                return;
            }
        }

        BonusXML      += "</Schemes>";
        AgentBonusXML += "</Schemes>";

        dtIsuse = new DAL.Tables.T_Isuses().Open("", "[ID] = " + IsuseID + " and IsOpened = 0", "");

        if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
        {
            this.Response.End();

            return;
        }

        DataSet ds     = null;
        int     Times  = 0;
        int     Result = -1;

        while ((Result < 0) && (Times < 5))
        {
            ReturnValue       = 0;
            ReturnDescription = "";

            Result = DAL.Procedures.P_ElectronTicketWin(ref ds, Shove._Convert.StrToLong(IsuseID, 0), BonusXML, AgentBonusXML, ref ReturnValue, ref ReturnDescription);

            if (Result < 0)
            {
                new Log("ElectronTicket\\HPSD").Write("电子票第 " + (Times + 1).ToString() + " 次派奖出现错误(IsuseOpenNotice) 期号为: " + number + ",彩种为: " + LotteryID.ToString());
                Times++;

                if (Times < 5)
                {
                    System.Threading.Thread.Sleep(10000);
                }

                continue;
            }
        }

        if (ReturnValue < 0)
        {
            new Log("ElectronTicket\\HPSD").Write("电子票派奖出现错误(IsuseOpenNotice) 期号为: " + number + ",彩种为: " + LotteryID.ToString() + ",错误:" + ReturnDescription);

            this.Response.End();

            return;
        }

        DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open("", " LotteryID =" + LotteryID.ToString(), "");

        if ((dtWinTypes != null) && dtWinTypes.Rows.Count > 0)
        {
            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            double DefaultMoney          = 0;
            double DefaultMoneyNoWithTax = 0;

            for (int i = 0; i < dtWinTypes.Rows.Count; i++)
            {
                DefaultMoney          = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoney"].ToString(), 0);
                DefaultMoneyNoWithTax = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                WinMoneyList[i * 2]     = DefaultMoney == 0 ? 1 : DefaultMoneyNoWithTax;
                WinMoneyList[i * 2 + 1] = DefaultMoneyNoWithTax == 0 ? 1 : DefaultMoneyNoWithTax;
            }

            DataTable dtSchemesWithTaskDetails = new DAL.Views.V_Schemes().Open("LotteryNumber, PlayTypeID, SiteID, ID, Multiple", " IsuseID = " + IsuseID + " and WinMoney = 0  and Buyed = 0", "");

            string LotteryNumber       = "";
            SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

            string Description       = "";
            double WinMoneyNoWithTax = 0;

            for (int i = 0; i < dtSchemesWithTaskDetails.Rows.Count; i++)
            {
                LotteryNumber     = dtSchemesWithTaskDetails.Rows[i]["LotteryNumber"].ToString();
                Description       = "";
                WinMoneyNoWithTax = 0;

                double WinMoney = lb.ComputeWin(LotteryNumber, WinNumber.Trim(), ref Description, ref WinMoneyNoWithTax, int.Parse(dtSchemesWithTaskDetails.Rows[i]["PlayTypeID"].ToString()), WinMoneyList);

                if (WinMoney > 0)
                {
                    if (DAL.Procedures.P_ChaseTaskStopWhenWin(Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["SiteID"].ToString(), 0), Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["ID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescription) < 0)
                    {
                        new Log("ElectronTicket\\HPSD").Write("执行电子票--判断是否停止追号的时候出现错误");
                    }

                    continue;
                }
            }
        }

        PF.SendWinNotification(ds);

        MessageID = nodes[0].Attributes["id"].Value;
        ReNotice(MessageID, "508");
    }
Beispiel #24
0
        //江西时时彩
        private void GetLotteryOpenNumberForJXSSC(int LotteryID)
        {
            DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

            DataSet ds = new DataSet();

            try
            {
                ds.ReadXml(JXSSC_Open_URL);
            }
            catch
            {
                new Log("SystemGetLotteryOpenNumber").Write("江西时时彩获取开奖号码页面异常");

                return;
            }

            if ((ds == null) || (ds.Tables.Count < 1) || (ds.Tables[0].Rows.Count < 1))
            {
                new Log("SystemGetLotteryOpenNumber").Write("江西时时彩获取开奖号码页面异常");

                return;
            }

            int i = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                //期数
                string t_IsuseName = dr["expect"].ToString().Substring(4);

                //开奖号码
                string t_winLotteryNumber = dr["opencode"].ToString().Replace(",", "");

                if (t_Isuses.GetCount(conn, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + t_IsuseName + "' and isnull(WinLotteryNumber, '') = '' and year(StartTime) = YEAR(GETDATE())") < 1)
                {
                    continue;
                }

                try
                {
                    t_Isuses.WinLotteryNumber.Value = t_winLotteryNumber;
                    t_Isuses.Update(conn, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + t_IsuseName + "' and isnull(WinLotteryNumber, '') = '' and year(StartTime) = YEAR(GETDATE())");

                    if (GP_Open_RulSYYDJ == "1")
                    {
                        //开奖
                        DrawingLottery(LotteryID, t_IsuseName, t_winLotteryNumber);
                    }
                }
                catch (Exception e)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("江西时时彩获取开奖号码异常:" + e.Message);
                }

                if (i == 0)
                {
                    DateTime EndTime = Shove._Convert.StrToDateTime(dr["opentime"].ToString(), DateTime.Now.ToString());

                    int Result = 0;
                    string ReturnDescption = "";

                    DAL.Procedures.P_IsuseUpdate(conn, LotteryID, t_IsuseName, 1, EndTime.AddMinutes(-10), EndTime, DateTime.Now, t_winLotteryNumber, ref Result, ref ReturnDescption);
                }

                i++;
            }
        }
Beispiel #25
0
        private void Betting()  // 解析,投注
        {
            DAL.Tables.T_SmsBettings t_SmsBettings = new DAL.Tables.T_SmsBettings();
            DataTable dt = t_SmsBettings.Open(ConnectionString, "", "HandleResult = 0", "[ID]");

            if (dt == null)
            {
                msg.Send("Read SMS fail.");
                log.Write("Read SMS fail.");

                return;
            }

            foreach (DataRow dr in dt.Rows)
            {
                string ID = dr["ID"].ToString();
                string Mobile = dr["From"].ToString().Trim();
                string Content = Shove._Convert.ToDBC(dr["Content"].ToString()).Trim();

                if ((Mobile == "") || (Content == ""))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1000)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                string[] Contents = Content.Split(';');

                if ((Contents == null) || (Contents.Length != 6))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1001)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 1;501;1;1;010203040506+01|010203040506+01;#2                          站点ID;玩法ID;总份数;认购份数;号码|号码;#倍数

                long SiteID = Shove._Convert.StrToLong(Contents[0], -1);

                if (SiteID < 0)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1002)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                if (new DAL.Tables.T_Sites().GetCount(ConnectionString, "[ID] = " + SiteID.ToString()) < 0)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1003)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                #region 投注

                if (!Contents[5].StartsWith("#"))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1004)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                int PlayTypeID = Shove._Convert.StrToInt(Contents[1], -1);
                int Share = Shove._Convert.StrToInt(Contents[2], -1);
                int BuyShare = Shove._Convert.StrToInt(Contents[3], -1);
                string LotteryNumber = Contents[4].Trim();
                int Multiple = Shove._Convert.StrToInt(Contents[5].Substring(1, Contents[5].Length - 1), -1);

                if ((PlayTypeID < 0) || (BuyShare < 0) || (Share < BuyShare) || (LotteryNumber == "") || (Multiple < 0))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1005)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 根据手机获取用户
                DataTable dtUsers = new DAL.Tables.T_Users().Open(ConnectionString, "[ID], Balance", "SiteID = " + SiteID.ToString() + " and Mobile = '" + Mobile + "' and isMobileValided = 1", "");

                if ((dtUsers == null) || (dtUsers.Rows.Count != 1))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "用户不存在(1006)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                long UserID = Shove._Convert.StrToLong(dtUsers.Rows[0]["ID"].ToString(), -1);
                double Balance = Shove._Convert.StrToDouble(dtUsers.Rows[0]["Balance"].ToString(), 0);

                if (UserID < 0)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "用户不存在(1007)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 获取彩种、同时也校验了玩法
                DataTable dtLottery = new DAL.Tables.T_PlayTypes().Open(ConnectionString, "LotteryID, Price, MaxMultiple", "[ID] = " + PlayTypeID.ToString(), "");

                if ((dtLottery == null) || (dtLottery.Rows.Count < 1))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(1008)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                int LotteryID = Shove._Convert.StrToInt(dtLottery.Rows[0]["LotteryID"].ToString(), -1);
                double Price = Shove._Convert.StrToDouble(dtLottery.Rows[0]["Price"].ToString(), -1);
                int MaxMultiple = Shove._Convert.StrToInt(dtLottery.Rows[0]["MaxMultiple"].ToString(), -1);

                if ((LotteryID < 0) || (Price < 2) || (Multiple > MaxMultiple))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "短信格式错误(10090)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 校验投注号码,计算注数、金额
                int Num = 0;
                LotteryNumber = GetLotteryNumber(LotteryID, PlayTypeID, LotteryNumber, ref Num);

                if (Num < 1)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "投注号码错误(1010)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                double Money = Num * Price * Multiple;

                // 获取期号
                DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(ConnectionString, "top 1 [ID]", "LotteryID = " + LotteryID.ToString() + " and GetDate() between StartTime and dbo.F_GetIsuseSystemEndTime([ID], " + PlayTypeID.ToString() + ") and IsOpened = 0", "");

                if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "奖期未开启(1011)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1);

                if (IsuseID < 0)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "奖期未开启(1012)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 校验余额
                if (Balance < Money)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = "投注卡账户余额不足(1013)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                // 投注
                string ReturnDescription = "";
                long SchemeID = InitiateScheme(SiteID, UserID, IsuseID, PlayTypeID, "本方案由用户手动编写短信代码投注(系统)", "短信ID:" + ID + "\r\n短信内容:" + Content, LotteryNumber, "", Multiple, Money, 0, Share, BuyShare, "", 0, ref ReturnDescription);

                if (SchemeID < 0)
                {
                    t_SmsBettings.HandleResult.Value = -1;
                    t_SmsBettings.HandleDescription.Value = ReturnDescription + "(1015)";
                    t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                    continue;
                }

                t_SmsBettings.SchemeID.Value = SchemeID;
                t_SmsBettings.HandleResult.Value = 1;
                t_SmsBettings.Update(ConnectionString, "[ID] = " + ID);

                #endregion
            }
        }
        private void GetLotteryOpenNumber()	//获取开奖号码
        {
            //查询自动开奖的彩种的期号
            DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

            if ((AutomaticOpenLottery == null) || (AutomaticOpenLottery == ""))
            {
                new Log("SystemGetLotteryOpenNumber").Write("没有可自动开奖的彩种");

                return;
            }

            DataTable dt = null;
            try
            {
                dt = t_Isuses.Open(conn, "distinct LotteryID", "LotteryID in (" + AutomaticOpenLottery + ") and LotteryID not in (28, 61) and IsOpened = 0 and EndTime < Getdate() and DAY(EndTime) = DAY(GETDATE()) and month(getdate()) = MONTH(StartTime) and YEAR(GETDATE()) = YEAR(StartTime) and isnull(WinLotteryNumber, '') = ''", "");
            }
            catch (Exception e)
            {
                new Log("SystemGetLotteryOpenNumber").Write(e.Message);
                return;
            }

            if (dt == null)
            {
                new Log("SystemGetLotteryOpenNumber").Write("数据读取错误." + AutomaticOpenLottery);

                return;
            }

            int LotteryID = -1;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                LotteryID = Shove._Convert.StrToInt(dt.Rows[i]["LotteryID"].ToString(), -1);

                new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString());

                switch (LotteryID)
                {
                    case 6:
                        try
                        {
                            GetLotteryOpenNumberForFC3D(LotteryID);
                        }
                        catch (Exception EM)
                        {
                            new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                            break;
                        }
                        break;
                        
                    case 29:
                        try
                        {
                            GetLotteryOpenNumberForSHSSL(LotteryID);
                        }
                        catch (Exception EM)
                        {
                            new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                            break;
                        }
                        break;

                    case 62:
                        try
                        {
                            GetLotteryOpenNumberForSYYDJ(LotteryID);
                        }
                        catch (Exception EM)
                        {
                            new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                            break;
                        }
                        break;

                    case 63:
                        try
                        {
                            GetLotteryOpenNumberForSZPL3(LotteryID);
                        }
                        catch (Exception EM)
                        {
                            new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                            break;
                        }
                        break;

                    case 64:
                        try
                        {
                            GetLotteryOpenNumberForSZPL5(LotteryID);
                        }
                        catch (Exception EM)
                        {
                            new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                            break;
                        }
                        break;

                    case 70:
                        try
                        {
                            GetLotteryOpenNumberForJX11X5(LotteryID);
                        }
                        catch (Exception EM)
                        {
                            new Log("SystemGetLotteryOpenNumber").Write("开奖的彩种" + LotteryID.ToString() + ",  " + EM.Message);
                            break;
                        }
                        break;
                }
            }
        }
Beispiel #27
0
    protected void btnAdd_Click(object sender, System.EventArgs e)
    {
        DateTime StartDate;

        try
        {
            StartDate = DateTime.Parse(tbDate.Text);
        }
        catch
        {
            Shove._Web.JavaScript.Alert(this.Page, "开始日期输入错误。");

            return;
        }

        int Days = Shove._Convert.StrToInt(tbDays.Text, 0);

        if (Days < 1)
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入要连续增加的天数。");

            return;
        }

        if (Days > 10)
        {
            Shove._Web.JavaScript.Alert(this.Page, "高频彩种一次最多只能增加10天。");

            return;
        }

        int LotteryID = int.Parse(tbLotteryID.Text);

        if (LotteryID == SZJS.Lottery.CQSSC.ID)
        {
            string IntervalType = DAL.Functions.F_GetLotteryIntervalType(LotteryID);
            int    Interval     = int.Parse(IntervalType.Substring(1, IntervalType.IndexOf(";") - 1));
            string FirstEndTime = IntervalType.Substring(IntervalType.IndexOf(";") + 1, 8);
            int    Degree       = int.Parse(IntervalType.Substring(IntervalType.LastIndexOf(";") + 1));

            for (int i = 0; i < Days; i++)
            {
                string    sDate = StartDate.Date.ToShortDateString();
                DataTable dt    = dt = new DAL.Tables.T_Isuses().Open("[ID]", "StartTime between '" + sDate + " 02:00:00' and '" + sDate + " 23:59:59' and LotteryID = " + Shove._Web.Utility.FilteSqlInfusion(tbLotteryID.Text), "");

                if (dt == null)
                {
                    PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAddForKeno");

                    return;
                }

                if (dt.Rows.Count > 0)
                {
                    StartDate = StartDate.AddDays(1);

                    continue;
                }

                DateTime IsuseStartTime = DateTime.Parse(StartDate.Date.ToShortDateString() + " 0:0:0");
                DateTime IsuseEndTime   = IsuseStartTime.AddMinutes(5);
                string   Isuse          = StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + "-001";

                long   NewIsuseID        = 0;
                string ReturnDescription = "";

                int Result = DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription);

                if (Result < 0)
                {
                    PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAddForKeno");

                    return;
                }

                if (NewIsuseID < 0)
                {
                    PF.GoError(ErrorNumber.Unknow, ReturnDescription, "Admin_IsuseAddForKeno");

                    return;
                }

                //凌晨 0:05分到 01:55
                for (int j = 2; j <= 23; j++)
                {
                    IsuseStartTime = IsuseEndTime;
                    IsuseEndTime   = IsuseEndTime.AddMinutes(5);
                    Isuse          = Isuse = StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + "-" + j.ToString().PadLeft(3, '0');
                    if (DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription) < 0)
                    {
                        break;
                    }
                }

                //凌晨 01:55 到 晚上 22:00
                IsuseStartTime = DateTime.Parse(StartDate.Date.ToShortDateString() + " 01:55:00");
                IsuseEndTime   = DateTime.Parse(StartDate.Date.ToShortDateString() + " " + FirstEndTime);
                Isuse          = StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + "-024";
                Result         = DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription);

                if (Result < 0)
                {
                    PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAddForKeno");

                    return;
                }

                for (int j = 25; j <= 96; j++)
                {
                    IsuseStartTime = IsuseEndTime;
                    IsuseEndTime   = IsuseEndTime.AddMinutes(Interval);
                    Isuse          = Isuse = StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + "-" + j.ToString().PadLeft(3, '0');

                    if (DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription) < 0)
                    {
                        break;
                    }
                }

                //22:00:00 点到 00:00:00

                //重庆时时彩 夜场
                if (LotteryID == SZJS.Lottery.CQSSC.ID)
                {
                    for (int j = 97; j <= 120; j++)
                    {
                        IsuseStartTime = IsuseEndTime;
                        IsuseEndTime   = IsuseEndTime.AddMinutes(5);
                        Isuse          = ConvertIsuseName(LotteryID, StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + "-" + j.ToString().PadLeft(3, '0'));
                        if (DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription) < 0)
                        {
                            break;
                        }
                    }
                }

                StartDate = StartDate.AddDays(1);
            }
        }
        else
        {
            string IntervalType = DAL.Functions.F_GetLotteryIntervalType(LotteryID);
            int    Interval     = int.Parse(IntervalType.Substring(1, IntervalType.IndexOf(";") - 1));
            string FirstEndTime = IntervalType.Substring(IntervalType.IndexOf(";") + 1, 8);
            int    Degree       = int.Parse(IntervalType.Substring(IntervalType.LastIndexOf(";") + 1));

            for (int i = 0; i < Days; i++)
            {
                string    sDate = StartDate.Date.ToShortDateString();
                DataTable dt    = new DAL.Tables.T_Isuses().Open("[ID]", "StartTime between '" + sDate + " 0:0:0' and '" + sDate + " 23:59:59' and LotteryID = " + Shove._Web.Utility.FilteSqlInfusion(tbLotteryID.Text), "");

                if (dt == null)
                {
                    PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAddForKeno");

                    return;
                }

                if (dt.Rows.Count > 0)
                {
                    StartDate = StartDate.AddDays(1);

                    continue;
                }

                DateTime IsuseStartTime = DateTime.Parse(StartDate.Date.ToShortDateString() + " 0:0:0");
                DateTime IsuseEndTime   = DateTime.Parse(StartDate.Date.ToShortDateString() + " " + FirstEndTime);
                string   Isuse          = ConvertIsuseName(LotteryID, StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + "01");

                long   NewIsuseID        = -1;
                string ReturnDescription = "";

                int Result = DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription);

                if (Result < 0)
                {
                    PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_IsuseAddForKeno");

                    return;
                }

                if (NewIsuseID < 0)
                {
                    PF.GoError(ErrorNumber.Unknow, ReturnDescription, "Admin_IsuseAddForKeno");

                    return;
                }

                for (int j = 2; j <= Degree; j++)
                {
                    IsuseStartTime = IsuseEndTime;
                    IsuseEndTime   = IsuseEndTime.AddMinutes(Interval);
                    Isuse          = ConvertIsuseName(LotteryID, StartDate.Year.ToString() + StartDate.Month.ToString().PadLeft(2, '0') + StartDate.Day.ToString().PadLeft(2, '0') + j.ToString().PadLeft(2, '0'));
                    int Results = -1;
                    Results = DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, IsuseStartTime, IsuseEndTime, "", ref NewIsuseID, ref ReturnDescription);
                    if (Results < 0)
                    {
                        break;
                    }
                }

                StartDate = StartDate.AddDays(1);
            }
        }

        this.Response.Redirect("Isuse.aspx?LotteryID=" + tbLotteryID.Text, true);
    }
        //江西十一选五
        private void GetLotteryOpenNumberForJX11X5(int LotteryID)
        {
            DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

            DataSet ds = new DataSet();

            try
            {
                ds.ReadXml(JX11X5_Open_URL);
            }
            catch
            {
                new Log("SystemGetLotteryOpenNumber").Write("江西11选5获取开奖号码页面异常");

                return;
            }

            if ((ds == null) || (ds.Tables.Count < 1) || (ds.Tables[0].Rows.Count < 1))
            {
                new Log("SystemGetLotteryOpenNumber").Write("江西11选5获取开奖号码页面异常");

                return;
            }

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                //期数
                string t_IsuseName = dr["expect"].ToString();

                //开奖号码
                string t_winLotteryNumber = dr["opencode"].ToString().Replace(","," ");

                if (t_Isuses.GetCount(conn, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + t_IsuseName + "' and isnull(WinLotteryNumber, '') = '' and year(StartTime) = YEAR(GETDATE())") < 1)
                {
                    continue;
                }

                try
                {
                    t_Isuses.WinLotteryNumber.Value = t_winLotteryNumber;
                    t_Isuses.Update(conn, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + t_IsuseName + "' and isnull(WinLotteryNumber, '') = '' and year(StartTime) = YEAR(GETDATE())");

                    if (GP_Open_RulJX11X5 == "1")
                    {
                        //开奖
                        DrawingLottery(LotteryID, t_IsuseName, t_winLotteryNumber);
                    }
                }
                catch (Exception e)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("江西11选5获取开奖号码异常:" + e.Message);
                }
            }
        }
Beispiel #29
0
        //江西时时彩
        private void GetLotteryOpenNumberForJXSSC(int LotteryID)
        {
            DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

            DataSet ds = new DataSet();

            try
            {
                ds.ReadXml(JXSSC_Open_URL);
            }
            catch
            {
                new Log("SystemGetLotteryOpenNumber").Write("江西时时彩获取开奖号码页面异常");

                return;
            }

            if ((ds == null) || (ds.Tables.Count < 1) || (ds.Tables[0].Rows.Count < 1))
            {
                new Log("SystemGetLotteryOpenNumber").Write("江西时时彩获取开奖号码页面异常");

                return;
            }

            int i = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                //期数
                string t_IsuseName = dr["expect"].ToString().Substring(4);

                //开奖号码
                string t_winLotteryNumber = dr["opencode"].ToString().Replace(",", "");

                if (t_Isuses.GetCount(conn, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + t_IsuseName + "' and isnull(WinLotteryNumber, '') = '' and year(StartTime) = YEAR(GETDATE())") < 1)
                {
                    continue;
                }

                try
                {
                    t_Isuses.WinLotteryNumber.Value = t_winLotteryNumber;
                    t_Isuses.Update(conn, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + t_IsuseName + "' and isnull(WinLotteryNumber, '') = '' and year(StartTime) = YEAR(GETDATE())");

                    if (GP_Open_RulSYYDJ == "1")
                    {
                        //开奖
                        DrawingLottery(LotteryID, t_IsuseName, t_winLotteryNumber);
                    }
                }
                catch (Exception e)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("江西时时彩获取开奖号码异常:" + e.Message);
                }

                if (i == 0)
                {
                    DateTime EndTime = Shove._Convert.StrToDateTime(dr["opentime"].ToString(), DateTime.Now.ToString());

                    int    Result          = 0;
                    string ReturnDescption = "";

                    DAL.Procedures.P_IsuseUpdate(conn, LotteryID, t_IsuseName, 1, EndTime.AddMinutes(-10), EndTime, DateTime.Now, t_winLotteryNumber, ref Result, ref ReturnDescption);
                }

                i++;
            }
        }
        //开奖派奖
        private void DrawingLottery(int LotteryID, string IsuseName, string WinNumber)
        {
            Log log = new Log("SystemGetLotteryOpenNumber");

            if (!new SLS.Lottery()[LotteryID].AnalyseWinNumber(WinNumber))
            {
                log.Write("开奖号码不正确!");

                return;
            }

            int ReturnValue = 0;
            string ReturnDescription = "";

            DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(conn, "top 1 [ID], IsOpened", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "' and IsOpened=0 and year(StartTime) = YEAR(GETDATE())", "");
            
            if (dtIsuse == null)
            {
                log.Write("数据读写错误001");

                return;
            }

            if (dtIsuse.Rows.Count <= 0)
            {
                //log.Write("暂无对应期号信息,彩种ID:" + LotteryID.ToString() + ", 期号:" + IsuseName);

                return;
            }

            if (Shove._Convert.StrToBool(dtIsuse.Rows[0]["IsOpened"].ToString(), false))
            {
                //log.Write("彩种ID:" + LotteryID + "第" + IsuseName + "期已开奖");

                return;
            }

            long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1);

            DataTable dtWin = null;
            
            dtWin = new DAL.Tables.T_Schemes().Open(conn, "ID", "IsuseID = " + IsuseID.ToString() + " and isOpened = 0", "");

            if (dtWin == null)
            {
                log.Write("数据读写错误002");

                return;
            }

            // 准备开奖,开奖之前,对出票不完整的方案进行出票处理
            ReturnValue = 0;
            ReturnDescription = "";

            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(conn, "[DefaultMoney],[DefaultMoneyNoWithTax]", "LotteryID = " + LotteryID.ToString(), "[Order]");

            if (dtWinTypes == null)
            {
                log.Write("奖金读取数据读写错误");

                return;
            }

            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            for (int y = 0; y < dtWinTypes.Rows.Count; y++)
            {
                WinMoneyList[y * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoney"].ToString(), 0);
                WinMoneyList[y * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoneyNoWithTax"].ToString(), 0);

                if (WinMoneyList[y * 2] < 0)
                {
                    log.Write("第 " + (y + 1).ToString() + " 项奖金输入错误!");

                    return;
                }
            }

            dtWin = null;

            #region 开奖第一步

            dtWin = new DAL.Tables.T_Schemes().Open(conn, "LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + IsuseID.ToString(), "[ID]");

            if (dtWin == null)
            {
                log.Write("方案数据读取错误");

                return;
            }

            for (int y = 0; y < dtWin.Rows.Count; y++)
            {
                string LotteryNumber = "";

                try
                {
                    LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString();
                }
                catch
                { }

                string Description = "";
                double WinMoneyNoWithTax = 0;

                try
                {

                    double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList);

                    if (WinMoney > 0)
                    {
                        log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 中奖金额:" + WinMoney.ToString());
                    }

                    Shove.Database.MSSQL.ExecuteNonQuery(conn, "update T_Schemes set EditWinMoney = @p1, EditWinMoneyNoWithTax = @p2, WinDescription = @p3 where [ID] = " + dtWin.Rows[y]["ID"].ToString(),
                        new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                        new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                        new Shove.Database.MSSQL.Parameter("p3", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));
                }
                catch
                {
                    log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 开奖号码出现错误");

                    continue;
                }
            }

            #endregion

            log.Write("开奖-----------------------------4");

            #region 开奖第三步

            string OpenAffiche = new OpenAfficheTemplates()[LotteryID];

            int SchemeCount, QuashCount, WinCount, WinNoBuyCount;
            bool isEndOpen = false;

            while (!isEndOpen)
            {
                SchemeCount = 0;
                QuashCount = 0;
                WinCount = 0;
                WinNoBuyCount = 0;
                //  总方案数,处理时撤单数,中奖数,中奖但未成功数

                ReturnValue = 0;
                ReturnDescription = "";
                DataSet dsWin = null;

                P_Win(conn, ref dsWin,
                     IsuseID,
                     WinNumber,
                     OpenAffiche,
                     1,
                     true,
                     ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount,
                     ref isEndOpen,
                     ref ReturnValue, ref ReturnDescription);

                if ((dsWin == null) || (ReturnDescription != ""))
                {
                    log.Write(ReturnDescription);

                    return;
                }

                string Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖还未全部完成, 请继续操作第三步。";

                if (isEndOpen)
                {
                    Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖已全部完成。";
                }

                log.Write(String.Format(Message,LotteryID,WinNumber, SchemeCount, QuashCount, WinCount, WinNoBuyCount));
            }

            #endregion

            log.Write("开奖-----------------------------5");
        }
Beispiel #31
0
    protected void btnEdit_Click(object sender, System.EventArgs e)
    {
        string Isuse = "";

        try
        {
            Isuse = Shove._Web.Utility.FilteSqlInfusion(tbIsuse.Text.Trim());
        }
        catch
        { }

        if (Isuse == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "期号不能为空!");

            return;
        }

        DataTable dt = new DAL.Tables.T_Isuses().Open("[ID]", "[Name]='" + Isuse + "' and LotteryID=" + Shove._Web.Utility.FilteSqlInfusion(tbLotteryID.Text) + " and [ID] <> " + Shove._Web.Utility.FilteSqlInfusion(tbIsuseID.Text), "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count > 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "期号已经存在,请不要输入重名期号!");

            return;
        }

        System.DateTime StartTime, EndTime;

        object time = PF.ValidLotteryTime(tbStartTime.Text);

        if (time == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "开始时间格式输入错误!");
            return;
        }

        StartTime = (DateTime)time;

        time = PF.ValidLotteryTime(tbEndTime.Text);

        if (time == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "截止时间格式输入错误!");

            return;
        }

        EndTime = (DateTime)time;

        if (EndTime <= StartTime)
        {
            Shove._Web.JavaScript.Alert(this.Page, "截止时间应该在开始时间之后!");

            return;
        }

        string AdditionasXml = "";

        if ((tbLotteryID.Text == SLS.Lottery.SFC.sID || tbLotteryID.Text == SLS.Lottery.ZCSFC.sID || tbLotteryID.Text == SLS.Lottery.ZCRJC.sID) && (BuildAdditionasXmlForSFC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SLS.Lottery.JQC.sID) && (BuildAdditionasXmlForJQC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SLS.Lottery.LCBQC.sID) && (BuildAdditionasXmlForLCBQC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SLS.Lottery.LCDC.sID) && (BuildAdditionasXmlForLCDC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SLS.Lottery.ZCDC.sID) && (BuildAdditionasXmlForZCDC(ref AdditionasXml) < 0))
        {
            return;
        }

        long IsuseID = long.Parse(tbIsuseID.Text);

        int    ReturnValue       = -1;
        string ReturnDescription = "";

        int Result = DAL.Procedures.P_IsuseEdit(IsuseID, Isuse, StartTime, EndTime, AdditionasXml, ref ReturnValue, ref ReturnDescription);

        if (Result < 0)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

            return;
        }

        if (ReturnValue < 0)
        {
            PF.GoError(ErrorNumber.Unknow, ReturnDescription, this.Page.GetType().BaseType.FullName);

            return;
        }

        if (tbTestNumber.Text.Trim() != "")
        {
            DAL.Tables.T_TestNumber t_TestNumber = new DAL.Tables.T_TestNumber();

            t_TestNumber.TestNumber.Value = tbTestNumber.Text.Trim();
            t_TestNumber.IsuseID.Value    = IsuseID.ToString();

            if (Shove._Convert.StrToLong(hidID.Value, 0) > 0)
            {
                t_TestNumber.Update("ID=" + hidID.Value);
            }
            else
            {
                t_TestNumber.Insert();
            }
        }

        if (tbMoney.Text.Trim() != "")
        {
            DAL.Tables.T_TotalMoney t_TotalMoney = new DAL.Tables.T_TotalMoney();
            t_TotalMoney.TotalMoney.Value = tbMoney.Text.Trim();
            t_TotalMoney.IsuseID.Value    = tbIsuseID.Text;

            if (Shove._Convert.StrToLong(moneyID.Value, 0) > 0)
            {
                t_TotalMoney.Update("ID=" + moneyID.Value);
            }
            else
            {
                t_TotalMoney.Insert();
            }
        }
        Shove._Web.Cache.ClearCache(CacheKey.LotteryCalendar);
        Shove._Web.Cache.ClearCache(DataCache.IsusesInfo + tbLotteryID.Text.Trim());
        this.Response.Redirect("Isuse.aspx?LotteryID=" + tbLotteryID.Text, true);
    }
        private void Open()
        {
            //查询自动开奖的彩种的期号
            DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses();

            if ((AutomaticOpenLottery == null) || (AutomaticOpenLottery == ""))
            {
                new Log("SystemGetLotteryOpenNumber").Write("没有可自动开奖的彩种");

                return;
            }

            DataTable dt = null;
            try
            {
                dt = t_Isuses.Open(conn, "[ID], LotteryID, [Name], WinLotteryNumber", "LotteryID in (" + AutomaticOpenLottery + ") and IsOpened = 0 and EndTime < Getdate() and isnull(WinLotteryNumber, '') <> ''", "[EndTime] asc");
            }
            catch (Exception e)
            {
                new Log("SystemGetLotteryOpenNumber").Write(e.Message);
                return;
            }

            if (dt == null)
            {
                new Log("SystemGetLotteryOpenNumber").Write("数据读取错误." + AutomaticOpenLottery);

                return;
            }

            int LotteryID = -1;
            string IsuseName = "";
            string WinLotteryNumber = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                LotteryID = Shove._Convert.StrToInt(dt.Rows[i]["LotteryID"].ToString(), -1);
                IsuseName = dt.Rows[i]["Name"].ToString();
                WinLotteryNumber = dt.Rows[i]["WinLotteryNumber"].ToString();

                try
                {
                    DrawingLottery(LotteryID, IsuseName, WinLotteryNumber);
                }
                catch(Exception EX)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("开奖有错误." + EX.Message);
                    continue;
                }
            }
        }
Beispiel #33
0
    public DataSet GetSchemes(long AgentID, DateTime TimeStamp, string Sign, int LotteryID, string IssueName)
    {
        new Log("Agent\\ElectronTicket").Write(String.Format("Method=GetSchemes\tAgentID={0}\tTimeStamp={1}\tSign={2}\tLotteryID={3}\tIssueName={4}", AgentID, TimeStamp, Sign, LotteryID, IssueName));

        DataSet ds             = new DataSet();
        string  UseLotteryList = "";
        double  Balance        = 0;
        short   State          = 0;

        if (Valid(ref ds, ref UseLotteryList, ref Balance, ref State, AgentID, TimeStamp, Sign, LotteryID, IssueName) < 0)
        {
            return(ds);
        }

        if (ValidLotteryID(ref ds, UseLotteryList, LotteryID) < 0)
        {
            return(ds);
        }

        DataTable dt = new DAL.Tables.T_Isuses().Open("[ID], StartTime, EndTime, State, isOpened", "LotteryID = " + LotteryID.ToString() + "and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IssueName) + "'", "");

        if ((dt == null) || (dt.Rows.Count < 1))
        {
            BuildReturnDataSetForError(-4, "奖期不存在", ref ds);

            new Log("Agent\\ElectronTicket").Write("奖期不存在");

            return(ds);
        }

        long     IsuseID    = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1);
        DateTime StartTime  = Shove._Convert.StrToDateTime(dt.Rows[0]["StartTime"].ToString(), "1980-1-1 0:0:0");
        short    IsuseState = Shove._Convert.StrToShort(dt.Rows[0]["State"].ToString(), -1);

        if (IsuseID < 0)
        {
            BuildReturnDataSetForError(-4, "奖期不存在", ref ds);

            new Log("Agent\\ElectronTicket").Write("奖期不存在");

            return(ds);
        }

        DateTime Now = DateTime.Now;

        if ((Now < StartTime) || (IsuseState < 1))
        {
            BuildReturnDataSetForError(-5, "奖期未开启", ref ds);

            new Log("Agent\\ElectronTicket").Write("奖期未开启");

            return(ds);
        }

        BuildReturnDataSet(0, ref ds);

        DataTable dtSchemes = new DAL.Tables.T_ElectronTicketAgentSchemes().Open("SchemeNumber, State", "AgentID = " + AgentID.ToString() + " and IsuseID = " + IsuseID.ToString(), "[ID]");

        ds.Tables.Add(dtSchemes);

        return(ds);
    }
Beispiel #34
0
    private void BindBet()
    {
        long BuyID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("id"), 0);

        string type = Shove._Web.Utility.GetRequest("type").ToString();

        if (BuyID < 1)
        {
            Shove._Web.JavaScript.Alert(this.Page, "获取数据失败请重新操作");
            return;
        }

        if (_User == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "请登陆后执行此操作");
            return;
        }

        DataTable dt = null;

        // 通过ID 获取擂台方案表中的相关数据
        if (type == "1")
        {
            dt = new DAL.Tables.T_ChallengeScheme().Open("ID,[DateTime],InitiateUserId,IsuseID,PlayTypeID,LotteryNumber,IsOpened", " ID = " + BuyID, "");
        }
        else
        {
            dt = Shove.Database.MSSQL.Select("select ID,[DateTime],InitiateUserId,IsuseID,PlayTypeID,LotteryNumber,IsOpened from T_ChallengeSaveScheme where ID = " + BuyID);
        }

        if (dt == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "对不起获取该方案失败,请重新操作");
            return;
        }

        if (dt.Rows.Count != 1)
        {
            Shove._Web.JavaScript.Alert(this.Page, "对不起获取该方案失败,请重新操作");
            return;
        }
        // 是否已经开过奖的
        if (dt.Rows[0]["IsOpened"].ToString().Equals("1"))
        {
            Shove._Web.JavaScript.Alert(this.Page, "对不起该方案内容已截至");
            return;
        }

        #region

        string LotteryNumber = "";

        int    Multiple = 0;
        double SumMoney = 0;
        long   IsuseID  = 0;
        int    Count    = 0;
        int    LotID    = 0;
        int    PlayID   = 0;

        // 购买ID
        hidBuyID.Value = BuyID.ToString();

        DataRow dr = dt.Rows[0];

        string HidIsuseID = dt.Rows[0]["IsuseID"].ToString();
        string playType   = dt.Rows[0]["PlayTypeID"].ToString();
        // Share  总分数 1
        string tb_Share = "1";
        // 购买分数 为 1
        string tb_BuyShare = "1";
        // 不保密
        string tbSecrecyLevel = "0";

        string tb_LotteryNumber = dr["LotteryNumber"].ToString();
        // 购买金额等于 总金额
        string tb_hide_AssureMoney = "2";
        // 没有
        string HidLotteryID = "72";
        // 倍数1倍
        string tb_Multiple = "1";

        if (tb_Multiple == "")
        {
            tb_Multiple = "1";
        }

        int    Share        = 0;
        int    BuyShare     = 0;
        double AssureMoney  = 0;
        short  SecrecyLevel = 0;

        try
        {
            Share        = int.Parse(tb_Share);
            BuyShare     = int.Parse(tb_BuyShare);
            AssureMoney  = double.Parse(tb_hide_AssureMoney);
            Multiple     = int.Parse(tb_Multiple);
            SecrecyLevel = short.Parse(tbSecrecyLevel);
            PlayID       = int.Parse(playType);
            LotID        = int.Parse(HidLotteryID);
            IsuseID      = long.Parse(HidIsuseID);
        }
        catch { }

        if ((BuyShare == Share) && (AssureMoney == 0))
        {
            Share    = 1;
            BuyShare = 1;
        }

        double BuyMoney = BuyShare * (SumMoney / Share) + AssureMoney;

        LotteryNumber = tb_LotteryNumber;

        if (!string.IsNullOrEmpty(LotteryNumber) && LotteryNumber[LotteryNumber.Length - 1] == '\n')
        {
            LotteryNumber = LotteryNumber.Substring(0, LotteryNumber.Length - 1);
        }

        hidLotteryNumber.Value = LotteryNumber;

        if (string.IsNullOrEmpty(LotteryNumber))
        {
            Shove._Web.JavaScript.Alert(this.Page, "传递的参数错误,请重新发起操作!");

            return;
        }

        dt = new DAL.Tables.T_PassRate().Open("MatchID, MatchNumber, StopSellTime", "", "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName);

            return;
        }

        hidMatchID.Value = "";

        foreach (DataRow drr in dt.Rows)
        {
            hidMatchID.Value += drr["MatchID"].ToString() + ",";
        }

        if (hidMatchID.Value.EndsWith(","))
        {
            hidMatchID.Value = hidMatchID.Value.Substring(0, hidMatchID.Value.Length - 1);
        }

        StringBuilder sb = new StringBuilder();

        sb.Append("<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" class=\"BgBlue\">");
        sb.Append("<tr align=\"center\" bgcolor=\"#FFFFFF\" class=\"BlueLightBg WhiteWords\">");
        sb.Append("<td width=\"8%\"><strong>序号</strong></td>");
        sb.Append("<td><strong>过关场次</strong></td>");
        sb.Append("<td width=\"10%\"><strong>过关方式</strong></td>");
        sb.Append("<td width=\"10%\"><strong>注数</strong></td>");
        sb.Append("<td width=\"10%\"><strong>投注金额(元)</strong></td></tr>");

        string[] LotteryNumbers = LotteryNumber.Replace("\r", "").Split('\n');
        string   Number         = "";
        int      No             = 0;
        string   BuyWays        = "";

        StringBuilder sbMatchIDs = new StringBuilder();

        PlayID = Shove._Convert.StrToInt(LotteryNumbers[0].Split(';')[0], 7201);
        LotID  = Shove._Convert.StrToInt(PlayID.ToString().Substring(0, 2), 72);

        DateTime EndTime = DateTime.Now;

        foreach (string str in LotteryNumbers)
        {
            if (string.IsNullOrEmpty(str))
            {
                continue;
            }

            No++;
            Count++;

            if (str.Split(';').Length < 3)
            {
                continue;
            }

            try
            {
                Multiple = Shove._Convert.StrToInt(str.Split(';')[2].Substring(1, str.Split(';')[2].Length - 2).Substring(2), 1);
            }
            catch
            { }

            SumMoney += 2 * Multiple;

            if (No > 10)
            {
                continue;
            }

            sb.Append("<tr align=\"center\" class=\"" + ((No % 2 == 0) ? "BlueWord WhiteBg" : "BlueLightBg2 BlueWord") + "\">");
            sb.Append("<td>" + No.ToString() + "</td>");

            Number = str.Split(';')[1].Substring(1, str.Split(';')[1].Length - 2);
            string[] Numbers = Number.Split('|');

            if (Numbers.Length < 2)
            {
                continue;
            }

            sb.Append("<td height=\"20\">");

            BuyWays = Numbers.Length.ToString() + "串1";

            long MatchID = 0;

            for (int i = 0; i < Numbers.Length; i++)
            {
                if (Numbers[i].IndexOf("(") < 0)
                {
                    continue;
                }

                MatchID = Shove._Convert.StrToLong(Numbers[i].Substring(0, Numbers[i].IndexOf("(")), 1);

                DataRow[] dr2 = dt.Select("MatchID=" + MatchID.ToString());

                if (dr2.Length < 1)
                {
                    continue;
                }

                sbMatchIDs.Append(Numbers[i].Substring(0, Numbers[i].IndexOf("(")) + ",");

                sb.Append(dr2[0]["MatchNumber"].ToString() + "->" + PF.Getesult(PlayID.ToString(), Numbers[i].Substring(Numbers[i].IndexOf("(") + 1, Numbers[i].IndexOf(")") - Numbers[i].IndexOf("(") - 1)) + ";");
            }

            sb.Append("</td>");
            sb.Append("<td height=\"20\">" + BuyWays + "</td>");
            sb.Append("<td>1</td>");
            sb.Append("<td>" + (2 * Multiple).ToString() + "</td></tr>");
        }

        sb.Append("</table>");
        labLotteryNumber.Text = sb.ToString();

        string MatchIDs = sbMatchIDs.ToString();

        if (MatchIDs.EndsWith(","))
        {
            MatchIDs = MatchIDs.Substring(0, MatchIDs.Length - 1);
        }
        if (string.IsNullOrEmpty(MatchIDs.Trim()))
        {
            Shove._Web.JavaScript.Alert(this.Page, "无法获取信息");
            return;
        }
        DataRow[] drTime = dt.Select("MatchID in (" + MatchIDs + ")", "StopSellTime");

        if (drTime.Length > 0)
        {
            EndTime = Shove._Convert.StrToDateTime(drTime[0]["StopSellTime"].ToString(), DateTime.Now.AddHours(1).ToString());
        }

        labEndTime.Text       = EndTime.ToString("yyyy-MM-dd HH:mm:ss");
        HidIsuseEndTime.Value = EndTime.ToString();

        labMultiple.Text    = Multiple.ToString();
        labSchemeMoney.Text = SumMoney.ToString();
        labNum.Text         = Count.ToString();

        dt = new DAL.Tables.T_Isuses().Open("ID", "LotteryID= " + LotID.ToString(), "EndTime desc");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count < 1)
        {
            PF.GoError(ErrorNumber.NoIsuse, "请添加期号", this.GetType().BaseType.FullName);

            return;
        }

        IsuseID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), 0);

        hidSchemeMoney.Value = SumMoney.ToString();
        hidMultiple.Value    = Multiple.ToString();
        hidlotid.Value       = LotID.ToString();
        hidplayid.Value      = PlayID.ToString();
        hidSumNum.Value      = Count.ToString();
        hidisuseid.Value     = IsuseID.ToString();

        #endregion
    }