示例#1
0
 static void printTimer_Tick(object sender, EventArgs e)
 {
     if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday || DateTime.Today.DayOfWeek == DayOfWeek.Sunday)
     {
         WriteMessage(String.Format("\n---Didn't print because of WEEKEND! {0}---", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString()));
     }
     else if (DateTime.Now.Hour < 7 || DateTime.Now.Hour > 15)
     {
         WriteMessage(String.Format("\n---Didn't print because of out of working hours! {0}---", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString()));
     }
     else
     {
         RawPrinterHelper.SendStringToPrinter(@"\\TRR-I-SERVER02\TRR-I-N023-101-1", String.Format("Jeg holder mig varm for DIN skyld <3\n{0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString()));
         WriteMessage(String.Format("\n---Printed at {0}---", DateTime.Now.ToShortTimeString()));
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            WriteMessage("Write \"Help\" for help");
            bool      exit       = false;
            TimerPlus printTimer = new TimerPlus(180);

            printTimer.Tick += printTimer_Tick;

            while (!exit)
            {
                string command = Console.ReadLine().ToLower();

                switch (command)
                {
                case "help":
                    WriteMessage("-----Help----", false);
                    WriteMessage("Help: This menu", false);
                    WriteMessage("Start: Start the printing timer", false);
                    WriteMessage("Stop: Stop the printing timer", false);
                    WriteMessage("Test: Print test now", false);
                    WriteMessage("SetTimer 30: Sets timer to 30 minutes (default 180)", false);
                    WriteMessage("SeeTimer: See time left before next print", false);
                    WriteMessage("-------------");
                    break;

                case "test":
                    WriteMessage("Printing test");
                    RawPrinterHelper.SendStringToPrinter(@"\\TRR-I-SERVER02\TRR-I-N023-101-1", "Test!");
                    break;

                case "start":
                    WriteMessage("Timer started");
                    printTimer.Start();
                    break;

                case "stop":
                    WriteMessage("Timer stopped");
                    printTimer.Stop();
                    break;

                case "seetimer":
                    WriteMessage(printTimer.TimeLeft);
                    break;

                case "settimer":
                    WriteMessage("Not yet implemented");
                    break;

                case "exit":
                    exit = true;
                    break;

                case "":
                    Console.Write(": ");
                    break;

                default:
                    WriteMessage("Unrecognized command");
                    break;
                }
            }
        }