public static string DiscoverPentairServer(bool IsDelayCheck)
        {
            _IsDelayCheck = IsDelayCheck;

            serverStatus = "NOTAVAILABLE";
            string addressInfo = string.Empty;

            //serverStatus = CheckForExistanceofIPAddress();
            if (_IsIpAddressFound)
            {
                return("AVAILABLE");
            }

            //if (vm == null)
            //{
            //    vm = new ViewModel.TestFixtureViewModel();
            //    vm.openFile = true;
            //}

            try
            {
                var nics = NetworkInterface.GetAllNetworkInterfaces();
                foreach (var nic in nics)
                {
                    if (serverStatus.Equals(connected))
                    {
                        break;
                    }
                    if (serverStatus.Equals(interrupted))
                    {
                        break;
                    }
                    if (serverStatus.Equals(serverUnavailable))
                    {
                        break;
                    }

                    //  _mServerIPAddress = null;
                    var ippropoerties = nic.GetIPProperties();
                    //we are only interested in IPv4 address
                    var ipv4add = ippropoerties.UnicastAddresses.Where(addr => addr.Address.AddressFamily == AddressFamily.InterNetwork);
                    foreach (var addr in ipv4add)
                    {
                        var network = CalculateNetwork(addr);
                        Console.WriteLine("Addr: {0}   Mask: {1}  Network: {2}", addr.Address, addr.IPv4Mask, network);

                        string retrivedip = addr.Address.ToString();

                        //Saved ip address
                        addressInfo = retrivedip;

                        string local_host = Dns.GetHostName(); // returns local hostname

                        IPHostEntry host_entry = Dns.GetHostEntry(Dns.GetHostName());

                        foreach (var ip in host_entry.AddressList)
                        {
                            int delay = 1;
                            LogStructureNew.DeviceDiscover = "FAIL";

                            if (_IsDelayCheck)
                            {
                                bool flag = vm.CheckTriggerDelayOnce(delay);
                                if (!flag)
                                {
                                    serverStatus = interrupted;
                                    return(serverStatus);
                                }
                            }

                            if (frmTestFixture.Instance.backgroundWorker1.CancellationPending)
                            {
                                serverStatus = "Cancelled SendCommandToServerToProcess operation";
                                frmTestFixture.Instance.WriteToLog(serverStatus, ApplicationConstants.TraceLogType.Information);
                                return("Cancelled SendCommandToServerToProcess operation");
                            }

                            TryToConnect(ip, ref retrivedip);
                            if (serverStatus.Equals(connected))
                            {
                                break;
                            }
                        }

                        //Saved ip address
                        addressInfo = retrivedip;
                    }
                }

                string serverStatusMessage = String.Format("IP Address '{0}': {1} ", _RetrivedIpAddress, serverStatus);

                if (frmTestFixture.Instance != null)
                {
                    frmTestFixture.Instance.SetIpAddressLabel(serverStatusMessage);
                }

                if (frmTestFixture.Instance != null)
                {
                    if (serverStatus.Equals(connected))
                    {
                        frmTestFixture.Instance.SetIpAddressTextBox(addressInfo);
                    }
                }
            }
            catch (Exception e)
            {
                _mexceptionMessage = e.Message.ToString();
            }

            return(serverStatus);
        }
        public static string DiscoverPentairServer()
        {
            vm          = new ViewModel.TestFixtureViewModel();
            vm.openFile = true;

            serverStatus = "NOTAVAILABLE";
            try
            {
                var nics = NetworkInterface.GetAllNetworkInterfaces();
                foreach (var nic in nics)
                {
                    if (serverStatus.Equals(connected))
                    {
                        break;
                    }
                    if (serverStatus.Equals(interrupted))
                    {
                        break;
                    }
                    if (serverStatus.Equals(serverUnavailable))
                    {
                        break;
                    }
                    //  _mServerIPAddress = null;
                    var ippropoerties = nic.GetIPProperties();
                    //we are only interested in IPv4 address
                    var ipv4add = ippropoerties.UnicastAddresses.Where(addr => addr.Address.AddressFamily == AddressFamily.InterNetwork);
                    foreach (var addr in ipv4add)
                    {
                        var network = CalculateNetwork(addr);
                        Console.WriteLine("Addr: {0}   Mask: {1}  Network: {2}", addr.Address, addr.IPv4Mask, network);

                        string retrivedip = addr.Address.ToString();

                        string local_host = Dns.GetHostName(); // returns local hostname

                        IPHostEntry host_entry = Dns.GetHostEntry(Dns.GetHostName());

                        foreach (var ip in host_entry.AddressList)
                        {
                            int delay = 1;
                            LogStructureNew.DeviceDiscover = "FAIL";

                            if (_IsDelayCheck)
                            {
                                bool flag = vm.CheckTriggerDelayOnce(delay);
                                if (!flag)
                                {
                                    serverStatus = interrupted;
                                    return(serverStatus);
                                }
                            }

                            TryToConnect(ip, ref retrivedip);
                            if (serverStatus.Equals(connected))
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _mexceptionMessage = e.Message.ToString();
            }

            return(serverStatus);
        }