Example #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            OpenALPRQueueMilestone servicesToRun = null;

            try
            {
                string VideoOS = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

                string dir = Path.Combine(VideoOS, @"VideoOS\MIPPlugins\OpenALPR");
                if (Directory.Exists(dir))
                {
                    Directory.SetCurrentDirectory(dir);
                }
                Console.WriteLine($"Current Directory: {Environment.CurrentDirectory}");

                Logger = new Logging("Service");
                if (Logger != null)
                {
                    Log = Logger.Log;

                    Console.WriteLine($"Log: {Logger.LogPath}");
                }

                servicesToRun = new OpenALPRQueueMilestone();

                if (Environment.UserInteractive)// Run Service as a Console Application.(for Debugging)
                {
                    Console.WriteLine("Press any key to stop program (debugging)");
                    servicesToRun.StartConsole(args);
                    Console.Read();
                    servicesToRun.StopConsole();
                }
                else                            // Run as a Service.
                {
                    ServiceBase.Run(servicesToRun);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (Logger != null)
                {
                    Logger.Log.Error(null, ex);
                }

                if (servicesToRun != null)
                {
                    servicesToRun.Stop();
                }
            }
        }
 public OpenALPRQueueMilestone()
 {
     InitializeComponent();
     serviceInstance = this;
 }