Exemple #1
0
        static void Main(string[] args)
        {
            _log.Info("***********************  BLANKER Starting Up!  ***********************");

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //Uri = "http://localhost:51284/";
            Uri = "http://displaydynamic.azure-mobile.net/";

            _log.DebugFormat("Going to {0}", Uri);

            try
            {
                if (args[0] == "test")
                {
                    _log.Warn("TEST MODE");
                    WebAccess.TestPost().Wait();
                    return;
                }

                iface = args[0];
                _log.DebugFormat("Using iface {0}", iface);
                BeaconId = int.Parse(args[1]);
                _log.DebugFormat("Using BeaconId {0}", BeaconId);
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                _log.Info("\nUSAGE: blanker.exe <interface> <beaconid>");
                return;
            }

            Proc proc   = new Proc(FILENAME, string.Format(ARGS, iface, SEPARATOR));
            int  failed = 0;

            //while (failed < MAXFAIL)
            {
                if (!proc.Start())
                {
                    failed++;
                    _log.ErrorFormat("Failed attempt #{0}...", failed);
                    //continue;
                }
                while (proc.IsRunning)
                {
                    failed = 0;
                    System.Threading.Thread.Sleep(5000);
                }
            }
            //if (failed > MAXFAIL)
            //    _log.Error("Failed to start.  quitting.");
            //else
            _log.InfoFormat("Exiting at {0}.  Ran for {1}", DateTime.Now, DateTime.Now - _runningSince);
        }
Exemple #2
0
        private async void reader()
        {
            using (StreamReader reader = _process.StandardOutput)
            {
                string   strOut;
                string[] cols;
                DateTime time;
                int      minuteIndex;
                _log.InfoFormat("Reader is reading...");
                while (IsRunning)
                {
                    strOut = reader.ReadLine();
                    if (!string.IsNullOrWhiteSpace(strOut))
                    {
                        //Console.WriteLine(strOut);
                        cols = strOut.Split(Program.SEPARATOR);
                        if (tryParseUTC(cols[0], out time))
                        {
                            if (!string.IsNullOrWhiteSpace(cols[1]))
                            {
                                cols[1]     = cols[1].Trim().ToLower();
                                minuteIndex = (int)(DateTime.Now - DateTime.Today).TotalMinutes;
                                if (!_ignoreList.Contains(cols[1]))
                                {
                                    if (!_macsPerMinute.ContainsKey(minuteIndex))
                                    {
                                        _macsPerMinute.Add(minuteIndex, new List <string>()
                                        {
                                            cols[1]
                                        });
                                        _log.DebugFormat("First MAC for Minute {0}: {1} ",
                                                         minuteIndex.ToString(), cols[1]);
                                        if (_lastminute > -1)
                                        {
                                            var uploadResult = await WebAccess.ProcessImprintsAsync(
                                                _lastminute, _macsPerMinute[_lastminute]);

                                            //if (uploadResult) //when the internet goes down?
                                            {
                                                _macsPerMinute.Remove(_lastminute);
                                            }
                                        }
                                        _lastminute = minuteIndex;
                                    }
                                    else
                                    {
                                        if (!_macsPerMinute[minuteIndex].Contains(cols[1]))
                                        {
                                            _macsPerMinute[minuteIndex].Add(cols[1]);
                                            _log.DebugFormat("New MAC for Minute {0}: {1}   count is now {2}",
                                                             minuteIndex.ToString(), cols[1], _macsPerMinute[minuteIndex].Count.ToString());
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            //no datetime component?
                            _log.WarnFormat("Bad Input Stream: '{0}'", strOut);
                        }
                    }
                }
            }
            _log.InfoFormat("Reader is quitting.");
        }