示例#1
0
        public csLine GetLastDate()
        {
            csLine data = null;

            try
            {
                dataset = connection.ExecutePA("[dbo].[spGetValueLastDate]");

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow fila in dataset.Tables[0].Rows)
                    {
                        data = new csLine(Convert.ToString(fila[0]), Convert.ToInt32(fila[1]), Convert.ToInt32(fila[2]));
                    }
                }
                else
                {
                    data = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }

            return(data);
        }
示例#2
0
        //************************************************************************************

        public csGame TotalRisk(csGame g)
        {
            try
            {
                parameters.Clear();
                parameters.Add("@pIdGame", g.IdGame);
                parameters.Add("@pPlay", -1);
                dataset = csG8Apps.ExecutePA("[dbo].[web_betsByGame]", parameters);;

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    ObservableCollection <csLine> data = new ObservableCollection <csLine>();
                    foreach (System.Data.DataRow fila in dataset.Tables[0].Rows)
                    {
                        csLine line = new csLine();
                        line.IdWager   = Convert.ToInt32(fila["IdWager"]);
                        line.WagerPlay = fila["WagerPlay"].ToString().ToUpper();
                        line.Risk      = Convert.ToDouble(fila["RiskAmount"]);
                        line.WagerType = fila["WAGERTYPE"].ToString();
                        data.Add(line);
                    }


                    if (data != null)
                    {
                        List <int> Enteros = new List <int>();
                        foreach (var i in data)
                        {
                            if (!i.WagerType.ToUpper().Contains("STRAIGHT"))
                            {
                                if (!Enteros.Contains(Convert.ToInt32(i.IdWager)))
                                {
                                    Enteros.Add(i.IdWager);
                                    g.RISK += i.Risk;
                                    g.BETS += 1;
                                }
                            }
                            else
                            {
                                g.RISK += i.Risk;
                                g.BETS += 1;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                parameters.Clear();
            }

            return(g);
        }
示例#3
0
 private csLine CastDate(csLine l, DateTime dt)
 {
     l.Year   = dt.Year;
     l.Month  = (dt.Month - 1);
     l.Day    = dt.Day;
     l.Hour   = dt.Hour;
     l.Minute = dt.Minute;
     l.Second = dt.Second;
     return(l);
 }
示例#4
0
文件: blLine.cs 项目: jfallasm/G8App
 private csLine CastDate(csLine l)
 {
     l.Year   = l.Date.Year;
     l.Month  = (l.Date.Month - 1);
     l.Day    = l.Date.Day;
     l.Hour   = l.Date.Hour;
     l.Minute = l.Date.Minute;
     l.Second = l.Date.Second;
     return(l);
 }
示例#5
0
        public ObservableCollection <csLine> GetBetPlayer(int idWager, string player, string userplay, string s, string type)
        {
            ObservableCollection <csLine> data = new ObservableCollection <csLine>();
            csLine line = null;
            string side = (userplay.ToUpper().ToUpper().Contains("VISI") && s == "V") ? "VISITOR" : "NONE";

            side = (userplay.ToUpper().Contains("HOME") && s == "H") ? "HOME" : side;
            side = (userplay.ToUpper().Contains("OVER")) && s == "V" ? "OVER" : side;
            side = (userplay.ToUpper().Contains("UNDER") && s == "H") ? "UNDER" : side;
            side = (userplay.ToUpper().Contains("DRAW")) ? "DRAW" : side;

            try
            {
                parameters.Clear();
                parameters.Add("@pPlayer", player);
                parameters.Add("@pIdWager", idWager);
                dataset = csG8Apps.ExecutePA("[dbo].[web_betIdWager]", parameters);;

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow fila in dataset.Tables[0].Rows)
                    {
                        line           = new csLine();
                        line.Juice     = Convert.ToInt32(fila["Odds"]);
                        line.Line      = Convert.ToDouble(fila["Points"]);
                        line.Casino    = -1;
                        line.WagerPlay = fila["WagerPlay"].ToString().ToUpper();
                        if (line.WagerPlay.Contains("TOTAL"))
                        {
                            line.Line = Math.Abs(Convert.ToInt32(line.Line));
                        }
                        DateTime dt = Convert.ToDateTime(fila["PlacedDate"]);
                        line      = CastDate(line, dt);
                        line.Time = CastTime(dt);

                        if (userplay.ToUpper() == line.WagerPlay && line.WagerPlay.Contains(side) &&
                            line.WagerPlay.Contains(type))
                        {
                            data.Add(line);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                data = null;
                throw new Exception(ex.Message);
            }
            finally
            {
                parameters.Clear();
            }

            return(data);
        }
示例#6
0
        private void Consult()
        {
            csLine collection = null;

            while (true)
            {
                System.Threading.Thread.Sleep(TimeSpan.FromMinutes(2));
                collection = lineBL.GetLastDate();

                if (collection != null)
                {
                    if (collection.MinutesStopped <= MinutesOFF && collection.MinutesHeartBeat <= MinutesOFF)
                    {
                        Application.ExitThread();
                        Application.Exit();
                        Application.Restart();
                        Environment.Exit(0);
                    }
                }
            }
        }
示例#7
0
        public ObservableCollection <csLine> GetSP(int IdEvent, string period, string side, string player, int idwager, string userplay, int idGame, int idPeriod)
        {
            ObservableCollection <csLine> data = new ObservableCollection <csLine>();
            csLine line = null;

            try
            {
                parameters.Clear();
                parameters.Add("@pIdEvent", IdEvent);
                parameters.Add("@pPeriod", period);
                dataset = csDonBest.ExecutePA("[dbo].[web_getSPForEvent]", parameters);

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow fila in dataset.Tables[0].Rows)
                    {
                        line        = new csLine();
                        line.Casino = Convert.ToInt32(fila["sportsbook"]);
                        DateTime dt = Convert.ToDateTime(fila["timeReceived"]);
                        line      = CastDate(line, dt);
                        line.Time = CastTime(dt);

                        if (side == "H")
                        {
                            line.Juice = Convert.ToInt32(fila["ps_home_price"]);
                            line.Line  = Convert.ToDouble(fila["ps_home_spread"]);
                            data.Add(line);
                        }
                        else if (side == "V")
                        {
                            line.Juice = Convert.ToInt32(fila["ps_away_price"]);
                            line.Line  = Convert.ToDouble(fila["ps_away_spread"]);
                            data.Add(line);
                        }
                    }

                    if (player != "")
                    {
                        var list = GetBetPlayer(idwager, player, userplay, side, "SPREAD");
                        if (list != null && list.Count > 0)
                        {
                            foreach (var i in list)
                            {
                                data.Add(i);
                            }
                        }
                    }
                    else
                    {
                        var list = BetByGame(idGame, idPeriod, side, "SPREAD");
                        if (list != null && list.Count > 0)
                        {
                            foreach (var i in list)
                            {
                                data.Add(i);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                data = null;
                throw new Exception(ex.Message);
            }
            finally
            {
                parameters.Clear();
            }

            return(data);
        }
示例#8
0
        public ObservableCollection <csLine> BetByGame(int idGame, int period, string s, string type)
        {
            ObservableCollection <csLine> data       = new ObservableCollection <csLine>();
            ObservableCollection <csLine> BetListAux = new ObservableCollection <csLine>();

            csLine line = null;
            string side = ((type == "MONEY" || type == "SPREAD") && s == "V") ? "VISITOR" : "NONE";

            side = ((type == "MONEY" || type == "SPREAD") && s == "H") ? "HOME" : side;
            side = ((type == "TOTAL") && s == "V") ? "OVER" : side;
            side = ((type == "TOTAL") && s == "H") ? "UNDER" : side;
            side = (type == "DRAW") ? "DRAW" : side;

            int play = 0;

            if (type == "SPREAD")
            {
                if (s == "V")
                {
                    play = 0;
                }
                else
                {
                    play = 1;
                }
            }
            else if (type == "MONEY")
            {
                if (s == "V")
                {
                    play = 4;
                }
                else
                {
                    play = 5;
                }
            }
            else if (type == "TOTAL")
            {
                if (s == "V")
                {
                    play = 2;
                }
                else
                {
                    play = 3;
                }
            }
            else
            {
                play = 6;
            }

            try
            {
                parameters.Clear();
                parameters.Add("@pIdGame", idGame);
                parameters.Add("@pPlay", play);
                dataset = csG8Apps.ExecutePA("[dbo].[web_betsByGame]", parameters);;

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow fila in dataset.Tables[0].Rows)
                    {
                        line = new csLine();
                        DateTime dt = Convert.ToDateTime(fila["PlacedDate"]);
                        line.Juice     = Convert.ToInt32(fila["Odds"]);
                        line.Line      = Convert.ToDouble(fila["Points"]);
                        line.IdWager   = Convert.ToInt32(fila["IdWager"]);
                        line.Casino    = -1;
                        line.Player    = fila["Player"].ToString();
                        line.WagerPlay = fila["WagerPlay"].ToString().ToUpper();
                        line.Risk      = Convert.ToDouble(fila["RiskAmount"]);
                        line.WagerType = fila["WAGERTYPE"].ToString();
                        line.Time      = CastTime(dt);
                        if (line.WagerPlay.Contains("TOTAL"))
                        {
                            line.Line = Math.Abs(Convert.ToInt32(line.Line));
                        }
                        line = CastDate(line, dt);
                        data.Add(line);
                    }


                    if (data != null)
                    {
                        List <int> Enteros = new List <int>();
                        foreach (var i in data)
                        {
                            if (!i.WagerType.ToUpper().Contains("STRAIGHT"))
                            {
                                if (!Enteros.Contains(Convert.ToInt32(i.IdWager)))
                                {
                                    Enteros.Add(Convert.ToInt32(i.IdWager));
                                    BetListAux.Add(i);
                                }
                            }
                            else
                            {
                                BetListAux.Add(i);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                data = null;
                throw new Exception(ex.Message);
            }
            finally
            {
                parameters.Clear();
            }

            return(BetListAux);
        }
示例#9
0
    void CheckForSkewLines(csLine line, csLine other)
    {
        if (line.Endpoint0 == other.Endpoint0
            || line.Endpoint0 == other.Endpoint1
            || line.Endpoint1 == other.Endpoint0
            || line.Endpoint1 == other.Endpoint1)
            return;
        var nLine = line.Normal;
        nLine = Vector3.Normalize(nLine);
        var nOther = line.Normal;
        nOther = Vector3.Normalize(nOther);
        var dot = Vector3.Dot(nLine, nOther);
        //if (dot >= 0) return; // If normals are at less than 90 degrees to each other, they are not facing each other
        var lSl = line.Endpoint1 - line.Endpoint0;
        var oSl = other.Endpoint1 - other.Endpoint0;
        line.CloseLines.Add(other);
        other.CloseLines.Add(line);
        var d = 100000f;
        #region parallel
        if (Mathf.Abs(lSl.x) == 0 && Mathf.Abs(oSl.x) == 0) // parallel to x
        {
                d = Mathf.Abs(line.Endpoint0.x - other.Endpoint0.x);
        }
        else if (Mathf.Abs(lSl.z) == 0 && Mathf.Abs(oSl.z) == 0) // parallel to z
        {
                d = Mathf.Abs(line.Endpoint0.z - other.Endpoint0.z);
        }
        #endregion
        else
        {
            var lNorm = line.Normal;
            var oNorm = other.Normal;
            var lMag = Vector3.SqrMagnitude(lNorm);
            var oMag = Vector3.SqrMagnitude(oNorm);
            var denom = lMag * oMag;
            var numer = Vector3.Dot(lNorm, oNorm);
            var theta = Mathf.Acos(numer / denom);
            theta = (theta / (2 * Mathf.PI)) * 360f;
            if (theta < 90 || theta > 270) return;
            var diff = line.Endpoint0 - other.Endpoint0;
            var sCheck1Constant = diff.x / oSl.x;
            var sCheck2Constant = diff.y / oSl.y;
            var sCheck1Slope = lSl.x / oSl.x;
            var sCheck2Slope = lSl.y / oSl.y;
            var constant = sCheck1Constant - sCheck2Constant;
            var slope = sCheck1Slope - sCheck2Slope;
            var t = (-constant) / slope;
            var s = diff.x + t * oSl.z;
            if (t < 0) t = 0;
            if (t > 1) t = 1;
            if (s < 0) s = 0;
            if (s > 1) s = 1;
            d = Vector3.Distance(line.Endpoint0 + t * lSl, other.Endpoint0 + s * oSl);
        }

        if (d > 0.0001f && d< line.WallThickness)
        {
            line.WallThickness = d;
            line.Closest = other;
        }
        if (d > 0.0001f && d < other.WallThickness)
        {
            other.WallThickness = d;
            other.Closest = line;
        }
    }
示例#10
0
    float CheckForParallelLines(csLine line, csLine other, float min)
    {
        var lineLength = Vector3.Distance(line.Endpoint0, line.Endpoint1);
        var otherLength = Vector3.Distance(other.Endpoint0, other.Endpoint1);
        if (line.Endpoint0.z == line.Endpoint1.z) // Moves In X
        {
            if (other.Endpoint0.z == other.Endpoint1.z) // Both Move In X
            {
                if (lineLength >= otherLength)
                {
                    if (other.Endpoint0.x <= line.Endpoint0.x && other.Endpoint0.x >= line.Endpoint1.x
                        || other.Endpoint0.x >= line.Endpoint0.x && other.Endpoint0.x <= line.Endpoint1.x
                        || other.Endpoint1.x <= line.Endpoint0.x && other.Endpoint1.x >= line.Endpoint1.x
                        || other.Endpoint1.x >= line.Endpoint0.x && other.Endpoint1.x <= line.Endpoint1.x) // Check that endpoints are within  x range
                    {
                        if (Mathf.Abs(line.Endpoint0.z - other.Endpoint0.z) < min)
                        {
                            min = Mathf.Abs(line.Endpoint0.z - other.Endpoint0.z);
                            line.CloseLines.Add(other);
                            line.Closest = other;
                            line.WallThickness = min;
                            other.CloseLines.Add(line);
                            other.Closest = other;
                            other.WallThickness = min;
                        }
                    }
                }
                else
                if (line.Endpoint0.x <= other.Endpoint0.x && line.Endpoint0.x >= other.Endpoint1.x
                        || line.Endpoint0.x >= other.Endpoint0.x && line.Endpoint0.x <= other.Endpoint1.x
                        || line.Endpoint1.x <= other.Endpoint0.x && line.Endpoint1.x >= other.Endpoint1.x
                        || line.Endpoint1.x >= other.Endpoint0.x && line.Endpoint1.x <= other.Endpoint1.x) // Check that endpoints are within  x range
                {
                    if (Mathf.Abs(line.Endpoint0.z - other.Endpoint0.z) < min)
                    {
                        min = Mathf.Abs(line.Endpoint0.z - other.Endpoint0.z);
                        line.CloseLines.Add(other);
                        line.Closest = other;
                        line.WallThickness = min;
                        other.CloseLines.Add(line);
                        other.Closest = other;
                        other.WallThickness = min;
                    }
                }
            }
        }

        if (line.Endpoint0.x == line.Endpoint1.x) // Moves In Z
        {
            if (other.Endpoint0.x == other.Endpoint1.x) // Both Move In Z
            {
                if (lineLength >= otherLength)
                {
                    if (other.Endpoint0.z <= line.Endpoint0.z && other.Endpoint0.z >= line.Endpoint1.z
                        || other.Endpoint0.z >= line.Endpoint0.z && other.Endpoint0.z <= line.Endpoint1.z
                        || other.Endpoint1.z <= line.Endpoint0.z && other.Endpoint1.z >= line.Endpoint1.z
                        || other.Endpoint1.z >= line.Endpoint0.z && other.Endpoint1.z <= line.Endpoint1.z) // Check that endpoints are within  Z range
                    {
                        if (Mathf.Abs(line.Endpoint0.x - other.Endpoint0.x) < min)
                        {
                            min = Mathf.Abs(line.Endpoint0.x - other.Endpoint0.x);
                            line.CloseLines.Add(other);
                            line.Closest = other;
                            line.WallThickness = min;
                            other.CloseLines.Add(line);
                            other.Closest = other;
                            other.WallThickness = min;
                        }
                    }
                }
                else
                if (line.Endpoint0.z <= other.Endpoint0.z && line.Endpoint0.z >= other.Endpoint1.z
                        || line.Endpoint0.z >= other.Endpoint0.z && line.Endpoint0.z <= other.Endpoint1.z
                        || line.Endpoint1.z <= other.Endpoint0.z && line.Endpoint1.z >= other.Endpoint1.z
                        || line.Endpoint1.z >= other.Endpoint0.z && line.Endpoint1.z <= other.Endpoint1.z) // Check that endpoints are within  Z range
                {
                    if (Mathf.Abs(line.Endpoint0.x - other.Endpoint0.x) < min)
                    {
                        min = Mathf.Abs(line.Endpoint0.x - other.Endpoint0.x);
                        line.CloseLines.Add(other);
                        line.Closest = other;
                        line.WallThickness = min;
                        other.CloseLines.Add(line);
                        other.Closest = other;
                        other.WallThickness = min;
                    }
                }
            }
        }
        return min;
    }
示例#11
0
    //get lines
    public ObservableCollection <csLine> LoadLine(int leagueId, long Last, string idSport)
    {
        //prop list
        ObservableCollection <csLine> LineList = new ObservableCollection <csLine>();

        try
        {
            HttpClient cli      = new HttpClient();
            var        authInfo = Convert.ToBase64String(Encoding.Default.GetBytes("testalfa:test123"));
            cli.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo);
            cli.BaseAddress = new Uri("https://api.pinnacle.com/v1/odds/special?sportid=" + idSport + "&leagueids=" + leagueId + "&since=" + Last);
            HttpResponseMessage res = cli.GetAsync("").Result;
            string contenido        = res.Content.ReadAsStringAsync().Result;

            csLine line = null;



            var results = JObject.Parse(contenido);

            var specials = results["leagues"][0]["specials"].ToList();
            for (int i = 0; i < specials.Count; i++)
            {
                if (results["leagues"][0]["specials"][i]["contestantLines"].ToList().Count == 2)
                {
                    var Special = results["leagues"][0]["specials"][i].ToList();
                    var Line1   = results["leagues"][0]["specials"][i]["contestantLines"][0].ToList();
                    var Line2   = results["leagues"][0]["specials"][i]["contestantLines"][1].ToList();

                    if (Reemplace(Line1[2].ToString()).Replace("price:", "").Trim() != "null" ||
                        Reemplace(Line2[2].ToString()).Replace("price:", "").Trim() != "null")
                    {
                        line           = new csLine();
                        line.specialID = Convert.ToInt32(Reemplace(Special[0].ToString()).Replace("id:", "").Trim());
                        line.MaxBet    = Convert.ToInt32(Convert.ToDouble(Reemplace(Special[1].ToString()).Replace("maxBet:", "").Trim()));
                        line.price1    = Convert.ToInt32(Convert.ToDouble(Reemplace(Line1[2].ToString()).Replace("price:", "").Trim()));

                        if (Reemplace(Line1[3].ToString()).Replace("handicap:", "").Trim() != "null")
                        {
                            line.handicap1 = Convert.ToDouble(Reemplace(Line1[3].ToString()).Replace("handicap:", "").Trim());
                        }
                        else
                        {
                            line.handicap1 = null;
                        }
                        if (Reemplace(Line2[3].ToString()).Replace("handicap:", "").Trim() != "null")
                        {
                            line.handicap2 = Convert.ToDouble(Reemplace(Line2[3].ToString()).Replace("handicap:", "").Trim());
                        }
                        else
                        {
                            line.handicap2 = null;
                        }

                        line.price2 = Convert.ToInt32(Convert.ToDouble(Reemplace(Line2[2].ToString()).Replace("price:", "").Trim()));
                        LineList.Add(line);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            return(null);
        }

        return(LineList);
    }
示例#12
0
    public void getZLines()
    {
        foreach (var layer in layers)
        {
            var inc = 1 / sloxelResolution.z;
            var left = Mathf.Floor(layer.Value.Min.z * sloxelResolution.z) / sloxelResolution.z;
            var right = Mathf.Ceil(layer.Value.Max.z * sloxelResolution.z) / sloxelResolution.z;
            for (float z = left; z <= right; z += inc)
            {
                foreach (var line in layer.Value.border)
                {
                    csLine newLine;
                    var ep0 = line.Endpoint0;
                    var ep1 = line.Endpoint1;
                    bool passes = false;
                    if ((ep0.z <= z && ep1.z >= z)
                        || (ep1.z <= z && ep0.z >= z))
                        passes = true;
                    if (!passes) continue;
                    if (ep0.z == z && ep1.z == z)
                    {
                        newLine = new csLine(ep0, ep1, line.Normal);
                        newLine.WallThickness = line.WallThickness;
                    }
                    else
                    {
                        newLine = null;
                        foreach (var other in layer.Value.border)
                        {
                            if (other == line) continue;
                            bool otherPasses = false;
                            if ((other.Endpoint0.z <= z && other.Endpoint1.z >= z)
                            || (other.Endpoint1.z <= z && other.Endpoint0.z >= z))
                                otherPasses = true;
                            if (!otherPasses) continue;

                            var p1 = GetZIntersectionPoint(line.Endpoint0, line.Endpoint1, z);
                            var p2 = GetZIntersectionPoint(other.Endpoint0, other.Endpoint1, z);
                            if (newLine == null || (Vector3.Magnitude(p1 - p2) > Vector3.Magnitude(newLine.Endpoint0 - newLine.Endpoint1)))
                            {
                                newLine = new csLine(p1, p2, new Vector3(0, 0, 1));
                                newLine.WallThickness = Mathf.Min(line.WallThickness, other.WallThickness);
                            }
                        }
                    }
                    if (newLine != null)
                        layer.Value.zLines.Add(newLine);
                }
            }
        }
    }
示例#13
0
    public void getXLines()
    {
        foreach (var layer in layers)
        {
            var inc = 1 / sloxelResolution.x;
            var left = Mathf.Floor(layer.Value.Min.x * sloxelResolution.x) / sloxelResolution.x;
            var right = Mathf.Ceil(layer.Value.Max.x * sloxelResolution.x) / sloxelResolution.x;
            for (float x = left; x <= right; x+= inc)
            {
                foreach (var line in layer.Value.border)
                {
                    csLine newLine;
                    var ep0 = line.Endpoint0;
                    var ep1 = line.Endpoint1;
                    bool passes = false;
                    if ((ep0.x <= x && ep1.x >= x)
                        || (ep1.x <= x && ep0.x >= x))
                        passes = true;
                    if (!passes) continue;
                    if (ep0.x == x && ep1.x == x)
                    {
                        newLine = new csLine(ep0, ep1, line.Normal);
                        newLine.WallThickness = line.WallThickness;
                        layer.Value.xLines.Add(newLine);
                    }
                    else
                    {
                        foreach (var other in layer.Value.border)
                        {
                            if (other == line) continue;
                            bool otherPasses = false;
                            if ((other.Endpoint0.x <= x && other.Endpoint1.x >= x)
                            || (other.Endpoint1.x <= x && other.Endpoint0.x >= x))
                                otherPasses = true;
                            if (!otherPasses) continue;

                            var p1 = GetXIntersectionPoint(line.Endpoint0, line.Endpoint1, x);
                            var p2 = GetXIntersectionPoint(other.Endpoint0, other.Endpoint1, x);
                            newLine = new csLine(p1, p2, new Vector3(1, 0, 0));
                            newLine.WallThickness = Mathf.Min(line.WallThickness, other.WallThickness);
                            layer.Value.xLines.Add(newLine);
                        }
                    }
                }
            }
        }
    }