Browse Source

checkpoint setup sync with regular token

pull/1/head
barhen 1 year ago
parent
commit
9da3638803
  1. 8
      Biskilog_Cloud.sln
  2. 27
      ClientManager/ClientManager.csproj
  3. 10
      ClientManager/Program.cs
  4. 11
      ClientManager/Properties/launchSettings.json
  5. 21
      ClientManager/Worker.cs
  6. 8
      ClientManager/appsettings.Development.json
  7. 8
      ClientManager/appsettings.json
  8. 1374
      ServerManager/BiskAcdbContext.cs
  9. 79
      ServerManager/BiskPosContext.cs
  10. 278
      ServerManager/BiskilogContext.cs
  11. 18
      ServerManager/Hubs/SalesHub.cs
  12. 7
      ServerManager/Interface/ISalesHub.cs
  13. 19
      ServerManager/Program.cs
  14. 1
      ServerManager/ServerManager.csproj
  15. 287
      ServerManager/ServiceRepo/CompanyService.cs
  16. 390
      ServerManager/ServiceRepo/ProductsService.cs
  17. 282
      ServerManager/ServiceRepo/SalesService.cs
  18. 346
      ServerManager/SyncMethods/CompanySync.cs
  19. 327
      ServerManager/SyncMethods/ProductSync.cs
  20. 341
      ServerManager/SyncMethods/SalesSync.cs
  21. 58
      ServerManager/Worker.cs
  22. 5
      ServerManager/appsettings.json
  23. 4
      Shared/CustomModels/CancelledSales.cs
  24. 4
      Shared/CustomModels/CustomerAccounts.cs
  25. 8
      Shared/CustomModels/ProductItem.cs
  26. 14
      Shared/CustomModels/SyncTimestamp.cs
  27. 4
      Shared/Interfaces/IAnalytics.cs
  28. 16
      Shared/Interfaces/ICompanyInfo.cs
  29. 3
      Shared/Interfaces/ICustomer.cs
  30. 24
      Shared/Interfaces/IProducts.cs
  31. 15
      Shared/Interfaces/ISalesInterface.cs
  32. 13
      Shared/Interfaces/IUser.cs
  33. 1
      Shared/Models/TbStock.cs
  34. 2
      Shared/Models/TblCustomer.cs
  35. 1
      Shared/Models/TblDeliveryDetail.cs
  36. 1
      Shared/Models/TblDeliveryRecipient.cs
  37. 2
      Shared/Models/TblInventory.cs
  38. 2
      Shared/Models/TblInventoryEntry.cs
  39. 6
      Shared/Models/TblInvoice.cs
  40. 6
      Shared/Models/TblPriceChange.cs
  41. 6
      Shared/Models/TblProduct.cs
  42. 24
      Shared/Models/TblUser.cs
  43. 21
      Shared/POSModels/Creditpurchase.cs
  44. 25
      Shared/POSModels/Customeraccount.cs
  45. 21
      Shared/POSModels/Productaltunit.cs
  46. 15
      Shared/POSModels/Restocklevel.cs
  47. 19
      Shared/POSModels/Systemuserrole.cs
  48. 19
      Shared/POSModels/Tblbranch.cs
  49. 13
      Shared/POSModels/Tblbrand.cs
  50. 17
      Shared/POSModels/Tblcancelledtransaction.cs
  51. 35
      Shared/POSModels/Tblcart.cs
  52. 13
      Shared/POSModels/Tblcategory.cs
  53. 21
      Shared/POSModels/Tblcompanydetail.cs
  54. 35
      Shared/POSModels/Tblcustomer.cs
  55. 15
      Shared/POSModels/Tblcustomerpurchase.cs
  56. 21
      Shared/POSModels/Tbldeliverydetail.cs
  57. 25
      Shared/POSModels/Tbldeliveryhead.cs
  58. 25
      Shared/POSModels/Tbldeliveryrecipient.cs
  59. 19
      Shared/POSModels/Tbldiscountlog.cs
  60. 33
      Shared/POSModels/Tbldriver.cs
  61. 15
      Shared/POSModels/Tblinventory.cs
  62. 17
      Shared/POSModels/Tblinventoryentry.cs
  63. 29
      Shared/POSModels/Tblinvoice.cs
  64. 19
      Shared/POSModels/Tblpricechange.cs
  65. 31
      Shared/POSModels/Tblproduct.cs
  66. 19
      Shared/POSModels/Tbltruck.cs
  67. 19
      Shared/POSModels/TbltruckDrivermapping.cs
  68. 21
      Shared/POSModels/Tbltruckassignment.cs
  69. 19
      Shared/POSModels/Tbltruckinventory.cs
  70. 33
      Shared/POSModels/Tbluser.cs
  71. 21
      Shared/POSModels/Tbstock.cs
  72. 17
      Shared/POSModels/Unitofmeasure.cs
  73. 3
      Shared/SharedClass.cs

8
Biskilog_Cloud.sln

@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientManager", "ClientManager\ClientManager.csproj", "{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerManager", "ServerManager\ServerManager.csproj", "{48786C44-14A8-4510-9DC2-167C431DDE95}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerManager", "ServerManager\ServerManager.csproj", "{48786C44-14A8-4510-9DC2-167C431DDE95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biskilog_Cloud.Shared", "Shared\Biskilog_Cloud.Shared.csproj", "{1D368EE7-D1D3-4D50-83ED-57B0EB9CC6F4}"
EndProject
@ -15,10 +13,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Release|Any CPU.Build.0 = Release|Any CPU
{48786C44-14A8-4510-9DC2-167C431DDE95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48786C44-14A8-4510-9DC2-167C431DDE95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48786C44-14A8-4510-9DC2-167C431DDE95}.Release|Any CPU.ActiveCfg = Release|Any CPU

27
ClientManager/ClientManager.csproj

@ -1,27 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-ClientManager-173f3572-8fd4-498f-addd-d620cda23800</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" />
<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>
<ItemGroup>
<ProjectReference Include="..\Shared\Biskilog_Cloud.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Sync\" />
</ItemGroup>
</Project>

10
ClientManager/Program.cs

@ -1,10 +0,0 @@
using ClientManager;
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
})
.Build();
host.Run();

11
ClientManager/Properties/launchSettings.json

@ -1,11 +0,0 @@
{
"profiles": {
"ClientManager": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

21
ClientManager/Worker.cs

@ -1,21 +0,0 @@
namespace ClientManager
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await Task.Delay(1000, stoppingToken);
}
}
}
}

8
ClientManager/appsettings.Development.json

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

8
ClientManager/appsettings.json

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

1374
ServerManager/BiskAcdbContext.cs

File diff suppressed because it is too large

79
ClientManager/BiskPosContext.cs → ServerManager/BiskPosContext.cs

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Biskilog_Cloud.Shared.Models;
using Microsoft.EntityFrameworkCore;
namespace ClientManager;
namespace ServerManager;
public partial class BiskPosContext : DbContext
{
@ -79,11 +79,6 @@ public partial class BiskPosContext : DbContext
public virtual DbSet<TblUserActivity> TblUserActivities { get; set; }
public virtual DbSet<UnitOfMeasure> UnitOfMeasures { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseSqlServer("Server=BarhenVM\\SqlExpress;Database=BISK_POS;Integrated Security=True;TrustServerCertificate=true");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<CreditPurchase>(entity =>
@ -105,7 +100,7 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.Date).HasColumnName("date");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Paid)
.HasColumnType("decimal(19, 2)")
.HasColumnName("paid");
@ -149,7 +144,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("debit");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.TransactionId)
.HasMaxLength(120)
.HasColumnName("transactionID");
@ -171,7 +166,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("branchID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(120)
.IsUnicode(false)
@ -206,7 +201,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("branchID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Unit)
.HasMaxLength(150)
.IsUnicode(false)
@ -225,7 +220,7 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.Cashier).HasColumnName("cashier");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Manager).HasColumnName("manager");
entity.Property(e => e.Owner).HasColumnName("owner");
entity.Property(e => e.Roles)
@ -247,7 +242,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("branchID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(50)
.HasColumnName("pcode");
@ -291,7 +286,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("city");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.StateOrProvince)
.HasMaxLength(50)
.IsUnicode(false)
@ -314,7 +309,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("brand");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
});
modelBuilder.Entity<TblCancelledTransaction>(entity =>
@ -338,7 +333,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("dateCancelled");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Transno)
.IsUnicode(false)
.HasColumnName("transno");
@ -373,7 +368,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("id");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Price)
.HasColumnType("decimal(19, 2)")
.HasColumnName("price");
@ -415,7 +410,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("category");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
});
modelBuilder.Entity<TblCompanyDetail>(entity =>
@ -441,7 +436,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("email");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.MainTelephone)
.HasMaxLength(50)
.HasColumnName("main_telephone");
@ -488,7 +483,7 @@ public partial class BiskPosContext : DbContext
.IsUnicode(false);
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.NameKey1)
.HasMaxLength(120)
.IsUnicode(false)
@ -531,7 +526,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("customerID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.TransactionId)
.HasMaxLength(50)
.HasColumnName("transactionID");
@ -554,7 +549,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("deliveryID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(60)
.HasColumnName("pcode");
@ -563,6 +558,10 @@ public partial class BiskPosContext : DbContext
.HasMaxLength(120)
.IsUnicode(false)
.HasColumnName("unit");
entity.Property(e => e.BranchId)
.HasMaxLength(50)
.IsUnicode(false)
.HasColumnName("branchID");
});
modelBuilder.Entity<TblDeliveryHead>(entity =>
@ -591,7 +590,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("generatedBy");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Status)
.HasMaxLength(20)
.IsUnicode(false)
@ -627,7 +626,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("fullname");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Telephone)
.HasMaxLength(15)
.IsUnicode(false)
@ -635,6 +634,10 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.ToDate)
.HasColumnType("date")
.HasColumnName("toDate");
entity.Property(e => e.BranchId)
.HasMaxLength(50)
.IsUnicode(false)
.HasColumnName("branchID");
});
modelBuilder.Entity<TblDiscountLog>(entity =>
@ -661,7 +664,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("discount");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.ReceiptId)
.HasMaxLength(50)
.HasColumnName("receiptID");
@ -704,7 +707,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("firstname");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Middlename)
.HasMaxLength(50)
.IsUnicode(false)
@ -764,7 +767,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("invoiceID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Price)
.HasColumnType("decimal(19, 2)")
.HasColumnName("price");
@ -803,7 +806,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("branchID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(50)
.HasColumnName("pcode");
@ -825,7 +828,7 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.Date).HasColumnName("date");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(50)
.HasColumnName("pcode");
@ -855,7 +858,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("invoiceID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(50)
.HasColumnName("pcode");
@ -894,7 +897,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("current_price");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(120)
.HasColumnName("pcode");
@ -934,7 +937,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("costprice");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(50)
.HasColumnName("pcode");
@ -972,7 +975,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("driver");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.LicensePlate)
.HasMaxLength(60)
.HasColumnName("licensePlate");
@ -997,7 +1000,7 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.DateAssigned).HasColumnName("dateAssigned");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.OrderId)
.HasMaxLength(50)
.HasColumnName("orderID");
@ -1025,7 +1028,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("driverID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Operation)
.HasMaxLength(50)
.IsUnicode(false)
@ -1046,7 +1049,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("countID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Pcode)
.HasMaxLength(50)
.HasColumnName("pcode");
@ -1091,7 +1094,7 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.LastLogin).HasColumnName("last_login");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Password)
.IsUnicode(false)
.HasColumnName("password");
@ -1129,7 +1132,7 @@ public partial class BiskPosContext : DbContext
entity.Property(e => e.LastActive).HasColumnName("last_active");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Workstation)
.HasMaxLength(100)
.HasColumnName("workstation");
@ -1150,7 +1153,7 @@ public partial class BiskPosContext : DbContext
.HasColumnName("branchID");
entity.Property(e => e.LastModified)
.HasDefaultValueSql("(getdate())")
.HasColumnName("last_modified");
.HasColumnName("lastmodified");
entity.Property(e => e.Status)
.HasMaxLength(50)
.IsUnicode(false)

278
ServerManager/BiskilogContext.cs

@ -1,278 +0,0 @@
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);
}

18
ServerManager/Hubs/SalesHub.cs

@ -1,18 +0,0 @@
using Microsoft.AspNetCore.SignalR;
using ServerManager.Interface;
namespace ServerManager.Hubs
{
public class SalesHub : Hub<ISalesHub>
{
public override Task OnConnectedAsync()
{
Clients.
return base.OnConnectedAsync();
}
public async Task Publish(string a_companyId)
{
await Clients.OthersInGroup(a_companyId).AddTransaction();
}
}
}

7
ServerManager/Interface/ISalesHub.cs

@ -1,7 +0,0 @@
namespace ServerManager.Interface
{
public interface ISalesHub
{
Task AddTransaction();
}
}

19
ServerManager/Program.cs

@ -1,3 +1,9 @@
using Biskilog_Cloud.Shared.Interfaces;
using Microsoft.EntityFrameworkCore;
using ServerManager;
using ServerManager.ServiceRepo;
using ServerManager.SyncMethods;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@ -6,7 +12,20 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddEntityFrameworkMySql().AddDbContext<BiskPosContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("Connection"));
});
builder.Services.AddScoped<SalesSync>();
builder.Services.AddScoped<CompanySync>();
builder.Services.AddScoped<ProductSync>();
builder.Services.AddHostedService<Worker>();
builder.Services.AddScoped<ISalesInterface, SalesService>();
builder.Services.AddScoped<IUser, CompanyService>();
builder.Services.AddScoped<ICustomer, CompanyService>();
builder.Services.AddScoped<ICompanyInfo, CompanyService>();
builder.Services.AddScoped<IProduct, ProductsService>();
var app = builder.Build();
// Configure the HTTP request pipeline.

1
ServerManager/ServerManager.csproj

@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.151" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" />
<PackageReference Include="BCrypt.Net" Version="0.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" />

287
ServerManager/ServiceRepo/CompanyService.cs

@ -0,0 +1,287 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.Interfaces;
using Biskilog_Cloud.Shared.Models;
using Dapper;
using Microsoft.Diagnostics.Tracing.Parsers.Kernel;
using Microsoft.EntityFrameworkCore;
using System;
using System.Data;
using System.Data.SqlClient;
namespace ServerManager.ServiceRepo
{
public class CompanyService : ICompanyInfo, ICustomer, IUser
{
private readonly BiskPosContext m_context;
public CompanyService(BiskPosContext a_context)
{
m_context = a_context;
}
#region Unimplemented
public IEnumerable<TblUser> FetchUsers()
{
throw new NotImplementedException();
}
public Task<IEnumerable<TblUser>> GetUsers()
{
throw new NotImplementedException();
}
public IEnumerable<CustomerAccounts> FetchCustomers()
{
throw new NotImplementedException();
}
public Task<IEnumerable<CustomerAccounts>> GetCustomers()
{
throw new NotImplementedException();
}
public Task<IEnumerable<TblBranch>> GetBranches()
{
throw new NotImplementedException();
}
public string GetBranchName(string a_branchId)
{
throw new NotImplementedException();
}
public Task<TblCompanyDetail> GetCompanyInfoAsync()
{
throw new NotImplementedException();
}
public string GetCompanyName()
{
throw new NotImplementedException();
}
public IEnumerable<TblBranch> FetchBranches()
{
throw new NotImplementedException();
}
#endregion
public async Task<IEnumerable<TblBranch>> FetchBranch(DateTime a_dateTime, string a_branch)
{
string connection = m_context.Database.GetConnectionString();
using (IDbConnection dbConnection = new SqlConnection(connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblbranch",
a_branchId = a_branch,
lastModified = a_dateTime
};
List<TblBranch> result = (await dbConnection.QueryAsync<TblBranch>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblCompanyDetail>> FetchCompanyInfoAsync(DateTime a_dateTime, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcompanydetails",
a_branchId = a_branch,
lastModified = a_dateTime
};
List<TblCompanyDetail> result = (await dbConnection.QueryAsync<TblCompanyDetail>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblTruckDriverMapping>> FetchDriverMappingAsync(DateTime a_syncDate, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tbltruck_drivermapping",
a_branchId = a_branch,
lastModified = a_syncDate
};
List<TblTruckDriverMapping> result = (await dbConnection.QueryAsync<TblTruckDriverMapping>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblDriver>> FetchDriversAsync(DateTime a_syncDate, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tbldrivers",
a_branchId = a_branch,
lastModified = a_syncDate
};
List<TblDriver> result = (await dbConnection.QueryAsync<TblDriver>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<SystemUserRole>> FetchSystemRoles(DateTime a_dateTime, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "systemuserroles",
a_branchId = a_branch,
lastModified = a_dateTime
};
List<SystemUserRole> result = (await dbConnection.QueryAsync<SystemUserRole>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblTruck>> FetchTruckAsync(DateTime a_syncDate, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tbltruck",
a_branchId = a_branch,
lastModified = a_syncDate
};
List<TblTruck> result = (await dbConnection.QueryAsync<TblTruck>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblTruckInventory>> FetchTruckInventoryAsync(DateTime a_syncDate, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tbltruckinventory",
a_branchId = a_branch,
lastModified = a_syncDate
};
List<TblTruckInventory> result = (await dbConnection.QueryAsync<TblTruckInventory>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblCustomer>> FetchCustomers(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcustomers",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblCustomer> result = (await dbConnection.QueryAsync<TblCustomer>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblTruckAssignment>> FetchTruckAssignmentAsync(DateTime a_syncDate, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tbltruckassignments",
a_branchId = a_branch,
lastModified = a_syncDate
};
List<TblTruckAssignment> result = (await dbConnection.QueryAsync<TblTruckAssignment>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblUser>> FetchUsers(DateTime a_syncDate, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_context.Database.GetConnectionString()))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblusers",
a_branchId = a_branch,
lastModified = a_syncDate
};
List<TblUser> result = (await dbConnection.QueryAsync<TblUser>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
}
}

390
ServerManager/ServiceRepo/ProductsService.cs

@ -0,0 +1,390 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.Interfaces;
using Biskilog_Cloud.Shared.Models;
using Dapper;
using Microsoft.EntityFrameworkCore;
using System.Data;
using System.Data.SqlClient;
namespace ServerManager.ServiceRepo
{
public class ProductsService : IProduct
{
private readonly BiskPosContext m_context;
private string m_connection;
public ProductsService(BiskPosContext a_context, IConfiguration configuration)
{
m_context = a_context;
m_connection = configuration.GetConnectionString("connection")!.ToString();
}
public event EventHandler ProductsChanged;
public event EventHandler UnitsChanged;
public event EventHandler BrandsChanged;
public event EventHandler CategoriesChanged;
public async Task<IEnumerable<TblBrand>> FetchBrandsAsync(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblBrand",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblBrand> result = (await dbConnection.QueryAsync<TblBrand>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TblBrand>();
}
}
public async Task<IEnumerable<TblCategory>> FetchCategoriesAsync(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcategory",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblCategory> result = (await dbConnection.QueryAsync<TblCategory>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TblCategory>();
}
}
public async Task<IEnumerable<TblInventory>> FetchInventory(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblInventory",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblInventory> result = (await dbConnection.QueryAsync<TblInventory>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TblInventory>();
}
}
public async Task<IEnumerable<TblInventoryEntry>> FetchInventoryEntries(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblInventoryentries",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblInventoryEntry> result = (await dbConnection.QueryAsync<TblInventoryEntry>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TblInventoryEntry>();
}
}
public async Task<IEnumerable<TblPriceChange>> FetchPriceChanges(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblpricechanges",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblPriceChange> result = (await dbConnection.QueryAsync<TblPriceChange>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TblPriceChange>();
}
}
public async Task<IEnumerable<ProductAltUnit>> FetchProductAltUnit(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "productaltunit",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<ProductAltUnit> result = (await dbConnection.QueryAsync<ProductAltUnit>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<ProductAltUnit>();
}
}
public async Task<IEnumerable<TblProduct>> FetchProducts(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
branchID = a_branch,
lastModified = a_lastSync
};
List<TblProduct> result = (await dbConnection.QueryAsync<TblProduct>(
"FetchProductTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TblProduct>();
}
}
public async Task<IEnumerable<RestockLevel>> FetchRestockAsync(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "Restocklevels",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<RestockLevel> result = (await dbConnection.QueryAsync<RestockLevel>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<RestockLevel>();
}
}
public async Task<IEnumerable<TbStock>> FetchStockAsync(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "Tbstock",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TbStock> result = (await dbConnection.QueryAsync<TbStock>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<TbStock>();
}
}
public async Task<IEnumerable<UnitOfMeasure>> FetchUnitOfMeasureAsync(DateTime a_lastSync, string a_branch)
{
try
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "unitofmeasure",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<UnitOfMeasure> result = (await dbConnection.QueryAsync<UnitOfMeasure>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<UnitOfMeasure>();
}
}
public Task FetchBrands()
{
throw new NotImplementedException();
}
public Task FetchLowStockProducts()
{
throw new NotImplementedException();
}
public Task FetchCategories()
{
throw new NotImplementedException();
}
public Task FetchProducts()
{
throw new NotImplementedException();
}
public Task FetchUnits()
{
throw new NotImplementedException();
}
public IEnumerable<TblBrand> GetBrands(string a_brandKey = "")
{
throw new NotImplementedException();
}
public IEnumerable<TblCategory> GetCategories(string a_categoryKey = "")
{
throw new NotImplementedException();
}
public IEnumerable<ProductItem> GetLowstockItems()
{
throw new NotImplementedException();
}
public ProductItem GetProductById(string a_id)
{
throw new NotImplementedException();
}
public ProductItem GetProductByName(string name)
{
throw new NotImplementedException();
}
public IEnumerable<ProductItem> GetProducts(string a_productKey = "")
{
throw new NotImplementedException();
}
public string GetUnitName(string a_unitCode)
{
throw new NotImplementedException();
}
public IEnumerable<UnitOfMeasure> GetUnitofmeasures()
{
throw new NotImplementedException();
}
public void RefreshList()
{
throw new NotImplementedException();
}
}
}

282
ServerManager/ServiceRepo/SalesService.cs

@ -0,0 +1,282 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.Interfaces;
using Biskilog_Cloud.Shared.Models;
using Dapper;
using Microsoft.EntityFrameworkCore;
using System.Data;
using System.Data.SqlClient;
namespace ServerManager.ServiceRepo
{
public class SalesService : ISalesInterface
{
private readonly BiskPosContext m_context;
private readonly string m_connection;
public SalesService(BiskPosContext a_context, IConfiguration configuration)
{
m_context = a_context;
m_connection = configuration.GetConnectionString("connection")!.ToString();
}
public event EventHandler TransactionsChanged;
public event EventHandler FetchComplete;
public event EventHandler FetchStart;
public async Task<IEnumerable<TblCancelledTransaction>> FetchCancelledTransaction(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcancelledtransaction",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblCancelledTransaction> result = (await dbConnection.QueryAsync<TblCancelledTransaction>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblCart>> FetchCartTbl(DateTime a_lastSync,string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcart",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblCart> result = (await dbConnection.QueryAsync<TblCart>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<CreditPurchase>> FetchCreditPurchase(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "CreditPurchases",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<CreditPurchase> result = (await dbConnection.QueryAsync<CreditPurchase>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<CustomerAccount>> FetchCustomerAccount(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "customeraccounts",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<CustomerAccount> result = (await dbConnection.QueryAsync<CustomerAccount>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblCustomerPurchase>> FetchCustomerPurchase(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcustomerpurchases",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblCustomerPurchase> result = (await dbConnection.QueryAsync<TblCustomerPurchase>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblDeliveryDetail>> FetchDeliveryDetails(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tbldeliverydetails",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblDeliveryDetail> result = (await dbConnection.QueryAsync<TblDeliveryDetail>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblDeliveryHead>> FetchDeliveryHead(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblDeliveryHeads",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblDeliveryHead> result = (await dbConnection.QueryAsync<TblDeliveryHead>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblDeliveryRecipient>> FetchDeliveryRecipients(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblDeliveryRecipients",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblDeliveryRecipient> result = (await dbConnection.QueryAsync<TblDeliveryRecipient>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblDiscountLog>> FetchDiscountLogs(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblDiscountLogs",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblDiscountLog> result = (await dbConnection.QueryAsync<TblDiscountLog>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public async Task<IEnumerable<TblInvoice>> FetchInvoice(DateTime a_lastSync, string a_branch)
{
using (IDbConnection dbConnection = new SqlConnection(m_connection))
{
dbConnection.Open();
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblInvoices",
a_branchId = a_branch,
lastModified = a_lastSync
};
List<TblInvoice> result = (await dbConnection.QueryAsync<TblInvoice>(
"FetchTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();
return result;
}
}
public Task FetchReceipt(string a_receiptId)
{
throw new NotImplementedException();
}
public Task FetchRecentTransaction(int a_limit)
{
throw new NotImplementedException();
}
public Task FetchTransaction(DateTime a_start, DateTime a_end)
{
throw new NotImplementedException();
}
public IEnumerable<SaleItem> GetReceipt(string a_receiptId)
{
throw new NotImplementedException();
}
public Task<IEnumerable<TblCart>> GetReceiptDetail(string a_receiptId)
{
throw new NotImplementedException();
}
public IEnumerable<SaleItem> GetRecentTransaction()
{
throw new NotImplementedException();
}
public IEnumerable<SaleItem> GetTransactions(DateTime a_start, DateTime a_end)
{
throw new NotImplementedException();
}
}
}

346
ServerManager/SyncMethods/CompanySync.cs

@ -0,0 +1,346 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.Interfaces;
using Biskilog_Cloud.Shared.Models;
using System.Net.Http;
using System.Net.Http.Headers;
namespace ServerManager.SyncMethods
{
public class CompanySync
{
private readonly ICompanyInfo m_companyService;
private readonly IUser m_userService;
private readonly ICustomer m_customerService;
private HttpClient m_httpClient;
public CompanySync(ICompanyInfo companyService, IUser userService, ICustomer customerService)
{
m_companyService = companyService;
m_userService = userService;
m_customerService = customerService;
m_httpClient = new HttpClient();
}
/// <summary>
/// Returns a collection of tasks to perform a sync in the ICompanyInterface
/// </summary>
/// <returns></returns>
public IEnumerable<Task> GetCompanySyncTask(HttpClient httpClient)
{
m_httpClient = httpClient;
return new Task[] {
SyncCompanyTable(),
SyncBranchTable(),
SyncCustomer(),
SyncDrivers(),
SyncTruckAssignments(),
SyncTruckDriverMappingSync(),
SyncTruckInventorySync(),
SyncUsersSync(),
SyncTruckSync(),
SyncSystemUserRoles()
};
}
private async Task SyncCompanyTable()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tblcompanydetails");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblCompanyDetail> modifiedCart = await m_companyService.FetchCompanyInfoAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp
{
TableName = "tblcompanydetails",
Timestamp = DateTime.Now.AddSeconds(-10),
};
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblCompanyDetail> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tblcompanydetails", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncBranchTable()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tblbranch");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblBranch> modifiedCart = await m_companyService.FetchBranch(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp
{
TableName = "tblbranch",
Timestamp = DateTime.Now.AddSeconds(-10),
};
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblBranch> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tblbranch", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncCustomer()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tblCustomers");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblCustomer> modifiedCart = await m_customerService.FetchCustomers(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp
{
TableName = "tblCustomers",
Timestamp = DateTime.Now.AddSeconds(-10),
};
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblCustomer> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tblCustomers", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncDrivers()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tbldrivers");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblDriver> modifiedCart = await m_companyService.FetchDriversAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbldrivers", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblDriver> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tbldriver", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncSystemUserRoles()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/systemuserroles");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<SystemUserRole> modifiedCart = await m_companyService.FetchSystemRoles(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "systemuserroles", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<SystemUserRole> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/SystemRoles", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncTruckAssignments()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tbltruckassignments");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblTruckAssignment> modifiedCart = await m_companyService.FetchTruckAssignmentAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbltruckassignments", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblTruckAssignment> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tblTruckAssignment", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncTruckDriverMappingSync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tbltruck_drivermapping");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblTruckDriverMapping> modifiedCart = await m_companyService.FetchDriverMappingAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbltruck_drivermapping", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblTruckDriverMapping> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tbldrivermappings", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncTruckInventorySync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tbltruckinventory");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblTruckInventory> modifiedCart = await m_companyService.FetchTruckInventoryAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbltruckinventory", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblTruckInventory> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tbltruckinventory", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncTruckSync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tbltrucks");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblTruck> modifiedCart = await m_companyService.FetchTruckAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbltrucks", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblTruck> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tbltrucks", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
private async Task SyncUsersSync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncCompanyInfo/lastsyncdate/tblusers");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblUser> modifiedCart = await m_userService.FetchUsers(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblusers", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblUser> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/publish/tblusers", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncCompanyInfo/setsyncdate", syncTimestamp);
}
}
}

327
ServerManager/SyncMethods/ProductSync.cs

@ -0,0 +1,327 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.Interfaces;
using Biskilog_Cloud.Shared.Models;
using System.Net.Http.Headers;
namespace ServerManager.SyncMethods
{
public class ProductSync
{
private readonly IProduct m_productService;
private HttpClient m_httpClient;
public ProductSync(IProduct a_produtService)
{
m_productService = a_produtService;
m_httpClient = new HttpClient();
}
/// <summary>
/// Returns a collection of tasks to perform a sync in the SalesInterface
/// </summary>
/// <returns></returns>
public IEnumerable<Task> GetProductSyncTask(HttpClient httpClient)
{
m_httpClient = httpClient;
return new Task[] {
SyncProductsAsync(),
SyncInventoryAsync(),
SyncInventoryEntriesAsync(),
SyncRestockAsync(),
SyncPriceChangesAsync(),
SyncProductAltUnitAsync(),
SyncStockAsync(),
SyncBrandsAsync(),
SyncCategoriesAsync(),
SyncUnitOfMeasureAsync(),
};
}
private async Task SyncProductsAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tblproduct");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblProduct> modifiedCart = await m_productService.FetchProducts(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblproduct", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblProduct> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblproducts", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncInventoryAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tblInventory");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblInventory> modifiedCart = await m_productService.FetchInventory(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblInventory", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblInventory> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblInventory", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncInventoryEntriesAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tblInventoryentries");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblInventoryEntry> modifiedCart = await m_productService.FetchInventoryEntries(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblInventoryentries", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblInventoryEntry> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblInventoryentry", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncRestockAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/restocklevels");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<RestockLevel> modifiedCart = await m_productService.FetchRestockAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "restocklevels", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<RestockLevel> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblRestock", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncPriceChangesAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tblpricechanges");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblPriceChange> modifiedCart = await m_productService.FetchPriceChanges(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblpricechanges", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblPriceChange> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tlpricechanges", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncProductAltUnitAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/productaltunit");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<RestockLevel> modifiedCart = await m_productService.FetchRestockAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "productaltunit", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<RestockLevel> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblProductAltUnit", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncStockAsync()
{var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tbstock");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TbStock> modifiedCart = await m_productService.FetchStockAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbstock", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TbStock> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblStock", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncBrandsAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tblbrands");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblBrand> modifiedCart = await m_productService.FetchBrandsAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblbrands", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblBrand> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblbrands", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncCategoriesAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tblcategory");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblCategory> modifiedCart = await m_productService.FetchCategoriesAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblcategory", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblCategory> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblCategories", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncUnitOfMeasureAsync()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/unitofmeasure");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<UnitOfMeasure> modifiedCart = await m_productService.FetchUnitOfMeasureAsync(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "unitofmeasure", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<UnitOfMeasure> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblunitofmeasure", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
}
}

341
ServerManager/SyncMethods/SalesSync.cs

@ -0,0 +1,341 @@
using System.Net.Http.Headers;
using Biskilog_Cloud.Shared.Interfaces;
using Biskilog_Cloud.Shared.Models;
using Biskilog_Cloud.Shared.CustomModels;
namespace ServerManager.SyncMethods
{
public class SalesSync
{
private readonly ISalesInterface m_salesService;
private HttpClient m_httpClient;
public SalesSync(ISalesInterface a_salesService)
{
m_salesService = a_salesService;
m_httpClient = new HttpClient();
}
/// <summary>
/// Returns a collection of tasks to perform a sync in the SalesInterface
/// </summary>
/// <returns></returns>
public IEnumerable<Task> GetSalesSyncTask(HttpClient httpClient)
{
m_httpClient = httpClient;
return new Task[] {
SyncCartTable(),
SyncInvoice(),
SyncDiscountLogs(),
SyncCancelledTransactionTable(),
SyncDeliveryRecipient(),
SyncCreditPurchase(),
SyncCustomerAccounts(),
SyncCustomerPurchases(),
SyncDeliveryDetails(),
SynctblDeliveryhead(),
};
}
private async Task SyncCartTable()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblcart");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblCart> modifiedCart = await m_salesService.FetchCartTbl(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp
{
TableName = "TblCart",
Timestamp = DateTime.Now.AddSeconds(-10),
};
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblCart> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblCart", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncCancelledTransactionTable()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblcancelledtransactions");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblCancelledTransaction> modifiedCart = await m_salesService.FetchCancelledTransaction(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp
{
TableName = "tblcancelledtransactions",
Timestamp = DateTime.Now.AddSeconds(-10),
};
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblCancelledTransaction> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblcancelledtransaction", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncCreditPurchase()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/CreditPurchases");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<CreditPurchase> modifiedCart = await m_salesService.FetchCreditPurchase(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp
{
TableName = "CreditPurchases",
Timestamp = DateTime.Now.AddSeconds(-10),
};
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<CreditPurchase> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblCreditpurchase", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncCustomerAccounts()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/customeraccounts");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<CustomerAccount> modifiedCart = await m_salesService.FetchCustomerAccount(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "customeraccounts", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<CustomerAccount> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblCustomerAccount", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncCustomerPurchases()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblcustomerpurchases");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblCustomerPurchase> modifiedCart = await m_salesService.FetchCustomerPurchase(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblcustomerpurchases", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblCustomerPurchase> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/CustomerPurchase", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncDiscountLogs()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tbldiscountlogs");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblDiscountLog> modifiedCart = await m_salesService.FetchDiscountLogs(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbldiscountlogs", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblDiscountLog> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/DiscountLogs", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncDeliveryDetails()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblDeliverydetails");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblDeliveryDetail> modifiedCart = await m_salesService.FetchDeliveryDetails(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbldeliverydetails", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblDeliveryDetail> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblDeliverydetails", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SynctblDeliveryhead()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblDeliveryhead");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblDeliveryHead> modifiedCart = await m_salesService.FetchDeliveryHead(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbldeliveryhead", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblDeliveryHead> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblDeliveryhead", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncDeliveryRecipient()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblDeliveryrecipients");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblDeliveryRecipient> modifiedCart = await m_salesService.FetchDeliveryRecipients(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tbldeliveryrecipients", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblDeliveryRecipient> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblDeliveryrecipient", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
private async Task SyncInvoice()
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncSales/lastsyncdate/tblinvoice");
if (!responseMessage.IsSuccessStatusCode)
{
return;
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<TblInvoice> modifiedCart = await m_salesService.FetchInvoice(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "tblinvoice", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
int batches = (totalItems + batchSize - 1) / batchSize; // Calculate total batches
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<TblInvoice> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncSales/publish/tblinvoice", batch);
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"Sent batch {batchIndex + 1}, Count: {batch.Count}");
}
}
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncSales/setsyncdate", syncTimestamp);
}
}
}

58
ServerManager/Worker.cs

@ -1 +1,57 @@

using ServerManager.SyncMethods;
using System.Net.Http.Headers;
namespace ServerManager
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
private readonly IServiceProvider _serviceProvider;
private readonly IConfiguration m_configuration;
private HttpClient m_httpClient;
public Worker(ILogger<Worker> logger, IServiceProvider serviceProvider, IConfiguration configuration)
{
_logger = logger;
_serviceProvider = serviceProvider;
m_configuration = configuration;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
try
{
string baseurl = m_configuration.GetValue("BaseUrl", "")!;
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(baseurl);
string token = m_configuration.GetValue("Token", "")!;
var authHeader = new AuthenticationHeaderValue("Bearer", token);
httpClient.DefaultRequestHeaders.Authorization = authHeader;
using var scope = _serviceProvider.CreateScope();
var salesSync = scope.ServiceProvider.GetRequiredService<SalesSync>();
var productSync = scope.ServiceProvider.GetRequiredService<ProductSync>();
var companySync = scope.ServiceProvider.GetRequiredService<CompanySync>();
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time} ", DateTimeOffset.Now);
List<Task> runTask = new List<Task>();
runTask.AddRange(salesSync.GetSalesSyncTask(httpClient));
runTask.AddRange(productSync.GetProductSyncTask(httpClient));
runTask.AddRange(companySync.GetCompanySyncTask(httpClient));
// Wait for all tasks to complete
await Task.WhenAll(runTask);
await Task.Delay(1000, stoppingToken);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}

5
ServerManager/appsettings.json

@ -6,9 +6,10 @@
}
},
"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;"
"Connection": "Server=BarhenVM\\SqlExpress;Database=BISK_POS;Integrated Security=True;TrustServerCertificate=true"
},
"Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMWM3MWE0Ni0xZmY2LTRkMGMtYmYzMS1iMTExMzJlMGM5ODQiLCJpYXQiOiIxNC8wOC8yMDIzIDY6MjI6MzIgcG0iLCJDb250cmFjdFN0YXJ0IjoiMTgvMDUvMjAyMyA4OjQ3OjI3IHBtIiwiQ29udHJhY3RFbmQiOiIxOC8wNS8yMDI0IDg6NDc6MjkgcG0iLCJVc2VySWQiOiIxIiwiVXNlcm5hbWUiOiJ0ZXN0IiwiRGJJZCI6IjEiLCJDb21wYXJpc29uTW9kZSI6IkZhbHNlIiwiQnJhbmNoSWQiOiJCUklEMCIsIkJyYW5jaEFjY2VzcyI6IkJSSUQwIiwiQ2xpZW50SWQiOiIxIiwiZXhwIjoxNjkzMjQ2OTUyLCJpc3MiOiJBVVRIIFNFUlZFUiIsImF1ZCI6IkJJU0tJTE9HIn0.W3kxw5kEj13TDSs96doR20IW96k3aO8uR5SKGiSaSX4",
"BaseUrl": "https://localhost:7247/",
"AllowedHosts": "*",
"JWT": {
"Key": "@@BISKILOGACCOUNTING2023DEV??//##$",

4
Shared/CustomModels/CancelledSales.cs

@ -1,4 +1,4 @@
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,7 +9,7 @@ namespace Biskilog_Cloud.Shared.CustomModels
{
public class CancelledSales
{
public Tblcancelledtransaction? CancelledTransaction { get; set; }
public TblCancelledTransaction? CancelledTransaction { get; set; }
public string Customer { get; set; } = "WALK-IN Purchase";
public decimal? Value { get; set; }
}

4
Shared/CustomModels/CustomerAccounts.cs

@ -1,4 +1,4 @@
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,7 +9,7 @@ namespace Biskilog_Cloud.Shared.CustomModels
{
public class CustomerAccounts
{
public Tblcustomer Customer { get; set; }
public TblCustomer Customer { get; set; }
public decimal Debt { get; set; } = 0;
}
}

8
Shared/CustomModels/ProductItem.cs

@ -1,4 +1,4 @@
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,9 +9,9 @@ namespace Biskilog_Cloud.Shared.CustomModels
{
public class ProductItem
{
public Tblproduct? Product { get; set; }
public Tblinventory? Stock { get; set; }
public Restocklevel? Restocklevel { get; set; }
public TblProduct? Product { get; set; }
public TblInventory? Stock { get; set; }
public RestockLevel? Restocklevel { get; set; }
public List<ProductUnits> Units { get; set; } = new List<ProductUnits>();
public string BaseUnit { get; set; } = string.Empty;
}

14
Shared/CustomModels/SyncTimestamp.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Biskilog_Cloud.Shared.CustomModels
{
public class SyncTimestamp
{
public string TableName { get; set; }
public DateTime Timestamp { get; set; }
}
}

4
Shared/Interfaces/IAnalytics.cs

@ -1,5 +1,5 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
namespace Biskilog_Cloud.Shared.Interfaces
{
@ -11,7 +11,7 @@ namespace Biskilog_Cloud.Shared.Interfaces
/// <param name="a_start">Specified Start Date</param>
/// <param name="a_end">Specified end Date</param>
/// <returns></returns>
IEnumerable<Tblcart> GetSalesTransaction(DateTime a_start, DateTime a_end);
IEnumerable<TblCart> GetSalesTransaction(DateTime a_start, DateTime a_end);
/// <summary>
/// Fetches a collection of sales transaction made within a one week period
/// </summary>

16
Shared/Interfaces/ICompanyInfo.cs

@ -1,4 +1,4 @@
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,10 +9,18 @@ namespace Biskilog_Cloud.Shared.Interfaces
{
public interface ICompanyInfo
{
IEnumerable<Tblbranch> FetchBranches();
Task<Tblcompanydetail> GetCompanyInfoAsync();
Task<IEnumerable<Tblbranch>> GetBranches();
IEnumerable<TblBranch> FetchBranches();
Task<TblCompanyDetail> GetCompanyInfoAsync();
Task<IEnumerable<TblBranch>> GetBranches();
string GetCompanyName();
string GetBranchName(string a_branchId);
Task<IEnumerable<TblBranch>> FetchBranch(DateTime a_dateTime, string a_branch);
Task<IEnumerable<SystemUserRole>> FetchSystemRoles(DateTime a_dateTime, string a_branch);
Task<IEnumerable<TblCompanyDetail>> FetchCompanyInfoAsync(DateTime a_dateTime, string a_branch);
Task<IEnumerable<TblDriver>> FetchDriversAsync(DateTime a_syncDate, string a_branchId);
Task<IEnumerable<TblTruckDriverMapping>> FetchDriverMappingAsync(DateTime a_syncDate, string a_branchId);
Task<IEnumerable<TblTruck>> FetchTruckAsync(DateTime a_syncDate, string a_branchId);
Task<IEnumerable<TblTruckInventory>> FetchTruckInventoryAsync(DateTime a_syncDate, string a_branchId);
Task<IEnumerable<TblTruckAssignment>> FetchTruckAssignmentAsync(DateTime a_syncDate, string a_branchId);
}
}

3
Shared/Interfaces/ICustomer.cs

@ -1,5 +1,5 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
namespace Biskilog_Cloud.Shared.Interfaces
{
@ -7,5 +7,6 @@ namespace Biskilog_Cloud.Shared.Interfaces
{
IEnumerable<CustomerAccounts> FetchCustomers();
Task<IEnumerable<CustomerAccounts>> GetCustomers();
Task<IEnumerable<TblCustomer>> FetchCustomers(DateTime a_lastSync, string a_branchId);
}
}

24
Shared/Interfaces/IProducts.cs

@ -1,19 +1,14 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.POSModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Biskilog_Cloud.Shared.Models;
namespace Biskilog_Cloud.Shared.Interfaces
{
public interface IProduct
{
IEnumerable<Unitofmeasure> GetUnitofmeasures();
IEnumerable<UnitOfMeasure> GetUnitofmeasures();
IEnumerable<ProductItem> GetProducts(string a_productKey = "");
IEnumerable<Tblbrand> GetBrands(string a_brandKey = "");
IEnumerable<Tblcategory> GetCategories(string a_categoryKey = "");
IEnumerable<TblBrand> GetBrands(string a_brandKey = "");
IEnumerable<TblCategory> GetCategories(string a_categoryKey = "");
IEnumerable<ProductItem> GetLowstockItems();
Task FetchProducts();
Task FetchLowStockProducts();
@ -28,5 +23,16 @@ namespace Biskilog_Cloud.Shared.Interfaces
event EventHandler UnitsChanged;
event EventHandler BrandsChanged;
event EventHandler CategoriesChanged;
Task<IEnumerable<TblProduct>> FetchProducts(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblInventory>> FetchInventory(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblInventoryEntry>> FetchInventoryEntries(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblPriceChange>> FetchPriceChanges(DateTime a_lastSync, string a_branch);
Task<IEnumerable<ProductAltUnit>> FetchProductAltUnit(DateTime a_lastSync, string a_branch);
Task<IEnumerable<RestockLevel>> FetchRestockAsync(DateTime a_lastSync, string a_branch);
Task<IEnumerable<UnitOfMeasure>> FetchUnitOfMeasureAsync(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TbStock>> FetchStockAsync(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblBrand>> FetchBrandsAsync(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblCategory>> FetchCategoriesAsync(DateTime a_lastSync, string a_branch);
}
}

15
Shared/Interfaces/ISalesInterface.cs

@ -1,5 +1,5 @@
using Biskilog_Cloud.Shared.CustomModels;
using Biskilog_Cloud.Shared.POSModels;
using Biskilog_Cloud.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -16,9 +16,20 @@ namespace Biskilog_Cloud.Shared.Interfaces
IEnumerable<SaleItem> GetRecentTransaction();
Task FetchReceipt(string a_receiptId);
IEnumerable<SaleItem> GetReceipt(string a_receiptId);
Task<IEnumerable<Tblcart>> GetReceiptDetail(string a_receiptId);
Task<IEnumerable<TblCart>> GetReceiptDetail(string a_receiptId);
event EventHandler TransactionsChanged;
event EventHandler FetchComplete;
event EventHandler FetchStart;
Task<IEnumerable<TblCart>> FetchCartTbl(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblCancelledTransaction>> FetchCancelledTransaction(DateTime a_lastSync, string a_branch);
Task<IEnumerable<CreditPurchase>> FetchCreditPurchase(DateTime a_lastSync, string a_branch);
Task<IEnumerable<CustomerAccount>> FetchCustomerAccount(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblCustomerPurchase>> FetchCustomerPurchase(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblDiscountLog>> FetchDiscountLogs(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblDeliveryDetail>> FetchDeliveryDetails(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblDeliveryHead>> FetchDeliveryHead(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblDeliveryRecipient>> FetchDeliveryRecipients(DateTime a_lastSync, string a_branch);
Task<IEnumerable<TblInvoice>> FetchInvoice(DateTime a_lastSync, string a_branch);
}
}

13
Shared/Interfaces/IUser.cs

@ -1,15 +1,12 @@
using Biskilog_Cloud.Shared.POSModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Biskilog_Cloud.Shared.Models;
namespace Biskilog_Cloud.Shared.Interfaces
{
public interface IUser
{
IEnumerable<Tbluser> FetchUsers();
Task<IEnumerable<Tbluser>> GetUsers();
IEnumerable<TblUser> FetchUsers();
Task<IEnumerable<TblUser>> GetUsers();
Task<IEnumerable<TblUser>> FetchUsers(DateTime a_syncDate, string a_branchId);
}
}

1
Shared/Models/TbStock.cs

@ -21,3 +21,4 @@ public partial class TbStock
public DateTime LastModified { get; set; }
}
;

2
Shared/Models/TblCustomer.cs

@ -23,7 +23,7 @@ public partial class TblCustomer
public string? Tin { get; set; }
public DateTime? DateExit { get; set; }
public DateTime? DateExit { get; set; } = new DateTime(2000, 01, 01);
public string? Email { get; set; }

1
Shared/Models/TblDeliveryDetail.cs

@ -18,4 +18,5 @@ public partial class TblDeliveryDetail
public string CountId { get; set; } = null!;
public DateTime LastModified { get; set; }
public string? BranchId { get; set; }
}

1
Shared/Models/TblDeliveryRecipient.cs

@ -22,4 +22,5 @@ public partial class TblDeliveryRecipient
public DateTime? ToDate { get; set; }
public DateTime LastModified { get; set; }
public string? BranchId { get; set; }
}

2
Shared/Models/TblInventory.cs

@ -7,7 +7,7 @@ public partial class TblInventory
{
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public int? Quantity { get; set; } = 0;
public string? BranchId { get; set; }

2
Shared/Models/TblInventoryEntry.cs

@ -7,7 +7,7 @@ public partial class TblInventoryEntry
{
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public int? Quantity { get; set; } = 0;
public DateTime? Date { get; set; }

6
Shared/Models/TblInvoice.cs

@ -9,13 +9,13 @@ public partial class TblInvoice
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public int? Quantity { get; set; } = 0;
public decimal? Unitprice { get; set; }
public decimal? Unitprice { get; set; } = 0;
public string? Unit { get; set; }
public decimal? Totalprice { get; set; }
public decimal? Totalprice { get; set; } = 0;
public DateTime? DateGenerated { get; set; }

6
Shared/Models/TblPriceChange.cs

@ -7,11 +7,11 @@ public partial class TblPriceChange
{
public string? Pcode { get; set; }
public decimal? PreviousPrice { get; set; }
public decimal? PreviousPrice { get; set; } = 0;
public decimal? CurrentPrice { get; set; }
public decimal? CurrentPrice { get; set; } = 0;
public DateTime? ChangeDate { get; set; }
public DateTime? ChangeDate { get; set; } = new DateTime(2000,01,01);
public string? BranchId { get; set; }

6
Shared/Models/TblProduct.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Biskilog_Cloud.Shared.Models;
@ -15,12 +16,11 @@ public partial class TblProduct
public string? Cid { get; set; }
public decimal? Price { get; set; }
public decimal? Price { get; set; } = 0;
public decimal? Costprice { get; set; }
public decimal? Costprice { get; set; } = 0;
public string? BaseUnit { get; set; }
public string? ProductName { get; set; }
public string? BranchId { get; set; }

24
Shared/Models/TblUser.cs

@ -7,29 +7,29 @@ public partial class TblUser
{
public string Username { get; set; } = null!;
public string? Password { get; set; }
public string? Password { get; set; } = string.Empty;
public string? Firstname { get; set; }
public string? Firstname { get; set; } = string.Empty;
public string? Surname { get; set; }
public string? Surname { get; set; } = string.Empty;
public string? StreetAddress1 { get; set; }
public string? StreetAddress1 { get; set; } = string.Empty;
public string? StreetAddress2 { get; set; }
public string? StreetAddress2 { get; set; } = string.Empty;
public string? City { get; set; }
public string? City { get; set; } = string.Empty;
public string? StateOrProvince { get; set; }
public string? StateOrProvince { get; set; } = string.Empty;
public string? Telephone { get; set; }
public string? Telephone { get; set; } = string.Empty;
public string? Email { get; set; }
public string? Email { get; set; } = string.Empty;
public string? AccessLevel { get; set; }
public string? AccessLevel { get; set; } = string.Empty;
public DateTime? LastLogin { get; set; }
public DateTime? LastLogin { get; set; } = new DateTime(2000, 01, 01);
public string? BranchId { get; set; }
public string? BranchId { get; set; } = string.Empty;
public DateTime LastModified { get; set; }
}

21
Shared/POSModels/Creditpurchase.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Creditpurchase
{
public string ReceiptId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public DateTime Date { get; set; }
public decimal TotalBill { get; set; }
public decimal Paid { get; set; }
public string CustomerId { get; set; } = null!;
public string Status { get; set; } = null!;
}

25
Shared/POSModels/Customeraccount.cs

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Customeraccount
{
public string CustomerId { get; set; } = null!;
public string TransactionId { get; set; } = null!;
public DateTime Date { get; set; }
public decimal Debit { get; set; }
public decimal Credit { get; set; }
public decimal Balance { get; set; }
public string Comments { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

21
Shared/POSModels/Productaltunit.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Productaltunit
{
public string? Pcode { get; set; }
public string? UnitCode { get; set; }
public string? UnitBarcode { get; set; }
public decimal? PriceUnit { get; set; }
public int? QuantityUnit { get; set; }
public string DistinctiveCode { get; set; } = null!;
public string BranchId { get; set; } = null!;
}

15
Shared/POSModels/Restocklevel.cs

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Restocklevel
{
public string ProductId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public int? WarnLevel { get; set; }
public string? Unit { get; set; }
}

19
Shared/POSModels/Systemuserrole.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Systemuserrole
{
public string? Roles { get; set; }
public sbyte? Owner { get; set; }
public sbyte? Manager { get; set; }
public sbyte? Assist { get; set; }
public sbyte? Cashier { get; set; }
public int Id { get; set; }
}

19
Shared/POSModels/Tblbranch.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblbranch
{
public string? BranchName { get; set; }
public string BranchId { get; set; } = null!;
public string? Address { get; set; }
public string? City { get; set; }
public string? StateOrProvince { get; set; }
public string? BranchTelephone { get; set; }
}

13
Shared/POSModels/Tblbrand.cs

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblbrand
{
public string Id { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Brand { get; set; }
}

17
Shared/POSModels/Tblcancelledtransaction.cs

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblcancelledtransaction
{
public string? Transno { get; set; }
public DateTime? DateCancelled { get; set; }
public string? CancelledBy { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

35
Shared/POSModels/Tblcart.cs

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblcart
{
public string? Transno { get; set; }
public string? Id { get; set; }
public int? Quantity { get; set; }
public DateTime? Date { get; set; }
public decimal? Price { get; set; }
public string? Cashier { get; set; }
public string? Status { get; set; }
public decimal? Total { get; set; }
public string? Unit { get; set; }
public decimal? Tendered { get; set; }
public decimal? Balance { get; set; }
public decimal? ValueAddTax { get; set; }
public decimal? Discount { get; set; } = 0;
public decimal? Costprice { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

13
Shared/POSModels/Tblcategory.cs

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblcategory
{
public string Id { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Category { get; set; }
}

21
Shared/POSModels/Tblcompanydetail.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblcompanydetail
{
public string? CompanyName { get; set; }
public string? Address { get; set; }
public string? Website { get; set; }
public string? Email { get; set; }
public string Tin { get; set; } = null!;
public string? MainTelephone { get; set; }
public string? Vatno { get; set; }
}

35
Shared/POSModels/Tblcustomer.cs

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblcustomer
{
public string CustomerId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Firstname { get; set; }
public string? Surname { get; set; }
public string? Address { get; set; }
public string? Telephone { get; set; }
public DateTime? DateAdded { get; set; }
public string? Status { get; set; }
public string? Tin { get; set; }
public DateTime? DateExit { get; set; }
public string? Email { get; set; }
public string? FinancialStatus { get; set; }
public string? NameKey1 { get; set; }
public string? NameKey2 { get; set; }
}

15
Shared/POSModels/Tblcustomerpurchase.cs

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblcustomerpurchase
{
public string? CustomerId { get; set; }
public string? TransactionId { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

21
Shared/POSModels/Tbldeliverydetail.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbldeliverydetail
{
public string? DeliveryId { get; set; }
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public string? Unit { get; set; }
public decimal? Cost { get; set; }
public string CountId { get; set; } = null!;
public string BranchId { get; set; } = null!;
}

25
Shared/POSModels/Tbldeliveryhead.cs

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbldeliveryhead
{
public string DeliveryId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? GeneratedBy { get; set; }
public DateTime? DateInitiated { get; set; }
public DateTime? DateCompleted { get; set; }
public string? Destination { get; set; }
public string? CustomerId { get; set; }
public decimal? TotalCost { get; set; }
public string? Status { get; set; }
}

25
Shared/POSModels/Tbldeliveryrecipient.cs

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbldeliveryrecipient
{
public string DeliveryId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Fullname { get; set; }
public string? Address { get; set; }
public string? Telephone { get; set; }
public string? Email { get; set; }
public string? CustomerId { get; set; }
public DateOnly? FromDate { get; set; }
public DateOnly? ToDate { get; set; }
}

19
Shared/POSModels/Tbldiscountlog.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbldiscountlog
{
public string? ReceiptId { get; set; }
public string? Cashier { get; set; }
public DateTime? Date { get; set; }
public decimal? Discount { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

33
Shared/POSModels/Tbldriver.cs

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbldriver
{
public string DriverId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Firstname { get; set; }
public string? Surname { get; set; }
public string? Middlename { get; set; }
public DateOnly? DateOfBirth { get; set; }
public string? Address1 { get; set; }
public string? Address2 { get; set; }
public string? Telephone { get; set; }
public string? Email { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Status { get; set; }
}

15
Shared/POSModels/Tblinventory.cs

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblinventory
{
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

17
Shared/POSModels/Tblinventoryentry.cs

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblinventoryentry
{
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public DateTime? Date { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

29
Shared/POSModels/Tblinvoice.cs

@ -1,29 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblinvoice
{
public string? InvoiceId { get; set; }
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public decimal? Unitprice { get; set; }
public string? Unit { get; set; }
public decimal? Totalprice { get; set; }
public DateOnly? DateGenerated { get; set; }
public string? Status { get; set; }
public string? GeneratedBy { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

19
Shared/POSModels/Tblpricechange.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblpricechange
{
public string? Pcode { get; set; }
public decimal? PreviousPrice { get; set; }
public decimal? CurrentPrice { get; set; }
public DateTime? ChangeDate { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

31
Shared/POSModels/Tblproduct.cs

@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tblproduct
{
public string? Pcode { get; set; }
public string? Barcode { get; set; }
public string? Pdesc { get; set; }
public string? Bid { get; set; }
public string? Cid { get; set; }
public decimal? Price { get; set; }
public decimal? Costprice { get; set; }
public string? BaseUnit { get; set; }
public string? ProductName { get; set; }
public string? Status { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

19
Shared/POSModels/Tbltruck.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbltruck
{
public string TruckId { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? LicensePlate { get; set; }
public string? Brand { get; set; }
public string? Driver { get; set; }
public decimal? Weight { get; set; }
}

19
Shared/POSModels/TbltruckDrivermapping.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class TbltruckDrivermapping
{
public string? TruckId { get; set; }
public string? DriverId { get; set; }
public DateTime? DateEntry { get; set; }
public string? Operation { get; set; }
public string CountId { get; set; } = null!;
public string BranchId { get; set; } = null!;
}

21
Shared/POSModels/Tbltruckassignment.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbltruckassignment
{
public string? OrderId { get; set; }
public decimal? Cost { get; set; }
public string? TruckId { get; set; }
public string? Status { get; set; }
public DateTime? DateAssigned { get; set; }
public string CountId { get; set; } = null!;
public string BranchId { get; set; } = null!;
}

19
Shared/POSModels/Tbltruckinventory.cs

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbltruckinventory
{
public string? TruckId { get; set; }
public string? Pcode { get; set; }
public int? Quantity { get; set; }
public string? Unit { get; set; }
public string CountId { get; set; } = null!;
public string BranchId { get; set; } = null!;
}

33
Shared/POSModels/Tbluser.cs

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbluser
{
public string Username { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Password { get; set; }
public string? Firstname { get; set; }
public string? Surname { get; set; }
public string? StreetAddress1 { get; set; }
public string? StreetAddress2 { get; set; }
public string? City { get; set; }
public string? StateOrProvince { get; set; }
public string? Telephone { get; set; }
public string? Email { get; set; }
public string? AccessLevel { get; set; }
public DateTime? LastLogin { get; set; }
}

21
Shared/POSModels/Tbstock.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Tbstock
{
public string? Refno { get; set; }
public string? Pcode { get; set; }
public int? Qty { get; set; }
public DateOnly? Sdate { get; set; }
public string? Stockinby { get; set; }
public string BranchId { get; set; } = null!;
public string CountId { get; set; } = null!;
}

17
Shared/POSModels/Unitofmeasure.cs

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
namespace Biskilog_Cloud.Shared.POSModels;
public partial class Unitofmeasure
{
public string UnitCode { get; set; } = null!;
public string BranchId { get; set; } = null!;
public string? Unitname { get; set; }
public string? Unitshort { get; set; }
public string? Status { get; set; }
}

3
Shared/SharedClass.cs

@ -1 +1,4 @@
/* Shared classes can be referenced by both the Client and Server */
public class Shared
{
}
Loading…
Cancel
Save