using EEMSClientCore; using ServiceBase; using System.Windows; namespace EEMSUIClient.Services { public class ClientService : IClientService, IClientBaseProvider { private readonly IClientCaller _clientCaller; private readonly ClientCaller _hubBase; private bool disposedValue; public ClientService() { _hubBase = new ClientCaller(this); _clientCaller = _hubBase; } public string? RecipePath { get; set; } public string? ConfigPath { get; set; } public bool Initialize(string ip, int port, string hub) { if (string.IsNullOrWhiteSpace(ip) || port < 0 || string.IsNullOrWhiteSpace(hub)) { //log return false; } if (!_hubBase.Initialize()) { //log return false; } if (!_hubBase.Open(ip, port, hub)) { //log return false; } return true; } public Guid RegisterDevice(Models.DeviceInfo deviceInfo) { return _clientCaller.RegisterDevice(deviceInfo.Convert()).Result; } public bool UpdateRealTimeData(Dictionary realtimeData) { return _clientCaller.UpdateRealTimeData(realtimeData).Result; } public void FileReceivedNotify(FileType fileType) { MessageBox.Show($"{fileType} Received"); } public void StartFileReceiveNotify(FileType fileType) { //Log Here //MessageBox.Show($"Start Receiving {fileType} File"); } public bool AllowReceiveFile() { return true; } public void FileReceivedNotify(FileType fileType, string path) { //Log Here } protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects) _hubBase?.Dispose(); } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null disposedValue = true; } } // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources // ~ClientService() // { // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // Dispose(disposing: false); // } public void Dispose() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method Dispose(disposing: true); GC.SuppressFinalize(this); } } }