Пример #1
0
    private void IsuseOpenNotice(string Transmessage)
    {
        XmlDocument document          = new XmlDocument();
        XmlNodeList elementsByTagName = null;
        XmlNodeList list2             = null;
        XmlNodeList list3             = null;

        try
        {
            document.Load(new StringReader(Transmessage));
            elementsByTagName = document.GetElementsByTagName("*");
            list2             = document.GetElementsByTagName("bonusItem");
            list3             = document.GetElementsByTagName("issue");
        }
        catch
        {
        }
        if (elementsByTagName != null)
        {
            string winNumber = "";
            for (int i = 0; i < elementsByTagName.Count; i++)
            {
                if ((elementsByTagName[i].Name.ToUpper() == "BODY") && (elementsByTagName[i].FirstChild.Name.ToUpper() == "BONUSNOTIFY"))
                {
                    winNumber = elementsByTagName[i].FirstChild.Attributes["bonusNumber"].InnerText;
                }
            }
            if (list3 == null)
            {
                base.Response.End();
            }
            else
            {
                string    messageID   = elementsByTagName[0].Attributes["id"].Value;
                string    input       = list3[0].Attributes["number"].Value;
                string    lotteryName = list3[0].Attributes["gameName"].Value;
                int       LotteryID   = this.GetLotteryID(lotteryName);
                string    str5        = this.GetWinNumber(LotteryID, winNumber);
                DataTable table       = new Tables.T_Isuses().Open("", " [Name] = '" + Utility.FilteSqlInfusion(input) + "' and LotteryID = " + LotteryID.ToString() + " and IsOpened = 0", "");
                if ((table == null) || (table.Rows.Count < 1))
                {
                    base.Response.End();
                }
                else
                {
                    string str = table.Rows[0]["ID"].ToString();
                    new Tables.T_Isuses {
                        WinLotteryNumber = { Value = str5 }, OpenOperatorID = { Value = 1 }
                    }.Update(" ID = " + str);
                    string bonusXML      = "<Schemes>";
                    string agentBonusXML = "<Schemes>";
                    if ((list2 != null) && (list2.Count > 0))
                    {
                        string  s   = Transmessage.Substring(Transmessage.IndexOf("<bonusNotify"), Transmessage.LastIndexOf("</body>") - Transmessage.IndexOf("<bonusNotify"));
                        DataSet set = new DataSet();
                        try
                        {
                            set.ReadXml(new StringReader(s));
                        }
                        catch (Exception exception)
                        {
                            new Log(@"ElectronTicket\HPSH").Write("电子票开奖,第 " + input + " 期解析开奖数据错误:" + exception.Message);
                            base.Response.End();
                            return;
                        }
                        if ((set == null) || (set.Tables.Count < 3))
                        {
                            new Log(@"ElectronTicket\HPSH").Write("电子票开奖,第 " + input + " 期开奖数据格式不符合要求。");
                            base.Response.End();
                            return;
                        }
                        DataTable source = set.Tables[2];
                        DataTable table3 = MSSQL.Select("SELECT SchemeID, AgentID, SchemesMultiple as Multiple, Identifiers FROM V_ElectronTicketAgentSchemesSendToCenter WHERE (IsuseID = " + str + ") UNION ALL SELECT SchemeID, 0 AS AgentID, SchemesMultiple as Multiple, Identifiers FROM V_SchemesSendToCenter WHERE (IsuseID = " + str + ")", new MSSQL.Parameter[0]);
                        if (table3 == null)
                        {
                            new Log(@"ElectronTicket\HPSH").Write("电子票开奖,第 " + input + " 期,读取本地方案错误。");
                            base.Response.End();
                            return;
                        }
                        try
                        {
                            foreach (var type in from NewDt in
                                     (from NewDt in
                                      (from NewDtTickets in source.AsEnumerable()
                                       join NewdtScheme in table3.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 = _Convert.StrToDouble(NewDtTickets.Field <string>("money"), 0.0), BonusLevel = NewDtTickets.Field <string>("bonusLevel"), Size = _Convert.StrToInt(NewDtTickets.Field <string>("size"), 1) }).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 = this.GetSchemeWinDescription(gg.Key.BonusLevel, LotteryID, gg.Sum(NewDt => NewDt.Size) / gg.Key.Multiple) }).AsQueryable()
                                     group NewDt by new { ID = NewDt.ID, Multiple = NewDt.Multiple, AgentID = 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() + "倍)") : "") })
                            {
                                string str10;
                                if (type.AgentID == 0L)
                                {
                                    str10    = bonusXML;
                                    bonusXML = str10 + "<Scheme SchemeID=\"" + type.SchemeID.ToString() + "\" WinMoney=\"" + type.Bonus.ToString() + "\" WinDescription=\"" + type.BonusLevel + "\" />";
                                }
                                else
                                {
                                    str10         = agentBonusXML;
                                    agentBonusXML = str10 + "<Scheme SchemeID=\"" + type.SchemeID.ToString() + "\" WinMoney=\"" + type.Bonus.ToString() + "\" WinDescription=\"" + type.BonusLevel + "\" />";
                                }
                            }
                        }
                        catch (Exception exception2)
                        {
                            new Log(@"ElectronTicket\HPSH").Write("电子票开奖,第 " + input + " 期详细中奖数据解析错误:" + exception2.Message);
                            base.Response.End();
                            return;
                        }
                    }
                    bonusXML      = bonusXML + "</Schemes>";
                    agentBonusXML = agentBonusXML + "</Schemes>";
                    table         = new Tables.T_Isuses().Open("", "[ID] = " + str + " and IsOpened = 0", "");
                    if ((table == null) || (table.Rows.Count < 1))
                    {
                        base.Response.End();
                    }
                    else
                    {
                        int     returnValue       = 0;
                        string  returnDescription = "";
                        DataSet ds   = null;
                        int     num5 = 0;
                        int     num6 = -1;
                        string  appSettingsString = WebConfig.GetAppSettingsString("ConnectionString");
                        if (appSettingsString.StartsWith("0x78AD"))
                        {
                            appSettingsString = Encrypt.Decrypt3DES(PF.GetCallCert(), appSettingsString.Substring(6), PF.DesKey);
                        }
                        SqlConnection conn = MSSQL.CreateDataConnection(appSettingsString + ";Connect Timeout=150;");
                        if (conn != null)
                        {
                            while ((num6 < 0) && (num5 < 5))
                            {
                                returnValue       = 0;
                                returnDescription = "";
                                num6 = this.P_ElectronTicketWin(conn, ref ds, _Convert.StrToLong(str, 0L), bonusXML, agentBonusXML, ref returnValue, ref returnDescription);
                                if (num6 < 0)
                                {
                                    string[] strArray = new string[] { "电子票第 ", (num5 + 1).ToString(), " 次派奖出现错误(IsuseOpenNotice) 期号为: ", input, ",彩种为: ", LotteryID.ToString() };
                                    new Log(@"ElectronTicket\HPSH").Write(string.Concat(strArray));
                                    num5++;
                                    if (num5 < 5)
                                    {
                                        Thread.Sleep(0x2710);
                                    }
                                }
                            }
                            if (returnValue < 0)
                            {
                                new Log(@"ElectronTicket\HPSH").Write("电子票派奖出现错误(IsuseOpenNotice) 期号为: " + input + ",彩种为: " + LotteryID.ToString() + ",错误:" + returnDescription);
                                base.Response.End();
                            }
                            else
                            {
                                PF.SendWinNotification(ds);
                                DataTable table4 = new Tables.T_WinTypes().Open("", " LotteryID =" + LotteryID.ToString(), "");
                                if ((table4 != null) && (table4.Rows.Count > 0))
                                {
                                    double[] winMoneyList = new double[table4.Rows.Count * 2];
                                    double   num8         = 0.0;
                                    double   num9         = 0.0;
                                    for (int j = 0; j < table4.Rows.Count; j++)
                                    {
                                        num8 = _Convert.StrToDouble(table4.Rows[j]["DefaultMoney"].ToString(), 0.0);
                                        num9 = _Convert.StrToDouble(table4.Rows[j]["DefaultMoneyNoWithTax"].ToString(), 0.0);
                                        winMoneyList[j * 2]       = (num8 == 0.0) ? 1.0 : num9;
                                        winMoneyList[(j * 2) + 1] = (num9 == 0.0) ? 1.0 : num9;
                                    }
                                    DataTable           table5            = new Views.V_Schemes().Open("", " IsuseName = '" + Utility.FilteSqlInfusion(input) + "' and LotteryID = " + LotteryID.ToString() + " and WinMoney = 0  and Buyed = 0 and ID in ( select ID from V_ChaseTaskDetails where IsuseName = '" + Utility.FilteSqlInfusion(input) + "' and LotteryID = " + LotteryID.ToString() + ")", "");
                                    string              number            = "";
                                    Lottery.LotteryBase base2             = new Lottery()[LotteryID];
                                    string              description       = "";
                                    double              winMoneyNoWithTax = 0.0;
                                    for (int k = 0; k < table5.Rows.Count; k++)
                                    {
                                        number            = table5.Rows[k]["LotteryNumber"].ToString();
                                        description       = "";
                                        winMoneyNoWithTax = 0.0;
                                        double winMoney = base2.ComputeWin(number, str5.Trim(), ref description, ref winMoneyNoWithTax, int.Parse(table5.Rows[k]["PlayTypeID"].ToString()), winMoneyList);
                                        if ((winMoney > 0.0) && (Procedures.P_ChaseTaskStopWhenWin(_Convert.StrToLong(table5.Rows[k]["SiteID"].ToString(), 0L), _Convert.StrToLong(table5.Rows[k]["ID"].ToString(), 0L), winMoney, ref returnValue, ref returnDescription) < 0))
                                        {
                                            new Log(@"ElectronTicket\HPSH").Write("执行电子票--判断是否停止追号的时候出现错误");
                                        }
                                    }
                                }
                                messageID = elementsByTagName[0].Attributes["id"].Value;
                                this.ReNotice(messageID, "508");
                            }
                        }
                        else
                        {
                            base.Response.End();
                        }
                    }
                }
            }
        }
    }
Пример #2
0
    private void IsuseOpenNotice(string Transmessage)
    {
        XmlDocument document          = new XmlDocument();
        XmlNodeList elementsByTagName = null;
        XmlNodeList list2             = null;
        XmlNodeList list3             = null;

        try
        {
            document.Load(new StringReader(Transmessage));
            elementsByTagName = document.GetElementsByTagName("*");
            list2             = document.GetElementsByTagName("bonusItem");
            list3             = document.GetElementsByTagName("issue");
        }
        catch
        {
        }
        if (elementsByTagName != null)
        {
            string winNumber = "";
            for (int i = 0; i < elementsByTagName.Count; i++)
            {
                if ((elementsByTagName[i].Name.ToUpper() == "BODY") && (elementsByTagName[i].FirstChild.Name.ToUpper() == "BONUSNOTIFY"))
                {
                    winNumber = elementsByTagName[i].FirstChild.Attributes["bonusNumber"].InnerText;
                }
            }
            if (list3 == null)
            {
                base.Response.End();
            }
            else
            {
                string    messageID   = elementsByTagName[0].Attributes["id"].Value;
                string    input       = list3[0].Attributes["number"].Value;
                string    lotteryName = list3[0].Attributes["gameName"].Value;
                int       LotteryID   = this.GetLotteryID(lotteryName);
                string    str5        = this.GetWinNumber(LotteryID, winNumber);
                DataTable table       = new Tables.T_Isuses().Open("", " [Name] = '" + Utility.FilteSqlInfusion(input) + "' and LotteryID = " + LotteryID.ToString() + " and IsOpened = 0", "");
                if ((table == null) || (table.Rows.Count < 1))
                {
                    base.Response.End();
                }
                else
                {
                    string str = table.Rows[0]["ID"].ToString();
                    new Tables.T_Isuses {
                        WinLotteryNumber = { Value = str5 }, OpenOperatorID = { Value = 1 }
                    }.Update(" ID = " + str);
                    int    returnValue       = 0;
                    string returnDescription = "";
                    if (LotteryID == 0x3e)
                    {
                        DataTable table2 = new Tables.T_WinTypes().Open("", " LotteryID =" + LotteryID.ToString(), "");
                        if ((table2 != null) && (table2.Rows.Count > 0))
                        {
                            double[] winMoneyList = new double[table2.Rows.Count * 2];
                            double   num3         = 0.0;
                            double   num4         = 0.0;
                            for (int j = 0; j < table2.Rows.Count; j++)
                            {
                                num3 = _Convert.StrToDouble(table2.Rows[j]["DefaultMoney"].ToString(), 0.0);
                                num4 = _Convert.StrToDouble(table2.Rows[j]["DefaultMoneyNoWithTax"].ToString(), 0.0);
                                winMoneyList[j * 2]       = (num3 == 0.0) ? 1.0 : num4;
                                winMoneyList[(j * 2) + 1] = (num4 == 0.0) ? 1.0 : num4;
                            }
                            DataTable           table3            = new Tables.T_Schemes().Open("", "IsuseID = " + str + " and WinMoney = 0  and Buyed = 1 and BuyOperatorID = 132011", "");
                            string              number            = "";
                            Lottery.LotteryBase base2             = new Lottery()[LotteryID];
                            string              description       = "";
                            double              winMoneyNoWithTax = 0.0;
                            for (int k = 0; k < table3.Rows.Count; k++)
                            {
                                number            = table3.Rows[k]["LotteryNumber"].ToString();
                                description       = "";
                                winMoneyNoWithTax = 0.0;
                                double num8 = base2.ComputeWin(number, str5.Trim(), ref description, ref winMoneyNoWithTax, int.Parse(table3.Rows[k]["PlayTypeID"].ToString()), winMoneyList);
                                if (num8 > 0.0)
                                {
                                    MSSQL.ExecuteNonQuery("update T_Schemes set PreWinMoney = @p1, PreWinMoneyNoWithTax = @p2, WinMoney = @p3, WinMoneyNoWithTax = @p4, WinDescription = @p5 where [ID] = " + table3.Rows[k]["ID"].ToString(), new MSSQL.Parameter[] { new MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, num8 * _Convert.StrToInt(table3.Rows[k]["Multiple"].ToString(), 1)), new MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, winMoneyNoWithTax * _Convert.StrToInt(table3.Rows[k]["Multiple"].ToString(), 1)), new MSSQL.Parameter("p3", SqlDbType.Money, 0, ParameterDirection.Input, num8 * _Convert.StrToInt(table3.Rows[k]["Multiple"].ToString(), 1)), new MSSQL.Parameter("p4", SqlDbType.Money, 0, ParameterDirection.Input, winMoneyNoWithTax * _Convert.StrToInt(table3.Rows[k]["Multiple"].ToString(), 1)), new MSSQL.Parameter("p5", SqlDbType.VarChar, 0, ParameterDirection.Input, description) });
                                }
                            }
                        }
                    }
                    string bonusXML      = "<Schemes>";
                    string agentBonusXML = "<Schemes>";
                    if ((list2 != null) && (list2.Count > 0))
                    {
                        string  s   = Transmessage.Substring(Transmessage.IndexOf("<bonusNotify"), Transmessage.LastIndexOf("</body>") - Transmessage.IndexOf("<bonusNotify"));
                        DataSet set = new DataSet();
                        try
                        {
                            set.ReadXml(new StringReader(s));
                        }
                        catch (Exception exception)
                        {
                            new Log(@"ElectronTicket\HPSD").Write("电子票开奖,第 " + input + " 期解析开奖数据错误:" + exception.Message);
                            base.Response.End();
                            return;
                        }
                        if ((set == null) || (set.Tables.Count < 3))
                        {
                            new Log(@"ElectronTicket\HPSD").Write("电子票开奖,第 " + input + " 期开奖数据格式不符合要求。");
                            base.Response.End();
                            return;
                        }
                        DataTable source = set.Tables[2];
                        DataTable table5 = MSSQL.Select("SELECT SchemeID, AgentID, SchemesMultiple as Multiple, Identifiers FROM V_ElectronTicketAgentSchemesSendToCenter WHERE (IsuseID = " + str + ") UNION ALL SELECT SchemeID, 0 AS AgentID, SchemesMultiple as Multiple, Identifiers FROM V_SchemesSendToCenter WHERE (IsuseID = " + str + ")", new MSSQL.Parameter[0]);
                        if (table5 == null)
                        {
                            new Log(@"ElectronTicket\HPSD").Write("电子票开奖,第 " + input + " 期,读取本地方案错误。");
                            base.Response.End();
                            return;
                        }
                        try
                        {
                            foreach (var type in from NewDt in
                                     (from NewDt in
                                      (from NewDtTickets in source.AsEnumerable()
                                       join NewdtScheme in table5.AsEnumerable() on NewDtTickets.Field <string>("ticketID") equals NewdtScheme.Field <string>("Identifiers")                     //Sum<Package>((Func<Package, double>) (pkg => pkg.Weight));
                                       select new { ID = NewdtScheme.Field <long>("SchemeID"), AgentID = NewdtScheme.Field <long>("AgentID"), Multiple = NewdtScheme.Field <int>("Multiple"), Bonus = _Convert.StrToDouble(NewDtTickets.Field <string>("money"), 0.0), BonusLevel = NewDtTickets.Field <string>("bonusLevel") }).AsQueryable()
                                      group NewDt by new { ID = NewDt.ID, BonusLevel = NewDt.BonusLevel, AgentID = NewDt.AgentID, Multiple = 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 = this.GetWinDescription(LotteryID, gg.Key.BonusLevel) }).AsQueryable()
                                     group NewDt by new { ID = NewDt.ID, Multiple = NewDt.Multiple, AgentID = 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() + "倍)") : "") })
                            {
                                string str13;
                                if (type.AgentID == 0L)
                                {
                                    str13    = bonusXML;
                                    bonusXML = str13 + "<Scheme SchemeID=\"" + type.SchemeID.ToString() + "\" WinMoney=\"" + type.Bonus.ToString() + "\" WinDescription=\"" + type.BonusLevel + "\" />";
                                }
                                else
                                {
                                    str13         = agentBonusXML;
                                    agentBonusXML = str13 + "<Scheme SchemeID=\"" + type.SchemeID.ToString() + "\" WinMoney=\"" + type.Bonus.ToString() + "\" WinDescription=\"" + type.BonusLevel + "\" />";
                                }
                            }
                        }
                        catch (Exception exception2)
                        {
                            new Log(@"ElectronTicket\HPSD").Write("电子票开奖,第 " + input + " 期详细中奖数据解析错误:" + exception2.Message);
                            base.Response.End();
                            return;
                        }
                    }
                    bonusXML      = bonusXML + "</Schemes>";
                    agentBonusXML = agentBonusXML + "</Schemes>";
                    table         = new Tables.T_Isuses().Open("", "[ID] = " + str + " and IsOpened = 0", "");
                    if ((table == null) || (table.Rows.Count < 1))
                    {
                        base.Response.End();
                    }
                    else
                    {
                        DataSet ds    = null;
                        int     num11 = 0;
                        int     num12 = -1;
                        while ((num12 < 0) && (num11 < 5))
                        {
                            returnValue       = 0;
                            returnDescription = "";
                            num12             = Procedures.P_ElectronTicketWin(ref ds, _Convert.StrToLong(str, 0L), bonusXML, agentBonusXML, ref returnValue, ref returnDescription);
                            if (num12 < 0)
                            {
                                string[] strArray = new string[] { "电子票第 ", (num11 + 1).ToString(), " 次派奖出现错误(IsuseOpenNotice) 期号为: ", input, ",彩种为: ", LotteryID.ToString() };
                                new Log(@"ElectronTicket\HPSD").Write(string.Concat(strArray));
                                num11++;
                                if (num11 < 5)
                                {
                                    Thread.Sleep(0x2710);
                                }
                            }
                        }
                        if (returnValue < 0)
                        {
                            new Log(@"ElectronTicket\HPSD").Write("电子票派奖出现错误(IsuseOpenNotice) 期号为: " + input + ",彩种为: " + LotteryID.ToString() + ",错误:" + returnDescription);
                            base.Response.End();
                        }
                        else
                        {
                            DataTable table6 = new Tables.T_WinTypes().Open("", " LotteryID =" + LotteryID.ToString(), "");
                            if ((table6 != null) && (table6.Rows.Count > 0))
                            {
                                double[] numArray2 = new double[table6.Rows.Count * 2];
                                double   num14     = 0.0;
                                double   num15     = 0.0;
                                for (int m = 0; m < table6.Rows.Count; m++)
                                {
                                    num14                  = _Convert.StrToDouble(table6.Rows[m]["DefaultMoney"].ToString(), 0.0);
                                    num15                  = _Convert.StrToDouble(table6.Rows[m]["DefaultMoneyNoWithTax"].ToString(), 0.0);
                                    numArray2[m * 2]       = (num14 == 0.0) ? 1.0 : num15;
                                    numArray2[(m * 2) + 1] = (num15 == 0.0) ? 1.0 : num15;
                                }
                                DataTable           table7 = new Views.V_Schemes().Open("LotteryNumber, PlayTypeID, SiteID, ID, Multiple", " IsuseID = " + str + " and WinMoney = 0  and Buyed = 0", "");
                                string              str14  = "";
                                Lottery.LotteryBase base3  = new Lottery()[LotteryID];
                                string              str15  = "";
                                double              num17  = 0.0;
                                for (int n = 0; n < table7.Rows.Count; n++)
                                {
                                    str14 = table7.Rows[n]["LotteryNumber"].ToString();
                                    str15 = "";
                                    num17 = 0.0;
                                    double winMoney = base3.ComputeWin(str14, str5.Trim(), ref str15, ref num17, int.Parse(table7.Rows[n]["PlayTypeID"].ToString()), numArray2);
                                    if ((winMoney > 0.0) && (Procedures.P_ChaseTaskStopWhenWin(_Convert.StrToLong(table7.Rows[n]["SiteID"].ToString(), 0L), _Convert.StrToLong(table7.Rows[n]["ID"].ToString(), 0L), winMoney, ref returnValue, ref returnDescription) < 0))
                                    {
                                        new Log(@"ElectronTicket\HPSD").Write("执行电子票--判断是否停止追号的时候出现错误");
                                    }
                                }
                            }
                            PF.SendWinNotification(ds);
                            messageID = elementsByTagName[0].Attributes["id"].Value;
                            this.ReNotice(messageID, "508");
                        }
                    }
                }
            }
        }
    }
Пример #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");
    }
Пример #4
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);
    }