Exemplo n.º 1
0
        /// <summary>
        /// Checking the integrity: Checking if the all components present and Checking 7-zip intergrity
        /// </summary>
        static void CheckIntergrity()
        {
            try
            {
                Directories.CriticalFoldersCheck();
                Files.CriticalFilesCheck();
            }
            catch (DirectoryNotFoundException e)
            {
                _packageIsBroken = true;
                Messages.ShowErrorBox(string.Format(Translation.Current[580], e.Message));
            }
            catch (FileNotFoundException e)
            {
                _packageIsBroken = true;
                Messages.ShowErrorBox(string.Format(Translation.Current[580], e.Message));
            }

            // Checking 7-zip intergrity
            try
            {
                MD5Class.Verify7ZipBinaries();
            }
            catch (InvalidSignException ee)
            {
                _7ZipIsBroken = true;
                Messages.ShowErrorBox(string.Format(Translation.Current[541], ee.Message));
            }

            _schedulerInstalled = File.Exists(Files.Scheduler);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called in the very beginning of backup lifetime cycle
        /// </summary>
        bool BeforeBackup(out Collection <MetaRecord> metarecords, out ArchiveTask[] archiveParameters)
        {
            _log.ProcedureCall("BeforeBackUp");
            _log.WriteLine(LoggingEvent.Debug, string.Format(CultureInfo.InvariantCulture, "Temp folder: {0}", Directories.TempFolder));
            _log.WriteLine(LoggingEvent.Debug, string.Format(CultureInfo.InvariantCulture, "Task: {0}", _task.Name));

            if ((_log is FileLog) && (_options.LoggingLevel == LogLevel.Support))
            {
                string[] options = File.ReadAllLines(Files.ProfileFile);

                foreach (string line in options)
                {
                    _log.WriteLine(LoggingEvent.Debug, line.Replace("<", "(").Replace(">", ")"));
                }
            }

            foreach (BackupEventTaskInfo taskInfo in _task.BeforeBackupTasksChain)
            {
                Notify(new RunProgramBeforeOrAfterBackupEventArgs(taskInfo, ProcessingState.NotStarted));
            }

            foreach (BackupEventTaskInfo taskInfo in _task.AfterBackupTasksChain)
            {
                Notify(new RunProgramBeforeOrAfterBackupEventArgs(taskInfo, ProcessingState.NotStarted));
            }

            archiveParameters = CreateArgsForCompressionAndMetaForImage(out metarecords);
            foreach (ArchiveTask archiveParameter in archiveParameters)
            {
                Notify(new PackingNotificationEventArgs(archiveParameter.ItemToCompress, ProcessingState.NotStarted));
            }

            foreach (StorageBase storage in _task.Storages)
            {
                Notify(new CopyingToStorageNotificationEventArgs(storage, ProcessingState.NotStarted));
            }

            Notify(new ImagePackingNotificationEventArgs(ProcessingState.NotStarted));

            try
            {
                MD5Class.Verify7ZipBinaries();
            }
            catch (InvalidSignException signException)
            {
                _log.WriteLine(LoggingEvent.Error, string.Format(Translation.Current[541], signException.Message));
                return(false);
            }

            return(IsAnySenceInPacking());
        }
Exemplo n.º 3
0
 /// <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);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Starts 7-zip and waits until it finishes its work
        /// </summary>
        /// <exception cref="FieldAccessException">Problems with 7-zip</exception>
        public void StartJob()
        {
            MD5Class.Verify7ZipBinaries();
            Process process = new Process();

            process.StartInfo.UseShellExecute = false;
            process.StartInfo.FileName        = Files.SevenZipGPacker;
            process.StartInfo.Arguments       = _parameters.ToString();

            try
            {
                process.Start();
            }
            catch (System.ComponentModel.Win32Exception exc)
            {
                throw new FieldAccessException(string.Format(CultureInfo.InvariantCulture, Translation.Current[550], exc.Message), exc);
            }

            process.WaitForExit();
        }
        private void ValidateSettings()
        {
            try
            {
                ProgramOptionsManager.ValidateOptions(_options);
            }
            catch (InvalidDataException exc)
            {
                ShowErrorAndQuit(exc);
            }

            try
            {
                MD5Class.Verify7ZipBinaries();
            }
            catch (InvalidSignException e)
            {
                // backup process is not breaked here
                // because this message should go in logs too
                // because this tool usually runned from scheduler
                Console.WriteLine(Translation.Current[541], e.Message);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }