Example #1
0
		private async void CheckLogDirectory()
		{
			if (logDirectory == null | logDirectory == "")
			{
				MessageBox.Show("Error: No log directory is specified, please do so before attempting to go on duty.");
				return;
			}

			if (!Directory.Exists(Settings.Default.NetLogPath))
			{
				MessageBox.Show("Error: Couldn't find E:D Netlog directory: " + Settings.Default.NetLogPath +
								". Please ensure that it is correct in Settings.");
				return;
			}

			StatusDisplay.Text = "Beginning to watch " + logDirectory + " for changes...";
			if (watcher == null)
			{
				watcher = new FileSystemWatcher();
				watcher.Path = logDirectory;
				watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName |
										NotifyFilters.DirectoryName | NotifyFilters.Size;
				watcher.Filter = "*.log";
				watcher.Changed += OnChanged;
				watcher.Created += OnChanged;
				watcher.Deleted += OnChanged;
				watcher.Renamed += OnRenamed;
				watcher.EnableRaisingEvents = true;
			}

			DirectoryInfo tempDir = new DirectoryInfo(logDirectory);
			logFile = (from f in tempDir.GetFiles("*.log") orderby f.LastWriteTime descending select f).First();
			AppendStatus("Started watching file " + logFile.FullName);
			CheckClientConn(logFile.FullName);
			List<KeyValuePair<string, string>> logindata = new List<KeyValuePair<string, string>>();
			logindata.Add(new KeyValuePair<string, string>("email", "*****@*****.**"));
			logindata.Add(new KeyValuePair<string, string>("password", "password"));
			apworker = new APIWorker();
			AppendStatus("Call to APIworker returning :" + apworker.connectAPI());
			object col = await apworker.sendAPI("login", logindata);
			AppendStatus("Login returned: " + col);
			apworker.InitWs();
			apworker.OpenWs();
			ReadLogfile(logFile.FullName);
			apworker.ws.MessageReceived += websocketClient_MessageReceieved;
			myTravelLog = new List<TravelLog>();
		}
Example #2
0
        private async void  checkLogDirectory()
        {
            Object col;
            if(logDirectory==null | logDirectory == "")
            {
                MessageBox.Show("Error: No log directory is specified, please do so before attempting to go on duty.");
                return;
            }
            if (!Directory.Exists(Properties.Settings.Default.NetLogPath))
            {
                MessageBox.Show("Error: Couldn't find E:D Netlog directory: " + Properties.Settings.Default.NetLogPath + ". Please ensure that it is correct in Settings.");
                return;
            }
            textBox.Text = logDirectory;
            statusDisplay.Text = "Beginning to watch " + logDirectory + " for changes...";
            if (watcher==null)
            {
                watcher = new FileSystemWatcher();
                watcher.Path = logDirectory;
                watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Size;
                watcher.Filter = "*.log";
                watcher.Changed += new FileSystemEventHandler(onChanged);
                watcher.Created += new FileSystemEventHandler(onChanged);
                watcher.Deleted += new FileSystemEventHandler(onChanged);
                watcher.Renamed += new RenamedEventHandler(onRenamed);
                watcher.EnableRaisingEvents = true;

            }
            DirectoryInfo tempDir=new DirectoryInfo(logDirectory);
            logFile = (from f in tempDir.GetFiles("*.log") orderby f.LastWriteTime descending select f).First();
            appendStatus("Started watching file " + logFile.FullName);
            checkClientConn(logFile.FullName);
            var logindata = new List<KeyValuePair<string, string>>();
            logindata.Add(new KeyValuePair<string,string>("email", "*****@*****.**"));
            logindata.Add(new KeyValuePair<string,string>("password", "password"));
            apworker = new APIWorker();
            appendStatus("Call to APIworker returning :"+apworker.connectAPI().ToString());
            //NameValueCollection col = await apworker.queryAPI("login", new List<KeyValuePair<string, string>>());
            col = await apworker.sendAPI("login", logindata);
            if (col.ToString() == null)
                appendStatus("Login returned NULL");
            else
            {
                //appendStatus("From col I have :" + col.ToString());
                appendStatus("Login returned: " + col);
                
            }
            appendStatus("I'm after queryAPI:"+col.ToString());
            initWS();
            openWS();
            readLogfile(logFile.FullName);
        }