barhen
1 year ago
73 changed files with 2196 additions and 2520 deletions
@ -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> |
@ -1,10 +0,0 @@ |
|||
using ClientManager; |
|||
|
|||
IHost host = Host.CreateDefaultBuilder(args) |
|||
.ConfigureServices(services => |
|||
{ |
|||
services.AddHostedService<Worker>(); |
|||
}) |
|||
.Build(); |
|||
|
|||
host.Run(); |
@ -1,11 +0,0 @@ |
|||
{ |
|||
"profiles": { |
|||
"ClientManager": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": true, |
|||
"environmentVariables": { |
|||
"DOTNET_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -1,8 +0,0 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
} |
|||
} |
@ -1,8 +0,0 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -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); |
|||
} |
@ -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(); |
|||
} |
|||
} |
|||
} |
@ -1,7 +0,0 @@ |
|||
namespace ServerManager.Interface |
|||
{ |
|||
public interface ISalesHub |
|||
{ |
|||
Task AddTransaction(); |
|||
} |
|||
} |
@ -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; |
|||
} |
|||
} |
|||
} |
|||
} |
@ -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(); |
|||
} |
|||
} |
|||
} |
@ -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(); |
|||
} |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
|||
} |
@ -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()); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
@ -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; } |
|||
} |
|||
} |
@ -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,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!; |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -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!; |
|||
} |
@ -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; } |
|||
} |
@ -1 +1,4 @@ |
|||
/* Shared classes can be referenced by both the Client and Server */ |
|||
public class Shared |
|||
{ |
|||
} |
Loading…
Reference in new issue