From d3db7ac4ece334520dfcc1d75427fb3d8d76211e Mon Sep 17 00:00:00 2001 From: seto Date: Sun, 22 Mar 2020 19:32:45 +0900 Subject: [PATCH] 20200322 --- CSManager/FormMain.cs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/CSManager/FormMain.cs b/CSManager/FormMain.cs index e747552..08385d5 100644 --- a/CSManager/FormMain.cs +++ b/CSManager/FormMain.cs @@ -702,7 +702,7 @@ private void saveDatabaseToolStripMenuItem_Click(object sender, EventArgs e) /// /// /// - private (bool Valid, int DataNum, int FileNum, long[] FileSizes, byte[][] CheckSum) checkDatabaseFiles(string path, bool checkValidity) + private (bool Valid, int DataNum, int FileNum, long[] FileSizes, byte[][] CheckSums) checkDatabaseFiles(string path, bool checkValidity) { stopwatch.Restart(); var nameWithoutExt = Path.GetFileNameWithoutExtension(path); @@ -764,7 +764,7 @@ private void saveDatabaseToolStripMenuItem_Click(object sender, EventArgs e) /// private void toolStripMenuItemReadDefault2_Click(object sender, EventArgs e) { - var (Valid, DataNum, FileNum, FileSizes, CheckSum) = checkDatabaseFiles(UserAppDataPath + "COD.cdb3", true); + var (Valid, DataNum, FileNum, FileSizes, CheckSums) = checkDatabaseFiles(UserAppDataPath + "COD.cdb3", true); string urlHeader = "https://github.com/seto77/CSManager/raw/master/COD/"; if (Valid) {//適切にダウンロードされている場合 @@ -808,9 +808,12 @@ private void toolStripMenuItemReadDefault2_Click(object sender, EventArgs e) { stopwatch.Restart(); new WebClient().DownloadFile(new Uri(urlHeader + "COD.cdb3"), UserAppDataPath + "COD.cdb3"); + Directory.CreateDirectory(UserAppDataPath + "COD"); - new WebClient().DownloadFile(new Uri(urlHeader + "COD/CheckSum"), UserAppDataPath + "COD\\CheckSum"); - (_, DataNum, FileNum, FileSizes, CheckSum) = checkDatabaseFiles(UserAppDataPath + "COD.cdb3", false); + + (_, DataNum, FileNum, FileSizes, CheckSums) = checkDatabaseFiles(UserAppDataPath + "COD.cdb3", false); + + var wc = new WebClient[FileNum]; var total = FileSizes.Sum(); @@ -838,6 +841,7 @@ private void toolStripMenuItemReadDefault2_Click(object sender, EventArgs e) readDatabase(UserAppDataPath + "COD.cdb3");//読み込む }; } + for (int i = 0; i < wc.Length; i++) wc[i].DownloadFileAsync(new Uri($"{urlHeader}COD/COD.{i:000}"), $"{UserAppDataPath}COD\\COD.{i:000}"); } @@ -847,19 +851,6 @@ private void toolStripMenuItemReadDefault2_Click(object sender, EventArgs e) } } - private long GetFileSize(string url) - { - var request = (HttpWebRequest)WebRequest.Create(new Uri(url)); - request.Method = "HEAD"; // ヘッダーのみ要求 - request.Timeout = 10000; - return (request.GetResponse() as HttpWebResponse).ContentLength; - } - - private void FormMain_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) - { - throw new NotImplementedException(); - } - private void importAllCrystalsMenuItem_Click(object sender, EventArgs e) => GetAllImport(); ///