Esempio n. 1
0
        public bool TryGetCustomOutline(IDriverInfo driverInfo, out ColorDto outlineColor)
        {
            bool driverHasCustomOutline = _driverPresentationsManager.TryGetDriverPresentation(driverInfo.DriverName, out DriverPresentationDto driverPresentationDto);

            outlineColor = driverPresentationDto?.OutLineColor;
            return(driverHasCustomOutline && driverPresentationDto?.CustomOutLineEnabled == true);
        }
Esempio n. 2
0
        public ActionResult AddDriver(IDriverInfo driverInfo)
        {
            PersonAccountDA account       = GetPersonAccount(driverInfo);
            DriverAccountDA driverAccount = new DriverAccountDA
            {
                Person     = account,
                PersonName = driverInfo.PersonName,
                CarBrand   = driverInfo.CarBrand,
                CarColor   = driverInfo.CarColor,
                CarNumber  = driverInfo.CarNumber
            };
            DriverInfoDA driver = new DriverInfoDA
            {
                PersonInfo = new PersonInfoDA
                {
                    Latitude  = driverInfo.CurrentLocationLatidude,
                    Longitude = driverInfo.CurrentLocationLongidude,
                    Person    = account
                }
            };

            _dataProxy.Session.Save(driver.PersonInfo);
            _dataProxy.Session.Save(driverAccount);
            _dataProxy.Session.Save(driver);
            return(ActionResult.ValidResult);
        }
Esempio n. 3
0
        public bool IsDriverLastSectorPurple(IDriverInfo driver, int sectorNumber)
        {
            if (driver?.DriverName == null)
            {
                return(false);
            }
            DriverTiming timing;

            lock (_lockObject)
            {
                if (!_driverNameTimingMap.TryGetValue(driver.DriverName, out timing))
                {
                    return(false);
                }
            }

            switch (sectorNumber)
            {
            case 1:
                return(timing.IsLastSector1SessionBest);

            case 2:
                return(timing.IsLastSector2SessionBest);

            case 3:
                return(timing.IsLastSector3SessionBest);

            default:
                return(false);
            }
        }
Esempio n. 4
0
 private DriverLogic CreateDriverLogic(IDriverInfo personSLO)
 {
     return(new DriverLogic(new DriverModel(personSLO)
     {
         PersonId = personSLO.PersonId
     }, _adaptersExtender, _city));
 }
Esempio n. 5
0
 internal DriverModel(IDriverInfo info)
     : base(info)
 {
     _personName = info.PersonName;
     _carColor   = info.CarColor;
     _carBrand   = info.CarBrand;
     _carNumber  = info.CarNumber;
 }
Esempio n. 6
0
        public DriverDataContract AuthenticateAsDriver(DriverAuthenticationRequestDataContract request)
        {
            IDriverInfo driverInfo = _server.CreateDriverInfo();

            ConvertHelper.FillDriverAuthenticationRequestInfo(driverInfo, request);
            _server.AuthenticateAsDriver(driverInfo, request.CityId);
            return(ConvertHelper.CreateDriverDataContract(driverInfo));
        }
Esempio n. 7
0
        protected override double GetX(IDriverInfo driver)
        {
            double lapLength = LastDataSet.SessionInfo.TrackInfo.LayoutLength.InMeters;
            double degrees   = (driver.LapDistance / lapLength) * 2 * Math.PI - Math.PI / 2;
            double x         = (ActualWidth / 2) * Math.Cos(degrees);

            return(double.IsNaN(x) ? 0 : x);
        }
Esempio n. 8
0
        protected virtual void OnDriverInfoChanged(IDriverInfo driverInfo)
        {
            EventHandler <ValueEventArgs <IDriverInfo> > handler = DriverInfoChanged;

            if (handler != null)
            {
                handler(this, new ValueEventArgs <IDriverInfo>(driverInfo));
            }
        }
Esempio n. 9
0
        public void AuthenticateAsDriver(IDriverInfo driverInfo, Guid cityId)
        {
            CityLogic city = _cities.Items.FirstOrDefault(c => c.Info.Id == cityId);

            if (city != null)
            {
                city.ModifyDriversCollection(col => col.Add(driverInfo));
            }
        }
Esempio n. 10
0
        public void PushPedestrianRequest(PedestrianRequestDataContract request)
        {
            IPedestrianInfo pedestrian = _server.Cities.SelectMany(c => c.Pedestrians).FirstOrDefault(p => p.Id == request.PedestrianId);
            IDriverInfo     driver     = _server.Cities.SelectMany(c => c.Drivers).FirstOrDefault(d => d.Id == request.DriverId);

            if (pedestrian != null && driver != null)
            {
                IPedestrianRequestInfo requestInfo = _server.CreatePedestrianRequestInfo(pedestrian, driver);
                ConvertHelper.FillPedestrianRequestInfo(requestInfo, request);
                _server.PushPedestrianRequestInfo(requestInfo);
            }
        }
Esempio n. 11
0
        public ActionResult RemoveDriver(IDriverInfo driverInfo)
        {
            DriverInfoDA data = _dataProxy.Session.CreateCriteria <DriverInfoDA>().List <DriverInfoDA>().FirstOrDefault(p => p.PersonInfo.Person.Id == driverInfo.Id);

            if (data == null)
            {
                return(ActionResult.GetErrorResult(new KeyNotFoundException()));
            }
            _dataProxy.Session.Delete(data);
            _dataProxy.Session.Delete(data.PersonInfo);
            return(ActionResult.ValidResult);
        }
Esempio n. 12
0
 public static DriverDataContract CreateDriverDataContract(IDriverInfo driverInfo)
 {
     return(new DriverDataContract
     {
         PersonId = driverInfo.Id,
         PhoneNumber = driverInfo.PhoneNumber,
         SkypeNumber = driverInfo.SkypeNumber,
         CarColor = driverInfo.CarColor,
         CurrentLocationLatidude = driverInfo.CurrentLocationLatidude,
         CurrentLocationLongitude = driverInfo.CurrentLocationLongidude,
         IsOnline = driverInfo.IsOnline
     });
 }
Esempio n. 13
0
        protected override double GetY(IDriverInfo driver)
        {
            double lapLength = LastDataSet.SessionInfo.TrackInfo.LayoutLength.InMeters;
            double degrees   = ((driver.LapDistance / lapLength) * 2 * Math.PI) - (Math.PI / 2);
            double y         = (ActualHeight / 2) * Math.Sin(degrees);

            if (driver.InPits)
            {
                y += 30;
            }

            return(double.IsNaN(y) ? 0 : y);
        }
        protected override ProfileLogic CreateProfileLogic(IPersonInfo personInfo)
        {
            IDriverInfo driverInfo = (IDriverInfo)personInfo;

            return(new DriverProfileLogic(new DriverProfileModel(_city.Model.Map)
            {
                SkypeNumber = personInfo.SkypeNumber,
                PhoneNumber = personInfo.PhoneNumber,
                PersonName = driverInfo.PersonName,
                CarColor = driverInfo.CarColor,
                CarBrand = driverInfo.CarBrand,
                CarNumber = driverInfo.CarNumber
            }, _adaptersExtender, _city));
        }
Esempio n. 15
0
        public bool TryGetCustomOutline(IDriverInfo driverInfo, out ColorDto outlineColor)
        {
            if (driverInfo?.DriverName == null)
            {
                outlineColor = null;
                return(false);
            }
            DriverTimingViewModel viewModel;

            lock (DriversViewModels)
            {
                viewModel = DriversViewModels.FirstOrDefault(x => x.Name == driverInfo.DriverName);
            }

            outlineColor = viewModel?.OutLineColor;
            return(viewModel?.HasCustomOutline ?? false);
        }
Esempio n. 16
0
        public bool IsDriverOnValidLap(IDriverInfo driver)
        {
            if (driver?.DriverName == null)
            {
                return(false);
            }

            lock (_lockObject)
            {
                if (_driverNameTimingMap.TryGetValue(driver.DriverName, out DriverTiming timing))
                {
                    return(timing.CurrentLap?.Valid ?? false);
                }
            }

            return(false);
        }
Esempio n. 17
0
        public Int32 getClassLivePosition(IDriverInfo driver)
        {
            IEnumerable <StandingsItem> query = this.Standings.Where(s => s.Driver.CarClassName == driver.CarClassName).OrderBy(s => s.PositionLive);
            Int32 position = 1;

            foreach (StandingsItem si in query)
            {
                if (si.Driver.CarIdx == driver.CarIdx)
                {
                    return(position);
                }
                else
                {
                    position++;
                }
            }
            return(0);
        }
Esempio n. 18
0
        public IEnumerable <IDriverInfo> EnumerateDrivers(Guid cityId)
        {
            IList <DriverAccountDA> accounts = _dataProxy.Session.CreateCriteria <DriverAccountDA>().List <DriverAccountDA>();
            IList <DriverInfoDA>    drivers  = _dataProxy.Session.CreateCriteria <DriverInfoDA>() /*.Add(Restrictions.Where<DriverInfoDA>(p => p.PersonInfo.City.Id == cityId))*/.List <DriverInfoDA>();

            foreach (var info in accounts.Join(drivers, account => account.Person.Id, driver => driver.PersonInfo.Person.Id,
                                               (account, driver) => new { AccountInfo = account, DriverInfo = driver }).Where(i => i.DriverInfo.PersonInfo.City.Id == cityId).ToArray())
            {
                IDriverInfo driverInfo = _server.CreateDriverInfo(info.AccountInfo.Person.Id);
                driverInfo.PhoneNumber              = info.AccountInfo.Person.PhoneNumber;
                driverInfo.SkypeNumber              = info.AccountInfo.Person.SkypeNumber;
                driverInfo.CurrentLocationLatidude  = info.DriverInfo.PersonInfo.Latitude;
                driverInfo.CurrentLocationLongidude = info.DriverInfo.PersonInfo.Longitude;
                driverInfo.PersonName = info.AccountInfo.PersonName;
                driverInfo.CarColor   = info.AccountInfo.CarColor;
                driverInfo.CarBrand   = info.AccountInfo.CarBrand;
                driverInfo.CarNumber  = info.AccountInfo.CarNumber;
                yield return(driverInfo);
            }
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** CoCar Client App *****");

            // Create the COM class using early binding.
            CoCar myCar = new CoCar();

            // Handle the BlewUp event.
            myCar.BlewUp += new __CoCar_BlewUpEventHandler(myCar_BlewUp);

            // Call the Create() method.
            myCar.Create(50, 10, CarType.BMW);

            // Set name of driver.
            IDriverInfo itf = null;

            itf            = (IDriverInfo)myCar;
            itf.DriverName = "Fred";
            Console.WriteLine("Drive is named: {0}", itf.DriverName);

            // Print type of car.
            Console.WriteLine("Your car is a {0}.", myCar.CarMake);
            Console.WriteLine();

            // Get the Engine and print name of a Cylinders.
            Engine eng = myCar.GetEngine();

            Console.WriteLine("Your Cylinders are named:");
            string[] names = (string[])eng.GetCylinders();
            foreach (string s in names)
            {
                Console.WriteLine(s);
            }
            Console.WriteLine();

            // Speed up car to trigger event.
            for (int i = 0; i < 5; i++)
            {
                myCar.SpeedUp();
            }
        }
 public MapViewDriverInfoFacade(IDriverInfo parentInfo, int customPosition, string customName)
 {
     ParentInfo = parentInfo;
     DriverName = customName;
     Position   = customPosition;
 }
Esempio n. 21
0
 public IPedestrianRequestInfo CreatePedestrianRequestInfo(IPedestrianInfo pedestrian, IDriverInfo driver)
 {
     return(new PedestrianRequestInfo(Guid.NewGuid(), driver.Id, pedestrian.Id));
 }
Esempio n. 22
0
 private bool CompareDriversInfo(DriverLogic logic, IDriverInfo slo)
 {
     return(logic.Model.PersonId == slo.PersonId);
 }
Esempio n. 23
0
 public ColorDto GetClassColor(IDriverInfo driverInfo)
 {
     return(_classColorProvider.GetColorForClass(driverInfo.CarClassId));
 }
Esempio n. 24
0
 public Int32 getClassLivePosition(IDriverInfo driver)
 {
     IEnumerable<StandingsItem> query = this.Standings.Where(s => s.Driver.CarClassName == driver.CarClassName).OrderBy(s => s.PositionLive);
     Int32 position = 1;
     foreach (StandingsItem si in query)
     {
         if (si.Driver.CarIdx == driver.CarIdx)
             return position;
         else
             position++;
     }
     return 0;
 }
Esempio n. 25
0
 public IWebDriver Resolve(IDriverInfo driverInfo)
 {
     return(new ChromeDriver());
 }
Esempio n. 26
0
 public static void FillDriverAuthenticationRequestInfo(IDriverInfo driverInfo, DriverAuthenticationRequestDataContract request)
 {
     driverInfo.PhoneNumber = request.PhoneNumber;
     driverInfo.SkypeNumber = request.SkypeNumber;
     driverInfo.CarColor    = request.CarColor;
 }