Ejemplo n.º 1
0
        public void DoJob()
        {
            bool succesfull = false;

            try
            {
                notify(new ImagePackingNotificationEventArgs(ProcessingState.InProgress));

                reserveFileForBackupImage();
                ImageCreator imagePacker = new ImageCreator(_imageFile.FileName, new ImageHeader(_metarecords));
                imagePacker.Pack(true);
                succesfull = true;
            }
            catch (FileNotFoundException e)
            {
                _log.WriteLine(LoggingEvent.Error, string.Format(Translation.Current[611], e.Message));
                _log.WriteLine(LoggingEvent.Debug, e.ToString());
            }
            catch (IOException e)
            {
                _log.WriteLine(LoggingEvent.Error, string.Format(Translation.Current[579], _imageFile.FileName, e.Message));
                _log.WriteLine(LoggingEvent.Debug, e.ToString());
            }
            catch (ThreadInterruptedException)
            {
                _log.WriteLine(LoggingEvent.Error, Translation.Current[578]);
            }
            finally
            {
                notify(new ImagePackingNotificationEventArgs(succesfull ? ProcessingState.FinishedSuccesfully: ProcessingState.FinishedWithErrors));

                if (_finished != null)
                {
                    _finished.Invoke(this, new JobThreadEventArgs(Thread.CurrentThread));
                }
            }
        }