Browse Source

完成文件还原,md5码比对备份

yuzhengyang 8 years ago
parent
commit
8e610b25e2

+ 2 - 1
Fork.Net/Oreo.Plugins/Oreo.FaultLog/Views/MainForm.Designer.cs

@@ -119,8 +119,9 @@
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.BackColor = System.Drawing.Color.Salmon;
+            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(247)))), ((int)(((byte)(161)))));
             this.ClientSize = new System.Drawing.Size(700, 485);
+            this.Colorful = true;
             this.Controls.Add(this.BtMin);
             this.Controls.Add(this.BtClose);
             this.Controls.Add(this.LbAppTitle);

+ 9 - 5
Fork.Net/Oreo.Plugins/Oreo.FileMan/App.config

@@ -5,8 +5,9 @@
     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
   </configSections>
   <startup>
-    
-  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
+
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
+  </startup>
   <connectionStrings>
     <add name="DefaultConnection" connectionString="data source=|DataDirectory|\FileMan.db" providerName="System.Data.SQLite"/>
   </connectionStrings>
@@ -34,9 +35,12 @@
       </dependentAssembly>
     </assemblyBinding>
   </runtime>
-<system.data>
+  <system.data>
     <DbProviderFactories>
       <remove invariant="System.Data.SQLite.EF6"/>
       <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6"/>
-    <remove invariant="System.Data.SQLite"/><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/></DbProviderFactories>
-  </system.data></configuration>
+      <remove invariant="System.Data.SQLite"/>
+      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
+    </DbProviderFactories>
+  </system.data>
+</configuration>

+ 5 - 2
Fork.Net/Oreo.Plugins/Oreo.FileMan/Commons/R.cs

@@ -16,9 +16,12 @@ namespace Oreo.FileMan.Commons
         internal static DateTime StartTime = DateTime.Now;
         internal static string MachineName = Environment.MachineName;
         internal static Module Module = Assembly.GetExecutingAssembly().GetModules()[0];
-        internal static Log Log { get; set; }
+        public static string DbConnString = "DefaultConnection";
         internal static string AesKey = "12345678901234567890123456789012";
 
+        internal static Log Log { get; set; }
+
+
         public static class Paths
         {
             public static string App = AppDomain.CurrentDomain.BaseDirectory;
@@ -43,7 +46,7 @@ namespace Oreo.FileMan.Commons
             public static class FileBackup
             {
                 public static string FileManBackup = @"D:\temp\FileManBackup\";//文件备份目录
-                public static int BACK_UP_INTERVAL = 5 * 1000;//备份文件间隔
+                public static int BACK_UP_INTERVAL = 60 * 1000;//备份文件间隔
                 public static int BACK_UP_COUNT = 10;//备份文件版本个数
             }
         }

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

@@ -38,11 +38,4 @@ namespace Oreo.FileMan.DatabaseEngine
             this.Property(o => o.Id).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = true }));
         }
     }
-    public class WatcherFilesMap : EntityTypeConfiguration<WatcherFiles>
-    {
-        public WatcherFilesMap()
-        {
-            this.Property(o => o.Id).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute() { IsUnique = true }));
-        }
-    }
 }

+ 3 - 2
Fork.Net/Oreo.Plugins/Oreo.FileMan/DatabaseEngine/Muse.cs

@@ -1,4 +1,5 @@
-using System;
+using Oreo.FileMan.Commons;
+using System;
 using System.Collections.Generic;
 using System.Data.Entity;
 using System.Data.Entity.Infrastructure;
@@ -12,7 +13,7 @@ namespace Oreo.FileMan.DatabaseEngine
         public SuperDb Context;
         public Muse()
         {
-            Context = new SuperDb();
+            Context = new SuperDb(R.DbConnString);
         }
 
         public int Add<T>(T EntityObj, bool isSave = true) where T : class

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

@@ -14,7 +14,7 @@ namespace Oreo.FileMan.DatabaseEngine
 {
     public class SuperDb : DbContext
     {
-        public SuperDb() : base(@"DefaultConnection")
+        public SuperDb(string connectionString) : base(connectionString)
         {
             //Database.SetInitializer(new MigrateDatabaseToLatestVersion<SuperDb, Configuration>());
         }

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

@@ -28,5 +28,9 @@ namespace Oreo.FileMan.Models
         /// 最后修改时间
         /// </summary>
         public string LastWriteTime { get; set; }
+        /// <summary>
+        /// Md5
+        /// </summary>
+        public string Md5 { get; set; }
     }
 }

+ 0 - 13
Fork.Net/Oreo.Plugins/Oreo.FileMan/Models/WatcherFiles.cs

@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Oreo.FileMan.Models
-{
-    public class WatcherFiles
-    {
-        public int Id { get; set; }
-        public string FullPath { get; set; }
-    }
-}

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

@@ -98,7 +98,6 @@
     <Compile Include="Models\BackupPaths.cs" />
     <Compile Include="Models\UsnDrives.cs" />
     <Compile Include="Models\UsnFiles.cs" />
-    <Compile Include="Models\WatcherFiles.cs" />
     <Compile Include="Partials\FileBackupPartial.cs">
       <SubType>UserControl</SubType>
     </Compile>

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

@@ -156,10 +156,10 @@ namespace Oreo.FileMan.Partials
                 {
                     using (var db = new Muse())
                     {
-                        db.Context.Database.Log = (sql) =>
-                        {
-                            R.Log.i(sql);
-                        };
+                        //db.Context.Database.Log = (sql) =>
+                        //{
+                        //    R.Log.i(sql);
+                        //};
                         try
                         {
                             var result = db.Do<BackupFiles>().
@@ -171,7 +171,7 @@ namespace Oreo.FileMan.Partials
                                     BackPath = x.Max(o => o.BackupFullPath),
                                     Count = x.Count(),
                                     Time = x.Max(o => o.LastWriteTime),
-                                }).ToList();
+                                }).OrderByDescending(x=>x.Time).ToList();
 
                             if (ListTool.HasElements(result))
                             {

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

@@ -17,6 +17,7 @@ using System.Data.Entity.Infrastructure;
 using Y.Utils.AppUtils;
 using Y.Utils.DataUtils.DateTimeUtils;
 using Y.Utils.DataUtils.StringUtils;
+using Oreo.FileMan.Commons;
 
 namespace Oreo.FileMan.Partials
 {
@@ -70,7 +71,7 @@ namespace Oreo.FileMan.Partials
                 foreach (var drive in drives)
                 {
                     NewFileCount = 0;
-                    if (!drive.Name.Contains("J")) continue;//测试只读取D盘
+                    //if (!drive.Name.Contains("J")) continue;//测试只读取D盘
                     //if (drive.Name.Contains("D")) continue;//测试时跳过D盘
                     //if (drive.Name.Contains("F")) continue;//测试时跳过F盘
 

+ 28 - 16
Fork.Net/Oreo.Plugins/Oreo.FileMan/Services/FileBackupService.cs

@@ -88,25 +88,36 @@ namespace Oreo.FileMan.Services
                         BackupFiles = new List<string>();
                     }
 
-                    foreach (var t in temp)
+                    using (var db = new Muse())
                     {
-                        if (File.Exists(t))
+                        foreach (var t in temp)
                         {
-                            string filepath = DirTool.GetFilePath(t);
-                            BackupPaths path = Paths.FirstOrDefault(x => filepath.Contains(x.Path));
-                            if (path != null)
+                            //要备份的文件存在
+                            if (File.Exists(t))
                             {
-                                string pathname = path.Path;
-                                string pathalias = path.Alias;
-                                string pathfile = t.Substring(pathname.Length, t.Length - pathname.Length);
-                                string fileext = DateTimeConvert.CompactString(DateTime.Now);
-                                string fullpath = DirTool.Combine(R.Settings.FileBackup.FileManBackup, pathalias, pathfile + "." + fileext);
+                                //文件属于要备份的文件目录
+                                string filepath = DirTool.GetFilePath(t);
+                                BackupPaths path = Paths.FirstOrDefault(x => filepath.Contains(x.Path));
+                                if (path != null)
+                                {
+                                    //文件的MD5码以前没有备份过
+                                    string md5 = FileTool.GetMD5(t);
+                                    bool isback = db.Any<BackupFiles>(x => x.FullPath == t && x.Md5 == md5, null);
+                                    if (!isback)
+                                    {
+                                        string pathname = path.Path;//备份文件夹路径
+                                        string pathalias = path.Alias;//备份文件夹别名
+                                        string pathfile = t.Substring(pathname.Length, t.Length - pathname.Length);//截取备份文件子目录(相对备份文件夹)
+                                        string fileext = "." + DateTimeConvert.CompactString(DateTime.Now) + Path.GetExtension(t);//设置后缀
+                                        string fullpath = DirTool.Combine(R.Settings.FileBackup.FileManBackup, pathalias, pathfile + fileext);//组合路径
 
-                                //删除冗余
-                                DeleteExcess(t);
-                                //备份文件
-                                BackupFile(t, fullpath);
-                                _FileCount++;
+                                        //删除冗余
+                                        DeleteExcess(t);
+                                        //备份文件
+                                        BackupFile(t, fullpath, md5);
+                                        _FileCount++;
+                                    }
+                                }
                             }
                         }
                     }
@@ -226,7 +237,7 @@ namespace Oreo.FileMan.Services
         /// </summary>
         /// <param name="path"></param>
         /// <param name="newpath"></param>
-        private void BackupFile(string path, string newpath)
+        private void BackupFile(string path, string newpath, string md5)
         {
             using (var db = new Muse())
             {
@@ -243,6 +254,7 @@ namespace Oreo.FileMan.Services
                             Size = FileTool.Size(path),
                             BackupTime = DateTimeConvert.StandardString(DateTime.Now),
                             LastWriteTime = lastwritetime,
+                            Md5 = md5,
                         });
                     }
                 }

+ 71 - 71
Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/FileRestoreForm.Designer.cs

@@ -29,14 +29,17 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
             this.BtClose = new System.Windows.Forms.Button();
             this.DgvFiles = new System.Windows.Forms.DataGridView();
+            this.DgvFilesVersion = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.DgvFilesLastWriteTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.DgvFilesSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.LbFileName = new System.Windows.Forms.Label();
             this.LbPath = new System.Windows.Forms.Label();
             this.label1 = new System.Windows.Forms.Label();
@@ -44,9 +47,6 @@
             this.LbVersion = new System.Windows.Forms.Label();
             this.BtRestoreToOld = new System.Windows.Forms.Button();
             this.BtRestoreToNew = new System.Windows.Forms.Button();
-            this.DgvFilesVersion = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.DgvFilesLastWriteTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.DgvFilesSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.panel1 = new System.Windows.Forms.Panel();
             this.panel2 = new System.Windows.Forms.Panel();
             this.TtLabel = new System.Windows.Forms.ToolTip(this.components);
@@ -62,7 +62,7 @@
             this.BtClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.BtClose.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.BtClose.ForeColor = System.Drawing.Color.White;
-            this.BtClose.Location = new System.Drawing.Point(379, 12);
+            this.BtClose.Location = new System.Drawing.Point(384, 4);
             this.BtClose.Name = "BtClose";
             this.BtClose.Size = new System.Drawing.Size(30, 23);
             this.BtClose.TabIndex = 20;
@@ -78,41 +78,41 @@
             this.DgvFiles.AllowUserToResizeRows = false;
             this.DgvFiles.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
             this.DgvFiles.BackgroundColor = System.Drawing.Color.White;
-            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
-            dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control;
-            dataGridViewCellStyle13.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.DgvFiles.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle13;
+            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
+            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.DgvFiles.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
             this.DgvFiles.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.DgvFiles.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.DgvFilesVersion,
             this.DgvFilesLastWriteTime,
             this.DgvFilesSize});
-            dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Window;
-            dataGridViewCellStyle17.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle17.ForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle17.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
-            dataGridViewCellStyle17.SelectionBackColor = System.Drawing.SystemColors.GradientActiveCaption;
-            dataGridViewCellStyle17.SelectionForeColor = System.Drawing.Color.Black;
-            dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
-            this.DgvFiles.DefaultCellStyle = dataGridViewCellStyle17;
+            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle5.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
+            dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.GradientActiveCaption;
+            dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black;
+            dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.DgvFiles.DefaultCellStyle = dataGridViewCellStyle5;
             this.DgvFiles.Dock = System.Windows.Forms.DockStyle.Fill;
             this.DgvFiles.GridColor = System.Drawing.Color.Silver;
             this.DgvFiles.Location = new System.Drawing.Point(0, 0);
             this.DgvFiles.Name = "DgvFiles";
             this.DgvFiles.ReadOnly = true;
-            dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
-            dataGridViewCellStyle18.BackColor = System.Drawing.SystemColors.Control;
-            dataGridViewCellStyle18.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle18.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.DgvFiles.RowHeadersDefaultCellStyle = dataGridViewCellStyle18;
+            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
+            dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.DgvFiles.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
             this.DgvFiles.RowHeadersVisible = false;
             this.DgvFiles.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
             this.DgvFiles.RowTemplate.Height = 23;
@@ -120,10 +120,38 @@
             this.DgvFiles.Size = new System.Drawing.Size(417, 207);
             this.DgvFiles.TabIndex = 21;
             // 
+            // DgvFilesVersion
+            // 
+            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.DgvFilesVersion.DefaultCellStyle = dataGridViewCellStyle2;
+            this.DgvFilesVersion.FillWeight = 50F;
+            this.DgvFilesVersion.HeaderText = "版本";
+            this.DgvFilesVersion.Name = "DgvFilesVersion";
+            this.DgvFilesVersion.ReadOnly = true;
+            // 
+            // DgvFilesLastWriteTime
+            // 
+            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.DgvFilesLastWriteTime.DefaultCellStyle = dataGridViewCellStyle3;
+            this.DgvFilesLastWriteTime.HeaderText = "最后修改时间";
+            this.DgvFilesLastWriteTime.Name = "DgvFilesLastWriteTime";
+            this.DgvFilesLastWriteTime.ReadOnly = true;
+            this.DgvFilesLastWriteTime.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // DgvFilesSize
+            // 
+            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+            this.DgvFilesSize.DefaultCellStyle = dataGridViewCellStyle4;
+            this.DgvFilesSize.FillWeight = 80F;
+            this.DgvFilesSize.HeaderText = "文件大小";
+            this.DgvFilesSize.Name = "DgvFilesSize";
+            this.DgvFilesSize.ReadOnly = true;
+            this.DgvFilesSize.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
             // LbFileName
             // 
             this.LbFileName.ForeColor = System.Drawing.Color.White;
-            this.LbFileName.Location = new System.Drawing.Point(90, 35);
+            this.LbFileName.Location = new System.Drawing.Point(90, 30);
             this.LbFileName.Name = "LbFileName";
             this.LbFileName.Size = new System.Drawing.Size(244, 12);
             this.LbFileName.TabIndex = 22;
@@ -132,7 +160,7 @@
             // LbPath
             // 
             this.LbPath.ForeColor = System.Drawing.Color.White;
-            this.LbPath.Location = new System.Drawing.Point(90, 58);
+            this.LbPath.Location = new System.Drawing.Point(90, 50);
             this.LbPath.Name = "LbPath";
             this.LbPath.Size = new System.Drawing.Size(244, 30);
             this.LbPath.TabIndex = 23;
@@ -142,7 +170,7 @@
             // 
             this.label1.AutoSize = true;
             this.label1.ForeColor = System.Drawing.Color.White;
-            this.label1.Location = new System.Drawing.Point(33, 35);
+            this.label1.Location = new System.Drawing.Point(33, 30);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(53, 12);
             this.label1.TabIndex = 24;
@@ -152,7 +180,7 @@
             // 
             this.label2.AutoSize = true;
             this.label2.ForeColor = System.Drawing.Color.White;
-            this.label2.Location = new System.Drawing.Point(33, 58);
+            this.label2.Location = new System.Drawing.Point(33, 50);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(41, 12);
             this.label2.TabIndex = 25;
@@ -162,7 +190,7 @@
             // 
             this.LbVersion.AutoSize = true;
             this.LbVersion.ForeColor = System.Drawing.Color.White;
-            this.LbVersion.Location = new System.Drawing.Point(362, 76);
+            this.LbVersion.Location = new System.Drawing.Point(362, 65);
             this.LbVersion.Name = "LbVersion";
             this.LbVersion.Size = new System.Drawing.Size(47, 12);
             this.LbVersion.TabIndex = 26;
@@ -188,40 +216,12 @@
             this.BtRestoreToNew.UseVisualStyleBackColor = true;
             this.BtRestoreToNew.Click += new System.EventHandler(this.BtRestoreToNew_Click);
             // 
-            // DgvFilesVersion
-            // 
-            dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
-            this.DgvFilesVersion.DefaultCellStyle = dataGridViewCellStyle14;
-            this.DgvFilesVersion.FillWeight = 50F;
-            this.DgvFilesVersion.HeaderText = "版本";
-            this.DgvFilesVersion.Name = "DgvFilesVersion";
-            this.DgvFilesVersion.ReadOnly = true;
-            // 
-            // DgvFilesLastWriteTime
-            // 
-            dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
-            this.DgvFilesLastWriteTime.DefaultCellStyle = dataGridViewCellStyle15;
-            this.DgvFilesLastWriteTime.HeaderText = "最后修改时间";
-            this.DgvFilesLastWriteTime.Name = "DgvFilesLastWriteTime";
-            this.DgvFilesLastWriteTime.ReadOnly = true;
-            this.DgvFilesLastWriteTime.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
-            // DgvFilesSize
-            // 
-            dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
-            this.DgvFilesSize.DefaultCellStyle = dataGridViewCellStyle16;
-            this.DgvFilesSize.FillWeight = 80F;
-            this.DgvFilesSize.HeaderText = "文件大小";
-            this.DgvFilesSize.Name = "DgvFilesSize";
-            this.DgvFilesSize.ReadOnly = true;
-            this.DgvFilesSize.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
             // panel1
             // 
             this.panel1.Controls.Add(this.BtRestoreToOld);
             this.panel1.Controls.Add(this.BtRestoreToNew);
             this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panel1.Location = new System.Drawing.Point(0, 299);
+            this.panel1.Location = new System.Drawing.Point(0, 288);
             this.panel1.Name = "panel1";
             this.panel1.Size = new System.Drawing.Size(417, 47);
             this.panel1.TabIndex = 30;
@@ -230,7 +230,7 @@
             // 
             this.panel2.Controls.Add(this.DgvFiles);
             this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panel2.Location = new System.Drawing.Point(0, 92);
+            this.panel2.Location = new System.Drawing.Point(0, 81);
             this.panel2.Name = "panel2";
             this.panel2.Size = new System.Drawing.Size(417, 207);
             this.panel2.TabIndex = 31;
@@ -241,7 +241,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(43)))), ((int)(((byte)(54)))));
             this.CancelButton = this.BtClose;
-            this.ClientSize = new System.Drawing.Size(417, 346);
+            this.ClientSize = new System.Drawing.Size(417, 335);
             this.Controls.Add(this.panel2);
             this.Controls.Add(this.panel1);
             this.Controls.Add(this.LbVersion);

+ 22 - 3
Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/FileRestoreForm.cs

@@ -1,4 +1,5 @@
-using Oreo.FileMan.DatabaseEngine;
+using Oreo.FileMan.Commons;
+using Oreo.FileMan.DatabaseEngine;
 using Oreo.FileMan.Models;
 using System;
 using System.Collections.Generic;
@@ -63,7 +64,17 @@ namespace Oreo.FileMan.Views
         {
             if (DgvFiles.CurrentRow != null && DgvFiles.CurrentRow.Index >= 0)
             {
-                var file = Files[DgvFiles.CurrentRow.Index];
+                BackupFiles file = Files[DgvFiles.CurrentRow.Index];
+                SaveFileDialog sfd = new SaveFileDialog();
+                sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);//设置默认目录
+                sfd.FileName = Path.GetFileName(file.FullPath);//设置默认文件名
+                sfd.Filter = "还原文件|*" + Path.GetExtension(file.FullPath);//设置默认文件类型
+                if (sfd.ShowDialog() == DialogResult.OK)
+                {
+                    string from = file.BackupFullPath;
+                    string to = sfd.FileName;
+                    File.Copy(from, to, true);
+                }
             }
         }
 
@@ -78,7 +89,15 @@ namespace Oreo.FileMan.Views
                 {
                     string from = file.BackupFullPath;
                     string to = file.FullPath;
-                    File.Copy(from, to, true);
+                    string topath = DirTool.GetFilePath(to);
+                    if (DirTool.Create(topath))
+                    {
+                        File.Copy(from, to, true);
+                    }
+                    else
+                    {
+                        MessageBox.Show(string.Format("路径:{0} 不存在,请还原到其他路径。", topath), "路径不存在");
+                    }
                 }
             }
         }

+ 101 - 37
Fork.Net/Y.Skin/YoForm/NoTitle/NoTitleForm.cs

@@ -1,19 +1,69 @@
 using System;
-using System.Collections.Generic;
 using System.ComponentModel;
-using System.Data;
 using System.Drawing;
 using System.Linq;
-using System.Text;
 using System.Windows.Forms;
+using Y.Utils.DrawUtils.ColorUtils;
 using Y.Utils.WindowsUtils.APIUtils;
 
 namespace Y.Skin.YoForm.NoTitle
 {
     public partial class NoTitleForm : Form
     {
-        private int Border = 1;
-        Color BorderColor = Color.Black;
+        #region 属性
+        //窗体边框粗细
+        private int _Border = 1;
+        [Category("Style")]
+        [Description("窗体边框粗细")]
+        [DefaultValue(typeof(int), "1")]
+        public int Border
+        {
+            get { return _Border; }
+            set
+            {
+                if (_Border != value)
+                {
+                    _Border = value;
+                    SetBorder();
+                }
+            }
+        }
+        //窗体边框颜色
+        private Color _BorderColor = Color.Black;
+        [Category("Style")]
+        [Description("窗体边框颜色")]
+        [DefaultValue(typeof(Color), "Black")]
+        public Color BorderColor
+        {
+            get { return _BorderColor; }
+            set
+            {
+                if (_BorderColor != value)
+                {
+                    _BorderColor = value;
+                    SetBorder();
+                }
+            }
+        }
+        //设置炫彩模式
+        private bool _Colorful = false;
+        [Category("Style")]
+        [Description("炫彩模式")]
+        [DefaultValue(typeof(bool), "false")]
+        public bool Colorful
+        {
+            get { return _Colorful; }
+            set
+            {
+                if (_Colorful != value)
+                {
+                    _Colorful = value;
+                    if (value) SetColorful();
+                }
+            }
+        }
+        #endregion
+
         public NoTitleForm()
         {
             InitializeComponent();
@@ -21,7 +71,9 @@ namespace Y.Skin.YoForm.NoTitle
         private void NoTitleForm_Load(object sender, EventArgs e)
         {
             SetBorder();
+            if (_Colorful) SetColorful();
         }
+
         /// <summary>
         /// 设置无标题窗口可拖动
         /// </summary>
@@ -37,41 +89,53 @@ namespace Y.Skin.YoForm.NoTitle
         /// </summary>
         protected void SetBorder()
         {
-            Label BorderTop = new Label();
-            BorderTop.BackColor = BorderColor;
-            BorderTop.Width = Width;
-            BorderTop.Height = Border;
-            Controls.Add(BorderTop);
-            BorderTop.BringToFront();
-            BorderTop.Top = 0;
-            BorderTop.Left = 0;
+            if (_Border > 0)
+            {
+                Label BorderTop = new Label();
+                BorderTop.BackColor = _BorderColor;
+                BorderTop.Width = Width;
+                BorderTop.Height = _Border;
+                Controls.Add(BorderTop);
+                BorderTop.BringToFront();
+                BorderTop.Top = 0;
+                BorderTop.Left = 0;
 
-            Label BorderBottom = new Label();
-            BorderBottom.BackColor = BorderColor;
-            BorderBottom.Width = Width;
-            BorderBottom.Height = Border;
-            Controls.Add(BorderBottom);
-            BorderBottom.BringToFront();
-            BorderBottom.Top = Height - Border;
-            BorderBottom.Left = 0;
+                Label BorderBottom = new Label();
+                BorderBottom.BackColor = _BorderColor;
+                BorderBottom.Width = Width;
+                BorderBottom.Height = _Border;
+                Controls.Add(BorderBottom);
+                BorderBottom.BringToFront();
+                BorderBottom.Top = Height - _Border;
+                BorderBottom.Left = 0;
 
-            Label BorderLeft = new Label();
-            BorderLeft.BackColor = BorderColor;
-            BorderLeft.Width = Border;
-            BorderLeft.Height = Height;
-            Controls.Add(BorderLeft);
-            BorderLeft.BringToFront();
-            BorderLeft.Top = 0;
-            BorderLeft.Left = 0;
+                Label BorderLeft = new Label();
+                BorderLeft.BackColor = _BorderColor;
+                BorderLeft.Width = _Border;
+                BorderLeft.Height = Height;
+                Controls.Add(BorderLeft);
+                BorderLeft.BringToFront();
+                BorderLeft.Top = 0;
+                BorderLeft.Left = 0;
 
-            Label BorderRight = new Label();
-            BorderRight.BackColor = BorderColor;
-            BorderRight.Width = Border;
-            BorderRight.Height = Height;
-            Controls.Add(BorderRight);
-            BorderRight.BringToFront();
-            BorderRight.Top = 0;
-            BorderRight.Left = Width - Border;
+                Label BorderRight = new Label();
+                BorderRight.BackColor = _BorderColor;
+                BorderRight.Width = _Border;
+                BorderRight.Height = Height;
+                Controls.Add(BorderRight);
+                BorderRight.BringToFront();
+                BorderRight.Top = 0;
+                BorderRight.Left = Width - _Border;
+            }
+        }
+        /// <summary>
+        /// 设置炫彩模式
+        /// </summary>
+        protected void SetColorful()
+        {
+            string[] colors = ColorStyle.Warm.Concat(ColorStyle.Silence).ToArray();
+            int index = new Random().Next(colors.Length);
+            BackColor = ColorTranslator.FromHtml(colors[index]);
         }
         protected override void OnPaint(PaintEventArgs e)
         {

+ 12 - 0
Fork.Net/Y.Utils/DataUtils/RandomUtils/RandomTool.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Y.Utils.DataUtils.RandomUtils
+{
+    public static class RandomTool
+    {
+
+    }
+}

+ 11 - 0
Fork.Net/Y.Utils/DrawUtils/ColorUtils/ColorPalette.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Y.Utils.DrawUtils.ColorUtils
+{
+    public static class ColorPalette
+    {
+    }
+}

+ 13 - 0
Fork.Net/Y.Utils/DrawUtils/ColorUtils/ColorStyle.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Y.Utils.DrawUtils.ColorUtils
+{
+    public static class ColorStyle
+    {
+        public static string[] Warm = new string[] { "#FFE957", "#F29F3F", "#F2753F", "#E87E51", "#DE8C68" };
+        public static string[] Silence = new string[] { "#81C2D6", "#8192D6", "#D9B3E6", "#DCF7A1", "#83FCD8" };
+    }
+}

+ 11 - 0
Fork.Net/Y.Utils/DrawUtils/ColorUtils/ColorTool.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Y.Utils.DrawUtils.ColorUtils
+{
+    class ColorTool
+    {
+    }
+}

+ 4 - 0
Fork.Net/Y.Utils/Y.Utils.csproj

@@ -52,9 +52,13 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AppUtils\AppUnique.cs" />
+    <Compile Include="DataUtils\RandomUtils\RandomTool.cs" />
     <Compile Include="DataUtils\StringUtils\NumberStringTool.cs" />
     <Compile Include="DelegateUtils\ProgressDelegate.cs" />
     <Compile Include="DelegateUtils\ProgressEventArgs.cs" />
+    <Compile Include="DrawUtils\ColorUtils\ColorPalette.cs" />
+    <Compile Include="DrawUtils\ColorUtils\ColorStyle.cs" />
+    <Compile Include="DrawUtils\ColorUtils\ColorTool.cs" />
     <Compile Include="IOUtils\DriveUtils\DriveTool.cs" />
     <Compile Include="IOUtils\FileManUtils\FileWatcherEventArgs.cs" />
     <Compile Include="IOUtils\FileUtils\FileCompressTool.cs" />