Beispiel #1
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 = 103)", "");

        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);


        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\\HPJX").Write("电子票开奖,第 " + number + " 期解析开奖数据错误:" + e.Message);

                this.Response.End();

                return;
            }

            if ((dsXML == null) || (dsXML.Tables.Count < 3))
            {
                new Log("ElectronTicket\\HPJX").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\\HPJX").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"),
                                 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)
                {
                    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\\HPJX").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;
        }

        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(ref ds, Shove._Convert.StrToLong(IsuseID, 0), BonusXML, AgentBonusXML, ref ReturnValue, ref ReturnDescription);

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

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

                continue;
            }
        }

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

            this.Response.End();

            return;
        }

        PF.SendWinNotification(ds);

        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("", "IsuseID = " + IsuseID + " and IsuseName = '" + Shove._Web.Utility.FilteSqlInfusion(number) + "' and LotteryID = " + LotteryID.ToString() + " and WinMoney = 0  and Buyed = 0 and ID in ( select ID from V_ChaseTaskDetails where IsuseName = '" + Shove._Web.Utility.FilteSqlInfusion(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(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\\HPJX").Write("执行电子票--判断是否停止追号的时候出现错误");
                    }

                    continue;
                }
            }
        }

        MessageID = nodes[0].Attributes["id"].Value;
        ReNotice(MessageID, "508");
    }
Beispiel #2
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 #3
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 #4
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);
    }