Exemple #1
0
        protected override void OnStart(string[] args)
        {
            strWorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

            FullJob.Init();

            frequncy          = new Timer();
            frequncy.Interval = FullJob.period * 1000;   //every 30 secs
            frequncy.Elapsed += new System.Timers.ElapsedEventHandler(this.frequncy_Tick);
            frequncy.Enabled  = true;
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         //                            .WriteTo.LiterateConsole()
                         .WriteTo.RollingFile(System.AppDomain.CurrentDomain.BaseDirectory + "logs\\repmon-{Date}.txt")
                         .CreateLogger();

            if (args.Length == 0)
            {
//                File.AppendAllText("c:\\temp\\mylog.txt", "Run it as a service");
                // Run your service normally.
                Log.Information("Run it as a service");
                ServiceBase[] ServicesToRun = new ServiceBase[] { new SmartFixService() };
                ServiceBase.Run(ServicesToRun);
            }
            else if (args.Length == 1)
            {
                switch (args[0])
                {
                case "-install":
                    InstallService();
                    StartService();
                    break;

                case "-uninstall":
                    StopService();
                    UninstallService();
                    break;

                case "-normal":
                    FullJob.Init();
                    FullJob.Bob();
                    break;

                case "-testmail":
                    System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
                    FullJob.loadSettings("settings.json");
                    FullJob.notifyDBA(true);
                    Console.WriteLine("Done! check your email inbox or the log file");
                    break;

                default:
                    throw new NotImplementedException();
                }
            }



            //start test

            /*
             *          System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
             *
             *
             *
             *          FullJob.Init();
             *          FullJob.Bob();
             *          var credential = FullJob.getMySQLCredential("server.xml");
             *          FullJob.loadSettings("settings.json");
             *          FullJob.getDaulShieldBinFolder("ALG");
             *          string contents = File.ReadAllText("exout.txt");
             *          FullJob.findErrorCode(contents);
             *                      Console.WriteLine();
             */

            //end test

            /*
             *          ServiceBase[] ServicesToRun;
             *          ServicesToRun = new ServiceBase[]
             *          {
             *              new SmartFixService()
             *          };
             *          ServiceBase.Run(ServicesToRun);
             *
             */
        }