Skip to content

Commit

Permalink
20200322
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Mar 22, 2020
1 parent 757ea89 commit d3db7ac
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions CSManager/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ private void saveDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
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);
Expand Down Expand Up @@ -764,7 +764,7 @@ private void saveDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
/// <param name="e"></param>
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)
{//適切にダウンロードされている場合
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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}");
}
Expand All @@ -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();

/// <summary>
Expand Down

0 comments on commit d3db7ac

Please sign in to comment.