コード例 #1
0
ファイル: Program.cs プロジェクト: geexmmo/SmartConnect
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool startMinimized = false;
            for (int i = 0; i != args.Length; ++i)
            {
                if (args[i] == "/StartMinimized")
                {
                    startMinimized = true;
                }
            }

            Main fMain = new Main();
            if (startMinimized)
            {
                fMain.WindowState = FormWindowState.Minimized;
                fMain.ShowInTaskbar = false;
            }
            else
            {
                fMain.WindowState = FormWindowState.Normal;
                fMain.ShowInTaskbar = true;
            }
            Application.Run(fMain);
        }
コード例 #2
0
ファイル: WiFiConnect.cs プロジェクト: geexmmo/SmartConnect
        public WiFiConnect(Main frmMain)
        {
            this.frmMain = frmMain;
            dSSIDs = new ConcurrentDictionary<string, SSID>();
            dAPs = new ConcurrentDictionary<string, AP>();
            lLinks = new List<SCLink>();
            dConfig = new ConcurrentDictionary<String, String>();
            localSSIDs = new ConcurrentDictionary<string,SSID>();
            dNetData = new ConcurrentDictionary<String, int>();
            wClient = new WlanClient();
            
            Load("all");

            try { Config8021X(); }
            catch (Exception ex) { log.Error("Error on WifiConnect constructor Config8021X(): " + ex.Message); }

            try { SetWirelessConnection(); }
            catch (Exception ex) { log.Error("Error on WifiConnect constructor SetWirelessConnection(): " + ex.Message); }

            int updateInterval=0, updateTimeout=300;

            String tmpUpdateInterval,tmpUpdateTimeout,tmpServerIP,tmpFilenameTemplate;
            try
            {
                if (dConfig.TryGetValue("updateInterval", out tmpUpdateInterval)) updateInterval = Convert.ToInt32(tmpUpdateInterval);
                if (dConfig.TryGetValue("serverTimeout", out tmpUpdateTimeout)) updateTimeout = Convert.ToInt32(tmpUpdateTimeout);
            }
            catch (FormatException ex) { log.Error("Error updateInterval in config is not a number, actual message: " + ex.Message); }

            updaterNetStatus = new NetStatusUpdater(20, this);
            updateNetStatusThread = new Thread(updaterNetStatus.Run);
            updateNetStatusThread.Start();

            if (dConfig.TryGetValue("serverIP", out tmpServerIP))
            {
                if(dConfig.TryGetValue("filenameTemplate", out tmpFilenameTemplate))
                {
                    updaterServer = new ServerUpdater(updateInterval, updateTimeout, tmpServerIP, tmpFilenameTemplate, this);
                    updateServerThread = new Thread(updaterServer.Run);
                }
                else log.Debug("WifiConnect constructor: filenameTemplate config value does not exist, skipping server updater");

                senderErrors = new ErrorSender(updateTimeout, tmpServerIP, this);
                sendErrorThread = new Thread(senderErrors.Run);

                senderData = new DataSender(updateTimeout, updateInterval, tmpServerIP, this);
                sendDataThread = new Thread(senderData.Run);

                bool tmpAutoUpdate = false, tmpSendErrors = false, tmpSendNetworkData = false;
                dFlags.TryGetValue("autoUpdate", out tmpAutoUpdate);
                dFlags.TryGetValue("sendErrors", out tmpSendErrors);
                dFlags.TryGetValue("sendNetworkData", out tmpSendNetworkData);

                if (tmpAutoUpdate && updateTimeout != 0) updateServerThread.Start();
                if (tmpSendErrors) sendErrorThread.Start();
                if (tmpSendNetworkData) sendDataThread.Start();
            }
            else log.Debug("WifiConnect constructor: serverIP config value does not exist, skipping server updater and senders");

        }