示例#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();
                        }
                    }
                }
            }
        }
    }
 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");
                     }
                 }
             }
         }
     }
 }
 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();
                     }
                 }
             }
         }
     }
 }
示例#4
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");
                        }
                    }
                }
            }
        }
    }