Example #1
0
        /// <summary>
        /// 开奖第二步,处理代理商电子票逻辑
        /// </summary>
        /// <param name="issueNo"></param>
        /// <param name="lotoId"></param>
        /// <param name="winNumber"></param>
        /// <param name="winMoneyList"></param>
        private void ExecForOpen_StepTwo(string issueNo, int lotoId, string winNumber, double[] winMoneyList)
        {
            var dt = new SLS.Dal.Tables.T_ElectronTicketAgentSchemes().Open(ConnectString
                                                                            , "*"
                                                                            , "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(issueNo) + " and WinMoney is null and state = 1"
                                                                            , "[ID]");

            if (dt == null)
            {
                throw new SLS.Common.ElectronicException("数据库读写错误");
            }

            var t_ElectronTicketAgentSchemes = new SLS.Dal.Tables.T_ElectronTicketAgentSchemes();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string LotteryNumber     = dt.Rows[i]["LotteryNumber"].ToString();
                string Description       = "";
                double WinMoneyNoWithTax = 0;

                double WinMoney = new SLS.Lottery()[lotoId].ComputeWin(LotteryNumber, winNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dt.Rows[i]["PlayTypeID"].ToString()), winMoneyList);

                t_ElectronTicketAgentSchemes.WinMoney.Value           = WinMoney * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1);
                t_ElectronTicketAgentSchemes.WinMoneyWithoutTax.Value = WinMoneyNoWithTax * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1);
                t_ElectronTicketAgentSchemes.WinDescription.Value     = Description;

                t_ElectronTicketAgentSchemes.Update(ConnectString, "[ID] =" + dt.Rows[i]["ID"].ToString());
            }
        }
        public string GenerateLuckLotteryNumber(int LotteryID, string Type, string Name)
        {
            string key = "Home_Room_Buy_GenerateLuckLotteryNumber" + LotteryID.ToString();

            Type = Shove._Web.Utility.FilteSqlInfusion(Type);
            Name = Shove._Web.Utility.FilteSqlInfusion(Name);
            if (Type == "3")
            {
                try
                {
                    DateTime time = Convert.ToDateTime(Name);
                    Name = time.ToString("yyyy-MM-dd");
                    if (time > DateTime.Now)
                    {
                        return("出生日期不能超过当前日期!");
                    }
                }
                catch
                {
                    return("日期格式不正确!");
                }
            }
            DataTable cacheAsDataTable = Shove._Web.Cache.GetCacheAsDataTable(key);

            if ((cacheAsDataTable == null) || (cacheAsDataTable.Rows.Count == 0))
            {
                cacheAsDataTable = new Tables.T_LuckNumber().Open("", "datediff(d,getdate(),DateTime)=0 and LotteryID=" + LotteryID.ToString(), "");
                Shove._Web.Cache.SetCache(key, cacheAsDataTable, 0xe10);
            }
            string lotteryNumber = "";

            DataRow[] rowArray = cacheAsDataTable.Select("Type=" + Type + " and Name='" + Name + "'");
            if ((rowArray != null) && (rowArray.Length > 0))
            {
                lotteryNumber = rowArray[0]["LotteryNumber"].ToString();
            }
            else
            {
                lotteryNumber = new SLS.Lottery()[LotteryID].BuildNumber(1);
                Tables.T_LuckNumber number = new Tables.T_LuckNumber
                {
                    LotteryID     = { Value = LotteryID },
                    LotteryNumber = { Value = lotteryNumber },
                    Name          = { Value = Name },
                    Type          = { Value = Type }
                };
                number.Insert();
                number.Delete("datediff(d,DateTime,getdate())>0");
                Shove._Web.Cache.ClearCache(key);
            }
            return(lotteryNumber + "|" + this.FormatLuckLotteryNumber(LotteryID, lotteryNumber));
        }
Example #3
0
        //获取开奖号码
        public static DataTable GetDataTable(DataTable dt, int Type2)
        {
            DataColumn newDC0 = new DataColumn("Order", System.Type.GetType("System.String"));
            DataColumn newDC1 = new DataColumn("LotteryID", System.Type.GetType("System.String"));
            DataColumn newDC2 = new DataColumn("LotteryName", System.Type.GetType("System.String"));
            DataColumn newDC3 = new DataColumn("IsuseName", System.Type.GetType("System.String"));
            DataColumn newDC4 = new DataColumn("WinLotteryNumber", System.Type.GetType("System.String"));
            DataColumn newDC5 = new DataColumn("LotteryTypeID", System.Type.GetType("System.String"));
            DataColumn newDC6 = new DataColumn("LotteryType2", System.Type.GetType("System.String"));
            DataColumn newDC7 = new DataColumn("LotteryType2Name", System.Type.GetType("System.String"));

            DataTable dtType2 = new DataTable();

            dtType2.Columns.Add(newDC0);
            dtType2.Columns.Add(newDC1);
            dtType2.Columns.Add(newDC2);
            dtType2.Columns.Add(newDC3);
            dtType2.Columns.Add(newDC4);
            dtType2.Columns.Add(newDC5);
            dtType2.Columns.Add(newDC6);
            dtType2.Columns.Add(newDC7);

            DataRow[] Rows;

            if (Type2 == 3)
            {
                Rows = dt.Select("LotteryType2 = " + Type2 + "and LotteryID <> " + SLS.Lottery.ZCDC.ID.ToString(), "EndTime desc");
            }
            else
            {
                Rows = dt.Select("LotteryType2 = " + Type2, "EndTime desc");
            }

            foreach (DataRow dr in Rows)
            {
                DataRow dr1 = dtType2.NewRow();
                dr1[0] = dr[0].ToString();
                dr1[1] = dr[1].ToString();
                dr1[2] = dr[2].ToString();
                dr1[3] = dr[3].ToString();
                dr1[4] = new SLS.Lottery()[int.Parse(dr[1].ToString())].ShowNumber(dr[4].ToString());
                dr1[5] = dr[5].ToString();
                dr1[6] = dr[6].ToString();
                dr1[7] = dr[7].ToString();

                dtType2.Rows.Add(dr1);
            }

            return(dtType2);
        }
 public string GenerateLuckLotteryNumber(int LotteryID, string Type, string Name)
 {
     string key = "Home_Room_Buy_GenerateLuckLotteryNumber" + LotteryID.ToString();
     Type = Shove._Web.Utility.FilteSqlInfusion(Type);
     Name = Shove._Web.Utility.FilteSqlInfusion(Name);
     if (Type == "3")
     {
         try
         {
             DateTime time = Convert.ToDateTime(Name);
             Name = time.ToString("yyyy-MM-dd");
             if (time > DateTime.Now)
             {
                 return "出生日期不能超过当前日期!";
             }
         }
         catch
         {
             return "日期格式不正确!";
         }
     }
     DataTable cacheAsDataTable = Shove._Web.Cache.GetCacheAsDataTable(key);
     if ((cacheAsDataTable == null) || (cacheAsDataTable.Rows.Count == 0))
     {
         cacheAsDataTable = new Tables.T_LuckNumber().Open("", "datediff(d,getdate(),DateTime)=0 and LotteryID=" + LotteryID.ToString(), "");
         Shove._Web.Cache.SetCache(key, cacheAsDataTable, 0xe10);
     }
     string lotteryNumber = "";
     DataRow[] rowArray = cacheAsDataTable.Select("Type=" + Type + " and Name='" + Name + "'");
     if ((rowArray != null) && (rowArray.Length > 0))
     {
         lotteryNumber = rowArray[0]["LotteryNumber"].ToString();
     }
     else
     {
         lotteryNumber = new SLS.Lottery()[LotteryID].BuildNumber(1);
         Tables.T_LuckNumber number = new Tables.T_LuckNumber
         {
             LotteryID = { Value = LotteryID },
             LotteryNumber = { Value = lotteryNumber },
             Name = { Value = Name },
             Type = { Value = Type }
         };
         number.Insert();
         number.Delete("datediff(d,DateTime,getdate())>0");
         Shove._Web.Cache.ClearCache(key);
     }
     return (lotteryNumber + "|" + this.FormatLuckLotteryNumber(lotteryNumber));
 }
        private void BindDataForAliBuy(long BuyID)
        {
            DataTable table = new Tables.T_AlipayBuyTemp().Open("", "ID=" + BuyID.ToString(), "");

            if ((table != null) && (table.Rows.Count != 0))
            {
                DataRow row   = table.Rows[0];
                string  s     = row["IsuseID"].ToString();
                string  str2  = row["PlayTypeID"].ToString();
                bool    flag  = _Convert.StrToBool(row["IsChase"].ToString(), false);
                bool    flag2 = _Convert.StrToBool(row["IsCoBuy"].ToString(), false);
                string  str3  = row["Share"].ToString();
                string  str4  = row["BuyShare"].ToString();
                string  str5  = row["AssureShare"].ToString();
                string  str6  = row["OpenUsers"].ToString();
                string  str7  = row["Title"].ToString();
                string  str8  = row["Description"].ToString();
                string  str9  = row["StopwhenwinMoney"].ToString();
                string  str10 = row["SecrecyLevel"].ToString();
                string  str11 = row["LotteryNumber"].ToString();
                string  str12 = row["SumMoney"].ToString();
                string  str13 = row["AssureMoney"].ToString();
                string  str14 = row["LotteryID"].ToString();
                string  str15 = row["Multiple"].ToString();
                string  xml   = row["AdditionasXml"].ToString();
                if (str15 == "")
                {
                    str15 = "1";
                }
                double num      = 0.0;
                int    num2     = 0;
                int    num3     = 0;
                double num4     = 0.0;
                int    num5     = 0;
                short  num6     = 0;
                int    playType = 0;
                int    num8     = 0;
                try
                {
                    num      = double.Parse(str12);
                    num2     = int.Parse(str3);
                    num3     = int.Parse(str4);
                    num4     = double.Parse(str13);
                    num5     = int.Parse(str15);
                    num6     = short.Parse(str10);
                    playType = int.Parse(str2);
                    num8     = int.Parse(str14);
                    long.Parse(s);
                    double.Parse(str9);
                }
                catch
                {
                }
                if ((num3 == num2) && (num4 == 0.0))
                {
                    num2 = 1;
                    num3 = 1;
                }
                double num1 = num / ((double)num2);
                if (flag)
                {
                    double.Parse(str12);
                }
                string str17 = str11;
                if (str17[str17.Length - 1] == '\n')
                {
                    str17 = str17.Substring(0, str17.Length - 1);
                }
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("<script type='text/javascript' defer='defer'>");
                builder.AppendLine("function clickPlayClass(i,obj)").AppendLine("{").AppendLine("var tds = obj.offsetParent.rows[0].cells;").AppendLine("for(var a=0; a<tds.length-1; a++)").AppendLine("{").AppendLine("if(a%2==1)").AppendLine("{").AppendLine("tds[a].className = 'nsplay';").AppendLine("}").AppendLine("if($Id('playTypes' + String(a))!=null)").AppendLine("{").AppendLine("$Id('playTypes' + String(a)).style.display = 'none';").AppendLine("}").AppendLine("}").AppendLine("var pt = $Id('playTypes' + String(i));").AppendLine("pt.style.display = '';");
                builder.AppendLine("$Id('playTypes').style.display = ((i == 1 || i == 2 || i == 3) ? 'none':'');");
                builder.AppendLine("obj.className = 'msplay';").AppendLine("}");
                builder.Append("var playclass =").Append("$Id('playType").Append(playType.ToString()).AppendLine("').parentNode.id.substr(9,1);");
                builder.Append("clickPlayClass(playclass,").Append("$Id('tbPlayTypeMenu").Append(num8.ToString()).AppendLine("').rows[0].cells[playclass*2+1]);");
                builder.Append("$Id('playType").Append(playType.ToString()).AppendLine("').checked = true;");
                builder.AppendLine("clickPlayType('" + playType.ToString() + "');");
                builder.AppendLine("function BindDataForFromAli(){");
                if (flag)
                {
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(xml);
                    foreach (XmlNode node in document.ChildNodes[0].ChildNodes)
                    {
                        builder.Append("$Id('times").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["Multiple"].Value).AppendLine("';");
                        builder.Append("$Id('money").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["Money"].Value).AppendLine("';");
                        builder.Append("$Id('share").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["Share"].Value).AppendLine("';");
                        builder.Append("$Id('buyedShare").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["BuyedShare"].Value).AppendLine("';");
                        builder.Append("$Id('assureShare").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["AssureShare"].Value).AppendLine("';");
                        builder.Append("$Id('check").Append(node.Attributes["IsuseID"].Value).AppendLine("').checked = true;");
                        builder.Append("$Id('times").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                        builder.Append("$Id('share").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                        builder.Append("$Id('buyedShare").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                        builder.Append("$Id('assureShare").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                    }
                }
                str17 = str17.Replace("\r", "");
                int    num9            = 0;
                string canonicalNumber = "";
                foreach (string str19 in str17.Split(new char[] { '\n' }))
                {
                    num9 += new SLS.Lottery()[num8].ToSingle(str19, ref canonicalNumber, playType).Length;
                    builder.AppendLine("var option = document.createElement('option');");
                    builder.AppendLine("$Id('list_LotteryNumber').options.add(option);");
                    builder.Append("option.innerText = '").Append(str19).AppendLine("';");
                    builder.Append("option.value = '").Append(str19).AppendLine("';");
                }
                if (flag)
                {
                    builder.AppendLine("$Id('Chase').checked = true;");
                    builder.AppendLine("oncbInitiateTypeClick($Id('Chase'));");
                }
                if (flag2)
                {
                    builder.AppendLine("$Id('CoBuy').checked = true;");
                    builder.AppendLine("oncbInitiateTypeClick($Id('CoBuy'));");
                }
                builder.Append("$Id('tb_LotteryNumber').value = '").Append(str11.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
                builder.Append("$Id('tb_Share').value = '").Append(str3).AppendLine("';");
                builder.Append("$Id('tb_BuyShare').value = '").Append(str4).AppendLine("';");
                builder.Append("$Id('tb_AssureShare').value = '").Append(str5).AppendLine("';");
                builder.Append("$Id('tb_OpenUserList').value = '").Append(str6).AppendLine("';");
                builder.Append("$Id('tb_Title').value = '").Append(str7).AppendLine("';");
                builder.Append("$Id('tb_Description').value = '").Append(str8.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
                builder.Append("$Id('tbAutoStopAtWinMoney').value = '").Append(str9).AppendLine("';");
                builder.Append("$Id('SecrecyLevel").Append(num6.ToString()).AppendLine("').checked = true;");
                builder.Append("$Id('tb_hide_SumMoney').value = '").Append(str12).AppendLine("';");
                builder.Append("$Id('tb_hide_AssureMoney').value = '").Append(num4.ToString("N0")).AppendLine("';");
                builder.Append("$Id('tb_Multiple').value = '").Append(num5.ToString()).AppendLine("';");
                builder.Append("$Id('lab_AssureMoney').innerText = '").Append(num4.ToString("N0")).AppendLine("';");
                builder.Append("$Id('lab_SumMoney').innerText = '").Append(num.ToString("N0")).AppendLine("';");
                builder.Append("$Id('LbSumMoney').innerText = '").Append(num.ToString("N0")).AppendLine("';");
                builder.Append("$Id('lab_Num').innerText = '").Append(num9.ToString()).AppendLine("';");
                builder.AppendLine("CalcResult();");
                builder.AppendLine("}");
                builder.AppendLine("</script>");
                this.script = builder.ToString();
            }
        }
Example #6
0
        private void SchemeSystemDealForJCZQ()	//检测竞彩未满员的方案,未成功方案系统撤单,竞彩专用(系统撤单)
        {
            int Result = 0;
            int ReturnValue = 0;
            string ReturnDescription = "";

            string LotteryNumber = "";
            string BuyContent = "";
            string vote = "";

            DataTable dt = MSSQL.Select(ConnectionString, "select [ID], SiteID, LotteryNumber, LotteryID, PlayTypeID, AssureMoney from V_SchemeSchedules where QuashStatus = 0 and Buyed = 0 and Schedule < 100 and LotteryID in (72, 73)");

            if (dt == null)
            {
                return;
            }

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

            DataTable dtPlayType = MSSQL.Select(ConnectionString, "select LotteryID, SystemEndAheadMinute, ID from T_PlayTypes where LotteryID in (72, 73)");

            if (dtPlayType == null)
            {
                return;
            }

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

            DataTable dtMatch = null;

            SLS.Lottery LotteryDc = new SLS.Lottery();

            string strMatchID = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                long SchemeID = long.Parse(dt.Rows[i]["ID"].ToString());
                long SiteID = long.Parse(dt.Rows[i]["SiteID"].ToString());
                 
                strMatchID = "";

                LotteryNumber = dt.Rows[i]["LotteryNumber"].ToString();

                if ((dt.Rows[i]["LotteryID"].ToString() == "72") && LotteryDc[SLS.Lottery.JCZQ.sID].GetSchemeSplit(LotteryNumber, ref BuyContent, ref vote))
                {
                    if (string.IsNullOrEmpty(BuyContent))
                    {
                        continue;
                    }

                    string[] strBuyContent = BuyContent.Replace("][", "|").Replace("]", "").Replace("[", "").Split('|');

                    foreach (string str in strBuyContent)
                    {
                        strMatchID += str.Substring(0, str.IndexOf("(")) + ",";
                    }

                    if (strMatchID.EndsWith(","))
                    {
                        strMatchID = strMatchID.Substring(0, strMatchID.Length - 1);
                    }

                    dtMatch = MSSQL.Select(ConnectionString, "select min(StopSellingTime) as StopSellingTime from T_match where ID in (" + strMatchID + ")", null);

                    if (dtMatch == null)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (dtMatch.Rows.Count == 0)
                    {
                        continue;
                    }

                    int time = Shove._Convert.StrToInt(dtPlayType.Select("ID=" + dt.Rows[i]["PlayTypeID"].ToString())[0]["SystemEndAheadMinute"].ToString(), 0);

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) < 0 &&
                        Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).CompareTo(DateTime.Now) > 0 && Shove._Convert.StrToDouble(dt.Rows[i]["AssureMoney"].ToString(), 0) > 0)
                    {

                        int Return = DAL.Procedures.P_SchemeAssureMoney(ConnectionString, SchemeID, ref ReturnValue, ref ReturnDescription);

                        if (Return < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());

                            return;
                        }

                        if (ReturnValue < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                        }

                        continue;
                    }

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) > 0)
                    {
                        continue;
                    }

                    Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, SchemeID, true, true, ref ReturnValue, ref ReturnDescription);

                    if (Result < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (ReturnValue < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");

                        continue;
                    }

                    if (ReturnDescription != "")
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                    }
                }
                else if ((dt.Rows[i]["LotteryID"].ToString() == "73") && LotteryDc[SLS.Lottery.JCLQ.sID].GetSchemeSplit(LotteryNumber, ref BuyContent, ref vote))
                {
                    if (string.IsNullOrEmpty(BuyContent))
                    {
                        continue;
                    }

                    string[] strBuyContent = BuyContent.Split('|');

                    foreach (string str in strBuyContent)
                    {
                        strMatchID += str.Substring(0, str.IndexOf("(")) + ",";
                    }

                    if (strMatchID.EndsWith(","))
                    {
                        strMatchID = strMatchID.Substring(0, strMatchID.Length - 1);
                    }

                    dtMatch = MSSQL.Select(ConnectionString, "select min(StopSellingTime) as StopSellingTime from T_MatchBasket where ID in (" + strMatchID + ")", null);

                    if (dtMatch == null)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (dtMatch.Rows.Count == 0)
                    {
                        continue;
                    }

                    int time = Shove._Convert.StrToInt(dtPlayType.Select("ID=" + dt.Rows[i]["PlayTypeID"].ToString())[0]["SystemEndAheadMinute"].ToString(), 0);

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) < 0 &&
                        Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).CompareTo(DateTime.Now) > 0 && Shove._Convert.StrToDouble(dt.Rows[i]["AssureMoney"].ToString(), 0) > 0)
                    {

                        int Return = DAL.Procedures.P_SchemeAssureMoney(ConnectionString, SchemeID, ref ReturnValue, ref ReturnDescription);

                        if (Return < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());

                            return;
                        }

                        if (ReturnValue < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                        }

                        continue;
                    }

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) > 0)
                    {
                        continue;
                    }

                    Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, SchemeID, true, true, ref ReturnValue, ref ReturnDescription);

                    if (Result < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (ReturnValue < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");

                        continue;
                    }

                    if (ReturnDescription != "")
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                    }
                }
            }
        }
Example #7
0
        //把方案拆分成票,并写入数据库
        private void WriteTickets()
        {
            DataTable dt = new DAL.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money", "Buyed = 0 and PrintOutType = 101 and (GetDate() between StartTime and EndTime) and Schedule >= 100 and not [ID] in (select SchemeID from T_SchemesSendToCenter)", "[ID]");

            if (dt == null)
            {
                log.Write("向恒朋-重庆电子票网关发送数据出错:读取方案错误。");

                return;
            }

            foreach (DataRow dr in dt.Rows)
            {
                long   SchemeID     = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int    LotteryID    = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotterNumber = dr["LotteryNumber"].ToString();
                int    PlayTypeID   = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int    Multiple     = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    log.Write("向恒朋-重庆电子票网关发送数据出错:读取方案错误。方案号:" + SchemeID.ToString());

                    continue;
                }

                double Money = 0;
                SLS.Lottery.Ticket[] Tickets = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPCQ(PlayTypeID, LotterNumber, Multiple, 200, ref Money);

                if (Tickets == null)
                {
                    log.Write("向恒朋-重庆电子票网关发送数据出错:读取方案错误。方案号:" + SchemeID.ToString());

                    continue;
                }

                if (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1))
                {
                    log.Write("向恒朋-重庆电子票网关发送数据出错:异常警告!!!!。方案号:" + SchemeID.ToString() + "的购买金额与实际票的金额不符合!!!!");

                    continue;
                }

                int Count = 0;

                foreach (SLS.Lottery.Ticket ticket in Tickets)
                {
                    int TicketID = -1;
                    //long ID = -1;
                    string ReturnDescription = "";

                    Count++;

                    if (TicketID < 0)
                    {
                        log.Write("向恒朋-重庆电子票网关发送数据出错:部分票写入错误:" + ReturnDescription + ",方案号:" + SchemeID.ToString());

                        continue;
                    }
                }
            }
        }
Example #8
0
        private void BindDataForAliBuy(long BuyID)
        {
            DataTable table = new Tables.T_AlipayBuyTemp().Open("", "ID=" + BuyID.ToString(), "");

            if ((table != null) && (table.Rows.Count != 0))
            {
                DataRow row   = table.Rows[0];
                string  s     = row["IsuseID"].ToString();
                string  str2  = row["PlayTypeID"].ToString();
                bool    flag  = _Convert.StrToBool(row["IsCoBuy"].ToString(), false);
                string  str3  = row["Share"].ToString();
                string  str4  = row["BuyShare"].ToString();
                string  str5  = row["AssureShare"].ToString();
                string  str6  = row["OpenUsers"].ToString();
                string  str7  = row["Title"].ToString();
                string  str8  = row["Description"].ToString();
                string  str9  = row["SecrecyLevel"].ToString();
                string  str10 = row["LotteryNumber"].ToString();
                string  str11 = row["SumMoney"].ToString();
                string  str12 = row["AssureMoney"].ToString();
                string  str13 = row["LotteryID"].ToString();
                string  str14 = row["Multiple"].ToString();
                if (str14 == "")
                {
                    str14 = "1";
                }
                double num      = 0.0;
                int    num2     = 0;
                int    num3     = 0;
                double num4     = 0.0;
                int    num5     = 0;
                short  num6     = 0;
                int    playType = 0;
                int    num8     = 0;
                try
                {
                    num      = double.Parse(str11);
                    num2     = int.Parse(str3);
                    num3     = int.Parse(str4);
                    num4     = double.Parse(str12);
                    num5     = int.Parse(str14);
                    num6     = short.Parse(str9);
                    playType = int.Parse(str2);
                    num8     = int.Parse(str13);
                    long.Parse(s);
                }
                catch
                {
                }
                if ((num3 == num2) && (num4 == 0.0))
                {
                    num2 = 1;
                    num3 = 1;
                }
                double num1  = num / ((double)num2);
                string str15 = str10;
                if (!string.IsNullOrEmpty(str15) && (str15[str15.Length - 1] == '\n'))
                {
                    str15 = str15.Substring(0, str15.Length - 1);
                }
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("<script type='text/javascript' defer='defer'>");
                builder.Append("$Id('playType").Append(playType.ToString()).AppendLine("').checked = true;");
                builder.AppendLine("clickPlayType('" + playType.ToString() + "');");
                builder.AppendLine("function BindDataForFromAli(){");
                str15 = str15.Replace("\r", "");
                int    num9            = 0;
                string canonicalNumber = "";
                foreach (string str17 in str15.Split(new char[] { '\n' }))
                {
                    if (!string.IsNullOrEmpty(str17))
                    {
                        num9 += new SLS.Lottery()[num8].ToSingle(str17, ref canonicalNumber, playType).Length;
                        builder.AppendLine("var option = document.createElement('option');");
                        builder.AppendLine("$Id('list_LotteryNumber').options.add(option);");
                        builder.Append("option.innerText = '").Append(str17).AppendLine("';");
                        builder.Append("option.value = '").Append(str17).AppendLine("';");
                    }
                }
                if (flag)
                {
                    builder.AppendLine("$Id('CoBuy').checked = true;");
                    builder.AppendLine("oncbInitiateTypeClick();");
                }
                builder.Append("$Id('tb_LotteryNumber').value = '").Append(str10.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
                builder.Append("$Id('tb_Share').value = '").Append(str3).AppendLine("';");
                builder.Append("$Id('tb_BuyShare').value = '").Append(str4).AppendLine("';");
                builder.Append("$Id('tb_AssureShare').value = '").Append(str5).AppendLine("';");
                builder.Append("$Id('tb_OpenUserList').value = '").Append(str6).AppendLine("';");
                builder.Append("$Id('tb_Title').value = '").Append(str7).AppendLine("';");
                builder.Append("$Id('tb_Description').value = '").Append(str8.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
                builder.Append("$Id('SecrecyLevel").Append(num6.ToString()).AppendLine("').checked = true;");
                builder.Append("$Id('tb_hide_SumMoney').value = '").Append(str11).AppendLine("';");
                builder.Append("$Id('tb_hide_AssureMoney').value = '").Append(num4.ToString("N0")).AppendLine("';");
                builder.Append("$Id('tb_Multiple').value = '").Append(num5.ToString()).AppendLine("';");
                builder.Append("$Id('lab_AssureMoney').innerText = '").Append(num4.ToString("N0")).AppendLine("';");
                builder.Append("$Id('lab_SumMoney').innerText = '").Append(num.ToString("N0")).AppendLine("';");
                builder.Append("$Id('lab_Num').innerText = '").Append(num9.ToString()).AppendLine("';");
                builder.Append("$Id('tb_SchemeMoney').value = '").Append(num.ToString()).AppendLine("';");
                builder.AppendLine("CalcResult();");
                builder.AppendLine("}");
                if (str2.Length != (num8.ToString().Length + 2))
                {
                    builder.AppendLine("BindDataForFromAli()");
                }
                builder.AppendLine("</script>");
                this.script = builder.ToString();
            }
        }
Example #9
0
    public static DataTable GetZCDCBuyContent(string BuyNum, long SchemeID, ref string vote)
    {
        string lotteryNumber = Shove._Convert.ToHtmlCode(BuyNum);

        string BuyContent = "";

        bool IsGetScheme = new SLS.Lottery()[SLS.Lottery.ZCDC.sID].GetSchemeSplit(lotteryNumber, ref BuyContent, ref vote);

        string PlayType = lotteryNumber.Split(';')[0].ToString();

        string[] Team = BuyContent.Split('|');

        DataTable dtnew = new DataTable();
        DataColumn newDC;

        newDC = new DataColumn("No", System.Type.GetType("System.Int32"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("LeagueTypeName", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("HostTeam", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("QuestTeam", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("Content", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("MarkersColor", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("sp", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("LotteryResult", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("GamesResult", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        newDC = new DataColumn("HalftimeResult", System.Type.GetType("System.String"));
        dtnew.Columns.Add(newDC);

        for (int i = 0; i < Team.Length; i++)
        {
            DataTable dtp = GetTeamInfo(Team[i].Split('(')[0], SchemeID);

            if (dtp == null)
            {
                return null;
            }

            string TeamResult = Team[i].Split('(')[1].Substring(0, Team[i].Split('(')[1].Length - 1);

            string LotteryResult = "";
            string GamesResult = "";
            string HalftimeResult = "";
            string LetBall = "";
            string sp = "";
            if (PlayType == SLS.Lottery.ZCDC.PlayType_SPF.ToString())
            {
                TeamResult = TeamResult.Replace("0", "负").Replace("1", "平").Replace("3", "胜");

                if (dtp.Rows[0]["SPFResult"] != null)
                {
                    LotteryResult = dtp.Rows[0]["SPFResult"].ToString();
                    LotteryResult = LotteryResult.Replace("0", "负").Replace("1", "平").Replace("3", "胜");
                }

                if (dtp.Rows[0]["SPF_SP"] != null)
                {
                    sp = dtp.Rows[0]["SPF_SP"].ToString();
                }
            }

            if (PlayType == SLS.Lottery.ZCDC.PlayType_ZJQ.ToString())
            {
                TeamResult = TeamResult.Replace("7", "7+");

                if (dtp.Rows[0]["ZJQResult"] != null)
                {
                    LotteryResult = dtp.Rows[0]["ZJQResult"].ToString();
                    LotteryResult = LotteryResult.Replace("7", "7+");
                }

                if (dtp.Rows[0]["ZJQ_SP"] != null)
                {
                    sp = dtp.Rows[0]["ZJQ_SP"].ToString();
                }
            }

            if (PlayType == SLS.Lottery.ZCDC.PlayType_SXDS.ToString())
            {
                TeamResult = TeamResult.Replace("1", "上-单").Replace("2", "上-双").Replace("3", "下-单").Replace("4", "下-双");

                if (dtp.Rows[0]["SXDSResult"] != null)
                {
                    LotteryResult = dtp.Rows[0]["SXDSResult"].ToString();
                    LotteryResult = LotteryResult.Replace("1", "上-单").Replace("2", "上-双").Replace("3", "下-单").Replace("4", "下-双");
                }

                if (dtp.Rows[0]["SXDS_SP"] != null)
                {
                    sp = dtp.Rows[0]["SXDS_SP"].ToString();
                }
            }

            string SaleTeam = "";
            string SaleTeamResult = "";

            if (PlayType == SLS.Lottery.ZCDC.PlayType_ZQBF.ToString())
            {
                string[] Teams = TeamResult.Split(',');

                for (int j = 0; j < Teams.Length; j++)
                {
                    if (Teams[j].Length > 1)
                    {
                        SaleTeam += Teams[j].Replace("25", "负其他").Replace("24", "2:4").Replace("23", "1:4").Replace("22", "0:4").Replace("21", "2:3").Replace("20", "1:3").Replace("19", "0:3").Replace("18", "1:2").Replace("17", "0:2").Replace("16", "0:1").Replace("15", "平其他").Replace("14", "3:3").Replace("13", "2:2").Replace("12", "1:1").Replace("11", "0:0").Replace("10", "胜其他");
                    }
                    else
                    {
                        SaleTeam += Teams[j].Replace("1", "1:0").Replace("2", "2:0").Replace("3", "2:1").Replace("4", "3:0").Replace("5", "3:1").Replace("6", "3:2").Replace("7", "4:0").Replace("8", "4:1").Replace("9", "4:2");

                    }

                    SaleTeam += ",";
                }

                TeamResult = SaleTeam.Substring(0, SaleTeam.Length - 1);

                if (dtp.Rows[0]["ZQBFResult"] != null)
                {
                    string[] TeamsResult = dtp.Rows[0]["ZQBFResult"].ToString().Split(',');

                    for (int j = 0; j < TeamsResult.Length; j++)
                    {

                        if (TeamsResult[j].Length > 1)
                        {
                            SaleTeamResult += TeamsResult[j].Replace("25", "负其他").Replace("24", "2:4").Replace("23", "1:4").Replace("22", "0:4").Replace("21", "2:3").Replace("20", "1:3").Replace("19", "0:3").Replace("18", "1:2").Replace("17", "0:2").Replace("16", "0:1").Replace("15", "平其他").Replace("14", "3:3").Replace("13", "2:2").Replace("12", "1:1").Replace("11", "0:0").Replace("10", "胜其他");
                        }
                        else
                        {
                            SaleTeamResult += TeamsResult[j].Replace("1", "1:0").Replace("2", "2:0").Replace("3", "2:1").Replace("4", "3:0").Replace("5", "3:1").Replace("6", "3:2").Replace("7", "4:0").Replace("8", "4:1").Replace("9", "4:2");

                        }

                        SaleTeamResult += ",";
                    }

                    LotteryResult = SaleTeamResult.Substring(0, SaleTeamResult.Length - 1);
                }


                if (dtp.Rows[0]["ZQBF_SP"] != null)
                {
                    sp = dtp.Rows[0]["ZQBF_SP"].ToString();
                }

            }

            if (PlayType == SLS.Lottery.ZCDC.PlayType_BQCSPF.ToString())
            {
                TeamResult = TeamResult.Replace("1", "胜-胜").Replace("2", "胜-平").Replace("3", "胜-负").Replace("4", "平-胜").Replace("5", "平-平").Replace("6", "平-负").Replace("7", "负-胜").Replace("8", "负-平 ").Replace("9", "负-负");

                if (dtp.Rows[0]["BQCSPFResult"] != null)
                {
                    LotteryResult = dtp.Rows[0]["BQCSPFResult"].ToString();
                    LotteryResult = LotteryResult.Replace("1", "胜-胜").Replace("2", "胜-平").Replace("3", "胜-负").Replace("4", "平-胜").Replace("5", "平-平").Replace("6", "平-负").Replace("7", "负-胜").Replace("8", "负-平 ").Replace("9", "负-负");
                }

                if (dtp.Rows[0]["BQCSPF_SP"] != null)
                {
                    sp = dtp.Rows[0]["BQCSPF_SP"].ToString();
                }
            }

            if (LotteryResult == "*")
            {
                LotteryResult = "延时";
                sp = "1";
            }

            if (dtp.Rows[0]["Result"] != null)
            {
                GamesResult = dtp.Rows[0]["Result"].ToString();
            }

            if (dtp.Rows[0]["HalftimeResult"] != null)
            {
                HalftimeResult = dtp.Rows[0]["HalftimeResult"].ToString();
            }

            if (dtp.Rows[0]["LetBall"] != null)
            {
                LetBall = dtp.Rows[0]["LetBall"].ToString();
            }

            if (LetBall == "0")
            {
                LetBall = "";
            }
            else
            {
                LetBall = "[" + LetBall + "]";
            }

            DataRow dr1 = dtnew.NewRow();
            dr1[0] = dtp.Rows[0]["No"].ToString();
            dr1[1] = dtp.Rows[0]["LeagueTypeName"].ToString();
            dr1[2] = dtp.Rows[0]["HostTeam"].ToString() + LetBall;
            dr1[3] = dtp.Rows[0]["QuestTeam"].ToString();
            dr1[4] = TeamResult;
            dr1[5] = dtp.Rows[0]["MarkersColor"].ToString();
            dr1[6] = sp;
            dr1[7] = LotteryResult;
            dr1[8] = GamesResult;
            dr1[9] = HalftimeResult;
            dtnew.Rows.Add(dr1);
        }

        return dtnew;
    }
Example #10
0
        // 满员方案拆分为票
        private void WriteTickets()
        {
            DataTable dt = new DAL.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money, (case LotteryID when 29 then -29 else LotteryID end) as LotteryID_2", "Buyed = 0 and (GetDate() between StartTime and EndTime) and BuyedShare >= Share and isnull(Identifiers, '') = '' and PrintOutType = 102 and State = 1 and dateadd(mi, 1, StateUpdateTime) <= GetDate() and LotteryID = 29", "LotteryID_2, UserType desc, [ID]");

            if (dt == null)
            {
                msg.Send("读取方案错误(WriteTickets)。");
                log.Write("读取方案错误(WriteTickets)。");

                return;
            }

            DAL.Tables.T_Schemes t_Schemes = new DAL.Tables.T_Schemes();

            foreach (DataRow dr in dt.Rows)
            {
                long SchemeID = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int LotteryID = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotterNumber = dr["LotteryNumber"].ToString();
                int PlayTypeID = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int Multiple = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    msg.Send("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());

                    continue;
                }

                double Money = 0;
                SLS.Lottery.Ticket[] Tickets = null;

                try
                {
                    Tickets = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPSH(PlayTypeID, LotterNumber, Multiple, 200, ref Money);
                }
                catch (Exception e)
                {
                    msg.Send("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);
                    log.Write("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);

                    continue;
                }

                if (Tickets == null)
                {
                    msg.Send("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());

                    continue;
                }

                if (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1))
                {
                    msg.Send("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");
                    log.Write("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");

                    SMS.Eucp.Gateway.CallResult SmsResult = segg.Send("13537697101", "异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");

                    if (SmsResult.Code < 0)
                    {
                        log.Write("Send is Fail: " + SmsResult.Description);
                    }

                    SmsResult = segg.Send("13612833534", "异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");

                    continue;
                }

                int TicketPlayTypeID = Tickets[0].PlayTypeID;

                string TicketXML = "<Tickets>";

                foreach (SLS.Lottery.Ticket ticket in Tickets)
                {
                    TicketXML += "<Ticket LotteryNumber=\"" + ticket.Number + "\" Multiple=\"" + ticket.Multiple + "\" Money=\"" + ticket.Money + "\" />";
                }

                TicketXML += "</Tickets>";

                int ReturnValue = 0;
                string ReturnDescription = "";

                int Result = DAL.Procedures.P_SchemesSendToCenterAdd(ConnectionString, SchemeID, TicketPlayTypeID, TicketXML, ref ReturnValue, ref ReturnDescription);

                if ((Result < 0) || (ReturnValue < 0))
                {
                    msg.Send("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                    log.Write("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                }
            }
        }
Example #11
0
        //把方案拆分成票,并写入数据库
        private void WriteTickets()
        {
            DataTable dt = new DAL.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money", "Buyed = 0 and PrintOutType = 101 and (GetDate() between StartTime and EndTime) and Schedule >= 100 and not [ID] in (select SchemeID from T_SchemesSendToCenter)", "[ID]");

            if (dt == null)
            {
                log.Write("向恒朋-重庆电子票网关发送数据出错:读取方案错误。");

                return;
            }

            foreach (DataRow dr in dt.Rows)
            {
                long SchemeID = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int LotteryID = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotterNumber = dr["LotteryNumber"].ToString();
                int PlayTypeID = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int Multiple = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    log.Write("向恒朋-重庆电子票网关发送数据出错:读取方案错误。方案号:" + SchemeID.ToString());

                    continue;
                }

                double Money = 0;
                SLS.Lottery.Ticket[] Tickets = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPCQ(PlayTypeID, LotterNumber, Multiple, 200, ref Money);

                if (Tickets == null)
                {
                    log.Write("向恒朋-重庆电子票网关发送数据出错:读取方案错误。方案号:" + SchemeID.ToString());

                    continue;
                }

                if (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1))
                {
                    log.Write("向恒朋-重庆电子票网关发送数据出错:异常警告!!!!。方案号:" + SchemeID.ToString() + "的购买金额与实际票的金额不符合!!!!");

                    continue;
                }

                int Count = 0;

                foreach (SLS.Lottery.Ticket ticket in Tickets)
                {
                    int TicketID = -1;
                    //long ID = -1;
                    string ReturnDescription = "";

                    Count++;

                    if (TicketID < 0)
                    {
                        log.Write("向恒朋-重庆电子票网关发送数据出错:部分票写入错误:" + ReturnDescription + ",方案号:" + SchemeID.ToString());

                        continue;
                    }
                }
            }
        }
Example #12
0
        //开奖派奖
        private void DrawingLottery(int LotteryID, string IsuseName, string WinNumber)
        {
            Log log = new Log("SystemGetLotteryOpenNumber");

            if (!new SLS.Lottery()[LotteryID].AnalyseWinNumber(WinNumber))
            {
                log.Write("开奖号码不正确!");

                return;
            }

            int ReturnValue = 0;
            string ReturnDescription = "";

            DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(conn, "top 1 [ID], IsOpened", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "' and IsOpened=0 and year(StartTime) = YEAR(GETDATE())", "");
            
            if (dtIsuse == null)
            {
                log.Write("数据读写错误001");

                return;
            }

            if (dtIsuse.Rows.Count <= 0)
            {
                //log.Write("暂无对应期号信息,彩种ID:" + LotteryID.ToString() + ", 期号:" + IsuseName);

                return;
            }

            if (Shove._Convert.StrToBool(dtIsuse.Rows[0]["IsOpened"].ToString(), false))
            {
                //log.Write("彩种ID:" + LotteryID + "第" + IsuseName + "期已开奖");

                return;
            }

            long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1);

            DataTable dtWin = null;
            
            dtWin = new DAL.Tables.T_Schemes().Open(conn, "ID", "IsuseID = " + IsuseID.ToString() + " and isOpened = 0", "");

            if (dtWin == null)
            {
                log.Write("数据读写错误002");

                return;
            }

            // 准备开奖,开奖之前,对出票不完整的方案进行出票处理
            ReturnValue = 0;
            ReturnDescription = "";

            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(conn, "[DefaultMoney],[DefaultMoneyNoWithTax]", "LotteryID = " + LotteryID.ToString(), "[Order]");

            if (dtWinTypes == null)
            {
                log.Write("奖金读取数据读写错误");

                return;
            }

            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            for (int y = 0; y < dtWinTypes.Rows.Count; y++)
            {
                WinMoneyList[y * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoney"].ToString(), 0);
                WinMoneyList[y * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoneyNoWithTax"].ToString(), 0);

                if (WinMoneyList[y * 2] < 0)
                {
                    log.Write("第 " + (y + 1).ToString() + " 项奖金输入错误!");

                    return;
                }
            }

            dtWin = null;

            #region 开奖第一步

            dtWin = new DAL.Tables.T_Schemes().Open(conn, "LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + IsuseID.ToString(), "[ID]");

            if (dtWin == null)
            {
                log.Write("方案数据读取错误");

                return;
            }

            for (int y = 0; y < dtWin.Rows.Count; y++)
            {
                string LotteryNumber = "";

                try
                {
                    LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString();
                }
                catch
                { }

                string Description = "";
                double WinMoneyNoWithTax = 0;

                try
                {

                    double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList);

                    if (WinMoney > 0)
                    {
                        log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 中奖金额:" + WinMoney.ToString());
                    }

                    Shove.Database.MSSQL.ExecuteNonQuery(conn, "update T_Schemes set EditWinMoney = @p1, EditWinMoneyNoWithTax = @p2, WinDescription = @p3 where [ID] = " + dtWin.Rows[y]["ID"].ToString(),
                        new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                        new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                        new Shove.Database.MSSQL.Parameter("p3", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));
                }
                catch
                {
                    log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 开奖号码出现错误");

                    continue;
                }
            }

            #endregion

            log.Write("开奖-----------------------------4");

            #region 开奖第三步

            string OpenAffiche = new OpenAfficheTemplates()[LotteryID];

            int SchemeCount, QuashCount, WinCount, WinNoBuyCount;
            bool isEndOpen = false;

            while (!isEndOpen)
            {
                SchemeCount = 0;
                QuashCount = 0;
                WinCount = 0;
                WinNoBuyCount = 0;
                //  总方案数,处理时撤单数,中奖数,中奖但未成功数

                ReturnValue = 0;
                ReturnDescription = "";
                DataSet dsWin = null;

                P_Win(conn, ref dsWin,
                     IsuseID,
                     WinNumber,
                     OpenAffiche,
                     1,
                     true,
                     ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount,
                     ref isEndOpen,
                     ref ReturnValue, ref ReturnDescription);

                if ((dsWin == null) || (ReturnDescription != ""))
                {
                    log.Write(ReturnDescription);

                    return;
                }

                string Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖还未全部完成, 请继续操作第三步。";

                if (isEndOpen)
                {
                    Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖已全部完成。";
                }

                log.Write(String.Format(Message,LotteryID,WinNumber, SchemeCount, QuashCount, WinCount, WinNoBuyCount));
            }

            #endregion

            log.Write("开奖-----------------------------5");
        }
Example #13
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
            }
        }
Example #14
0
        private void WinScoreScale()
        {
            DataTable dt = MSSQL.Select(ConnectionString, "select id, PlayTypeID, WinMoney, LotteryNumber, IsuseID, Multiple from T_Schemes where not exists (select 1 from T_SchemeIsCalcuteScore where ScoreType = 2 and T_Schemes.ID = T_SchemeIsCalcuteScore.SchemeID) and ID > isnull((select max(SchemeID) - 10000 from T_SchemeIsCalcuteScore where ScoreType = 2), 0) and exists (select 1 from T_Isuses where LotteryID in (6, 28, 29, 60, 61, 62, 63, 64, 68, 70) and T_Isuses.ID = T_Schemes.IsuseID) and isOpened = 1 order by IsuseID desc");

            if (dt == null)
            {
                log.Write("Exec WinScoreScale: DataTable \"WinScoreScale\" Fail.");

                return;
            }

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

            DAL.Tables.T_SchemeIsCalcuteScore t_SchemeIsCalcuteScore = new DAL.Tables.T_SchemeIsCalcuteScore();

            DataTable dtIsuses = null;
            DataTable dtWinMoney = null;

            foreach (DataRow dr in dt.Rows)
            {
                if (Shove._Convert.StrToDouble(dr["WinMoney"].ToString(), 0) == 0)
                {
                    t_SchemeIsCalcuteScore.SchemeID.Value = dr["ID"].ToString();
                    t_SchemeIsCalcuteScore.ScoreType.Value = 2;
                    t_SchemeIsCalcuteScore.Insert(ConnectionString);

                    continue;
                }

                dtIsuses = new DAL.Tables.T_Isuses().Open(ConnectionString, "WinLotteryNumber, LotteryID", "ID=" + dr["IsuseID"].ToString(), "");

                if (dtIsuses == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"T_Isuses\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

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

                dtWinMoney = MSSQL.Select(ConnectionString, "select DefaultMoney * a.ScoreScale as DefaultMoney, DefaultMoneyNoWithTax * a.ScoreScale as DefaultMoneyNoWithTax, a.WinMoney as WinMoney from T_WinTypes inner join T_WinScoreScale a on T_WinTypes.ID = a.WinTypeID where exists (select * from T_PlayTypes where ID = " + dr["PlayTypeID"].ToString() + " and T_WinTypes.LotteryID = T_PlayTypes.LotteryID)  order by [Order]");

                if (dtWinMoney == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"dtWinMoney\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

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

                double[] WinMoneyList = new double[dtWinMoney.Rows.Count * 2];

                double MaxMoney = 0;

                for (int i = 0; i < dtWinMoney.Rows.Count; i++)
                {
                    WinMoneyList[i * 2] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoney"].ToString(), 0);
                    WinMoneyList[i * 2 + 1] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                    if (Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0) > MaxMoney)
                    {
                        MaxMoney = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0);
                    }
                }

                string LotteryNumber = dr["LotteryNumber"].ToString();
                string Description = "";

                double WinMoneyNoWithTax = 0;
                double WinMoney = 0;

                try
                {
                    WinMoney = new SLS.Lottery()[int.Parse(dtIsuses.Rows[0]["LotteryID"].ToString())].ComputeWin(LotteryNumber, dtIsuses.Rows[0]["WinLotteryNumber"].ToString(), ref Description, ref WinMoneyNoWithTax, int.Parse(dr["PlayTypeID"].ToString()), WinMoneyList);
                }
                catch
                {
                    WinMoney = 0;
                }

                log.Write("方案号:" + dr["ID"].ToString() + "-------中奖金额:" + (Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney).ToString() + "-----------最大金额:" + MaxMoney.ToString());

                if (DAL.Procedures.P_SchemeWinCalculatedScore(ConnectionString, Shove._Convert.StrToLong(dr["ID"].ToString(), 0), Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney, MaxMoney) < 0)
                {
                    log.Write("Exec WinScoreScale: Procedures \"P_SchemeWinCalculatedScore\" Fail.");

                    continue;
                }
            }

        #endregion
        }
Example #15
0
        private void WriteTickets()
        {   
            DataTable dt = new SLS.Dal.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money, (case LotteryID when 29 then -29 else LotteryID end) as LotteryID_2", "Buyed = 0 and (GetDate() between StartTime and EndTime) and BuyedShare >= Share and PrintOutType = 301 and State = 1 and dateadd(mi, 1, StateUpdateTime) <= GetDate() and LotteryID <> 29", "LotteryID_2, UserType desc, [ID]"); // and isnull(Identifiers, '') = '' removed from condition
            if (dt == null)
            {
                //msg.Send("读取方案错误(WriteTickets)。");
                log.Write("读取方案错误(WriteTickets)。");
                return;
            }

            SLS.Dal.Tables.T_Schemes t_Schemes = new SLS.Dal.Tables.T_Schemes();
            foreach (DataRow dr in dt.Rows)
            {
                long SchemeID = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int LotteryID = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotteryNumber = dr["LotteryNumber"].ToString();
                int PlayTypeID = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int Multiple = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    //msg.Send("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                double Money = 0;
                //etSunLotto.slTicket[] Tickets = null;
                SLS.Lottery.Ticket[] tics = null;
                try
                {
                    if (LotteryID == SLS.Lottery.CQSSC.ID)
                    {
                        if (PlayTypeID == 2803)
                            tics = eTicketProvider.ToElectronicTicket_ZH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                        else
                            tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPCQ(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                    }
                    else
                        tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPSH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                }
                catch(Exception e)
                {
                    log.Write("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);
                    continue;
                }

                if (tics == null)
                {
                    log.Write("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                if ((LotteryID != SLS.Lottery.CQSSC.ID) && (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1)))
                {
                    log.Write("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");
                    continue;
                }

                string TicketXML = "<Tickets>";
                foreach (SLS.Lottery.Ticket ticket in tics)
                {
                    TicketXML += "<Ticket LotteryNumber=\"" + ticket.Number + "\" Multiple=\"" + ticket.Multiple + "\" Money=\"" + ticket.Money + "\" />";
                }
                TicketXML += "</Tickets>";

                int ReturnValue = 0;
                string ReturnDescription = "";
                int Result = SLS.Dal.Procedures.P_SchemesSendToCenterAdd(ConnectionString, SchemeID, PlayTypeID, TicketXML, ref ReturnValue, ref ReturnDescription);
                if ((Result < 0) || (ReturnValue < 0))
                {
                    log.Write("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                }
            }
        }
Example #16
0
        // 满员方案拆分为票
        private void WriteTickets()
        {
            DataTable dt = new DAL.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money, (case LotteryID when 29 then -29 else LotteryID end) as LotteryID_2", "Buyed = 0 and (GetDate() between StartTime and EndTime) and BuyedShare >= Share and isnull(Identifiers, '') = '' and PrintOutType = 102 and State = 1 and dateadd(mi, 1, StateUpdateTime) <= GetDate() and LotteryID = 29", "LotteryID_2, UserType desc, [ID]");

            if (dt == null)
            {
                msg.Send("读取方案错误(WriteTickets)。");
                log.Write("读取方案错误(WriteTickets)。");

                return;
            }

            DAL.Tables.T_Schemes t_Schemes = new DAL.Tables.T_Schemes();

            foreach (DataRow dr in dt.Rows)
            {
                long   SchemeID     = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int    LotteryID    = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotterNumber = dr["LotteryNumber"].ToString();
                int    PlayTypeID   = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int    Multiple     = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    msg.Send("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());

                    continue;
                }

                double Money = 0;
                SLS.Lottery.Ticket[] Tickets = null;

                try
                {
                    Tickets = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPSH(PlayTypeID, LotterNumber, Multiple, 200, ref Money);
                }
                catch (Exception e)
                {
                    msg.Send("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);
                    log.Write("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);

                    continue;
                }

                if (Tickets == null)
                {
                    msg.Send("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());

                    continue;
                }

                if (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1))
                {
                    msg.Send("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");
                    log.Write("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");

                    SMS.Eucp.Gateway.CallResult SmsResult = segg.Send("13537697101", "异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");

                    if (SmsResult.Code < 0)
                    {
                        log.Write("Send is Fail: " + SmsResult.Description);
                    }

                    SmsResult = segg.Send("13612833534", "异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");

                    continue;
                }

                int TicketPlayTypeID = Tickets[0].PlayTypeID;

                string TicketXML = "<Tickets>";

                foreach (SLS.Lottery.Ticket ticket in Tickets)
                {
                    TicketXML += "<Ticket LotteryNumber=\"" + ticket.Number + "\" Multiple=\"" + ticket.Multiple + "\" Money=\"" + ticket.Money + "\" />";
                }

                TicketXML += "</Tickets>";

                int    ReturnValue       = 0;
                string ReturnDescription = "";

                int Result = DAL.Procedures.P_SchemesSendToCenterAdd(ConnectionString, SchemeID, TicketPlayTypeID, TicketXML, ref ReturnValue, ref ReturnDescription);

                if ((Result < 0) || (ReturnValue < 0))
                {
                    msg.Send("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                    log.Write("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                }
            }
        }
Example #17
0
        private void WriteTickets()
        {
            DataTable dt = new SLS.Dal.Views.V_SchemeSchedules().Open(ConnectionString, "ID, LotteryID, PlayTypeID, LotteryNumber, Multiple, Money, (case LotteryID when 29 then -29 else LotteryID end) as LotteryID_2", "Buyed = 0 and (GetDate() between StartTime and EndTime) and BuyedShare >= Share and PrintOutType = 301 and State = 1 and dateadd(mi, 1, StateUpdateTime) <= GetDate() and LotteryID <> 29", "LotteryID_2, UserType desc, [ID]"); // and isnull(Identifiers, '') = '' removed from condition

            if (dt == null)
            {
                //msg.Send("读取方案错误(WriteTickets)。");
                log.Write("读取方案错误(WriteTickets)。");
                return;
            }

            SLS.Dal.Tables.T_Schemes t_Schemes = new SLS.Dal.Tables.T_Schemes();
            foreach (DataRow dr in dt.Rows)
            {
                long   SchemeID      = Shove._Convert.StrToLong(dr["ID"].ToString(), -1);
                int    LotteryID     = Shove._Convert.StrToInt(dr["LotteryID"].ToString(), -1);
                string LotteryNumber = dr["LotteryNumber"].ToString();
                int    PlayTypeID    = Shove._Convert.StrToInt(dr["PlayTypeID"].ToString(), -1);
                int    Multiple      = Shove._Convert.StrToInt(dr["Multiple"].ToString(), -1);

                if ((SchemeID < 0) || (LotteryID < 0) || (PlayTypeID < 0) || (Multiple < 1))
                {
                    //msg.Send("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    log.Write("读取方案错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                double Money = 0;
                //etSunLotto.slTicket[] Tickets = null;
                SLS.Lottery.Ticket[] tics = null;
                try
                {
                    if (LotteryID == SLS.Lottery.CQSSC.ID)
                    {
                        if (PlayTypeID == 2803)
                        {
                            tics = eTicketProvider.ToElectronicTicket_ZH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                        }
                        else
                        {
                            tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPCQ(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                        }
                    }
                    else
                    {
                        tics = new SLS.Lottery()[LotteryID].ToElectronicTicket_HPSH(PlayTypeID, LotteryNumber, Multiple, 50, ref Money);
                    }
                }
                catch (Exception e)
                {
                    log.Write("拆票错误(WriteTickets)。方案号:" + SchemeID.ToString() + "," + e.Message);
                    continue;
                }

                if (tics == null)
                {
                    log.Write("分解票错误(WriteTickets)。方案号:" + SchemeID.ToString());
                    continue;
                }

                if ((LotteryID != SLS.Lottery.CQSSC.ID) && (Money != Shove._Convert.StrToDouble(dr["Money"].ToString(), -1)))
                {
                    log.Write("异常警告!!!!(WriteTickets)。方案号: " + SchemeID.ToString() + " 的购买金额与实际票的金额不符合!!!!");
                    continue;
                }

                string TicketXML = "<Tickets>";
                foreach (SLS.Lottery.Ticket ticket in tics)
                {
                    TicketXML += "<Ticket LotteryNumber=\"" + ticket.Number + "\" Multiple=\"" + ticket.Multiple + "\" Money=\"" + ticket.Money + "\" />";
                }
                TicketXML += "</Tickets>";

                int    ReturnValue       = 0;
                string ReturnDescription = "";
                int    Result            = SLS.Dal.Procedures.P_SchemesSendToCenterAdd(ConnectionString, SchemeID, PlayTypeID, TicketXML, ref ReturnValue, ref ReturnDescription);
                if ((Result < 0) || (ReturnValue < 0))
                {
                    log.Write("票写入错误(WriteTickets):方案号:" + SchemeID.ToString() + "," + ReturnDescription);
                }
            }
        }
Example #18
0
        private void WinScoreScale()
        {
            DataTable dt = MSSQL.Select(ConnectionString, "select id, PlayTypeID, WinMoney, LotteryNumber, IsuseID, Multiple from T_Schemes where not exists (select 1 from T_SchemeIsCalcuteScore where ScoreType = 2 and T_Schemes.ID = T_SchemeIsCalcuteScore.SchemeID) and ID > isnull((select max(SchemeID) - 10000 from T_SchemeIsCalcuteScore where ScoreType = 2), 0) and exists (select 1 from T_Isuses where LotteryID in (6, 28, 29, 60, 61, 62, 63, 64, 68, 70) and T_Isuses.ID = T_Schemes.IsuseID) and isOpened = 1 order by IsuseID desc");

            if (dt == null)
            {
                log.Write("Exec WinScoreScale: DataTable \"WinScoreScale\" Fail.");

                return;
            }

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

            DAL.Tables.T_SchemeIsCalcuteScore t_SchemeIsCalcuteScore = new DAL.Tables.T_SchemeIsCalcuteScore();

            DataTable dtIsuses   = null;
            DataTable dtWinMoney = null;

            foreach (DataRow dr in dt.Rows)
            {
                if (Shove._Convert.StrToDouble(dr["WinMoney"].ToString(), 0) == 0)
                {
                    t_SchemeIsCalcuteScore.SchemeID.Value  = dr["ID"].ToString();
                    t_SchemeIsCalcuteScore.ScoreType.Value = 2;
                    t_SchemeIsCalcuteScore.Insert(ConnectionString);

                    continue;
                }

                dtIsuses = new DAL.Tables.T_Isuses().Open(ConnectionString, "WinLotteryNumber, LotteryID", "ID=" + dr["IsuseID"].ToString(), "");

                if (dtIsuses == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"T_Isuses\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

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

                dtWinMoney = MSSQL.Select(ConnectionString, "select DefaultMoney * a.ScoreScale as DefaultMoney, DefaultMoneyNoWithTax * a.ScoreScale as DefaultMoneyNoWithTax, a.WinMoney as WinMoney from T_WinTypes inner join T_WinScoreScale a on T_WinTypes.ID = a.WinTypeID where exists (select * from T_PlayTypes where ID = " + dr["PlayTypeID"].ToString() + " and T_WinTypes.LotteryID = T_PlayTypes.LotteryID)  order by [Order]");

                if (dtWinMoney == null)
                {
                    log.Write("Exec WinScoreScale: DataTable \"dtWinMoney\" Fail.期号为:" + dr["IsuseID"].ToString());

                    continue;
                }

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

                double[] WinMoneyList = new double[dtWinMoney.Rows.Count * 2];

                double MaxMoney = 0;

                for (int i = 0; i < dtWinMoney.Rows.Count; i++)
                {
                    WinMoneyList[i * 2]     = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoney"].ToString(), 0);
                    WinMoneyList[i * 2 + 1] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                    if (Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0) > MaxMoney)
                    {
                        MaxMoney = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0);
                    }
                }

                string LotteryNumber = dr["LotteryNumber"].ToString();
                string Description   = "";

                double WinMoneyNoWithTax = 0;
                double WinMoney          = 0;

                try
                {
                    WinMoney = new SLS.Lottery()[int.Parse(dtIsuses.Rows[0]["LotteryID"].ToString())].ComputeWin(LotteryNumber, dtIsuses.Rows[0]["WinLotteryNumber"].ToString(), ref Description, ref WinMoneyNoWithTax, int.Parse(dr["PlayTypeID"].ToString()), WinMoneyList);
                }
                catch
                {
                    WinMoney = 0;
                }

                log.Write("方案号:" + dr["ID"].ToString() + "-------中奖金额:" + (Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney).ToString() + "-----------最大金额:" + MaxMoney.ToString());

                if (DAL.Procedures.P_SchemeWinCalculatedScore(ConnectionString, Shove._Convert.StrToLong(dr["ID"].ToString(), 0), Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney, MaxMoney) < 0)
                {
                    log.Write("Exec WinScoreScale: Procedures \"P_SchemeWinCalculatedScore\" Fail.");

                    continue;
                }
            }

            #endregion
        }
Example #19
0
        private void ExecForOpen_StepOne(string winXml,int lotteryId,string issueNo,string winNumber,double[] winMoneyList,out long _issueId)
        { 
            //根据彩种ID和期号查询当期的自增ID
            var dtIssue = new SLS.Dal.Tables.T_Isuses().Open(ConnectString
                                                                , "*"
                                                                , string.Format(" LotteryID={0} AND Name='{1}' ",lotteryId,issueNo)
                                                                , "");
            if (dtIssue == null)
                throw new SLS.Common.ElectronicException("数据库读写错误");
            if (dtIssue.Rows.Count == 0)
                throw new SLS.Common.ElectronicException(string.Format("未查询到当前期次,彩种:{0},期次号:{1}",lotteryId,issueNo));

            var issueId = dtIssue.Rows[0]["ID"].ToString();
            _issueId = long.Parse(issueId);
            var dtIsuseBonuses = new SLS.Dal.Tables.T_IsuseBonuses().Open(ConnectString
                                     , ""
                                     , "IsuseID = " + issueId
                                     , "");

            if (dtIsuseBonuses == null)
                throw new SLS.Common.ElectronicException("数据库读写错误");

            if (dtIsuseBonuses.Rows.Count < 1)
            {
                int ReturnValue = -1;
                string ReturnDescription = "";


                int Result = SLS.Dal.Procedures.P_IsuseBonusesAdd(ConnectString
                                , Shove._Convert.StrToLong(issueId, 0)
                                , 1 //todo : 是否需要修改为自动开奖特殊用户ID
                                , winXml
                                , ref ReturnValue
                                , ref ReturnDescription);

                if (Result < 0)
                    throw new SLS.Common.ElectronicException("数据库读写错误");

                if (ReturnValue < 0)
                    throw new SLS.Common.ElectronicException(ReturnDescription);
            }
            //取出需要开奖的投注记录
            var dt = new SLS.Dal.Tables.T_Schemes().Open(ConnectString
                        , "* "
                        , "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(issueId) + " and isOpened = 0 and Buyed = 1"
                        , "[ID]");

            if (dt == null)
                throw new SLS.Common.ElectronicException("数据库读写错误");

            StringBuilder sb = new StringBuilder();
            string NoWinSchemeID = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string LotteryNumber = dt.Rows[i]["LotteryNumber"].ToString();
                string Description = "";
                double WinMoneyNoWithTax = 0;
                double WinMoney = 0;

                try
                {
                    WinMoney = new SLS.Lottery()[lotteryId].ComputeWin(LotteryNumber
                                                                , winNumber
                                                                , ref Description
                                                                , ref WinMoneyNoWithTax
                                                                , int.Parse(dt.Rows[i]["PlayTypeID"].ToString())
                                                                , winMoneyList);
                }
                catch
                {
                    WinMoney = 0;
                    base.WriteLog("方案 ID:" + dt.Rows[i]["ID"].ToString() + " 算奖出现错误!");                    
                }

                if (WinMoney == 0)
                {
                    NoWinSchemeID += dt.Rows[i]["ID"].ToString()  + ",";

                    continue;
                }

                sb.Append("update T_Schemes set EditWinMoney = ").Append(WinMoney * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1))
                    .Append(", EditWinMoneyNoWithTax = ").Append(WinMoneyNoWithTax * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1))
                    .Append(", WinDescription = '").Append(Description).Append("'")
                    .Append(" where [ID] = ").AppendLine(dt.Rows[i]["ID"].ToString());
            }

            if(!string.IsNullOrEmpty(sb.ToString()))
                Shove.Database.MSSQL.ExecuteNonQuery(ConnectString,sb.ToString(), new Shove.Database.MSSQL.Parameter[0]);

            if (NoWinSchemeID.EndsWith(","))
            {
                NoWinSchemeID = NoWinSchemeID.Substring(0, NoWinSchemeID.Length - 1);
            }

            if (!string.IsNullOrEmpty(NoWinSchemeID))
            {
                StringBuilder sb1 = new StringBuilder();

                sb1.Append("update T_Schemes set EditWinMoney = 0")
                    .Append(", EditWinMoneyNoWithTax = 0, isOpened = 1 , OpenOperatorID=" + 1)  //todo : 是否替换userid
                    .Append(", WinDescription = ''")
                    .Append(" where [ID] in (" + NoWinSchemeID + ")");

                Shove.Database.MSSQL.ExecuteNonQuery(ConnectString,sb1.ToString(), new Shove.Database.MSSQL.Parameter[0]);
            }

            if (dt.Rows.Count == 0)
                return;
            //执行第三步,派奖逻辑
            ExecForOpen_StepThree(issueNo, lotteryId, winNumber, winMoneyList,_issueId);
        }
 public string SplitScheme(string LotteryNumber, int PlayTypeID)
 {
     SLS.Lottery lottery = new SLS.Lottery();
     string canonicalNumber = "";
     string[] strArray = lottery[0x3e].ToSingle(LotteryNumber, ref canonicalNumber, PlayTypeID);
     if ((strArray == null) || (strArray.Length < 1))
     {
         return "";
     }
     LotteryNumber = "";
     foreach (string str2 in strArray)
     {
         LotteryNumber = LotteryNumber + str2.Replace(" ", "|") + ",";
     }
     int length = strArray.Length;
     return (LotteryNumber + length.ToString());
 }
Example #21
0
        /// <summary>
        /// 开奖第二步,处理代理商电子票逻辑
        /// </summary>
        /// <param name="issueNo"></param>
        /// <param name="lotoId"></param>
        /// <param name="winNumber"></param>
        /// <param name="winMoneyList"></param>
        private void ExecForOpen_StepTwo(string issueNo,int lotoId,string winNumber,double[] winMoneyList)
        {
            var dt = new SLS.Dal.Tables.T_ElectronTicketAgentSchemes().Open(ConnectString
                        , "*"
                        , "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(issueNo) + " and WinMoney is null and state = 1"
                        , "[ID]");
            if(dt == null)
                throw new SLS.Common.ElectronicException("数据库读写错误");

            var t_ElectronTicketAgentSchemes = new SLS.Dal.Tables.T_ElectronTicketAgentSchemes();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string LotteryNumber = dt.Rows[i]["LotteryNumber"].ToString();
                string Description = "";
                double WinMoneyNoWithTax = 0;

                double WinMoney = new SLS.Lottery()[lotoId].ComputeWin(LotteryNumber, winNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dt.Rows[i]["PlayTypeID"].ToString()), winMoneyList);

                t_ElectronTicketAgentSchemes.WinMoney.Value = WinMoney * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1);
                t_ElectronTicketAgentSchemes.WinMoneyWithoutTax.Value = WinMoneyNoWithTax * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1);
                t_ElectronTicketAgentSchemes.WinDescription.Value = Description;

                t_ElectronTicketAgentSchemes.Update(ConnectString,"[ID] =" + dt.Rows[i]["ID"].ToString());
            }
        }
Example #22
0
    //获取开奖号码
    public static DataTable GetDataTable(DataTable dt, int Type2)
    {
        DataColumn newDC0 = new DataColumn("Order", System.Type.GetType("System.String"));
        DataColumn newDC1 = new DataColumn("LotteryID", System.Type.GetType("System.String"));
        DataColumn newDC2 = new DataColumn("LotteryName", System.Type.GetType("System.String"));
        DataColumn newDC3 = new DataColumn("IsuseName", System.Type.GetType("System.String"));
        DataColumn newDC4 = new DataColumn("WinLotteryNumber", System.Type.GetType("System.String"));
        DataColumn newDC5 = new DataColumn("LotteryTypeID", System.Type.GetType("System.String"));
        DataColumn newDC6 = new DataColumn("LotteryType2", System.Type.GetType("System.String"));
        DataColumn newDC7 = new DataColumn("LotteryType2Name", System.Type.GetType("System.String"));

        DataTable dtType2 = new DataTable();
        dtType2.Columns.Add(newDC0);
        dtType2.Columns.Add(newDC1);
        dtType2.Columns.Add(newDC2);
        dtType2.Columns.Add(newDC3);
        dtType2.Columns.Add(newDC4);
        dtType2.Columns.Add(newDC5);
        dtType2.Columns.Add(newDC6);
        dtType2.Columns.Add(newDC7);

        DataRow[] Rows;

        if (Type2 == 3)
        {
            Rows = dt.Select("LotteryType2 = " + Type2 + "and LotteryID <> " + SLS.Lottery.ZCDC.ID.ToString(), "EndTime desc");
        }
        else
        {
            Rows = dt.Select("LotteryType2 = " + Type2, "EndTime desc");
        }

        foreach (DataRow dr in Rows)
        {
            DataRow dr1 = dtType2.NewRow();
            dr1[0] = dr[0].ToString();
            dr1[1] = dr[1].ToString();
            dr1[2] = dr[2].ToString();
            dr1[3] = dr[3].ToString();
            dr1[4] = new SLS.Lottery()[int.Parse(dr[1].ToString())].ShowNumber(dr[4].ToString());
            dr1[5] = dr[5].ToString();
            dr1[6] = dr[6].ToString();
            dr1[7] = dr[7].ToString();

            dtType2.Rows.Add(dr1);
        }

        return dtType2;
    }
Example #23
0
        private void ExecForOpen_StepOne(string winXml, int lotteryId, string issueNo, string winNumber, double[] winMoneyList, out long _issueId)
        {
            //根据彩种ID和期号查询当期的自增ID
            var dtIssue = new SLS.Dal.Tables.T_Isuses().Open(ConnectString
                                                             , "*"
                                                             , string.Format(" LotteryID={0} AND Name='{1}' ", lotteryId, issueNo)
                                                             , "");

            if (dtIssue == null)
            {
                throw new SLS.Common.ElectronicException("数据库读写错误");
            }
            if (dtIssue.Rows.Count == 0)
            {
                throw new SLS.Common.ElectronicException(string.Format("未查询到当前期次,彩种:{0},期次号:{1}", lotteryId, issueNo));
            }

            var issueId = dtIssue.Rows[0]["ID"].ToString();

            _issueId = long.Parse(issueId);
            var dtIsuseBonuses = new SLS.Dal.Tables.T_IsuseBonuses().Open(ConnectString
                                                                          , ""
                                                                          , "IsuseID = " + issueId
                                                                          , "");

            if (dtIsuseBonuses == null)
            {
                throw new SLS.Common.ElectronicException("数据库读写错误");
            }

            if (dtIsuseBonuses.Rows.Count < 1)
            {
                int    ReturnValue       = -1;
                string ReturnDescription = "";


                int Result = SLS.Dal.Procedures.P_IsuseBonusesAdd(ConnectString
                                                                  , Shove._Convert.StrToLong(issueId, 0)
                                                                  , 1 //todo : 是否需要修改为自动开奖特殊用户ID
                                                                  , winXml
                                                                  , ref ReturnValue
                                                                  , ref ReturnDescription);

                if (Result < 0)
                {
                    throw new SLS.Common.ElectronicException("数据库读写错误");
                }

                if (ReturnValue < 0)
                {
                    throw new SLS.Common.ElectronicException(ReturnDescription);
                }
            }
            //取出需要开奖的投注记录
            var dt = new SLS.Dal.Tables.T_Schemes().Open(ConnectString
                                                         , "* "
                                                         , "IsuseID = " + Shove._Web.Utility.FilteSqlInfusion(issueId) + " and isOpened = 0 and Buyed = 1"
                                                         , "[ID]");

            if (dt == null)
            {
                throw new SLS.Common.ElectronicException("数据库读写错误");
            }

            StringBuilder sb            = new StringBuilder();
            string        NoWinSchemeID = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string LotteryNumber     = dt.Rows[i]["LotteryNumber"].ToString();
                string Description       = "";
                double WinMoneyNoWithTax = 0;
                double WinMoney          = 0;

                try
                {
                    WinMoney = new SLS.Lottery()[lotteryId].ComputeWin(LotteryNumber
                                                                       , winNumber
                                                                       , ref Description
                                                                       , ref WinMoneyNoWithTax
                                                                       , int.Parse(dt.Rows[i]["PlayTypeID"].ToString())
                                                                       , winMoneyList);
                }
                catch
                {
                    WinMoney = 0;
                    base.WriteLog("方案 ID:" + dt.Rows[i]["ID"].ToString() + " 算奖出现错误!");
                }

                if (WinMoney == 0)
                {
                    NoWinSchemeID += dt.Rows[i]["ID"].ToString() + ",";

                    continue;
                }

                sb.Append("update T_Schemes set EditWinMoney = ").Append(WinMoney * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1))
                .Append(", EditWinMoneyNoWithTax = ").Append(WinMoneyNoWithTax * Shove._Convert.StrToInt(dt.Rows[i]["Multiple"].ToString(), 1))
                .Append(", WinDescription = '").Append(Description).Append("'")
                .Append(" where [ID] = ").AppendLine(dt.Rows[i]["ID"].ToString());
            }

            if (!string.IsNullOrEmpty(sb.ToString()))
            {
                Shove.Database.MSSQL.ExecuteNonQuery(ConnectString, sb.ToString(), new Shove.Database.MSSQL.Parameter[0]);
            }

            if (NoWinSchemeID.EndsWith(","))
            {
                NoWinSchemeID = NoWinSchemeID.Substring(0, NoWinSchemeID.Length - 1);
            }

            if (!string.IsNullOrEmpty(NoWinSchemeID))
            {
                StringBuilder sb1 = new StringBuilder();

                sb1.Append("update T_Schemes set EditWinMoney = 0")
                .Append(", EditWinMoneyNoWithTax = 0, isOpened = 1 , OpenOperatorID=" + 1)      //todo : 是否替换userid
                .Append(", WinDescription = ''")
                .Append(" where [ID] in (" + NoWinSchemeID + ")");

                Shove.Database.MSSQL.ExecuteNonQuery(ConnectString, sb1.ToString(), new Shove.Database.MSSQL.Parameter[0]);
            }

            if (dt.Rows.Count == 0)
            {
                return;
            }
            //执行第三步,派奖逻辑
            ExecForOpen_StepThree(issueNo, lotteryId, winNumber, winMoneyList, _issueId);
        }
Example #24
0
        private string GetLotteryNumber(int LotteryID, int PlayTypeID, string BettingNumber, ref int Num)   // Num 返回注数
        {
            Num = 0;

            if (String.IsNullOrEmpty(BettingNumber))
            {
                return "";
            }

            BettingNumber = BettingNumber.Replace("|", "\n");
            BettingNumber = ConvertLotteryNumber(LotteryID, BettingNumber);

            SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

            if (lb == null)
            {
                return "";
            }

            string t_Number = lb.AnalyseScheme(BettingNumber, PlayTypeID);

            if (String.IsNullOrEmpty(t_Number))
            {
                return "";
            }

            string[] t_Numbers = t_Number.Split('\n');

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

            string Result = "";

            foreach (string str in t_Numbers)
            {
                string t_str = str.Trim();

                if (String.IsNullOrEmpty(t_str))
                {
                    continue;
                }

                string[] t_strs = t_str.Split('|');

                if ((t_strs == null) || (t_strs.Length != 2))
                {
                    continue;
                }

                int t_Num = Shove._Convert.StrToInt(t_strs[1], -1);

                if (String.IsNullOrEmpty(t_strs[0]) || (t_Num < 1))
                {
                    continue;
                }

                Result += t_strs[0] + "\n";
                Num += t_Num;
            }

            if (Result.EndsWith("\n"))
            {
                Result = Result.Substring(0, Result.Length - 1);
            }

            return Result;
        }
Example #25
0
        //开奖派奖
        private void DrawingLottery(int LotteryID, string IsuseName, string WinNumber)
        {
            Log log = new Log("SystemGetLotteryOpenNumber");

            if (!new SLS.Lottery()[LotteryID].AnalyseWinNumber(WinNumber))
            {
                log.Write("开奖号码不正确!");

                return;
            }

            int    ReturnValue       = 0;
            string ReturnDescription = "";

            DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(conn, "top 1 [ID], IsOpened", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "' and IsOpened=0 and year(StartTime) = YEAR(GETDATE())", "");

            if (dtIsuse == null)
            {
                log.Write("数据读写错误001");

                return;
            }

            if (dtIsuse.Rows.Count <= 0)
            {
                //log.Write("暂无对应期号信息,彩种ID:" + LotteryID.ToString() + ", 期号:" + IsuseName);

                return;
            }

            if (Shove._Convert.StrToBool(dtIsuse.Rows[0]["IsOpened"].ToString(), false))
            {
                //log.Write("彩种ID:" + LotteryID + "第" + IsuseName + "期已开奖");

                return;
            }

            long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1);

            DataTable dtWin = null;

            dtWin = new DAL.Tables.T_Schemes().Open(conn, "ID", "IsuseID = " + IsuseID.ToString() + " and isOpened = 0", "");

            if (dtWin == null)
            {
                log.Write("数据读写错误002");

                return;
            }

            // 准备开奖,开奖之前,对出票不完整的方案进行出票处理
            ReturnValue       = 0;
            ReturnDescription = "";

            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(conn, "[DefaultMoney],[DefaultMoneyNoWithTax]", "LotteryID = " + LotteryID.ToString(), "[Order]");

            if (dtWinTypes == null)
            {
                log.Write("奖金读取数据读写错误");

                return;
            }

            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            for (int y = 0; y < dtWinTypes.Rows.Count; y++)
            {
                WinMoneyList[y * 2]     = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoney"].ToString(), 0);
                WinMoneyList[y * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoneyNoWithTax"].ToString(), 0);

                if (WinMoneyList[y * 2] < 0)
                {
                    log.Write("第 " + (y + 1).ToString() + " 项奖金输入错误!");

                    return;
                }
            }

            dtWin = null;

            #region 开奖第一步

            dtWin = new DAL.Tables.T_Schemes().Open(conn, "LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + IsuseID.ToString(), "[ID]");

            if (dtWin == null)
            {
                log.Write("方案数据读取错误");

                return;
            }

            for (int y = 0; y < dtWin.Rows.Count; y++)
            {
                string LotteryNumber = "";

                try
                {
                    LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString();
                }
                catch
                { }

                string Description       = "";
                double WinMoneyNoWithTax = 0;

                try
                {
                    double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList);

                    if (WinMoney > 0)
                    {
                        log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 中奖金额:" + WinMoney.ToString());
                    }

                    Shove.Database.MSSQL.ExecuteNonQuery(conn, "update T_Schemes set EditWinMoney = @p1, EditWinMoneyNoWithTax = @p2, WinDescription = @p3 where [ID] = " + dtWin.Rows[y]["ID"].ToString(),
                                                         new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)),
                                                         new Shove.Database.MSSQL.Parameter("p3", SqlDbType.VarChar, 0, ParameterDirection.Input, Description));
                }
                catch
                {
                    log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 开奖号码出现错误");

                    continue;
                }
            }

            #endregion

            log.Write("开奖-----------------------------4");

            #region 开奖第三步

            string OpenAffiche = new OpenAfficheTemplates()[LotteryID];

            int  SchemeCount, QuashCount, WinCount, WinNoBuyCount;
            bool isEndOpen = false;

            while (!isEndOpen)
            {
                SchemeCount   = 0;
                QuashCount    = 0;
                WinCount      = 0;
                WinNoBuyCount = 0;
                //  总方案数,处理时撤单数,中奖数,中奖但未成功数

                ReturnValue       = 0;
                ReturnDescription = "";
                DataSet dsWin = null;

                P_Win(conn, ref dsWin,
                      IsuseID,
                      WinNumber,
                      OpenAffiche,
                      1,
                      true,
                      ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount,
                      ref isEndOpen,
                      ref ReturnValue, ref ReturnDescription);

                if ((dsWin == null) || (ReturnDescription != ""))
                {
                    log.Write(ReturnDescription);

                    return;
                }

                string Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖还未全部完成, 请继续操作第三步。";

                if (isEndOpen)
                {
                    Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖已全部完成。";
                }

                log.Write(String.Format(Message, LotteryID, WinNumber, SchemeCount, QuashCount, WinCount, WinNoBuyCount));
            }

            #endregion

            log.Write("开奖-----------------------------5");
        }
        private void Buy(Users _User)
        {
            string request = Shove._Web.Utility.GetRequest("HidIsuseID");
            string str2    = Shove._Web.Utility.GetRequest("HidIsuseEndTime");
            string s       = Shove._Web.Utility.GetRequest("tbPlayTypeID");
            string str4    = Shove._Web.Utility.GetRequest("Chase");

            Shove._Web.Utility.GetRequest("CoBuy");
            string str5 = Shove._Web.Utility.GetRequest("tb_Share");
            string str6 = Shove._Web.Utility.GetRequest("tb_BuyShare");

            Shove._Web.Utility.GetRequest("tb_AssureShare");
            string str7  = Shove._Web.Utility.GetRequest("tb_OpenUserList");
            string str8  = Shove._Web.Utility.GetRequest("tb_Title");
            string str9  = Shove._Web.Utility.GetRequest("tb_Description");
            string str10 = Shove._Web.Utility.GetRequest("tbAutoStopAtWinMoney");
            string str11 = Shove._Web.Utility.GetRequest("SecrecyLevel");
            string str12 = Shove._Web.Utility.FilteSqlInfusion(base.Request["tb_LotteryNumber"]);
            string str13 = Shove._Web.Utility.GetRequest("tb_hide_SumMoney");
            string str14 = Shove._Web.Utility.GetRequest("tb_hide_AssureMoney");
            string str15 = Shove._Web.Utility.GetRequest("tb_hide_SumNum");

            Shove._Web.Utility.GetRequest("HidIsuseCount");
            string str16 = Shove._Web.Utility.GetRequest("HidLotteryID");

            Shove._Web.Utility.GetRequest("HidIsAlipay");
            string str17 = Shove._Web.Utility.GetRequest("tb_Multiple");

            Shove._Web.Utility.GetRequest("HidIsuseName");
            Shove._Web.Utility.GetRequest("tbPlayTypeName");
            string str18 = Shove._Web.Utility.GetRequest("tb_hide_ChaseBuyedMoney");
            string str19 = Shove._Web.Utility.GetRequest("tb_SchemeBonusScale");
            string str20 = Shove._Web.Utility.GetRequest("tb_SchemeBonusScalec");
            int    num   = 2;

            if (str17 == "")
            {
                str17 = "1";
            }
            double money             = 0.0;
            int    share             = 0;
            int    buyShare          = 0;
            double assureMoney       = 0.0;
            int    multiple          = 0;
            int    num7              = 0;
            short  num8              = 0;
            int    playType          = 0;
            int    lotteryID         = 0;
            long   isuseID           = 0L;
            double stopWhenWinMoney  = 0.0;
            double schemeBonusScale  = 0.0;
            double schemeBonusScalec = 0.0;

            try
            {
                money             = double.Parse(str13);
                share             = int.Parse(str5);
                buyShare          = int.Parse(str6);
                assureMoney       = double.Parse(str14);
                multiple          = int.Parse(str17);
                num7              = int.Parse(str15);
                num8              = short.Parse(str11);
                playType          = int.Parse(s);
                lotteryID         = int.Parse(str16);
                isuseID           = long.Parse(request);
                stopWhenWinMoney  = double.Parse(str10);
                schemeBonusScale  = double.Parse(str19);
                schemeBonusScalec = double.Parse(str20);
            }
            catch
            {
                JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                return;
            }
            if ((money > 0.0) && (num7 >= 1))
            {
                if (assureMoney < 0.0)
                {
                    JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                }
                else if (share < 1)
                {
                    JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                }
                else
                {
                    if ((buyShare == share) && (assureMoney == 0.0))
                    {
                        share    = 1;
                        buyShare = 1;
                    }
                    if ((money / ((double)share)) < 1.0)
                    {
                        JavaScript.Alert(this.Page, "每份金额最低不能少于 1 元。");
                    }
                    else
                    {
                        double num15 = (buyShare * (money / ((double)share))) + assureMoney;
                        if (str4 != "")
                        {
                            num15 = double.Parse(str18);
                        }
                        if (num15 > _User.Balance)
                        {
                            this.SaveDataForAliBuy();
                        }
                        else if (num15 > 10000000.0)
                        {
                            JavaScript.Alert(this.Page, "投注金额不能大于" + 0x989680.ToString() + ",谢谢。");
                        }
                        else if (multiple > 0x3e7)
                        {
                            JavaScript.Alert(this.Page, "投注倍数不能大于 999 倍,谢谢。");
                        }
                        else if ((schemeBonusScale < 0.0) && (schemeBonusScale > 10.0))
                        {
                            JavaScript.Alert(this.Page, "佣金比例只能在0~10之间");
                        }
                        else if ((schemeBonusScale.ToString().IndexOf("-") > -1) || (schemeBonusScale.ToString().IndexOf(".") > -1))
                        {
                            JavaScript.Alert(this.Page, "佣金比例输入有误");
                        }
                        else if ((schemeBonusScalec < 0.0) && (schemeBonusScalec > 10.0))
                        {
                            JavaScript.Alert(this.Page, "佣金比例只能在0~10之间");
                        }
                        else if ((schemeBonusScalec.ToString().IndexOf("-") > -1) || (schemeBonusScalec.ToString().IndexOf(".") > -1))
                        {
                            JavaScript.Alert(this.Page, "佣金比例输入有误");
                        }
                        else
                        {
                            schemeBonusScale  /= 100.0;
                            schemeBonusScalec /= 100.0;
                            string number = str12;
                            if (number[number.Length - 1] == '\n')
                            {
                                number = number.Substring(0, number.Length - 1);
                            }
                            SLS.Lottery lottery  = new SLS.Lottery();
                            string[]    strArray = this.SplitLotteryNumber(number);
                            if ((strArray == null) || (strArray.Length < 1))
                            {
                                JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。(-694)");
                            }
                            else
                            {
                                int num17 = 0;
                                foreach (string str22 in strArray)
                                {
                                    string str23 = lottery[lotteryID].AnalyseScheme(str22, playType);
                                    if (!string.IsNullOrEmpty(str23))
                                    {
                                        string[] strArray3 = str23.Split(new char[] { '|' });
                                        if ((strArray3 != null) && (strArray3.Length >= 1))
                                        {
                                            num17 += _Convert.StrToInt(strArray3[strArray3.Length - 1], 0);
                                        }
                                    }
                                }
                                if (num17 != num7)
                                {
                                    JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。");
                                }
                                else
                                {
                                    StringBuilder builder           = new StringBuilder();
                                    int           num19             = 0;
                                    string        detailXML         = "";
                                    string        returnDescription = "";
                                    if (str4 == "1")
                                    {
                                        foreach (string str26 in base.Request.Form.AllKeys)
                                        {
                                            if (str26.IndexOf("check") > -1)
                                            {
                                                int num20 = _Convert.StrToInt(str26.Replace("check", ""), -1);
                                                if (num20 > 0)
                                                {
                                                    num19++;
                                                    int num21 = (_Convert.StrToInt(base.Request.Form["tb_hide_SumNum"], -1) * num) * _Convert.StrToInt(base.Request.Form["times" + num20.ToString()], -1);
                                                    builder.Append(base.Request.Form[str26]).Append(",").Append(base.Request.Form["times" + num20.ToString()]).Append(",").Append(num21.ToString()).Append(";");
                                                }
                                            }
                                        }
                                        if (builder.Length > 0)
                                        {
                                            builder.Remove(builder.Length - 1, 1);
                                        }
                                        if (number[number.Length - 1] == '\n')
                                        {
                                            number = number.Substring(0, number.Length - 1);
                                        }
                                        try
                                        {
                                            money = double.Parse(str13);
                                        }
                                        catch
                                        {
                                            JavaScript.Alert(this.Page, "输入有错误,请仔细检查。(-1325)");
                                            return;
                                        }
                                        if (money < 2.0)
                                        {
                                            JavaScript.Alert(this.Page, "输入有错误,请仔细检查。(-1332)");
                                        }
                                        else
                                        {
                                            string[] strArray5 = builder.ToString().Split(new char[] { ';' });
                                            int      length    = strArray5.Length;
                                            string[] str       = new string[length * 6];
                                            DateTime time2     = DateTime.Parse(Functions.F_GetIsuseSystemEndTime(long.Parse(strArray5[0].Split(new char[] { ',' })[0]), playType).ToString());
                                            if (DateTime.Now >= time2)
                                            {
                                                JavaScript.Alert(this.Page, "您选择的追号期号中包含已截止的期,请重新选择。");
                                            }
                                            else
                                            {
                                                for (int i = 0; i < length; i++)
                                                {
                                                    str[i * 6]       = strArray5[i].Split(new char[] { ',' })[0];
                                                    str[(i * 6) + 1] = playType.ToString();
                                                    str[(i * 6) + 2] = number;
                                                    str[(i * 6) + 3] = strArray5[i].Split(new char[] { ',' })[1];
                                                    str[(i * 6) + 4] = strArray5[i].Split(new char[] { ',' })[2];
                                                    str[(i * 6) + 5] = num8.ToString();
                                                    if ((_Convert.StrToDouble(str[(i * 6) + 3], 0.0) * money) != _Convert.StrToDouble(str[(i * 6) + 4], 1.0))
                                                    {
                                                        JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                                                        return;
                                                    }
                                                    if (_Convert.StrToDouble(str[(i * 6) + 3], 0.0) < multiple)
                                                    {
                                                        JavaScript.Alert(this.Page, "追号倍数有错误,请仔细检查!");
                                                        return;
                                                    }
                                                    if (((double.Parse(str[(i * 6) + 3]) * num7) * num) != double.Parse(str[(i * 6) + 4]))
                                                    {
                                                        JavaScript.Alert(this.Page, "追号金额有错误,请仔细检查!可能原因:浏览器不兼容,建议使用IE 7.0");
                                                        return;
                                                    }
                                                }
                                                detailXML = PF.BuildIsuseAdditionasXmlForChase(str);
                                                if (detailXML == "")
                                                {
                                                    JavaScript.Alert(this.Page, "追号发生错误。");
                                                }
                                                else if (_User.InitiateChaseTask(str8.Trim(), str9.Trim(), lotteryID, stopWhenWinMoney, detailXML, number, schemeBonusScalec, ref returnDescription) < 0)
                                                {
                                                    PF.GoError(1, returnDescription, base.GetType().FullName + "(-754)");
                                                }
                                                else
                                                {
                                                    Shove._Web.Cache.ClearCache("Home_Room_CoBuy_BindDataForType" + isuseID.ToString());
                                                    Shove._Web.Cache.ClearCache("Home_Room_SchemeAll_BindData" + isuseID.ToString());
                                                    Shove._Web.Cache.ClearCache(base._Site.ID.ToString() + "AccountFreezeDetail_" + _User.ID.ToString());
                                                    base.Response.Redirect("../Home/Room/UserBuySuccess.aspx?LotteryID=" + lotteryID.ToString() + "&Type=2&Money=" + num15.ToString());
                                                }
                                            }
                                        }
                                    }
                                    else if (DateTime.Now >= _Convert.StrToDateTime(str2.Replace("/", "-"), DateTime.Now.AddDays(-1.0).ToString()))
                                    {
                                        JavaScript.Alert(this.Page, "本期投注已截止,谢谢。");
                                    }
                                    else if (((num * num7) * multiple) != money)
                                    {
                                        JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                                    }
                                    else
                                    {
                                        long num25 = _User.InitiateScheme(isuseID, playType, (str8.Trim() == "") ? "(无标题)" : str8.Trim(), str9.Trim(), number, "", multiple, money, assureMoney, share, buyShare, str7.Trim(), short.Parse(num8.ToString()), schemeBonusScale, ref returnDescription);
                                        if (num25 < 0L)
                                        {
                                            PF.GoError(1, returnDescription, base.GetType().FullName + "(-755)");
                                        }
                                        else
                                        {
                                            Shove._Web.Cache.ClearCache("Home_Room_CoBuy_BindDataForType" + isuseID.ToString());
                                            Shove._Web.Cache.ClearCache("Home_Room_SchemeAll_BindData" + isuseID.ToString());
                                            if ((money > 50.0) && (share > 1))
                                            {
                                                Shove._Web.Cache.ClearCache("Home_Room_JoinAllBuy_BindData");
                                            }
                                            base.Response.Redirect("../Home/Room/UserBuySuccess.aspx?LotteryID=" + lotteryID.ToString() + "&&Money=" + num15.ToString() + "&SchemeID=" + num25.ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
            }
        }
 private void BindDataForAliBuy(long BuyID)
 {
     DataTable table = new Tables.T_AlipayBuyTemp().Open("", "ID=" + BuyID.ToString(), "");
     if ((table != null) && (table.Rows.Count != 0))
     {
         DataRow row = table.Rows[0];
         string s = row["IsuseID"].ToString();
         string str2 = row["PlayTypeID"].ToString();
         bool flag = _Convert.StrToBool(row["IsChase"].ToString(), false);
         bool flag2 = _Convert.StrToBool(row["IsCoBuy"].ToString(), false);
         string str3 = row["Share"].ToString();
         string str4 = row["BuyShare"].ToString();
         string str5 = row["AssureShare"].ToString();
         string str6 = row["OpenUsers"].ToString();
         string str7 = row["Title"].ToString();
         string str8 = row["Description"].ToString();
         string str9 = row["StopwhenwinMoney"].ToString();
         string str10 = row["SecrecyLevel"].ToString();
         string str11 = row["LotteryNumber"].ToString();
         string str12 = row["SumMoney"].ToString();
         string str13 = row["AssureMoney"].ToString();
         string str14 = row["LotteryID"].ToString();
         string str15 = row["Multiple"].ToString();
         string xml = row["AdditionasXml"].ToString();
         if (str15 == "")
         {
             str15 = "1";
         }
         double num = 0.0;
         int num2 = 0;
         int num3 = 0;
         double num4 = 0.0;
         int num5 = 0;
         short num6 = 0;
         int playType = 0;
         int num8 = 0;
         try
         {
             num = double.Parse(str12);
             num2 = int.Parse(str3);
             num3 = int.Parse(str4);
             num4 = double.Parse(str13);
             num5 = int.Parse(str15);
             num6 = short.Parse(str10);
             playType = int.Parse(str2);
             num8 = int.Parse(str14);
             long.Parse(s);
             double.Parse(str9);
         }
         catch
         {
         }
         if ((num3 == num2) && (num4 == 0.0))
         {
             num2 = 1;
             num3 = 1;
         }
         double num1 = num / ((double)num2);
         if (flag)
         {
             double.Parse(str12);
         }
         string str17 = str11;
         if (str17[str17.Length - 1] == '\n')
         {
             str17 = str17.Substring(0, str17.Length - 1);
         }
         StringBuilder builder = new StringBuilder();
         builder.AppendLine("<script type='text/javascript' defer='defer'>");
         builder.AppendLine("function clickPlayClass(i,obj)").AppendLine("{").AppendLine("var tds = obj.offsetParent.rows[0].cells;").AppendLine("for(var a=0; a<tds.length-1; a++)").AppendLine("{").AppendLine("if(a%2==1)").AppendLine("{").AppendLine("tds[a].className = 'nsplay';").AppendLine("}").AppendLine("if($Id('playTypes' + String(a))!=null)").AppendLine("{").AppendLine("$Id('playTypes' + String(a)).style.display = 'none';").AppendLine("}").AppendLine("}").AppendLine("var pt = $Id('playTypes' + String(i));").AppendLine("pt.style.display = '';");
         builder.AppendLine("$Id('playTypes').style.display = ((i == 1 || i == 2 || i == 3) ? 'none':'');");
         builder.AppendLine("obj.className = 'msplay';").AppendLine("}");
         builder.Append("var playclass =").Append("$Id('playType").Append(playType.ToString()).AppendLine("').parentNode.id.substr(9,1);");
         builder.Append("clickPlayClass(playclass,").Append("$Id('tbPlayTypeMenu").Append(num8.ToString()).AppendLine("').rows[0].cells[playclass*2+1]);");
         builder.Append("$Id('playType").Append(playType.ToString()).AppendLine("').checked = true;");
         builder.AppendLine("clickPlayType('" + playType.ToString() + "');");
         builder.AppendLine("function BindDataForFromAli(){");
         if (flag)
         {
             XmlDocument document = new XmlDocument();
             document.LoadXml(xml);
             foreach (XmlNode node in document.ChildNodes[0].ChildNodes)
             {
                 builder.Append("$Id('times").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["Multiple"].Value).AppendLine("';");
                 builder.Append("$Id('money").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["Money"].Value).AppendLine("';");
                 builder.Append("$Id('share").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["Share"].Value).AppendLine("';");
                 builder.Append("$Id('buyedShare").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["BuyedShare"].Value).AppendLine("';");
                 builder.Append("$Id('assureShare").Append(node.Attributes["IsuseID"].Value).Append("').value = '").Append(node.Attributes["AssureShare"].Value).AppendLine("';");
                 builder.Append("$Id('check").Append(node.Attributes["IsuseID"].Value).AppendLine("').checked = true;");
                 builder.Append("$Id('times").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                 builder.Append("$Id('share").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                 builder.Append("$Id('buyedShare").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
                 builder.Append("$Id('assureShare").Append(node.Attributes["IsuseID"].Value).AppendLine("').disabled = '';");
             }
         }
         str17 = str17.Replace("\r", "");
         int num9 = 0;
         string canonicalNumber = "";
         foreach (string str19 in str17.Split(new char[] { '\n' }))
         {
             num9 += new SLS.Lottery()[num8].ToSingle(str19, ref canonicalNumber, playType).Length;
             builder.AppendLine("var option = document.createElement('option');");
             builder.AppendLine("$Id('list_LotteryNumber').options.add(option);");
             builder.Append("option.innerText = '").Append(str19).AppendLine("';");
             builder.Append("option.value = '").Append(str19).AppendLine("';");
         }
         if (flag)
         {
             builder.AppendLine("$Id('Chase').checked = true;");
             builder.AppendLine("oncbInitiateTypeClick($Id('Chase'));");
         }
         if (flag2)
         {
             builder.AppendLine("$Id('CoBuy').checked = true;");
             builder.AppendLine("oncbInitiateTypeClick($Id('CoBuy'));");
         }
         builder.Append("$Id('tb_LotteryNumber').value = '").Append(str11.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
         builder.Append("$Id('tb_Share').value = '").Append(str3).AppendLine("';");
         builder.Append("$Id('tb_BuyShare').value = '").Append(str4).AppendLine("';");
         builder.Append("$Id('tb_AssureShare').value = '").Append(str5).AppendLine("';");
         builder.Append("$Id('tb_OpenUserList').value = '").Append(str6).AppendLine("';");
         builder.Append("$Id('tb_Title').value = '").Append(str7).AppendLine("';");
         builder.Append("$Id('tb_Description').value = '").Append(str8.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
         builder.Append("$Id('tbAutoStopAtWinMoney').value = '").Append(str9).AppendLine("';");
         builder.Append("$Id('SecrecyLevel").Append(num6.ToString()).AppendLine("').checked = true;");
         builder.Append("$Id('tb_hide_SumMoney').value = '").Append(str12).AppendLine("';");
         builder.Append("$Id('tb_hide_AssureMoney').value = '").Append(num4.ToString("N0")).AppendLine("';");
         builder.Append("$Id('tb_Multiple').value = '").Append(num5.ToString()).AppendLine("';");
         builder.Append("$Id('lab_AssureMoney').innerText = '").Append(num4.ToString("N0")).AppendLine("';");
         builder.Append("$Id('lab_SumMoney').innerText = '").Append(num.ToString("N0")).AppendLine("';");
         builder.Append("$Id('LbSumMoney').innerText = '").Append(num.ToString("N0")).AppendLine("';");
         builder.Append("$Id('lab_Num').innerText = '").Append(num9.ToString()).AppendLine("';");
         builder.AppendLine("CalcResult();");
         builder.AppendLine("}");
         builder.AppendLine("</script>");
         this.script = builder.ToString();
     }
 }
Example #28
0
        private void Buy(Users _User)
        {
            string request = Shove._Web.Utility.GetRequest("HidIsuseID");
            string str2    = Shove._Web.Utility.GetRequest("HidIsuseEndTime");
            string str3    = Shove._Web.Utility.GetRequest("playType");

            Shove._Web.Utility.GetRequest("CoBuy");
            string s    = Shove._Web.Utility.GetRequest("tb_Share");
            string str5 = Shove._Web.Utility.GetRequest("tb_BuyShare");

            Shove._Web.Utility.GetRequest("tb_AssureShare");
            string str6  = Shove._Web.Utility.GetRequest("tb_OpenUserList");
            string str7  = Shove._Web.Utility.GetRequest("tb_Title");
            string str8  = Shove._Web.Utility.GetRequest("tb_Description");
            string str9  = Shove._Web.Utility.GetRequest("SecrecyLevel");
            string str10 = Shove._Web.Utility.FilteSqlInfusion(base.Request["tb_LotteryNumber"]);
            string str11 = Shove._Web.Utility.GetRequest("tb_hide_SumMoney");
            string str12 = Shove._Web.Utility.GetRequest("tb_hide_AssureMoney");
            string str13 = Shove._Web.Utility.GetRequest("tb_hide_SumNum");
            string str14 = Shove._Web.Utility.GetRequest("HidLotteryID");
            string str15 = Shove._Web.Utility.GetRequest("tb_Multiple");
            string str16 = Shove._Web.Utility.GetRequest("tb_SchemeBonusScale");
            string str17 = Shove._Web.Utility.GetRequest("tbPlayTypeID");
            string str18 = Shove._Web.Utility.GetRequest("tb_SchemeMoney");
            int    num   = 2;

            if (str15 == "")
            {
                str15 = "1";
            }
            double money            = 0.0;
            int    share            = 0;
            int    buyShare         = 0;
            double assureMoney      = 0.0;
            int    multiple         = 0;
            int    num7             = 0;
            short  num8             = 0;
            int    playType         = 0;
            int    num10            = 0;
            long   isuseID          = 0L;
            double schemeBonusScale = 0.0;

            try
            {
                money            = double.Parse(str11);
                share            = int.Parse(s);
                buyShare         = int.Parse(str5);
                assureMoney      = double.Parse(str12);
                multiple         = int.Parse(str15);
                num7             = int.Parse(str13);
                num8             = short.Parse(str9);
                playType         = int.Parse(str17);
                num10            = int.Parse(str14);
                isuseID          = long.Parse(request);
                schemeBonusScale = double.Parse(str16);
            }
            catch
            {
                JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                return;
            }
            if (str17 != str3)
            {
                money = double.Parse(str18);
            }
            if ((money > 0.0) && ((num7 >= 1) || !(str17 == str3)))
            {
                if (assureMoney < 0.0)
                {
                    JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                }
                else if (share < 1)
                {
                    JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                }
                else
                {
                    if ((buyShare == share) && (assureMoney == 0.0))
                    {
                        share    = 1;
                        buyShare = 1;
                    }
                    if ((money / ((double)share)) < 1.0)
                    {
                        JavaScript.Alert(this.Page, "每份金额最低不能少于 1 元。");
                    }
                    else
                    {
                        double num13 = (buyShare * (money / ((double)share))) + assureMoney;
                        if (num13 > _User.Balance)
                        {
                            this.SaveDataForAliBuy();
                        }
                        else if (num13 > 10000000.0)
                        {
                            JavaScript.Alert(this.Page, "投注金额不能大于" + 0x989680.ToString() + ",谢谢。");
                        }
                        else if (multiple > 0x3e7)
                        {
                            JavaScript.Alert(this.Page, "投注倍数不能大于 999 倍,谢谢。");
                        }
                        else if ((schemeBonusScale < 0.0) && (schemeBonusScale > 10.0))
                        {
                            JavaScript.Alert(this.Page, "佣金比例只能在0~10之间");
                        }
                        else if ((schemeBonusScale.ToString().IndexOf("-") > -1) || (schemeBonusScale.ToString().IndexOf(".") > -1))
                        {
                            JavaScript.Alert(this.Page, "佣金比例输入有误");
                        }
                        else
                        {
                            schemeBonusScale /= 100.0;
                            string number = str10;
                            if (str17 == str3)
                            {
                                if (number[number.Length - 1] == '\n')
                                {
                                    number = number.Substring(0, number.Length - 1);
                                }
                                SLS.Lottery lottery  = new SLS.Lottery();
                                string[]    strArray = this.SplitLotteryNumber(number);
                                if ((strArray == null) || (strArray.Length < 1))
                                {
                                    JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。(-694)");
                                    return;
                                }
                                int num15 = 0;
                                foreach (string str20 in strArray)
                                {
                                    string str21 = lottery[num10].AnalyseScheme(str20, playType);
                                    if (!string.IsNullOrEmpty(str21))
                                    {
                                        string[] strArray3 = str21.Split(new char[] { '|' });
                                        if ((strArray3 != null) && (strArray3.Length >= 1))
                                        {
                                            num15 += _Convert.StrToInt(strArray3[strArray3.Length - 1], 0);
                                        }
                                    }
                                }
                                if (num15 != num7)
                                {
                                    JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。");
                                    return;
                                }
                            }
                            string returnDescription = "";
                            if (DateTime.Now >= _Convert.StrToDateTime(str2.Replace("/", "-"), DateTime.Now.AddDays(-1.0).ToString()))
                            {
                                JavaScript.Alert(this.Page, "本期投注已截止,谢谢。");
                            }
                            else if ((str3 == str17) && (((num * num7) * multiple) != money))
                            {
                                JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                            }
                            else
                            {
                                long num17 = _User.InitiateScheme(isuseID, playType, (str7.Trim() == "") ? "(无标题)" : str7.Trim(), str8.Trim(), number, "", multiple, money, assureMoney, share, buyShare, str6.Trim(), short.Parse(num8.ToString()), schemeBonusScale, ref returnDescription);
                                if (num17 < 0L)
                                {
                                    PF.GoError(1, returnDescription, base.GetType().FullName + "(-755)");
                                }
                                else
                                {
                                    Shove._Web.Cache.ClearCache("Home_Room_CoBuy_BindDataForType" + isuseID.ToString());
                                    Shove._Web.Cache.ClearCache("Home_Room_SchemeAll_BindData" + isuseID.ToString());
                                    if ((money > 50.0) && (share > 1))
                                    {
                                        Shove._Web.Cache.ClearCache("Home_Room_JoinAllBuy_BindData");
                                    }
                                    base.Response.Redirect("../Home/Room/UserBuySuccess.aspx?LotteryID=" + num10.ToString() + "&&Money=" + num13.ToString() + "&SchemeID=" + num17.ToString());
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
            }
        }
 private void BindDataForAliBuy(long BuyID)
 {
     DataTable table = new Tables.T_AlipayBuyTemp().Open("", "ID=" + BuyID.ToString(), "");
     if ((table != null) && (table.Rows.Count != 0))
     {
         DataRow row = table.Rows[0];
         string s = row["IsuseID"].ToString();
         string str2 = row["PlayTypeID"].ToString();
         bool flag = _Convert.StrToBool(row["IsCoBuy"].ToString(), false);
         string str3 = row["Share"].ToString();
         string str4 = row["BuyShare"].ToString();
         string str5 = row["AssureShare"].ToString();
         string str6 = row["OpenUsers"].ToString();
         string str7 = row["Title"].ToString();
         string str8 = row["Description"].ToString();
         string str9 = row["SecrecyLevel"].ToString();
         string str10 = row["LotteryNumber"].ToString();
         string str11 = row["SumMoney"].ToString();
         string str12 = row["AssureMoney"].ToString();
         string str13 = row["LotteryID"].ToString();
         string str14 = row["Multiple"].ToString();
         if (str14 == "")
         {
             str14 = "1";
         }
         double num = 0.0;
         int num2 = 0;
         int num3 = 0;
         double num4 = 0.0;
         int num5 = 0;
         short num6 = 0;
         int playType = 0;
         int num8 = 0;
         try
         {
             num = double.Parse(str11);
             num2 = int.Parse(str3);
             num3 = int.Parse(str4);
             num4 = double.Parse(str12);
             num5 = int.Parse(str14);
             num6 = short.Parse(str9);
             playType = int.Parse(str2);
             num8 = int.Parse(str13);
             long.Parse(s);
         }
         catch
         {
         }
         if ((num3 == num2) && (num4 == 0.0))
         {
             num2 = 1;
             num3 = 1;
         }
         double num1 = num / ((double)num2);
         string str15 = str10;
         if (!string.IsNullOrEmpty(str15) && (str15[str15.Length - 1] == '\n'))
         {
             str15 = str15.Substring(0, str15.Length - 1);
         }
         StringBuilder builder = new StringBuilder();
         builder.AppendLine("<script type='text/javascript' defer='defer'>");
         builder.Append("$Id('playType").Append(playType.ToString()).AppendLine("').checked = true;");
         builder.AppendLine("clickPlayType('" + playType.ToString() + "');");
         builder.AppendLine("function BindDataForFromAli(){");
         str15 = str15.Replace("\r", "");
         int num9 = 0;
         string canonicalNumber = "";
         foreach (string str17 in str15.Split(new char[] { '\n' }))
         {
             if (!string.IsNullOrEmpty(str17))
             {
                 num9 += new SLS.Lottery()[num8].ToSingle(str17, ref canonicalNumber, playType).Length;
                 builder.AppendLine("var option = document.createElement('option');");
                 builder.AppendLine("$Id('list_LotteryNumber').options.add(option);");
                 builder.Append("option.innerText = '").Append(str17).AppendLine("';");
                 builder.Append("option.value = '").Append(str17).AppendLine("';");
             }
         }
         if (flag)
         {
             builder.AppendLine("$Id('CoBuy').checked = true;");
             builder.AppendLine("oncbInitiateTypeClick();");
         }
         builder.Append("$Id('tb_LotteryNumber').value = '").Append(str10.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
         builder.Append("$Id('tb_Share').value = '").Append(str3).AppendLine("';");
         builder.Append("$Id('tb_BuyShare').value = '").Append(str4).AppendLine("';");
         builder.Append("$Id('tb_AssureShare').value = '").Append(str5).AppendLine("';");
         builder.Append("$Id('tb_OpenUserList').value = '").Append(str6).AppendLine("';");
         builder.Append("$Id('tb_Title').value = '").Append(str7).AppendLine("';");
         builder.Append("$Id('tb_Description').value = '").Append(str8.Replace("\r", @"\r").Replace("\n", @"\n")).AppendLine("';");
         builder.Append("$Id('SecrecyLevel").Append(num6.ToString()).AppendLine("').checked = true;");
         builder.Append("$Id('tb_hide_SumMoney').value = '").Append(str11).AppendLine("';");
         builder.Append("$Id('tb_hide_AssureMoney').value = '").Append(num4.ToString("N0")).AppendLine("';");
         builder.Append("$Id('tb_Multiple').value = '").Append(num5.ToString()).AppendLine("';");
         builder.Append("$Id('lab_AssureMoney').innerText = '").Append(num4.ToString("N0")).AppendLine("';");
         builder.Append("$Id('lab_SumMoney').innerText = '").Append(num.ToString("N0")).AppendLine("';");
         builder.Append("$Id('lab_Num').innerText = '").Append(num9.ToString()).AppendLine("';");
         builder.Append("$Id('tb_SchemeMoney').value = '").Append(num.ToString()).AppendLine("';");
         builder.AppendLine("CalcResult();");
         builder.AppendLine("}");
         if (str2.Length != (num8.ToString().Length + 2))
         {
             builder.AppendLine("BindDataForFromAli()");
         }
         builder.AppendLine("</script>");
         this.script = builder.ToString();
     }
 }
Example #30
0
        private string GetLotteryNumber(int LotteryID, int PlayTypeID, string BettingNumber, ref int Num)   // Num 返回注数
        {
            Num = 0;

            if (String.IsNullOrEmpty(BettingNumber))
            {
                return("");
            }

            BettingNumber = BettingNumber.Replace("|", "\n");
            BettingNumber = ConvertLotteryNumber(LotteryID, BettingNumber);

            SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

            if (lb == null)
            {
                return("");
            }

            string t_Number = lb.AnalyseScheme(BettingNumber, PlayTypeID);

            if (String.IsNullOrEmpty(t_Number))
            {
                return("");
            }

            string[] t_Numbers = t_Number.Split('\n');

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

            string Result = "";

            foreach (string str in t_Numbers)
            {
                string t_str = str.Trim();

                if (String.IsNullOrEmpty(t_str))
                {
                    continue;
                }

                string[] t_strs = t_str.Split('|');

                if ((t_strs == null) || (t_strs.Length != 2))
                {
                    continue;
                }

                int t_Num = Shove._Convert.StrToInt(t_strs[1], -1);

                if (String.IsNullOrEmpty(t_strs[0]) || (t_Num < 1))
                {
                    continue;
                }

                Result += t_strs[0] + "\n";
                Num    += t_Num;
            }

            if (Result.EndsWith("\n"))
            {
                Result = Result.Substring(0, Result.Length - 1);
            }

            return(Result);
        }
Example #31
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
            }
        }
Example #32
0
        private void SchemeSystemDealForJCZQ()  //检测竞彩未满员的方案,未成功方案系统撤单,竞彩专用(系统撤单)
        {
            int    Result            = 0;
            int    ReturnValue       = 0;
            string ReturnDescription = "";

            string LotteryNumber = "";
            string BuyContent    = "";
            string vote          = "";

            DataTable dt = MSSQL.Select(ConnectionString, "select [ID], SiteID, LotteryNumber, LotteryID, PlayTypeID, AssureMoney from V_SchemeSchedules where QuashStatus = 0 and Buyed = 0 and Schedule < 100 and LotteryID in (72, 73)");

            if (dt == null)
            {
                return;
            }

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

            DataTable dtPlayType = MSSQL.Select(ConnectionString, "select LotteryID, SystemEndAheadMinute, ID from T_PlayTypes where LotteryID in (72, 73)");

            if (dtPlayType == null)
            {
                return;
            }

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

            DataTable dtMatch = null;

            SLS.Lottery LotteryDc = new SLS.Lottery();

            string strMatchID = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                long SchemeID = long.Parse(dt.Rows[i]["ID"].ToString());
                long SiteID   = long.Parse(dt.Rows[i]["SiteID"].ToString());

                strMatchID = "";

                LotteryNumber = dt.Rows[i]["LotteryNumber"].ToString();

                if ((dt.Rows[i]["LotteryID"].ToString() == "72") && LotteryDc[SLS.Lottery.JCZQ.sID].GetSchemeSplit(LotteryNumber, ref BuyContent, ref vote))
                {
                    if (string.IsNullOrEmpty(BuyContent))
                    {
                        continue;
                    }

                    string[] strBuyContent = BuyContent.Replace("][", "|").Replace("]", "").Replace("[", "").Split('|');

                    foreach (string str in strBuyContent)
                    {
                        strMatchID += str.Substring(0, str.IndexOf("(")) + ",";
                    }

                    if (strMatchID.EndsWith(","))
                    {
                        strMatchID = strMatchID.Substring(0, strMatchID.Length - 1);
                    }

                    dtMatch = MSSQL.Select(ConnectionString, "select min(StopSellingTime) as StopSellingTime from T_match where ID in (" + strMatchID + ")", null);

                    if (dtMatch == null)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (dtMatch.Rows.Count == 0)
                    {
                        continue;
                    }

                    int time = Shove._Convert.StrToInt(dtPlayType.Select("ID=" + dt.Rows[i]["PlayTypeID"].ToString())[0]["SystemEndAheadMinute"].ToString(), 0);

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) < 0 &&
                        Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).CompareTo(DateTime.Now) > 0 && Shove._Convert.StrToDouble(dt.Rows[i]["AssureMoney"].ToString(), 0) > 0)
                    {
                        int Return = DAL.Procedures.P_SchemeAssureMoney(ConnectionString, SchemeID, ref ReturnValue, ref ReturnDescription);

                        if (Return < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());

                            return;
                        }

                        if (ReturnValue < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                        }

                        continue;
                    }

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) > 0)
                    {
                        continue;
                    }

                    Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, SchemeID, true, true, ref ReturnValue, ref ReturnDescription);

                    if (Result < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (ReturnValue < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");

                        continue;
                    }

                    if (ReturnDescription != "")
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                    }
                }
                else if ((dt.Rows[i]["LotteryID"].ToString() == "73") && LotteryDc[SLS.Lottery.JCLQ.sID].GetSchemeSplit(LotteryNumber, ref BuyContent, ref vote))
                {
                    if (string.IsNullOrEmpty(BuyContent))
                    {
                        continue;
                    }

                    string[] strBuyContent = BuyContent.Split('|');

                    foreach (string str in strBuyContent)
                    {
                        strMatchID += str.Substring(0, str.IndexOf("(")) + ",";
                    }

                    if (strMatchID.EndsWith(","))
                    {
                        strMatchID = strMatchID.Substring(0, strMatchID.Length - 1);
                    }

                    dtMatch = MSSQL.Select(ConnectionString, "select min(StopSellingTime) as StopSellingTime from T_MatchBasket where ID in (" + strMatchID + ")", null);

                    if (dtMatch == null)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (dtMatch.Rows.Count == 0)
                    {
                        continue;
                    }

                    int time = Shove._Convert.StrToInt(dtPlayType.Select("ID=" + dt.Rows[i]["PlayTypeID"].ToString())[0]["SystemEndAheadMinute"].ToString(), 0);

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) < 0 &&
                        Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).CompareTo(DateTime.Now) > 0 && Shove._Convert.StrToDouble(dt.Rows[i]["AssureMoney"].ToString(), 0) > 0)
                    {
                        int Return = DAL.Procedures.P_SchemeAssureMoney(ConnectionString, SchemeID, ref ReturnValue, ref ReturnDescription);

                        if (Return < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Fail." + Return.ToString());

                            return;
                        }

                        if (ReturnValue < 0)
                        {
                            msg.Send("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                            log.Write("Exec SchemeSystemDeal: Procedure \"P_SchemeAssureMoney\" Return: " + ReturnDescription);
                        }

                        continue;
                    }

                    if (Shove._Convert.StrToDateTime(dtMatch.Rows[0]["StopSellingTime"].ToString(), DateTime.Now.ToString()).AddMinutes(time * -1).CompareTo(DateTime.Now) > 0)
                    {
                        continue;
                    }

                    Result = DAL.Procedures.P_QuashScheme(ConnectionString, SiteID, SchemeID, true, true, ref ReturnValue, ref ReturnDescription);

                    if (Result < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure 方案ID为\"" + SchemeID.ToString() + "的方案,方案书写格式错误\" Fail.");

                        continue;
                    }

                    if (ReturnValue < 0)
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Fail.");

                        continue;
                    }

                    if (ReturnDescription != "")
                    {
                        msg.Send("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                        log.Write("Exec SchemeSystemDealForJCZQ: Procedure \"P_QuashScheme\" Return: " + ReturnDescription);
                    }
                }
            }
        }
Example #33
0
        private void GetSprize(string IsuseID, string Transmessage)
        {
            System.Xml.XmlDocument XmlDoc = new XmlDocument();
            XmlDoc.Load(new StringReader(Transmessage));

            System.Xml.XmlNodeList nodes = XmlDoc.GetElementsByTagName("*");
            System.Xml.XmlNodeList nodesBonusItem = XmlDoc.GetElementsByTagName("bonusItem");
            System.Xml.XmlNodeList nodesIssue = XmlDoc.GetElementsByTagName("issue");

            string code = "";

            if (nodes == null)
            {
                return;
            }

            string BonusNumber = "";

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

                if (nodes[j].Name.ToUpper() != "BONUSQUERYRESULT")
                {
                    continue;
                }

                BonusNumber = nodes[j].Attributes["bonusNumber"].InnerText;

            }

            if (code != "0000")
            {
                return;
            }

            if (nodesIssue == null)
            {
                return;
            }

            string number = nodesIssue[0].Attributes["number"].Value;
            string LotteryName = nodesIssue[0].Attributes["gameName"].Value;

            int LotteryID = GetLotteryID(LotteryName);
            string WinNumber = GetWinNumber(LotteryID, BonusNumber);

            DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(ConnectionString, "", "[ID] = " + IsuseID + " and [Name] = '" + number + "' and LotteryID = " + LotteryID.ToString() + " and IsOpened = 0", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                return;
            }

            DAL.Tables.T_Isuses T_Isuses = new DAL.Tables.T_Isuses();

            T_Isuses.WinLotteryNumber.Value = WinNumber;
            T_Isuses.OpenOperatorID.Value = 1;
            T_Isuses.Update(ConnectionString, "[ID] = " + IsuseID + " and [Name] = '" + number + "' and LotteryID = " + LotteryID.ToString());

            DataTable dtWinTypesSSL = new DAL.Tables.T_WinTypes().Open(ConnectionString, "", " LotteryID =" + LotteryID.ToString(), "");

            if ((dtWinTypesSSL != null) && dtWinTypesSSL.Rows.Count > 0)
            {
                double[] WinMoneyListSSL = new double[dtWinTypesSSL.Rows.Count * 2];

                double DefaultMoneySSL = 0;
                double DefaultMoneyNoWithTaxSSL = 0;

                for (int i = 0; i < dtWinTypesSSL.Rows.Count; i++)
                {
                    DefaultMoneySSL = Shove._Convert.StrToDouble(dtWinTypesSSL.Rows[i]["DefaultMoney"].ToString(), 0);
                    DefaultMoneyNoWithTaxSSL = Shove._Convert.StrToDouble(dtWinTypesSSL.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                    WinMoneyListSSL[i * 2] = DefaultMoneySSL == 0 ? 1 : DefaultMoneyNoWithTaxSSL;
                    WinMoneyListSSL[i * 2 + 1] = DefaultMoneyNoWithTaxSSL == 0 ? 1 : DefaultMoneyNoWithTaxSSL;
                }

                DataTable t_dtSchemes = new DAL.Tables.T_Schemes().Open(ConnectionString, "", "IsuseID = " + IsuseID + " and WinMoney = 0 and Buyed =1 and  isnull(Identifiers, '') = ''", "");

                string t_LotteryNumber = "";
                SLS.Lottery.LotteryBase t_lb = new SLS.Lottery()[LotteryID];

                string t_Description = "";
                double t_WinMoneyNoWithTax = 0;

                for (int i = 0; i < t_dtSchemes.Rows.Count; i++)
                {
                    t_LotteryNumber = t_dtSchemes.Rows[i]["LotteryNumber"].ToString();
                    t_Description = "";
                    t_WinMoneyNoWithTax = 0;

                    double WinMoney = t_lb.ComputeWin(t_LotteryNumber, WinNumber.Trim(), ref t_Description, ref t_WinMoneyNoWithTax, int.Parse(t_dtSchemes.Rows[i]["PlayTypeID"].ToString()), WinMoneyListSSL);

                    if (WinMoney > 0)
                    {
                        Shove.Database.MSSQL.ExecuteNonQuery(ConnectionString, "update T_Schemes set PreWinMoney = @p1, PreWinMoneyNoWithTax = @p2, WinMoney = @p3, WinMoneyNoWithTax = @p4, WinDescription = @p5 where [ID] = " + t_dtSchemes.Rows[i]["ID"].ToString(),
                            new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, t_WinMoneyNoWithTax * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p3", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p4", SqlDbType.Money, 0, ParameterDirection.Input, t_WinMoneyNoWithTax * Shove._Convert.StrToInt(t_dtSchemes.Rows[i]["Multiple"].ToString(), 1)),
                            new Shove.Database.MSSQL.Parameter("p5", SqlDbType.VarChar, 0, ParameterDirection.Input, t_Description));

                        continue;
                    }
                }
            }

            string BonusXML = "<Schemes>";

            if ((nodesBonusItem != null) && (nodesBonusItem.Count > 0))
            {
                string bonusItemXML = Transmessage.Substring(Transmessage.IndexOf("<bonusQueryResult"), Transmessage.LastIndexOf("</response>") - Transmessage.IndexOf("<bonusQueryResult"));
                DataSet dsXML = new DataSet();

                try
                {
                    dsXML.ReadXml(new StringReader(bonusItemXML));
                }
                catch (Exception e)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期解析开奖数据错误:" + e.Message);

                    return;
                }

                if ((dsXML == null) || (dsXML.Tables.Count < 3))
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期开奖数据格式不符合要求。");

                    return;
                }

                DataTable dtTickets = dsXML.Tables[2];
                DataTable dtSchemes = MSSQL.Select(ConnectionString, "SELECT SchemeID, 0 AS AgentID, SchemesMultiple as Multiple, Identifiers FROM V_SchemesSendToCenter WHERE (IsuseID = " + IsuseID + ")");

                if (dtSchemes == null)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期,读取本地方案错误。");

                    return;
                }

                try
                {
                    var query1 = from NewDtTickets in dtTickets.AsEnumerable()
                                 join NewdtScheme in dtSchemes.AsEnumerable()
                                 on NewDtTickets.Field<string>("ticketID") equals NewdtScheme.Field<string>("Identifiers")
                                 select new
                                 {
                                     ID = NewdtScheme.Field<long>("SchemeID"),
                                     AgentID = NewdtScheme.Field<long>("AgentID"),
                                     Multiple = NewdtScheme.Field<int>("Multiple"),
                                     Bonus = Shove._Convert.StrToDouble(NewDtTickets.Field<string>("money"), 0),
                                     BonusLevel = NewDtTickets.Field<string>("bonusLevel"),
                                     Size = Shove._Convert.StrToInt(NewDtTickets.Field<string>("size"), 1)
                                 };

                    var query2 = from NewDt in query1.AsQueryable()
                                 group NewDt by new { NewDt.ID, NewDt.BonusLevel, NewDt.AgentID, NewDt.Multiple } into gg
                                 select new
                                 {
                                     ID = gg.Key.ID,
                                     AgentID = gg.Key.AgentID,
                                     Multiple = gg.Key.Multiple,
                                     Bonus = gg.Sum(NewDt => NewDt.Bonus),
                                     BonusLevel = GetSchemeWinDescription(gg.Key.BonusLevel, LotteryID, (gg.Sum(NewDt => NewDt.Size) / gg.Key.Multiple))
                                 };

                    var query3 = from NewDt in query2.AsQueryable()
                                 group NewDt by new { NewDt.ID, NewDt.Multiple, NewDt.AgentID } into t_dtSchemes
                                 select new
                                 {
                                     SchemeID = t_dtSchemes.Key.ID,
                                     AgentID = t_dtSchemes.Key.AgentID,
                                     Multiple = t_dtSchemes.Key.Multiple,
                                     Bonus = t_dtSchemes.Sum(NewDt => NewDt.Bonus),
                                     BonusLevel = t_dtSchemes.Merge(NewDt => NewDt.BonusLevel) + ((t_dtSchemes.Key.Multiple != 1) ? "(" + t_dtSchemes.Key.Multiple.ToString() + "倍)" : "")
                                 };

                    foreach (var Scheme in query3)
                    {
                            BonusXML += "<Scheme SchemeID=\"" + Scheme.SchemeID.ToString() + "\" WinMoney=\"" + Scheme.Bonus.ToString() + "\" WinDescription=\"" + Scheme.BonusLevel + "\" />";
                    }
                }
                catch (Exception e)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票开奖,第 " + number + " 期详细中奖数据解析错误:" + e.Message);

                    return;
                }
            }

            BonusXML += "</Schemes>";

            dtIsuse = new DAL.Tables.T_Isuses().Open(ConnectionString, "", "[ID] = " + IsuseID + " and IsOpened = 0", "");

            if ((dtIsuse == null) || (dtIsuse.Rows.Count < 1))
            {
                return;
            }

            int ReturnValue = 0;
            string ReturnDescription = "";

            DataSet ds = null;
            int Times = 0;
            int Result = -1;

            while ((Result < 0) && (Times < 5))
            {
                ReturnValue = 0;
                ReturnDescription = "";

                Result = DAL.Procedures.P_ElectronTicketWin(ConnectionString, ref ds, Shove._Convert.StrToLong(IsuseID, 0), BonusXML, ref ReturnValue, ref ReturnDescription);

                if (Result < 0)
                {
                    new Log("ElectronTicket\\HPSH").Write("电子票第 " + (Times + 1).ToString() + " 次派奖出现错误(IsuseOpenNotice) 期号为: " + number + ",彩种为: " + LotteryID.ToString());
                    Times++;

                    if (Times < 5)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }

                    continue;
                }
            }

            if (ReturnValue < 0)
            {
                log.Write(ReturnDescription);

                return;
            }

            //PublicFunction.SendWinNotification(ds);

            DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(ConnectionString, "", " LotteryID =" + LotteryID.ToString(), "");

            if ((dtWinTypes == null) || dtWinTypes.Rows.Count < 1)
            {
                msg.Send("执行电子票--获取彩种: " + LotteryID.ToString() + ",奖金等级时出现错误!");
                log.Write("执行电子票--获取彩种: " + LotteryID.ToString() + ",奖金等级时出现错误!");

                return;
            }

            double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2];

            double DefaultMoney = 0;
            double DefaultMoneyNoWithTax = 0;

            for (int i = 0; i < dtWinTypes.Rows.Count; i++)
            {
                DefaultMoney = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoney"].ToString(), 0);
                DefaultMoneyNoWithTax = Shove._Convert.StrToDouble(dtWinTypes.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0);

                WinMoneyList[i * 2] = DefaultMoney == 0 ? 1 : DefaultMoneyNoWithTax;
                WinMoneyList[i * 2 + 1] = DefaultMoneyNoWithTax == 0 ? 1 : DefaultMoneyNoWithTax;
            }

            DataTable dtSchemesWithTaskDetails = new DAL.Views.V_Schemes().Open(ConnectionString, "", " IsuseName = '" + number + "' and LotteryID = " + LotteryID.ToString() + " and WinMoney = 0  and Buyed = 0 and ID in ( select ID from V_ChaseTaskDetails where IsuseName = '" + number + "' and LotteryID = " + LotteryID.ToString() + ")", "");

            string LotteryNumber = "";
            SLS.Lottery.LotteryBase lb = new SLS.Lottery()[LotteryID];

            string Description = "";
            double WinMoneyNoWithTax = 0;

            for (int i = 0; i < dtSchemesWithTaskDetails.Rows.Count; i++)
            {
                LotteryNumber = dtSchemesWithTaskDetails.Rows[i]["LotteryNumber"].ToString();

                Description = "";
                WinMoneyNoWithTax = 0;

                double WinMoney = lb.ComputeWin(LotteryNumber, WinNumber.Trim(), ref Description, ref WinMoneyNoWithTax, int.Parse(dtSchemesWithTaskDetails.Rows[i]["PlayTypeID"].ToString()), WinMoneyList);

                if (WinMoney > 0)
                {
                    if (DAL.Procedures.P_ChaseTaskStopWhenWin(ConnectionString, Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["SiteID"].ToString(), 0), Shove._Convert.StrToLong(dtSchemesWithTaskDetails.Rows[i]["ID"].ToString(), 0), WinMoney, ref ReturnValue, ref ReturnDescription) < 0)
                    {
                        msg.Send("执行电子票--判断是否停止追号的时候出现错误");
                        log.Write("执行电子票--判断是否停止追号的时候出现错误");

                        continue;
                    }
                }
            }
        }
 private void Buy(Users _User)
 {
     string request = Shove._Web.Utility.GetRequest("HidIsuseID");
     string str2 = Shove._Web.Utility.GetRequest("HidIsuseEndTime");
     string s = Shove._Web.Utility.GetRequest("playType");
     string str4 = Shove._Web.Utility.GetRequest("Chase");
     Shove._Web.Utility.GetRequest("CoBuy");
     string str5 = Shove._Web.Utility.GetRequest("tb_Share");
     string str6 = Shove._Web.Utility.GetRequest("tb_BuyShare");
     Shove._Web.Utility.GetRequest("tb_AssureShare");
     string str7 = Shove._Web.Utility.GetRequest("tb_OpenUserList");
     string str8 = Shove._Web.Utility.GetRequest("tb_Title");
     string str9 = Shove._Web.Utility.GetRequest("tb_Description");
     string str10 = Shove._Web.Utility.GetRequest("tbAutoStopAtWinMoney");
     string str11 = Shove._Web.Utility.GetRequest("SecrecyLevel");
     string str12 = Shove._Web.Utility.FilteSqlInfusion(base.Request["tb_LotteryNumber"]);
     string str13 = Shove._Web.Utility.GetRequest("tb_hide_SumMoney");
     string str14 = Shove._Web.Utility.GetRequest("tb_hide_AssureMoney");
     string str15 = Shove._Web.Utility.GetRequest("tb_hide_SumNum");
     Shove._Web.Utility.GetRequest("HidIsuseCount");
     string str16 = Shove._Web.Utility.GetRequest("HidLotteryID");
     Shove._Web.Utility.GetRequest("HidIsAlipay");
     string str17 = Shove._Web.Utility.GetRequest("tb_Multiple");
     Shove._Web.Utility.GetRequest("HidIsuseName");
     Shove._Web.Utility.GetRequest("tbPlayTypeName");
     string str18 = Shove._Web.Utility.GetRequest("tb_hide_ChaseBuyedMoney");
     string str19 = Shove._Web.Utility.GetRequest("tb_SchemeBonusScale");
     string str20 = Shove._Web.Utility.GetRequest("tb_SchemeBonusScalec");
     int num = 2;
     if (str17 == "")
     {
         str17 = "1";
     }
     double money = 0.0;
     int share = 0;
     int buyShare = 0;
     double assureMoney = 0.0;
     int multiple = 0;
     int num7 = 0;
     short num8 = 0;
     int playType = 0;
     int lotteryID = 0;
     long isuseID = 0L;
     double stopWhenWinMoney = 0.0;
     double schemeBonusScale = 0.0;
     double schemeBonusScalec = 0.0;
     try
     {
         money = double.Parse(str13);
         share = int.Parse(str5);
         buyShare = int.Parse(str6);
         assureMoney = double.Parse(str14);
         multiple = int.Parse(str17);
         num7 = int.Parse(str15);
         num8 = short.Parse(str11);
         playType = int.Parse(s);
         lotteryID = int.Parse(str16);
         isuseID = long.Parse(request);
         stopWhenWinMoney = double.Parse(str10);
         schemeBonusScale = double.Parse(str19);
         schemeBonusScalec = double.Parse(str20);
     }
     catch
     {
         JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
         return;
     }
     if ((money > 0.0) && (num7 >= 1))
     {
         if (assureMoney < 0.0)
         {
             JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
         }
         else if (share < 1)
         {
             JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
         }
         else
         {
             if ((buyShare == share) && (assureMoney == 0.0))
             {
                 share = 1;
                 buyShare = 1;
             }
             if ((money / ((double)share)) < 1.0)
             {
                 JavaScript.Alert(this.Page, "每份金额最低不能少于 1 元。");
             }
             else
             {
                 double num15 = (buyShare * (money / ((double)share))) + assureMoney;
                 if (str4 != "")
                 {
                     num15 = double.Parse(str18);
                 }
                 if (num15 > _User.Balance)
                 {
                     this.SaveDataForAliBuy();
                 }
                 else if (num15 > 10000000.0)
                 {
                     JavaScript.Alert(this.Page, "投注金额不能大于" + 0x989680.ToString() + ",谢谢。");
                 }
                 else if (multiple > 0x3e7)
                 {
                     JavaScript.Alert(this.Page, "投注倍数不能大于 999 倍,谢谢。");
                 }
                 else if ((schemeBonusScale < 0.0) && (schemeBonusScale > 10.0))
                 {
                     JavaScript.Alert(this.Page, "佣金比例只能在0~10之间");
                 }
                 else if ((schemeBonusScale.ToString().IndexOf("-") > -1) || (schemeBonusScale.ToString().IndexOf(".") > -1))
                 {
                     JavaScript.Alert(this.Page, "佣金比例输入有误");
                 }
                 else if ((schemeBonusScalec < 0.0) && (schemeBonusScalec > 10.0))
                 {
                     JavaScript.Alert(this.Page, "佣金比例只能在0~10之间");
                 }
                 else if ((schemeBonusScalec.ToString().IndexOf("-") > -1) || (schemeBonusScalec.ToString().IndexOf(".") > -1))
                 {
                     JavaScript.Alert(this.Page, "佣金比例输入有误");
                 }
                 else
                 {
                     schemeBonusScale /= 100.0;
                     schemeBonusScalec /= 100.0;
                     string number = str12;
                     if (number[number.Length - 1] == '\n')
                     {
                         number = number.Substring(0, number.Length - 1);
                     }
                     SLS.Lottery lottery = new SLS.Lottery();
                     string[] strArray = this.SplitLotteryNumber(number);
                     if ((strArray == null) || (strArray.Length < 1))
                     {
                         JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。(-694)");
                     }
                     else
                     {
                         int num17 = 0;
                         foreach (string str22 in strArray)
                         {
                             string str23 = lottery[lotteryID].AnalyseScheme(str22, playType);
                             if (!string.IsNullOrEmpty(str23))
                             {
                                 string[] strArray3 = str23.Split(new char[] { '|' });
                                 if ((strArray3 != null) && (strArray3.Length >= 1))
                                 {
                                     num17 += _Convert.StrToInt(strArray3[strArray3.Length - 1], 0);
                                 }
                             }
                         }
                         if (num17 != num7)
                         {
                             JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。");
                         }
                         else
                         {
                             StringBuilder builder = new StringBuilder();
                             int num19 = 0;
                             string detailXML = "";
                             string returnDescription = "";
                             if (str4 == "1")
                             {
                                 foreach (string str26 in base.Request.Form.AllKeys)
                                 {
                                     if (str26.IndexOf("check") > -1)
                                     {
                                         int num20 = _Convert.StrToInt(str26.Replace("check", ""), -1);
                                         if (num20 > 0)
                                         {
                                             num19++;
                                             int num21 = (_Convert.StrToInt(base.Request.Form["tb_hide_SumNum"], -1) * num) * _Convert.StrToInt(base.Request.Form["times" + num20.ToString()], -1);
                                             builder.Append(base.Request.Form[str26]).Append(",").Append(base.Request.Form["times" + num20.ToString()]).Append(",").Append(num21.ToString()).Append(",").Append(base.Request.Form["share" + num20.ToString()]).Append(",").Append(base.Request.Form["buyedShare" + num20.ToString()]).Append(",").Append(base.Request.Form["assureShare" + num20.ToString()]).Append(";");
                                         }
                                     }
                                 }
                                 if (builder.Length > 0)
                                 {
                                     builder.Remove(builder.Length - 1, 1);
                                 }
                                 if (number[number.Length - 1] == '\n')
                                 {
                                     number = number.Substring(0, number.Length - 1);
                                 }
                                 try
                                 {
                                     money = double.Parse(str13);
                                 }
                                 catch
                                 {
                                     JavaScript.Alert(this.Page, "输入有错误,请仔细检查。(-1325)");
                                     return;
                                 }
                                 if (money < 2.0)
                                 {
                                     JavaScript.Alert(this.Page, "输入有错误,请仔细检查。(-1332)");
                                 }
                                 else
                                 {
                                     string[] strArray5 = builder.ToString().Split(new char[] { ';' });
                                     int length = strArray5.Length;
                                     string[] str = new string[length * 9];
                                     DateTime time2 = DateTime.Parse(Functions.F_GetIsuseSystemEndTime(long.Parse(strArray5[0].Split(new char[] { ',' })[0]), playType).ToString());
                                     if (DateTime.Now >= time2)
                                     {
                                         JavaScript.Alert(this.Page, "您选择的追号期号中包含已截止的期,请重新选择。");
                                     }
                                     else
                                     {
                                         for (int i = 0; i < length; i++)
                                         {
                                             str[i * 9] = strArray5[i].Split(new char[] { ',' })[0];
                                             str[(i * 9) + 1] = playType.ToString();
                                             str[(i * 9) + 2] = number;
                                             str[(i * 9) + 3] = strArray5[i].Split(new char[] { ',' })[1];
                                             str[(i * 9) + 4] = strArray5[i].Split(new char[] { ',' })[2];
                                             str[(i * 9) + 5] = num8.ToString();
                                             str[(i * 9) + 6] = strArray5[i].Split(new char[] { ',' })[3];
                                             str[(i * 9) + 7] = strArray5[i].Split(new char[] { ',' })[4];
                                             str[(i * 9) + 8] = strArray5[i].Split(new char[] { ',' })[5];
                                             if ((_Convert.StrToDouble(str[(i * 9) + 3], 0.0) * money) != _Convert.StrToDouble(str[(i * 9) + 4], 1.0))
                                             {
                                                 JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                                                 return;
                                             }
                                             if (_Convert.StrToDouble(str[(i * 9) + 3], 0.0) < multiple)
                                             {
                                                 JavaScript.Alert(this.Page, "追号倍数有错误,请仔细检查!");
                                                 return;
                                             }
                                             if (((double.Parse(str[(i * 9) + 3]) * num7) * num) != double.Parse(str[(i * 9) + 4]))
                                             {
                                                 JavaScript.Alert(this.Page, "追号金额有错误,请仔细检查!可能原因:浏览器不兼容,建议使用IE 7.0");
                                                 return;
                                             }
                                         }
                                         detailXML = PF.BuildIsuseAdditionasXmlForBJKL8(str);
                                         if (detailXML == "")
                                         {
                                             JavaScript.Alert(this.Page, "追号发生错误。");
                                         }
                                         else if (_User.InitiateChaseTask(str8.Trim(), str9.Trim(), lotteryID, stopWhenWinMoney, detailXML, number, schemeBonusScalec, ref returnDescription) < 0)
                                         {
                                             PF.GoError(1, returnDescription, base.GetType().FullName + "(-754)");
                                         }
                                         else
                                         {
                                             Shove._Web.Cache.ClearCache("Home_Room_CoBuy_BindDataForType" + isuseID.ToString());
                                             Shove._Web.Cache.ClearCache("Home_Room_SchemeAll_BindData" + isuseID.ToString());
                                             Shove._Web.Cache.ClearCache(base._Site.ID.ToString() + "AccountFreezeDetail_" + _User.ID.ToString());
                                             base.Response.Redirect("../Home/Room/UserBuySuccess.aspx?LotteryID=" + lotteryID.ToString() + "&Type=2&Money=" + num15.ToString());
                                         }
                                     }
                                 }
                             }
                             else if (DateTime.Now >= _Convert.StrToDateTime(str2.Replace("/", "-"), DateTime.Now.AddDays(-1.0).ToString()))
                             {
                                 JavaScript.Alert(this.Page, "本期投注已截止,谢谢。");
                             }
                             else if (((num * num7) * multiple) != money)
                             {
                                 JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                             }
                             else
                             {
                                 long num25 = _User.InitiateScheme(isuseID, playType, (str8.Trim() == "") ? "(无标题)" : str8.Trim(), str9.Trim(), number, "", multiple, money, assureMoney, share, buyShare, str7.Trim(), short.Parse(num8.ToString()), schemeBonusScale, ref returnDescription);
                                 if (num25 < 0L)
                                 {
                                     PF.GoError(1, returnDescription, base.GetType().FullName + "(-755)");
                                 }
                                 else
                                 {
                                     Shove._Web.Cache.ClearCache("Home_Room_CoBuy_BindDataForType" + isuseID.ToString());
                                     Shove._Web.Cache.ClearCache("Home_Room_SchemeAll_BindData" + isuseID.ToString());
                                     if ((money > 50.0) && (share > 1))
                                     {
                                         Shove._Web.Cache.ClearCache("Home_Room_JoinAllBuy_BindData");
                                     }
                                     base.Response.Redirect("../Home/Room/UserBuySuccess.aspx?LotteryID=" + lotteryID.ToString() + "&Money=" + num15.ToString() + "&SchemeID=" + num25.ToString());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     else
     {
         JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
     }
 }
Example #35
0
        // 查询奖期状态
        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
            }
        }
 private void Buy(Users _User)
 {
     string request = Shove._Web.Utility.GetRequest("HidIsuseID");
     string str2 = Shove._Web.Utility.GetRequest("HidIsuseEndTime");
     string str3 = Shove._Web.Utility.GetRequest("playType");
     Shove._Web.Utility.GetRequest("CoBuy");
     string s = Shove._Web.Utility.GetRequest("tb_Share");
     string str5 = Shove._Web.Utility.GetRequest("tb_BuyShare");
     Shove._Web.Utility.GetRequest("tb_AssureShare");
     string str6 = Shove._Web.Utility.GetRequest("tb_OpenUserList");
     string str7 = Shove._Web.Utility.GetRequest("tb_Title");
     string str8 = Shove._Web.Utility.GetRequest("tb_Description");
     string str9 = Shove._Web.Utility.GetRequest("SecrecyLevel");
     string str10 = Shove._Web.Utility.FilteSqlInfusion(base.Request["tb_LotteryNumber"]);
     string str11 = Shove._Web.Utility.GetRequest("tb_hide_SumMoney");
     string str12 = Shove._Web.Utility.GetRequest("tb_hide_AssureMoney");
     string str13 = Shove._Web.Utility.GetRequest("tb_hide_SumNum");
     string str14 = Shove._Web.Utility.GetRequest("HidLotteryID");
     string str15 = Shove._Web.Utility.GetRequest("tb_Multiple");
     string str16 = Shove._Web.Utility.GetRequest("tb_SchemeBonusScale");
     string str17 = Shove._Web.Utility.GetRequest("tbPlayTypeID");
     string str18 = Shove._Web.Utility.GetRequest("tb_SchemeMoney");
     int num = 2;
     if (str15 == "")
     {
         str15 = "1";
     }
     double money = 0.0;
     int share = 0;
     int buyShare = 0;
     double assureMoney = 0.0;
     int multiple = 0;
     int num7 = 0;
     short num8 = 0;
     int playType = 0;
     int num10 = 0;
     long isuseID = 0L;
     double schemeBonusScale = 0.0;
     try
     {
         money = double.Parse(str11);
         share = int.Parse(s);
         buyShare = int.Parse(str5);
         assureMoney = double.Parse(str12);
         multiple = int.Parse(str15);
         num7 = int.Parse(str13);
         num8 = short.Parse(str9);
         playType = int.Parse(str17);
         num10 = int.Parse(str14);
         isuseID = long.Parse(request);
         schemeBonusScale = double.Parse(str16);
     }
     catch
     {
         JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
         return;
     }
     if (str17 != str3)
     {
         money = double.Parse(str18);
     }
     if ((money > 0.0) && ((num7 >= 1) || !(str17 == str3)))
     {
         if (assureMoney < 0.0)
         {
             JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
         }
         else if (share < 1)
         {
             JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
         }
         else
         {
             if ((buyShare == share) && (assureMoney == 0.0))
             {
                 share = 1;
                 buyShare = 1;
             }
             if ((money / ((double)share)) < 1.0)
             {
                 JavaScript.Alert(this.Page, "每份金额最低不能少于 1 元。");
             }
             else
             {
                 double num13 = (buyShare * (money / ((double)share))) + assureMoney;
                 if (num13 > _User.Balance)
                 {
                     this.SaveDataForAliBuy();
                 }
                 else if (num13 > 10000000.0)
                 {
                     JavaScript.Alert(this.Page, "投注金额不能大于" + 0x989680.ToString() + ",谢谢。");
                 }
                 else if (multiple > 0x3e7)
                 {
                     JavaScript.Alert(this.Page, "投注倍数不能大于 999 倍,谢谢。");
                 }
                 else if ((schemeBonusScale < 0.0) && (schemeBonusScale > 10.0))
                 {
                     JavaScript.Alert(this.Page, "佣金比例只能在0~10之间");
                 }
                 else if ((schemeBonusScale.ToString().IndexOf("-") > -1) || (schemeBonusScale.ToString().IndexOf(".") > -1))
                 {
                     JavaScript.Alert(this.Page, "佣金比例输入有误");
                 }
                 else
                 {
                     schemeBonusScale /= 100.0;
                     string number = str10;
                     if (str17 == str3)
                     {
                         if (number[number.Length - 1] == '\n')
                         {
                             number = number.Substring(0, number.Length - 1);
                         }
                         SLS.Lottery lottery = new SLS.Lottery();
                         string[] strArray = this.SplitLotteryNumber(number);
                         if ((strArray == null) || (strArray.Length < 1))
                         {
                             JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。(-694)");
                             return;
                         }
                         int num15 = 0;
                         foreach (string str20 in strArray)
                         {
                             string str21 = lottery[num10].AnalyseScheme(str20, playType);
                             if (!string.IsNullOrEmpty(str21))
                             {
                                 string[] strArray3 = str21.Split(new char[] { '|' });
                                 if ((strArray3 != null) && (strArray3.Length >= 1))
                                 {
                                     num15 += _Convert.StrToInt(strArray3[strArray3.Length - 1], 0);
                                 }
                             }
                         }
                         if (num15 != num7)
                         {
                             JavaScript.Alert(this.Page, "选号发生异常,请重新选择号码投注,谢谢。");
                             return;
                         }
                     }
                     string returnDescription = "";
                     if (DateTime.Now >= _Convert.StrToDateTime(str2.Replace("/", "-"), DateTime.Now.AddDays(-1.0).ToString()))
                     {
                         JavaScript.Alert(this.Page, "本期投注已截止,谢谢。");
                     }
                     else if ((str3 == str17) && (((num * num7) * multiple) != money))
                     {
                         JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
                     }
                     else
                     {
                         long num17 = _User.InitiateScheme(isuseID, playType, (str7.Trim() == "") ? "(无标题)" : str7.Trim(), str8.Trim(), number, "", multiple, money, assureMoney, share, buyShare, str6.Trim(), short.Parse(num8.ToString()), schemeBonusScale, ref returnDescription);
                         if (num17 < 0L)
                         {
                             PF.GoError(1, returnDescription, base.GetType().FullName + "(-755)");
                         }
                         else
                         {
                             Shove._Web.Cache.ClearCache("Home_Room_CoBuy_BindDataForType" + isuseID.ToString());
                             Shove._Web.Cache.ClearCache("Home_Room_SchemeAll_BindData" + isuseID.ToString());
                             if ((money > 50.0) && (share > 1))
                             {
                                 Shove._Web.Cache.ClearCache("Home_Room_JoinAllBuy_BindData");
                             }
                             base.Response.Redirect("../Home/Room/UserBuySuccess.aspx?LotteryID=" + num10.ToString() + "&&Money=" + num13.ToString() + "&SchemeID=" + num17.ToString());
                         }
                     }
                 }
             }
         }
     }
     else
     {
         JavaScript.Alert(this.Page, "输入有错误,请仔细检查。");
     }
 }
Example #37
0
        public void GetLotteryOpenNumberAndOpenWin_SaveSchemes() // 获取开奖信息,并计算奖金对保存方案开奖
        {
            // 读取未开奖的擂台方案表
            DataTable dtSchemeChallenge = new DAL.Tables.T_ChallengeSaveScheme().Open(ConnectionString, "[ID],[InitiateUserID],[LotteryNumber],[Odds], PlayTypeID, Money", "IsOpened = 0 and DateTime < CONVERT(VARCHAR(24),GETDATE(),111)", "");

            if (dtSchemeChallenge == null)
            {
                new Log("SystemGetLotteryOpenNumber").Write("(保存)比拼擂台方案保存表,没有可开奖的数据。");

                return;
            }

            if (dtSchemeChallenge.Rows.Count < 1)
            {
                IsOpened = true;

                return;
            }

            string PlayTypeID = "";
            string SchemeID = "";
            string InitiateUserID = "";
            string LotteryNunber = "";
            string Content = "";
            string WaysNumber = "";
            string Matchs = "";

            // 遍历没有开奖的方案
            foreach (DataRow dr in dtSchemeChallenge.Rows)
            {
                //得到方案ID
                SchemeID = dr["ID"].ToString().Trim();

                //得到方案发起用户ID
                InitiateUserID = dr["InitiateUserID"].ToString().Trim();

                //得到投注号码
                LotteryNunber = dr["LotteryNumber"].ToString().Trim();

                PlayTypeID = dr["PlayTypeID"].ToString().Trim();

                #region 对投注号码进行分析,判断注数

                SLS.Lottery slsLottery = new SLS.Lottery();
                string[] t_lotterys = SplitLotteryNumber(LotteryNunber);

                if ((t_lotterys == null) || (t_lotterys.Length < 1))
                {
                    new Log("SystemGetLotteryOpenNumber").Write("(保存)投注号码出现异常,读取格式不正确:" + LotteryNunber);
                    return;
                }

                int ValidNum = 0;

                foreach (string str in t_lotterys)
                {
                    string Number = slsLottery[72].AnalyseScheme(str, Shove._Convert.StrToInt(PlayTypeID, 0));

                    if (string.IsNullOrEmpty(Number))
                    {
                        continue;
                    }

                    string[] str_s = Number.Split('|');

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

                    ValidNum += Shove._Convert.StrToInt(str_s[str_s.Length - 1], 0);
                }



                #endregion

                //解析投注号码
                Content = LotteryNunber.Trim().Split(';')[1].ToString(); // 得到投注内容
                WaysNumber = LotteryNunber.Trim().Split(';')[2].ToString(); // 得到过关玩法

                // 得到投注比赛ID、投注内容
                string[] Numbers = Content.Substring(1, Content.Length - 2).Split('|');

                Matchs = "";

                foreach (string Number in Numbers)
                {
                    Matchs += Number.Substring(0, Number.IndexOf('(')) + ",";
                }

                if (Matchs.EndsWith(","))
                {
                    Matchs = Matchs.Substring(0, Matchs.Length - 1);
                }

                if (string.IsNullOrEmpty(Matchs))
                {
                    continue;
                }

                //通过赛事ID 查找赛事结果
                DataTable dt = new DAL.Tables.T_Match().Open(ConnectionString, "[SPFResult], [ID]", "[ID] in (" + Matchs + ") and IsOpened = 1", "[ID]");

                if (dt == null)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("(保存)读取 T_Match 数据时候出现异常");

                    continue;
                }

                if (dt.Rows.Count < 1)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("(保存)MatchID:(" + Matchs + ")暂未开奖");

                    continue;
                }

                bool IsWin = true;
                string Result = "";
                int WinCoumt = 0;       // 命中场次
                int i = 0;
                string[] matchsId = Matchs.Split(',');

                foreach (string Number in Numbers)
                {
                    DataRow[] drs = dt.Select("ID = " + matchsId[i]);



                    if (drs.Length < 1)
                    {
                        IsWin = false;
                        break;
                    }
                    string ddx = Number.Substring(Number.IndexOf('(')).Substring(1);
                    if (ddx.EndsWith(")"))
                    {
                        ddx = ddx.Substring(0, ddx.Length - 1);
                    }

                    Result = GetResult(drs[0]["SPFResult"].ToString(), PlayTypeID);

                    if (!Result.Equals(ddx))
                    {
                        IsWin = false;
                    }
                    else
                    {
                        WinCoumt++;
                    }
                    i++;
                }

                string sql = "";
                int result = 0;

                // 计算命中场次  ==> WinCount

                if (!IsWin)
                {// 没有中奖
                    sql = "update T_ChallengeSaveScheme set IsOpened = 1, OpenOperateId = 1  where ID = " + SchemeID;

                    result = Shove.Database.MSSQL.ExecuteNonQuery(ConnectionString, sql);

                    if (result < 0)
                    {
                        new Log("SystemGetLotteryOpenNumber").Write("(保存)执行Sql语句失败:" + sql);

                        continue;
                    }


                    continue;
                }

                string Odds = dr["odds"].ToString();

                double WinMoney = 2;

                foreach (string Odd in Odds.Split('|'))
                {
                    WinMoney *= Shove._Convert.StrToDouble(Odd, 0);
                }

                // 修改方案的 IsOpen , WinMoney ,WinDescription
                sql = "update T_ChallengeSaveScheme set IsOpened = 1,WinMoney = " + WinMoney.ToString() + ",WinDescription='(保存)擂台中奖', OpenOperateId = 1 where ID = " + SchemeID;

                result = Shove.Database.MSSQL.ExecuteNonQuery(ConnectionString, sql);

                if (result < 0)
                {
                    new Log("SystemGetLotteryOpenNumber").Write("(保存)执行Sql语句失败:" + sql);

                    continue;
                }

                new Log("SystemGetLotteryOpenNumber").Write("(保存)开奖成功,SchemeID:" + SchemeID);
            }
        }