-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
更改备份方式 修复代码上传存在的问题 修复数据库无法使用
- Loading branch information
Showing
12 changed files
with
121 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,30 @@ | ||
using ColoryrServer.Core.FileSystem; | ||
using ICSharpCode.SharpZipLib.Zip; | ||
using MySql.Data.MySqlClient; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
Stopwatch stopwatch = new(); | ||
stopwatch.Start(); | ||
var Conn = new MySqlConnection("SslMode=none;Server=127.0.0.1;Port=3306;User ID=root;Password=123456;Charset=utf8;Pooling=false;"); | ||
Conn.Open(); | ||
stopwatch.Stop(); | ||
Console.WriteLine(stopwatch.Elapsed); | ||
|
||
MySqlCommand Sql = new MySqlCommand("select * from citypipeerror"); | ||
|
||
Sql.Connection = Conn; | ||
Sql.Connection.ChangeDatabase("citypipe"); | ||
MySqlDataReader reader = Sql.ExecuteReader(); | ||
var readlist = new List<List<dynamic>>(); | ||
var readlist1 = new List<Dictionary<string, dynamic>>(); | ||
while (reader.Read()) | ||
var dir = AppContext.BaseDirectory + "test\\"; | ||
if (!Directory.Exists(dir)) | ||
{ | ||
Directory.CreateDirectory(dir); | ||
} | ||
ZipFile zip; | ||
if (!File.Exists(dir + "backup.zip")) | ||
{ | ||
var item = new List<dynamic>(); | ||
var item1 = new Dictionary<string, dynamic>(); | ||
var data = reader.GetSchemaTable(); | ||
for (int b = 0; b < reader.FieldCount; b++) | ||
{ | ||
item1.Add(data.Rows[b][0] as string, reader[b]); | ||
item.Add(reader[b]); | ||
} | ||
readlist1.Add(item1); | ||
readlist.Add(item); | ||
ZipOutputStream s = new(File.Create(dir + "backup.zip")); | ||
s.Close(); | ||
} | ||
reader.Close(); | ||
Sql.Connection.Close(); | ||
zip = new ZipFile(dir + "backup.zip"); | ||
var dir1 = AppContext.BaseDirectory + "test\\test\\"; | ||
zip.BeginUpdate(); | ||
foreach (var item in new DirectoryInfo(dir1).GetFiles()) | ||
{ | ||
zip.Add(item.FullName, item.Name); | ||
} | ||
zip.CommitUpdate(); | ||
zip.Close(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using ICSharpCode.SharpZipLib.Zip; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ColoryrBuild | ||
{ | ||
internal class ZIPUtils | ||
{ | ||
public static void Pack(string dir, string file, string name) | ||
{ | ||
ZipFile zip; | ||
if (!File.Exists(dir + "backup.zip")) | ||
{ | ||
ZipOutputStream s = new(File.Create(dir + "backup.zip")); | ||
s.Close(); | ||
} | ||
zip = new ZipFile(dir + "backup.zip"); | ||
zip.BeginUpdate(); | ||
zip.Add(file, name); | ||
zip.CommitUpdate(); | ||
zip.Close(); | ||
} | ||
|
||
public static void Pack1(string dir, string dir1, string name) | ||
{ | ||
ZipFile zip; | ||
if (!File.Exists(dir + "backup.zip")) | ||
{ | ||
ZipOutputStream s = new(File.Create(dir + "backup.zip")); | ||
s.Close(); | ||
} | ||
zip = new ZipFile(dir + "backup.zip"); | ||
zip.BeginUpdate(); | ||
zip.AddDirectory(name); | ||
foreach (var item in new DirectoryInfo(dir1).GetFiles()) | ||
{ | ||
zip.Add(item.FullName, name + "/" + item.Name); | ||
} | ||
zip.CommitUpdate(); | ||
zip.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters