master
Jolys Enzo 2 years ago
commit ae29bef471

@ -0,0 +1,64 @@
kind: pipeline
type: docker
name: default
trigger:
event:
- push
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
volumes:
- name: docs
path: /docs
commands:
- cd Sources/
- dotnet restore ApiSolution.sln
- dotnet build ApiSolution.sln -c Release --no-restore
- dotnet publish ApiSolution.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- name: tests
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- cd Sources/
- dotnet restore ApiSolution.sln
- dotnet test ApiSolution.sln --no-restore
depends_on:
- build
- name: docker-build-and-push
image: plugins/docker
settings:
dockerfile: Sources/Api/Dockerfile
context: Sources/
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/R-Dash/Serveur_R-Dash
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
depends_on:
- tests
when:
branch:
- master
- name: deploy-container
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/R-Dash/Serveur_R-Dash:latest
CONTAINERNAME: R-Dash_Container
COMMAND: create
OVERWRITE: true
ADMINS: enzojolys
depends_on:
- docker-build-and-push
when:
branch:
- master
volumes:
- name: docs
temp: {}

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

162
Sources/.gitignore vendored

@ -0,0 +1,162 @@
build/
*.suo
*.user
_ReSharper.*/
*.sdf
bin/
obj/
Debug/
Release/
*.opensdf
*.tlog
*.log
TestResult.xml
*.VisualState.xml
Version.cs
Version.h
Version.cpp
# Xcode
!**/*.xcodeproj
!**/*.pbxproj
!**/*.xcworkspacedata
!**/*.xcsettings
!**/*.xcscheme
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
**/.xcode.env.local
.expo
.yarn
# Gradle
/build/
/packages/react-native-gradle-plugin/build/
/packages/rn-tester/build
/packages/rn-tester/android/app/.cxx/
/packages/rn-tester/android/app/build/
/packages/rn-tester/android/app/gradle/
/packages/rn-tester/android/app/gradlew
/packages/rn-tester/android/app/gradlew.bat
/ReactAndroid/build/
/ReactAndroid/.cxx/
/ReactAndroid/gradle/
/ReactAndroid/gradlew
/ReactAndroid/gradlew.bat
/ReactAndroid/external-artifacts/build/
/ReactAndroid/external-artifacts/artifacts/
/ReactAndroid/hermes-engine/build/
/ReactAndroid/hermes-engine/.cxx/
/template/android/app/build/
/template/android/build/
# Buck
.buckd
buck-out
/.lsp.buckd
/.lsp-buck-out
/ReactAndroid/src/main/jni/prebuilt/lib/
/ReactAndroid/src/main/gen
# Android Studio
.project
.settings
.classpath
# Watchman
.watchmanconfig
# Android
.idea
.gradle
local.properties
*.iml
/android/*
!/android/README.md
# Node
node_modules
*.log
.nvm
package-lock.json
# OS X
.DS_Store
# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
*.js.meta
/coverage
/third-party
# Test Reports
/reports
# Stack Dumps generated when programs crash (Ex. bash.exe.stackdump on Win)
*.stackdump
# Root dir shouldn't have Xcode project
/*.xcodeproj
# ReactCommon subdir shouldn't have Xcode project
/ReactCommon/**/*.xcodeproj
# Libs that shouldn't have Xcode project
/Libraries/FBLazyVector/**/*.xcodeproj
/Libraries/RCTRequired/**/*.xcodeproj
/React/CoreModules/**/*.xcodeproj
/React/FBReactNativeSpec/**/*.xcodeproj
/packages/react-native-codegen/**/*.xcodeproj
# Ruby Gems (Bundler)
/vendor
/template/vendor
.ruby-version
/**/.ruby-version
# iOS / CocoaPods
/template/ios/build/
/template/ios/Pods/
/template/ios/Podfile.lock
/packages/rn-tester/Gemfile.lock
# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here.
/packages/rn-tester/Pods/*
!/packages/rn-tester/Pods/__offline_mirrors_hermes__
!/packages/rn-tester/Pods/__offline_mirrors_jsc__
# @react-native/codegen
/React/FBReactNativeSpec/FBReactNativeSpec
/packages/react-native-codegen/lib
/packages/react-native-codegen/tmp/
/ReactCommon/react/renderer/components/rncore/
/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec*
/**/RCTThirdPartyFabricComponentsProvider.*
# Additional SDKs
/sdks/download
/sdks/hermes
/sdks/hermesc
# Visual studio
.vscode
.vs
# Android memory profiler files
*.hprof
# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

@ -0,0 +1,145 @@
# Xcode
!**/*.xcodeproj
!**/*.pbxproj
!**/*.xcworkspacedata
!**/*.xcsettings
!**/*.xcscheme
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
**/.xcode.env.local
.expo
.yarn
# Gradle
/build/
/packages/react-native-gradle-plugin/build/
/packages/rn-tester/build
/packages/rn-tester/android/app/.cxx/
/packages/rn-tester/android/app/build/
/packages/rn-tester/android/app/gradle/
/packages/rn-tester/android/app/gradlew
/packages/rn-tester/android/app/gradlew.bat
/ReactAndroid/build/
/ReactAndroid/.cxx/
/ReactAndroid/gradle/
/ReactAndroid/gradlew
/ReactAndroid/gradlew.bat
/ReactAndroid/external-artifacts/build/
/ReactAndroid/external-artifacts/artifacts/
/ReactAndroid/hermes-engine/build/
/ReactAndroid/hermes-engine/.cxx/
/template/android/app/build/
/template/android/build/
# Buck
.buckd
buck-out
/.lsp.buckd
/.lsp-buck-out
/ReactAndroid/src/main/jni/prebuilt/lib/
/ReactAndroid/src/main/gen
# Android Studio
.project
.settings
.classpath
# Watchman
.watchmanconfig
# Android
.idea
.gradle
local.properties
*.iml
/android/*
!/android/README.md
# Node
node_modules
*.log
.nvm
package-lock.json
# OS X
.DS_Store
# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
*.js.meta
/coverage
/third-party
# Test Reports
/reports
# Stack Dumps generated when programs crash (Ex. bash.exe.stackdump on Win)
*.stackdump
# Root dir shouldn't have Xcode project
/*.xcodeproj
# ReactCommon subdir shouldn't have Xcode project
/ReactCommon/**/*.xcodeproj
# Libs that shouldn't have Xcode project
/Libraries/FBLazyVector/**/*.xcodeproj
/Libraries/RCTRequired/**/*.xcodeproj
/React/CoreModules/**/*.xcodeproj
/React/FBReactNativeSpec/**/*.xcodeproj
/packages/react-native-codegen/**/*.xcodeproj
# Ruby Gems (Bundler)
/vendor
/template/vendor
.ruby-version
/**/.ruby-version
# iOS / CocoaPods
/template/ios/build/
/template/ios/Pods/
/template/ios/Podfile.lock
/packages/rn-tester/Gemfile.lock
# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here.
/packages/rn-tester/Pods/*
!/packages/rn-tester/Pods/__offline_mirrors_hermes__
!/packages/rn-tester/Pods/__offline_mirrors_jsc__
# @react-native/codegen
/React/FBReactNativeSpec/FBReactNativeSpec
/packages/react-native-codegen/lib
/packages/react-native-codegen/tmp/
/ReactCommon/react/renderer/components/rncore/
/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec*
/**/RCTThirdPartyFabricComponentsProvider.*
# Additional SDKs
/sdks/download
/sdks/hermes
/sdks/hermesc
# Visual studio
.vscode
.vs
# Android memory profiler files
*.hprof
# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>df403082-13dd-4046-9b6a-b186df4676fe</UserSecretsId>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dto\Dto.csproj" />
<ProjectReference Include="..\Entity_Framework\Entity_Framework.csproj" />
<ProjectReference Include="..\Extraction_Donnees\Extraction_Donnees.csproj" />
<ProjectReference Include="..\Interface\Interface.csproj" />
<ProjectReference Include="..\Modele\Modele.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,48 @@
using Dto.Classe;
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class Circuits : Controller
{
private readonly IApi data;
public Circuits(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(string name = "All")
{
if (name == "All")
{
return Ok((await data.GetCircuits()).Select(e => e.ModeleToDTO()));
}
Circuit circuit = await data.GetOneCircuit(name);
if (circuit == null)
{
return BadRequest(name);
}
return Ok(circuit.ModeleToDTO());
}
[HttpPost]
public async Task<IActionResult> Post(CircuitDTO circuitDto)
{
Circuit circuit = await data.AddCircuit(circuitDto.DTOToModele());
if (circuit == null)
{
return BadRequest("Le pilote existe déjà !");
}
return Ok(circuit.ModeleToDTO());
}
}
}

@ -0,0 +1,83 @@
using Dto.Classe;
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
using System.Runtime.Intrinsics.X86;
namespace Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class Ecuries : Controller
{
private readonly IApi data;
public Ecuries(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(string Email,string password,string name = "All")
{
Pilote piloteCheck = await data.CheckPilote(Email, password);
if (piloteCheck == null)
{
return BadRequest();
}
if (name == "All")
{
return Ok((await data.GetEcuries()).Select(e => e.ModeleToDTO()));
}
else
{
Ecurie ecurie = await data.GetOneEcurie(name);
if (ecurie == null)
{
return BadRequest(name);
}
else
{
return Ok(ecurie.ModeleToDTO());
}
}
}
[HttpPost]
public async Task<IActionResult> Post(string Email,string password,EcurieDTO ecurie,string pseudo)
{
Pilote piloteCheck = await data.CheckPilote(Email, password);
if (piloteCheck == null)
{
return BadRequest();
}
List<int> result = new List<int>();
result = await data.AddEcurie(ecurie.DTOToModele(),pseudo);
if (result.ToList()[0] == 1)
{
int tmpListe = result.ToList()[1];
if (tmpListe == 2)
{
return BadRequest("Le nom de l'écurie est déjà pris !");
}
else if (tmpListe == 3)
{
return BadRequest("Le pilote n'existe pas !");
}
else if (tmpListe == 4)
{
return BadRequest("Le pilote fait déjà partie d'une écurie !");
}
else
{
return BadRequest("Erreur !");
}
}
return CreatedAtAction(nameof(Get), new { name = ecurie.Name }, ecurie);
}
}
}

@ -0,0 +1,47 @@
using Extraction_Donnees.Extraction_EXECL;
using Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[Route("[controller]")]
[ApiController]
public class File : Controller
{
private readonly IApi data;
public File(IApi manager)
{
this.data = manager;
}
[HttpPost]
public async Task<IActionResult> PostExecl(IFormFile file, string pseudoPilote,string Email ,string password,string nameSession, string nameCircuit, string typeSession)
{
Pilote pilote = await data.CheckPilote(Email, password);
if (pilote == null)
{
return BadRequest();
}
if ( file == null || file.Length == 0)
{
return BadRequest("File vide");
}
Session session;
try
{
session = await Excel.ReadExcel(file);
await data.AddSession(session,pseudoPilote, nameCircuit, nameSession,typeSession);
}
catch(Exception e) {
return BadRequest(e.Message);
}
return Ok(session.Tours[0].Points[0]);
}
}
}

@ -0,0 +1,32 @@
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
/*
namespace Api.Controllers
{
[Route("[controller]")]
[ApiController]
public class Geolocalisations : Controller
{
private readonly IApi data;
public Geolocalisations(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(long IdPoint)
{
Geolocalisation geo = (await data.GetGeolocalisations(IdPoint));
if (geo == null)
{
return BadRequest(IdPoint);
}
return Ok(geo.ModeleToDTO());
}
}
}
*/

@ -0,0 +1,31 @@
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[Route("[controller]")]
[ApiController]
public class Image : Controller
{
private readonly IApi data;
public Image(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(int IdPilote)
{
Modele.Classe.Image img = (await data.GetImage(IdPilote));
if (img == null)
{
return BadRequest(IdPilote);
}
return Ok(img.ModeleToDTO());
}
}
}

@ -0,0 +1,78 @@
using Dto.Classe;
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class Pilotes : Controller
{
private readonly IApi data;
public Pilotes(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(string Email,string password,string? pseudo)
{
Pilote piloteCheck = await data.CheckPilote(Email, password);
if (piloteCheck == null)
{
return BadRequest();
}
if (pseudo == null)
{
return Ok((await data.GetPilotes()).Select(e => e.ModeleToDTO()));
}
else
{
Pilote pilote = await data.GetOnePilote(pseudo);
if (pilote == null)
{
return BadRequest(pseudo);
}
else
{
return Ok(pilote.ModeleToDTO());
}
}
}
[HttpPost]
public async Task<IActionResult> Post(string Email,string password,PiloteDTO piloteDTO)
{
Pilote piloteCheck = await data.CheckPilote(Email, password);
if (piloteCheck == null)
{
return BadRequest();
}
Pilote pilote = await data.AddPilote(piloteDTO.DTOToModele());
if (pilote == null)
{
return BadRequest("Le pilote existe déjà !");
}
return Ok(pilote.ModeleToDTO());
}
[HttpGet("check")]
public async Task<IActionResult> CheckPilote(string Email,string password)
{
Pilote pilote = await data.CheckPilote(Email, password);
if ( pilote == null)
{
return BadRequest(null);
}
return Ok(pilote);
}
}
}

@ -0,0 +1,33 @@
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[Route("[controller]")]
[ApiController]
public class Points : Controller
{
private readonly IApi data;
public Points(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(long IdTour)
{
IEnumerable<Point> points = (await data.GetPoints(IdTour));
if (points == null)
{
return BadRequest();
}
return Ok(points.Select(e => e.ModeleToDTO()));
}
}
}

@ -0,0 +1,31 @@
using Dto.Classe;
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class Sessions : Controller
{
private readonly IApi data;
public Sessions(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(string pseudo)
{
IEnumerable<Session> sessions = (await data.GetSessionsByPilotes(pseudo));
if (sessions == null)
{
return NotFound(pseudo);
}
return Ok(sessions.Select(e => e.ModeleToDTO()));
}
}
}

@ -0,0 +1,31 @@
using Dto.Factories;
using Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Modele.Classe;
namespace Api.Controllers
{
[ApiController]
[Route("[controller]")]
public class Tours : Controller
{
private readonly IApi data;
public Tours(IApi manager)
{
this.data = manager;
}
[HttpGet]
public async Task<IActionResult> Get(long IdSession)
{
IEnumerable<Tour> tours = (await data.GetTours(IdSession));
if (tours == null)
{
return BadRequest(IdSession);
}
return Ok(tours.Select(e => e.ModeleToDTO()));
}
}
}

@ -0,0 +1,30 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Api/Api.csproj", "Api/"]
COPY ["Dto/Dto.csproj", "Dto/"]
COPY ["Modele/Modele.csproj", "Modele/"]
COPY ["Entity_Framework/Entity_Framework.csproj", "Entity_Framework/"]
COPY ["Interface/Interface.csproj", "Interface/"]
COPY ["Extraction_Donnees/Extraction_Donnees.csproj", "Extraction_Donnees/"]
RUN dotnet restore "Api/Api.csproj"
COPY . .
WORKDIR "/src/Api"
RUN dotnet build "Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Api.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Api.dll"]

@ -0,0 +1,30 @@
using Extraction_Donnees.Extraction;
using Interface;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<IApi, Extraction>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,38 @@
{
"profiles": {
"Api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7217;http://localhost:5031"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56800",
"sslPort": 44325
}
}
}

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

@ -0,0 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "Api\Api.csproj", "{4448F5FC-CAE2-4756-920F-C63171F8498E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTest", "ConsoleTest\ConsoleTest.csproj", "{96B34ADC-CEFD-469F-9FB4-24366779B135}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dto", "Dto\Dto.csproj", "{85988F81-B575-4B90-A1A7-5255DF9A5F99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entity_Framework", "Entity_Framework\Entity_Framework.csproj", "{F5026481-E8C5-4F10-8F89-80511FBA8874}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extraction_Donnees", "Extraction_Donnees\Extraction_Donnees.csproj", "{ECC3B1A4-6C07-43C4-9748-71F0A8CBE4DF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extraction_Excel_Test", "Extraction_Excel_Test\Extraction_Excel_Test.csproj", "{BCD1468F-2313-4B28-9EAE-9E9E5878A6BA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Interface", "Interface\Interface.csproj", "{75F1273E-8191-4577-B8F2-A44B00E2E136}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modele", "Modele\Modele.csproj", "{BAEC968D-9C1E-4CE2-AB3A-19F0444142F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4448F5FC-CAE2-4756-920F-C63171F8498E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4448F5FC-CAE2-4756-920F-C63171F8498E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4448F5FC-CAE2-4756-920F-C63171F8498E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4448F5FC-CAE2-4756-920F-C63171F8498E}.Release|Any CPU.Build.0 = Release|Any CPU
{96B34ADC-CEFD-469F-9FB4-24366779B135}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96B34ADC-CEFD-469F-9FB4-24366779B135}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96B34ADC-CEFD-469F-9FB4-24366779B135}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96B34ADC-CEFD-469F-9FB4-24366779B135}.Release|Any CPU.Build.0 = Release|Any CPU
{85988F81-B575-4B90-A1A7-5255DF9A5F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85988F81-B575-4B90-A1A7-5255DF9A5F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85988F81-B575-4B90-A1A7-5255DF9A5F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85988F81-B575-4B90-A1A7-5255DF9A5F99}.Release|Any CPU.Build.0 = Release|Any CPU
{F5026481-E8C5-4F10-8F89-80511FBA8874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5026481-E8C5-4F10-8F89-80511FBA8874}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5026481-E8C5-4F10-8F89-80511FBA8874}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5026481-E8C5-4F10-8F89-80511FBA8874}.Release|Any CPU.Build.0 = Release|Any CPU
{ECC3B1A4-6C07-43C4-9748-71F0A8CBE4DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECC3B1A4-6C07-43C4-9748-71F0A8CBE4DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECC3B1A4-6C07-43C4-9748-71F0A8CBE4DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECC3B1A4-6C07-43C4-9748-71F0A8CBE4DF}.Release|Any CPU.Build.0 = Release|Any CPU
{BCD1468F-2313-4B28-9EAE-9E9E5878A6BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCD1468F-2313-4B28-9EAE-9E9E5878A6BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCD1468F-2313-4B28-9EAE-9E9E5878A6BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCD1468F-2313-4B28-9EAE-9E9E5878A6BA}.Release|Any CPU.Build.0 = Release|Any CPU
{75F1273E-8191-4577-B8F2-A44B00E2E136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75F1273E-8191-4577-B8F2-A44B00E2E136}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75F1273E-8191-4577-B8F2-A44B00E2E136}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75F1273E-8191-4577-B8F2-A44B00E2E136}.Release|Any CPU.Build.0 = Release|Any CPU
{BAEC968D-9C1E-4CE2-AB3A-19F0444142F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAEC968D-9C1E-4CE2-AB3A-19F0444142F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAEC968D-9C1E-4CE2-AB3A-19F0444142F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAEC968D-9C1E-4CE2-AB3A-19F0444142F3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5E1A4343-995A-4650-83DF-0F54E91608E0}
EndGlobalSection
EndGlobal

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Api\Api.csproj" />
<ProjectReference Include="..\Dto\Dto.csproj" />
<ProjectReference Include="..\Entity_Framework\Entity_Framework.csproj" />
<ProjectReference Include="..\Modele\Modele.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,19 @@
// See https://aka.ms/new-console-template for more information
using Dto.Classe;
using Entity_Framework;
using Entity_Framework.Entity;
using Extraction_Donnees.Extraction;
using Microsoft.AspNetCore.Mvc;
Console.WriteLine("Hello, World!");
Extraction tmp2 = new Extraction();
Api.Controllers.Pilotes tmp = new Api.Controllers.Pilotes(tmp2);
var result = await tmp.Get("All");
Console.WriteLine(result);
Console.WriteLine("End !");

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class CircuitDTO
{
public string Name { get; set; }
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class EcurieDTO
{
public string Name { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class GeolocalisationDTO
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class ImageDTO
{
public string Base64 { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class PiloteDTO
{
public string Pseudo { get; set; }
public string Email { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class PointDTO
{
public float Distance { get; set; }
public long IdGeolocalisation { get; set; }
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class SessionDTO
{
public long Id { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public DateTime Date { get; set; }
public string NameCircuit { get; set; }
public string NamePilote { set; get; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Classe
{
public class TourDTO
{
public float Temps { get; set; }
public long IdSession { get; set; }
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Modele\Modele.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,27 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class CircuitFactorie
{
public static CircuitDTO ModeleToDTO(this Circuit circuit)
{
CircuitDTO circuitDTO = new CircuitDTO();
circuitDTO.Name = circuit.name;
return circuitDTO;
}
public static Circuit DTOToModele(this CircuitDTO dto)
{
return new Circuit(nameArg:dto.Name);
}
}
}

@ -0,0 +1,27 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class EcurieFactorie
{
public static EcurieDTO ModeleToDTO(this Ecurie ecurie)
{
EcurieDTO ecurieDTO = new EcurieDTO();
ecurieDTO.Name = ecurie.name;
return ecurieDTO;
}
public static Ecurie DTOToModele(this EcurieDTO dto)
{
return new Ecurie(nameArg: dto.Name);
}
}
}

@ -0,0 +1,21 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class GeolocalisationFactorie
{
public static GeolocalisationDTO ModeleToDTO(this Geolocalisation modele)
{
GeolocalisationDTO dto = new GeolocalisationDTO();
dto.Longitude = modele.Longitude;
dto.Latitude = modele.Latitude;
return dto;
}
}
}

@ -0,0 +1,20 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class ImageFactorie
{
public static ImageDTO ModeleToDTO(this Image modele)
{
ImageDTO dto = new ImageDTO();
dto.Base64 = modele.Base64;
return dto;
}
}
}

@ -0,0 +1,29 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class PiloteFactorie
{
public static PiloteDTO ModeleToDTO(this Pilote pilote)
{
PiloteDTO piloteDTO = new PiloteDTO();
piloteDTO.Pseudo = pilote.Pseudo;
piloteDTO.Email = pilote.Email;
return piloteDTO;
}
public static Pilote DTOToModele(this PiloteDTO piloteDto)
{
return new Pilote(_Pseudo:piloteDto.Pseudo,_Email:piloteDto.Email,_Password:"Inconnu !");
}
}
}

@ -0,0 +1,21 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class PointFactorie
{
public static PointDTO ModeleToDTO(this Point modele)
{
PointDTO dto = new PointDTO();
dto.Distance = modele.Distance;
//dto.IdGeolocalisation = modele.IdGeolocalisation;
return dto;
}
}
}

@ -0,0 +1,27 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class SessionFactorie
{
public static SessionDTO ModeleToDTO(this Session session)
{
SessionDTO sessionDTO = new SessionDTO();
sessionDTO.Name = session.name;
sessionDTO.Type = session.type;
sessionDTO.NamePilote = session.namePilote;
sessionDTO.NameCircuit = session.nameCircuit;
sessionDTO.Date = session.date;
sessionDTO.Id = session.Id;
return sessionDTO;
}
}
}

@ -0,0 +1,23 @@
using Dto.Classe;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dto.Factories
{
public static class TourFactorie
{
public static TourDTO ModeleToDTO(this Tour modele)
{
TourDTO tourDTO = new TourDTO();
tourDTO.IdSession = modele.IdSession;
//tourDTO.Temps = modele.Temps;
return tourDTO;
}
}
}

Binary file not shown.

@ -0,0 +1,156 @@
using Entity_Framework.Entity;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Reflection.Emit;
using System.Security.Cryptography;
using System.Text;
namespace Entity_Framework
{
public class BDDContext : DbContext
{
// Constructeur
public BDDContext() { }
public BDDContext(DbContextOptions<BDDContext> option) : base(option) { }
// Fluent Api
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// -------------------------------------------------------------------//
// Tables Pilotes
modelBuilder.Entity<Pilotes>().HasKey(e => e.Id);
modelBuilder.Entity<Pilotes>().Property(e => e.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<Pilotes>().Property(e => e.Pseudo).IsRequired();
modelBuilder.Entity<Pilotes>().HasIndex(e => e.Pseudo).IsUnique();
modelBuilder.Entity<Pilotes>().Property(e => e.Email).IsRequired();
modelBuilder.Entity<Pilotes>().HasIndex(e => e.Email).IsUnique();
modelBuilder.Entity<Pilotes>().Property(e => e.Password).IsRequired();
//Relation avec écurie pour le propriétaire
modelBuilder.Entity<Pilotes>().HasOne(e => e.EcuriePropriétaire)
.WithOne(e => e.PiloteProprietaire)
.HasForeignKey<Ecuries>(e => e.IdPiloteProprietaire);
// Relation avec Session
modelBuilder.Entity<Pilotes>().HasMany(e => e.Sessions)
.WithOne(e => e.Pilote)
.HasForeignKey(e => e.IdPilote);
// -------------------------------------------------------------------//
// Tables Ecuries
modelBuilder.Entity<Ecuries>().HasKey(e => e.Id);
modelBuilder.Entity<Ecuries>().Property(e => e.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<Ecuries>().Property(e => e.Name).IsRequired();
modelBuilder.Entity<Ecuries>().HasIndex(e => e.Name).IsUnique();
// Relation avec pilotes
modelBuilder.Entity<Ecuries>().HasMany(e => e.Pilotes)
.WithOne(e => e.Ecurie)
.HasForeignKey(e => e.IdEcurie)
.IsRequired(false);
// -------------------------------------------------------------------//
// Tables Circuits
modelBuilder.Entity<Circuits>().HasKey(e => e.Id);
modelBuilder.Entity<Circuits>().Property(e => e.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<Circuits>().Property(e => e.Name).IsRequired();
modelBuilder.Entity<Circuits>().HasIndex(e => e.Name).IsUnique();
modelBuilder.Entity<Circuits>().HasMany(e => e.Course)
.WithOne(e => e.Circuit)
.HasForeignKey(e => e.IdCircuit);
// -------------------------------------------------------------------//
// Tables Session
modelBuilder.Entity<Sessions>().HasKey(e => e.Id);
modelBuilder.Entity<Sessions>().Property(e => e.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<Sessions>().Property(e => e.Name).IsRequired();
modelBuilder.Entity<Sessions>().HasMany(e => e.Tours)
.WithOne(e => e.Session)
.HasForeignKey(e => e.IdSession);
// -------------------------------------------------------------------//
// Tables Geolocalisations
/*
modelBuilder.Entity<Geolocalisations>().HasKey(e => e.Id);
modelBuilder.Entity<Geolocalisations>().Property(e => e.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<Geolocalisations>().Property(e => e.Latitude).IsRequired();
modelBuilder.Entity<Geolocalisations>().Property(e => e.Longitude).IsRequired();
// Relation avec Points
modelBuilder.Entity<Geolocalisations>().HasOne(e => e.Point)
.WithOne(z => z.Geolocalisation)
.HasForeignKey<Points>(x => x.IdGeolocalisation);
*/
// -------------------------------------------------------------------//
// Tables Points
modelBuilder.Entity<Points>().HasKey(e => e.Id);
modelBuilder.Entity<Points>().Property(e => e.Id)
.ValueGeneratedOnAdd();
// -------------------------------------------------------------------//
// Tables Tours
modelBuilder.Entity<Tours>().HasKey(e => e.Id);
modelBuilder.Entity<Tours>().Property(e => e.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<Tours>().HasMany(e => e.Points)
.WithOne(e => e.Tours)
.HasForeignKey(x => x.IdTours);
// -------------------------------------------------------------------//
// Tables Images
modelBuilder.Entity<Images>().HasKey(e => e.Id);
modelBuilder.Entity<Images>().Property(e => e.Id)
.ValueGeneratedOnAdd();
// ------------------------ STUB ------------------------------------ //
//stub data
byte[] passwordByte = Encoding.UTF8.GetBytes("test123");
SHA256 sha256 = SHA256.Create();
byte[] hashedByte = sha256.ComputeHash(passwordByte);
string hashedPassword = Convert.ToBase64String(hashedByte);
var pilote = new Pilotes { Id = 1, Pseudo = "test_PILOTE", Email = "test@gmail.com", Password = hashedPassword };
modelBuilder.Entity<Pilotes>().HasData(pilote);
modelBuilder.Entity<Circuits>().HasData(new Circuits { Id = 1, Name = "test_CIRCUIT" });
}
// DbSet
public DbSet<Pilotes> Pilotes { get; set; }
public DbSet<Circuits> Circuits { get; set; }
public DbSet<Sessions> Sessions { get; set; }
public DbSet<Ecuries> Ecuries { get; set; }
//public DbSet<Geolocalisations> Geolocalisations { get; set; }
public DbSet<Points> Points { get; set; }
public DbSet<Tours> Tours { get; set; }
public DbSet<Images> Images { get; set; }
// BDD
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
//optionsBuilder.UseSqlite($"Data Source=..\\Entity_Framework\\BDD.db");
optionsBuilder.UseSqlite($"Data Source=C:\\Users\\Jolys Enzo\\home\\BUT\\Projet\\Sae4.01\\Projet\\R-Dash_APP\\Entity_Framework\\BDD.db");
}
}
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
public class Circuits
{
public int Id { get; set; }
public string Name { get; set; }
// -------------------- Relation -------------------- //
//Courses
public List<Sessions> Course { get; set; }
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
public class Ecuries
{
public int Id { get; set; }
public string Name { get; set; }
// -------------------- Relation -------------------- //
//Pilotes
public List<Pilotes> Pilotes { get; set; }
// Pilote propriétaire
public int IdPiloteProprietaire { get; set; }
public Pilotes PiloteProprietaire { get; set; }
}
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
// Attribut à redefinir
public class Geolocalisations
{
public long Id { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
// -------------------- Relation -------------------- //
// Points
//public Points Point { get; set; }
}
}

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
public class Images
{
public int Id { get; set; }
public string Base64 { get; set; }
// ----- Relation ------ //
[Required]
public int IdPilote { get; set; }
[ForeignKey(nameof(IdPilote))]
public Pilotes Pilote { get; set; }
}
}

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
public class Pilotes
{
public int Id { get; set; }
public string Pseudo { get; set; }
public string Email { get; set; }
public string Password { get; set; }
/*{ get
{
return Password;
}
set
{
Password = BCrypt.Net.BCrypt.HashPassword(value);
}
}*/
// -------------------- Relation -------------------- //
// Ecurie liste
public int? IdEcurie { get; set; }
public Ecuries Ecurie { get; set; }
//Ecurie propriétaire
public Ecuries EcuriePropriétaire { get; set; }
// Courses
public List<Sessions> Sessions { get; set; }
//Images
public Images Image { get; set; }
}
}

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
// Attributs à redefinir
public class Points
{
public long Id { get; set; }
public float Timer { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
public float Distance { get; set; }
public float P_BreakF { get; set; }
public float NGearASCII { get; set; }
public float A_Steer { get; set;}
public float R_Pedal { get; set;}
public float G_Lon { get; set; }
public float G_Lat { get; set; }
public float V_Car { get; set;}
// -------------------- Relation -------------------- //
// Geolocalisation
//public long IdGeolocalisation { get; set;}
//public Geolocalisations Geolocalisation { get; set;}
// Tours
public long IdTours { get; set;}
public Tours Tours { get; set;}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity.Relations
{
public class Relation_Pilote_Ecurie
{
public int IdPilote { get; set; }
public int IdEcurie { get; set; }
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
public class Sessions
{
public long Id { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public DateTime Date { get; set; }
// -------------------- Relation -------------------- //
//Circuit
public int IdCircuit { get; set; }
public Circuits Circuit { get; set; }
// Pilotes
public int IdPilote { get; set; }
public Pilotes Pilote { get; set; }
//Tours
public List<Tours> Tours { get; set; }
}
}

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Entity
{
public class Tours
{
public long Id { get; set; }
public string Temps { get; set; }
public int Numero { get; set; }
// -------------------- Relation -------------------- //
// Points
public List<Points> Points { get; set; }
// Courses
public long IdSession { get; set; }
public Sessions Session { get; set; }
}
}

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Interface\Interface.csproj" />
<ProjectReference Include="..\Modele\Modele.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,25 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class CircuitFactorie
{
public static Circuit EntityToModele(this Circuits entity)
{
return new Circuit(nameArg:entity.Name);
}
public static Circuits ModeleToEntity(this Circuit modele)
{
Circuits circuit = new Circuits();
circuit.Name = modele.name;
return circuit;
}
}
}

@ -0,0 +1,27 @@
using Dto.Classe;
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class EcurieFactorie
{
public static Ecurie EntityToModele(this Ecuries dto)
{
return new Ecurie(nameArg:dto.Name);
}
public static Ecuries ModeleToEntity(this Ecurie ecurie)
{
Ecuries entity = new Ecuries();
entity.Name = ecurie.name;
return entity;
}
}
}

@ -0,0 +1,19 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class GeolocalisationFactorie
{
public static Geolocalisation EntityToModele(this Geolocalisations entity)
{
//return new Geolocalisation(LatitudeArg:entity.Latitude,LongitudeArg:entity.Longitude);
return null;
}
}
}

@ -0,0 +1,18 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class ImageFactorie
{
public static Image EntityToModele(this Images entity)
{
return new Image(base64:entity.Base64);
}
}
}

@ -0,0 +1,30 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class PiloteFactories
{
public static Pilotes ModeleToEntity(this Pilote piloteModele)
{
Pilotes pilote = new Pilotes();
pilote.Pseudo = piloteModele.Pseudo;
pilote.Email = piloteModele.Email;
pilote.Password = piloteModele.Password;
return pilote;
}
public static Pilote EntityToModele(this Pilotes piloteEntity)
{
return new Pilote(_Pseudo:piloteEntity.Pseudo,_Email:piloteEntity.Email,_Password:piloteEntity.Password);
}
}
}

@ -0,0 +1,37 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class PointFactorie
{
public static Point EntityToModele(this Points entity)
{
return new Point(entity.Longitude,entity.Latitude,entity.Timer,entity.Distance,entity.NGearASCII,entity.P_BreakF,entity.A_Steer,entity.R_Pedal,entity.G_Lon,entity.G_Lat,entity.V_Car);
}
public static Points ModeleToEntity(this Point modele)
{
return new Points
{
Longitude = modele.Longitude,
Latitude = modele.Latitude,
Timer = modele.Timer,
Distance = modele.Distance,
NGearASCII = modele.NGear,
P_BreakF = modele.PBrakeF,
A_Steer = modele.ASteer,
R_Pedal = modele.RPedal,
G_Lon = modele.GLong,
G_Lat = modele.GLat,
};
}
}
}

@ -0,0 +1,29 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class SessionFactorie
{
public static Session EntityToModele(this Sessions entity)
{
return new Session(IdArg:entity.Id,dateArg:entity.Date,nameArg: entity.Name, typeArg: entity.Type, nameCircuitArg: entity.Circuit.Name, namePiloteArg: entity.Pilote.Pseudo);
}
public static Sessions ModeleToEntity(this Session modele)
{
Sessions entity = new Sessions();
entity.Name = modele.name;
entity.Type = modele.type;
entity.Date = modele.date;
return entity;
}
}
}

@ -0,0 +1,28 @@
using Entity_Framework.Entity;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity_Framework.Factories
{
public static class TourFactorie
{
public static Tour EntityToModele(this Tours entity)
{
return new Tour(TempsArg:entity.Temps,IdSessionArg:entity.IdSession);
}
public static Tours ModeleToEntity(this Tour modele)
{
Tours tours = new Tours();
tours.Temps = modele.Temps;
tours.Numero = modele.Numero;
return tours;
}
}
}

@ -0,0 +1,345 @@
// <auto-generated />
using System;
using Entity_Framework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Entity_Framework.Migrations
{
[DbContext(typeof(BDDContext))]
[Migration("20230317102828_test")]
partial class test
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.3");
modelBuilder.Entity("Entity_Framework.Entity.Circuits", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Circuits");
b.HasData(
new
{
Id = 1,
Name = "test_CIRCUIT"
});
});
modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("IdPiloteProprietaire")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdPiloteProprietaire")
.IsUnique();
b.HasIndex("Name")
.IsUnique();
b.ToTable("Ecuries");
});
modelBuilder.Entity("Entity_Framework.Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("IdPilote")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("IdPilote")
.IsUnique();
b.ToTable("Images");
});
modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("IdEcurie")
.HasColumnType("INTEGER");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.HasIndex("IdEcurie");
b.HasIndex("Pseudo")
.IsUnique();
b.ToTable("Pilotes");
b.HasData(
new
{
Id = 1,
Email = "test@gmail.com",
Password = "7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=",
Pseudo = "test_PILOTE"
});
});
modelBuilder.Entity("Entity_Framework.Entity.Points", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<float>("A_Steer")
.HasColumnType("REAL");
b.Property<float>("Distance")
.HasColumnType("REAL");
b.Property<float>("G_Lat")
.HasColumnType("REAL");
b.Property<float>("G_Lon")
.HasColumnType("REAL");
b.Property<long>("IdTours")
.HasColumnType("INTEGER");
b.Property<double>("Latitude")
.HasColumnType("REAL");
b.Property<double>("Longitude")
.HasColumnType("REAL");
b.Property<float>("NGearASCII")
.HasColumnType("REAL");
b.Property<float>("P_BreakF")
.HasColumnType("REAL");
b.Property<float>("R_Pedal")
.HasColumnType("REAL");
b.Property<float>("Timer")
.HasColumnType("REAL");
b.Property<float>("V_Car")
.HasColumnType("REAL");
b.HasKey("Id");
b.HasIndex("IdTours");
b.ToTable("Points");
});
modelBuilder.Entity("Entity_Framework.Entity.Sessions", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("IdCircuit")
.HasColumnType("INTEGER");
b.Property<int>("IdPilote")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdCircuit");
b.HasIndex("IdPilote");
b.ToTable("Sessions");
});
modelBuilder.Entity("Entity_Framework.Entity.Tours", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("IdSession")
.HasColumnType("INTEGER");
b.Property<int>("Numero")
.HasColumnType("INTEGER");
b.Property<string>("Temps")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdSession");
b.ToTable("Tours");
});
modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b =>
{
b.HasOne("Entity_Framework.Entity.Pilotes", "PiloteProprietaire")
.WithOne("EcuriePropriétaire")
.HasForeignKey("Entity_Framework.Entity.Ecuries", "IdPiloteProprietaire")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PiloteProprietaire");
});
modelBuilder.Entity("Entity_Framework.Entity.Images", b =>
{
b.HasOne("Entity_Framework.Entity.Pilotes", "Pilote")
.WithOne("Image")
.HasForeignKey("Entity_Framework.Entity.Images", "IdPilote")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pilote");
});
modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b =>
{
b.HasOne("Entity_Framework.Entity.Ecuries", "Ecurie")
.WithMany("Pilotes")
.HasForeignKey("IdEcurie");
b.Navigation("Ecurie");
});
modelBuilder.Entity("Entity_Framework.Entity.Points", b =>
{
b.HasOne("Entity_Framework.Entity.Tours", "Tours")
.WithMany("Points")
.HasForeignKey("IdTours")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tours");
});
modelBuilder.Entity("Entity_Framework.Entity.Sessions", b =>
{
b.HasOne("Entity_Framework.Entity.Circuits", "Circuit")
.WithMany("Course")
.HasForeignKey("IdCircuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entity_Framework.Entity.Pilotes", "Pilote")
.WithMany("Sessions")
.HasForeignKey("IdPilote")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Circuit");
b.Navigation("Pilote");
});
modelBuilder.Entity("Entity_Framework.Entity.Tours", b =>
{
b.HasOne("Entity_Framework.Entity.Sessions", "Session")
.WithMany("Tours")
.HasForeignKey("IdSession")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Session");
});
modelBuilder.Entity("Entity_Framework.Entity.Circuits", b =>
{
b.Navigation("Course");
});
modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b =>
{
b.Navigation("Pilotes");
});
modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b =>
{
b.Navigation("EcuriePropriétaire")
.IsRequired();
b.Navigation("Image")
.IsRequired();
b.Navigation("Sessions");
});
modelBuilder.Entity("Entity_Framework.Entity.Sessions", b =>
{
b.Navigation("Tours");
});
modelBuilder.Entity("Entity_Framework.Entity.Tours", b =>
{
b.Navigation("Points");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,271 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Entity_Framework.Migrations
{
/// <inheritdoc />
public partial class test : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Circuits",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Circuits", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Ecuries",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
IdPiloteProprietaire = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Ecuries", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Pilotes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Pseudo = table.Column<string>(type: "TEXT", nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: false),
Password = table.Column<string>(type: "TEXT", nullable: false),
IdEcurie = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Pilotes", x => x.Id);
table.ForeignKey(
name: "FK_Pilotes_Ecuries_IdEcurie",
column: x => x.IdEcurie,
principalTable: "Ecuries",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Base64 = table.Column<string>(type: "TEXT", nullable: false),
IdPilote = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Images", x => x.Id);
table.ForeignKey(
name: "FK_Images_Pilotes_IdPilote",
column: x => x.IdPilote,
principalTable: "Pilotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Sessions",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Type = table.Column<string>(type: "TEXT", nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
IdCircuit = table.Column<int>(type: "INTEGER", nullable: false),
IdPilote = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sessions", x => x.Id);
table.ForeignKey(
name: "FK_Sessions_Circuits_IdCircuit",
column: x => x.IdCircuit,
principalTable: "Circuits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Sessions_Pilotes_IdPilote",
column: x => x.IdPilote,
principalTable: "Pilotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Tours",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Temps = table.Column<string>(type: "TEXT", nullable: false),
Numero = table.Column<int>(type: "INTEGER", nullable: false),
IdSession = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tours", x => x.Id);
table.ForeignKey(
name: "FK_Tours_Sessions_IdSession",
column: x => x.IdSession,
principalTable: "Sessions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Points",
columns: table => new
{
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Timer = table.Column<float>(type: "REAL", nullable: false),
Latitude = table.Column<double>(type: "REAL", nullable: false),
Longitude = table.Column<double>(type: "REAL", nullable: false),
Distance = table.Column<float>(type: "REAL", nullable: false),
P_BreakF = table.Column<float>(type: "REAL", nullable: false),
NGearASCII = table.Column<float>(type: "REAL", nullable: false),
A_Steer = table.Column<float>(type: "REAL", nullable: false),
R_Pedal = table.Column<float>(type: "REAL", nullable: false),
G_Lon = table.Column<float>(type: "REAL", nullable: false),
G_Lat = table.Column<float>(type: "REAL", nullable: false),
V_Car = table.Column<float>(type: "REAL", nullable: false),
IdTours = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Points", x => x.Id);
table.ForeignKey(
name: "FK_Points_Tours_IdTours",
column: x => x.IdTours,
principalTable: "Tours",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Circuits",
columns: new[] { "Id", "Name" },
values: new object[] { 1, "test_CIRCUIT" });
migrationBuilder.InsertData(
table: "Pilotes",
columns: new[] { "Id", "Email", "IdEcurie", "Password", "Pseudo" },
values: new object[] { 1, "test@gmail.com", null, "7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=", "test_PILOTE" });
migrationBuilder.CreateIndex(
name: "IX_Circuits_Name",
table: "Circuits",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Ecuries_IdPiloteProprietaire",
table: "Ecuries",
column: "IdPiloteProprietaire",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Ecuries_Name",
table: "Ecuries",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Images_IdPilote",
table: "Images",
column: "IdPilote",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pilotes_Email",
table: "Pilotes",
column: "Email",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pilotes_IdEcurie",
table: "Pilotes",
column: "IdEcurie");
migrationBuilder.CreateIndex(
name: "IX_Pilotes_Pseudo",
table: "Pilotes",
column: "Pseudo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Points_IdTours",
table: "Points",
column: "IdTours");
migrationBuilder.CreateIndex(
name: "IX_Sessions_IdCircuit",
table: "Sessions",
column: "IdCircuit");
migrationBuilder.CreateIndex(
name: "IX_Sessions_IdPilote",
table: "Sessions",
column: "IdPilote");
migrationBuilder.CreateIndex(
name: "IX_Tours_IdSession",
table: "Tours",
column: "IdSession");
migrationBuilder.AddForeignKey(
name: "FK_Ecuries_Pilotes_IdPiloteProprietaire",
table: "Ecuries",
column: "IdPiloteProprietaire",
principalTable: "Pilotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Ecuries_Pilotes_IdPiloteProprietaire",
table: "Ecuries");
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropTable(
name: "Points");
migrationBuilder.DropTable(
name: "Tours");
migrationBuilder.DropTable(
name: "Sessions");
migrationBuilder.DropTable(
name: "Circuits");
migrationBuilder.DropTable(
name: "Pilotes");
migrationBuilder.DropTable(
name: "Ecuries");
}
}
}

@ -0,0 +1,342 @@
// <auto-generated />
using System;
using Entity_Framework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Entity_Framework.Migrations
{
[DbContext(typeof(BDDContext))]
partial class BDDContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.3");
modelBuilder.Entity("Entity_Framework.Entity.Circuits", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Circuits");
b.HasData(
new
{
Id = 1,
Name = "test_CIRCUIT"
});
});
modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("IdPiloteProprietaire")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdPiloteProprietaire")
.IsUnique();
b.HasIndex("Name")
.IsUnique();
b.ToTable("Ecuries");
});
modelBuilder.Entity("Entity_Framework.Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("IdPilote")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("IdPilote")
.IsUnique();
b.ToTable("Images");
});
modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("IdEcurie")
.HasColumnType("INTEGER");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.HasIndex("IdEcurie");
b.HasIndex("Pseudo")
.IsUnique();
b.ToTable("Pilotes");
b.HasData(
new
{
Id = 1,
Email = "test@gmail.com",
Password = "7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=",
Pseudo = "test_PILOTE"
});
});
modelBuilder.Entity("Entity_Framework.Entity.Points", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<float>("A_Steer")
.HasColumnType("REAL");
b.Property<float>("Distance")
.HasColumnType("REAL");
b.Property<float>("G_Lat")
.HasColumnType("REAL");
b.Property<float>("G_Lon")
.HasColumnType("REAL");
b.Property<long>("IdTours")
.HasColumnType("INTEGER");
b.Property<double>("Latitude")
.HasColumnType("REAL");
b.Property<double>("Longitude")
.HasColumnType("REAL");
b.Property<float>("NGearASCII")
.HasColumnType("REAL");
b.Property<float>("P_BreakF")
.HasColumnType("REAL");
b.Property<float>("R_Pedal")
.HasColumnType("REAL");
b.Property<float>("Timer")
.HasColumnType("REAL");
b.Property<float>("V_Car")
.HasColumnType("REAL");
b.HasKey("Id");
b.HasIndex("IdTours");
b.ToTable("Points");
});
modelBuilder.Entity("Entity_Framework.Entity.Sessions", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("IdCircuit")
.HasColumnType("INTEGER");
b.Property<int>("IdPilote")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdCircuit");
b.HasIndex("IdPilote");
b.ToTable("Sessions");
});
modelBuilder.Entity("Entity_Framework.Entity.Tours", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("IdSession")
.HasColumnType("INTEGER");
b.Property<int>("Numero")
.HasColumnType("INTEGER");
b.Property<string>("Temps")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdSession");
b.ToTable("Tours");
});
modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b =>
{
b.HasOne("Entity_Framework.Entity.Pilotes", "PiloteProprietaire")
.WithOne("EcuriePropriétaire")
.HasForeignKey("Entity_Framework.Entity.Ecuries", "IdPiloteProprietaire")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PiloteProprietaire");
});
modelBuilder.Entity("Entity_Framework.Entity.Images", b =>
{
b.HasOne("Entity_Framework.Entity.Pilotes", "Pilote")
.WithOne("Image")
.HasForeignKey("Entity_Framework.Entity.Images", "IdPilote")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pilote");
});
modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b =>
{
b.HasOne("Entity_Framework.Entity.Ecuries", "Ecurie")
.WithMany("Pilotes")
.HasForeignKey("IdEcurie");
b.Navigation("Ecurie");
});
modelBuilder.Entity("Entity_Framework.Entity.Points", b =>
{
b.HasOne("Entity_Framework.Entity.Tours", "Tours")
.WithMany("Points")
.HasForeignKey("IdTours")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tours");
});
modelBuilder.Entity("Entity_Framework.Entity.Sessions", b =>
{
b.HasOne("Entity_Framework.Entity.Circuits", "Circuit")
.WithMany("Course")
.HasForeignKey("IdCircuit")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entity_Framework.Entity.Pilotes", "Pilote")
.WithMany("Sessions")
.HasForeignKey("IdPilote")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Circuit");
b.Navigation("Pilote");
});
modelBuilder.Entity("Entity_Framework.Entity.Tours", b =>
{
b.HasOne("Entity_Framework.Entity.Sessions", "Session")
.WithMany("Tours")
.HasForeignKey("IdSession")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Session");
});
modelBuilder.Entity("Entity_Framework.Entity.Circuits", b =>
{
b.Navigation("Course");
});
modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b =>
{
b.Navigation("Pilotes");
});
modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b =>
{
b.Navigation("EcuriePropriétaire")
.IsRequired();
b.Navigation("Image")
.IsRequired();
b.Navigation("Sessions");
});
modelBuilder.Entity("Entity_Framework.Entity.Sessions", b =>
{
b.Navigation("Tours");
});
modelBuilder.Entity("Entity_Framework.Entity.Tours", b =>
{
b.Navigation("Points");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,12 @@
using Dto.Classe;
using Interface;
using Modele.Classe;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction : IApi
{
}
}

@ -0,0 +1,58 @@
using Entity_Framework;
using Entity_Framework.Entity;
using Entity_Framework.Factories;
using Modele.Classe;
using System.Security.Cryptography;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<IEnumerable<Circuit>> GetCircuits()
{
IEnumerable<Circuit> result = new List<Circuit>();
using (BDDContext db = new BDDContext())
{
result = db.Circuits.ToList().Select(e => e.EntityToModele());
}
return Task.FromResult<IEnumerable<Circuit>>(result);
}
public Task<Circuit> GetOneCircuit(string name)
{
Circuits circuit = new Circuits();
using (BDDContext db = new BDDContext())
{
circuit = db.Circuits.Where(e => e.Name == name).FirstOrDefault();
}
if (circuit == null)
{
return Task.FromResult<Circuit>(null);
}
return Task.FromResult<Circuit>(circuit.EntityToModele());
}
public Task<Circuit> AddCircuit(Circuit circuit)
{
Circuits circuitEntity = circuit.ModeleToEntity();
using (BDDContext db = new BDDContext())
{
bool checkCircuit = db.Circuits.Any(e => e.Name == circuitEntity.Name);
if (checkCircuit)
{
return Task.FromResult<Circuit>(null);
}
db.Add(circuitEntity);
db.SaveChanges();
}
return Task.FromResult<Circuit>(circuitEntity.EntityToModele());
}
}
}

@ -0,0 +1,81 @@
using Entity_Framework;
using Entity_Framework.Entity;
using Entity_Framework.Factories;
using Modele.Classe;
using System.Collections.Generic;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<IEnumerable<Ecurie>> GetEcuries()
{
IEnumerable<Ecurie> result = new List<Ecurie>();
using (BDDContext db = new BDDContext())
{
result = db.Ecuries.ToList().Select(e => e.EntityToModele());
}
return Task.FromResult<IEnumerable<Ecurie>>(result);
}
public Task<Ecurie> GetOneEcurie(string name)
{
Ecuries ecurie = new Ecuries();
using (BDDContext db = new BDDContext())
{
ecurie = db.Ecuries.Where(e => e.Name == name).FirstOrDefault();
}
if(ecurie == null)
{
return Task.FromResult<Ecurie>(null);
}
return Task.FromResult<Ecurie>(ecurie.EntityToModele());
}
public Task<List<int>> AddEcurie(Ecurie ecurie, string pseudo)
{
// IEnumerable<int>
//Indice 0 : Réussi ou pas -> value : 0 ok / 1 erreur
//Indice 1 : L'erreur -> Value : 2 nom ecurie / 3 pilote introuvable / 4 fait déjà partie d'une ecurie
List<int> result = new List<int>();
Ecuries ecurieEntity = ecurie.ModeleToEntity();
using (BDDContext db = new BDDContext())
{
bool checkEcurieName = db.Ecuries.Any(e => e.Name == ecurie.name);
if (checkEcurieName == true)
{
result.Add(1);
result.Add(2);
return Task.FromResult<List<int>>(result);
}
bool chackPilotePseudo = db.Pilotes.Any(e => e.Pseudo == pseudo);
if ( chackPilotePseudo == false )
{
result.Add(1);
result.Add(3);
return Task.FromResult<List<int>>(result);
}
int idPilote = db.Pilotes.Where(e => e.Pseudo == pseudo).First().Id;
bool checkPiloteWithEcurie = db.Ecuries.Any( e => e.IdPiloteProprietaire == idPilote);
if (checkPiloteWithEcurie == true )
{
result.Add(1);
result.Add(4);
return Task.FromResult<List<int>>(result);
}
ecurieEntity.IdPiloteProprietaire = idPilote;
db.Add(ecurieEntity);
db.SaveChanges();
}
result.Add(0);
return Task.FromResult<List<int>>(result);
}
}
}

@ -0,0 +1,35 @@
using Entity_Framework.Entity;
using Entity_Framework;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity_Framework.Factories;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<Geolocalisation> GetGeolocalisations(long IdPoint)
{
/*Geolocalisations result = new Geolocalisations();
using (BDDContext db = new BDDContext())
{
bool checkPoint = db.Points.Any(e => e.Id == IdPoint);
if (checkPoint == false)
{
return Task.FromResult<Geolocalisation>(null);
}
result = (from geo in db.Geolocalisations
from point in db.Points
where geo.Id == point.IdGeolocalisation
select geo).First();
}
return Task.FromResult<Geolocalisation>(result.EntityToModele());*/
return null;
}
}
}

@ -0,0 +1,29 @@
using Entity_Framework;
using Entity_Framework.Entity;
using Entity_Framework.Factories;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<Image> GetImage(int IdPilote)
{
Images image = new Images();
using (BDDContext db = new BDDContext())
{
image = db.Images.Where( e => e.IdPilote == IdPilote).FirstOrDefault();
}
if ( image == null)
{
return Task.FromResult<Image>(null);
}
return Task.FromResult<Image>(image.EntityToModele());
}
}
}

@ -0,0 +1,76 @@
using Dto.Classe;
using Dto.Factories;
using Entity_Framework;
using Entity_Framework.Entity;
using Entity_Framework.Factories;
using Modele.Classe;
using System.Security.Cryptography;
using System.Text;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<IEnumerable<Pilote>> GetPilotes()
{
IEnumerable<Pilote> result = new List<Pilote>();
using (BDDContext db = new BDDContext())
{
result = db.Pilotes.ToList().Select(e => e.EntityToModele());
}
return Task.FromResult(result);
}
public Task<Pilote> GetOnePilote(string pseudo)
{
Pilotes pilote = new Pilotes();
using (BDDContext db = new BDDContext())
{
pilote = db.Pilotes.Where( e => e.Pseudo == pseudo).FirstOrDefault();
}
if (pilote == null)
{
return Task.FromResult<Pilote>(null);
}
return Task.FromResult<Pilote>(pilote.EntityToModele());
}
public Task<Pilote> AddPilote(Pilote pilote)
{
Pilotes piloteEntity = pilote.ModeleToEntity();
using (BDDContext db = new BDDContext())
{
IEnumerable<Pilotes> piloteCheck = db.Pilotes.Where(e => e.Pseudo == piloteEntity.Pseudo );
if (piloteCheck.Count() != 0)
{
return Task.FromResult<Pilote>(null);
}
db.Add(piloteEntity);
db.SaveChanges();
}
return Task.FromResult<Pilote>(pilote);
}
public Task<Pilote> CheckPilote(string Email, string password)
{
byte[] passwordByte = Encoding.UTF8.GetBytes(password);
SHA256 sha256 = SHA256.Create();
byte[] hashedByte = sha256.ComputeHash(passwordByte);
string hashedPassword = Convert.ToBase64String(hashedByte);
using (BDDContext db = new BDDContext())
{
Pilotes pilote = db.Pilotes.Where(e => e.Email == Email && e.Password == hashedPassword).FirstOrDefault();
if (pilote == null)
{
return Task.FromResult<Pilote>(null);
}
return Task.FromResult(pilote.EntityToModele());
}
}
}
}

@ -0,0 +1,34 @@
using Entity_Framework;
using Entity_Framework.Entity;
using Entity_Framework.Factories;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<IEnumerable<Point>> GetPoints(long IdTour)
{
IEnumerable<Points> result = new List<Points>();
using (BDDContext db = new BDDContext())
{
bool checkTour = db.Tours.Any(e => e.Id == IdTour);
if (checkTour == false)
{
return Task.FromResult<IEnumerable<Point>>(null);
}
result = (from tour in db.Tours
from point in db.Points
where tour.Id == point.IdTours
select point).ToList();
}
return Task.FromResult<IEnumerable<Point>>(result.Select( e => e.EntityToModele()));
}
}
}

@ -0,0 +1,100 @@
using Entity_Framework.Entity;
using Entity_Framework;
using Modele.Classe;
using Entity_Framework.Factories;
using Dto.Factories;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<IEnumerable<Session>> GetSessionsByPilotes(string pseudo)
{
IEnumerable<Sessions> result = new List<Sessions>();
using (BDDContext db = new BDDContext())
{
bool checkPilote = db.Pilotes.Any(e => e.Pseudo == pseudo);
if (checkPilote == false)
{
return Task.FromResult<IEnumerable<Session>>(null);
}
result = (from session in db.Sessions
from pilotes in db.Pilotes
where pilotes.Id == session.IdPilote
select session).ToList();
}
return Task.FromResult<IEnumerable<Session>>(result.Select( e => e.EntityToModele()));
}
public Task<Session> AddSession(Session session,string namePseudo,string nameCircuit,string nameSession,string typeSession)
{
int idPilote;
using (BDDContext db = new BDDContext())
{
// Check si pilote existe
Pilotes piloteEntity = db.Pilotes.Where(e => e.Pseudo == namePseudo).FirstOrDefault();
if (piloteEntity == null)
{
return Task.FromResult<Session>(null);
}
idPilote = piloteEntity.Id;
// Check si circuit existe
Circuits circuitEntity = db.Circuits.Where( e => e.Name == nameCircuit).FirstOrDefault();
Sessions sessionsEntity = session.ModeleToEntity();
if(circuitEntity != null)
{
sessionsEntity.IdCircuit = circuitEntity.Id;
}
sessionsEntity.IdPilote = piloteEntity.Id;
sessionsEntity.Name = nameSession;
sessionsEntity.Type = typeSession;
db.Sessions.Add(sessionsEntity);
db.SaveChanges();
}
Console.WriteLine("Session fini !");
long idSession;
IEnumerable<Tours> tours = session.Tours.Select( e => e.ModeleToEntity());
using (BDDContext db = new BDDContext())
{
Sessions sessions = db.Sessions.Where(e => e.Name == nameSession && e.IdPilote == idPilote).First();
idSession = sessions.Id;
foreach (Tours tour in tours)
{
tour.IdSession = idSession;
db.Add(tour);
}
db.SaveChanges();
}
Console.WriteLine("Tour fini !");
using (BDDContext db = new BDDContext())
{
int i = 1;
foreach (Tour tour in session.Tours)
{
long idTour = db.Tours.Where(e => e.Numero == i && e.IdSession == idSession).First().Id;
foreach (Point point in tour.Points)
{
Points entityPoint = point.ModeleToEntity();
entityPoint.IdTours = idTour;
db.Points.Add(entityPoint);
}
i++;
}
db.SaveChanges();
}
Console.WriteLine("Point fini !");
return Task.FromResult<Session>(session);
}
}
}

@ -0,0 +1,34 @@
using Entity_Framework;
using Entity_Framework.Entity;
using Entity_Framework.Factories;
using Modele.Classe;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Extraction_Donnees.Extraction
{
public partial class Extraction
{
public Task<IEnumerable<Tour>> GetTours(long IdSession)
{
IEnumerable<Tours> result = new List<Tours>();
using (BDDContext db = new BDDContext())
{
bool checkSession = db.Sessions.Any(e => e.Id == IdSession);
if (checkSession == false)
{
return Task.FromResult<IEnumerable<Tour>>(null);
}
result = (from tour in db.Tours
from session in db.Sessions
where session.Id == tour.IdSession
select tour).ToList();
}
return Task.FromResult<IEnumerable<Tour>>(result.Select(e => e.EntityToModele()));
}
}
}

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Content Remove="C:\Users\zinn1\.nuget\packages\dotnetcore.npoi\1.2.3\contentFiles\any\netstandard2.0\NOTICE.TXT" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="DotNetCore.NPOI" Version="1.2.3" />
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
<PackageReference Include="ExcelDataReader.DataSet" Version="3.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
<PackageReference Include="Spire.XLS" Version="13.2.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dto\Dto.csproj" />
<ProjectReference Include="..\Entity_Framework\Entity_Framework.csproj" />
<ProjectReference Include="..\Interface\Interface.csproj" />
<ProjectReference Include="..\Modele\Modele.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,322 @@

using ExcelDataReader;
using Microsoft.AspNetCore.Http;
using Modele.Classe;
using System.Text.RegularExpressions;
using Spire.Xls;
using NPOI;
using NPOI.POIFS.FileSystem;
using NPOI.HSSF.UserModel;
using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using System.Data;
using System.Globalization;
namespace Extraction_Donnees.Extraction_EXECL
{
public static class Excel
{
// FONCTION A UTILISER POUR RECUPERER LES DONNES EXCEL AVEC L'API
public static async Task<Session> ReadExcel(IFormFile file)
{
var session = new Session();
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
using (var stream = new MemoryStream())
{
file.CopyTo(stream);
stream.Position = 0;
/* int tourNo = -1;
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
while (reader.Read())
{
if (reader.GetValue(2) == null) break;
if (reader.Depth == 0) continue; // sauter les en-têtes
var tourExtrait = reader.GetString(0);
if (!string.IsNullOrEmpty(tourExtrait))
{
tourNo = Int32.Parse(Regex.Match(tourExtrait, @"\d+").Value); // récupérer le numéro du tour
Tour tour = new Tour(tourNo, reader.GetString(1)); // création du tour
session.Tours.Add(tour); // ajouter le tour sans points à la session
}
try
{
var point = new Point(
new Geolocalisation(reader.GetDouble(11), reader.GetDouble(12)),
(float)reader.GetDouble(2),
(float)reader.GetDouble(3),
(float)reader.GetDouble(4),
(float)reader.GetDouble(5),
(float)reader.GetDouble(6),
(float)reader.GetDouble(7),
(float)reader.GetDouble(8),
(float)reader.GetDouble(9),
(float)reader.GetDouble(10));
if (tourNo != -1)
{
session.Tours.Find(t => t.Nombre == tourNo).Points.Add(point);
}
else
{
throw new ArgumentException("Aucun tour n'a été trouvé dans le fichier !");
}
}
catch (IndexOutOfRangeException e)
{
throw new ArgumentException($"Problème lors de la lecture des données, données manquantes ! (colonnes manquantes dans l'Excel). {e.Message}");
}
}
}*/
using (var reader = new StreamReader(stream))
{
int cpt = 0;
int tourNo = -1;
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
cpt++;
var values = line.Split('\t');
if (cpt == 1) continue;
if (values.Count() < 4)
break;
if (reader.Peek() == -1) break;
if (values[0].ToLower().Contains("lap:"))
{
tourNo = Int32.Parse(Regex.Match(values[0], @"\d+").Value); // récupérer le numéro du tour
Tour tour = new Tour(tourNo, values[1]); // création du tour
session.Tours.Add(tour); // ajouter le tour sans points à la session
}
else
{
try
{
var point = new Point(
double.Parse(values[11], CultureInfo.InvariantCulture),
double.Parse(values[12], CultureInfo.InvariantCulture),
float.Parse(values[2], CultureInfo.InvariantCulture),
float.Parse(values[3], CultureInfo.InvariantCulture),
float.Parse(values[4], CultureInfo.InvariantCulture),
float.Parse(values[5], CultureInfo.InvariantCulture),
float.Parse(values[6], CultureInfo.InvariantCulture),
float.Parse(values[7], CultureInfo.InvariantCulture),
float.Parse(values[8], CultureInfo.InvariantCulture),
float.Parse(values[9], CultureInfo.InvariantCulture),
float.Parse(values[10], CultureInfo.InvariantCulture)
);
if (tourNo != -1)
{
session.Tours.Find(t => t.Numero == tourNo).Points.Add(point);
}
else
{
throw new ArgumentException("Aucun tour n'a été trouvé dans le fichier !");
}
}
catch (IndexOutOfRangeException e)
{
throw new ArgumentException($"Problème lors de la lecture des données, données manquantes ! (colonnes manquantes dans l'Excel). {e.Message}");
}
}
}
}
}
return session;
}
public static Session TestExcel(string filePath)
{
var session = new Session();
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
int tourNo = -1;
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
while (reader.Read())
{
if (reader.GetValue(2) == null) break;
if (reader.Depth == 0) continue; // sauter les en-têtes
var tourExtrait = reader.GetString(0);
if (!string.IsNullOrEmpty(tourExtrait))
{
tourNo = Int32.Parse(Regex.Match(tourExtrait, @"\d+").Value); // récupérer le numéro du tour
Tour tour = new Tour(tourNo, reader.GetString(1)); // création du tour
session.Tours.Add(tour); // ajouter le tour sans points à la session
}
try
{
var point = new Point(
reader.GetDouble(11),
reader.GetDouble(12),
(float)reader.GetDouble(2),
(float)reader.GetDouble(3),
(float)reader.GetDouble(4),
(float)reader.GetDouble(5),
(float)reader.GetDouble(6),
(float)reader.GetDouble(7),
(float)reader.GetDouble(8),
(float)reader.GetDouble(9),
(float)reader.GetDouble(10)) ;
if (tourNo != -1)
{
session.Tours.Find(t => t.Numero == tourNo).Points.Add(point);
}
else
{
throw new ArgumentException("Aucun tour n'a été trouvé dans le fichier !");
}
}
catch (IndexOutOfRangeException e)
{
throw new ArgumentException($"Problème lors de la lecture des données, données manquantes ! (colonnes manquantes dans l'Excel). {e.Message}");
}
}
}
}
return session;
}
public static async Task<Session> TestExcel2(string filePath)
{
var session = new Session();
using (var reader = new StreamReader(filePath))
{
int cpt = 0;
int tourNo = -1;
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
cpt++;
var values = line.Split('\t');
if (cpt == 1) continue;
if (values.Count() < 4)
break;
if (reader.Peek() == -1) break;
if (values[0].ToLower().Contains("lap:"))
{
tourNo = Int32.Parse(Regex.Match(values[0], @"\d+").Value); // récupérer le numéro du tour
Tour tour = new Tour(tourNo, values[1]); // création du tour
session.Tours.Add(tour); // ajouter le tour sans points à la session
}
else
{
try
{
var point = new Point(
double.Parse(values[11], CultureInfo.InvariantCulture),
double.Parse(values[12], CultureInfo.InvariantCulture),
float.Parse(values[2], CultureInfo.InvariantCulture),
float.Parse(values[3], CultureInfo.InvariantCulture),
float.Parse(values[4], CultureInfo.InvariantCulture),
float.Parse(values[5], CultureInfo.InvariantCulture),
float.Parse(values[6], CultureInfo.InvariantCulture),
float.Parse(values[7], CultureInfo.InvariantCulture),
float.Parse(values[8], CultureInfo.InvariantCulture),
float.Parse(values[9], CultureInfo.InvariantCulture),
float.Parse(values[10], CultureInfo.InvariantCulture)
);
if (tourNo != -1)
{
session.Tours.Find(t => t.Numero == tourNo).Points.Add(point);
}
else
{
throw new ArgumentException("Aucun tour n'a été trouvé dans le fichier !");
}
}
catch (IndexOutOfRangeException e)
{
throw new ArgumentException($"Problème lors de la lecture des données, données manquantes ! (colonnes manquantes dans l'Excel). {e.Message}");
}
}
}
}
return session;
}
public static DataTable TextExcel3(string filePath)
{
DataTable dt = new DataTable();
try
{
using (StreamReader sr = new StreamReader(filePath))
{
// read the header line and create columns in the DataTable
string[] headers = sr.ReadLine().Split('\t');
foreach (string header in headers)
{
dt.Columns.Add(header.Trim());
}
// read the data lines and add rows to the DataTable
while (!sr.EndOfStream)
{
string[] values = sr.ReadLine().Split('\t');
DataRow row = dt.NewRow();
for (int i = 0; i < headers.Length; i++)
{
if (i < values.Length)
{
row[i] = values[i].Trim();
}
else
{
row[i] = "";
}
}
dt.Rows.Add(row);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error reading file: " + ex.Message);
}
return dt;
}
public static string OpenDIS(string path)
{
try
{
string text = File.ReadAllText(path);
return text;
}
catch (IOException e)
{
Console.WriteLine($"Error reading file: {e.Message}");
}
return "l";
}
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Extraction_Donnees\Extraction_Donnees.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,35 @@

using Extraction_Donnees.Extraction;
using Extraction_Donnees.Extraction_EXECL;
using Interface;
using Modele.Classe;
using NPOI.SS.Formula.Functions;
/*
var p = "C:\\Users\\Jolys Enzo\\home\\BUT\\Projet\\Sae4.01\\Projet\\R-Dash_APP\\Extraction_Excel_Test\\tmp.xls";
var sesh = await Excel.TestExcel2(p);
if (sesh == null)
{
Console.WriteLine("L READ G");
}
else
{
Console.WriteLine(sesh.ToString());
foreach (var tour in sesh.Tours)
{
Console.WriteLine(tour.ToString());
}
}
Console.WriteLine("Tours : " + sesh.Tours.Count);
*/
IApi data = new Extraction();
Session session = await Excel.TestExcel2("C:\\Users\\Jolys Enzo\\home\\BUT\\Projet\\Sae4.01\\Projet\\R-Dash_APP\\Extraction_Excel_Test\\tmp.xls");
Console.WriteLine("Start !");
await data.AddSession(session, "test_PILOTE", "test_CIRCUIT","Session_test","Championnat");
Console.WriteLine("Fini !");

File diff suppressed because it is too large Load Diff

@ -0,0 +1,44 @@
using Dto.Classe;
using Modele.Classe;
namespace Interface
{
public interface IApi
{
// Pilotes
Task<IEnumerable<Pilote>> GetPilotes();
Task<Pilote> GetOnePilote(string pseudo);
Task<Pilote> AddPilote(Pilote pilote);
Task<Pilote> CheckPilote(string Email, string password);
// Ecuries
Task<IEnumerable<Ecurie>> GetEcuries();
Task<Ecurie> GetOneEcurie(string name);
Task<List<int>> AddEcurie(Ecurie ecurie,string pseudo);
// Circuits
Task<IEnumerable<Circuit>> GetCircuits();
Task<Circuit> GetOneCircuit(string name);
Task<Circuit> AddCircuit(Circuit circuit);
// Session
Task<IEnumerable<Session>> GetSessionsByPilotes(string pseudo);
Task<Session> AddSession(Session session, string namePseudo, string nameCircuit,string nameSession,string typeSession);
// Tours
Task<IEnumerable<Tour>> GetTours(long IdSession);
// Point
Task<IEnumerable<Point>> GetPoints(long IdTour);
// Geolocalisation
Task<Geolocalisation> GetGeolocalisations(long IdPoint);
//Image
Task<Image> GetImage(int IdPilote);
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Dto\Dto.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Circuit
{
public string name { get; set; }
public Circuit(string nameArg = "Inconnu !")
{
name = nameArg;
}
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Ecurie
{
public string name { get; set; }
public Ecurie(string nameArg = "Inconnu !")
{
name = nameArg;
}
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Geolocalisation
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public Geolocalisation(double LatitudeArg,double LongitudeArg)
{
Latitude = LatitudeArg;
Longitude = LongitudeArg;
}
}
}

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Image
{
public string Base64 { get; set; }
public Image(string base64)
{
Base64 = base64;
}
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Pilote
{
public string Pseudo { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public Pilote(string _Pseudo, string _Email, string _Password)
{
Pseudo = _Pseudo;
Email = _Email;
Password = _Password;
}
public Pilote() { }
}
}

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Point
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public float Timer { get; set; }
public float Distance { get; set; }
public float NGear { get; set; }
public float PBrakeF { get; set; }
public float ASteer { get; set; }
public float RPedal { get; set; }
public float GLong { get; set; }
public float GLat { get; set; }
public float VCar { get; set; }
public Point(double longitude,double latitude, float timer, float distance, float nGear, float pBrakeF, float aSteer, float rPedal, float gLong, float gLat, float vCar)
{
Latitude = latitude;
Longitude = longitude;
Timer = timer;
Distance = distance;
NGear = nGear;
PBrakeF = pBrakeF;
ASteer = aSteer;
RPedal = rPedal;
GLong = gLong;
GLat = gLat;
VCar = vCar;
}
}
}

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modele.Classe
{
public class Session
{
public long Id { get; set; }
public string name { get; set; }
public string type { get; set; }
public DateTime date { get; set; }
public string nameCircuit { get; set; }
public string namePilote { set; get; }
public List<Tour> Tours { get; set; }
public Session()
{
Tours = new List<Tour>();
}
public Session(long IdArg,DateTime dateArg,string nameArg = "Inconnu !",string typeArg = "Inconnu !",string nameCircuitArg = "Inconnu !",string namePiloteArg = "Inconnu !")
{
name = nameArg;
type = typeArg;
nameCircuit = nameCircuitArg;
namePilote = namePiloteArg;
date = dateArg;
Id = IdArg;
}
public Session(List<Tour> tours, long IdArg, DateTime dateArg, string nameArg = "Inconnu !", string typeArg = "Inconnu !", string nameCircuitArg = "Inconnu !", string namePiloteArg = "Inconnu !")
{
name = nameArg;
type = typeArg;
nameCircuit = nameCircuitArg;
namePilote = namePiloteArg;
date = dateArg;
Id = IdArg;
Tours = tours;
}
public override string ToString()
{
string sb = "";
foreach (Tour tour in Tours)
{
sb += tour.ToString();
}
return sb;
}
}
}

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//classe tour
namespace Modele.Classe
{
public class Tour
{
public string Temps { get; set; }
public int Numero { get; set; }
public long IdSession { get; set; }
public List<Point> Points { get; set; }
public Tour(string TempsArg,long IdSessionArg)
{
Temps = TempsArg;
IdSession = IdSessionArg;
}
public Tour(int nombre, string temps)
{
Numero = nombre;
Temps = temps;
Points = new List<Point>();
}
public override string ToString()
{
string sb = "-";
sb+=$"Tour {Numero}: {Temps}\n";
foreach (Point point in Points)
{
sb += $"\tTime: {point.Timer}, Distance: {point.Distance}\n";
sb += $"\tNGear: {point.NGear}, PBrakeF: {point.PBrakeF}, ASteer: {point.ASteer}\n";
sb += $"\tRPedal: {point.RPedal}, GLong: {point.GLong}, GLat: {point.GLat}\n";
sb += $"\tVCar: {point.VCar}, Geo: {point.Latitude}, {point.Longitude}\n\n";
}
return sb;
}
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,3 @@
Api R-Dash !!
Modif !!!
Loading…
Cancel
Save