// 接收奖期通知 private void IsuseNotice(string TransMessage) { System.Xml.XmlDocument XmlDoc = new XmlDocument(); System.Xml.XmlNodeList nodes = null; System.Xml.XmlNodeList nodesIssue = null; try { XmlDoc.Load(new StringReader(TransMessage)); nodes = XmlDoc.GetElementsByTagName("*"); nodesIssue = XmlDoc.GetElementsByTagName("issue"); } catch { } if (nodes == null) { this.Response.End(); return; } DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses(); for (int i = 0; i < nodes.Count; i++) { if (!(nodes[i].Name.ToUpper() == "BODY" && nodes[i].FirstChild.Name.ToUpper() == "ISSUENOTIFY")) { continue; } for (int j = 0; j < nodesIssue.Count; j++) { string IsuseName = nodesIssue[j].Attributes["number"].Value; string LotteryName = nodesIssue[j].Attributes["gameName"].Value; string Status = nodesIssue[j].Attributes["status"].Value; string StartTime = nodesIssue[j].Attributes["startTime"].Value; string EndTime = nodesIssue[j].Attributes["stopTime"].Value; int LotteryID = GetLotteryID(LotteryName); string WinNumber = ""; try { WinNumber = GetWinNumber(LotteryID, nodesIssue[j].Attributes["bonusCode"].Value); } catch { } if ((LotteryID < 0) || (String.IsNullOrEmpty(IsuseName))) { continue; } if (t_Isuses.GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IsuseName) + "'") < 1) { DateTime _StartTime = DateTime.Now; DateTime _EndTime = DateTime.Now; try { _StartTime = DateTime.Parse(StartTime); _EndTime = DateTime.Parse(EndTime); } catch { continue; } long IsuseID = -1; string ReturnDescription = ""; if (DAL.Procedures.P_IsuseAdd(LotteryID, IsuseName, _StartTime, _EndTime, "", ref IsuseID, ref ReturnDescription) < 0) { continue; } if (IsuseID < 0) { continue; } } DataTable dtIsuse = t_Isuses.Open("ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(IsuseName) + "' and LotteryID in (select id from T_Lotteries where PrintOutType = 104)", ""); if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1)) { continue; } if (Status == "4") { int ReturnValue = 0; string ReturnDescprtion = ""; if (DAL.Procedures.P_ElectronTicketAgentSchemeQuash(Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), 0), ref ReturnValue, ref ReturnDescprtion) < 0) { new Log("ElectronTicket\\HPSH").Write("电子票方案撤单错误_P_ElectronTicketAgentSchemeQuash"); continue; } } bool isHasUpdate = false; if (dtIsuse.Rows[0]["State"].ToString() != Status) { isHasUpdate = true; } if (!String.IsNullOrEmpty(WinNumber) && (dtIsuse.Rows[0]["WinLotteryNumber"].ToString() != WinNumber)) { if (LotteryID == SLS.Lottery.SHSSL.ID) { DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open("", "LotteryID =" + LotteryID.ToString(), ""); double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2]; for (int k = 0; k < dtWinTypes.Rows.Count; k++) { WinMoneyList[k * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoney"].ToString(), 1); WinMoneyList[k * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoneyNoWithTax"].ToString(), 1); } DataTable dtChaseTaskDetails = new DAL.Tables.T_ChaseTaskDetails().Open("", "IsuseID=" + dtIsuse.Rows[0]["ID"].ToString() + " and SchemeID IS NOT NULL", ""); for (int k = 0; k < dtChaseTaskDetails.Rows.Count; k++) { string LotteryNumber = dtChaseTaskDetails.Rows[k]["LotteryNumber"].ToString(); string Description = ""; double WinMoneyNoWithTax = 0; double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtChaseTaskDetails.Rows[k]["PlayTypeID"].ToString()), WinMoneyList); if (WinMoney < 1) { continue; } int ReturnValue = 0; string ReturnDescprtion = ""; if (DAL.Procedures.P_ChaseTaskStopWhenWin(Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SiteID"].ToString(), 1), Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SchemeID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescprtion) < 0) { new Log("ElectronTicket\\HPSH").Write("电子票撤销追号错误_P_ChaseTaskStopWhenWin。"); } } } } if (isHasUpdate) { int ReturnValue = 0; string ReturnDescprtion = ""; if (DAL.Procedures.P_IsuseUpdate(LotteryID, Shove._Web.Utility.FilteSqlInfusion(IsuseName), Shove._Convert.StrToShort(Status, 1), Shove._Convert.StrToDateTime(StartTime, DateTime.Now.ToString()), Shove._Convert.StrToDateTime(EndTime, DateTime.Now.ToString()), DateTime.Now, WinNumber, ref ReturnValue, ref ReturnDescprtion) < 0) { new Log("ElectronTicket\\HPSH").Write("电子票撤销追号错误P_IsuseEdit。"); } if (ReturnValue < 0) { new Log("ElectronTicket\\HPSH").Write(ReturnDescprtion); } } } } string MessageID = nodes[0].Attributes["id"].Value; ReNotice(MessageID, "501"); }
protected void g_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem) { string str = e.Item.Cells[4].Text.Trim(); if (str.Length > 8) { str = str.Substring(0, 7) + ".."; } string type = e.Item.Cells[1].Text; if (type == "我的追号") { e.Item.Cells[3].Text = "<a href='ChaseDetail.aspx?id=" + e.Item.Cells[10].Text + "'><font color=\"#330099\">" + e.Item.Cells[3].Text + "</Font></a>"; e.Item.Cells[4].Text = "<a href='ChaseDetail.aspx?id=" + e.Item.Cells[10].Text + "'><font color=\"#330099\">" + str + "</Font></a>"; } else { e.Item.Cells[3].Text = "<a href='ChaseDetails.aspx?id=" + e.Item.Cells[10].Text + "'><font color=\"#330099\">" + e.Item.Cells[3].Text + "</Font></a>"; e.Item.Cells[4].Text = "<a href='ChaseDetails.aspx?id=" + e.Item.Cells[10].Text + "'><font color=\"#330099\">" + str + "</Font></a>"; } double money = Shove._Convert.StrToDouble(e.Item.Cells[5].Text, 0); e.Item.Cells[5].Text = (money == 0) ? "" : money.ToString("N"); int SumIsuseNum = Shove._Convert.StrToInt(e.Item.Cells[6].Text, 0); int BuyedIsuseNum = Shove._Convert.StrToInt(e.Item.Cells[7].Text, 0); int QuashedIsuseNum = Shove._Convert.StrToInt(e.Item.Cells[13].Text, 0); int QuashStatus = Shove._Convert.StrToInt(e.Item.Cells[11].Text, 0); if (type == "我的追号") { e.Item.Cells[9].Text = (SumIsuseNum > (BuyedIsuseNum + QuashedIsuseNum)) ? "<Font color=\'Red\'>进行中</font>" : "已终止"; } else { e.Item.Cells[9].Text = QuashStatus == 1 ? "已终止" : (SumIsuseNum == BuyedIsuseNum ? "已完成" : "<Font color=\'Red\'>进行中</font>"); } int Type = Shove._Convert.StrToInt(e.Item.Cells[12].Text, 1); double StopMoney = Shove._Convert.StrToDouble(e.Item.Cells[8].Text, 0); if (Type == 1 || StopMoney == 0) { e.Item.Cells[8].Text = "完成方案"; } else { e.Item.Cells[8].Text = "单期中奖金额达到" + StopMoney.ToString("N") + "元"; } if (tdIsuses.Visible && e.Item.Cells[9].Text != "已终止" && e.Item.Cells[9].Text != "已完成") { if (e.Item.Cells[1].Text == "我的追号") { DataTable dt = new DAL.Tables.T_ChaseTaskDetails().Open("Executed", "ChaseTaskID=" + e.Item.Cells[10].Text + " and IsuseID=" + ddlIsuses.SelectedValue + "", ""); if (dt != null && dt.Rows.Count > 0) { if (Shove._Convert.StrToBool(dt.Rows[0]["Executed"].ToString(), false)) { e.Item.Cells[9].Text = "已执行"; } else { e.Item.Cells[9].Text = "未执行"; } } } else { if (new DAL.Tables.T_ExecutedChases().GetCount("ChaseID=" + e.Item.Cells[10].Text + " and SchemeID in (select ID from T_Schemes where IsuseID=" + ddlIsuses.SelectedValue + ")") > 0) { e.Item.Cells[9].Text = "已执行"; } else { e.Item.Cells[9].Text = "未执行"; } } } } }
// 查询奖期状态 private void QueryIsuseState() { // 查询的几组条件说明: // 1 有效期内未开奖、未开启的 // 2 已截止未开奖的 DataTable dt = new DAL.Views.V_Isuses().Open(ConnectionString, "[ID], LotteryID, [Name]", "((isOpened = 0 and (Getdate() between StartTime and EndTime) and State = 0) or (isOpened = 0 and Getdate() > EndTime and State < 5)) and PrintOutType = 102", "EndTime"); if (dt == null) { msg.Send("期号状态查询错误(QueryIsuseState)。"); log.Write("期号状态查询错误(QueryIsuseState)。"); return; } if (dt.Rows.Count < 1) { return; } for (int i = 0; i < dt.Rows.Count; i++) { if (i % 100 == 0) { System.Threading.Thread.Sleep(1000); } #region 查询奖期 string LotteryName = GetLotteryName(Shove._Convert.StrToInt(dt.Rows[i]["LotteryID"].ToString(), 0)); string IsuseName = dt.Rows[i]["Name"].ToString(); DateTime Now = DateTime.Now; string MessageID = ElectronTicket_HPSH_UserName + Now.ToString("yyyyMMdd") + Now.ToString("HHmmss") + (i % 100).ToString().PadLeft(2, '0'); string Body = "<body><issueQuery><issue gameName=\"" + LotteryName + "\" number=\"" + IsuseName + "\"/></issueQuery></body>"; string TimeStamp = Now.ToString("yyyyMMdd") + Now.ToString("HHmmss"); string Message = "<?xml version=\"1.0\" encoding=\"GBK\"?>"; Message += "<message version=\"1.0\" id=\"" + MessageID + "\">"; Message += "<header>"; Message += "<messengerID>" + ElectronTicket_HPSH_UserName + "</messengerID>"; Message += "<timestamp>" + TimeStamp + "</timestamp>"; Message += "<transactionType>102</transactionType>"; Message += "<digest>" + Shove._Security.Encrypt.MD5(MessageID + TimeStamp + ElectronTicket_HPSH_UserPassword + Body, "gb2312") + "</digest>"; Message += "</header>"; Message += Body; Message += "</message>"; WriteElectronTicketLog(true, "102", "transType=102&transMessage=" + Message); string ReceiveString = ""; try { ReceiveString = PublicFunction.Post(ElectronTicket_HPSH_Getway, "transType=102&transMessage=" + Message, TimeoutSeconds); } catch { continue; } if (ReceiveString.Length <= 10) { continue; } string[] t_strs = ReceiveString.Split('&'); if ((t_strs == null) || (t_strs.Length < 2)) { continue; } string TransType = t_strs[0]; string TransMessage = t_strs[1]; TransType = TransType.Substring(10); TransMessage = TransMessage.Substring(13); WriteElectronTicketLog(false, TransType, ReceiveString); #endregion #region 处理结果 System.Xml.XmlDocument XmlDoc = new XmlDocument(); System.Xml.XmlNodeList nodes = null; System.Xml.XmlNodeList nodesIssue = null; try { XmlDoc.Load(new StringReader(TransMessage)); nodes = XmlDoc.GetElementsByTagName("response"); nodesIssue = XmlDoc.GetElementsByTagName("issue"); } catch { continue; } if (nodes == null) { continue; } if (nodes[0].Attributes["code"].Value != "0000") { continue; } if (nodesIssue == null) { continue; } DAL.Tables.T_Isuses t_Isuses = new DAL.Tables.T_Isuses(); for (int j = 0; j < nodesIssue.Count; j++) { LotteryName = nodesIssue[j].Attributes["gameName"].Value; IsuseName = nodesIssue[j].Attributes["number"].Value; string Status = nodesIssue[j].Attributes["status"].Value; int LotteryID = GetLotteryID(LotteryName); string WinNumber = ""; try { WinNumber = GetWinNumber(LotteryID, nodesIssue[j].Attributes["bonusCode"].Value); } catch { } if ((LotteryID < 0) || (String.IsNullOrEmpty(IsuseName))) { continue; } DataTable dtIsuse = t_Isuses.Open(ConnectionString, "ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "'", ""); if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1)) { continue; } bool isHasUpdate = false; if (dtIsuse.Rows[0]["State"].ToString() != Status) { t_Isuses.State.Value = Status; t_Isuses.StateUpdateTime.Value = DateTime.Now; isHasUpdate = true; } if (!String.IsNullOrEmpty(WinNumber) && (dtIsuse.Rows[0]["WinLotteryNumber"].ToString() != WinNumber)) { t_Isuses.WinLotteryNumber.Value = WinNumber; isHasUpdate = true; if (LotteryID == SLS.Lottery.SHSSL.ID) { DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(ConnectionString, "", "LotteryID =" + LotteryID.ToString(), ""); double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2]; for (int k = 0; k < dtWinTypes.Rows.Count; k++) { WinMoneyList[k * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoney"].ToString(), 1); WinMoneyList[k * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[k]["DefaultMoneyNoWithTax"].ToString(), 1); } DataTable dtChaseTaskDetails = new DAL.Tables.T_ChaseTaskDetails().Open(ConnectionString, "", "IsuseID=" + dtIsuse.Rows[0]["ID"].ToString() + " and SchemeID IS NOT NULL", ""); for (int k = 0; k < dtChaseTaskDetails.Rows.Count; k++) { string LotteryNumber = dtChaseTaskDetails.Rows[k]["LotteryNumber"].ToString(); string Description = ""; double WinMoneyNoWithTax = 0; double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtChaseTaskDetails.Rows[k]["PlayTypeID"].ToString()), WinMoneyList); if (WinMoney < 1) { continue; } int ReturnValue = 0; string ReturnDescprtion = ""; if (DAL.Procedures.P_ChaseTaskStopWhenWin(ConnectionString, Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SiteID"].ToString(), 1), Shove._Convert.StrToLong(dtChaseTaskDetails.Rows[k]["SchemeID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescprtion) < 0) { msg.Send("电子票撤销追号错误_P_ChaseTaskStopWhenWin。"); log.Write("电子票撤销追号错误_P_ChaseTaskStopWhenWin。"); } } } } if (isHasUpdate) { t_Isuses.Update(ConnectionString, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "'"); } } #endregion } }