POS_Sprint_2 #4
@ -12,20 +12,24 @@ using System.Collections.Generic;
|
||||
using System.Security;
|
||||
using System.Net;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace Klient.Droid
|
||||
{
|
||||
[Activity(Label = "Klient", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||
{
|
||||
public static int PickImageId = 1000;
|
||||
private static readonly HttpClient client = new HttpClient();
|
||||
public static Android.Content.Intent photo;
|
||||
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
|
||||
base.OnCreate(savedInstanceState);
|
||||
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
LoadApplication(new App());
|
||||
SetContentView(Resource.Layout.ekranLogowania);
|
||||
SetContentView(Resource.Layout.ekranStartowy);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("SignIn")]
|
||||
@ -34,11 +38,11 @@ namespace Klient.Droid
|
||||
var Login = FindViewById<EditText>(Resource.Id.Login).Text;
|
||||
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.Password).Text).SecurePassword;
|
||||
|
||||
if(Login.Length < 3 || Login.Length > 12)
|
||||
if (Login.Length < 3 || Login.Length > 12)
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranLogowania);
|
||||
}
|
||||
if(string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
|
||||
if (string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranLogowania);
|
||||
}
|
||||
@ -51,19 +55,20 @@ namespace Klient.Droid
|
||||
|
||||
var content = new FormUrlEncodedContent(values);
|
||||
|
||||
var response = await client.PostAsync("https://localhost:44371/api/User/SignIn", content);
|
||||
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranPoLogowaniu);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("ResetPassword")]
|
||||
async public void ResetPassword()
|
||||
{
|
||||
|
||||
SetContentView(Resource.Layout.ekranLogowania);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("SignUp")]
|
||||
async public void SignUp()
|
||||
async public void SignUp(View v)
|
||||
{
|
||||
var Name = FindViewById<EditText>(Resource.Id.Name).Text;
|
||||
var Surname = FindViewById<EditText>(Resource.Id.Surname).Text;
|
||||
@ -72,7 +77,7 @@ namespace Klient.Droid
|
||||
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.NewPassword).Text).SecurePassword;
|
||||
SecureString Password2 = new NetworkCredential("", FindViewById<EditText>(Resource.Id.RepeatPassword).Text).SecurePassword;
|
||||
|
||||
if(new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
|
||||
if (new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranRejestracji);
|
||||
}
|
||||
@ -88,9 +93,11 @@ namespace Klient.Droid
|
||||
|
||||
var content = new FormUrlEncodedContent(values);
|
||||
|
||||
var response = await client.PostAsync("https://localhost:44371/api/User/Register", content);
|
||||
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Register", content);
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK) SetContentView(Resource.Layout.ekranLogowania);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("HelpLoginScreen")]
|
||||
@ -98,5 +105,61 @@ namespace Klient.Droid
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranRejestracji);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("SignInMainScreen")]
|
||||
public void MainScreenSignIn(View v)
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranLogowania);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("SignUpMainScreen")]
|
||||
public void MainScreenSignUp(View v)
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranRejestracji);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("about")]
|
||||
public void MainScreenAbout(View v)
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranStartowy);
|
||||
}
|
||||
|
||||
[Java.Interop.Export("LoadFromFolder")]
|
||||
public void LoadFile(View v)
|
||||
{
|
||||
Intent = new Android.Content.Intent();
|
||||
Intent.SetType("image/*");
|
||||
Intent.SetAction(Android.Content.Intent.ActionGetContent);
|
||||
|
||||
StartActivityForResult(Android.Content.Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
|
||||
}
|
||||
|
||||
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
|
||||
{
|
||||
SetContentView(Resource.Layout.ekranPoZdjeciu);
|
||||
Android.Net.Uri uri = data.Data;
|
||||
photo = data;
|
||||
FindViewById<ImageView>(Resource.Id.Preview).SetImageURI(uri);
|
||||
|
||||
}
|
||||
|
||||
[Java.Interop.Export("SendPhoto")]
|
||||
async public void UploadPhoto(View v)
|
||||
{
|
||||
using(var imageStream = ContentResolver.OpenInputStream(photo.Data))
|
||||
using(var stramContent = new StreamContent(imageStream))
|
||||
using(var byteArrayContent = new ByteArrayContent(await stramContent.ReadAsByteArrayAsync()))
|
||||
using(var formDataContent = new MultipartFormDataContent())
|
||||
{
|
||||
formDataContent.Add(byteArrayContent, "image", Guid.NewGuid() + ".jpg");
|
||||
foreach (var content in formDataContent)
|
||||
{
|
||||
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentResolver.GetType(photo.Data));
|
||||
break;
|
||||
}
|
||||
var response = await client.PostAsync("http://10.0.2.2:5001/api/Image/Process", formDataContent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@
|
||||
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
||||
<BundleAssemblies>false</BundleAssemblies>
|
||||
<MandroidI18n />
|
||||
<Debugger>Xamarin</Debugger>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -98,7 +99,6 @@
|
||||
<Folder Include="Resources\drawable-xhdpi\" />
|
||||
<Folder Include="Resources\drawable-xxhdpi\" />
|
||||
<Folder Include="Resources\drawable-xxxhdpi\" />
|
||||
<Folder Include="Resources\drawable\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Klient\Klient.csproj">
|
||||
@ -116,6 +116,27 @@
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\ekranStartowy.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\ekranPoLogowaniu.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\Obraz2.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\Obraz1.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\ekranPoZdjeciu.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.Klient.Android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.Klient.Android" android:installLocation="preferExternal">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
|
||||
<application android:label="Klient.Android"></application>
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application android:label="Klient.Android" android:usesCleartextTraffic="true" />
|
||||
</manifest>
|
1270
Klient/Klient/Klient.Android/Resources/Resource.designer.cs
generated
1270
Klient/Klient/Klient.Android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
BIN
Klient/Klient/Klient.Android/Resources/drawable/Obraz1.png
Normal file
BIN
Klient/Klient/Klient.Android/Resources/drawable/Obraz1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 982 B |
BIN
Klient/Klient/Klient.Android/Resources/drawable/Obraz2.png
Normal file
BIN
Klient/Klient/Klient.Android/Resources/drawable/Obraz2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#ffbdd7f0">
|
||||
<ImageButton
|
||||
android:src="@drawable/Obraz1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="80px"
|
||||
android:minHeight="80px"
|
||||
android:id="@+id/LoadFromFolder"
|
||||
android:contentDescription="Wybieranie z pliku"
|
||||
android:background="#ffbdd7f0"
|
||||
android:layout_below="@+id/text5"
|
||||
android:layout_alignParentRight="false"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="75dp"
|
||||
android:onClick="LoadFromFolder" />
|
||||
<TextView
|
||||
android:text="Poszukiwacz 2020"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/text3"
|
||||
android:textColor="#ff000000"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
<TextView
|
||||
android:text="Załaduj zdjęcie"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/text5"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginVertical="100dp"
|
||||
android:textSize="45dp"
|
||||
android:textColor="#ff000000"
|
||||
android:gravity="center" />
|
||||
<ImageButton
|
||||
android:src="@drawable/obraz2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/LoadFromCamera"
|
||||
android:contentDescription="Zrób zdjęcie"
|
||||
android:background="#ffbdd7f0"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@+id/text5"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="75dp"
|
||||
android:onClick="LoadFromCamera" />
|
||||
</RelativeLayout>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#ffbdd7f0">
|
||||
<ImageView
|
||||
android:src="@android:drawable/ic_menu_gallery"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="217.5dp"
|
||||
android:minWidth="100px"
|
||||
android:minHeight="100px"
|
||||
android:id="@+id/Preview" />
|
||||
<Button
|
||||
android:text="Wyślij zdjęcie"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/SendPhoto"
|
||||
android:onClick="SendPhoto"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#ffbdd7f0">
|
||||
<TextView
|
||||
android:text="Poszukiwacz"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="25px"
|
||||
android:minHeight="25px"
|
||||
android:id="@+id/text4"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textColor="#ff000000"
|
||||
android:textStyle="bold"
|
||||
android:textSize="45dp"
|
||||
android:layout_marginVertical="100dp" />
|
||||
<TextView
|
||||
android:text="Poszukiwacz 2020"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/text1"
|
||||
android:textColor="#ff000000"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
<Button
|
||||
android:text="?"
|
||||
android:layout_width="35.0dp"
|
||||
android:layout_height="35.0dp"
|
||||
android:id="@+id/help"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="#ff0b31c8"
|
||||
android:textColor="#fffcfcfc"
|
||||
android:gravity="center"
|
||||
android:onClick="HelpLoginScreen" />
|
||||
<Button
|
||||
android:text="I"
|
||||
android:layout_width="35.0dp"
|
||||
android:layout_height="35.0dp"
|
||||
android:id="@+id/about"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="#ff0b31c8"
|
||||
android:textColor="#fffcfcfc"
|
||||
android:gravity="center"
|
||||
android:onClick="AboutMainScreen" />
|
||||
<Button
|
||||
android:text="Zaloguj"
|
||||
android:layout_width="200.0dp"
|
||||
android:layout_height="70.0dp"
|
||||
android:id="@+id/SignInMainScreen"
|
||||
android:layout_alignParentLeft="false"
|
||||
android:layout_centerInParent="true"
|
||||
android:onClick="SignInMainScreen" />
|
||||
<Button
|
||||
android:text="Stwórz konto"
|
||||
android:layout_width="200.0dp"
|
||||
android:layout_height="50.0dp"
|
||||
android:id="@+id/SignUpMainScreen"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_below="@+id/SignInMainScreen"
|
||||
android:layout_marginVertical="15dp"
|
||||
android:onClick="SignUpMainScreen" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
12
Serwer/Serwer.Api/.config/dotnet-tools.json
Normal file
12
Serwer/Serwer.Api/.config/dotnet-tools.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "5.0.1",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
37
Serwer/Serwer.Api/Controllers/ImageController.cs
Normal file
37
Serwer/Serwer.Api/Controllers/ImageController.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serwer.Infrastructure.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Api.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ImageController : ControllerBase
|
||||
{
|
||||
private readonly IImageService _imageService;
|
||||
public ImageController(IImageService imageService)
|
||||
{
|
||||
_imageService = imageService;
|
||||
}
|
||||
|
||||
[HttpPost("Process")]
|
||||
public async Task<IActionResult> Process([FromForm]IFormFile image)
|
||||
{
|
||||
if(image == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await image.CopyToAsync(memoryStream);
|
||||
var response = await _imageService.Process(image.Name, image.ContentType, memoryStream.ToArray());
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serwer.Infrastructure.DTO;
|
||||
using Serwer.Infrastructure.Services;
|
||||
using Serwer.Infrastructure.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -20,17 +21,17 @@ namespace Serwer.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("Register")]
|
||||
public async Task<IActionResult> Register(string email, string name, string surname, string login, string password)
|
||||
public async Task<IActionResult> Register([FromForm]RegisterModel request)
|
||||
{
|
||||
await _userService.RegisterAsync(email, name, surname, login, password);
|
||||
await _userService.RegisterAsync(request.Email, request.Name, request.Surname, request.Login, request.Password);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("SignIn")]
|
||||
public async Task<IActionResult> SignIn(string login, string password)
|
||||
public async Task<IActionResult> SignIn([FromForm]SignInModel request)
|
||||
{
|
||||
var user = await _userService.SignInAsync(login, password);
|
||||
var user = await _userService.SignInAsync(request.Login, request.Password);
|
||||
return Ok(user);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ namespace Serwer.Api
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
webBuilder.UseUrls("http://localhost:5001");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,113 @@
|
||||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"metadata": {
|
||||
"_dependencyType": "appService.windows"
|
||||
},
|
||||
"parameters": {
|
||||
"resourceGroupName": {
|
||||
"type": "string",
|
||||
"defaultValue": "PixBlocksAdditionResourceGroup",
|
||||
"metadata": {
|
||||
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
|
||||
}
|
||||
},
|
||||
"resourceGroupLocation": {
|
||||
"type": "string",
|
||||
"defaultValue": "centralus",
|
||||
"metadata": {
|
||||
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
|
||||
}
|
||||
},
|
||||
"resourceName": {
|
||||
"type": "string",
|
||||
"defaultValue": "PixBlocksAddition",
|
||||
"metadata": {
|
||||
"description": "Name of the main resource to be created by this template."
|
||||
}
|
||||
},
|
||||
"resourceLocation": {
|
||||
"type": "string",
|
||||
"defaultValue": "[parameters('resourceGroupLocation')]",
|
||||
"metadata": {
|
||||
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
|
||||
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Resources/resourceGroups",
|
||||
"name": "[parameters('resourceGroupName')]",
|
||||
"location": "[parameters('resourceGroupLocation')]",
|
||||
"apiVersion": "2019-10-01"
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
|
||||
"resourceGroup": "[parameters('resourceGroupName')]",
|
||||
"apiVersion": "2019-10-01",
|
||||
"dependsOn": [
|
||||
"[parameters('resourceGroupName')]"
|
||||
],
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": [
|
||||
{
|
||||
"location": "[parameters('resourceLocation')]",
|
||||
"name": "[parameters('resourceName')]",
|
||||
"type": "Microsoft.Web/sites",
|
||||
"apiVersion": "2015-08-01",
|
||||
"tags": {
|
||||
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[variables('appServicePlan_ResourceId')]"
|
||||
],
|
||||
"kind": "app",
|
||||
"properties": {
|
||||
"name": "[parameters('resourceName')]",
|
||||
"kind": "app",
|
||||
"httpsOnly": true,
|
||||
"reserved": false,
|
||||
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
|
||||
"siteConfig": {
|
||||
"metadata": [
|
||||
{
|
||||
"name": "CURRENT_STACK",
|
||||
"value": "dotnetcore"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"identity": {
|
||||
"type": "SystemAssigned"
|
||||
}
|
||||
},
|
||||
{
|
||||
"location": "[parameters('resourceLocation')]",
|
||||
"name": "[variables('appServicePlan_name')]",
|
||||
"type": "Microsoft.Web/serverFarms",
|
||||
"apiVersion": "2015-08-01",
|
||||
"sku": {
|
||||
"name": "S1",
|
||||
"tier": "Standard",
|
||||
"family": "S",
|
||||
"size": "S1"
|
||||
},
|
||||
"properties": {
|
||||
"name": "[variables('appServicePlan_name')]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
"dotnetRunMessages": "true",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"applicationUrl": "http://localhost:5001;https://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
@ -4,6 +4,10 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="wwwroot\tessdata\eng.traineddata" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" NoWarn="NU1605" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" NoWarn="NU1605" />
|
||||
@ -15,4 +19,8 @@
|
||||
<ProjectReference Include="..\Serwer.Infrastructure\Serwer.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="wwwroot\tessdata\eng.traineddata" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -25,12 +25,14 @@ namespace Serwer.Api
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
public Startup(IConfiguration configuration, IWebHostEnvironment env)
|
||||
{
|
||||
Configuration = configuration;
|
||||
WebRootPath = env.WebRootPath;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
protected string WebRootPath { get; set; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
@ -41,6 +43,7 @@ namespace Serwer.Api
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Serwer.Api", Version = "v1" });
|
||||
});
|
||||
|
||||
var hostEnviroment = new HostEnviroment { RootPath = WebRootPath};
|
||||
var jwtSettings = new JwtSettings()
|
||||
{
|
||||
Issuer = "PoszukiwaczInc",
|
||||
@ -60,9 +63,11 @@ namespace Serwer.Api
|
||||
};
|
||||
});
|
||||
|
||||
services.AddSingleton<IHostEnviroment>(hostEnviroment);
|
||||
services.AddSingleton<IMapper>(AutoMapperConfig.Initialize());
|
||||
services.AddSingleton<IJwtHandler, JwtHandler>(sp => new JwtHandler(jwtSettings));
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
services.AddScoped<IImageService, ImageService>();
|
||||
services.AddScoped<IUserService, UserService>();
|
||||
}
|
||||
|
||||
@ -71,13 +76,16 @@ namespace Serwer.Api
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseCors(builder =>
|
||||
{
|
||||
builder.AllowAnyHeader();
|
||||
builder.AllowAnyMethod();
|
||||
builder.AllowAnyOrigin();
|
||||
});
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Serwer.Api v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
BIN
Serwer/Serwer.Api/wwwroot/sample/wielomian.png
Normal file
BIN
Serwer/Serwer.Api/wwwroot/sample/wielomian.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 932 B |
BIN
Serwer/Serwer.Api/wwwroot/tessdata/eng.traineddata
Normal file
BIN
Serwer/Serwer.Api/wwwroot/tessdata/eng.traineddata
Normal file
Binary file not shown.
BIN
Serwer/Serwer.Api/wwwroot/tessdata/equ.traineddata
Normal file
BIN
Serwer/Serwer.Api/wwwroot/tessdata/equ.traineddata
Normal file
Binary file not shown.
BIN
Serwer/Serwer.Api/wwwroot/tessdata/pol.traineddata
Normal file
BIN
Serwer/Serwer.Api/wwwroot/tessdata/pol.traineddata
Normal file
Binary file not shown.
32
Serwer/Serwer.Core/Domain/File.cs
Normal file
32
Serwer/Serwer.Core/Domain/File.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Core.Domain
|
||||
{
|
||||
public class File
|
||||
{
|
||||
public string Name { get; protected set; }
|
||||
public string ContentType { get; protected set; }
|
||||
public byte[] Bytes { get; protected set; }
|
||||
public long SizeBytes => Bytes.Length;
|
||||
|
||||
protected File()
|
||||
{
|
||||
}
|
||||
|
||||
protected File(string name, string contentType, byte[] bytes)
|
||||
{
|
||||
Name = name;
|
||||
ContentType = contentType;
|
||||
Bytes = bytes;
|
||||
}
|
||||
|
||||
public static File Empty => new File();
|
||||
|
||||
public static File Create(string name, string contentType, byte[] bytes)
|
||||
=> new File(name, contentType, bytes);
|
||||
}
|
||||
}
|
13
Serwer/Serwer.Infrastructure/Services/IImageHandler.cs
Normal file
13
Serwer/Serwer.Infrastructure/Services/IImageHandler.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.Services
|
||||
{
|
||||
public interface IImageHandler
|
||||
{
|
||||
|
||||
}
|
||||
}
|
14
Serwer/Serwer.Infrastructure/Services/IImageService.cs
Normal file
14
Serwer/Serwer.Infrastructure/Services/IImageService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Serwer.Core.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.Services
|
||||
{
|
||||
public interface IImageService
|
||||
{
|
||||
Task<string> Process(string name, string contentType, byte[] bytes);
|
||||
}
|
||||
}
|
12
Serwer/Serwer.Infrastructure/Services/ImageHandler.cs
Normal file
12
Serwer/Serwer.Infrastructure/Services/ImageHandler.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.Services
|
||||
{
|
||||
class ImageHandler
|
||||
{
|
||||
}
|
||||
}
|
30
Serwer/Serwer.Infrastructure/Services/ImageService.cs
Normal file
30
Serwer/Serwer.Infrastructure/Services/ImageService.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Serwer.Core.Domain;
|
||||
using Serwer.Infrastructure.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tesseract;
|
||||
|
||||
namespace Serwer.Infrastructure.Services
|
||||
{
|
||||
public class ImageService : IImageService
|
||||
{
|
||||
private readonly ISet<File> _files = new HashSet<File>();
|
||||
private readonly string _env;
|
||||
public ImageService(IHostEnviroment hostEnviroment)
|
||||
{
|
||||
_env = hostEnviroment.RootPath;
|
||||
}
|
||||
public async Task<string> Process(string name, string contentType, byte[] bytes)
|
||||
{
|
||||
var engine = new TesseractEngine(System.IO.Path.Combine(_env, "tessdata"),"eng+equ", EngineMode.Default);
|
||||
var img = Pix.LoadFromMemory(bytes);
|
||||
var res = engine.Process(img);
|
||||
var txt = res.GetText();
|
||||
|
||||
return await Task.FromResult(txt);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,10 +8,27 @@
|
||||
<PackageReference Include="AutoMapper" Version="10.1.1" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.8.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
|
||||
<PackageReference Include="Tesseract" Version="4.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Serwer.Core\Serwer.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="C:\Users\ppopo\.nuget\packages\tesseract\4.1.1\build\\..\x64\leptonica-1.80.0.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="C:\Users\ppopo\.nuget\packages\tesseract\4.1.1\build\\..\x64\tesseract41.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="C:\Users\ppopo\.nuget\packages\tesseract\4.1.1\build\\..\x86\leptonica-1.80.0.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="C:\Users\ppopo\.nuget\packages\tesseract\4.1.1\build\\..\x86\tesseract41.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
13
Serwer/Serwer.Infrastructure/Settings/HostEnviroment.cs
Normal file
13
Serwer/Serwer.Infrastructure/Settings/HostEnviroment.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.Settings
|
||||
{
|
||||
public class HostEnviroment: IHostEnviroment
|
||||
{
|
||||
public string RootPath { get; set; }
|
||||
}
|
||||
}
|
13
Serwer/Serwer.Infrastructure/Settings/IHostEnviroment.cs
Normal file
13
Serwer/Serwer.Infrastructure/Settings/IHostEnviroment.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.Settings
|
||||
{
|
||||
public interface IHostEnviroment
|
||||
{
|
||||
string RootPath { get; set; }
|
||||
}
|
||||
}
|
17
Serwer/Serwer.Infrastructure/ViewModels/RegisterModel.cs
Normal file
17
Serwer/Serwer.Infrastructure/ViewModels/RegisterModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.ViewModels
|
||||
{
|
||||
public class RegisterModel
|
||||
{
|
||||
public string Email { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
public string Login { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
14
Serwer/Serwer.Infrastructure/ViewModels/SignInModel.cs
Normal file
14
Serwer/Serwer.Infrastructure/ViewModels/SignInModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.ViewModels
|
||||
{
|
||||
public class SignInModel
|
||||
{
|
||||
public string Login { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user