Horizon – Diff between revs 24 and 27
?pathlinks?
Rev 24 | Rev 27 | |||
---|---|---|---|---|
Line 33... | Line 33... | |||
33 | |
33 | |
|
Line 34... | Line 34... | |||
34 | private static ScheduledContinuation _searchTextBoxChangedContinuation; |
34 | private static ScheduledContinuation _searchTextBoxChangedContinuation; |
|
Line 35... | Line -... | |||
35 | |
- | ||
36 | #endregion |
- | ||
37 | |
- | ||
38 | #region Public Events & Delegates |
- | ||
39 | |
- | ||
40 | public event EventHandler<PreviewRetrievedEventArgs> PreviewRetrieved; |
- | ||
41 | |
35 | |
|
Line 42... | Line 36... | |||
42 | #endregion |
36 | #endregion |
|
Line 43... | Line 37... | |||
43 | |
37 | |
|
Line 44... | Line 38... | |||
44 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
38 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
|
Line 45... | Line 39... | |||
45 | |
39 | |
|
Line 46... | Line 40... | |||
46 | private readonly MainForm _mainForm; |
40 | private readonly MainForm _mainForm; |
|
Line 47... | Line 41... | |||
47 | |
41 | |
|
Line 269... | Line 263... | |||
269 | |
263 | |
|
270 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
264 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
271 | { |
265 | { |
|
272 | try |
266 | try |
|
273 | { |
- | ||
274 | var fileStream = await _snapshotDatabase.RetrieveFileStreamAsync( |
267 | { |
|
- | 268 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
275 | (string)rows[i].Cells["HashColumn"].Value, |
269 | |
|
Line 276... | Line 270... | |||
276 | cancellationToken); |
270 | var fileStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, cancellationToken); |
|
277 | |
271 | |
|
278 | progress.Report(new DataGridViewRowProgressSuccessRetrieveFileStream(rows[i], i, fileStream)); |
272 | progress.Report(new DataGridViewRowProgressSuccessRetrieveFileStream(rows[i], i, fileStream)); |
|
279 | } |
273 | } |
|
Line 284... | Line 278... | |||
284 | } |
278 | } |
|
285 | } |
279 | } |
|
Line 286... | Line 280... | |||
286 | |
280 | |
|
287 | private void SnapshotManagerForm_Resize(object sender, EventArgs e) |
281 | private void SnapshotManagerForm_Resize(object sender, EventArgs e) |
|
288 | { |
282 | { |
|
289 | if (_snapshotPreviewForm != null) |
283 | if (_snapshotPreviewForm is { Visible: true }) |
|
290 | { |
284 | { |
|
291 | _snapshotPreviewForm.WindowState = WindowState; |
285 | _snapshotPreviewForm.WindowState = WindowState; |
|
292 | } |
286 | } |
|
Line 301... | Line 295... | |||
301 | } |
295 | } |
|
Line 302... | Line 296... | |||
302 | |
296 | |
|
303 | Process.Start("explorer.exe", $"/select, \"{(string)row.Cells["PathColumn"].Value}\""); |
297 | Process.Start("explorer.exe", $"/select, \"{(string)row.Cells["PathColumn"].Value}\""); |
|
Line 304... | Line 298... | |||
304 | } |
298 | } |
|
305 | |
299 | |
|
306 | private async void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) |
300 | private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) |
|
Line 307... | Line -... | |||
307 | { |
- | ||
308 | var dataGridView = (DataGridView)sender; |
- | ||
309 | |
- | ||
310 | if (_snapshotPreviewForm == null) |
- | ||
311 | { |
- | ||
312 | _snapshotPreviewForm = new SnapshotPreviewForm(this, _snapshotDatabase); |
- | ||
313 | _snapshotPreviewForm.Owner = this; |
- | ||
314 | _snapshotPreviewForm.Closing += SnapshotPreviewForm_Closing; |
- | ||
315 | _snapshotPreviewForm.Show(); |
301 | { |
|
316 | } |
302 | var dataGridView = (DataGridView)sender; |
|
317 | |
303 | |
|
318 | var row = GetSelectedDataGridViewRows(dataGridView).FirstOrDefault(); |
304 | var row = GetSelectedDataGridViewRows(dataGridView).FirstOrDefault(); |
|
319 | if (row == null) |
305 | if (row == null) |
|
Line 320... | Line 306... | |||
320 | { |
306 | { |
|
Line 321... | Line -... | |||
321 | return; |
- | ||
322 | } |
- | ||
323 | |
- | ||
324 | var hash = (string)row.Cells["HashColumn"].Value; |
- | ||
325 | |
307 | return; |
|
326 | var snapshotPreview = |
308 | } |
|
327 | await Task.Run(async () => await _snapshotDatabase.RetrievePreviewAsync(hash, _cancellationToken), |
309 | |
|
328 | _cancellationToken); |
310 | var hash = (string)row.Cells["HashColumn"].Value; |
|
Line 329... | Line 311... | |||
329 | |
311 | |
|
- | 312 | if (_snapshotPreviewForm is { Visible: true }) |
||
- | 313 | { |
||
- | 314 | _snapshotPreviewForm.Close(); |
||
330 | if (snapshotPreview == null) |
315 | } |
|
Line 331... | Line 316... | |||
331 | { |
316 | |
|
332 | return; |
317 | _snapshotPreviewForm = new SnapshotPreviewForm(this, hash, _snapshotDatabase, _cancellationToken); |
|
333 | } |
318 | _snapshotPreviewForm.Owner = this; |
|
334 | |
319 | _snapshotPreviewForm.Closing += SnapshotPreviewForm_Closing; |
|
335 | PreviewRetrieved?.Invoke(this, new PreviewRetrievedEventArgs(snapshotPreview)); |
320 | _snapshotPreviewForm.Show(); |
|
336 | } |
321 | } |
|
Line -... | Line 322... | |||
- | 322 | |
||
337 | |
323 | private void SnapshotPreviewForm_Closing(object sender, CancelEventArgs e) |
|
338 | private void SnapshotPreviewForm_Closing(object sender, CancelEventArgs e) |
- | ||
339 | { |
324 | { |
|
Line 340... | Line 325... | |||
340 | if (_snapshotPreviewForm == null) |
325 | if (_snapshotPreviewForm is { Visible: false }) |
|
341 | { |
326 | { |
|
342 | return; |
327 | return; |
|
Line 647... | Line 632... | |||
647 | private async void SnapshotManagerForm_Load(object sender, EventArgs e) |
632 | private async void SnapshotManagerForm_Load(object sender, EventArgs e) |
|
648 | { |
633 | { |
|
649 | // Start browsing for network services. |
634 | // Start browsing for network services. |
|
650 | _horizonServiceBrowser.Browse("_horizon._tcp", "local"); |
635 | _horizonServiceBrowser.Browse("_horizon._tcp", "local"); |
|
Line -... | Line 636... | |||
- | 636 | |
||
- | 637 | int count; |
||
- | 638 | try |
||
- | 639 | { |
||
- | 640 | count = (int)await _snapshotDatabase.CountSnapshotsAsync(_cancellationToken); |
||
- | 641 | } |
||
- | 642 | catch (Exception exception) |
||
- | 643 | { |
||
- | 644 | Log.Error(exception, "Could not count snapshots."); |
||
- | 645 | return; |
||
- | 646 | } |
||
- | 647 | |
||
- | 648 | if (count == 0) |
||
- | 649 | { |
||
- | 650 | return; |
||
- | 651 | } |
||
651 | |
652 | |
|
652 | // Load snapshots. |
653 | // Load snapshots. |
|
653 | toolStripProgressBar1.Minimum = 0; |
654 | toolStripProgressBar1.Minimum = 0; |
|
Line 654... | Line 655... | |||
654 | toolStripProgressBar1.Maximum = (int)await _snapshotDatabase.CountSnapshotsAsync(_cancellationToken); |
655 | toolStripProgressBar1.Maximum = count; |
|
Line 655... | Line 656... | |||
655 | |
656 | |
|
656 | var snapshotQueue = new ConcurrentQueue<Snapshot>(); |
657 | var snapshotQueue = new ConcurrentQueue<Snapshot>(); |
|
Line 789... | Line 790... | |||
789 | |
790 | |
|
790 | private void SnapshotManagerForm_Closing(object sender, FormClosingEventArgs e) |
791 | private void SnapshotManagerForm_Closing(object sender, FormClosingEventArgs e) |
|
791 | { |
792 | { |
|
Line 792... | Line 793... | |||
792 | _cancellationTokenSource.Cancel(); |
793 | _cancellationTokenSource.Cancel(); |
|
793 | |
794 | |
|
794 | if (_snapshotPreviewForm != null) |
795 | if (_snapshotPreviewForm is { Visible: true }) |
|
795 | { |
- | ||
796 | _snapshotPreviewForm.Close(); |
796 | { |
|
Line 797... | Line 797... | |||
797 | _snapshotPreviewForm = null; |
797 | _snapshotPreviewForm.Close(); |
|
798 | } |
798 | } |
|
799 | |
799 | |
|
800 | if (_hexViewForm != null) |
- | ||
801 | { |
800 | if (_hexViewForm is { Visible: true }) |
|
802 | _hexViewForm.Close(); |
801 | { |
|
Line 803... | Line 802... | |||
803 | _hexViewForm = null; |
802 | _hexViewForm.Close(); |
|
804 | } |
803 | } |
|
Line 833... | Line 832... | |||
833 | var name = Path.GetFileName(directoryFile); |
832 | var name = Path.GetFileName(directoryFile); |
|
834 | var path = Path.Combine(Path.GetDirectoryName(directoryFile), name); |
833 | var path = Path.Combine(Path.GetDirectoryName(directoryFile), name); |
|
Line 835... | Line 834... | |||
835 | |
834 | |
|
836 | try |
835 | try |
|
837 | { |
836 | { |
|
838 | await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color, |
- | ||
Line 839... | Line 837... | |||
839 | _cancellationToken); |
837 | await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color, _cancellationToken); |
|
840 | |
838 | |
|
841 | progress.Report(new CreateSnapshotProgressSuccess(file)); |
839 | progress.Report(new CreateSnapshotProgressSuccess(file)); |
|
842 | } |
840 | } |
|
Line 848... | Line 846... | |||
848 | |
846 | |
|
849 | return; |
847 | return; |
|
Line 850... | Line 848... | |||
850 | } |
848 | } |
|
- | 849 | |
||
851 | |
850 | var fileName = Path.GetFileName(file); |
|
Line 852... | Line 851... | |||
852 | var fileName = Path.GetFileName(file); |
851 | |
|
853 | var pathName = Path.Combine(Path.GetDirectoryName(file), fileName); |
852 | var pathName = Path.Combine(Path.GetDirectoryName(file), fileName); |
|
854 | |
853 | |
|
Line 1042... | Line 1041... | |||
1042 | toolStripProgressBar1.Value = toolStripProgressBar1.Maximum; |
1041 | toolStripProgressBar1.Value = toolStripProgressBar1.Maximum; |
|
1043 | toolStripStatusLabel1.Text = "Done."; |
1042 | toolStripStatusLabel1.Text = "Done."; |
|
1044 | } |
1043 | } |
|
1045 | } |
1044 | } |
|
Line 1046... | Line 1045... | |||
1046 | |
1045 | |
|
1047 | private async void NoteToolStripMenuItem_Click(object sender, EventArgs e) |
1046 | private void NoteToolStripMenuItem_Click(object sender, EventArgs e) |
|
1048 | { |
- | ||
1049 | if (_snapshotNote != null) |
- | ||
1050 | { |
- | ||
1051 | return; |
- | ||
1052 | } |
- | ||
1053 | |
1047 | { |
|
1054 | var row = GetSelectedDataGridViewRows(dataGridView1).FirstOrDefault(); |
1048 | var row = GetSelectedDataGridViewRows(dataGridView1).FirstOrDefault(); |
|
1055 | if (row == null) |
1049 | if (row == null) |
|
1056 | { |
1050 | { |
|
1057 | return; |
1051 | return; |
|
Line 1058... | Line -... | |||
1058 | } |
- | ||
1059 | |
- | ||
1060 | try |
- | ||
1061 | { |
1052 | } |
|
1062 | var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync( |
- | ||
1063 | (string)row.Cells["HashColumn"].Value, _cancellationToken); |
- | ||
1064 | |
- | ||
1065 | if (snapshotPreview == null) |
- | ||
1066 | { |
- | ||
Line 1067... | Line -... | |||
1067 | return; |
- | ||
1068 | } |
1053 | |
|
1069 | |
- | ||
1070 | _snapshotNote = new SnapshotNoteForm(this, snapshotPreview); |
- | ||
1071 | _snapshotNote.Owner = this; |
- | ||
1072 | _snapshotNote.SaveNote += SnapshotNote_SaveNote; |
- | ||
1073 | _snapshotNote.Closing += SnapshotNote_Closing; |
- | ||
1074 | _snapshotNote.Show(); |
1054 | var hash = (string)row.Cells["HashColumn"].Value; |
|
1075 | } |
1055 | |
|
1076 | catch (Exception exception) |
1056 | if (_snapshotNoteForm is { Visible: true }) |
|
- | 1057 | { |
||
- | 1058 | _snapshotNoteForm.Close(); |
||
- | 1059 | } |
||
- | 1060 | |
||
- | 1061 | _snapshotNoteForm = new SnapshotNoteForm(hash, _snapshotDatabase, _cancellationToken); |
||
- | 1062 | _snapshotNoteForm.Owner = this; |
||
1077 | { |
1063 | _snapshotNoteForm.SaveNote += SnapshotNoteFormSaveNoteForm; |
|
Line 1078... | Line 1064... | |||
1078 | Log.Error(exception, "Could not open notes form."); |
1064 | _snapshotNoteForm.Closing += SnapshotNoteForm_Closing; |
|
1079 | } |
1065 | _snapshotNoteForm.Show(); |
|
1080 | } |
1066 | } |
|
Line 1081... | Line 1067... | |||
1081 | |
1067 | |
|
Line 1117... | Line 1103... | |||
1117 | toolStripProgressBar1.Value = toolStripProgressBar1.Maximum; |
1103 | toolStripProgressBar1.Value = toolStripProgressBar1.Maximum; |
|
1118 | toolStripStatusLabel1.Text = "Done."; |
1104 | toolStripStatusLabel1.Text = "Done."; |
|
1119 | } |
1105 | } |
|
1120 | } |
1106 | } |
|
Line 1121... | Line 1107... | |||
1121 | |
1107 | |
|
1122 | private void SnapshotNote_Closing(object sender, CancelEventArgs e) |
1108 | private void SnapshotNoteForm_Closing(object sender, CancelEventArgs e) |
|
1123 | { |
1109 | { |
|
1124 | if (_snapshotNote == null) |
1110 | if (_snapshotNoteForm is { Visible: false }) |
|
1125 | { |
1111 | { |
|
1126 | return; |
1112 | return; |
|
Line 1127... | Line 1113... | |||
1127 | } |
1113 | } |
|
1128 | |
1114 | |
|
1129 | _snapshotNote.Closing -= SnapshotNote_Closing; |
1115 | _snapshotNoteForm.SaveNote -= SnapshotNoteFormSaveNoteForm; |
|
1130 | _snapshotNote.Close(); |
1116 | _snapshotNoteForm.Closing -= SnapshotNoteForm_Closing; |
|
Line 1131... | Line 1117... | |||
1131 | _snapshotNote = null; |
1117 | _snapshotNoteForm.Dispose(); |
|
1132 | } |
1118 | } |
|
1133 | |
1119 | |
|
1134 | private async void ViewHexToolStripMenuItem_Click(object sender, EventArgs e) |
1120 | private void ViewHexToolStripMenuItem_Click(object sender, EventArgs e) |
|
1135 | { |
1121 | { |
|
1136 | var rows = GetSelectedDataGridViewRows(dataGridView1); |
1122 | var rows = GetSelectedDataGridViewRows(dataGridView1); |
|
1137 | var row = rows.FirstOrDefault(); |
1123 | var row = rows.FirstOrDefault(); |
|
1138 | if (row == null) |
1124 | if (row == null) |
|
Line 1139... | Line 1125... | |||
1139 | { |
1125 | { |
|
Line 1140... | Line 1126... | |||
1140 | return; |
1126 | return; |
|
1141 | } |
1127 | } |
|
1142 | |
- | ||
1143 | var hash = (string)row.Cells["HashColumn"].Value; |
- | ||
1144 | |
- | ||
1145 | using (var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, _cancellationToken)) |
- | ||
1146 | { |
- | ||
1147 | if (memoryStream == null) |
- | ||
1148 | { |
- | ||
1149 | return; |
- | ||
1150 | } |
- | ||
1151 | |
- | ||
1152 | if (_hexViewForm != null) |
- | ||
1153 | { |
- | ||
1154 | _hexViewForm.UpdateData(memoryStream.ToArray()); |
- | ||
1155 | _hexViewForm.Activate(); |
- | ||
1156 | return; |
- | ||
1157 | } |
- | ||
1158 | |
- | ||
1159 | _hexViewForm = new HexViewForm(_snapshotDatabase, hash, memoryStream.ToArray()); |
1128 | |
|
1160 | _hexViewForm.Owner = this; |
1129 | var hash = (string)row.Cells["HashColumn"].Value; |
|
- | 1130 | |
||
- | 1131 | if (_hexViewForm is { Visible: true }) |
||
- | 1132 | { |
||
- | 1133 | _hexViewForm.Close(); |
||
- | 1134 | } |
||
- | 1135 | |
||
1161 | _hexViewForm.Closing += HexViewForm_Closing; |
1136 | _hexViewForm = new HexViewForm(hash, _snapshotDatabase, _cancellationToken); |
|
Line 1162... | Line 1137... | |||
1162 | _hexViewForm.SaveData += HexViewForm_SaveData; |
1137 | _hexViewForm.Owner = this; |
|
1163 | |
1138 | _hexViewForm.Closing += HexViewForm_Closing; |
|
- | 1139 | _hexViewForm.SaveData += HexViewForm_SaveData; |
||
- | 1140 | _hexViewForm.Show(); |
||
- | 1141 | } |
||
- | 1142 | |
||
1164 | _hexViewForm.Show(); |
1143 | private async void HexViewForm_SaveData(object sender, SaveDataEventArgs e) |
|
- | 1144 | { |
||
- | 1145 | string hash; |
||
- | 1146 | |
||
- | 1147 | try |
||
- | 1148 | { |
||
- | 1149 | hash = await _snapshotDatabase.UpdateFileAsync(e.Hash, e.Data, _cancellationToken); |
||
Line 1165... | Line 1150... | |||
1165 | } |
1150 | } |
|
1166 | } |
1151 | catch (Exception exception) |
|
1167 | |
1152 | { |
|
1168 | private async void HexViewForm_SaveData(object sender, SaveDataEventArgs e) |
1153 | Log.Error(exception, "Could not update snapshot data."); |
|
Line 1201... | Line 1186... | |||
1201 | }); |
1186 | }); |
|
1202 | } |
1187 | } |
|
Line 1203... | Line 1188... | |||
1203 | |
1188 | |
|
1204 | private void HexViewForm_Closing(object sender, CancelEventArgs e) |
1189 | private void HexViewForm_Closing(object sender, CancelEventArgs e) |
|
1205 | { |
1190 | { |
|
1206 | if (_hexViewForm == null) |
1191 | if (_hexViewForm is { Visible: false }) |
|
1207 | { |
1192 | { |
|
1208 | return; |
1193 | return; |
|
Line 1209... | Line 1194... | |||
1209 | } |
1194 | } |
|
1210 | |
1195 | |
|
1211 | _hexViewForm.SaveData -= HexViewForm_SaveData; |
1196 | _hexViewForm.SaveData -= HexViewForm_SaveData; |
|
1212 | _hexViewForm.Closing -= HexViewForm_Closing; |
- | ||
1213 | _hexViewForm.Close(); |
1197 | _hexViewForm.Closing -= HexViewForm_Closing; |
|
Line 1214... | Line 1198... | |||
1214 | _hexViewForm = null; |
1198 | _hexViewForm.Dispose(); |
|
1215 | } |
1199 | } |
|
1216 | |
1200 | |
|
Line 1490... | Line 1474... | |||
1490 | |
1474 | |
|
1491 | for (var index = 0; index < count && !cancellationToken.IsCancellationRequested; ++index) |
1475 | for (var index = 0; index < count && !cancellationToken.IsCancellationRequested; ++index) |
|
1492 | { |
1476 | { |
|
1493 | try |
1477 | try |
|
1494 | { |
1478 | { |
|
- | 1479 | var hash = (string)rows[index].Cells["HashColumn"].Value; |
||
1495 | await _snapshotDatabase.RemoveFileAsync((string)rows[index].Cells["HashColumn"].Value, |
1480 | |
|
Line 1496... | Line 1481... | |||
1496 | cancellationToken); |
1481 | await _snapshotDatabase.RemoveFileAsync(hash, cancellationToken); |
|
1497 | |
1482 | |
|
1498 | progress.Report(new DataGridViewRowProgressSuccess(rows[index], index)); |
1483 | progress.Report(new DataGridViewRowProgressSuccess(rows[index], index)); |
|
1499 | } |
1484 | } |
|
Line 1506... | Line 1491... | |||
1506 | |
1491 | |
|
1507 | private async Task DeleteFilesFast(IReadOnlyList<DataGridViewRow> rows, CancellationToken cancellationToken) |
1492 | private async Task DeleteFilesFast(IReadOnlyList<DataGridViewRow> rows, CancellationToken cancellationToken) |
|
1508 | { |
1493 | { |
|
Line -... | Line 1494... | |||
- | 1494 | var hashes = rows.Select(row => (string)row.Cells["HashColumn"].Value); |
||
- | 1495 | |
||
1509 | var hashes = rows.Select(row => (string)row.Cells["HashColumn"].Value); |
1496 | try |
|
- | 1497 | { |
||
- | 1498 | await _snapshotDatabase.RemoveFileFastAsync(hashes, cancellationToken); |
||
- | 1499 | } |
||
- | 1500 | catch (Exception exception) |
||
- | 1501 | { |
||
1510 | |
1502 | Log.Error(exception, "Failed to remove files."); |
|
Line 1511... | Line 1503... | |||
1511 | await _snapshotDatabase.RemoveFileFastAsync(hashes, cancellationToken); |
1503 | } |
|
1512 | } |
1504 | } |
|
1513 | |
1505 | |
|
Line 1518... | Line 1510... | |||
1518 | |
1510 | |
|
1519 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1511 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1520 | { |
1512 | { |
|
1521 | try |
1513 | try |
|
1522 | { |
1514 | { |
|
- | 1515 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1523 | await _snapshotDatabase.UpdateNoteAsync((string)rows[i].Cells["HashColumn"].Value, note, |
1516 | |
|
Line 1524... | Line 1517... | |||
1524 | cancellationToken); |
1517 | await _snapshotDatabase.UpdateNoteAsync(hash, note,cancellationToken); |
|
1525 | |
1518 | |
|
1526 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1519 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
1527 | } |
1520 | } |
|
Line 1550... | Line 1543... | |||
1550 | |
1543 | |
|
1551 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1544 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1552 | { |
1545 | { |
|
1553 | try |
1546 | try |
|
1554 | { |
1547 | { |
|
- | 1548 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1555 | await _snapshotDatabase.RemoveColorAsync((string)rows[i].Cells["HashColumn"].Value, |
1549 | |
|
Line 1556... | Line 1550... | |||
1556 | cancellationToken); |
1550 | await _snapshotDatabase.RemoveColorAsync(hash, cancellationToken); |
|
1557 | |
1551 | |
|
1558 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1552 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
1559 | } |
1553 | } |
|
Line 1571... | Line 1565... | |||
1571 | |
1565 | |
|
1572 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1566 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1573 | { |
1567 | { |
|
1574 | try |
1568 | try |
|
1575 | { |
1569 | { |
|
- | 1570 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1576 | await _snapshotDatabase.UpdateColorAsync((string)rows[i].Cells["HashColumn"].Value, color, |
1571 | |
|
Line 1577... | Line 1572... | |||
1577 | cancellationToken); |
1572 | await _snapshotDatabase.UpdateColorAsync(hash, color, cancellationToken); |
|
1578 | |
1573 | |
|
1579 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1574 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
1580 | } |
1575 | } |
|
Line 1603... | Line 1598... | |||
1603 | |
1598 | |
|
1604 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1599 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1605 | { |
1600 | { |
|
1606 | try |
1601 | try |
|
- | 1602 | { |
||
- | 1603 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1607 | { |
1604 | |
|
1608 | var completeSnapshot = |
1605 | var completeSnapshot = |
|
1609 | await _snapshotDatabase.GenerateTransferSnapshotAsync( |
- | ||
Line 1610... | Line 1606... | |||
1610 | (string)rows[i].Cells["HashColumn"].Value, cancellationToken); |
1606 | await _snapshotDatabase.GenerateTransferSnapshotAsync(hash, cancellationToken); |
|
Line 1611... | Line 1607... | |||
1611 | |
1607 | |
|
Line 1664... | Line 1660... | |||
1664 | |
1660 | |
|
1665 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1661 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1666 | { |
1662 | { |
|
1667 | try |
1663 | try |
|
1668 | { |
1664 | { |
|
1669 | await _snapshotDatabase.RevertFileAsync((string)rows[i].Cells["NameColumn"].Value, |
1665 | var path = (string)rows[i].Cells["NameColumn"].Value; |
|
- | 1666 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1670 | (string)rows[i].Cells["HashColumn"].Value, |
1667 | |
|
Line 1671... | Line 1668... | |||
1671 | cancellationToken, _mainForm.Configuration.AtomicOperations); |
1668 | await _snapshotDatabase.RevertFileAsync(path, hash, cancellationToken, _mainForm.Configuration.AtomicOperations); |
|
1672 | |
1669 | |
|
1673 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1670 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
1674 | } |
1671 | } |
|
Line 1686... | Line 1683... | |||
1686 | |
1683 | |
|
1687 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1684 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1688 | { |
1685 | { |
|
1689 | try |
1686 | try |
|
- | 1687 | { |
||
1690 | { |
1688 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
|
1691 | var fileInfo = new FileInfo((string)rows[i].Cells["NameColumn"].Value); |
1689 | var fileInfo = new FileInfo((string)rows[i].Cells["NameColumn"].Value); |
|
1692 | var file = fileInfo.Name; |
1690 | var file = fileInfo.Name; |
|
Line 1693... | Line 1691... | |||
1693 | var path = Path.Combine(directory, file); |
1691 | var path = Path.Combine(directory, file); |
|
1694 | |
- | ||
Line 1695... | Line 1692... | |||
1695 | await _snapshotDatabase.SaveFileAsync(path, (string)rows[i].Cells["HashColumn"].Value, |
1692 | |
|
1696 | cancellationToken); |
1693 | await _snapshotDatabase.SaveFileAsync(path, hash, cancellationToken); |
|
1697 | |
1694 | |
|
1698 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1695 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
Line 1712... | Line 1709... | |||
1712 | |
1709 | |
|
1713 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1710 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1714 | { |
1711 | { |
|
1715 | try |
1712 | try |
|
- | 1713 | { |
||
1716 | { |
1714 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
|
Line 1717... | Line 1715... | |||
1717 | var path = Path.Combine(directory, (string)rows[i].Cells["NameColumn"].Value); |
1715 | var path = Path.Combine(directory, (string)rows[i].Cells["NameColumn"].Value); |
|
1718 | |
- | ||
Line 1719... | Line 1716... | |||
1719 | await _snapshotDatabase.RelocateFileAsync((string)rows[i].Cells["HashColumn"].Value, path, |
1716 | |
|
1720 | cancellationToken); |
1717 | await _snapshotDatabase.RelocateFileAsync(hash, path, cancellationToken); |
|
1721 | |
1718 | |
|
1722 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1719 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
Line 1736... | Line 1733... | |||
1736 | |
1733 | |
|
1737 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1734 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1738 | { |
1735 | { |
|
1739 | try |
1736 | try |
|
1740 | { |
1737 | { |
|
- | 1738 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1741 | using (var memoryStream = |
1739 | |
|
1742 | await _snapshotDatabase.RetrieveFileStreamAsync((string)rows[i].Cells["HashColumn"].Value, |
1740 | using var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, cancellationToken); |
|
1743 | cancellationToken)) |
1741 | if (memoryStream == null) |
|
1744 | { |
- | ||
1745 | if (memoryStream == null) |
- | ||
1746 | { |
1742 | { |
|
1747 | continue; |
1743 | continue; |
|
Line 1748... | Line 1744... | |||
1748 | } |
1744 | } |
|
1749 | |
- | ||
1750 | using (var md5 = MD5.Create()) |
- | ||
1751 | { |
- | ||
1752 | var recomputedHash = md5.ComputeHash(memoryStream); |
- | ||
Line -... | Line 1745... | |||
- | 1745 | |
||
- | 1746 | using var md5 = MD5.Create(); |
||
- | 1747 | |
||
- | 1748 | var recomputedHash = md5.ComputeHash(memoryStream); |
||
1753 | var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "") |
1749 | var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "") |
|
1754 | .ToLowerInvariant(); |
1750 | .ToLowerInvariant(); |
|
Line 1755... | Line 1751... | |||
1755 | |
1751 | |
|
Line 1756... | Line 1752... | |||
1756 | await _snapshotDatabase.UpdateHashAsync((string)rows[i].Cells["HashColumn"].Value, hashHex, |
1752 | await _snapshotDatabase.UpdateHashAsync(hash, hashHex, |
|
1757 | cancellationToken); |
- | ||
1758 | |
- | ||
1759 | rows[i].Cells["HashColumn"].Value = hashHex; |
1753 | cancellationToken); |
|
1760 | |
1754 | |
|
1761 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1755 | rows[i].Cells["HashColumn"].Value = hashHex; |
|
1762 | } |
1756 | |
|
1763 | } |
1757 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
Line 1798... | Line 1792... | |||
1798 | var rootPath = new DirectoryInfo(basePath).Name; |
1792 | var rootPath = new DirectoryInfo(basePath).Name; |
|
1799 | var relPath = rowPath.Remove(0, basePath.Length).Trim('\\'); |
1793 | var relPath = rowPath.Remove(0, basePath.Length).Trim('\\'); |
|
1800 | var newPath = Path.Combine(targetPath, rootPath, relPath); |
1794 | var newPath = Path.Combine(targetPath, rootPath, relPath); |
|
Line 1801... | Line 1795... | |||
1801 | |
1795 | |
|
- | 1796 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1802 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
1797 | |
|
Line 1803... | Line 1798... | |||
1803 | await _snapshotDatabase.SaveFileAsync(newPath, hash, cancellationToken); |
1798 | await _snapshotDatabase.SaveFileAsync(newPath, hash, cancellationToken); |
|
Line 1804... | Line 1799... | |||
1804 | |
1799 | |
|
Line 1824... | Line 1819... | |||
1824 | |
1819 | |
|
1825 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1820 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1826 | { |
1821 | { |
|
1827 | try |
1822 | try |
|
1828 | { |
1823 | { |
|
- | 1824 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1829 | await _snapshotDatabase.NormalizeTimeAsync((string)rows[i].Cells["HashColumn"].Value, |
1825 | |
|
Line 1830... | Line 1826... | |||
1830 | cancellationToken); |
1826 | await _snapshotDatabase.NormalizeTimeAsync(hash, cancellationToken); |
|
1831 | |
1827 | |
|
1832 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1828 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
1833 | } |
1829 | } |
|
Line 1888... | Line 1884... | |||
1888 | |
1884 | |
|
1889 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
1885 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
|
1890 | { |
1886 | { |
|
1891 | try |
1887 | try |
|
1892 | { |
1888 | { |
|
- | 1889 | var hash = (string)rows[i].Cells["HashColumn"].Value; |
||
1893 | await _snapshotDatabase.DeleteScreenshotAsync((string)rows[i].Cells["HashColumn"].Value, |
1890 | |
|
Line 1894... | Line 1891... | |||
1894 | cancellationToken); |
1891 | await _snapshotDatabase.DeleteScreenshotAsync(hash, cancellationToken); |
|
1895 | |
1892 | |
|
1896 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
1893 | progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
1897 | } |
1894 | } |