示例#1
0
        private void timer1_tick(object sender, ElapsedEventArgs e)
        {
            try
            {
                ProgramFunctions.IntegrityCheck(ProgramDirectories.NSOC);
                Logging.WriteLog("");
                Logging.WriteLog("_____________________________________________");

                Logging.WriteLog("checking for updates");

                Program.Main();
            }

            finally
            {
                timer1.Enabled = true;
                DirectoryInfo getUpdates = new DirectoryInfo(ProgramDirectories.NSOC);
                FileInfo[]    Files      = getUpdates.GetFiles("*.*");

                if (Files.Length == 0)
                {
                    ProgramFunctions.Cleanup();
                    Logging.WriteLog("Finishing updates");

                    Logging.WriteLog("_____________________________________________");
                }
            }
        }
        public static void Main()
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new Scheduler()
            };
            ServiceBase.Run(ServicesToRun);

            ProgramFunctions.CreateDirectories();



            int ZipCount = Directory.GetFiles(ProgramDirectories.NSOC, "*.zip",
                                              SearchOption.TopDirectoryOnly).Length;

            int FileCount = Directory.GetFiles(ProgramDirectories.NSOC, "*.nessus",
                                               SearchOption.TopDirectoryOnly).Length;


            if (FileCount != 0 || ZipCount != 0)
            {
                Logging.WriteLog("Updates Found Extracting now");
                ProgramFunctions.IntegrityCheck(ProgramDirectories.NSOC);
                Archiving.CopyToArchive();
                ProgramFunctions.IMnotAzip();
                UnZip.unZipper();
            }

            ProgramFunctions.CopyToConnectors(ProgramDirectories.NewUpdates, ProgramDirectories.CM1);
            ProgramFunctions.IntegrityCheck(ProgramDirectories.CM1);
            ProgramFunctions.CopyToConnectors(ProgramDirectories.NewUpdates, ProgramDirectories.CM2);
            ProgramFunctions.IntegrityCheck(ProgramDirectories.CM2);
            ProgramFunctions.CopyToConnectors(ProgramDirectories.NewUpdates, ProgramDirectories.CM3);
            ProgramFunctions.IntegrityCheck(ProgramDirectories.CM3);
            ProgramFunctions.CopyToConnectors(ProgramDirectories.NewUpdates, ProgramDirectories.CM4);
            ProgramFunctions.IntegrityCheck(ProgramDirectories.CM4);
            ProgramFunctions.CopyToConnectors(ProgramDirectories.NewUpdates, ProgramDirectories.CM5);
            ProgramFunctions.IntegrityCheck(ProgramDirectories.CM5);
            ProgramFunctions.CopyToConnectors(ProgramDirectories.NewUpdates, ProgramDirectories.CM6);
            ProgramFunctions.IntegrityCheck(ProgramDirectories.CM6);



            Logging.DisplayUpdates();

            ProgramFunctions.RmTempFile();

            Archiving.ZipOldUpdate();
        }
示例#3
0
        protected override void OnStart(string[] args)
        {
            ProgramFunctions.CreateDirectories();
            ReadMeDoc.README();
            Logging.TailLogPowerShellScript();

            timer1          = new Timer();
            timer1.Interval = 60000 * 5;  // <-- Poll every 5 Min
            Logging.WriteLog("*************** Starting Service");
            Logging.WriteLog("Updates being checked every " + ((timer1.Interval / 1000) / 60) + " Minute(S) starting");
            ProgramFunctions.IntegrityCheck(ProgramDirectories.NSOC);
            timer1.Elapsed += new ElapsedEventHandler(timer1_tick);
            timer1.Enabled  = true;

            timer1.AutoReset = false;
        }