Example #1
0
 public RouterTests()
 {
     _RouteDestination1 = new RouteDestination(typeof(FakeClass3), resolutionKey: "key");
     _RouteDestination2 = new RouteDestination(typeof(FakeClass4));
     _Router            = new Router();
     _Router.Register <FakeClass1>("1");
     _Router.Register(typeof(FakeClass2), "2");
     _Router.Register(new RouteSpecification("3"), _RouteDestination1);
     _Router.Register(new RouteSpecification("a", "1"), _RouteDestination2);
 }
        internal Tuple <RouteSpecification, RouteDestination> GetRouteInformation(Type type, string id)
        {
            var typeName = type.Name;

            if (typeName.EndsWith(_PostFix))
            {
                typeName = typeName.Substring(0, typeName.Length - _PostFix.Length);
            }

            var route = string.Format(_Format, typeName, type.Namespace, id);

            if (_LowerPath)
            {
                route = route.ToLower();
            }

            var routeDestination = new RouteDestination(type);

            return(Tuple.Create(new RouteSpecification(route), routeDestination));
        }
Example #3
0
        /// <summary>
        /// Creates a route from a service template and date. Uses a random route name.
        /// </summary>
        private void CreateRoute(DateTime date, ServiceTemplate serviceTemplate, BusinessAccount ownerBusinessAccount, int clientIndex)
        {
            var newRoute = new Route
            {
                Id = Guid.NewGuid(),
                Name = _routeNames.RandomItem(),
                Date = date.Date,
                RouteType = serviceTemplate.Name,
                OwnerBusinessAccount = ownerBusinessAccount,
                CreatedDate = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };

            //Add employees to the Route
            newRoute.Employees.Add(_employeesDesignData.DesignEmployees.FirstOrDefault(e => e.FirstName == "Jon"));

            //Add vehicles to the Route
            newRoute.Vehicles.Add(_vehiclesDesignData.DesignVehicles.RandomItem());

            var orderInRoute = 1;

            var startingClientIndex = clientIndex * 6;

            //Create Services and RouteTasks, add them to the Route
            for (var i = startingClientIndex; i <= (startingClientIndex + 5); i++)
            {
                //Prevents you from trying to add a client that doesnt exist in Design Data
                if (i > _clientsDesignData.DesignClients.Count())
                    break;

                var currentClient = _clientsDesignData.DesignClients.ElementAt(i);

                //Take the first location from the client
                var currentLocation = currentClient.Locations.ElementAt(0);

                var newService = new Service
                {
                    ServiceDate = newRoute.Date,
                    ServiceTemplate = serviceTemplate.MakeChild(ServiceTemplateLevel.ServiceDefined),
                    Client = currentClient,
                    ServiceProvider = ownerBusinessAccount,
                    CreatedDate = DateTime.UtcNow,
                    LastModified = DateTime.UtcNow
                };

                newService.ServiceTemplate.SetDestination(currentLocation);

                var routeTask = new RouteTask
                {
                    OrderInRouteDestination = 1,
                    Date = newRoute.Date,
                    Location = currentClient.Locations.ElementAt(0),
                    Client = currentClient,
                    Name = newRoute.RouteType,
                    EstimatedDuration = new TimeSpan(0, _random.Next(25), 0),
                    OwnerBusinessAccount = ownerBusinessAccount,
                    Service = newService,
                    TaskStatus = ownerBusinessAccount.TaskStatuses.FirstOrDefault(ts => ts.DefaultTypeInt != null && ts.DefaultTypeInt == ((int)StatusDetail.RoutedDefault)),
                    CreatedDate = DateTime.UtcNow,
                    LastModified = DateTime.UtcNow
                };

                var routeDestination = new RouteDestination
                {
                    OrderInRoute = orderInRoute,
                    CreatedDate = DateTime.UtcNow,
                    LastModified = DateTime.UtcNow
                };
                routeDestination.RouteTasks.Add(routeTask);
                newRoute.RouteDestinations.Add(routeDestination);

                orderInRoute++;
            }

            DesignRoutes.Add(newRoute);
        }
Example #4
0
 public IRoute GetRoute(RouteDestination destination, GeoPoint currentlocation)
 {
     return(GetArrivalRoute(currentlocation));
 }