Beispiel #1
0
        int AddToDataGridTable(RemoteHosts h)
        {
            // colRemoteName, colIPAddress,colDescription, colStatus


            // do we have a host name?
            string hostName;

            if (h.hostName == null)
            {
                hostName = " ";
            }
            else
            {
                hostName = h.hostName;
            }

            // do we have an IP address?
            string ipaddress;

            if (h.hostIPstr != null)
            {
                ipaddress = h.hostIPstr;
            }
            else
            {
                ipaddress = " ";
            }

            string description;

            if (h.hostDescription == null)
            {
                description = " ";
            }
            else
            {
                description = h.hostDescription;
            }

            string status = "starting validation...";

            //
            // n is the new index. The cells must also be accessed by an index.
            // In this example, there are four cells in each row.
            //
            int n = dataGridViewRemoteHostList.Rows.Add();

            dataGridViewRemoteHostList.Rows[n].Cells[0].Value = hostName;
            dataGridViewRemoteHostList.Rows[n].Cells[1].Value = ipaddress;


            dataGridViewRemoteHostList.Rows[n].Cells[2].Value = description;

            dataGridViewRemoteHostList.Rows[n].Cells[3].Style.WrapMode = DataGridViewTriState.True;

            dataGridViewRemoteHostList.Rows[n].Cells[3].Value = status;

            return(n);
        }
Beispiel #2
0
        private void dataGridViewRemoteHostList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (((RemoteHosts)m_AppData.CurrentlyLoggedInRemoteServer).LoggedIn)
            {
                return;                                                                  // don't select a new server until the user logs out of the current one
            }
            RemoteHosts host = (RemoteHosts)m_HostsLookup[e.RowIndex];

            if (host == null)
            {
                return;
            }

            if (host.hostName != null)
            {
                // its a verified host, select it

                m_AppData.CurrentlyLoggedInRemoteServer = (RemoteHosts)host;

                textBoxSelectedSystem.ForeColor = Color.Black;
                textBoxSelectedSystem.Text      = host.HostNameStatus;

                SetLoginButtonStatus(host);
            }
        }
Beispiel #3
0
        bool ValidateHostInfo(RemoteHosts h)
        {
            try
            {
                // 1. is the supplied IR address a valid IP address or is it a host name?
                System.Net.IPAddress remoteIPAddress = null;
                if (!System.Net.IPAddress.TryParse(h.hostIPstr, out remoteIPAddress))
                {
                    // if it was not a valid ip address, perhaps it was a host name instead
                    System.Net.IPHostEntry GetIPHost = System.Net.Dns.GetHostEntry(h.hostIPstr);
                    h.hostIP = GetIPHost.AddressList[0];
                }
                else
                {
                    h.hostIP = System.Net.IPAddress.Parse(h.hostIPstr);
                }

                // 2. is the supplied host IP reachable via ping?

                h.MessageEventGenerators.OnStatusChange          += OnHostsStatusChange;
                h.MessageEventGenerators.OnGetHostName           += OnHostsRxHostName;
                h.MessageEventGenerators.OnRxValidAdminPassword  += OnValidPassword;
                h.MessageEventGenerators.OnRxValidViewerPassword += OnValidPassword;
                h.StartValidation();

//                h.StartValidation(OnHostsStatusChange, OnHostsRxHostName);
            }
            catch (Exception ex)
            {
                m_Log.Log("ValidateHostInfo ex: " + ex.Message, ErrorLog.LOG_TYPE.INFORMATIONAL);
            }
            return(true);
        }
Beispiel #4
0
        void AddLocalDefaultHost()
        {
            ClearTable();

            m_Hosts       = new List <RemoteHosts>();
            m_HostsLookup = new Hashtable();


            RemoteHosts h = new RemoteHosts(m_AppData, false);

            h.hostIPstr = "127.0.0.1";

            h.hostDescription = "This Machine";

            h.MessageEventGenerators.OnRxInvalidPassword += OnInvalidPassword;

            h.MessageEventGenerators.OnStatusChange          += OnHostsStatusChange;
            h.MessageEventGenerators.OnGetHostName           += OnHostsRxHostName;
            h.MessageEventGenerators.OnRxValidAdminPassword  += OnValidPassword;
            h.MessageEventGenerators.OnRxValidViewerPassword += OnValidPassword;
            h.MessageEventGenerators.OnRxHealthStatus        += OnRxHealthStats;

            // this entry to the host display table
            h.datagridRowIndex = AddToDataGridTable(h);
            m_HostsLookup.Add(h.datagridRowIndex, h);

            // spin off a validation thread for this potential host
            ValidateHostInfo(h);
        }
Beispiel #5
0
        void SetLoginButtonStatus(RemoteHosts host)
        {
            textBoxSelectedSystem.ForeColor = Color.Black;
            textBoxSelectedSystem.Text      = host.HostNameStatus;

            if (host.LoggedIn)
            {
                // allow logout


                buttonLogout.Location = buttonLoginAsAdmin.Location;
                buttonLogout.Enabled  = true;
                buttonLogout.Visible  = true;

                buttonLoginAsAdmin.Visible = false;
                buttonLoginAsAdmin.Enabled = false;

                buttonLoginAsViewer.Visible = false;
                buttonLoginAsViewer.Enabled = false;
            }
            else
            {
                // allow login


                buttonLogout.Enabled = false;
                buttonLogout.Visible = false;

                buttonLoginAsAdmin.Visible = true;
                buttonLoginAsAdmin.Enabled = true;

                buttonLoginAsViewer.Visible = true;
                buttonLoginAsViewer.Enabled = true;
            }
        }
Beispiel #6
0
        void LoadHostsFromFile(string hostsFile)
        {
            ClearTable();

            m_Hosts       = new List <RemoteHosts>();
            m_HostsLookup = new Hashtable();

            try
            {
                string[] lines = File.ReadAllLines(hostsFile);
                for (int i = 0; i < lines.Count(); i++)
                {
                    // hostIP,  hostDecription
                    string[] bits = lines[i].Split(',');
                    if (bits.Length != 2)
                    {
                        m_Log.Log("found bad line (" + (i + 1).ToString() + ") in file :", ErrorLog.LOG_TYPE.INFORMATIONAL);
                        continue;
                    }
                    RemoteHosts h = new RemoteHosts(m_AppData, false);
                    h.hostIPstr = bits[0];

                    // load up handlers for receiving messages from the remote host

                    //   h.MessageEventGenerators. OnLoginResult += HandlePasswordTestResult;

                    string test = h.hostIPstr.ToLower();
                    if (test.Equals("localhost"))
                    {
                        h.hostIPstr = "127.0.0.1";
                    }

                    h.hostDescription = bits[1].Trim(' ');;

                    h.MessageEventGenerators.OnRxInvalidPassword += OnInvalidPassword;

                    h.MessageEventGenerators.OnStatusChange          += OnHostsStatusChange;
                    h.MessageEventGenerators.OnGetHostName           += OnHostsRxHostName;
                    h.MessageEventGenerators.OnRxValidAdminPassword  += OnValidPassword;
                    h.MessageEventGenerators.OnRxValidViewerPassword += OnValidPassword;
                    h.MessageEventGenerators.OnRxHealthStatus        += OnRxHealthStats;


                    // this entry to the host display table
                    h.datagridRowIndex = AddToDataGridTable(h);
                    m_HostsLookup.Add(h.datagridRowIndex, h);

                    // spin off a validation thread for this potential host
                    ValidateHostInfo(h);
                }
            }
            catch (Exception ex)
            {
                m_Log.Log(" LoadHostsFromFile ex: " + ex.Message, ErrorLog.LOG_TYPE.INFORMATIONAL);
            }
        }
Beispiel #7
0
        void OnHostsStatusChange(RemoteHosts host, RemoteHosts.HOST_STATUS status, string details)
        {
            if (details.Contains("actively refused"))
            {
                details = "LPR Service not running on server";
            }

            if (host.ValidationState == RemoteHosts.VALIDATION_STATE.COMPLETED)
            {
                return;                                                                // dont print the "not connected" status, for validation connections leave the "connected"
            }
            UpdateGridStatusCell(host.datagridRowIndex, details, host.StatusColorCode);
        }
Beispiel #8
0
        private void dataGridViewRemoteHostList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            RemoteHosts host = (RemoteHosts)m_HostsLookup[e.RowIndex];

            if (host.hostName != null)
            {
                // its a verified host, select it

                m_CurrentlySelectedRemoteSystem = host;

                textBoxSelectedSystem.ForeColor = Color.Black;
                textBoxSelectedSystem.Text      = host.HostNameStatus;

                SetLoginButtonStatus(host);
            }
        }
Beispiel #9
0
        // from the RemoteHost object
        void HandlePasswordTestResult(RemoteHosts host, RemoteHosts.LOGIN_TYPE ltype)
        {
            if (m_PWPrompt != null)
            {
                if (ltype == RemoteHosts.LOGIN_TYPE.ADMIN)
                {
                    m_PWPrompt.PasswordValidationResult(host.LoggedIn);
                }
                else
                {
                    m_PWPrompt.PasswordValidationResult(host.LoggedIn);
                }
            }

            if (host.LoggedIn)
            {
                Thread.Sleep(2000);
                m_PWPrompt.Close();
            }
        }
Beispiel #10
0
        int AddToDataGridTable(RemoteHosts h)
        {
            // colRemoteName, colIPAddress,colDescription, colStatus

            // do we have a host name?
            string hostName;
            if (h.hostName == null) hostName = " ";
            else hostName = h.hostName;

            // do we have an IP address?
            string ipaddress;
            if (h.hostIPstr != null) ipaddress = h.hostIPstr;
            else ipaddress = " ";

            string description;
            if (h.hostDescription == null) description = " ";
            else description = h.hostDescription;

            string status = "starting validation...";

            //
            // n is the new index. The cells must also be accessed by an index.
            // In this example, there are four cells in each row.
            //
            int n = dataGridViewRemoteHostList.Rows.Add();

            dataGridViewRemoteHostList.Rows[n].Cells[0].Value = hostName;
            dataGridViewRemoteHostList.Rows[n].Cells[1].Value = ipaddress;

            dataGridViewRemoteHostList.Rows[n].Cells[2].Value= description;

            dataGridViewRemoteHostList.Rows[n].Cells[3].Style.WrapMode = DataGridViewTriState.True;

            dataGridViewRemoteHostList.Rows[n].Cells[3].Value = status;

            return (n);
        }
Beispiel #11
0
 public MessageEventHandlersClass(RemoteHosts parent)
 {
     Parent = parent;
 }
Beispiel #12
0
 public MessageEventGeneratorsClass(RemoteHosts parent)
 {
     Parent = parent;
 }
Beispiel #13
0
 void OnCurrentServerLoggedOut(RemoteHosts host)
 {
     this.BeginInvoke((MethodInvoker) delegate { this.UnLoadHostFromLiveView(); });
 }
Beispiel #14
0
 void OnNewServerSelected(RemoteHosts host)
 {
     this.BeginInvoke((MethodInvoker) delegate { this.LoadSourceChannels(); });
 }
Beispiel #15
0
 public MessageEventHandlersClass(RemoteHosts parent)
 {
     Parent = parent;
 }
Beispiel #16
0
 public MessageEventGeneratorsClass(RemoteHosts parent)
 {
     Parent = parent;
 }
Beispiel #17
0
 void OnCurrentServerLoggedOut(RemoteHosts host)
 {
     this.BeginInvoke((MethodInvoker)delegate { this.UnLoadHostFromLiveView(); });
 }
Beispiel #18
0
        // from the RemoteHost object
        void HandlePasswordTestResult(RemoteHosts host, RemoteHosts.LOGIN_TYPE ltype)
        {
            if (m_PWPrompt != null)
            {
                if (ltype == RemoteHosts.LOGIN_TYPE.ADMIN)
                    m_PWPrompt.PasswordValidationResult(host.LoggedIn);
                else
                    m_PWPrompt.PasswordValidationResult(host.LoggedIn);
            }

            if (host.LoggedIn)
            {
                Thread.Sleep(2000);
                m_PWPrompt.Close();
            }
        }
Beispiel #19
0
        bool ValidateHostInfo(RemoteHosts h)
        {
            try
            {
                // 1. is the supplied IR address a valid IP address or is it a host name?
                System.Net.IPAddress remoteIPAddress = null;
                if (!System.Net.IPAddress.TryParse(h.hostIPstr, out remoteIPAddress))
                {
                    // if it was not a valid ip address, perhaps it was a host name instead
                    System.Net.IPHostEntry GetIPHost = System.Net.Dns.GetHostEntry(h.hostIPstr);
                    h.hostIP = GetIPHost.AddressList[0];
                }
                else
                {
                    h.hostIP = System.Net.IPAddress.Parse(h.hostIPstr);
                }

                // 2. is the supplied host IP reachable via ping?

                h.StartValidation();

            //                h.StartValidation(OnHostsStatusChange, OnHostsRxHostName);

            }
            catch(Exception ex)
            {
                m_Log.Log("ValidateHostInfo ex: " + ex.Message, ErrorLog.LOG_TYPE.INFORMATIONAL);
            }
            return (true);
        }
Beispiel #20
0
        void OnHostsStatusChange(RemoteHosts host, RemoteHosts.HOST_STATUS status, string details)
        {
            if (status == RemoteHosts.HOST_STATUS.LOGGEDOUT)
            {
                changeStateToLoggedOut();
                return;
            }

            if (details.Contains("actively refused")) details = "LPR Service not running on server";

            if (host.ValidationState == RemoteHosts.VALIDATION_STATE.COMPLETED) return;// dont print the "not connected" status, for validation connections leave the "connected"

            UpdateGridStatusCell(host.datagridRowIndex, details, host.StatusColorCode);
        }
Beispiel #21
0
        void LoadHostsFromFile(string hostsFile)
        {
            ClearTable();

            m_Hosts = new List<RemoteHosts>();
            m_HostsLookup = new Hashtable();

            try
            {
                string[] lines = File.ReadAllLines(hostsFile);
                for (int i =0; i < lines.Count(); i++)
                {
                    // hostIP,  hostDecription
                    string[] bits = lines[i].Split(',');
                    if (bits.Length != 2)
                    {
                        m_Log.Log("found bad line ("+ (i+1).ToString()+") in file :", ErrorLog.LOG_TYPE.INFORMATIONAL);
                        continue;
                    }
                    RemoteHosts h = new RemoteHosts(m_AppData, false);
                    h.hostIPstr = bits[0];

                    // load up handlers for receiving messages from the remote host

                 //   h.MessageEventGenerators. OnLoginResult += HandlePasswordTestResult;

                    string test = h.hostIPstr.ToLower();
                    if (test.Equals("localhost"))
                        h.hostIPstr = "127.0.0.1";

                    h.hostDescription = bits[1].Trim(' '); ;

                    h.MessageEventGenerators.OnRxInvalidPassword += OnInvalidPassword;

                    h.MessageEventGenerators.OnStatusChange += OnHostsStatusChange;
                    h.MessageEventGenerators.OnGetHostName += OnHostsRxHostName;
                    h.MessageEventGenerators.OnRxValidAdminPassword += OnValidPassword;
                    h.MessageEventGenerators.OnRxValidViewerPassword += OnValidPassword;
                    h.MessageEventGenerators.OnRxHealthStatus += OnRxHealthStats;

                    // this entry to the host display table
                    h.datagridRowIndex = AddToDataGridTable(h);
                    m_HostsLookup.Add(h.datagridRowIndex, h);

                    // spin off a validation thread for this potential host
                    ValidateHostInfo(h);
                }
            }
            catch(Exception ex)
            {
                m_Log.Log(" LoadHostsFromFile ex: " + ex.Message, ErrorLog.LOG_TYPE.INFORMATIONAL);
            }
        }
Beispiel #22
0
 void OnNewServerSelected(RemoteHosts host)
 {
     this.BeginInvoke((MethodInvoker)delegate { this.LoadSourceChannels(); });
 }
Beispiel #23
0
 void OnHostsRxHostName(RemoteHosts host, string name)
 {
     UpdateGridHostNameCell(host.datagridRowIndex, name);
 }
Beispiel #24
0
 void OnHostsRxHostName(RemoteHosts host, string name)
 {
     UpdateGridHostNameCell(host.datagridRowIndex, name);
 }
Beispiel #25
0
 void OnNewServerSelected(RemoteHosts host)
 {
     // LiveView has registered its own notfication on host logged in
 }
Beispiel #26
0
        void SetLoginButtonStatus(RemoteHosts host)
        {
            textBoxSelectedSystem.ForeColor = Color.Black;
            textBoxSelectedSystem.Text = host.HostNameStatus;

            if (host.LoggedIn)
            {
                // allow logout

                buttonLogout.Location = buttonLoginAsAdmin.Location;
                buttonLogout.Enabled = true;
                buttonLogout.Visible = true;

                buttonLoginAsAdmin.Visible = false;
                buttonLoginAsAdmin.Enabled = false;

                buttonLoginAsViewer.Visible = false;
                buttonLoginAsViewer.Enabled = false;
            }
            else
            {
                // allow login

                buttonLogout.Enabled = false;
                buttonLogout.Visible = false;

                buttonLoginAsAdmin.Visible = true;
                buttonLoginAsAdmin.Enabled = true;

                buttonLoginAsViewer.Visible = true;
                buttonLoginAsViewer.Enabled = true;

            }
        }
Beispiel #27
0
        private void dataGridViewRemoteHostList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            RemoteHosts host =(RemoteHosts) m_HostsLookup[e.RowIndex];

            if (host.hostName != null)
            {
                // its a verified host, select it

                m_CurrentlySelectedRemoteSystem = host;

                textBoxSelectedSystem.ForeColor = Color.Black;
                textBoxSelectedSystem.Text = host.HostNameStatus;

                SetLoginButtonStatus(host);
            }
        }
Beispiel #28
0
        void AddLocalDefaultHost()
        {
            ClearTable();

            m_Hosts = new List<RemoteHosts>();
            m_HostsLookup = new Hashtable();

            RemoteHosts h = new RemoteHosts(m_AppData, false);

            h.hostIPstr = "127.0.0.1";

            h.hostDescription = "This Machine";

            h.MessageEventGenerators.OnRxInvalidPassword += OnInvalidPassword;

            h.MessageEventGenerators.OnStatusChange += OnHostsStatusChange;
            h.MessageEventGenerators.OnGetHostName += OnHostsRxHostName;
            h.MessageEventGenerators.OnRxValidAdminPassword += OnValidPassword;
            h.MessageEventGenerators.OnRxValidViewerPassword += OnValidPassword;
            h.MessageEventGenerators.OnRxHealthStatus += OnRxHealthStats;

            // this entry to the host display table
            h.datagridRowIndex = AddToDataGridTable(h);
            m_HostsLookup.Add(h.datagridRowIndex, h);

            // spin off a validation thread for this potential host
            ValidateHostInfo(h);
        }
 void OnNewServerSelected(RemoteHosts host)
 {
     // LiveView has registered its own notfication on host logged in
 }