public static UdpConnectionService BuildService(SystemEntity entity) { var service = new UdpConnectionService(); service.IpAddress = entity.ServerURL; service.Port = int.Parse(entity.ServerPort); return(service); }
public UdpLoggingScreen() { InitializeComponent(); udpService = new UdpConnectionService(false, userName); udpService.NewMessageLineOn += AddNewMessageLine; buttonSend.IsEnabled = false; Closing += this.OnWindowClosing; LocalIpBox.Text = udpService.GetLocalIPAddress(); buttonDisconnect.IsEnabled = false; }
public static void UpdateDeviceData(ref SystemEntity entity, UdpConnectionService service) { if (!string.IsNullOrWhiteSpace(service.IpAddress)) { entity.ServerURL = service.IpAddress; } if (service.Port != 0) { entity.ServerPort = service.Port.ToString(); } }
private void Subscribe(RemoteLoggingService loggingService, UdpConnectionService udpService, MailSender smtpService) { if (UdpLogging) { loggingService.NewMessageOn += udpService.SendMessage; } if (EmailLogging) { loggingService.NewMessageOn += smtpService.SendMessage; } loggingService.Start(); }
public MainWindow() { InitializeComponent(); SetUserCard(); SetPreviousInteractions(); SetPCInfo(); try { EmailLogging = config.EmailLoggingOn; UdpLogging = config.UdpLoggingOn; RemoteLoggingService loggingService = new RemoteLoggingService(config); UdpConnectionService udpService = new UdpConnectionService(true, UserPrincipal.Current.DisplayName); int port = config.Port; string host = config.SmtpHost; MailSender smtpService = new MailSender(port, host, config); try { udpService.Connect(); } catch { MessageBox.Show("Something went wrong while setting UDP connection"); UdpLogging = false; } this.Subscribe(loggingService, udpService, smtpService); } catch (MailLoggingException e) { MessageBox.Show(e.Message); } catch (Exception e) { MessageBox.Show("Something went wrong"); } }