Spludlow Mame Web Header

Spludlow MAME - About


MAME: 0.218 - Released: 02/02/2020 03:02:28 - Machines: 41415 - rom: 309782 - disk: 1067 - Lists: 577 - Software: 124211 - rom: 203526 - disk: 9279

Introduction

This web provides a quick and simple way to query the current MAME machines. You can search the machine name and description or the ROM SHA1 hash.

It will be automatically updated from the official MAME full driver information in XML format the software lists are from the XML in the MAME hash directory.

Some Code

The Spludlow Framework has been used to grab the MAME XML and put it into a Microsoft SQL database, here is the update code:

              public static void Refresh(

                     string serverConnectionString,

                     string databaseTempDirectory,

                     string databaseNameMachines,

                     string databaseNameSoftware,

                     string databaseNameReports,

                     string webHost,

                     string webAppPool)

              {

                     DateTime startTime = DateTime.Now;

 

                     //     Get links from MAME site

                     string[] links = ExtractLinks(new string[] { "lx.zip", "b_64bit.exe" });

 

                     string xmlArchiveUrl = links[0];

                     string binArchiveUrl = links[1];

 

                     //     Get release from link

                     string mameRelease = ChopRelease(xmlArchiveUrl, "mame", "lx.zip");

 

                     if (mameRelease != ChopRelease(binArchiveUrl, "mame", "b_64bit.exe"))

                           throw new ApplicationException("Mame Data Load, release mismatch: " + mameRelease + ", " + binArchiveUrl);

 

                     //     Check if already have

                     string lastMameRelease = Spludlow.Variables.GetValue(LastRefreshKey);

                     if (lastMameRelease != null && mameRelease == lastMameRelease)

                     {

                           Spludlow.Log.Info("Mame Data Load, Refresh Already have: " + mameRelease);

                           return;

                     }

 

                     //     Download and Extract XML

                     string machinesXmlFilename = XmlCacheDirectory + @"\" + mameRelease + "-machines.xml";

                     string softwareXmlFilename = XmlCacheDirectory + @"\" + mameRelease + "-software.xml";

 

                     if (File.Exists(machinesXmlFilename) == false)

                           ProcessMachineXml(xmlArchiveUrl, machinesXmlFilename);

 

                     if (File.Exists(softwareXmlFilename) == false)

                           ProcessSoftwareXml(binArchiveUrl, softwareXmlFilename);

 

                     DateTime releaseDate = File.GetLastWriteTimeUtc(machinesXmlFilename);

                     File.SetLastWriteTimeUtc(softwareXmlFilename, releaseDate);

 

                     //     Assign temp database names

                     string tempDatabaseNameMachines = databaseNameMachines + "_TEMP";

                     string tempDatabaseNameSoftware = databaseNameSoftware + "_TEMP";

                     string tempDatabaseNameReports = databaseNameReports + "_TEMP";

 

                     //     Read XML into databases

                     DatabaseFromXml(machinesXmlFilename, "machine", serverConnectionString, tempDatabaseNameMachines);

                     DatabaseFromXml(softwareXmlFilename, "softwarelist", serverConnectionString, tempDatabaseNameSoftware);

 

                     //     Run Web Reports

                     RunReports(serverConnectionString, tempDatabaseNameMachines, tempDatabaseNameSoftware, tempDatabaseNameReports);

 

                     //     Create web header

                     string headerFilename = XmlCacheDirectory + @"\" + mameRelease + "-header.txt";

                     SaveHeader(headerFilename, mameRelease, releaseDate, serverConnectionString, tempDatabaseNameMachines, tempDatabaseNameSoftware);

 

                     DateTime downTime = DateTime.Now;

 

                     //     Stop the MAME Web

                     if (webHost != null)

                     {

                           Spludlow.Log.Warning("Mame Data Load, Stopping Web Application Pool: " + webHost + ", " + webAppPool);

                           Spludlow.Admin.WebStop(webHost, webAppPool);

                     }

 

                     //     Copy the temp databases to the live

                     Spludlow.Data.Database.CopyDatabaseWithBackup(

                           serverConnectionString, tempDatabaseNameMachines, databaseTempDirectory,

                           serverConnectionString, databaseNameMachines, databaseTempDirectory);

                     Spludlow.Data.Database.CopyDatabaseWithBackup(

                           serverConnectionString, tempDatabaseNameSoftware, databaseTempDirectory,

                           serverConnectionString, databaseNameSoftware, databaseTempDirectory);

                     Spludlow.Data.Database.CopyDatabaseWithBackup(

                           serverConnectionString, tempDatabaseNameReports, databaseTempDirectory,

                           serverConnectionString, databaseNameReports, databaseTempDirectory);

 

                     //     Start the MAME Web

                     if (webHost != null)

                     {

                           Spludlow.Admin.WebStart(webHost, webAppPool);

                     }

 

                     DateTime upTime = DateTime.Now;

 

                     //     Delete the temp SQL databases

                     Spludlow.Data.IDAL database = Spludlow.Data.DAL.Create(serverConnectionString);

                     database.DatabaseDelete(tempDatabaseNameMachines);

                     database.DatabaseDelete(tempDatabaseNameSoftware);

                     database.DatabaseDelete(tempDatabaseNameReports);

 

                     //     Record the mame release

                     Spludlow.Variables.SetValue(LastRefreshKey, mameRelease);

 

                     DateTime finishTime = DateTime.Now;

 

                     Spludlow.Log.Finish("Mame Data Load: " + mameRelease + ", " + releaseDate.ToString() +

                           ", total: " + Spludlow.Text.TimeTook(finishTime - startTime) +

                           ", offline: " + Spludlow.Text.TimeTook(upTime - downTime));

              }

The entire database and schema are completely replaced on each update.

Database Diagrams

Here are the automatically generated database diagram in SSMS (click for the PDF)

MAME Machines

The main database from the driver information XML file.

MAME Software Lists

From the XML in the MAME hash directory

 

 

 

 



Spludlow Mame Web Footer