123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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<string, object> 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);
- }
- }
- }
|