Ejemplo n.º 1
0
        public static UdpConnectionService BuildService(SystemEntity entity)
        {
            var service = new UdpConnectionService();

            service.IpAddress = entity.ServerURL;
            service.Port      = int.Parse(entity.ServerPort);
            return(service);
        }
Ejemplo n.º 2
0
 public UdpLoggingScreen()
 {
     InitializeComponent();
     udpService = new UdpConnectionService(false, userName);
     udpService.NewMessageLineOn += AddNewMessageLine;
     buttonSend.IsEnabled         = false;
     Closing                   += this.OnWindowClosing;
     LocalIpBox.Text            = udpService.GetLocalIPAddress();
     buttonDisconnect.IsEnabled = false;
 }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
 private void Subscribe(RemoteLoggingService loggingService, UdpConnectionService udpService, MailSender smtpService)
 {
     if (UdpLogging)
     {
         loggingService.NewMessageOn += udpService.SendMessage;
     }
     if (EmailLogging)
     {
         loggingService.NewMessageOn += smtpService.SendMessage;
     }
     loggingService.Start();
 }
Ejemplo n.º 5
0
        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");
            }
        }