コード例 #1
0
        private static int VolumeMaintenance(VolumeMaintenanceOptions args)
        {
            using (TextWriterWrapper textWriterWrapper = new TextWriterWrapper(args.LogPath))
                using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + args.DatabasePath)) {
                    connection.Open();

                    if ((args.EnableVolume || args.DisableVolume) && !(args.EnableVolume && args.DisableVolume))
                    {
                        VolumeOperations.SetVolumeEnabledState(connection, args.Volume.Value, args.EnableVolume);
                    }

                    if (args.PurgeData)
                    {
                        // to do this we start a fake scan that isn't actually allowed to see/touch any file
                        var volumes = VolumeOperations.GetKnownVolumes(connection);
                        foreach (Volume v in volumes)
                        {
                            if (args.Volume.Value == v.ID)
                            {
                                ProcessVolume(textWriterWrapper.Writer, connection, v, fakeScan: true);
                            }
                        }
                    }

                    connection.Close();
                }

            return(0);
        }
コード例 #2
0
        private static int ListVolumes(string logPath, string databasePath, bool showDisabledVolumes)
        {
            using (TextWriterWrapper textWriterWrapper = new TextWriterWrapper(logPath))
                using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + databasePath)) {
                    connection.Open();
                    PrintVolumeInformation(textWriterWrapper.Writer, VolumeOperations.GetKnownVolumes(connection).Where(x => showDisabledVolumes || x.ShouldScan));
                    connection.Close();
                }

            return(0);
        }
コード例 #3
0
        private static int Search(SearchOptions args)
        {
            using (TextWriterWrapper textWriterWrapper = new TextWriterWrapper(args.LogPath))
                using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + args.DatabasePath)) {
                    connection.Open();
                    List <Volume> volumes = VolumeOperations.GetKnownVolumes(connection);
                    foreach (var sameFiles in CollectFiles(connection, GetFilesWithFilename(connection, "%" + args.File + "%"), (x) => true))
                    {
                        PrintSameFileInformation(textWriterWrapper.Writer, sameFiles, volumes);
                    }
                    connection.Close();
                }

            return(0);
        }
コード例 #4
0
        private static int ListFiles(string logPath, string databasePath, int?volume, bool selectedVolumeOnly, ShouldPrint shouldPrint)
        {
            using (TextWriterWrapper textWriterWrapper = new TextWriterWrapper(logPath))
                using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + databasePath)) {
                    connection.Open();

                    List <StorageFile> files   = GetKnownFilesOnVolume(connection, volume);
                    List <Volume>      volumes = VolumeOperations.GetKnownVolumes(connection);
                    foreach (var sameFiles in CollectFiles(connection, files, shouldPrint, selectedVolumeOnly ? volume : null))
                    {
                        PrintSameFileInformation(textWriterWrapper.Writer, sameFiles, volumes);
                    }

                    connection.Close();
                }

            return(0);
        }
コード例 #5
0
        public static int PrintExistingArchives(string logPath, string databasePath)
        {
            using (TextWriterWrapper textWriterWrapper = new TextWriterWrapper(logPath))
                using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + databasePath)) {
                    connection.Open();
                    List <Volume>  volumes  = VolumeOperations.GetKnownVolumes(connection);
                    List <Archive> archives = GetKnownArchives(connection);
                    connection.Close();

                    foreach (Archive a in archives)
                    {
                        textWriterWrapper.Writer.WriteLine("Archive #{0}:", a.ArchiveId);
                        foreach (ArchivePath p in a.Paths)
                        {
                            textWriterWrapper.Writer.WriteLine("  Volume #{0} {1}{2}", p.VolumeId, volumes.First(x => x.ID == p.VolumeId).Label, p.Path);
                        }
                        foreach (ArchivePattern p in a.Patterns)
                        {
                            textWriterWrapper.Writer.WriteLine("  Pattern #{0}: {1} from {2} to {3}", p.ArchivePatternId, p.Pattern, p.TimestampBegin, p.TimestampEnd);
                        }
                    }
                }
            return(0);
        }