SyncService + SyncPage added
This commit is contained in:
@@ -1,22 +1,59 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.DataLayer;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Services
|
||||
{
|
||||
public class SyncService: ISyncService
|
||||
public class SyncService : BaseService, ISyncService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly AppDbContext _dbContext;
|
||||
|
||||
public SyncService(HttpClient httpClient, AppDbContext dbContext)
|
||||
public SyncService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext) : base(httpClient, configuration, dbContext)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_dbContext = dbContext;
|
||||
|
||||
}
|
||||
|
||||
public async Task SyncDatas()
|
||||
{
|
||||
await SyncCheckPoints();
|
||||
}
|
||||
public async Task SyncCheckPoints()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Az API végpont meghatározása
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllCheckPoints";
|
||||
|
||||
// HTTP GET kérés küldése
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckPointListDTO>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
var checkPointList = await _dbContext.CheckPoints.ToListAsync();
|
||||
var missingItems = response.Data.CheckPointList.Where(f => !checkPointList.Any(s => s.Id == f.Id)).ToList();
|
||||
|
||||
foreach (var item in missingItems) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user