예제 #1
0
        /// <summary>
        /// This method drives/orchestrates the desired
        /// functionality based on the action specified
        /// from the command line.
        /// </summary>
        /// <param name="parameters"></param>
        private static void runAsConsoleApplication(TeslaMergeConfig config)
        {
            try
            {
                Console.WriteLine("Press any key to terminate...");

                MergeThread thread = new MergeThread(config);
                thread.RunOnce();

                // This will prevent the program
                // from terminating, while still
                // allowing this primary thread to
                // be responsive and display console
                // i/o generated from the trace
                bool done = false;
                do
                {
                    done = Console.KeyAvailable;
                    Thread.Sleep(200);
                } while (done == false);

                Console.WriteLine("Stopping background worker threads...");

                // Stop Threads
                thread.Stop();


                Console.WriteLine("Finished.");
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
예제 #2
0
        protected override void OnStart(string[] args)
        {
            _config = TeslaMergeConfig.GetConfig();

            _mainThread = new MergeThread(_config);

            _mainThread.Start();
        }
예제 #3
0
        static int Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                runAsService();
            }
            else
            {
                showHeader();

                TeslaMergeConfig config = TeslaMergeConfig.GetConfig();

                try
                {
                    if (args[0] == "-install")
                    {
                        installService();

                        return(SUCCESS);
                    }
                    else if (args[0] == "-uninstall")
                    {
                        uninstallService();

                        return(SUCCESS);
                    }
                    else if (args[0] == "-console")
                    {
                        runAsConsoleApplication(config);
                    }
                    else if (args.Length > 0)
                    {
                        showUsage();

                        return(SUCCESS);
                    }
                }
                catch
                {
                    Console.WriteLine("An unrecoverable problem was encountered - see event log for details.");

                    throw;
                }
            }

            return(SUCCESS);
        }
예제 #4
0
        public static TeslaMergeConfig GetConfig()
        {
            var configSection = (NameValueCollection)ConfigurationManager.GetSection("TeslaMergeWin");

            TeslaMergeConfig results = new TeslaMergeConfig();

            results.DashCamFolder          = getConfigValue(configSection, "DashCamFolder");
            results.ffmpegBinaryFolder     = getConfigValue(configSection, "ffmpegBinaryFolder");
            results.TriggerFile            = getConfigValue(configSection, "TriggerFile");
            results.CombinedFileArguments  = getConfigValue(configSection, "CombinedFileArguments");
            results.PreviewFileArguments   = getConfigValue(configSection, "PreviewFileArguments");
            results.TimelapseFileArguments = getConfigValue(configSection, "TimelapseFileArguments");
            results.DeleteOriginals        = bool.Parse(getConfigValue(configSection, "DeleteOriginals"));
            results.DateFormat             = getConfigValue(configSection, "DateFormat");
            results.PushOverApplication    = getConfigValue(configSection, "PushOverApplication", false);
            results.PushOverUser           = getConfigValue(configSection, "PushOverUser", false);

            return(results);
        }
예제 #5
0
 public MergeThread(TeslaMergeConfig config)
 {
     _config = config;
 }