Пример #1
0
 internal bool StartInstance(WatcherFolderOption option, WatcherFactory factory)
 {
     Options = option;
     GUID    = option.FolderGUID;
     //snapshotFactory = new SnapshotFactory(backupPath);
     return(InitInstance(factory));
 }
Пример #2
0
        private void CreateFirstInstance()
        {
            WatcherFolderOption option = CreateNewWatcherInstance(@"C:\", false);

            optionsFactory.Options.WatcherFolderOptions.Add(option);
            optionsFactory.SaveOptions();
        }
Пример #3
0
        internal string GetRestorePath(WatcherChangeTypes watcherChangeTypes, WatcherFolderOption watcherFolderOption)
        {
            string folderName = String.Empty;

            if (watcherFolderOption.UseSubFolderEventNames)
            {
                switch (watcherChangeTypes)
                {
                case WatcherChangeTypes.Created:
                    break;

                case WatcherChangeTypes.Deleted:
                    folderName = watcherFolderOption.TrashFolder + "\\" + FolderNames.Deleted.ToString();
                    break;

                case WatcherChangeTypes.Changed:
                    folderName = watcherFolderOption.TrashFolder + "\\" + FolderNames.Changed.ToString();
                    break;

                case WatcherChangeTypes.Renamed:
                    break;

                case WatcherChangeTypes.All:
                    break;

                default:
                    break;
                }
            }
            else
            {
                folderName = watcherFolderOption.TrashFolder;
            }
            return(folderName);
        }
Пример #4
0
        internal string GetTrashFileName(WatcherChangeTypes watcherChangeTypes, WatcherFolderOption watcherFolderOption, string FileName)
        {
            string trashFolder   = GetRestorePath(watcherChangeTypes, watcherFolderOption);
            string trashFileName = trashFolder + "\\" + FileName;

            if (File.Exists(trashFileName))
            {
                trashFileName = GetFileVersion(trashFileName);
                return(trashFileName);
            }
            else
            {
                return(trashFileName);
            }
        }
Пример #5
0
        internal bool CreateEventFolder(WatcherFolderOption watcherFolderOption, FolderNames folder)
        {
            string folderName = watcherFolderOption.TrashFolder + "\\" + folder.ToString();

            if (!Directory.Exists(folderName))
            {
                try
                {
                    Directory.CreateDirectory(folderName);
                    slLogger.WriteLogLine("Directory " + folderName + " created at " + DateTime.Today.ToShortDateString());
                    return(true);
                }
                catch (Exception ex)
                {
                    slLogger.WriteLogLine(ex, "SetupTrashFolderError CreateEventFolderError");
                    return(false);
                }
            }
            return(false);
        }
Пример #6
0
 public void SetupTrashFolder(WatcherFolderOption watcherFolderOption)
 {
     if (!Directory.Exists(watcherFolderOption.TrashFolder))
     {
         try
         {
             Directory.CreateDirectory(watcherFolderOption.TrashFolder);
             slLogger.WriteLogLine("Directory " + watcherFolderOption.TrashFolder + " created at " + DateTime.Today.ToShortDateString());
         }
         catch (Exception ex)
         {
             slLogger.WriteLogLine(ex, "SetupTrashFolderError");
         }
         if (watcherFolderOption.UseSubFolderEventNames)
         {
             CreateEventFolder(watcherFolderOption, FolderNames.Changed);
             CreateEventFolder(watcherFolderOption, FolderNames.Deleted);
         }
     }
 }
Пример #7
0
        public WatcherFolderOption CreateNewWatcherInstance(string FolderPath, bool FolderEnabled = true, string FolderFilter = "*.*", bool IncludeSubDirectories = false, string Description = "New Description", int BufferSize = 8192)
        {
            WatcherFolderOption option = new WatcherFolderOption();

            if (FolderPath.IsNullOrEmpty())
            {
                return(null);
            }
            option.FolderGUID             = Guid.NewGuid().ToString();
            option.FolderPath             = FolderPath;
            option.FolderDescription      = Description;
            option.FolderEnabled          = FolderEnabled;
            option.FolderFilter           = FolderFilter;
            option.FolderIncludeSub       = IncludeSubDirectories;
            option.InternalBufferSize     = BufferSize;
            option.UseDate                = false;
            option.UseForensicsFactory    = false;
            option.UseSubFolderEventNames = false;
            option.DaysToStore            = 21;
            return(option);
        }
Пример #8
0
 internal string GetEventFolderName(WatcherFolderOption watcherFolderOption, WatcherFactory.FolderNames folder)
 {
     return(watcherFolderOption.TrashFolder + "\\" + folder.ToString());
 }