This commit is contained in:
parent
94f71fc00f
commit
73400b5c9f
@ -10,8 +10,9 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sledgemapper.Api.Core.Entities;
|
||||
using Sentry;
|
||||
using Sledgemapper.Api.Models;
|
||||
using User = Sledgemapper.Api.Core.Entities.User;
|
||||
|
||||
namespace Sledgemapper.Api.Controllers
|
||||
{
|
||||
|
@ -2,12 +2,13 @@ using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sledgemapper.Api.Commands;
|
||||
using Sledgemapper.Api.Infrastructure.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sentry;
|
||||
using Session = Sledgemapper.Shared.Entities.Session;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
@ -26,7 +27,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await _dbcontext.Users.FindAsync(command.UserId);
|
||||
var user = await _dbcontext.Users.FindAsync(new[] { command.UserId }, cancellationToken: cancellationToken);
|
||||
_dbcontext.Attach(user);
|
||||
|
||||
|
||||
@ -37,7 +38,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
.Include(c => c.InvitedUsers)
|
||||
.Include(c => c.Maps)
|
||||
.Include(c => c.Owner)
|
||||
.Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user)).FirstAsync();
|
||||
.Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user)).FirstAsync(cancellationToken);
|
||||
|
||||
|
||||
|
||||
@ -49,6 +50,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sentry;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
@ -26,19 +27,16 @@ namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await _dbcontext.Users.FindAsync(command.UserId);
|
||||
var user = await _dbcontext.Users.FindAsync(new[] { command.UserId }, cancellationToken: cancellationToken);
|
||||
_dbcontext.Attach(user);
|
||||
|
||||
|
||||
var campaign = await _dbcontext
|
||||
.Campaigns
|
||||
.Where(campaign => campaign.CampaignId == command.CampaignId)
|
||||
.Include(c => c.InvitedUsers)
|
||||
|
||||
.Include(c => c.Owner)
|
||||
.Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user)).FirstAsync();
|
||||
|
||||
|
||||
.Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user)).FirstAsync(cancellationToken);
|
||||
|
||||
//var campaign = await _dbcontext.Campaigns.Where(campaign => campaign.CampaignId == command.CampaignId && campaign.OwnerId == command.UserId).Include(campaign => campaign.InvitedUsers).FirstAsync();
|
||||
|
||||
@ -47,6 +45,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sentry;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
@ -38,6 +39,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
return new List<Campaign>();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sentry;
|
||||
using Sledgemapper.Api.Commands;
|
||||
using Sledgemapper.Api.Infrastructure.Data;
|
||||
|
||||
@ -24,7 +25,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users.FindAsync(command.UserId);
|
||||
var user = await _dbContext.Users.FindAsync(new[] { command.UserId }, cancellationToken: cancellationToken);
|
||||
|
||||
var campaign = await _dbContext
|
||||
.Campaigns
|
||||
@ -46,6 +47,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -4,7 +4,8 @@ using Sledgemapper.Api.Infrastructure.Data;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sledgemapper.Api.Core.Entities;
|
||||
using Sentry;
|
||||
using User = Sledgemapper.Api.Core.Entities.User;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
@ -39,8 +40,7 @@ namespace Sledgemapper.Api.Handlers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sentry;
|
||||
using Sentry.AspNetCore;
|
||||
using Sentry.Extensibility;
|
||||
using Sledgemapper.Api.Infrastructure.Data;
|
||||
|
||||
namespace Sledgemapper.Api
|
||||
@ -13,13 +16,59 @@ namespace Sledgemapper.Api
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
CreateDbIfNotExists(host);
|
||||
using (Sentry.SentrySdk.Init(o =>
|
||||
{
|
||||
o.Dsn = "https://dbd98432b84b445696dc2996e4e01c90@glitchtip.michelescandura.com/2";
|
||||
o.MaxBreadcrumbs = 50;
|
||||
o.Debug = true;
|
||||
o.StackTraceMode = StackTraceMode.Enhanced;
|
||||
o.AttachStacktrace = true;
|
||||
o.Release = "1.0.0-alpha.3";
|
||||
|
||||
#if DEBUG
|
||||
o.Environment = "dev";
|
||||
#else
|
||||
o.Environment = "production";
|
||||
#endif
|
||||
|
||||
|
||||
}))
|
||||
// {
|
||||
host.Run();
|
||||
SentrySdk.CaptureMessage("Backend starting");
|
||||
//}
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseSentry(o =>
|
||||
{
|
||||
o.Dsn = "https://dbd98432b84b445696dc2996e4e01c90@glitchtip.michelescandura.com/2";
|
||||
o.MaxRequestBodySize = RequestSize.Always;
|
||||
o.MaxBreadcrumbs = 50;
|
||||
o.Debug = true;
|
||||
o.StackTraceMode = StackTraceMode.Enhanced;
|
||||
o.AttachStacktrace = true;
|
||||
o.Release = "1.0.0-alpha.3";
|
||||
//o.TracesSampler = ctx =>
|
||||
//{
|
||||
// if (string.Equals(ctx.TryGetHttpRoute(), "/Home/Privacy", StringComparison.Ordinal))
|
||||
// {
|
||||
// // Collect fewer traces for this page
|
||||
// return 0.3;
|
||||
// }
|
||||
|
||||
// return 1;
|
||||
//};
|
||||
#if DEBUG
|
||||
o.Environment = "dev";
|
||||
#else
|
||||
o.Environment = "production";
|
||||
#endif
|
||||
|
||||
});
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
|
||||
@ -32,8 +81,7 @@ namespace Sledgemapper.Api
|
||||
|
||||
private static void CreateDbIfNotExists(IHost host)
|
||||
{
|
||||
using (var scope = host.Services.CreateScope())
|
||||
{
|
||||
using var scope = host.Services.CreateScope();
|
||||
var services = scope.ServiceProvider;
|
||||
try
|
||||
{
|
||||
@ -48,4 +96,3 @@ namespace Sledgemapper.Api
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.10" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
|
||||
<PackageReference Include="Sentry" Version="3.9.3" />
|
||||
<PackageReference Include="Sentry.AspNetCore" Version="3.9.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.10" />
|
||||
|
@ -11,10 +11,12 @@ using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Polly;
|
||||
using Polly.Retry;
|
||||
using Refit;
|
||||
using Sentry;
|
||||
using SharpFontInternal;
|
||||
using Sledgemapper.Messages;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using TinyMessenger;
|
||||
using Session = Sledgemapper.Shared.Entities.Session;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
@ -141,7 +143,7 @@ namespace Sledgemapper
|
||||
Connection.On<Player>("NewPlayer", player =>
|
||||
{
|
||||
var p = SessionData.Players.FirstOrDefault(m => m.UserId == player.UserId);
|
||||
if (p is null)
|
||||
if (p is not null)
|
||||
{
|
||||
SessionData.Players.Add(player);
|
||||
}
|
||||
@ -299,7 +301,7 @@ namespace Sledgemapper
|
||||
//_authenticateResponse = await Api.Authenticate(authenticateModel).ConfigureAwait(false);
|
||||
var data = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(_authenticateResponse));
|
||||
|
||||
Program.helper.SaveUnencryptedTokenCache(JsonSerializer.SerializeToUtf8Bytes(_authenticateResponse));
|
||||
Program.Helper.SaveUnencryptedTokenCache(JsonSerializer.SerializeToUtf8Bytes(_authenticateResponse));
|
||||
|
||||
await Connection.StopAsync();
|
||||
|
||||
@ -335,7 +337,7 @@ namespace Sledgemapper
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
|
||||
await Connection.StartAsync();
|
||||
@ -343,7 +345,7 @@ namespace Sledgemapper
|
||||
|
||||
public void CheckLogin()
|
||||
{
|
||||
var data = Program.helper.LoadUnencryptedTokenCache();
|
||||
var data = Program.Helper.LoadUnencryptedTokenCache();
|
||||
if (data != null && data.Any())
|
||||
{
|
||||
|
||||
|
@ -9,8 +9,8 @@ namespace Sledgemapper
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
private static IConfiguration configuration;
|
||||
public static MsalCacheHelper helper;
|
||||
private static IConfiguration _configuration;
|
||||
public static MsalCacheHelper Helper { get; private set; }
|
||||
|
||||
[STAThread]
|
||||
static void Main()
|
||||
@ -19,7 +19,7 @@ namespace Sledgemapper
|
||||
.SetBasePath(System.IO.Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json");
|
||||
|
||||
configuration = builder.Build();
|
||||
_configuration = builder.Build();
|
||||
|
||||
// Loading PublicClientApplicationOptions from the values set on appsettings.json
|
||||
|
||||
@ -40,17 +40,18 @@ namespace Sledgemapper
|
||||
.Build();
|
||||
// storage = Storage.Create(storageProperties);
|
||||
|
||||
helper = MsalCacheHelper.CreateAsync(storageProperties).Result;
|
||||
Helper = MsalCacheHelper.CreateAsync(storageProperties).Result;
|
||||
|
||||
using (Sentry.SentrySdk.Init(o =>
|
||||
{
|
||||
o.Dsn = "https://973ac1606651454ba7a19f642d0a9bc1@glitchtip.michelescandura.com/1";
|
||||
//o.Dsn = "https://3a58b39d3d38447a83b647fdb1c68160@o1020733.ingest.sentry.io/5986244";
|
||||
o.MaxBreadcrumbs = 50;
|
||||
o.Debug = true;
|
||||
o.StackTraceMode = StackTraceMode.Enhanced;
|
||||
o.AttachStacktrace = true;
|
||||
o.Release = "1.0.0-alpha.3";
|
||||
|
||||
o.TracesSampleRate = 1.0;
|
||||
#if DEBUG
|
||||
o.Environment = "dev";
|
||||
#else
|
||||
|
@ -879,7 +879,7 @@ namespace Sledgemapper
|
||||
var items = _sessionData.Lines.Values.Union<BaseMapEntity>(_sessionData.Rooms.Values)
|
||||
.OrderBy(t => t.Timestamp).ToArray();
|
||||
|
||||
for (var i = 0; i < items.Count(); i++)
|
||||
for (var i = 0; i < items.Length; i++)
|
||||
{
|
||||
var item = items.ElementAt(i);
|
||||
if (IsMapElementOffscreen(item)) continue;
|
||||
|
@ -140,7 +140,7 @@ namespace Sledgemapper.UI
|
||||
{
|
||||
var button = ((TextButton)sender);
|
||||
Container container = button.Parent;
|
||||
while (!(container is Window))
|
||||
while (container is not Window)
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ namespace Sledgemapper.UI
|
||||
_windowEditor.ShowModal(Desktop);
|
||||
}
|
||||
|
||||
private async void OnLoginSuccesfulMessage(LoginSuccesfulMessage obj)
|
||||
private void OnLoginSuccesfulMessage(LoginSuccesfulMessage obj)
|
||||
{
|
||||
//MenuConnectNew.Enabled = true;
|
||||
//MenuConnectJoin.Enabled = true;
|
||||
|
@ -64,7 +64,6 @@ namespace Sledgemapper.UI
|
||||
private void OnMapSelected(object sender, EventArgs e)
|
||||
{
|
||||
var item = sender as ListItem;
|
||||
var localContent = item.GetParentContentInWindow<Widget>();
|
||||
|
||||
var list = item.Parent as Grid;
|
||||
for (var i = 0; i < list.ChildrenCount; i++)
|
||||
|
1
legacyDb/kalguumer snapshot.json
Normal file
1
legacyDb/kalguumer snapshot.json
Normal file
File diff suppressed because one or more lines are too long
0
legacyDb/test
Normal file
0
legacyDb/test
Normal file
Loading…
Reference in New Issue
Block a user