// --------------------------------------------------------------------------------------------------------------------
        //  WinFCU process Special Actions - process the list of selected hardcoded special actions
        // --------------------------------------------------------------------------------------------------------------------
        public static void processSpecialActions(string scheduleName)
        {
            // Processing specials require a schedule, they will NOT be targetted when the schedule requals #ALL# !!
            // This to prevent unnecessary clenup runs on potentially risky environments!
            foreach (string spcName in specialActions.Keys)
            {
                specialsInfo siObject   = specialActions[spcName];
                string       saSchedule = siObject.schedule;
                total.Logger.Debug(String.Format("Verifying special: {0} ({1}/{2}/{3})", spcName, siObject.enabled, siObject.systemOk, saSchedule));
                if (String.IsNullOrEmpty(saSchedule))
                {
                    saSchedule = scheduleName;
                }
                if (!siObject.enabled)
                {
                    total.Logger.Debug("Special disabled, skipping: " + spcName); continue;
                }
                if (scheduleName != saSchedule)
                {
                    total.Logger.Debug("Schedule mismatch, skipping: " + spcName); continue;
                }
                total.Logger.Info("Processing WinFCU Special: " + spcName);
                switch (spcName)
                {
                case "WindowsInstaller": cleanWindowsInstaller(); break;

                case "RecycleBins": cleanRecycleBins(); break;
                }
            }
        }
 // --------------------------------------------------------------------------------------------------------------------
 //  WinFCU show Special Actions - Show the list of hardcoded special actions
 // --------------------------------------------------------------------------------------------------------------------
 public static void showSpecialActions()
 {
     // Show the know specials
     Console.WriteLine("\r\n WinFCU Specials\r\n{0}", new string('-', 80));
     foreach (string spcName in specialActions.Keys)
     {
         specialsInfo siObject = specialActions[spcName];
         Console.WriteLine("  {0,-25} {1}", spcName, siObject.description);
     }
     Console.WriteLine("");
 }
        // --------------------------------------------------------------------------------------------------------------------
        //  WinFCU define Special Actions - define the list of hardcoded special actions
        // --------------------------------------------------------------------------------------------------------------------
        public static void defineSpecialActions()
        {
            // Declare the known 'Special Actions' - enabled and systemOk are initial always false!
            specialsInfo siObject = new specialsInfo();

            siObject.enabled  = false;
            siObject.systemOk = false;
            siObject.schedule = "";
            // TestSpecialAction
            // siObject.description = "Test entry for Special Actions Items";
            // specialActions.Add("TestSpecialAction", siObject);
            // WindowsInstaller
            siObject.description = "Remove obsolete packages from the Windows Installer folder";
            specialActions.Add("WindowsInstaller", siObject);
            // RecycleBins
            siObject.description = "Clear Recycle Bins on all drives";
            specialActions.Add("RecycleBins", siObject);
        }
Ejemplo n.º 4
0
        // ====================================================================================================================
        //  WinFCU Get Status - Get/Assemble the WinFCU status (config settings, is service installed? etc.)
        // --------------------------------------------------------------------------------------------------------------------
        public static string GetStatus()
        {
            string sc_Status;

            try { ServiceController sc = new ServiceController(ProjectInstaller.SvcServiceName); sc_Status = sc.Status.ToString(); sc.Dispose(); }
            catch (Exception) { sc_Status = "No Service"; }
            // --------------------------------------------------------------------------------------------------------------------
            //   Lets put all info into the prcInfo string so it will be written to the logfile when the config is (re)loaded
            // --------------------------------------------------------------------------------------------------------------------
            string prcInfo = String.Format(" WinFCU {0} - Run Details:\r\n{1}\r\n", fcuVersion, new string('=', 80));

            prcInfo += String.Format("\r\n WinFCU Process Info\r\n {0}\r\n", new string('-', 78));
            prcInfo += String.Format("  - Process ID           : {0,-12}- ParentID             : {1}\r\n", total.PRC.ProcessID, total.PRC.ParentID);
            prcInfo += String.Format("  - Logon Type           : {0,-12}- Logon Type Name      : {1}\r\n", total.PRC.Type, total.PRC.TypeName);
            prcInfo += String.Format("  - x64bit OS            : {0,-12}- x64bit Mode          : {1}\r\n", total.ENV.x64os, total.ENV.x64mode);
            prcInfo += String.Format("  - longpathsenabled     : {0,-12}\r\n", total.SYS.longpathenabled);

            prcInfo += String.Format("\r\n WinFCU Runtime Options\r\n {0}\r\n", new string('-', 78));
            prcInfo += String.Format("  - Debug                : {0,-12}- Dryrun               : {1}\r\n", total.APP.Debug, total.APP.Dryrun);
            prcInfo += String.Format("  - Parallel Schedules   : {0,-12}- Service              : {1}\r\n", fcu.parallelSchedules, sc_Status);

            prcInfo += String.Format("\r\n WinFCU Inheritable Defaults\r\n {0}\r\n", new string('-', 78));
            prcInfo += String.Format("  - File Age (days)      : {0,-12}- File Age check type  : {1}\r\n", defAttributes.fileAge, checkType[defAttributes.checkType]);
            prcInfo += String.Format("  - Process hidden files : {0,-12}- Delete empty folders : {1}\r\n", defAttributes.processHiddenFiles, defAttributes.deleteEmptyFolders);
            prcInfo += String.Format("  - Force overwrite      : {0,-12}- Recursive File Scan  : {1}\r\n", defAttributes.forceOverWrite, defAttributes.recursiveScan);
            prcInfo += String.Format("  - Allowed Systems      : {0,-12}- Default schedule     : {1}\r\n", defAttributes.systemName, defAttributes.scheduleName);
            prcInfo += String.Format("  - Internal ArchivePath : {0,-12}- Exclude from scan    : {1}\r\n", defAttributes.archivePath, defAttributes.excludeFromScan);
            prcInfo += String.Format("  - Follow SymLinks      : {0,-12}\r\n", defAttributes.followSymLinks);

            prcInfo += String.Format("\r\n WinFCU Configuration Info\r\n {0}\r\n", new string('-', 78));
            prcInfo += String.Format("  - Logfile              : {0}\r\n", fcu.runLogFile);
            prcInfo += String.Format("  - Config file          : {0}\r\n", fcu.runConfig);
            string showInclude = "  - Include file(s)      : {0}\r\n";

            foreach (string incFile in fcu.includeFiles)
            {
                prcInfo    += String.Format(showInclude, incFile);
                showInclude = "                           {0}\r\n";
            }

            prcInfo += String.Format("\r\n WinFCU Restricted Paths\r\n {0}\r\n", new string('-', 78));
            string showResPath = "  - Restricted path(s)   : {0}\r\n";

            foreach (string resPath in restrictedPaths)
            {
                prcInfo    += String.Format(showResPath, resPath);
                showResPath = "                           {0}\r\n";
            }

            if (runHasSpecials)
            {
                prcInfo += String.Format("\r\n WinFCU Special Actions\r\n {0}\r\n", new string('-', 78));
                prcInfo += String.Format("  Name                       Enabled  System  Schedule\r\n  {0}\r\n", new string('-', 76));
                foreach (string spcName in specialActions.Keys)
                {
                    specialsInfo siObject = specialActions[spcName];
                    prcInfo += String.Format("  {0,-25}  {1,-5}    {2,-5}   {3}\r\n", spcName, siObject.enabled, siObject.systemOk, siObject.schedule);
                }
            }
            prcInfo += String.Format("\r\n{0}", new string('=', 80));
            return(prcInfo);
        }