예제 #1
0
        public override void Close()
        {
            if (IsOpened)
            {
                if (!ErrorsOrWarningsRegistered)
                {
                    //No any error or warning registered during backup!
                    writeInFile(Translation.Current[503]);
                }

                writeInFile("</dody>");
                writeInFile("</html>");
                if (ErrorsOrWarningsRegistered)
                {
                    writeInFile(Files.ErroneousBackupMarkInHtmlLog);
                }
                else
                {
                    writeInFile(Files.SuccesfullBackupMarkInHtmlLog);
                }

                _logFile.Flush();
                _logFile.Close();
                _syncfile.Dispose();
                IsOpened = false;

                GC.SuppressFinalize(this);
            }

            System.Diagnostics.Debug.WriteLine("log::close::finished");
        }
예제 #2
0
        /// <summary>
        /// Removes file
        /// </summary>
        /// <param name="file">sync object</param>
        /// <param name="secureDeleting">if true - does ovewrites file with zeros</param>
        void RemoveAllFilesAtFolder(SyncFile file, bool secureDeleting)
        {
            _log.ProcedureCall("RemoveAllFilesAtFolder", secureDeleting.ToString());

            file.Dispose();

            if (secureDeleting)
            {
                OverWriteFileWithZeros(file.FileName);
            }

            _log.WriteLine(LoggingEvent.Debug, "X " + file.FileName);

            if (!string.IsNullOrEmpty(file.FileName))
            {
                try
                {
                    File.Delete(file.FileName);
                }
                catch (DirectoryNotFoundException e)
                {
                    _log.WriteLine(LoggingEvent.Warning,
                                   string.Format(CultureInfo.CurrentCulture, _couldNotDeleteFileFormatString, file.FileName, e.Message));
                }
                catch (PathTooLongException e)
                {
                    _log.WriteLine(LoggingEvent.Warning,
                                   string.Format(CultureInfo.CurrentCulture, _couldNotDeleteFileFormatString, file.FileName, e.Message));
                }
                catch (FileNotFoundException e)
                {
                    _log.WriteLine(LoggingEvent.Warning,
                                   string.Format(CultureInfo.CurrentCulture, _couldNotDeleteFileFormatString, file.FileName, e.Message));
                }
                catch (UnauthorizedAccessException e)
                {
                    _log.WriteLine(LoggingEvent.Warning,
                                   string.Format(CultureInfo.CurrentCulture, _couldNotDeleteFileFormatString, file.FileName, e.Message));
                }
                catch (IOException e)
                {
                    _log.WriteLine(LoggingEvent.Warning,
                                   string.Format(CultureInfo.CurrentCulture, _couldNotDeleteFileFormatString, file.FileName, e.Message));
                }
            }
            else
            {
                _log.WriteLine(LoggingEvent.Debug, "empty file");
            }
        }
예제 #3
0
        void DoDispose(bool final)
        {
            if (final)
            {
                if (_temporaryFiles == null)
                {
                    return;
                }
            }

            if (!_isDisposed)
            {
                _temporaryFiles.Dispose();
                _imageFile.Dispose();
                _isDisposed = true;

                if (_log.IsOpened)
                {
                    _log.Close();
                }
            }
        }