コード例 #1
0
        protected override void OnStart(string[] args)
        {
            var history = new InternetHistory();

            history.Start("Starting.");

            _timer = new Timer {
                Interval = 1000
            };
            _timer.Elapsed += OnTimer;
            _timer.Start();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            var startComment = new StringBuilder();

            var startPrompt         = "Did you use the Internet before starting the Internet Monitor?";
            var startPromptResponse = GetUserInput(startPrompt + " (yes/no)");

            startComment.AppendLine(startPrompt + " " + startPromptResponse);
            startComment.AppendLine($"Comments: {GetUserInput("Please provide comments.")}");

            var history = new InternetHistory();

            history.Start(startComment.ToString());

            var timer = new Timer {
                Interval = 1000
            };

            timer.Elapsed += OnTimer;
            timer.Start();

            do
            {
                try
                {
                    Console.WriteLine("Type 'comment' or 'exit'.");
                    var input = Console.ReadLine();

                    if (string.IsNullOrEmpty(input))
                    {
                        continue;
                    }

                    if (input == "comment")
                    {
                        history.WriteEntry(GetUserInput("Enter comments."), string.Empty);
                        continue;
                    }
                    if (input != "exit")
                    {
                        continue;
                    }

                    history.Stop(GetUserInput("Please enter a reason."));
                    break;
                }
                catch (Exception e)
                {
                    log.Error(e, "Unknown Error.");
                }
            }while (true);
        }
コード例 #3
0
        protected override void OnShutdown()
        {
            var history = new InternetHistory();

            history.Stop("Shutting Down.");
        }
コード例 #4
0
        protected override void OnContinue()
        {
            var history = new InternetHistory();

            history.Start("Continuing.");
        }
コード例 #5
0
        protected override void OnPause()
        {
            var history = new InternetHistory();

            history.Stop("Pausing.");
        }
コード例 #6
0
        protected override void OnStop()
        {
            var history = new InternetHistory();

            history.Stop("Stopping.");
        }