Пример #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;
 }