Browse Source

添加要备份的文件夹,并存储到数据库

yuzhengyang 8 years ago
parent
commit
36330899d2

+ 4 - 1
Fork.Net/Fork.Net.SpeciallyTools/Y.FileQueryEngine/UsnOperation/UsnOperator.cs

@@ -145,6 +145,7 @@ namespace Y.FileQueryEngine.UsnOperation
         }
         public void GetEntries(long usn, GetEntriesHandler handler, int count)
         {
+            bool usnjump = usn > 0;
             List<UsnEntry> result = new List<UsnEntry>();
             UsnErrorCode usnErrorCode = this.QueryUSNJournal();
             if (usnErrorCode == UsnErrorCode.SUCCESS)
@@ -176,7 +177,9 @@ namespace Y.FileQueryEngine.UsnOperation
                     while (outBytesCount > 60)
                     {
                         var usnRecord = new USN_RECORD_V2(ptrUsnRecord);
-                        result.Add(new UsnEntry(usnRecord));
+
+                        if (usnjump) usnjump = false; else result.Add(new UsnEntry(usnRecord));
+
                         ptrUsnRecord = new IntPtr(ptrUsnRecord.ToInt32() + usnRecord.RecordLength);
                         outBytesCount -= usnRecord.RecordLength;
 

+ 1 - 1
Fork.Net/Oreo.Plugins/Oreo.FileMan/App.config

@@ -8,7 +8,7 @@
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
   </startup>
   <connectionStrings>
-    <add name="DefaultConnection" connectionString="data source=|DataDirectory|\files.db" providerName="System.Data.SQLite"/>
+    <add name="DefaultConnection" connectionString="data source=|DataDirectory|\FileMan.db" providerName="System.Data.SQLite"/>
   </connectionStrings>
   <entityFramework>
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

+ 14 - 0
Fork.Net/Oreo.Plugins/Oreo.FileMan/DatabaseEngine/Mapping.cs

@@ -24,4 +24,18 @@ namespace Oreo.FileMan.DatabaseEngine
             this.Property(o => o.Id).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = true }));
         }
     }
+    public class BackupPathsMap : EntityTypeConfiguration<BackupPaths>
+    {
+        public BackupPathsMap()
+        {
+            this.Property(o => o.Id).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = true }));
+        }
+    }
+    public class BackupFilesMap : EntityTypeConfiguration<BackupFiles>
+    {
+        public BackupFilesMap()
+        {
+            this.Property(o => o.Id).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = true }));
+        }
+    }
 }

+ 1 - 1
Fork.Net/Oreo.Plugins/Oreo.FileMan/DatabaseEngine/SuperDb.cs

@@ -27,7 +27,7 @@ namespace Oreo.FileMan.DatabaseEngine
             Database.SetInitializer(new MyDbInitializer(Database.Connection.ConnectionString, modelBuilder));
         }
 
-        public class MyDbInitializer : SqliteCreateDatabaseIfNotExists<SuperDb>//SqliteDropCreateDatabaseAlways
+        public class MyDbInitializer : SqliteDropCreateDatabaseWhenModelChanges<SuperDb>//SqliteDropCreateDatabaseAlways
         {
             public MyDbInitializer(string connectionString, DbModelBuilder modelBuilder)
                 : base(modelBuilder)

+ 16 - 0
Fork.Net/Oreo.Plugins/Oreo.FileMan/Models/BackupFiles.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Oreo.FileMan.Models
+{
+    public class BackupFiles
+    {
+        public int Id { get; set; }
+        public string FilePath { get; set; }
+        public long Size { get; set; }
+        public string UpdateTime { get; set; }
+        public string BackupFileName { get; set; }
+    }
+}

+ 4 - 3
Fork.Net/Oreo.Plugins/Oreo.FileMan/Models/Backups.cs

@@ -5,10 +5,11 @@ using System.Text;
 
 namespace Oreo.FileMan.Models
 {
-    public class Backups
+    public class BackupPaths
     {
         public int Id { get; set; }
-        public string FileName { get; set; }
-        public string FullFileName { get; set; }
+        public string  Name { get; set; }
+        public string  Path { get; set; }
+        
     }
 }

+ 2 - 1
Fork.Net/Oreo.Plugins/Oreo.FileMan/Oreo.FileMan.csproj

@@ -92,7 +92,8 @@
     <Compile Include="DatabaseEngine\Mapping.cs" />
     <Compile Include="DatabaseEngine\Muse.cs" />
     <Compile Include="DatabaseEngine\SuperDb.cs" />
-    <Compile Include="Models\Backups.cs" />
+    <Compile Include="Models\BackupFiles.cs" />
+    <Compile Include="Models\BackupPaths.cs" />
     <Compile Include="Models\Drives.cs" />
     <Compile Include="Models\Files.cs" />
     <Compile Include="Partials\FileBackupPartial.cs">

+ 37 - 26
Fork.Net/Oreo.Plugins/Oreo.FileMan/Partials/FileBackupPartial.Designer.cs

@@ -31,7 +31,7 @@
             this.DgvPath = new System.Windows.Forms.DataGridView();
             this.DgvPathName = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvPathSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.BtAddFolder = new System.Windows.Forms.Button();
+            this.BtAddPath = new System.Windows.Forms.Button();
             this.DgvFile = new System.Windows.Forms.DataGridView();
             this.DgvFileName = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilePath = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -41,7 +41,7 @@
             this.button1 = new System.Windows.Forms.Button();
             this.textBox1 = new System.Windows.Forms.TextBox();
             this.button2 = new System.Windows.Forms.Button();
-            this.BtDelFolder = new System.Windows.Forms.Button();
+            this.BtDelPath = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.DgvPath)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvFile)).BeginInit();
             this.SuspendLayout();
@@ -49,6 +49,7 @@
             // DgvPath
             // 
             this.DgvPath.AllowUserToAddRows = false;
+            this.DgvPath.AllowUserToDeleteRows = false;
             this.DgvPath.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.DgvPath.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.DgvPathName,
@@ -60,6 +61,7 @@
             this.DgvPath.RowTemplate.Height = 23;
             this.DgvPath.Size = new System.Drawing.Size(214, 249);
             this.DgvPath.TabIndex = 0;
+            this.DgvPath.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvPath_CellDoubleClick);
             // 
             // DgvPathName
             // 
@@ -67,27 +69,30 @@
             this.DgvPathName.HeaderText = "文件夹";
             this.DgvPathName.Name = "DgvPathName";
             this.DgvPathName.ReadOnly = true;
+            this.DgvPathName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // DgvPathSize
             // 
             this.DgvPathSize.HeaderText = "大小";
             this.DgvPathSize.Name = "DgvPathSize";
             this.DgvPathSize.ReadOnly = true;
+            this.DgvPathSize.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             this.DgvPathSize.Width = 60;
             // 
-            // BtAddFolder
+            // BtAddPath
             // 
-            this.BtAddFolder.Location = new System.Drawing.Point(7, 6);
-            this.BtAddFolder.Name = "BtAddFolder";
-            this.BtAddFolder.Size = new System.Drawing.Size(75, 23);
-            this.BtAddFolder.TabIndex = 1;
-            this.BtAddFolder.Text = "添加目录";
-            this.BtAddFolder.UseVisualStyleBackColor = true;
-            this.BtAddFolder.Click += new System.EventHandler(this.BtAddFolder_Click);
+            this.BtAddPath.Location = new System.Drawing.Point(7, 6);
+            this.BtAddPath.Name = "BtAddPath";
+            this.BtAddPath.Size = new System.Drawing.Size(75, 23);
+            this.BtAddPath.TabIndex = 1;
+            this.BtAddPath.Text = "添加目录";
+            this.BtAddPath.UseVisualStyleBackColor = true;
+            this.BtAddPath.Click += new System.EventHandler(this.BtAddPath_Click);
             // 
             // DgvFile
             // 
             this.DgvFile.AllowUserToAddRows = false;
+            this.DgvFile.AllowUserToDeleteRows = false;
             this.DgvFile.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.DgvFile.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.DgvFileName,
@@ -108,30 +113,35 @@
             this.DgvFileName.HeaderText = "文件名";
             this.DgvFileName.Name = "DgvFileName";
             this.DgvFileName.ReadOnly = true;
+            this.DgvFileName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // DgvFilePath
             // 
             this.DgvFilePath.HeaderText = "路径";
             this.DgvFilePath.Name = "DgvFilePath";
             this.DgvFilePath.ReadOnly = true;
+            this.DgvFilePath.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // DgvFileSize
             // 
             this.DgvFileSize.HeaderText = "大小";
             this.DgvFileSize.Name = "DgvFileSize";
             this.DgvFileSize.ReadOnly = true;
+            this.DgvFileSize.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // DgvFileVersionHistory
             // 
             this.DgvFileVersionHistory.HeaderText = "历史版本";
             this.DgvFileVersionHistory.Name = "DgvFileVersionHistory";
             this.DgvFileVersionHistory.ReadOnly = true;
+            this.DgvFileVersionHistory.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // DgvFileLastBackupTime
             // 
             this.DgvFileLastBackupTime.HeaderText = "最后备份时间";
             this.DgvFileLastBackupTime.Name = "DgvFileLastBackupTime";
             this.DgvFileLastBackupTime.ReadOnly = true;
+            this.DgvFileLastBackupTime.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // button1
             // 
@@ -158,29 +168,30 @@
             this.button2.Text = "设置备份目录";
             this.button2.UseVisualStyleBackColor = true;
             // 
-            // BtDelFolder
+            // BtDelPath
             // 
-            this.BtDelFolder.Location = new System.Drawing.Point(99, 6);
-            this.BtDelFolder.Name = "BtDelFolder";
-            this.BtDelFolder.Size = new System.Drawing.Size(75, 23);
-            this.BtDelFolder.TabIndex = 6;
-            this.BtDelFolder.Text = "删除目录";
-            this.BtDelFolder.UseVisualStyleBackColor = true;
-            this.BtDelFolder.Click += new System.EventHandler(this.BtDelFolder_Click);
+            this.BtDelPath.Location = new System.Drawing.Point(99, 6);
+            this.BtDelPath.Name = "BtDelPath";
+            this.BtDelPath.Size = new System.Drawing.Size(75, 23);
+            this.BtDelPath.TabIndex = 6;
+            this.BtDelPath.Text = "删除目录";
+            this.BtDelPath.UseVisualStyleBackColor = true;
+            this.BtDelPath.Click += new System.EventHandler(this.BtDelPath_Click);
             // 
             // FileBackupPartial
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.Controls.Add(this.BtDelFolder);
+            this.Controls.Add(this.BtDelPath);
             this.Controls.Add(this.button2);
             this.Controls.Add(this.textBox1);
             this.Controls.Add(this.button1);
             this.Controls.Add(this.DgvFile);
-            this.Controls.Add(this.BtAddFolder);
+            this.Controls.Add(this.BtAddPath);
             this.Controls.Add(this.DgvPath);
             this.Name = "FileBackupPartial";
             this.Size = new System.Drawing.Size(646, 326);
+            this.Load += new System.EventHandler(this.FileBackupPartial_Load);
             ((System.ComponentModel.ISupportInitialize)(this.DgvPath)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvFile)).EndInit();
             this.ResumeLayout(false);
@@ -191,18 +202,18 @@
         #endregion
 
         private System.Windows.Forms.DataGridView DgvPath;
-        private System.Windows.Forms.Button BtAddFolder;
+        private System.Windows.Forms.Button BtAddPath;
+        private System.Windows.Forms.DataGridView DgvFile;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.TextBox textBox1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Button BtDelPath;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvPathName;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvPathSize;
-        private System.Windows.Forms.DataGridView DgvFile;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFileName;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFilePath;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFileSize;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFileVersionHistory;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFileLastBackupTime;
-        private System.Windows.Forms.Button button1;
-        private System.Windows.Forms.TextBox textBox1;
-        private System.Windows.Forms.Button button2;
-        private System.Windows.Forms.Button BtDelFolder;
     }
 }

+ 123 - 29
Fork.Net/Oreo.Plugins/Oreo.FileMan/Partials/FileBackupPartial.cs

@@ -11,77 +11,161 @@ using System.IO;
 using Y.Utils.IOUtils.FileUtils;
 using Y.Utils.DataUtils.Collections;
 using Y.Utils.DataUtils.UnitConvertUtils;
+using Y.Utils.IOUtils.PathUtils;
+using Oreo.FileMan.Models;
+using Oreo.FileMan.DatabaseEngine;
 
 namespace Oreo.FileMan.Partials
 {
     public partial class FileBackupPartial : UserControl
     {
-        List<string> BackupFolder = new List<string>();
+        List<BackupPaths> BackupPath = new List<BackupPaths>();
         public FileBackupPartial()
         {
             InitializeComponent();
         }
-
-        private void BtAddFolder_Click(object sender, EventArgs e)
+        private void FileBackupPartial_Load(object sender, EventArgs e)
+        {
+            Task.Factory.StartNew(() =>
+            {
+                using (var db = new Muse())
+                {
+                    BackupPath = db.GetAll<BackupPaths>(null, false).ToList();
+                    if (ListTool.HasElements(BackupPath))
+                    {
+                        foreach (var b in BackupPath)
+                        {
+                            UIDgvPathAdd(b.Name);
+                        }
+                    }
+                }
+            });
+        }
+        #region 目录操作
+        private void BtAddPath_Click(object sender, EventArgs e)
         {
             FolderBrowserDialog dialog = new FolderBrowserDialog();
             dialog.Description = "请选择要备份的文件夹";
             if (dialog.ShowDialog() == DialogResult.OK)
             {
-                int row = DgvPath.Rows.Count;
-                UIEnableButton(false);
-                string foldPath = dialog.SelectedPath;
-                BackupFolder.Add(foldPath);
-                UIDgvPathAdd(Path.GetFileName(foldPath));
-                long size = 0;
+                string selPath = dialog.SelectedPath;//格式化选中的目录
+                List<BackupPaths> clashPath = BackupPath.Where(x => x.Path.Contains(selPath + "\\") || (selPath + "\\").Contains(x.Path)).ToList();//查询冲突项
+                if (ListTool.HasElements(clashPath))
+                {
+                    string cp = "";
+                    clashPath.ForEach(x => cp += (x.Path + ";"));
+                    //存在重合目录
+                    MessageBox.Show(string.Format("您当前选择路径:{0},与之前选择的目录:{1},存在嵌套包含关系,请先从备份目录中移除,然后重新添加。", selPath, cp));
+                }
+                else
+                {
+                    long size = 0;//目录下的文件大小
+                    int row = DgvPath.Rows.Count;//当前目录列表总数
+                    BackupPaths bp = new BackupPaths() { Name = Path.GetFileName(selPath), Path = selPath + "\\", };
+                    BackupPath.Add(bp);//添加到列表
+                    UIDgvPathAdd(Path.GetFileName(selPath));//添加到列表UI
 
+                    UIEnableButton(false);
+                    Task.Factory.StartNew(() =>
+                    {
+                        using (var db = new Muse())
+                        {
+                            if (!db.Do<BackupPaths>().Any(x => x.Path == (selPath + "\\"))) db.Add(bp);//添加到数据库
+                            List<string> files = FileTool.GetAllFile(selPath);
+                            if (ListTool.HasElements(files))
+                            {
+                                foreach (var f in files)
+                                {
+                                    size += FileTool.Size(f);
+                                    UIDgvPathUpdate(row, Path.GetFileName(selPath), ByteConvertTool.Fmt(size));//更新目录文件大小
+                                }
+                            }
+                        }
+                        UIEnableButton(true);
+                    });
+                }
+            }
+        }
+        private void BtDelPath_Click(object sender, EventArgs e)
+        {
+            if (DgvPath.CurrentRow != null)
+            {
+                int row = DgvPath.CurrentRow.Index;
+                string path = BackupPath[row].Path;
+                if (row >= 0)
+                {
+                    using (var db = new Muse())
+                    {
+                        BackupPaths bp = db.Get<BackupPaths>(x => x.Path == path, null);
+                        if (bp != null) db.Del(bp, true);
+                        BackupPath.RemoveAt(row);
+                    }
+                    UIDgvPathDel(row);
+                }
+            }
+        }
+        private void DgvPath_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
+        {
+            if (e.RowIndex >= 0)
+            {
+                string path = BackupPath[e.RowIndex].Path;
+                UIEnableButton(false);
+                DgvFile.Rows.Clear();
                 Task.Factory.StartNew(() =>
                 {
-                    List<string> files = FileTool.GetAllFile(foldPath);
+                    List<string> files = FileTool.GetAllFile(path);
                     if (ListTool.HasElements(files))
                     {
-                        foreach (var f in files)
+                        foreach (var file in files)
                         {
-                            size += FileTool.Size(f);
-                            UIDgvPathUpdate(row, Path.GetFileName(foldPath), ByteConvertTool.Fmt(size));
+                            UIDgvFileAdd(Path.GetFileName(file), file, FileTool.SizeFormat(file));
                         }
                     }
                     UIEnableButton(true);
                 });
             }
         }
-        private void BtDelFolder_Click(object sender, EventArgs e)
-        {
-            UIDgvPathDel();
-        }
+        #endregion
+
+        /// <summary>
+        /// 停用或启用所有按钮
+        /// </summary>
+        /// <param name="enable"></param>
         void UIEnableButton(bool enable)
         {
             BeginInvoke(new Action(() =>
             {
-                BtAddFolder.Enabled = enable;
+                BtAddPath.Enabled = enable;
             }));
         }
-        void UIDgvPathAdd(string path)
+        #region 路径列表UI操作
+        /// <summary>
+        /// 添加到路径列表
+        /// </summary>
+        /// <param name="path"></param>
+        void UIDgvPathAdd(string name)
         {
             BeginInvoke(new Action(() =>
             {
-                DgvPath.Rows.Add(new object[] { Path.GetFileName(path), "-" });
+                DgvPath.Rows.Add(new object[] { name, "-" });
             }));
         }
-        void UIDgvPathDel()
+        /// <summary>
+        /// 从路径列表删除
+        /// </summary>
+        void UIDgvPathDel(int row)
         {
             BeginInvoke(new Action(() =>
             {
-                if (DgvPath.CurrentRow != null)
-                {
-                    int row = DgvPath.CurrentRow.Index;
-                    if (row >= 0)
-                    {
-                        DgvPath.Rows.RemoveAt(row);
-                    }
-                }
+                DgvPath.Rows.RemoveAt(row);
             }));
         }
+        /// <summary>
+        /// 更新到路径列表
+        /// </summary>
+        /// <param name="row"></param>
+        /// <param name="path"></param>
+        /// <param name="size"></param>
         void UIDgvPathUpdate(int row, string path, string size)
         {
             BeginInvoke(new Action(() =>
@@ -89,6 +173,16 @@ namespace Oreo.FileMan.Partials
                 DgvPath.Rows[row].SetValues(new object[] { Path.GetFileName(path), size });
             }));
         }
+        #endregion
+        #region 文件列表UI操作
+        void UIDgvFileAdd(string file, string path, string size)
+        {
+            BeginInvoke(new Action(() =>
+            {
+                DgvFile.Rows.Add(new object[] { file, path, size });
+            }));
+        }
+        #endregion
 
 
     }

+ 0 - 21
Fork.Net/Oreo.Plugins/Oreo.FileMan/Partials/FileBackupPartial.resx

@@ -123,27 +123,6 @@
   <metadata name="DgvPathSize.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="DgvPathName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="DgvPathSize.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="DgvFileName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="DgvFilePath.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="DgvFileSize.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="DgvFileVersionHistory.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="DgvFileLastBackupTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="DgvFileName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>

+ 3 - 2
Fork.Net/Oreo.Plugins/Oreo.FileMan/Partials/FileTypePartial.cs

@@ -147,7 +147,8 @@ namespace Oreo.FileMan.Partials
                 {
                     NewFileCount = 0;
                     if (drive.Name.Contains("C")) continue;//测试时跳过C盘
-                    if (drive.Name.Contains("D")) continue;//测试时跳过D盘
+                    //if (drive.Name.Contains("D")) continue;//测试时跳过D盘
+                    if (drive.Name.Contains("F")) continue;//测试时跳过F盘
 
                     using (var db = new Muse())
                     {
@@ -173,7 +174,7 @@ namespace Oreo.FileMan.Partials
                         long currentUsn = 0;
                         if (db.Any<Files>(x => x.Drive == drive.Name, null))
                         {
-                            currentUsn = db.Do<Files>().Where(x => x.Drive == drive.Name).Max(x => x.Usn) + 1;
+                            currentUsn = db.Do<Files>().Where(x => x.Drive == drive.Name).Max(x => x.Usn);
                         }
                         //从上次Usn记录开始读取
                         var usnOperator = new UsnOperator(drive);

+ 9 - 3
Fork.Net/Y.Utils/DataUtils/DateTimeUtils/DateTimeConvert.cs

@@ -1,7 +1,10 @@
-//############################################################
+//************************************************************************
 //      https://github.com/yuzhengyang
-//      author:yuzhengyang
-//############################################################
+//      author:     yuzhengyang
+//      date:       2017.3.29 - 2017.6.27
+//      desc:       日期格式转换
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -10,6 +13,9 @@ using System.Threading.Tasks;
 
 namespace Y.Utils.DataUtils.DateTimeUtils
 {
+    /// <summary>
+    /// 日期格式转换工具
+    /// </summary>
     public sealed class DateTimeConvert
     {
         /// <summary>

+ 64 - 3
Fork.Net/Y.Utils/IOUtils/PathUtils/DirTool.cs

@@ -1,7 +1,11 @@
-//############################################################
+//************************************************************************
 //      https://github.com/yuzhengyang
-//      author:yuzhengyang
-//############################################################
+//      author:     yuzhengyang
+//      date:       2017.3.29 - 2017.6.27
+//      desc:       文件目录工具类
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
+
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -11,8 +15,16 @@ using Y.Utils.DataUtils.Collections;
 
 namespace Y.Utils.IOUtils.PathUtils
 {
+    /// <summary>
+    /// 文件目录工具类
+    /// </summary>
     public class DirTool
     {
+        /// <summary>
+        /// 创建文件目录
+        /// </summary>
+        /// <param name="path"></param>
+        /// <returns></returns>
         public static bool Create(string path)
         {
             if (Directory.Exists(path))
@@ -27,6 +39,11 @@ namespace Y.Utils.IOUtils.PathUtils
                 }
             return false;
         }
+        /// <summary>
+        /// 获取目录的父目录
+        /// </summary>
+        /// <param name="path"></param>
+        /// <returns></returns>
         public static string Parent(string path)
         {
             try
@@ -36,12 +53,22 @@ namespace Y.Utils.IOUtils.PathUtils
             catch (Exception e) { }
             return null;
         }
+        /// <summary>
+        /// 获取目录下的目录(一层)
+        /// </summary>
+        /// <param name="path"></param>
+        /// <returns></returns>
         public static List<string> GetPath(string path)
         {
             if (Directory.Exists(path))
                 try { return Directory.EnumerateDirectories(path).ToList(); } catch (Exception e) { }
             return null;
         }
+        /// <summary>
+        /// 获取目录下所有目录(递归)
+        /// </summary>
+        /// <param name="path"></param>
+        /// <returns></returns>
         public static List<string> GetAllPath(string path)
         {
             List<string> result = GetPath(path);
@@ -59,6 +86,11 @@ namespace Y.Utils.IOUtils.PathUtils
             }
             return null;
         }
+        /// <summary>
+        /// 判断目录是否为磁盘
+        /// </summary>
+        /// <param name="path"></param>
+        /// <returns></returns>
         public static bool IsDriver(string path)
         {
             if (path != null && path.Length >= 2)
@@ -85,6 +117,11 @@ namespace Y.Utils.IOUtils.PathUtils
             }
             return result;
         }
+        /// <summary>
+        /// 连接多个string构成目录
+        /// </summary>
+        /// <param name="paths"></param>
+        /// <returns></returns>
         public static string Combine(params string[] paths)
         {
             if (ListTool.HasElements(paths))
@@ -110,5 +147,29 @@ namespace Y.Utils.IOUtils.PathUtils
             }
             return "";
         }
+        /// <summary>
+        /// 路径包含关系
+        /// </summary>
+        /// <param name="path1"></param>
+        /// <param name="path2"></param>
+        /// <returns>
+        /// -1:不存在包含关系
+        /// 0:两个目录相同
+        /// 1:path1 包含 path2(path1 大)
+        /// 2:path2 包含 path1(path2 大)
+        /// </returns>
+        public static int Include(string path1, string path2)
+        {
+            if (path1 == path2) return 0;//两个目录相同
+
+            string p1 = Combine(path1 + "\\");
+            string p2 = Combine(path2 + "\\");
+
+            if (p1 == p2) return 0;//两个目录相同(防止路径后有带\或不带\的情况)
+            if (p1.Length > p2.Length && p1.Contains(p2)) return 1;//path1 包含 path2(path1 大)
+            if (p2.Length > p1.Length && p2.Contains(p1)) return 2;//path2 包含 path1(path2 大)
+
+            return -1;//不存在包含关系
+        }
     }
 }