Merge pull request 'develop' (#11) from develop into master

Reviewed-on: michele/Map#11
This commit is contained in:
michele 2020-11-23 23:57:39 +00:00
commit ffd6768ef2
22 changed files with 171 additions and 176 deletions

7
.drone.yml Normal file
View file

@ -0,0 +1,7 @@
kind: pipeline
name: default
steps:
- name: compile
image: mcr.microsoft.com/dotnet/sdk:5.0
commands:
- sh build.sh

View file

@ -3,10 +3,6 @@ FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
# copy csproj and restore as distinct layers
#COPY *.sln .
# COPY SignalRChat/*.csproj ./aspnetapp/
# WORKDIR /source/aspnetapp
# RUN dotnet restore
COPY Sledgemapper.Api/*.csproj ./Sledgemapper.Api/
COPY Sledgemapper.Shared/*.csproj ./Sledgemapper.Shared/
@ -27,33 +23,4 @@ RUN dotnet publish -c release -o /app --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "SignalRChat.dll"]
# # https://hub.docker.com/_/microsoft-dotnet-core
# FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
# # copy csproj and restore as distinct layers
# #COPY *.sln .
# WORKDIR /source
# COPY Sledgemapper.Api/*.csproj ./Sledgemapper.Api/
# WORKDIR /source/Sledgemapper.Api
# RUN dotnet restore
# WORKDIR /source
# COPY Sledgemapper.Shared/*.csproj ./Sledgemapper.Shared/
# WORKDIR /source/Sledgemapper.Shared
# RUN dotnet restore
# # copy everything else and build app
# WORKDIR /source
# COPY Sledgemapper.Api/. ./Sledgemapper.Api/
# COPY Sledgemapper.Shared/. ./Sledgemapper.Shared/
# WORKDIR /source/Sledgemapper.Api
# RUN dotnet publish -c release -o /app --no-restore
# # final stage/image
# FROM mcr.microsoft.com/dotnet/aspnet:5.0
# WORKDIR /app
# COPY --from=build /app ./
# ENTRYPOINT ["dotnet", "Sledgemapper.Api.dll"]
ENTRYPOINT ["dotnet", "Sledgemapper.Api.dll"]

View file

@ -1,6 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Hubs;
using Sledgemapper.Api.Hubs;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;

View file

@ -1,6 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Hubs;
using Sledgemapper.Api.Hubs;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;

View file

@ -1,10 +1,10 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Hubs;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;
using System.Threading.Tasks;
using Sledgemapper.Api.Hubs;
namespace Sledgemapper.Api.Handlers
{

View file

@ -1,6 +1,6 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Hubs;
using Sledgemapper.Api.Hubs;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;

View file

@ -1,10 +1,10 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Hubs;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;
using System.Threading.Tasks;
using Sledgemapper.Api.Hubs;
namespace Sledgemapper.Api.Handlers
{

View file

@ -1,10 +1,10 @@
using MediatR;
using Microsoft.AspNetCore.SignalR;
using SignalRChat.Hubs;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;
using System.Threading.Tasks;
using Sledgemapper.Api.Hubs;
namespace Sledgemapper.Api.Handlers
{

View file

@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Authorization;
using Sledgemapper.Api.Models;
using Sledgemapper.Helpers;
namespace SignalRChat.Hubs
namespace Sledgemapper.Api.Hubs
{
[Authorize]
public class SledgemapperHub : Hub<ISledgemapperClient>

View file

@ -1,53 +1,53 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Sledgemapper.Helpers;
// // <auto-generated />
// using System;
// using Microsoft.EntityFrameworkCore;
// using Microsoft.EntityFrameworkCore.Infrastructure;
// using Microsoft.EntityFrameworkCore.Metadata;
// using Microsoft.EntityFrameworkCore.Migrations;
// using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
// using Sledgemapper.Helpers;
namespace Sledgemapper.Migrations.SqlServerMigrations
{
[DbContext(typeof(DataContext))]
[Migration("20200102103423_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// namespace Sledgemapper.Migrations.SqlServerMigrations
// {
// [DbContext(typeof(DataContext))]
// [Migration("20200102103423_InitialCreate")]
// partial class InitialCreate
// {
// protected override void BuildTargetModel(ModelBuilder modelBuilder)
// {
// #pragma warning disable 612, 618
// modelBuilder
// .HasAnnotation("ProductVersion", "3.1.0")
// .HasAnnotation("Relational:MaxIdentifierLength", 128)
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Sledgemapper.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// modelBuilder.Entity("Sledgemapper.Entities.User", b =>
// {
// b.Property<int>("Id")
// .ValueGeneratedOnAdd()
// .HasColumnType("int")
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
// b.Property<string>("FirstName")
// .HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
// b.Property<string>("LastName")
// .HasColumnType("nvarchar(max)");
b.Property<byte[]>("PasswordHash")
.HasColumnType("varbinary(max)");
// b.Property<byte[]>("PasswordHash")
// .HasColumnType("varbinary(max)");
b.Property<byte[]>("PasswordSalt")
.HasColumnType("varbinary(max)");
// b.Property<byte[]>("PasswordSalt")
// .HasColumnType("varbinary(max)");
b.Property<string>("Username")
.HasColumnType("nvarchar(max)");
// b.Property<string>("Username")
// .HasColumnType("nvarchar(max)");
b.HasKey("Id");
// b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}
// b.ToTable("Users");
// });
// #pragma warning restore 612, 618
// }
// }
// }

View file

@ -1,33 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
// using Microsoft.EntityFrameworkCore.Migrations;
namespace Sledgemapper.Migrations.SqlServerMigrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(nullable: true),
LastName = table.Column<string>(nullable: true),
Username = table.Column<string>(nullable: true),
PasswordHash = table.Column<byte[]>(nullable: true),
PasswordSalt = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
}
// namespace Sledgemapper.Migrations.SqlServerMigrations
// {
// public partial class InitialCreate : Migration
// {
// protected override void Up(MigrationBuilder migrationBuilder)
// {
// migrationBuilder.CreateTable(
// name: "Users",
// columns: table => new
// {
// Id = table.Column<int>(nullable: false)
// .Annotation("SqlServer:Identity", "1, 1"),
// FirstName = table.Column<string>(nullable: true),
// LastName = table.Column<string>(nullable: true),
// Username = table.Column<string>(nullable: true),
// PasswordHash = table.Column<byte[]>(nullable: true),
// PasswordSalt = table.Column<byte[]>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_Users", x => x.Id);
// });
// }
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Users");
}
}
}
// protected override void Down(MigrationBuilder migrationBuilder)
// {
// migrationBuilder.DropTable(
// name: "Users");
// }
// }
// }

View file

@ -1,51 +1,51 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Sledgemapper.Helpers;
// // <auto-generated />
// using System;
// using Microsoft.EntityFrameworkCore;
// using Microsoft.EntityFrameworkCore.Infrastructure;
// using Microsoft.EntityFrameworkCore.Metadata;
// using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
// using Sledgemapper.Helpers;
namespace Sledgemapper.Migrations.SqlServerMigrations
{
[DbContext(typeof(DataContext))]
partial class DataContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// namespace Sledgemapper.Migrations.SqlServerMigrations
// {
// [DbContext(typeof(DataContext))]
// partial class DataContextModelSnapshot : ModelSnapshot
// {
// protected override void BuildModel(ModelBuilder modelBuilder)
// {
// #pragma warning disable 612, 618
// modelBuilder
// .HasAnnotation("ProductVersion", "3.1.0")
// .HasAnnotation("Relational:MaxIdentifierLength", 128)
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Sledgemapper.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// modelBuilder.Entity("Sledgemapper.Entities.User", b =>
// {
// b.Property<int>("Id")
// .ValueGeneratedOnAdd()
// .HasColumnType("int")
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
// b.Property<string>("FirstName")
// .HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
// b.Property<string>("LastName")
// .HasColumnType("nvarchar(max)");
b.Property<byte[]>("PasswordHash")
.HasColumnType("varbinary(max)");
// b.Property<byte[]>("PasswordHash")
// .HasColumnType("varbinary(max)");
b.Property<byte[]>("PasswordSalt")
.HasColumnType("varbinary(max)");
// b.Property<byte[]>("PasswordSalt")
// .HasColumnType("varbinary(max)");
b.Property<string>("Username")
.HasColumnType("nvarchar(max)");
// b.Property<string>("Username")
// .HasColumnType("nvarchar(max)");
b.HasKey("Id");
// b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}
// b.ToTable("Users");
// });
// #pragma warning restore 612, 618
// }
// }
// }

View file

@ -5,7 +5,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Sledgemapper.Api.Data;
namespace SignalRChat
namespace Sledgemapper.Api
{
public class Program
{
@ -20,7 +20,7 @@ namespace SignalRChat
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().UseUrls("http://localhost:5000");
webBuilder.UseStartup<Startup>();
});
// public static IHostBuilder CreateHostBuilder(string[] args) =>

View file

@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SignalRChat.Hubs;
using Sledgemapper.Api.Data;
using Microsoft.EntityFrameworkCore;
using MediatR;
@ -17,8 +16,9 @@ using System.Text;
using AutoMapper;
using Sledgemapper.Services;
using System.Security.Claims;
using Sledgemapper.Api.Hubs;
namespace SignalRChat
namespace Sledgemapper.Api
{
public class Startup
{
@ -35,9 +35,9 @@ namespace SignalRChat
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
if (_env.IsProduction())
services.AddDbContext<DataContext>();
else
// if (_env.IsProduction())
// services.AddDbContext<DataContext>();
// else
services.AddDbContext<DataContext, SqliteDataContext>();
// services.AddRazorPages();

View file

@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"WebApiDatabase": "Data Source=LocalDatabase.db"
"WebApiDatabase": "Data Source=db/LocalDatabase.db"
},
"Logging": {
"LogLevel": {

View file

@ -0,0 +1,12 @@
{
"ConnectionStrings": {
"WebApiDatabase": "Data Source=db/LocalDatabase.db"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

Binary file not shown.

View file

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace SignalRChat.Hubs
namespace Sledgemapper.Api.Hubs
{
public static class ExtensionMethods
{

View file

@ -26,13 +26,14 @@ namespace Sledgemapper
SessionData = sessionData;
Connection = new HubConnectionBuilder()
.WithAutomaticReconnect()
//.WithUrl("http://hub.michelescandura.com:5001/SledgemapperHub")
.WithUrl("http://localhost:5000/SledgemapperHub", options =>
//.WithUrl("http://localhost:5001/SledgemapperHub", options =>
.WithUrl("http://hub.michelescandura.com:5000/SledgemapperHub", options =>
{
options.AccessTokenProvider = () => Task.FromResult(_authenticateResponse.Token);
})
// .WithUrl("http://hub.michelescandura.com:5000/SledgemapperHub")
.Build();
@ -40,7 +41,8 @@ namespace Sledgemapper
Api = RestService.For<IMapApi>(
new HttpClient(new AuthenticatedHttpClientHandler(GetToken))
{
BaseAddress = new Uri("http://localhost:5000")
BaseAddress = new Uri("http://hub.michelescandura.com:5000")
// BaseAddress = new Uri("http://localhost:5001")
}
);

View file

@ -1154,6 +1154,7 @@ namespace Sledgemapper
textBox.Background = new SolidBrush(new Color(51, 51, 51)); ;
}
return valid;
}
}
}

View file

@ -4,18 +4,18 @@
<TargetFramework>net5.0</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
<PublishTrimmed>false</PublishTrimmed>
<TrimMode>link</TrimMode>
<PublishTrimmed>false</PublishTrimmed>
<!-- <TrimMode>link</TrimMode> -->
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --verbose</_ExtraTrimmerArgs>
</PropertyGroup>
<Target Name="EnsureAllAssembliesAreLinked" BeforeTargets="PrepareForILLink">
<!-- <Target Name="EnsureAllAssembliesAreLinked" BeforeTargets="PrepareForILLink">
<ItemGroup>
<ManagedAssemblyToLink>
<TrimMode>link</TrimMode>
</ManagedAssemblyToLink>
<TrimmerRootAssembly Include="$(TargetName)" />
</ItemGroup>
</Target>
</Target> -->
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
@ -31,9 +31,9 @@
<ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" />
</ItemGroup>
<ItemGroup>
<!-- <ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Xna.Framework.Content.ContentTypeReader" Visible="false" />
</ItemGroup>
</ItemGroup> -->
<ItemGroup>
<PackageReference Include="AsyncAwaitBestPractices" Version="5.0.2" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />

6
build.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
cd Sledgemapper
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true
dotnet publish -r linux-x64 -c Release /p:PublishSingleFile=true
dotnet publish -r osx-x64 -c Release /p:PublishSingleFile=true