Browse Source

Server Manager Setup

pull/1/head
barhen 2 years ago
parent
commit
f0555cb977
  1. 5
      ClientManager/ClientManager.csproj
  2. 1374
      ServerManager/BiskAcdbContext.cs
  3. 278
      ServerManager/BiskilogContext.cs
  4. 6
      ServerManager/ServerManager.csproj
  5. 13
      ServerManager/appsettings.json
  6. 63
      Shared/ServiceRepo/CalculatorService.cs
  7. 33
      Shared/ServiceRepo/SearchService.cs

5
ClientManager/ClientManager.csproj

@ -8,6 +8,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>
</Project>

1374
ServerManager/BiskAcdbContext.cs

File diff suppressed because it is too large

278
ServerManager/BiskilogContext.cs

@ -0,0 +1,278 @@
using Biskilog_Cloud.Shared.ClientContractModels;
using Microsoft.EntityFrameworkCore;
namespace ServerManager;
/// <summary>
/// This is the main EF DbContext for the Biskilog Accounting
/// </summary>
public partial class BiskilogContext : DbContext
{
public BiskilogContext()
{
}
public BiskilogContext(DbContextOptions<BiskilogContext> options)
: base(options)
{
}
public virtual DbSet<Authtype> Authtypes { get; set; }
public virtual DbSet<Clientbusiness> Clientbusinesses { get; set; }
public virtual DbSet<Clientinfo> Clientinfos { get; set; }
public virtual DbSet<Contract> Contracts { get; set; }
public virtual DbSet<Databasemap> Databasemaps { get; set; }
public virtual DbSet<Siteaccesspermission> Siteaccesspermissions { get; set; }
public virtual DbSet<Userauth> Userauths { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
modelBuilder.Entity<Authtype>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("authtypes")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.Property(e => e.Id)
.HasColumnType("int(11)")
.HasColumnName("id");
entity.Property(e => e.Type)
.HasMaxLength(50)
.HasColumnName("type")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
});
modelBuilder.Entity<Clientbusiness>(entity =>
{
entity.HasKey(e => new { e.BusinessId, e.ClientId })
.HasName("PRIMARY")
.HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
entity
.ToTable("clientbusiness")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.Property(e => e.BusinessId)
.HasComment("there could be multiple branches of the same business")
.HasColumnType("int(11)")
.HasColumnName("businessId");
entity.Property(e => e.ClientId)
.HasColumnType("int(11)")
.HasColumnName("clientID");
entity.Property(e => e.BiskilogVersion)
.HasMaxLength(50)
.HasDefaultValueSql("''")
.HasColumnName("biskilog_version")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.BusinessName)
.HasMaxLength(50)
.HasDefaultValueSql("''")
.HasColumnName("business_name")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.DateJoined)
.HasDefaultValueSql("current_timestamp()")
.HasColumnType("datetime")
.HasColumnName("date_joined");
entity.Property(e => e.BusinessExternalId)
.HasMaxLength(50)
.HasDefaultValueSql("''")
.HasColumnName("businessExternalId")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
});
modelBuilder.Entity<Clientinfo>(entity =>
{
entity.HasKey(e => e.ClientId).HasName("PRIMARY");
entity
.ToTable("clientinfo")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.Property(e => e.ClientId)
.HasColumnType("int(11)")
.HasColumnName("clientID");
entity.Property(e => e.Email)
.HasMaxLength(200)
.HasColumnName("email")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.Fullname)
.HasMaxLength(200)
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.PhoneNumber)
.HasMaxLength(200)
.HasColumnName("phoneNumber")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
});
modelBuilder.Entity<Contract>(entity =>
{
entity.HasKey(e => e.ContractId).HasName("PRIMARY");
entity
.ToTable("contracts")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.HasIndex(e => new { e.ClientId, e.BusinessId }, "clientId_businessId").IsUnique();
entity.Property(e => e.ContractId)
.HasColumnType("int(11)")
.HasColumnName("contractId");
entity.Property(e => e.Bill)
.HasPrecision(18, 2)
.HasColumnName("bill");
entity.Property(e => e.BusinessId)
.HasColumnType("int(11)")
.HasColumnName("businessId");
entity.Property(e => e.ClientId)
.HasColumnType("int(11)")
.HasColumnName("clientId");
entity.Property(e => e.Comments)
.HasColumnType("text")
.HasColumnName("comments")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.EndDate)
.HasColumnType("datetime")
.HasColumnName("end_date");
entity.Property(e => e.StartDate)
.HasColumnType("datetime")
.HasColumnName("start_date");
});
modelBuilder.Entity<Databasemap>(entity =>
{
entity.HasKey(e => e.DbNo).HasName("PRIMARY");
entity
.ToTable("databasemap")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.HasIndex(e => e.ClientId, "businessId").IsUnique();
entity.Property(e => e.DbNo)
.HasColumnType("int(11)")
.HasColumnName("db_no");
entity.Property(e => e.ClientId)
.HasColumnType("int(11)")
.HasColumnName("clientID");
entity.Property(e => e.DbName)
.HasMaxLength(50)
.HasDefaultValueSql("''")
.HasColumnName("db_name")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.Domain)
.HasMaxLength(50)
.HasDefaultValueSql("''")
.HasColumnName("domain")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.LastSyncDate)
.HasColumnType("datetime")
.HasColumnName("last_sync_date");
});
modelBuilder.Entity<Siteaccesspermission>(entity =>
{
entity.HasKey(e => new { e.UserId, e.BusinessId, e.ClientId })
.HasName("PRIMARY")
.HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0, 0 });
entity
.ToTable("siteaccesspermission")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.Property(e => e.UserId)
.HasColumnType("int(11)")
.HasColumnName("userID");
entity.Property(e => e.BusinessId)
.HasComment("businessIds could also been seen as branchID")
.HasColumnType("int(11)")
.HasColumnName("businessId");
entity.Property(e => e.ClientId)
.HasColumnType("int(11)")
.HasColumnName("clientId");
});
modelBuilder.Entity<Userauth>(entity =>
{
entity.HasKey(e => e.UserId).HasName("PRIMARY");
entity
.ToTable("userauth")
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.HasIndex(e => e.AuthType, "authType");
entity.HasIndex(e => new { e.ClientId, e.Username, e.Email }, "clientId_username_email").IsUnique();
entity.Property(e => e.UserId)
.HasColumnType("int(11)")
.HasColumnName("userId");
entity.Property(e => e.AuthType)
.HasColumnType("int(11)")
.HasColumnName("authType");
entity.Property(e => e.ClientId)
.HasColumnType("int(11)")
.HasColumnName("clientId");
entity.Property(e => e.Email)
.HasMaxLength(200)
.HasColumnName("email")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.Isactive)
.HasColumnType("bit(1)")
.HasColumnName("isactive");
entity.Property(e => e.Isowner)
.HasColumnType("bit(1)")
.HasColumnName("isowner");
entity.Property(e => e.LastLogin)
.HasColumnType("datetime")
.HasColumnName("last_login");
entity.Property(e => e.Passsword)
.HasMaxLength(200)
.HasColumnName("passsword")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.PhoneNumber)
.HasMaxLength(50)
.HasColumnName("phoneNumber")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
entity.Property(e => e.Username)
.HasMaxLength(30)
.HasColumnName("username")
.UseCollation("utf8mb4_general_ci")
.HasCharSet("utf8mb4");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

6
ServerManager/ServerManager.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
@ -27,5 +27,7 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Biskilog_Cloud.Shared.csproj" />
</ItemGroup>
</Project>

13
ServerManager/appsettings.json

@ -5,5 +5,14 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
"ConnectionStrings": {
"Connection": "server=54.37.19.162;database=dev_biskilogclients;user=biskilog;password=mefbuk-6niFsu-fytrew",
"PrivateConnection": "server={0};database={1};user=biskilog;password=mefbuk-6niFsu-fytrew;default command timeout=0;"
},
"AllowedHosts": "*",
"JWT": {
"Key": "@@BISKILOGACCOUNTING2023DEV??//##$",
"Issuer": "AUTH SERVER",
"Audience": "BISKILOG"
}
}

63
Shared/ServiceRepo/CalculatorService.cs

@ -1,63 +0,0 @@
using Biskilog_Cloud.Shared.Interfaces;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Biskilog_Cloud.Shared.ServiceRepo
{
public class CalculatorService : ICalculator
{
public double CalculatePercentage()
{
throw new NotImplementedException();
}
public string FormatMoneyWithCurrency(double a_amount)
{
return string.Format(GetCurrencyCode(), " {0:C2}", a_amount);
}
public string FormatMoneyWithCurrencyKilo(double a_amount)
{
return GetCurrencyCode().CurrencySymbol + FormatNumber(a_amount);
}
public NumberFormatInfo GetCurrencyCode()
{
//TODO have a better implementation
// Specify the locale for Ghana
string locale = "en-GH";
// Get the NumberFormatInfo for the specified locale
NumberFormatInfo numberFormatInfo = new CultureInfo(locale).NumberFormat;
// Set the currency symbol to Ghanaian cedi
numberFormatInfo.CurrencySymbol = "GH₵ ";
return numberFormatInfo;
}
private string FormatNumber(double a_amount)
{
if (a_amount >= 100000000)
{
return (a_amount / 1000000D).ToString("0.#M");
}
if (a_amount >= 1000000)
{
return (a_amount / 1000000D).ToString("0.##M");
}
if (a_amount >= 100000)
{
return (a_amount / 1000D).ToString("0.#k");
}
if (a_amount >= 10000)
{
return (a_amount / 1000D).ToString("0.##k");
}
return a_amount.ToString("#,0");
}
}
}

33
Shared/ServiceRepo/SearchService.cs

@ -1,33 +0,0 @@
using Biskilog_Cloud.Shared.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Biskilog_Cloud.Shared.ServiceRepo
{
public class SearchService : ISearchService
{
public event Action<string> SearchValueChanged;
public event Action ClearTextBox;
// Method that raises the event
protected virtual void OnSearchValueChanged(string a_searchKey)
{
SearchValueChanged?.Invoke(a_searchKey);
}
// Method that triggers the event
public void PerformSearch(string a_searchKey)
{
OnSearchValueChanged(a_searchKey);
}
public void Clear()
{
ClearTextBox?.Invoke();
}
}
}
Loading…
Cancel
Save