private static void InsertBaseData(Neo4JClient client) { // Create the base flight data: client.CreateReasons(GetReasons()); Console.WriteLine($"Starting Carriers CSV Import: {csvCarriersFile}"); GetCarriers(csvCarriersFile) // As an Observable: .ToObservable() // Batch in 1000 Entities / or wait 1 Second: .Buffer(TimeSpan.FromSeconds(1), 1000) // Insert when Buffered: .Subscribe(records => { client.CreateCarriers(records); }); Console.WriteLine($"Starting Airports CSV Import: {csvAirportsFile}"); GetAirportInformation(csvAirportsFile) // As an Observable: .ToObservable() // Batch in 1000 Entities / or wait 1 Second: .Buffer(TimeSpan.FromSeconds(1), 1000) // Insert when Buffered: .Subscribe(records => { client.CreateAirports(records); }); }
public async Task Post(/*[FromBody] string value*/) { var service = new MovieDataService(); var settings = ConnectionSettings.CreateBasicAuth(url, username, password); using (var client = new Neo4JClient(settings)) { // Create Indices for faster Lookups: //await client.CreateIndices(); //// Create Base Data: //await client.CreateMovies(service.Movies); //await client.CreatePersons(service.Persons); //await client.CreateGenres(service.Genres); //// Create Relationships: //await client.CreateRelationships(service.Metadatas); //await client.CreateServices(service.Services); //await client.CreateFrontEnds(service.FrontEnds); //await client.CreateDatabases(service.Databases); //await client.CreateRelationships_Service(service.Metadatas_service); //await client.CreateRelationships_Database(service.Metadatas_database); //await client.CreateRelationships_FrontEnd(service.Metadatas_frontend); //await client.CreateServices(service.Services_sc1); //await client.CreateRelationships_Service(service.Metadatas_service_sc1); } }
public JsonResult GetPersons(string movieType, string movieTitle, string personsRelation) { using (var client = new Neo4JClient(settings)) { IList <Person> result = client.GetSpecificPersons(movieType, movieTitle, personsRelation); return(Json(result)); } }
public JsonResult GetMovies() { using (var client = new Neo4JClient(settings)) { IList <Movie> result = client.GetSpecificMovies(null); return(Json(result)); } }
public async Task Index() { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { await client.CreateIndices(); } }
public ActionResult GetDegree() { var settings = ConnectionSettings.CreateBasicAuth(url, username, password); using (var client = new Neo4JClient(settings)) { return(Ok(client.GetDegrees())); } }
public async Task <List <Category> > Index() { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, "neo4j", "admin"); using (var client = new Neo4JClient(settings)) { CategoryService myService = new CategoryService(client); return(await myService.GetAllCategories()); } }
public async Task <List <Like> > Index() { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { LikeService myService = new LikeService(client); return(await myService.getAllLikes()); } }
private static async Task InsertLocalWeatherDataAsync(Neo4JClient client) { // Import 10 Minute CDC Weather Data: var csvWeatherDataFiles = GetFilesFromFolder(@"D:\datasets\CDC"); foreach (var csvWeatherDataFile in csvWeatherDataFiles) { await ProcessLocalWeatherData(client, csvWeatherDataFile); } }
public ActionResult GetPathLengths() { var settings = ConnectionSettings.CreateBasicAuth(url, username, password); using (var client = new Neo4JClient(settings)) { var result = client.GetPathLengths(); return(Ok(result)); } }
public static void Main(string[] args) { var settings = ConnectionSettings.CreateBasicAuth("bolt://localhost:7687/db/flights", "neo4j", "test_pwd"); using (var client = new Neo4JClient(settings)) { // Create Indices for faster Lookups: client.CreateIndices(); // Insert the Base Data (Airports, Carriers, ...): InsertBaseData(client); // Insert the Flight Data: InsertFlightData(client); } }
public async Task <IActionResult> Report(ReportInfo reportInfo) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { ReportService myService = new ReportService(client); string ans = await myService.CreateReport(reportInfo); Response response = new Response { Ans = ans }; return(Created(Neo4JClient.uri, response)); } }
public async Task <List <User> > FilterByCategory(string name) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { Category category = new Category { Name = name }; CategoryService myService = new CategoryService(client); myService.addCategory(category); return(await myService.GetUsers(myService.Categories)); } }
public async Task <List <User> > FilterByLike(string name) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { Like like = new Like { Name = name }; LikeService myService = new LikeService(client); myService.addLike(like); return(await myService.GetUsers(myService.likes)); } }
public async Task <ActionResult> InsertTraces() { var dataService = new MovieDataService(); var settings = ConnectionSettings.CreateBasicAuth(url, username, password); using (var client = _factory.CreateClient()) { //read from json var tracesfromFile = JsonConvert.DeserializeObject <List <List <SpanDto> > >(System.IO.File.ReadAllText("traces.json")); var traces_model = dataService.Create(tracesfromFile); using (var client_2 = new Neo4JClient(settings)) { //delete the existing graph first await client_2.DeleteGraph(); foreach (var trace in traces_model) { //await client_2.CreateServices(trace.services); //await client.CreateFrontEnds(service.FrontEnds); //await client.CreateDatabases(service.Databases); //if (traces_model[0] == trace) // System.IO.File.WriteAllText("traces_1.json", JsonConvert.SerializeObject(trace.serviceinformation)); //if (traces_model[1] == trace) // System.IO.File.WriteAllText("traces_2.json", JsonConvert.SerializeObject(trace.serviceinformation)); //if (traces_model[2] == trace) // System.IO.File.WriteAllText("traces_3.json", JsonConvert.SerializeObject(trace.serviceinformation)); //if (traces_model[3] == trace) // System.IO.File.WriteAllText("traces_4.json", JsonConvert.SerializeObject(trace.serviceinformation)); await client_2.CreateRelationships_Service(trace.serviceinformation); //await client.CreateRelationships_Database(service.Metadatas_database); //await client.CreateRelationships_FrontEnd(service.Metadatas_frontend); //await client.CreateServices(service.Services_sc1); //await client.CreateRelationships_Service(service.Metadatas_service_sc1); } } return(Ok(traces_model)); } }
public async Task <List <Like> > UsersLikes(string id) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { UserService myService = new UserService(client); User auxUser = new User { Id = id }; myService.addUser(auxUser); List <Like> ans = await myService.UsersLikes(myService.Users); return(ans); } }
private static async Task ProcessLocalWeatherData(CancellationToken cancellationToken = default(CancellationToken)) { var settings = ConnectionSettings.CreateBasicAuth("bolt://localhost:7687/db/weather", "neo4j", "test_pwd"); using (var client = new Neo4JClient(settings)) { // Create Indices for faster Lookups: await client.CreateIndicesAsync(); // Insert the Base Data (Airports, Carriers, ...): await InsertStationsAsync(client); // Insert the Flight Data: await InsertLocalWeatherDataAsync(client); } }
public async Task <IActionResult> GetSuggestion(string id) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { User user = new User { Id = id }; UserService aux = new UserService(client); aux.addUser(user); SuggestionService myService = new SuggestionService(client); List <SuggestionInfo> ans = await myService.getSuggestion(aux.Users); return(Ok(ans)); } }
public async Task <bool> ExistLike(string name) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { Like like = new Like { Name = name }; LikeService myService = new LikeService(client); myService.addLike(like); List <bool> ans = await myService.ExistLike(myService.likes); return(ans[0]); } }
public async Task <IActionResult> NewIs(LikeInfo likeInfo) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { LikeService myService = new LikeService(client); myService.addMetadata(likeInfo); string aux = await myService.CreateRelationshipLike(myService.likeInfos); Response ans = new Response() { Ans = aux }; return(Created(Neo4JClient.uri, ans)); } }
public async Task <IActionResult> Deactivate(Suggestion suggestion) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { SuggestionService myService = new SuggestionService(client); myService.addSuggestion(suggestion); string aux = await myService.ChangeIsActive(myService.Suggestions); Response ans = new Response() { Ans = aux }; return(Ok(ans)); } }
public async Task <bool> ExistCategory(string name) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { Category category = new Category { Name = name }; CategoryService myService = new CategoryService(client); myService.addCategory(category); List <bool> ans = await myService.ExistCategory(myService.Categories); return(ans[0]); } }
public async Task <IActionResult> NewCategory(Category category) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, "neo4j", "admin"); using (var client = new Neo4JClient(settings)) { CategoryService myService = new CategoryService(client); myService.addCategory(category); string aux = await myService.CreateCategory(myService.Categories); Response ans = new Response() { Ans = aux }; return(Created(Neo4JClient.uri, ans)); } }
public async Task <IActionResult> NewGather(UserInfo userInfo) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { UserService myService = new UserService(client); myService.addMetadata(userInfo); string aux = await myService.CreateRelationGatherUser(myService.UserInfos); Response ans = new Response() { Ans = aux }; return(Created(Neo4JClient.uri, ans)); } }
private static void InsertFlightData(Neo4JClient client) { // Create Flight Data with Batched Items: foreach (var csvFlightStatisticsFile in csvFlightStatisticsFiles) { Console.WriteLine($"Starting Flights CSV Import: {csvFlightStatisticsFile}"); GetFlightInformation(csvFlightStatisticsFile) // As an Observable: .ToObservable() // Batch in 1000 Entities / or wait 1 Second: .Buffer(TimeSpan.FromSeconds(1), 1000) // Insert when Buffered: .Subscribe(records => { client.CreateFlights(records); }); } }
public static async Task RunAsync(IMovieDataService service) { var settings = ConnectionSettings.CreateBasicAuth("bolt://localhost:7687/db/actors", "neo4j", "test_pwd"); using (var client = new Neo4JClient(settings)) { // Create Indices for faster Lookups: await client.CreateIndices(); // Create Base Data: await client.CreateMovies(service.Movies); await client.CreatePersons(service.Persons); await client.CreateGenres(service.Genres); // Create Relationships: await client.CreateRelationships(service.Metadatas); } }
public ActionResult GetCC() { var settings = ConnectionSettings.CreateBasicAuth(url, username, password); using (var client = new Neo4JClient(settings)) { var result = client.GetCC(); //we omit cc values for nodes in chains by checking null for traceid. It will consider only the main graph nodes //var result2 = result.Where(y => y.GUID == "null").GroupBy(x => x.Name).Select(y => new //{ // //id = y.First().Id, // name = y.First().Name, // cc = y.OrderByDescending(c => c.CC).First().CC //}); var result2 = result.Where(y => y.GUID == "null"); return(Ok(result2)); } }
private static async Task InsertStationsAsync(Neo4JClient client) { // Read the Stations: string csvStationDataFile = @"D:\datasets\CDC\zehn_min_tu_Beschreibung_Stationen.txt"; // Access to the List of Parsers: var batches = Parsers // Use the LocalWeatherData Parser: .StationParser // Read the File: .ReadFromFile(csvStationDataFile, Encoding.UTF8, 1) // Get the Valid Results: .Where(x => x.IsValid) // And get the populated Entities: .Select(x => x.Result) // Let's stay safe! Stop parallelism here: .AsEnumerable() // Evaluate, prefer smaller batches for Neo4j: .Batch(10000) // Go Parallel again: .AsParallel() // As List: .Select(batch => { return(batch // Group by WBAN, Date and Time to avoid duplicates for this batch: .GroupBy(x => new { x.Identifier }) // If there are duplicates then make a guess and select the first one: .Select(x => x.First()) // Convert to Neo4j: .Select(x => LocalWeatherDataConverter.Convert(x)) // And evaluate to prevent multiple iterations: .ToList()); }); foreach (var batch in batches) { // Finally write them with the Batch Writer: await client.CreateStationsAsync(batch); } }
private static async Task ProcessLocalWeatherData(Neo4JClient client, string csvFilePath, CancellationToken cancellationToken = default(CancellationToken)) { Console.WriteLine($"Processing File: {csvFilePath}"); // Access to the List of Parsers: var batches = Parsers // Use the LocalWeatherData Parser: .LocalWeatherDataParser // Read the File: .ReadFromFile(csvFilePath, Encoding.UTF8, 1) // Get the Valid Results: .Where(x => x.IsValid) // And get the populated Entities: .Select(x => x.Result) // Let's stay safe! Stop parallelism here: .AsEnumerable() // Evaluate, prefer smaller batches for Neo4j: .Batch(30000) // Go Parallel again: .AsParallel() // As List: .Select(batch => { return(batch // Group by WBAN, Date and Time to avoid duplicates for this batch: .GroupBy(x => new { x.StationIdentifier, x.TimeStamp }) // If there are duplicates then make a guess and select the first one: .Select(x => x.First()) // Convert to Neo4j: .Select(x => LocalWeatherDataConverter.Convert(x)) // And evaluate to prevent multiple iterations: .ToList()); }); foreach (var batch in batches) { // Finally write them with the Batch Writer: await client.CreateLocalWeatherDataAsync(batch); } }
public async Task <IList <SuggestionInfo> > CreateSuggest(User user) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { SuggestionService myService = new SuggestionService(client); UserService myService2 = new UserService(client); myService2.addUser(user); IList <SuggestionInfo> toReturn = await myService.CreateSuggestedRelation(myService2.Users); UserInfo metadata = new UserInfo { User = user, Suggestions = myService.Suggestions }; myService2.addMetadata(metadata); await myService2.CreateRelationSuggUser(myService2.UserInfos); return(toReturn); } }