Introduced a concept of folder depth in the database code, and updated the Snapshot class to take advantage of it. Only working for a 'OneLevel' Folder Group type.
This commit is contained in:
+32
-7
@@ -86,12 +86,29 @@ namespace DataOrganizer
|
||||
|
||||
while(reader.Read())
|
||||
{
|
||||
var type = OrganizationType.Custom;
|
||||
var patternId = Convert.ToInt32(reader["pattern_id"]);
|
||||
|
||||
switch (patternId)
|
||||
{
|
||||
case 1:
|
||||
type = OrganizationType.SingleLevel;
|
||||
break;
|
||||
case 2:
|
||||
type = OrganizationType.Flat;
|
||||
break;
|
||||
default:
|
||||
type = OrganizationType.Custom;
|
||||
break;
|
||||
}
|
||||
|
||||
profile.FolderGroups.Add(new FolderGroup
|
||||
{
|
||||
Name = reader["name"].ToString(),
|
||||
Id = Convert.ToInt32(reader["root_id"]),
|
||||
Path = reader["path"].ToString(),
|
||||
PatternId = Convert.ToInt32(reader["pattern_id"])
|
||||
PatternId = Convert.ToInt32(reader["pattern_id"]),
|
||||
Type = type
|
||||
});
|
||||
}
|
||||
|
||||
@@ -365,19 +382,18 @@ namespace DataOrganizer
|
||||
|
||||
while(reader.Read())
|
||||
{
|
||||
var fullPath = string.Format("{0}{1}", reader["path"], reader["full_path"]);
|
||||
|
||||
files.Add(new FileSnapshot
|
||||
{
|
||||
Id = Convert.ToInt32(reader["file_id"]),
|
||||
FullPath = fullPath,
|
||||
PathNoRoot = reader["full_path"].ToString(),
|
||||
Name = reader["name"].ToString(),
|
||||
ProfileId = profileId,
|
||||
RootFolderId = folderGroupId,
|
||||
Size = Convert.ToInt64(reader["size"]),
|
||||
CreationDate = Convert.ToDateTime(reader["date_created"]),
|
||||
ModifiedDate = Convert.ToDateTime(reader["date_modified"]),
|
||||
PatternId = Convert.ToInt32(reader["pattern_override_id"])
|
||||
PatternId = Convert.ToInt32(reader["pattern_override_id"]),
|
||||
RootPath = reader["path"].ToString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -401,7 +417,7 @@ namespace DataOrganizer
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
command.Parameters.AddWithValue("FullPath", file.FullPath.Remove(0, rootLength));
|
||||
command.Parameters.AddWithValue("FullPath", file.PathNoRoot.Remove(0, rootLength));
|
||||
command.Parameters.AddWithValue("Name", file.Name);
|
||||
command.Parameters.AddWithValue("Size", file.Size);
|
||||
command.Parameters.AddWithValue("DateCreated", file.CreationDate);
|
||||
@@ -435,6 +451,7 @@ namespace DataOrganizer
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string Path;
|
||||
public OrganizationType Type;
|
||||
public int PatternId;
|
||||
}
|
||||
|
||||
@@ -449,7 +466,7 @@ namespace DataOrganizer
|
||||
public struct FileSnapshot
|
||||
{
|
||||
public int Id;
|
||||
public string FullPath;
|
||||
public string PathNoRoot;
|
||||
public string Name;
|
||||
public int ProfileId;
|
||||
public int PatternId;
|
||||
@@ -457,6 +474,14 @@ namespace DataOrganizer
|
||||
public DateTime CreationDate;
|
||||
public DateTime ModifiedDate;
|
||||
public long Size;
|
||||
public string RootPath;
|
||||
}
|
||||
|
||||
public enum OrganizationType
|
||||
{
|
||||
Flat = 0,
|
||||
SingleLevel = 1,
|
||||
Custom = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user