public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, [CosmosDB( Constants.DATABASE_NAME, Constants.USERS_COLLECTION, ConnectionStringSetting = Constants.DATABASE_CONNECTION_STRING_SETTING)] DocumentClient client, ILogger log) { var ids = req.Query["ids"]; if (string.IsNullOrWhiteSpace(ids)) { return(new NotFoundResult()); } var min = req.Query["min"]; var max = req.Query["max"]; var world = req.Query["world"]; var userIds = ids.First().Split(','); var collectionUri = UriFactory.CreateDocumentCollectionUri(Constants.DATABASE_NAME, Constants.USERS_COLLECTION); //https://stackoverflow.com/questions/46170004/net-c-sharp-cross-partition-query-is-required-but-disabled-trouble-on-docum var feedOptions = new FeedOptions { EnableCrossPartitionQuery = true }; var query = client.CreateDocumentQuery <User>(collectionUri, feedOptions) .Where(x => userIds.Contains(x.Id)) .AsDocumentQuery(); var users = new List <User>(); while (query.HasMoreResults) { foreach (User user in await query.ExecuteNextAsync <User>()) { users.Add(user); } } var pendingRoutes = RoutesManager.GetPendingRoutes(users); if (!string.IsNullOrWhiteSpace(min)) { pendingRoutes = pendingRoutes.Where(x => x.Distance > int.Parse(min.First()) * 1000).ToList(); } if (!string.IsNullOrWhiteSpace(max)) { pendingRoutes = pendingRoutes.Where(x => x.Distance < int.Parse(max.First()) * 1000).ToList(); } if (!string.IsNullOrWhiteSpace(world)) { pendingRoutes = pendingRoutes.Where(x => x.World.Equals(world.First(), StringComparison.InvariantCultureIgnoreCase)).ToList(); } return(new OkObjectResult(pendingRoutes)); }
public static RouteInfo FindRoute(int from, int to) { //define the route RouteInfo route = new RouteInfo(); route.Towns = new System.Collections.Generic.List <int>(); int totalLength = 0; int start = from < to ? from : to; int end = from < to ? to : from; route.Towns.Add(start); int currentPosition = start; int minEvristic = RoutesManager.INFINITY; int stepTo = RoutesManager.INFINITY; int lengthToNext = 0; do { //interates on the adjacency matirx for (int i = 0; i < RoutesManager.Length; i++) { //the route is exist if (RoutesManager.AdjacencyMatrix[currentPosition, i] != 0) { if (minEvristic > RoutesManager.GetEvristic(i, end)) { minEvristic = RoutesManager.GetEvristic(i, end); stepTo = i; lengthToNext = RoutesManager.AdjacencyMatrix[currentPosition, i]; } } } //if we dont have a way if (stepTo == RoutesManager.INFINITY) { throw new System.EntryPointNotFoundException("Route is not exist"); } //add to the points route.Towns.Add(stepTo); //move to the next currentPosition = stepTo; stepTo = 0; totalLength += lengthToNext; }while (currentPosition != end); route.Length = totalLength; return(route); }
private void Awake() { if (Instance != null) { DestroyImmediate(gameObject); return; } Instance = this; DontDestroyOnLoad(gameObject); Routes = GetChilds(); }
public void Configuration(IAppBuilder app) { var configuration = new HttpConfiguration(); // enable logging configuration.Filters.Add(new DiagnosticsFilterAttribute()); // Web API configuration and services // CORS Attribute configuration.EnableCors(CorsManager.CorsAttribute()); // Ensure HTTPS over TLS 1.2 for External and Prod SecurityProtocolManager.SetSecurityProtocol(); // Set application specific Json Serialization settings SerializerManager.ApplyCustomSettings(configuration.Formatters); // Web API routes and application routes RoutesManager.AddRoutes(configuration); // Owin level exception handling app.Use <GlobalExceptionMiddleware>(); // IoC and DI configuration configuration.DependencyResolver = ConfigureIocResolver(); // Middleware for properties stored on the LogicalThreadContext for log4net and other purposes app.Use <RequestMetadataMiddleware>(); var authMiddleware = (AuthMiddleware)configuration.DependencyResolver.GetService(typeof(IAuthMiddleware)); app.Use(async(context, next) => { await authMiddleware.Invoke(context, next); }); // Global exception handler for AC errors configuration.Filters.Add(new MgiExceptionFilter()); // Filter to add custom headers to the response configuration.Filters.Add(new HeaderFilter()); AwMapper.Configure(); // Web API documentation configuration // Web API documentation for environments that have ApiDocumentation app key set to true var keyName = "ApiDocumentation"; var apiDocKeyExists = ConfigurationManager.AppSettings.AllKeys.Contains(keyName); if (apiDocKeyExists && bool.Parse(ConfigurationManager.AppSettings[keyName])) { ApiDocumentationManager.Configure(configuration); } app.UseWebApi(configuration); }
public static IApplicationBuilder UseCustomizedMvc(this IApplicationBuilder app) { app.UseMvc(routes => { routes.Routes.Add(new UrlSlugRoute(routes.DefaultHandler)); RoutesManager.RegisterRoutes(routes); routes.MapRoute("Default", "{controller=Home}/{action=Index}/{id?}"); }); return(app); }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // Регистрируем роуты RoutesManager.RegisterActionRoutes(); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional } ); }
internal LocalizableItemsExtractor(string sourceDir, string destDir, ValidateLocalizableExtractor validator, IEnumerable <string> cultures) { _routesManager = new RoutesManager(sourceDir, destDir); _cultures = cultures; _validator = validator; }
internal ValidateLocalizableExtractor(string originalExtractPath, string actualExtractPath) { _routesManager = new RoutesManager(originalExtractPath, actualExtractPath); }
internal OriginalLocalizableItemsExtractor(string sourceDirPath, string destinationDirPath) { _routesManager = new RoutesManager(sourceDirPath, destinationDirPath); }
public void GetPendingRoutes_OK() { #region Routes var route1 = new Route { Id = "1" }; var route2 = new Route { Id = "2" }; var route3 = new Route { Id = "3" }; var route4 = new Route { Id = "4" }; #endregion var user1 = new User { PendingRoutes = new RoutesList() { route1, route2 } }; var user2 = new User { PendingRoutes = new RoutesList() { route1, route2, route3 } }; var user3 = new User { PendingRoutes = new RoutesList() { route2, route3, route4 } }; var pendingRoutes = RoutesManager.GetPendingRoutes(new List <User> { user1, user2, user3 }); pendingRoutes.Count.Should().Be.EqualTo(1); pendingRoutes.First().Id.Should().Be.EqualTo("2"); }
public static async Task <List <Route> > GetRoutesToUpsertAsync(IEnumerable <Route> existingRoutes) { var sourceRoutes = await new RoutesScrapper().GetDataAsync(); return(RoutesManager.GetRoutesToUpdate(existingRoutes.ToList(), sourceRoutes)); }
public LocalizableItemsMerger(string sourceDir, string destDir) { _routesManager = new RoutesManager(sourceDir, destDir); }