Ejemplo n.º 1
0
        private void ConnectionButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (userNameTextBox.Text == "" || userNameTextBox.Text == null)
                {
                    userNameTextBox.Text = userName;
                }
                userName = userNameTextBox.Text;
                udpService.Connect();
                udpService.IsConnectionAlive = true;
                Thread ListenStart = new Thread(new ThreadStart(udpService.Listen));
                ListenStart.Start();

                buttonConnect.IsEnabled    = false;
                userNameTextBox.IsReadOnly = true;
                buttonSend.IsEnabled       = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while setting connection");
            }
        }
Ejemplo n.º 2
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");
            }
        }