Exemplo n.º 1
0
        public void Render(BillettServiceEvent bsEvent, int width = 460, int height = 650)
        {
            var ctrl = new SingleMatch {
                DataContext = _vm = new SingleMatchViewmodel(bsEvent)
            };

            var path = Path.Combine(StautConfiguration.Current.StaticImageDirectory, bsEvent.EventNumber + ".png");

            RenderAndSave(ctrl, path, width, height);
        }
Exemplo n.º 2
0
        public SingleMatchViewmodel(BillettServiceEvent bsEvent)
        {
            Opponent   = bsEvent.Opponent;
            Tournament = CreateTournamentName(bsEvent);

            Location    = bsEvent.Location == "TLD" ? "Lerkendal stadion" : "";
            _matchStart = bsEvent.Start;

            var logoPath = StautConfiguration.Current.LogoDirectory ?? Environment.CurrentDirectory;

            EnemyLogoPath = Path.Combine(logoPath, Opponent.Replace("/", "_") + ".png"); // Helvetes Bodø/Glimt.
            if (!File.Exists(EnemyLogoPath))
            {
                EnemyLogoPath = Path.Combine(logoPath, "NoLogo.png");
            }

            var lastMeasurement = bsEvent.Measurements.LastOrDefault();

            if (lastMeasurement != null)
            {
                SoldTickets            = lastMeasurement.AmountSold;
                SoldSeasonTickets      = lastMeasurement.AmountSeasonTicket;
                ReservedUnknownTickets = lastMeasurement.AmountReserved + lastMeasurement.AmountUnknown;
                TicketsForSale         = lastMeasurement.AmountAvailable;
            }

            LastUpdateTime = bsEvent.Measurements
                             .OrderByDescending(m => m.MeasurementTime)
                             .First()
                             .MeasurementTime;

            var reducedMeasurements = new PointReducer().Reduce(bsEvent.Measurements);

            DataSeries = new ObservableCollection <StautSeries>
            {
                new StautSeries
                {
                    Title  = "Rosenborg - " + bsEvent.Opponent,
                    Start  = bsEvent.Start,
                    Points =
                        new List <StautPoint>(
                            reducedMeasurements
                            .Where(m => m.TotalAmountSold > 0)
                            .Select(
                                m =>
                                new StautPoint
                    {
                        XValue = bsEvent.Start.Subtract(m.MeasurementTime).TotalDays,
                        YValue = m.TotalAmountSold
                    }))
                }
            };
        }
        public IEnumerable <MeasurementFile> GetMeasurements(BillettServiceEvent bsEvent)
        {
            if (!_events.ContainsValue(bsEvent))
            {
                yield break;
            }

            var dir = _events.Single(kvp => kvp.Value == bsEvent).Key;

            var files = Directory.GetFiles(dir, "*.xml", SearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
                yield return(new MeasurementFile(file));
            }
        }
Exemplo n.º 4
0
        public void Render(BillettServiceEvent bsEvent, int width = 460, int height = 650)
        {
            var ctrl = new SingleMatch {
                DataContext = _vm = new SingleMatchViewmodel(bsEvent)
            };

            var path = Path.Combine(StautConfiguration.Current.StaticImageDirectory, bsEvent.EventNumber + ".png");

            Trace.TraceInformation("Rendering {0}x{1} chart for event {2} to {3}", width, height, bsEvent.EventNumber, path);

            var sw = new Stopwatch();

            sw.Start();

            RenderAndSave(ctrl, path, width, height);

            sw.Stop();
            Trace.TraceInformation("Chart render took {0}ms", sw.ElapsedMilliseconds);
        }
Exemplo n.º 5
0
        public string CreateTournamentName(BillettServiceEvent bsEvent)
        {
            var year = bsEvent.Start.Year;

            switch (bsEvent.Tournament)
            {
            case "LEAGUE":
                if (year >= 2017)
                {
                    return("Elite Serien " + year);    // Haw haw haw
                }
                return("Tippeligaen " + year);

            case "NM":
                return("Norgesmesterskapet " + year);

            case "EC":
                return("Europacup");

            default:
                return(String.Empty);
            }
        }
        private BillettServiceEvent CreateTournament()
        {
            var evt = new BillettServiceEvent
            {
                Tournament   = "LEAGUE",
                Opponent     = "Odd",
                Measurements = new List <Measurement>
                {
                    (new Measurement
                    {
                        AmountAvailable = 21667,
                        AmountReserved = 2000,
                        AmountSeasonTicket = 10000,
                        AmountSold = 1000,
                        AmountTicketMaster = 12,
                        AmountUnavailable = 100,
                        AmountUnknown = 100
                    })
                }
            };

            return(evt);
        }
Exemplo n.º 7
0
 public void Store(BillettServiceEvent evt)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 8
0
 public IEnumerable <Measurement> GetForEventAndDateTimes(BillettServiceEvent bsEvent, IEnumerable <DateTime> dateTimes)
 {
     return
         (_context.Measurements.Where(
              m => m.BillettServiceEventId == bsEvent.Id && dateTimes.Contains(m.MeasurementTime)));
 }
Exemplo n.º 9
0
 public void Delete(BillettServiceEvent evt)
 {
     _context.Events.Remove(evt);
     _context.SaveChanges();
 }
Exemplo n.º 10
0
        public void Store(BillettServiceEvent evt)
        {
            _context.Events.Add(evt);

            _context.SaveChanges();
        }
Exemplo n.º 11
0
        public BillettServiceEvent ReadProperties(string file)
        {
            var props = Readfile(file);

            var bsEvent = new BillettServiceEvent {
                Measurements = new List <Measurement>()
            };

            foreach (var prop in props)
            {
                switch (prop.Key)
                {
                case "eventname":
                    bsEvent.DisplayName = prop.Value;
                    break;

                case "eventid":
                    bsEvent.EventNumber = Convert.ToInt32(prop.Value);
                    break;

                case "eventcode":
                    bsEvent.EventCode = prop.Value;
                    break;

                case "location":
                    bsEvent.Location = prop.Value;
                    break;

                case "competition":
                    bsEvent.Tournament = prop.Value;
                    break;

                case "round":
                    bsEvent.Round = Convert.ToInt32(prop.Value);
                    break;

                case "opponent":
                    bsEvent.Opponent = prop.Value;
                    break;

                case "eventdate":
                    bsEvent.Start = DateTime.ParseExact(prop.Value, @"dd\.MM\.yyyy", CultureInfo.InvariantCulture);
                    break;

                case "eventtime":
                    var span = TimeSpan.ParseExact(prop.Value, @"hh\:mm", CultureInfo.InvariantCulture);
                    bsEvent.Start = bsEvent.Start.Add(span);
                    break;

                case "availabilityurl":
                    bsEvent.AvailibilityUrl = prop.Value;
                    break;

                case "geometryurl":
                    bsEvent.GeometryUrl = prop.Value;
                    break;
                }
            }

            return(bsEvent);
        }