Browse Source

Resolved productaltunit and tblcancelledtransactions sync issues

dev
Benjamin Arhen 1 year ago
parent
commit
a2cd8cd7c7
  1. 5
      ServerManager/ServiceRepo/ProductsService.cs
  2. 4
      ServerManager/ServiceRepo/SalesService.cs
  3. 10
      ServerManager/SyncMethods/ProductSync.cs
  4. 8
      ServerManager/appsettings.json

5
ServerManager/ServiceRepo/ProductsService.cs

@ -184,12 +184,11 @@ namespace ServerManager.ServiceRepo
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "productaltunit",
a_branchId = a_branch,
branchID = a_branch,
lastModified = a_lastSync
};
List<ProductAltUnit> result = (await dbConnection.QueryAsync<ProductAltUnit>(
"FetchTableRows",
"FetchProductAltUnitTableRows",
parameters,
commandType: CommandType.StoredProcedure)).AsList();

4
ServerManager/ServiceRepo/SalesService.cs

@ -32,7 +32,7 @@ namespace ServerManager.ServiceRepo
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "tblcancelledtransaction",
a_tableName = "tblcancelledtransactions",
a_branchId = a_branch,
lastModified = a_lastSync
};
@ -231,7 +231,7 @@ namespace ServerManager.ServiceRepo
// Using Dapper to call a stored procedure with parameters
var parameters = new
{
a_tableName = "TblInvoices",
a_tableName = "TblInvoice",
a_branchId = a_branch,
lastModified = a_lastSync
};

10
ServerManager/SyncMethods/ProductSync.cs

@ -180,6 +180,8 @@ namespace ServerManager.SyncMethods
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}
private async Task SyncProductAltUnitAsync()
{
try
{
var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/productaltunit");
if (!responseMessage.IsSuccessStatusCode)
@ -188,7 +190,7 @@ namespace ServerManager.SyncMethods
}
DateTime date = await responseMessage.Content.ReadFromJsonAsync<DateTime>();
IEnumerable<RestockLevel> modifiedCart = await m_productService.FetchRestockAsync(date, "BRID0");
IEnumerable<ProductAltUnit> modifiedCart = await m_productService.FetchProductAltUnit(date, "BRID0");
SyncTimestamp syncTimestamp = new SyncTimestamp { TableName = "productaltunit", Timestamp = DateTime.Now.AddSeconds(-10) };
int batchSize = 200;
int totalItems = modifiedCart.Count();
@ -196,7 +198,7 @@ namespace ServerManager.SyncMethods
for (int batchIndex = 0; batchIndex < batches; batchIndex++)
{
List<RestockLevel> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
List<ProductAltUnit> batch = modifiedCart.Skip(batchIndex * batchSize).Take(batchSize).ToList();
var response = await m_httpClient.PostAsJsonAsync("/api/SyncProducts/publish/tblProductAltUnit", batch);
if (response.IsSuccessStatusCode)
@ -207,6 +209,10 @@ namespace ServerManager.SyncMethods
//Set last sync date
await m_httpClient.PostAsJsonAsync("/api/SyncProducts/setsyncdate", syncTimestamp);
}catch (Exception ex)
{
}
}
private async Task SyncStockAsync()
{var responseMessage = await m_httpClient.GetAsync("/api/SyncProducts/lastsyncdate/tbstock");

8
ServerManager/appsettings.json

@ -10,10 +10,6 @@
},
"APIKEY": "AI1@h1BBmaU4d9LqU4W6UKGh7kWFNB9V",
"BaseUrl": "https://localhost:7122/",
"AllowedHosts": "*",
"JWT": {
"Key": "@@BISKILOGACCOUNTING2023DEV??//##$",
"Issuer": "AUTH SERVER",
"Audience": "BISKILOG"
}
"AllowedHosts": "*"
}
Loading…
Cancel
Save