Skip to content

Samples

Tomas Fabian edited this page Jan 22, 2021 · 28 revisions

Installation instructions

Prerequesities:

.NET 5.0 or .NET Core 3.x or .NET Framework 4.7.2 https://dotnet.microsoft.com/download

Visual Studio 2019 with ASP.NET and web development

Set (multiple) startup project(s) in Joker.sln/Examples:

  • WPF (NET Core 3.1 and NET Framework 4.72) with EntityChangesViewModel example (Joker.WPF.Sample.csproj). If the OData service is running, you can run multiple WPF instances and all will be refreshed via PubSub after Http POST, PATCH, PUT or DELETE. WPF repository.

  • OData server with SqlTableDependencyRedisProvider and EntityFramework (SelfHostedODataService.csproj) or use docker-compose as the OData startup project (it runs also Sql server and Redis containers).

  • Blazor\Joker.BlazorApp.Sample.csproj is a client side Blazor Web assembly (Wasm). Subscribes to Sql server data changes. It depends on OData service.

  • OData server with SqlTableDependencyRedisProvider and EntityFrameworkCore (SelfHostedODataService.EFCore.csproj)

  • Console app with SqlTableDependencyProvider and SqlTableDependencyRedisProvider (SqlTableDependency.Extensions.Sample.csproj)

  • WinUI 3 in Desktop and UWP Preview 3 can be found in Joker\Samples\WinUI3\Joker.WinUI3.Sample.sln. This solution requires at least .NET 5 and Visual Studio 2019, version 16.9 Preview:

    1. project "Joker.WinUI3.Desktop (Package)"
    2. project "Joker.WinUI3.UWP.Sample (Universal Windows)"
  • Kafka.DotNet.ksqlDB.Sample.csproj - LINQ to ksqldb - DotNet ksql push queries provider

Git

git clone https://github.com/tomasfabian/Joker.git

CD Joker

Docker:

Install Docker:

https://www.docker.com/products/docker-desktop

Set docker-compose as startup project in the Joker.sln or start Joker.OData web service endpoint and its dependencies (SQL Server, Redis) manually:

docker compose build

docker compose up -d

Stop:

docker compose down

Or use the following commands in Powershell or command line:

Run MS SQL Server 2017 latest:

docker run --name sql -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourNewStrong@Passw0rd>" -p 1401:1433 -d mcr.microsoft.com/mssql/server:2017-latest

Test SQL Server:

docker exec -it sql /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1,1433-U SA -P "<YourNewStrong@Passw0rd>"

1> SELECT GETDATE()

2> GO

Run Redis latest:

docker run --name redis-server -p 6379:6379 -d redis

Test redis:

docker run -it --name my-redis-cli --link redis-server:redis --rm redis redis-cli -h redis -p 6379

redis:6379> SET myKey Test

OK

redis:6379> GET myKey

"Test"

Examples Entity Framework migrations:

The Test database with Products table is created automatically at startup or you can create it manually:

Package Manager Console (Default project => Examples\Samples.Data):

Update-Database -ConnectionString "Server=127.0.0.1,1401;User Id = SA;Password=<YourNewStrong@Passw0rd>;Initial Catalog = Test;" -ConnectionProviderName "System.Data.SqlClient" -ProjectName Sample.Data -verbose

Examples Entity Framework Core migrations:

  • set SelfHostedODataService.EFCore.csproj as startup project
  • set package manager console default project to Sample.DataCore
  • PM> Update-Database

OData example with Docker:

docker network create sqlnetwork

docker network ls

docker run --name sqln --network sqlnetwork -v sqldata:/var/opt/mssql -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourNewStrong@Passw0rd>" -p 1402:1433 -d mcr.microsoft.com/mssql/server:2017-latest

docker run --network sqlnetwork --name redis-server -p 6379:6379 -d redis

#dev

docker build -f Dockerfile.dev -t tomasfabian/jokerodatadev .

docker run -it --rm --network sqlnetwork -v ${pwd}:/app -p 3000:80 -e REDISHOST=redis-server -e DBHOST=sqln --name jokerodatadev tomasfabian/jokerodatadev

#release https://hub.docker.com/repository/docker/tomasfabian/jokerodata

#docker build -f Dockerfile -t tomasfabian/jokerodata

docker run -it --rm --network sqlnetwork -p 3000:80 -e REDISHOST=redis-server -e DBHOST=sqln --name jokerodata tomasfabian/jokerodata

Test OData endpoint: http://localhost:3000/Products

#logs

docker exec jokerodata cat logs.txt

docker exec jokerodata grep -i exception logs.txt