Ejemplo n.º 1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            const string MemberName = "Main";

            using (new Tracer(MemberName))
            {
                try
                {
                    if (args.Length > 0)
                    {
                        if (String.Compare(args[0], "-regadapters", true) == 0 ||
                            String.Compare(args[0], "/regadapters", true) == 0)
                        {
                            ConMonInstaller installer = new ConMonInstaller();
                            installer.UpdateAppConfigFile();
                        }
                    }
                    else
                    {
                        ServiceBase[] ServicesToRun;

                        // More than one user Service may run within the same process. To add
                        // another service to this process, change the following line to
                        // create a second service object. For example,
                        //
                        //   ServicesToRun = new ServiceBase[] {new Service1(), new MySecondUserService()};
                        //
                        ServicesToRun = new ServiceBase[] { new ConMonService() };

                        ServiceBase.Run(ServicesToRun);
                    }
                }
                catch (ConnectionMonitorException cme)
                {
                    throw cme;
                }
                catch (Exception ex)
                {
                    ConnectionMonitorException cme = new ConnectionMonitorException(
                        "Exception caught in " + MemberName, ex);
                    Logger.Write(ex);
                    throw ex;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds an internal list of NICs and if passed true for forceUpdate, will update the wireless NIC entry in the configuration file.
        /// </summary>
        /// <param name="forceUpdate">Boolean if true, forces the application to update the configuration with the name of the wireless NIC installed on the computer.</param>
        private void PopulateWirelessNicsAndController(bool forceUpdate)
        {
            const string MemberName = "PopulateWirelessNicsAndController";

            using (new Tracer(MemberName))
            {
                try
                {
                    if ((forceUpdate == true))
                    {
                        // No wireless adapters were found during installation.
                        // Perhaps it was disabled in the BIOS upon install.
                        // Let's try again...
                        ConMonInstaller installer = new ConMonInstaller();
                        installer.UpdateAppConfigFile();
                    }
                    string            vpnExceptionList = GetVPNExceptionList();
                    MonitoredDevice[] monitoredDevices = ReadMonitoredDevicesFromConfig();
                    nicController = new NetworkInterfaceController(eventLog, vpnExceptionList, monitoredDevices);

                    // Build list of NIC Names and publish NICsFound event to WCF service
                    List <string> nics = new List <string>();
                    foreach (MonitoredDevice device in monitoredDevices)
                    {
                        nics.Add(device.Name);
                    }
                    if (nics != null && nics.Count > 0)
                    {
                        this.ConMonServiceEventsWCFServiceClient.NICsFound(nics.ToArray());
                    }
                }
                catch (ConnectionMonitorException cme)
                {
                    Logger.Write(cme);
                    throw cme;
                }
                catch (Exception ex)
                {
                    Logger.Write(ex);
                    throw ex;
                }
            }
        }