Пример #1
0
        private void ImportMedia(XmlNode node,
                                 string borrow,
                                 string comment,
                                 long volumeID)
        {
            FileSystemVolume v         = new FileSystemVolume(targetDb);
            VolumeDriveType  driveType = driveTypeMapping[node.Attributes["type"].Value];
            DateTime         added;

            if (!DateTime.TryParseExact(node.Attributes["time"].Value, DATETIME_FORMAT,
                                        ci.DateTimeFormat, DateTimeStyles.None, out added))
            {
                added = DateTime.MinValue;
            }

            v.SetVolumeFields(volumeID,
                              node.Attributes["name"].Value,
                              added,
                              false,
                              node.Attributes["number"].Value,
                              driveType,
                              borrow,
                              DateTime.MinValue,
                              DateTime.MinValue,
                              null,
                              comment,
                              null);

            v.SetFileSystemVolumeFields(counters[TOTAL_FILES],
                                        counters[TOTAL_DIRS],
                                        counters[TOTAL_SIZE]);

            v.InsertIntoDB();

            // insert root item
            DirectoryVolumeItem item = new DirectoryVolumeItem(targetDb);

            item.SetFileSystemVolumeItemFields(null,
                                               DateTime.MinValue,
                                               VolumeDatabase.ID_NONE);

            item.SetVolumeItemFields(volumeID,
                                     1L,
                                     0L,
                                     "/",
                                     VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY,
                                     MetadataStore.Empty,
                                     null,
                                     null);

            item.InsertIntoDB();
        }
Пример #2
0
        private static void ImportDisk(IDataReader reader,
		                               long volumeID,
		                               VolumeDatabase db,
		                               long[] counters)
        {
            FileSystemVolume v = new FileSystemVolume(db);

            // try to guess the drivetype
            VolumeDriveType driveType;
            string root = (string)reader["root"];
            if (root.ToUpper().Contains("CDROM") || root.ToUpper().Contains("DVD"))
                driveType = VolumeDriveType.CDRom;
            else if (root.StartsWith("/media"))
                driveType = VolumeDriveType.Removable;
            else
                driveType = VolumeDriveType.Harddisk;

            v.SetVolumeFields(volumeID,
                              Util.ReplaceDBNull<string>(reader["name"], null),
                              DateTime.Now,
                              false,
                              null,
                              driveType,
                              Util.ReplaceDBNull<string>(reader["borrow"], null),
                              DateTime.MinValue,
                              DateTime.MinValue,
                              null,
                              Util.ReplaceDBNull<string>(reader["comment"], null),
                              null);

            v.SetFileSystemVolumeFields(counters[TOTAL_FILES],
                                        counters[TOTAL_DIRS],
                                        counters[TOTAL_SIZE]);

            v.InsertIntoDB();

            // insert root item
            DirectoryVolumeItem item = new DirectoryVolumeItem(db);

            item.SetFileSystemVolumeItemFields(null,
                                               DateTime.MinValue,
                                               VolumeDatabase.ID_NONE);

            item.SetVolumeItemFields(volumeID,
                                     1L,
                                     0L,
                                     "/",
                                     VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY,
                                     MetadataStore.Empty,
                                     null,
                                     null);

            item.InsertIntoDB();
        }
Пример #3
0
        private static void ImportDisk(IDataReader reader,
                                       long volumeID,
                                       VolumeDatabase db,
                                       long[] counters)
        {
            FileSystemVolume v = new FileSystemVolume(db);

            // try to guess the drivetype
            VolumeDriveType driveType;
            string          root = (string)reader["root"];

            if (root.ToUpper().Contains("CDROM") || root.ToUpper().Contains("DVD"))
            {
                driveType = VolumeDriveType.CDRom;
            }
            else if (root.StartsWith("/media"))
            {
                driveType = VolumeDriveType.Removable;
            }
            else
            {
                driveType = VolumeDriveType.Harddisk;
            }

            v.SetVolumeFields(volumeID,
                              Util.ReplaceDBNull <string>(reader["name"], null),
                              DateTime.Now,
                              false,
                              null,
                              driveType,
                              Util.ReplaceDBNull <string>(reader["borrow"], null),
                              DateTime.MinValue,
                              DateTime.MinValue,
                              null,
                              Util.ReplaceDBNull <string>(reader["comment"], null),
                              null);

            v.SetFileSystemVolumeFields(counters[TOTAL_FILES],
                                        counters[TOTAL_DIRS],
                                        counters[TOTAL_SIZE]);

            v.InsertIntoDB();

            // insert root item
            DirectoryVolumeItem item = new DirectoryVolumeItem(db);

            item.SetFileSystemVolumeItemFields(null,
                                               DateTime.MinValue,
                                               VolumeDatabase.ID_NONE);

            item.SetVolumeItemFields(volumeID,
                                     1L,
                                     0L,
                                     "/",
                                     VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY,
                                     MetadataStore.Empty,
                                     null,
                                     null);

            item.InsertIntoDB();
        }