-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added (in top-left menu system) an option to Audit the Scraped Data F…
…older - #32
- Loading branch information
Showing
5 changed files
with
243 additions
and
3 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
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,81 @@ | ||
<simpleChildWindow:ChildWindow x:Class="MedLaunch.ScrapedDataAudit" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow" | ||
mc:Ignorable="d" | ||
d:DesignHeight="800" | ||
d:DesignWidth="600" | ||
CloseOnOverlay="True" | ||
GlowBrush="{DynamicResource AccentColorBrush}" | ||
BorderBrush="{DynamicResource AccentColorBrush}" | ||
BorderThickness="1" | ||
ShowCloseButton="True" | ||
IsModal="True"> | ||
|
||
<simpleChildWindow:ChildWindow.Icon> | ||
<Rectangle Width="22" | ||
Height="22" | ||
Fill="{DynamicResource IdealForegroundColorBrush}"> | ||
<Rectangle.OpacityMask> | ||
<VisualBrush Stretch="Uniform" | ||
Visual="{DynamicResource appbar_cog}" /> | ||
</Rectangle.OpacityMask> | ||
</Rectangle> | ||
</simpleChildWindow:ChildWindow.Icon> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<TextBlock Grid.Row="0" | ||
Margin="5" | ||
FontSize="36" | ||
FontWeight="Thin" | ||
Text="Matches Found" /> | ||
|
||
<DataGrid Height="500" x:Name="dgAudit" AutoGenerateColumns="False" ItemsSource="{Binding}" IsReadOnly="True" SelectionMode="Single"> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="Folder" Binding="{Binding FolderName}" /> | ||
<DataGridTextColumn Header="Game" Binding="{Binding GameName}" /> | ||
<DataGridTextColumn Header="Platform" Binding="{Binding System}" /> | ||
<DataGridCheckBoxColumn Header="In Use" Binding="{Binding IsLinked}" /> | ||
<DataGridTemplateColumn Header="Local"> | ||
<DataGridTemplateColumn.CellTemplate> | ||
<DataTemplate> | ||
<Button Name="btnLocal" Click="btnLocal_Click"> | ||
Open Folder | ||
</Button> | ||
</DataTemplate> | ||
</DataGridTemplateColumn.CellTemplate> | ||
</DataGridTemplateColumn> | ||
<DataGridTemplateColumn Header="Online"> | ||
<DataGridTemplateColumn.CellTemplate> | ||
<DataTemplate> | ||
<Button Name="btnOnline" Click="btnOnline_Click"> | ||
View on thegamesdb.net | ||
</Button> | ||
</DataTemplate> | ||
</DataGridTemplateColumn.CellTemplate> | ||
</DataGridTemplateColumn> | ||
</DataGrid.Columns> | ||
|
||
</DataGrid> | ||
|
||
|
||
<Button Grid.Row="3" | ||
|
||
Margin="5" | ||
IsDefault="True" | ||
VerticalAlignment="Bottom" | ||
FontSize="20" | ||
FontWeight="Thin" | ||
Content="Close" | ||
Click="CloseSec_OnClick" /> | ||
</Grid> | ||
</simpleChildWindow:ChildWindow> |
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,141 @@ | ||
using MahApps.Metro.SimpleChildWindow; | ||
using MedLaunch.Models; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
|
||
namespace MedLaunch | ||
{ | ||
/// <summary> | ||
/// Interaction logic for ScrapedDataAudit.xaml | ||
/// </summary> | ||
public partial class ScrapedDataAudit : ChildWindow | ||
{ | ||
public List<FolderData> Data { get; set; } | ||
public string BaseFolder { get; set; } | ||
public List<ScraperMaster> Master { get; set; } | ||
|
||
public ScrapedDataAudit() | ||
{ | ||
InitializeComponent(); | ||
|
||
Data = new List<FolderData>(); | ||
|
||
// load the MasterGames.json | ||
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\Data\\System\\MasterGames.json")) | ||
{ | ||
MessageBox.Show("Unable to locate the MasterGames.json file! MedLaunch re-install may be necessary.."); | ||
this.Close(); | ||
} | ||
|
||
string json = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\Data\\System\\MasterGames.json"); | ||
Master = JsonConvert.DeserializeObject<List<ScraperMaster>>(json); | ||
|
||
// enumerate game data folder | ||
BaseFolder = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\Games"; | ||
|
||
var fol = Directory.GetDirectories(BaseFolder); | ||
foreach (var d in fol) | ||
{ | ||
string fName = System.IO.Path.GetFileName(d); | ||
|
||
// check whether folder name is a valid number | ||
int n; | ||
bool isNumeric = int.TryParse(fName, out n); | ||
if (isNumeric == false) | ||
continue; | ||
|
||
// build folderdata object | ||
FolderData fd = new FolderData(); | ||
fd.FolderName = n; | ||
|
||
// find gdbid from Master | ||
var g = (from a in Master | ||
where a.GamesDbId == n | ||
select a).FirstOrDefault(); | ||
|
||
// is result empty? | ||
if (g == null) | ||
continue; | ||
|
||
fd.GameName = g.TGDBData.GamesDBTitle; | ||
fd.System = GSystem.GetSystemName(Convert.ToInt32(g.MedLaunchSystemId)); | ||
|
||
// now check whether it is linked anywhere in the database | ||
var search = from a in Game.GetGames() | ||
where a.gdbId == n | ||
select a; | ||
|
||
if (search.Count() > 0) | ||
{ | ||
fd.IsLinked = true; | ||
} | ||
else | ||
{ | ||
fd.IsLinked = false; | ||
} | ||
|
||
// add to list | ||
Data.Add(fd); | ||
} | ||
|
||
Data.OrderBy(a => a.FolderName); | ||
|
||
// populate the datagrid | ||
dgAudit.ItemsSource = Data; | ||
} | ||
|
||
private void CloseSec_OnClick(object sender, RoutedEventArgs e) | ||
{ | ||
this.Close(); | ||
} | ||
|
||
private void btnLocal_Click(object sender, RoutedEventArgs e) | ||
{ | ||
// get the id | ||
var r = (FolderData)dgAudit.SelectedItem; | ||
string gdbid = r.FolderName.ToString(); | ||
|
||
// open the folder in windows explorer | ||
string dirPath = System.AppDomain.CurrentDomain.BaseDirectory + @"\Data\Games\" + gdbid; | ||
// check folder exists | ||
if (Directory.Exists(dirPath)) | ||
{ | ||
// open the folder | ||
Process.Start(dirPath); | ||
} | ||
} | ||
|
||
private void btnOnline_Click(object sender, RoutedEventArgs e) | ||
{ | ||
// get the id | ||
var r = (FolderData)dgAudit.SelectedItem; | ||
string gdbid = r.FolderName.ToString(); | ||
|
||
// open thegamesdb.net url in the default browser | ||
string url = @"http://thegamesdb.net/game/" + gdbid; | ||
Process.Start(url); | ||
} | ||
} | ||
|
||
public class FolderData | ||
{ | ||
public int FolderName { get; set; } // gdbid | ||
public string System { get; set; } | ||
public string GameName { get; set; } | ||
public bool IsLinked { get; set; } | ||
} | ||
} |