Exemplo n.º 1
0
        // 查询奖期状态
        private void QueryIsuseState()
        {
            // 查询的几组条件说明:
            //  1 有效期内未开奖、未开启的
            //  2 已截止未开奖的 (2 days ago = 2280 minutes)
            DataTable dt = new SLS.Dal.Views.V_Isuses().Open(ConnectionString, "[ID], LotteryID, [Name], [EndTime]", "((isOpened = 0 and (Getdate() between StartTime and EndTime) and State = 0) or (isOpened = 0 and DATEDIFF(MINUTE, Getdate(), EndTime) > -2280 AND GETDATE() > EndTime and State < 6)) and PrintOutType = 301", "EndTime");
           
            if (dt == null)
            {
                //msg.Send("期号状态查询错误(QueryIsuseState)。");
                issLog.Write("期号状态查询错误(QueryIsuseState)。");
                return;
            }

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

                #region 查询奖期 一次1期
                // inquery xml here
                int lottoID = 0;
                if (!int.TryParse(dt.Rows[i]["LotteryID"].ToString(), out lottoID))
                    continue;
                string ReceiveString = null;
                string ErrorCode = null;
                try
                {   // post to provider and wait for response
                    ErrorCode = eTicketProvider.GetLotteryInfo(lottoID, dt.Rows[i]["Name"].ToString(), out ReceiveString);
                }
                catch{
                    continue;
                }
                string logString = string.Empty;
                if(string.IsNullOrEmpty(ConfigurationManager.AppSettings["LogAll"]) || ConfigurationManager.AppSettings["LogAll"].Equals("true"))
                {
                    XmlDocument xdLog = new XmlDocument();
                    xdLog.LoadXml(ReceiveString);
                    XmlNodeList xNode = xdLog.GetElementsByTagName("body");
                    if (xNode != null && xNode.Count > 0)
                        logString = xNode[0].OuterXml;
                    else
                        logString = ReceiveString;
                }
                issLog.Write("期号: (" + lottoID.ToString() + ") " + dt.Rows[i]["Name"].ToString() + " | " + logString);
                #endregion
                if (ErrorCode == null || ReceiveString == null)
                    continue;
                if (ErrorCode != "0")
                    continue;

                #region 处理结果

                XmlDocument XmlDoc = new XmlDocument();
                XmlNodeList nodesIssue = null;

                try
                {
                    XmlDoc.Load(new StringReader(ReceiveString));
                    nodesIssue = XmlDoc.GetElementsByTagName("issue");
                }
                catch{
                    continue;
                }

                if (nodesIssue == null || nodesIssue.Count < 1)
                    continue;

                SLS.Dal.Tables.T_Isuses t_Isuses = new SLS.Dal.Tables.T_Isuses();
                string lotoid = null;
                string issue = null;
                string Status = null;
                string lottoNum = null;
                int LotteryID = 0;
                string IssueName = null;

                if (nodesIssue[0].Attributes.Count < 1){
                    continue;
                }
                try
                {
                    lotoid = nodesIssue[0].Attributes["lotoid"].Value;
                    issue = nodesIssue[0].Attributes["issue"].Value;
                    Status = nodesIssue[0].Attributes["status"].Value;
                    if (nodesIssue[0].Attributes["bonuscode"] != null)
                        lottoNum = nodesIssue[0].Attributes["bonuscode"].Value;
                    LotteryID = eTicketProvider.GetSystemLotteryID(lotoid);
                    IssueName = eTicketProvider.ConvertIntoSystemIssue(lotoid, issue);
                }
                catch { continue; }
                if ((LotteryID == 0)) { continue; }
                
                DataTable dtIsuse = t_Isuses.Open(ConnectionString, "ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "'", "");
                if ((dtIsuse == null) || (dtIsuse.Rows.Count != 1)){ continue; }

                bool isHasUpdate = false;
                // 奖期状态:0 未开启 1 开始 2 暂停 3 截止 4 期结 5 返奖 6 返奖结束
                // Sun : 0 未开启 1 已开新期 2 暂停 3 截止投注 4 摇出奖号 5 兑奖中 6 结期兑奖
                if (dtIsuse.Rows[0]["State"].ToString() != Status)
                {
                    t_Isuses.State.Value = Status;
                    t_Isuses.StateUpdateTime.Value = DateTime.Now;
                    isHasUpdate = true;
                }
                string WinNumber = null;
                if (lottoNum != null)
                    WinNumber = eTicketProvider.ConverToSystemLottoNum(lotoid, lottoNum);

                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 SLS.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 SLS.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 (SLS.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)
                            {
                                log.Write("(QueryIsuseState)电子票撤销追号错误 P_ChaseTaskStopWhenWin。");
                            }
                        }
                    }
                }
                
                if (isHasUpdate){
                    t_Isuses.Update(ConnectionString, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "'");
                }
                #endregion
            }
        }
Exemplo n.º 2
0
        // 查询奖期状态
        private void QueryIsuseState()
        {
            // 查询的几组条件说明:
            //  1 有效期内未开奖、未开启的
            //  2 已截止未开奖的 (2 days ago = 2280 minutes)
            DataTable dt = new SLS.Dal.Views.V_Isuses().Open(ConnectionString, "[ID], LotteryID, [Name], [EndTime]", "((isOpened = 0 and (Getdate() between StartTime and EndTime) and State = 0) or (isOpened = 0 and DATEDIFF(MINUTE, Getdate(), EndTime) > -2280 AND GETDATE() > EndTime and State < 6)) and PrintOutType = 301", "EndTime");

            if (dt == null)
            {
                //msg.Send("期号状态查询错误(QueryIsuseState)。");
                issLog.Write("期号状态查询错误(QueryIsuseState)。");
                return;
            }

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

                #region 查询奖期 一次1期
                // inquery xml here
                int lottoID = 0;
                if (!int.TryParse(dt.Rows[i]["LotteryID"].ToString(), out lottoID))
                {
                    continue;
                }
                string ReceiveString = null;
                string ErrorCode     = null;
                try
                {   // post to provider and wait for response
                    ErrorCode = eTicketProvider.GetLotteryInfo(lottoID, dt.Rows[i]["Name"].ToString(), out ReceiveString);
                }
                catch {
                    continue;
                }
                string logString = string.Empty;
                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["LogAll"]) || ConfigurationManager.AppSettings["LogAll"].Equals("true"))
                {
                    XmlDocument xdLog = new XmlDocument();
                    xdLog.LoadXml(ReceiveString);
                    XmlNodeList xNode = xdLog.GetElementsByTagName("body");
                    if (xNode != null && xNode.Count > 0)
                    {
                        logString = xNode[0].OuterXml;
                    }
                    else
                    {
                        logString = ReceiveString;
                    }
                }
                issLog.Write("期号: (" + lottoID.ToString() + ") " + dt.Rows[i]["Name"].ToString() + " | " + logString);
                #endregion
                if (ErrorCode == null || ReceiveString == null)
                {
                    continue;
                }
                if (ErrorCode != "0")
                {
                    continue;
                }

                #region 处理结果

                XmlDocument XmlDoc     = new XmlDocument();
                XmlNodeList nodesIssue = null;

                try
                {
                    XmlDoc.Load(new StringReader(ReceiveString));
                    nodesIssue = XmlDoc.GetElementsByTagName("issue");
                }
                catch {
                    continue;
                }

                if (nodesIssue == null || nodesIssue.Count < 1)
                {
                    continue;
                }

                SLS.Dal.Tables.T_Isuses t_Isuses = new SLS.Dal.Tables.T_Isuses();
                string lotoid    = null;
                string issue     = null;
                string Status    = null;
                string lottoNum  = null;
                int    LotteryID = 0;
                string IssueName = null;

                if (nodesIssue[0].Attributes.Count < 1)
                {
                    continue;
                }
                try
                {
                    lotoid = nodesIssue[0].Attributes["lotoid"].Value;
                    issue  = nodesIssue[0].Attributes["issue"].Value;
                    Status = nodesIssue[0].Attributes["status"].Value;
                    if (nodesIssue[0].Attributes["bonuscode"] != null)
                    {
                        lottoNum = nodesIssue[0].Attributes["bonuscode"].Value;
                    }
                    LotteryID = eTicketProvider.GetSystemLotteryID(lotoid);
                    IssueName = eTicketProvider.ConvertIntoSystemIssue(lotoid, issue);
                }
                catch { continue; }
                if ((LotteryID == 0))
                {
                    continue;
                }

                DataTable dtIsuse = t_Isuses.Open(ConnectionString, "ID, State, WinLotteryNumber", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "'", "");
                if ((dtIsuse == null) || (dtIsuse.Rows.Count != 1))
                {
                    continue;
                }

                bool isHasUpdate = false;
                // 奖期状态:0 未开启 1 开始 2 暂停 3 截止 4 期结 5 返奖 6 返奖结束
                // Sun : 0 未开启 1 已开新期 2 暂停 3 截止投注 4 摇出奖号 5 兑奖中 6 结期兑奖
                if (dtIsuse.Rows[0]["State"].ToString() != Status)
                {
                    t_Isuses.State.Value           = Status;
                    t_Isuses.StateUpdateTime.Value = DateTime.Now;
                    isHasUpdate = true;
                }
                string WinNumber = null;
                if (lottoNum != null)
                {
                    WinNumber = eTicketProvider.ConverToSystemLottoNum(lotoid, lottoNum);
                }

                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 SLS.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 SLS.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 (SLS.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)
                            {
                                log.Write("(QueryIsuseState)电子票撤销追号错误 P_ChaseTaskStopWhenWin。");
                            }
                        }
                    }
                }

                if (isHasUpdate)
                {
                    t_Isuses.Update(ConnectionString, "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IssueName + "'");
                }
                #endregion
            }
        }