コード例 #1
0
ファイル: ElectronTicket.cs プロジェクト: r0o0o0o0ots/Shove
        //向大赢家出票接口发送票  发送类型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);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: WinNumber.cs プロジェクト: r0o0o0o0ots/Shove
        //向大赢家出票接口发送票  发送类型110(发送开奖号码请求)
        private void Send()
        {
            DataTable          SiteLoID           = new DAL.Tables.T_Lotteries().Open("[ID]", "[ID] in (2,3,5,6,9,13,15,28,29,39,61,63,64,65,70,74,75)", "[Order]");
            ElectronTicket_BLL ElectronTicket_BLL = new ElectronTicket_BLL();

            for (int i = 0; i < SiteLoID.Rows.Count; i++)
            {
                DataTable dt = GetIsusesInfo(SiteLoID.Rows[i]["ID"].ToString());
                if (dt.Rows.Count > 0)
                {
                    //上期期信息(未开奖)
                    string LastIsuseName = null;
                    string LastLotteryID = null;
                    string wMsgID        = null;
                    try
                    {
                        LastIsuseName = dt.Rows[0]["Name"].ToString();
                        LastLotteryID = dt.Rows[0]["LotteryID"].ToString();
                        wMsgID        = dt.Rows[0]["ID"].ToString();;
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    //wAgent=3821&wAction=110&wMsgID=1238494210&wSign=b7c289e65e00f5fb834f338e6b753e44&wParam=LotID=11_LotIssue=2008001
                    //wAgent+wAction+wMsgID+wParam+代理商密钥
                    string wParamStr = "";
                    string wSignStr  = "";

                    try
                    {
                        wParamStr = "LotID=" + ElectronTicket_BLL.GetLotteryID(LastLotteryID) + "_LotIssue=" + ElectronTicket_BLL.GetIsuse(Convert.ToInt32(LastLotteryID), LastIsuseName) + "";
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }
                    try
                    {
                        wSignStr = Shove._Security.Encrypt.MD5(ElectronTicket_Agent_UserNumber + "110" + wMsgID + wParamStr + ElectronTicket_Agent_Key + "", "gb2312");
                    }
                    catch (Exception ex)
                    {
                        msg.Send(ex.Message);
                        log.Write(ex.Message);
                        continue;
                    }

                    string ReceiveString = "";
                    try
                    {
                        //log.Write(ElectronTicket_Getway + "wAgent=" + ElectronTicket_Agent_UserNumber + "&wAction=110&wMsgID=" + wMsgID + "&wSign=" + wSignStr + "&wParam=" + wParamStr);
                        System.Threading.Thread.Sleep(500);
                        ReceiveString = PublicFunction.Post(ElectronTicket_Getway, "wAgent=" + ElectronTicket_Agent_UserNumber + "&wAction=110&wMsgID=" + wMsgID + "&wSign=" + wSignStr + "&wParam=" + wParamStr + "", TimeoutSeconds);
                    }
                    catch
                    {
                        msg.Send("获取开奖号-110 发送失败");
                        log.Write("获取开奖号-110 发送失败");
                        continue;
                    }

                    // log.Write(ReceiveString);
                    System.Threading.Thread.Sleep(500);
                    string code = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xCode");
                    if (code == "0")
                    {
                        string xValue  = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xValue");
                        string IsuseID = ElectronTicket_BLL.GetXMLCode(ReceiveString, "xMsgID");
                        var    arrInfo = xValue.Split('_');
                        DAL.Tables.T_Isuses T_Isuses = new DAL.Tables.T_Isuses();
                        T_Isuses.WinLotteryNumber.Value = arrInfo[1];

                        if (T_Isuses.Update("[ID] = " + IsuseID) < 0)
                        {
                            msg.Send("自动录入开奖号码失败 彩种ID:" + IsuseID);
                            log.Write("自动录入开奖号码失败 彩种ID:" + IsuseID);
                            continue;
                        }
                    }
                }
                continue;
            }
        }