public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ImproveIt.InitInfrastructure(true); LoadLanguage(); CheckIntergrity(); ProcessArguments(args); }
public static void Main(string[] args) { ImproveIt.InitInfrastructure(false); try { Console.WriteLine(_ABOUT); if (args.Length == 0) { runServiceHelper(); } else { switch (args.Length) { case 1: string command = args[0].Substring(1).ToUpperInvariant(); switch (command) { case _HELP: Console.WriteLine(_USAGE); return; case "I": case _INSTALL: installHelper(true); return; case "U": case _DEINSTALL: installHelper(false); return; default: Console.WriteLine(_INVALIDARGUMENTS); Console.WriteLine(_USAGE); break; } break; default: Console.WriteLine(_INVALIDNUMBEROFARGUMENTS); Console.WriteLine(_USAGE); break; } } } catch (Exception e) { ImproveIt.ProcessUnhandledException(e); } }
/// <summary> /// Checks integrity of 7-zip software. In case it's incorrect, /// writes event to program log and halts application /// Does not throw any exceptons /// </summary> private static void check7zipIntegrity() { try { MD5Class.Verify7ZipBinaries(); } catch (InvalidSignException) { // there's no need in service - because installation was damaged by virus! seriousBugHelper(_7ZIPBINARIESWEREDAMAGED, true); } catch (Exception e) { ImproveIt.ProcessUnhandledException(e); } }
/// <summary> /// Stops time planning and kills backup process if any /// </summary> void RequiresStop() { #if DEBUG Console.WriteLine("RequiresStop: "); #endif _scheduler.StopTimePlanning(); if (_process != null) { if (!_process.HasExited) { try { _process.Kill(); } catch (Exception e) { ImproveIt.ProcessUnhandledException(e); } }
public static void Main(string[] args) { ImproveIt.InitInfrastructure(false); try { using (var controller = new ConsoleBackupController()) { if (controller.ParseCommandLineArguments(args)) { if (controller.Prepare()) { controller.Backup(); } } } Console.WriteLine(CopyrightInfo.Copyright); } catch (Exception e) { ImproveIt.ProcessUnhandledException(e); } }
/// <summary> /// Starts the machinery /// </summary> void LoadConfiguration() { ScheduleOptions options = null; // fixed bug with restoring from sleep mode(do not access disk drive) try { options = ScheduleOptionsManager.Load(); ScheduleOptionsManager.Validate(options); } catch (FileNotFoundException) { // but no config was created // it's normal situation after installation // so we're exiting Environment.Exit(0); } catch (ScheduleOptionsInvalidException) { seriousBugHelper(_InvalidOptions, true); } catch (Exception e) { ImproveIt.ProcessUnhandledException(e); } // if there's no scheduling if (!options.EnableScheduling) { // we're exiting to free system resources Environment.Exit(0); } else { _scheduler.Options = options; Resume(); } }
void DoBackup(object sender, EventArgs e) { check7zipIntegrity(); using (CpuUsage cpu = new CpuUsage()) { cpu.WaitUntilCpuLoadingLess(_scheduler.Options.PuttingOffBackupCpuLoading); } _process = new Process(); _process.StartInfo.CreateNoWindow = true; _process.StartInfo.Arguments = "-DoOutputInLogs"; _process.StartInfo.FileName = Files.ConsoleBackupTool; _process.StartInfo.WorkingDirectory = Directories.BinariesDir; try { _process.Start(); } catch (Exception ee) { ImproveIt.ProcessUnhandledException(ee); } }
public static void Main(string[] args) { ImproveIt.InitInfrastructure(true); loadLocalization(); processInternalArguments(args); if (!File.Exists(Files.ProfileFile)) { showErrorAndCloseApplicationIn10Seconds(Translation.Current[582]); } if (!SingleInstance.FirstInstance) { showErrorAndCloseApplicationIn10Seconds(Translation.Current[583]); } try { MD5Class.Verify7ZipBinaries(); } catch (InvalidSignException e) { showErrorAndCloseApplicationIn10Seconds(string.Format(Translation.Current[584], e.Message)); } loadConfiguration(); Controller controller = new Controller(_options); if (args != null && args.Length > 0) { if (!(args.Length == 1 && args[0] == SchedulerParameters.START_WITHOUT_MESSAGE)) { showErrorAndCloseApplicationIn10Seconds(Translation.Current[586]); } } else { ThreadPool.QueueUserWorkItem(new WaitCallback(showMessageFor10Seconds), Translation.Current[587]); } try { if (!_options.DontCareAboutSchedulerStartup && !_options.DontNeedScheduler) { verifyStartupScriptAndFixIt(); } Application.SetCompatibleTextRenderingDefault(false); using (WithTray tray = new WithTray(controller)) { if (!RunAsWinFormApp) { tray.TurnIntoHiddenMode(); } Application.Run(); } } catch (Exception unhandledException) { ImproveIt.ProcessUnhandledException(unhandledException); } }