• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguicwindows翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

将棋ウォーズ棋譜を検索条件を指定して一括でダウンロードする。


コミットメタ情報

リビジョン13 (tree)
日時2015-01-31 15:10:41
作者bellyoshi

ログメッセージ

差分をダウンロードするように変更

変更サマリ

差分

--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmProgress.vb (revision 12)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmProgress.vb (revision 13)
@@ -15,7 +15,7 @@
1515 End Sub
1616
1717 Private Sub BackgroundWorker1_ProgressChanged(sender As System.Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
18- lblKifuFileName.Text = e.UserState
18+ lblKifuFileName.Text = String.Format("{0}", e.UserState)
1919 If downloder.IsDownloading Then
2020 Me.Text = String.Format("棋譜ダウンロード中({0}/{1})",
2121 downloder.DownLoadIndex,
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/downloder.vb (revision 12)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/downloder.vb (revision 13)
@@ -61,7 +61,8 @@
6161 Next
6262
6363 _backGroudWoker.ReportProgress(0, "ダウンロード開始")
64- For Me._gTypePairListIndex = 0 To _gTypePairList.Count - 1
64+ For i As Integer = 0 To _gTypePairList.Count - 1
65+ _gTypePairListIndex = i
6566 DownLoadsReq(_gTypePairList(Me._gTypePairListIndex))
6667 Next
6768 IsComplete = True
@@ -72,8 +73,8 @@
7273
7374 cc = New System.Net.CookieContainer()
7475
75- Dim webreq As System.Net.HttpWebRequest = _
76- System.Net.WebRequest.Create(baseUrl)
76+ Dim webreq As System.Net.HttpWebRequest = DirectCast(
77+ System.Net.WebRequest.Create(baseUrl), System.Net.HttpWebRequest)
7778 webreq.CookieContainer = cc
7879 Dim webres As System.Net.WebResponse = webreq.GetResponse()
7980 Dim st As System.IO.Stream = webres.GetResponseStream()
@@ -106,7 +107,7 @@
106107 If backGroudWoker.CancellationPending Then
107108 Throw New CancelException
108109 End If
109- _backGroudWoker.ReportProgress(DownLoadIndex / DownLoadsCount, String.Format("{0}", link.Text))
110+ _backGroudWoker.ReportProgress(DownLoadIndex \ DownLoadsCount, String.Format("{0}", link.Text))
110111 DownLoadOneLink(wc, link, dirfullpath)
111112 p.DownloadIndexOfList += 1
112113 Next
@@ -140,6 +141,11 @@
140141
141142 Private Sub ListPageReadReq(ByVal p As gTypeDirectoryPair)
142143
144+ Dim dirfullpath As String = p.saveDirectoryPathName
145+ If Not IOUtil.CreateDirectoryIfNotExist(dirfullpath) Then
146+ _backGroudWoker.ReportProgress(0, String.Format("ディレクトリ""{0}""が作成できません", dirfullpath))
147+ Exit Sub
148+ End If
143149 Dim ps As New Hashtable
144150 ps.Add("csrfmiddlewaretoken", csrfmiddlewaretoken)
145151 ps.Add("name1", _name1)
@@ -150,11 +156,23 @@
150156
151157 Dim resText As String = HttpPostUtl.HttpPost(baseUrl, ps, cc, encoder)
152158 p.DownloadIndexOfList = 0
153- p.List = GetLinks(resText)
154- 'Todo フォルダ上にあるファイルをリスト上から削除
159+ Dim allList As IList(Of aLink) = GetLinks(resText)
160+ Dim existsList As IList(Of String) = IOUtil.GetFileNames(p.saveDirectoryPathName)
161+ p.List = GetRemovedList(allList, existsList)
155162
156163 End Sub
157164
165+ Private Function GetRemovedList(ByVal source As IList(Of aLink), ByVal target As IList(Of String)) As IList(Of aLink)
166+ Dim newList As New List(Of aLink)
167+ For Each s As aLink In source
168+ If Not target.Contains(s.Text) Then
169+ newList.Add(s)
170+ End If
171+ Next
172+ Return newList
173+ End Function
174+
175+
158176 Private Function GetLinks(ByVal text As String) As IList(Of aLink)
159177
160178 Dim mc As System.Text.RegularExpressions.MatchCollection =
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmCondtion.vb (revision 12)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmCondtion.vb (revision 13)
@@ -1,15 +1,37 @@
11 Public Class frmCondtion
22
33
4- Private Sub btnDownload_Click(sender As System.Object, e As System.EventArgs) Handles btnDownload.Click
5- If txt10minSaveDirectory.Text = String.Empty Then
4+ Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
5+
6+ If chk10min.Checked AndAlso
7+ txt10minSaveDirectory.Text = String.Empty Then
68 MessageBox.Show("保存先を選択してください。")
79 Exit Sub
810 End If
11+
12+ If chk3min.Checked AndAlso
13+ txt3minSaveDirectory.Text = String.Empty Then
14+ MessageBox.Show("保存先を選択してください。")
15+ Exit Sub
16+ End If
17+
18+ If chk10sec.Checked AndAlso
19+ txt10secSaveDirectory.Text = String.Empty Then
20+ MessageBox.Show("保存先を選択してください。")
21+ Exit Sub
22+ End If
23+
24+ If chkAnimal.Checked AndAlso
25+ txtAnimalSaveDirectory.Text = String.Empty Then
26+ MessageBox.Show("保存先を選択してください。")
27+ Exit Sub
28+ End If
29+
930 If txtName1.Text = String.Empty AndAlso
1031 txtName2.Text = String.Empty Then
1132 MessageBox.Show("対局者をどちらか入力してください。")
1233 End If
34+
1335 If Not chk10min.Checked AndAlso
1436 Not chk3min.Checked AndAlso
1537 Not chk10sec.Checked AndAlso
@@ -23,7 +45,7 @@
2345 txtName1.Text,
2446 txtName2.Text)
2547 SetGTypeDirectoryPairTo(downloder)
26- frm.downLoder = downloder
48+ frm.downloder = downloder
2749 frm.ShowDialog()
2850
2951 End Sub
@@ -85,6 +107,30 @@
85107 chkAnimal.Checked = chkAll.Checked
86108 End Sub
87109
110+ Private Sub chk10min_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chk10min.CheckedChanged
111+ If Not chk10min.Checked Then
112+ chkAll.Checked = False
113+ End If
114+ End Sub
115+
116+ Private Sub chk3min_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chk3min.CheckedChanged
117+ If Not chk3min.Checked Then
118+ chkAll.Checked = False
119+ End If
120+ End Sub
121+
122+ Private Sub chk10sec_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chk10sec.CheckedChanged
123+ If Not chk10sec.Checked Then
124+ chkAll.Checked = False
125+ End If
126+ End Sub
127+
128+ Private Sub chkAnimal_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkAnimal.CheckedChanged
129+ If Not chkAnimal.Checked Then
130+ chkAll.Checked = False
131+ End If
132+ End Sub
133+
88134 Private Sub frmCondtion_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
89135 SettingSave()
90136 End Sub
@@ -122,4 +168,6 @@
122168 .Save()
123169 End With
124170 End Sub
171+
172+
125173 End Class
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/IOUtil.vb (revision 12)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/IOUtil.vb (revision 13)
@@ -16,4 +16,20 @@
1616 End If
1717 Return True
1818 End Function
19+
20+ ''' <summary>
21+ ''' フォルダの中にあるファイル名の一覧を返す。
22+ ''' </summary>
23+ ''' <param name="directoryPath"></param>
24+ ''' <returns></returns>
25+ ''' <remarks></remarks>
26+ Public Shared Function GetFileNames(ByVal directoryPath As String) As IList(Of String)
27+ Dim fileFullPathNames As String() = System.IO.Directory.GetFiles(
28+ directoryPath, "*", System.IO.SearchOption.TopDirectoryOnly)
29+ Dim fileNames As New List(Of String)
30+ For Each path As String In fileFullPathNames
31+ fileNames.Add(IO.Path.GetFileName(path))
32+ Next
33+ Return fileNames
34+ End Function
1935 End Class