Beispiel #1
0
        //向大赢家出票接口发送票  发送类型101(投注请求)
        private void Send()
        {
            DataTable dt = new DAL.Views.V_SchemesSendToCenter().Open(ConnectionString, "", "Buyed = 0 and PrintOutType = 101 and (GetDate() between StartTime and EndTime) and ((Sends = 0) or (Sends < 3 and HandleResult = 0 and datediff(minute, [Datetime], GetDate()) > 3))", "[ID]");

            if (dt == null)
            {
                log.Write("向大赢家电子票网关发送数据出错:读取方案错误。");
                return;
            }

            DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();
            ElectronTicket_BLL ElectronTicket_BLL = new ElectronTicket_BLL();

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

            int SendCount = 0;

            if ((dt.Rows.Count % 500) != 0)
            {
                SendCount = (dt.Rows.Count - (dt.Rows.Count % 500)) / 500 + 1;
            }
            else
            {
                SendCount = dt.Rows.Count / 500;
            }
            // wAgent=3821&wAction=101&wMsgID=1194065967&wSign=6d8ce6c8cb4c76d60af98a87c8a9d723&wParam=OrderID=2007129298_LotID=10202_LotIssue=2007110818_LotMoney=12_LotMulti=2_OneMoney=2_LotCode=1|68,2,9;6|5,1,8_Attach=投注测试
            //wAgent+wAction+wMsgID+wParam+代理商密钥
            for (int i = 0; i < SendCount; i++)
            {
                DateTime Now = DateTime.Now;
                for (int j = i * 500; j < (i * 500) + 500; j++)
                {
                    if (j >= dt.Rows.Count)
                    {
                        break;
                    }

                    DataRow dr        = dt.Rows[j];
                    string  wParamStr = "";
                    string  wSignStr  = "";
                    try
                    {
                        wParamStr = "OrderID=" + dr["SchemeIdentifiers"].ToString() + "_LotID=" + ElectronTicket_BLL.GetLotteryID(dr["LotteryID"].ToString()) + "_LotIssue=" + ElectronTicket_BLL.GetIsuse(Convert.ToInt32(dr["LotteryID"].ToString()), dr["IsuseName"].ToString()) + "_LotMoney=" + Shove._Convert.StrToFloat(dr["Money"].ToString(), 0) + "_LotMulti=" + dr["Multiple"].ToString() + "_OneMoney=" + ElectronTicket_BLL.getSingleMoney(dr["PlayTypeName"].ToString()) + "_LotCode=" + dr["Ticket"].ToString() + "_Attach=Betting";
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    try
                    {
                        wSignStr = Shove._Security.Encrypt.MD5(ElectronTicket_Agent_UserNumber + "101" + dr["Identifiers"].ToString() + wParamStr + ElectronTicket_Agent_Key + "", "gb2312");
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    string Sends = dr["Sends"].ToString();
                    if (MSSQL.ExecuteNonQuery(ConnectionString, "update T_SchemesSendToCenter set Sends = Sends + 1, [DateTime] = GetDate() where [ID] =" + dr["ID"].ToString()) < 0)
                    {
                        msg.Send("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        log.Write("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        continue;
                    }

                    string ReceiveString = "";

                    try
                    {
                        log.Write(ElectronTicket_Getway + "wAgent=" + ElectronTicket_Agent_UserNumber + "&wAction=101&wMsgID=" + dr["Identifiers"].ToString() + "&wSign=" + wSignStr + "&wParam=" + wParamStr);

                        ReceiveString = PublicFunction.Post(ElectronTicket_Getway, "wAgent=" + ElectronTicket_Agent_UserNumber + "&wAction=101&wMsgID=" + dr["Identifiers"].ToString() + "&wSign=" + wSignStr + "&wParam=" + wParamStr + "", TimeoutSeconds);
                    }
                    catch
                    {
                        msg.Send("电子票-101 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        log.Write("电子票-101 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        continue;
                    }

                    log.Write(ReceiveString);
                    string code              = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xCode");
                    int    ReturnValue       = 0;
                    string ReturnDescription = "";
                    if (code == "0")
                    {
                        int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送的成功的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                            log.Write("对所发送的成功的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                        }

                        continue;
                    }

                    int State  = 0;
                    int SiteID = Shove._Convert.StrToInt(dt.Rows[i]["SiteID"].ToString(), 1);

                    try
                    {
                        State = int.Parse(code);
                    }
                    catch { }

                    if (code == "1007")     // 系统限号,投注失败!
                    {
                        if (Shove._Convert.StrToInt(Sends, 0) < 99)
                        {
                            t_SchemesSendToCenter.Sends.Value = 99;
                            t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());
                        }
                        else
                        {
                            int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                            if ((Result < 0) || (ReturnValue < 0))
                            {
                                msg.Send("对所发送失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                                log.Write("对所发送失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                            }
                        }

                        continue;
                    }

                    t_SchemesSendToCenter.Sends.Value = 100 + State;
                    t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());
                    if ("100 101 102 103 104 198 199 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 2001 2002 2003 2004 2005 2006 2007 8001 8002".IndexOf(code) >= 0)
                    {
                        int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                            log.Write("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        //向中民卓彩票出票接口发送票  发送类型102(投注请求)
        private void Send()
        {
            DataTable dt = new DAL.Views.V_SchemesSendToCenter().Open(ConnectionString, "", "Buyed = 0 and PrintOutType = 104 and (GetDate() between StartTime and EndTime) and ((Sends = 0) or (Sends < 3 and HandleResult = 0 and datediff(minute, [Datetime], GetDate()) > 3))", "[ID]");

            if (dt == null)
            {
                log.Write("向中民卓彩票电子票网关发送数据出错:读取方案错误。");
                return;
            }

            DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();
            if (dt.Rows.Count < 1)
            {
                return;
            }

            int SendCount = 0;

            if ((dt.Rows.Count % 500) != 0)
            {
                SendCount = (dt.Rows.Count - (dt.Rows.Count % 500)) / 500 + 1;
            }
            else
            {
                SendCount = dt.Rows.Count / 500;
            }
            ElectronTicketBase.ElectronTicketTwo ElectronTicket = new ElectronTicketBase.ElectronTicketTwo();
            for (int i = 0; i < SendCount; i++)
            {
                DateTime Now = DateTime.Now;
                for (int j = i * 500; j < (i * 500) + 500; j++)
                {
                    if (j >= dt.Rows.Count)
                    {
                        break;
                    }

                    DataRow dr        = dt.Rows[j];
                    string  wParamStr = "";
                    string  wSignStr  = "";
                    try
                    {
                        var    Ticket    = dr["Ticket"].ToString().Split(',');
                        string transcode = "102";
                        wParamStr  = @"<?xml version='1.0' encoding='utf-8'?>";
                        wParamStr += @"<msg>";
                        wParamStr += @"<head transcode='" + transcode + "' partnerid='" + ElectronTicketbase_FC_Agent_UserNumber + "' version='1.0' time='" + DateTime.Now.ToString("yyyymmddhhmmss") + "'/>";
                        wParamStr += @"<body>";
                        wParamStr += @"<ticketorder lotteryid='" + ElectronTicket.GetLotteryID(dr["LotteryID"].ToString()) + "' issueid='" + ElectronTicket.GetToPalyIsuse(Convert.ToInt32(dr["LotteryID"].ToString()), dr["IsuseName"].ToString()) + "'  ticketnum='" + Convert.ToInt32(Ticket.Length - 1) + "'  totalmoney='" + Convert.ToDecimal(dr["Money"].ToString()).ToString("F2") + "' > ";
                        wParamStr += @"<tickets>";
                        for (int k = 0; k < Ticket.Length - 1; k++)
                        {
                            wParamStr += @"<ticket play='" + Ticket[k].Split('|')[0].ToString() + "' id='" + Guid.NewGuid().ToString() + "'  multiple='" + dr["Multiple"].ToString() + "' money='" + Ticket[k].Split('|')[2].ToString() + "' code='" + Ticket[k].Split('|')[1].ToString() + "'/>";
                        }
                        wParamStr += @"</tickets>";
                        wParamStr += @"</ticketorder>";
                        wParamStr += @"</body>";
                        wParamStr += @"</msg>";
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    try
                    {
                        wSignStr = Shove._Security.Encrypt.MD5(wParamStr + ElectronTicketbase_FC_Agent_Key, "UTF-8");
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    string Sends = dr["Sends"].ToString();
                    if (MSSQL.ExecuteNonQuery(ConnectionString, "update T_SchemesSendToCenter set Sends = Sends + 1, [DateTime] = GetDate() where [ID] =" + dr["ID"].ToString()) < 0)
                    {
                        msg.Send("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        log.Write("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        continue;
                    }

                    string ReceiveString = "";

                    try
                    {
                        log.Write(wParamStr);
                        ReceiveString = PublicFunction.Post(ElectronTicketbase_FC_Getway, wParamStr, wSignStr);
                    }
                    catch
                    {
                        msg.Send("电子票-102 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        log.Write("电子票-102 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                        continue;
                    }

                    log.Write(ReceiveString);

                    string code              = ElectronTicket.GetXMLValue(ReceiveString, "head", "transcode");
                    int    ReturnValue       = 0;
                    string ReturnDescription = "";
                    if (code == "702")
                    {
                        int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送的成功的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                            log.Write("对所发送的成功的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                        }

                        continue;
                    }

                    int State  = 0;
                    int SiteID = Shove._Convert.StrToInt(dt.Rows[i]["SiteID"].ToString(), 1);
                    t_SchemesSendToCenter.Sends.Value = 100 + State;
                    t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());
                    if ("9999 9001 9005 9002 9003 9004".IndexOf(code) >= 0)
                    {
                        int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                            log.Write("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        // 发送代购电子票
        private void SendTickets()
        {
            DAL.Views.V_SchemesSendToCenter v_SchemesSendToCenter = new DAL.Views.V_SchemesSendToCenter();

            DataTable dt = v_SchemesSendToCenter.Open(ConnectionString, "distinct SchemeID, SiteID, UserType", "Buyed = 0 and (GetDate() between StartTime and EndTime) and Sends < 99 and HandleResult = 0 and State = 1 and LotteryID = 29", " UserType desc");

            if (dt == null)
            {
                msg.Send("发送代购票出错(SendTickets):读取方案错误。");
                log.Write("发送代购票出错(SendTickets):读取方案错误。");

                return;
            }

            DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();

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

                DataTable dtSchemesSend = v_SchemesSendToCenter.Open(ConnectionString, "", "SchemeID=" + dt.Rows[i]["SchemeID"].ToString() + " and Buyed = 0 and (GetDate() between StartTime and EndTime) and Sends < 99 and HandleResult = 0 and State = 1", "");

                if (dtSchemesSend == null)
                {
                    msg.Send("发送代购票出错(SendTickets):读取方案错误。方案号:" + dt.Rows[i]["SchemeID"].ToString());
                    log.Write("发送代购票出错(SendTickets):读取方案错误。方案号:" + dt.Rows[i]["SchemeID"].ToString());

                    continue;
                }

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

                string Sends = dtSchemesSend.Rows[0]["Sends"].ToString();

                if (MSSQL.ExecuteNonQuery(ConnectionString, "update T_SchemesSendToCenter set Sends = Sends + 1 where SchemeID = " + dt.Rows[i]["SchemeID"].ToString()) < 0)
                {
                    msg.Send("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                    log.Write("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());

                    continue;
                }

                string ticketid = "";
                string LotteryNumber = "";
                DateTime Now = DateTime.Now;

                string Body = "<body><lotteryRequest>";

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

                    ticketid = dr["Identifiers"].ToString();

                    Body += "<ticket id=\"" + ticketid + "\"";
                    Body += " playType=\"" + dr["PlayTypeID"].ToString() + "\" money=\"" + double.Parse(dr["Money"].ToString()).ToString("N").Replace(",", "") + "\" amount=\"" + dr["Multiple"].ToString() + "\">";
                    Body += "<issue number=\"" + dr["IsuseName"].ToString() + "\" gameName=\"" + GetLotteryName(int.Parse(dr["LotteryID"].ToString())) + "\"/>";
                    Body += "<userProfile userName=\"" + ElectronTicket_PrintOut_AlipayName + "\" cardType=\"1\" mail=\"" + ElectronTicket_PrintOut_Email + "\" cardNumber=\"" + ElectronTicket_PrintOut_IDCardNumber + "\" mobile=\"" + ElectronTicket_PrintOut_Mobile + "\" realName=\"" + ElectronTicket_PrintOut_RealityName + "\" bonusPhone=\"" + ElectronTicket_PrintOut_Mobile + "\"/>";

                    try
                    {
                        LotteryNumber = dr["Ticket"].ToString();
                    }
                    catch
                    {
                        continue;
                    }

                    string[] strs = LotteryNumber.Split('\n');

                    foreach (string str in strs)
                    {
                        if (str.Trim() == "")
                        {
                            continue;
                        }

                        Body += "<anteCode>" + str + "</anteCode>";
                    }

                    Body += "</ticket>";
                }

                Body += "</lotteryRequest></body>";

                string MessageID = ElectronTicket_HPSH_UserName + Now.ToString("yyyyMMdd") + Now.ToString("HHmmss") + "1" + (i % 10).ToString();
                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>103</transactionType>";
                Message += "<digest>" + Shove._Security.Encrypt.MD5(MessageID + TimeStamp + ElectronTicket_HPSH_UserPassword + Body, "gb2312") + "</digest>";
                Message += "</header>";
                Message += Body;
                Message += "</message>";

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

                string ReceiveString = "";

                try
                {
                    ReceiveString = PublicFunction.Post(ElectronTicket_HPSH_Getway, "transType=103&transMessage=" + Message, TimeoutSeconds);
                }
                catch
                {
                    msg.Send("电子票-103 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                    log.Write("电子票-103 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());

                    continue;
                }

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

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

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

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

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

                WriteElectronTicketLog(false, TransType, ReceiveString);

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

                try
                {
                    XmlDoc.Load(new StringReader(TransMessage));
                    nodes = XmlDoc.GetElementsByTagName("*");
                }
                catch
                {
                    continue;
                }

                string code = "";

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

                int ReturnValue = 0;
                string ReturnDescription = "";

                if (code == "0000")
                {
                    int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                    if ((Result < 0) || (ReturnValue < 0))
                    {
                        msg.Send("对所发送的成功落地的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                        log.Write("对所发送的成功落地的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);

                        System.Threading.Thread.Sleep(1000);

                        ReturnValue = 0;
                        ReturnDescription = "";

                        Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送的成功落地的代购票第二次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                            log.Write("对所发送的成功落地的代购票第二次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                        }
                    }

                    continue;
                }

                int State = 0;
                int SiteID = Shove._Convert.StrToInt(dt.Rows[i]["SiteID"].ToString(), 1);

                try
                {
                    State = int.Parse(code);
                }
                catch { }

                if (code == "2032")     // 限号
                {
                    if (Shove._Convert.StrToInt(Sends, 0) < 99)
                    {
                        t_SchemesSendToCenter.Sends.Value = 99;
                        t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());
                    }
                    else
                    {
                        int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                            log.Write("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                        }
                    }

                    continue;
                }

                if ("2048 3003 9999 1011".IndexOf(code) >= 0)     // 重复发送的投注票
                {
                    continue;
                }

                t_SchemesSendToCenter.Sends.Value = 100 + State;
                t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());

                if ("2010 2011 2012 2013 2014 2015 2016 2017 2018 2030 2031".IndexOf(code) >= 0)
                {
                    int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                    if ((Result < 0) || (ReturnValue < 0))
                    {
                        msg.Send("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                        log.Write("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                    }
                }
            }
        }
Beispiel #4
0
        // 代购票查询
        private void QueryTickets()
        {
            DataTable dt = new DAL.Views.V_SchemesSendToCenter().Open(ConnectionString, "distinct SchemeID", "(((Sends > 0) AND (Sends < 100)) or (sends = 3301) or (sends = 2148)) AND (HandleResult = 0) AND (IsOpened = 0) and LotteryID = 29 and buyed = 0", "");

            if (dt == null)
            {
                msg.Send("查询代购票出错(QueryTickets):读取未成功票错误。");
                log.Write("查询代购票出错(QueryTickets):读取未成功票错误。");

                return;
            }

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

            DataTable dtSchemesSendToCenter = null;

            DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dtSchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter().Open(ConnectionString, "top 1 *", "schemeid=" + dt.Rows[i]["SchemeID"].ToString() + " and (Sends > 0) AND (Sends < 100)", "");

                if (dtSchemesSendToCenter == null)
                {
                    continue;
                }

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

                System.Threading.Thread.Sleep(1000);

                string ticketid = dtSchemesSendToCenter.Rows[0]["Identifiers"].ToString();
                string Body = "<body><ticketQuery>" + "<ticket id=\"" + ticketid + "\"/>" + "</ticketQuery></body>";

                string MessageID = ElectronTicket_HPSH_UserName + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + "1" + (i % 10).ToString();
                string TimeStamp = DateTime.Now.ToString("yyyyMMdd") + DateTime.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>105</transactionType>";
                Message += "<digest>" + Shove._Security.Encrypt.MD5(MessageID + TimeStamp + ElectronTicket_HPSH_UserPassword + Body, "gb2312") + "</digest>";
                Message += "</header>";
                Message += Body;
                Message += "</message>";

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

                string ReceiveString = "";

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

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

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

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

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

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

                WriteElectronTicketLog(false, TransType, ReceiveString);

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

                try
                {
                    XmlDoc.Load(new StringReader(TransMessage));
                    nodes = XmlDoc.GetElementsByTagName("ticket");
                }
                catch { }

                if (nodes == null)
                {
                    continue;
                }

                for (int k = 0; k < nodes.Count; k++)
                {
                    string Identifiers = nodes[k].Attributes["id"].Value;
                    string Status = nodes[k].Attributes["status"].Value;
                    string _Message = nodes[k].Attributes["message"].Value;

                    if (Status == "0000")
                    {
                        string DealTime = nodes[k].Attributes["dealTime"].Value;

                        int ReturnValue = 0;
                        string ReturnDescription = "";

                        int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now,true, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所查询到的电子票数据第一次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                            log.Write("对所查询到的电子票数据第一次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);

                            System.Threading.Thread.Sleep(1000);

                            ReturnValue = 0;
                            ReturnDescription = "";

                            Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), Shove._Convert.StrToDateTime(DealTime, DateTime.Now.ToString()), true, ref ReturnValue, ref ReturnDescription);

                            if ((Result < 0) || (ReturnValue < 0))
                            {
                                msg.Send("对所查询到的电子票数据第二次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                                log.Write("对所查询到的电子票数据第二次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                            }
                        }

                        continue;
                    }

                    if ("0010 0011 0014 0015 0016 0098 0097 1008 1009 1010 1012 1016 1017 2001 2002 2003 2004 2010 2011 2012 2013 2014 2015 2016 2017 2018 2030 2031 2040 2041 2042 -1 2043 2044 2046 3000 3002 3004 3005 3011 3012 3013 3014 3015 3016 3017 3018 3100 3101 3202 3203 3204 3205".IndexOf(Status) >= 0)
                    {
                        t_SchemesSendToCenter.Sends.Value = Status + 100;
                        t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());

                        continue;
                    }

                    if (Status == "2052")
                    {
                        System.Threading.Thread.Sleep(1000);

                        continue;
                    }

                    if (Status == "2032")
                    {
                        t_SchemesSendToCenter.Sends.Value = "99";
                        t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());

                        continue;
                    }
                }
            }
        }
Beispiel #5
0
        // 发送代购电子票
        private void SendTickets()
        {
            DAL.Views.V_SchemesSendToCenter v_SchemesSendToCenter = new DAL.Views.V_SchemesSendToCenter();

            DataTable dt = v_SchemesSendToCenter.Open(ConnectionString, "distinct SchemeID, SiteID, UserType", "Buyed = 0 and (GetDate() between StartTime and EndTime) and Sends < 99 and HandleResult = 0 and State = 1 and LotteryID = 29", " UserType desc");

            if (dt == null)
            {
                msg.Send("发送代购票出错(SendTickets):读取方案错误。");
                log.Write("发送代购票出错(SendTickets):读取方案错误。");

                return;
            }

            DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();

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

                DataTable dtSchemesSend = v_SchemesSendToCenter.Open(ConnectionString, "", "SchemeID=" + dt.Rows[i]["SchemeID"].ToString() + " and Buyed = 0 and (GetDate() between StartTime and EndTime) and Sends < 99 and HandleResult = 0 and State = 1", "");

                if (dtSchemesSend == null)
                {
                    msg.Send("发送代购票出错(SendTickets):读取方案错误。方案号:" + dt.Rows[i]["SchemeID"].ToString());
                    log.Write("发送代购票出错(SendTickets):读取方案错误。方案号:" + dt.Rows[i]["SchemeID"].ToString());

                    continue;
                }

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

                string Sends = dtSchemesSend.Rows[0]["Sends"].ToString();

                if (MSSQL.ExecuteNonQuery(ConnectionString, "update T_SchemesSendToCenter set Sends = Sends + 1 where SchemeID = " + dt.Rows[i]["SchemeID"].ToString()) < 0)
                {
                    msg.Send("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                    log.Write("更新票发送状态时出错(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());

                    continue;
                }

                string   ticketid      = "";
                string   LotteryNumber = "";
                DateTime Now           = DateTime.Now;

                string Body = "<body><lotteryRequest>";

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

                    ticketid = dr["Identifiers"].ToString();

                    Body += "<ticket id=\"" + ticketid + "\"";
                    Body += " playType=\"" + dr["PlayTypeID"].ToString() + "\" money=\"" + double.Parse(dr["Money"].ToString()).ToString("N").Replace(",", "") + "\" amount=\"" + dr["Multiple"].ToString() + "\">";
                    Body += "<issue number=\"" + dr["IsuseName"].ToString() + "\" gameName=\"" + GetLotteryName(int.Parse(dr["LotteryID"].ToString())) + "\"/>";
                    Body += "<userProfile userName=\"" + ElectronTicket_PrintOut_AlipayName + "\" cardType=\"1\" mail=\"" + ElectronTicket_PrintOut_Email + "\" cardNumber=\"" + ElectronTicket_PrintOut_IDCardNumber + "\" mobile=\"" + ElectronTicket_PrintOut_Mobile + "\" realName=\"" + ElectronTicket_PrintOut_RealityName + "\" bonusPhone=\"" + ElectronTicket_PrintOut_Mobile + "\"/>";

                    try
                    {
                        LotteryNumber = dr["Ticket"].ToString();
                    }
                    catch
                    {
                        continue;
                    }

                    string[] strs = LotteryNumber.Split('\n');

                    foreach (string str in strs)
                    {
                        if (str.Trim() == "")
                        {
                            continue;
                        }

                        Body += "<anteCode>" + str + "</anteCode>";
                    }

                    Body += "</ticket>";
                }

                Body += "</lotteryRequest></body>";

                string MessageID = ElectronTicket_HPSH_UserName + Now.ToString("yyyyMMdd") + Now.ToString("HHmmss") + "1" + (i % 10).ToString();
                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>103</transactionType>";
                Message += "<digest>" + Shove._Security.Encrypt.MD5(MessageID + TimeStamp + ElectronTicket_HPSH_UserPassword + Body, "gb2312") + "</digest>";
                Message += "</header>";
                Message += Body;
                Message += "</message>";

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

                string ReceiveString = "";

                try
                {
                    ReceiveString = PublicFunction.Post(ElectronTicket_HPSH_Getway, "transType=103&transMessage=" + Message, TimeoutSeconds);
                }
                catch
                {
                    msg.Send("电子票-103 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());
                    log.Write("电子票-103 发送失败(SendTickets)。方案ID:" + dt.Rows[i]["SchemeID"].ToString());

                    continue;
                }

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

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

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

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

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

                WriteElectronTicketLog(false, TransType, ReceiveString);

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

                try
                {
                    XmlDoc.Load(new StringReader(TransMessage));
                    nodes = XmlDoc.GetElementsByTagName("*");
                }
                catch
                {
                    continue;
                }

                string code = "";

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

                int    ReturnValue       = 0;
                string ReturnDescription = "";

                if (code == "0000")
                {
                    int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                    if ((Result < 0) || (ReturnValue < 0))
                    {
                        msg.Send("对所发送的成功落地的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                        log.Write("对所发送的成功落地的代购票第一次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);

                        System.Threading.Thread.Sleep(1000);

                        ReturnValue       = 0;
                        ReturnDescription = "";

                        Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送的成功落地的代购票第二次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                            log.Write("对所发送的成功落地的代购票第二次处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + ReturnDescription);
                        }
                    }

                    continue;
                }

                int State  = 0;
                int SiteID = Shove._Convert.StrToInt(dt.Rows[i]["SiteID"].ToString(), 1);

                try
                {
                    State = int.Parse(code);
                }
                catch { }

                if (code == "2032")     // 限号
                {
                    if (Shove._Convert.StrToInt(Sends, 0) < 99)
                    {
                        t_SchemesSendToCenter.Sends.Value = 99;
                        t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());
                    }
                    else
                    {
                        int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                            log.Write("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                        }
                    }

                    continue;
                }

                if ("2048 3003 9999 1011".IndexOf(code) >= 0)     // 重复发送的投注票
                {
                    continue;
                }

                t_SchemesSendToCenter.Sends.Value = 100 + State;
                t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());

                if ("2010 2011 2012 2013 2014 2015 2016 2017 2018 2030 2031".IndexOf(code) >= 0)
                {
                    int Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), 0), true, false, ref ReturnValue, ref ReturnDescription);

                    if ((Result < 0) || (ReturnValue < 0))
                    {
                        msg.Send("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                        log.Write("对所发送落地失败的代购票【作撤单】处理出错(SendTickets):数据读写错误。票号:" + dt.Rows[i]["SchemeID"].ToString() + "," + code + "," + ReturnDescription);
                    }
                }
            }
        }
Beispiel #6
0
        // 代购票查询
        private void QueryTickets()
        {
            DataTable dt = new DAL.Views.V_SchemesSendToCenter().Open(ConnectionString, "distinct SchemeID", "(((Sends > 0) AND (Sends < 100)) or (sends = 3301) or (sends = 2148)) AND (HandleResult = 0) AND (IsOpened = 0) and LotteryID = 29 and buyed = 0", "");

            if (dt == null)
            {
                msg.Send("查询代购票出错(QueryTickets):读取未成功票错误。");
                log.Write("查询代购票出错(QueryTickets):读取未成功票错误。");

                return;
            }

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

            DataTable dtSchemesSendToCenter = null;

            DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dtSchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter().Open(ConnectionString, "top 1 *", "schemeid=" + dt.Rows[i]["SchemeID"].ToString() + " and (Sends > 0) AND (Sends < 100)", "");

                if (dtSchemesSendToCenter == null)
                {
                    continue;
                }

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

                System.Threading.Thread.Sleep(1000);

                string ticketid = dtSchemesSendToCenter.Rows[0]["Identifiers"].ToString();
                string Body     = "<body><ticketQuery>" + "<ticket id=\"" + ticketid + "\"/>" + "</ticketQuery></body>";

                string MessageID = ElectronTicket_HPSH_UserName + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + "1" + (i % 10).ToString();
                string TimeStamp = DateTime.Now.ToString("yyyyMMdd") + DateTime.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>105</transactionType>";
                Message += "<digest>" + Shove._Security.Encrypt.MD5(MessageID + TimeStamp + ElectronTicket_HPSH_UserPassword + Body, "gb2312") + "</digest>";
                Message += "</header>";
                Message += Body;
                Message += "</message>";

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

                string ReceiveString = "";

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

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

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

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

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

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

                WriteElectronTicketLog(false, TransType, ReceiveString);

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

                try
                {
                    XmlDoc.Load(new StringReader(TransMessage));
                    nodes = XmlDoc.GetElementsByTagName("ticket");
                }
                catch { }

                if (nodes == null)
                {
                    continue;
                }

                for (int k = 0; k < nodes.Count; k++)
                {
                    string Identifiers = nodes[k].Attributes["id"].Value;
                    string Status      = nodes[k].Attributes["status"].Value;
                    string _Message    = nodes[k].Attributes["message"].Value;

                    if (Status == "0000")
                    {
                        string DealTime = nodes[k].Attributes["dealTime"].Value;

                        int    ReturnValue       = 0;
                        string ReturnDescription = "";

                        int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), DateTime.Now, true, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            msg.Send("对所查询到的电子票数据第一次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                            log.Write("对所查询到的电子票数据第一次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);

                            System.Threading.Thread.Sleep(1000);

                            ReturnValue       = 0;
                            ReturnDescription = "";

                            Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(ConnectionString, Shove._Convert.StrToLong(dt.Rows[i]["SchemeID"].ToString(), -1), Shove._Convert.StrToDateTime(DealTime, DateTime.Now.ToString()), true, ref ReturnValue, ref ReturnDescription);

                            if ((Result < 0) || (ReturnValue < 0))
                            {
                                msg.Send("对所查询到的电子票数据第二次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                                log.Write("对所查询到的电子票数据第二次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                            }
                        }

                        continue;
                    }

                    if ("0010 0011 0014 0015 0016 0098 0097 1008 1009 1010 1012 1016 1017 2001 2002 2003 2004 2010 2011 2012 2013 2014 2015 2016 2017 2018 2030 2031 2040 2041 2042 -1 2043 2044 2046 3000 3002 3004 3005 3011 3012 3013 3014 3015 3016 3017 3018 3100 3101 3202 3203 3204 3205".IndexOf(Status) >= 0)
                    {
                        t_SchemesSendToCenter.Sends.Value = Status + 100;
                        t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());

                        continue;
                    }

                    if (Status == "2052")
                    {
                        System.Threading.Thread.Sleep(1000);

                        continue;
                    }

                    if (Status == "2032")
                    {
                        t_SchemesSendToCenter.Sends.Value = "99";
                        t_SchemesSendToCenter.Update(ConnectionString, "SchemeID = " + dt.Rows[i]["SchemeID"].ToString());

                        continue;
                    }
                }
            }
        }
Beispiel #7
0
    protected void g_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
    {
        if (e.CommandName == "btnBuy")
        {
            string LotteryCode = ((TextBox)e.Item.FindControl("tbLotteryCode")).Text.Trim();

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

            int Results = -1;
            Results = DAL.Procedures.P_SchemePrintOut(
                Shove._Convert.StrToLong(((HtmlInputHidden)e.Item.FindControl("tbSiteID")).Value, -1),
                Shove._Convert.StrToLong(((HtmlInputHidden)e.Item.FindControl("tbID")).Value, -1),
                _User.ID, PrintOutTypes.Local, LotteryCode, true, ref ReturnValue, ref ReturnDescription);

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

                return;
            }

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

                return;
            }

            BindData();

            return;
        }
        else if (e.CommandName == "btnSerach")
        {
            long SchemeID = Shove._Convert.StrToLong(((HtmlInputHidden)e.Item.FindControl("tbID")).Value, -1);

            DataTable dt_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter().Open("top 1 *", "schemeid=" + SchemeID.ToString() + " and (Sends > 0) AND (Sends < 100)", "ID");

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

                return;
            }

            if (dt_SchemesSendToCenter.Rows.Count < 1)
            {
                Shove._Web.JavaScript.Alert(this.Page, "此方案暂未拆票.");

                return;
            }

            SystemOptions so = new SystemOptions();

            string ElectronTicket_HPSD_Getway       = so["ElectronTicket_HPSD_Getway"].Value.ToString();
            string ElectronTicket_HPSD_UserName     = so["ElectronTicket_HPSD_UserName"].Value.ToString();
            string ElectronTicket_HPSD_UserPassword = so["ElectronTicket_HPSD_UserPassword"].Value.ToString();
            int    TimeoutSeconds = 120;

            string ticketid = dt_SchemesSendToCenter.Rows[0]["Identifiers"].ToString();
            string Body     = "<body><ticketQuery>" + "<ticket id=\"" + ticketid + "\"/>" + "</ticketQuery></body>";

            string MessageID = ElectronTicket_HPSD_UserName + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + "99";
            string TimeStamp = DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss");

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

            new Log("System").Write("105|transType=105&transMessage=" + Message);

            string ReceiveString = "";

            try
            {
                ReceiveString = Post(ElectronTicket_HPSD_Getway, "transType=105&transMessage=" + Message, TimeoutSeconds);
            }
            catch
            {
                return;
            }

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

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

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

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

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

            new Log("System").Write(TransType + "|" + ReceiveString);

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

            try
            {
                XmlDoc.Load(new StringReader(TransMessage));
                nodes = XmlDoc.GetElementsByTagName("ticket");
            }
            catch { }

            if (nodes == null)
            {
                return;
            }

            for (int k = 0; k < nodes.Count; k++)
            {
                string Identifiers = nodes[k].Attributes["id"].Value;
                string Status      = nodes[k].Attributes["status"].Value;
                string _Message    = nodes[k].Attributes["message"].Value;

                if (Status == "0000")
                {
                    string DealTime = nodes[k].Attributes["dealTime"].Value;

                    int    ReturnValue       = 0;
                    string ReturnDescription = "";

                    int Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(SchemeID, DateTime.Now, false, ref ReturnValue, ref ReturnDescription);

                    if ((Result < 0) || (ReturnValue < 0))
                    {
                        Shove._Web.JavaScript.Alert(this.Page, "对所查询到的电子票数据第一次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);

                        new Log("System").Write("对所查询到的电子票数据第一次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);

                        System.Threading.Thread.Sleep(1000);

                        ReturnValue       = 0;
                        ReturnDescription = "";

                        Result = DAL.Procedures.P_SchemesSendToCenterHandleUniteAnte(SchemeID, Shove._Convert.StrToDateTime(DealTime, DateTime.Now.ToString()), false, ref ReturnValue, ref ReturnDescription);

                        if ((Result < 0) || (ReturnValue < 0))
                        {
                            Shove._Web.JavaScript.Alert(this.Page, "对所查询到的电子票数据第二次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);

                            new Log("System").Write("对所查询到的电子票数据第二次处理出错(QueryTickets):数据读写错误。票号:" + Identifiers + "," + ReturnDescription);
                        }
                    }

                    continue;
                }

                Shove._Web.JavaScript.Alert(this.Page, _Message);

                DAL.Tables.T_SchemesSendToCenter t_SchemesSendToCenter = new DAL.Tables.T_SchemesSendToCenter();

                if ("0010 0011 0012 0014 0015 0016 0098 0097 1008 1009 1010 1012 1013 1016 1017 2001 2002 2003 2004 2010 2011 2012 2013 2014 2015 2016 2017 2018 2030 2031 2040 2041 2042 -1 2043 2044 2046 3000 3002 3003 3004 3005 3010 3011 3012 3013 3014 3015 3220 3221 3222 3223 3224 3225 9001 9002 9003 9004 9005 9006 9007 4001 4002 4003 4004 4005 4006 4007".IndexOf(Status) >= 0)
                {
                    t_SchemesSendToCenter.Sends.Value = Status + 100;
                    t_SchemesSendToCenter.Update("SchemeID = " + SchemeID.ToString());

                    BindData();

                    return;
                }

                if (Status == "2052")
                {
                    System.Threading.Thread.Sleep(1000);

                    BindData();

                    return;
                }

                if (Status == "2032")
                {
                    t_SchemesSendToCenter.Sends.Value = "99";
                    t_SchemesSendToCenter.Update("SchemeID = " + SchemeID.ToString());

                    BindData();

                    return;
                }
            }

            BindData();

            return;
        }
    }