public Nintendo64_PostProcess(string DirectoryToProcess, char SpaceChar, bool MetaEnabled, bool RenamingEnabled, bool MovingEnabled, DatabaseConnector DBConnection)
        {
            MetaEnabled = true;
            RenamingEnabled = true;
            MovingEnabled = true;

            string[] FilesToProcess = System.IO.Directory.GetFiles(@DirectoryToProcess);
            Progress ProgressForm = new Progress();
            ProgressForm.Show();
            ProgressForm.Step = ProgressForm.CalculateStep(FilesToProcess.Length);

            foreach (string SingleFile in FilesToProcess)
            {
                ProgressForm.UpdateProcessingName = SingleFile;

                //Get the Directory including the file
                string FileDirectory = System.IO.Directory.GetParent(SingleFile).FullName;

                //Get the filename without the path
                string Filename = SingleFile.Replace(FileDirectory + "\\", "");
                string Searchname = Filename;
                //Strip and Save the extension
                Regex FileExtensionRegex = new Regex("\\.(...)$");
                string Extension = FileExtensionRegex.Match(Searchname).Value;
                Searchname = FileExtensionRegex.Replace(Searchname, "");

                //Replace "SpaceChar" with actual spaces for our search
                Searchname = Searchname.Replace(SpaceChar, " ".ToCharArray()[0]);
                LogFacility.WriteToFile(4, "Title to search: " + Searchname, LogSource);

                //Initiate scraper
                Scraper.TheGamesDB InfoScraper = new Scraper.TheGamesDB(LogFacility);
                List<Game> Results = InfoScraper.Search(Searchname, "Nintendo 64");

                //We will only take the first result, let's hope that it's the best one...
                if (Results != null)
                    DBConnection.InsertGame(InfoScraper.GetGameByID(Results[0].scraper_gdb_id));
                else
                    LogFacility.WriteToFile(1, "Could not find an item for " + Searchname, LogSource);

                if (Results != null)
                {
                    Filename = Results[0].Name.Replace(" ".ToCharArray()[0], SpaceChar);
                    Filename += Extension;

                    LogFacility.WriteToFile(4, "Resulted Filename: " + FileDirectory + "\\" + Filename, LogSource);

                    if (RenamingEnabled && !MovingEnabled)
                        System.IO.File.Move(SingleFile, FileDirectory + "\\" + Filename);

                    if (MovingEnabled)
                        System.IO.File.Move(SingleFile, FileDirectory + "\\" + Filename);
                }

                ProgressForm.UpdateProgressBar();
            }

            ProgressForm.Close();
        }
Example #2
0
        private void btSearch_Click(object sender, EventArgs e)
        {
            LogInstance.WriteToFile(4, "Starting search for " + tBSearchString.Text + " on platform " + cBPlatform.Text, LogSource);
            cBSearchResultPicker.Items.Clear();
            TheGamesDB Scraper_GameDB = new TheGamesDB(LogInstance);
            List<Game> ResultList;
            string Platform = cBPlatform.Text;

            if (Platform == "Choose Platform" || Platform == "Choose the desired platform")
                Platform = "";

            if (tBSearchString.Text != "")
                ResultList = Scraper_GameDB.Search(tBSearchString.Text, Platform);
            else
            {
                LogInstance.WriteToFile(4, "User did not define a search!", LogSource);
                MessageBox.Show("Please enter something to search for.");
                return;
            }

            if (ResultList != null)
            {
                for (int x = 0; x < ResultList.Count; x++)
                {
                    if (ResultList[x].ReleaseDate.Year != 1)
                        cBSearchResultPicker.Items.Add (ResultList[x].Name.Replace(":", "-") + " (" + ResultList[x].ReleaseDate.Year + ") - ID: " + ResultList[x].scraper_gdb_id);
                    else
                        cBSearchResultPicker.Items.Add(ResultList[x].Name.Replace(":", " -") + " - ID: " + ResultList[x].scraper_gdb_id);
                }
            }

            btAddGame.Enabled = true;
            btAddGame.Visible = true;
            cBSearchResultPicker.SelectedIndex = 0;
            cBSearchResultPicker.Enabled = true;
            cBSearchResultPicker.Visible = true;
        }
Example #3
0
        private void btAddGame_Click(object sender, EventArgs e)
        {
            LogInstance.WriteToFile(4, "Adding a game to the database", LogSource);
            TheGamesDB Scraper_GameDB = new TheGamesDB(LogInstance);
            Game GameToAdd = new Game();
            string TextValue = (string)cBSearchResultPicker.SelectedItem;
            TextValue = TextValue.Split(Char.Parse(":"))[1].Trim();
            GameToAdd = Scraper_GameDB.GetGameByID(int.Parse(TextValue));

            int newid = DBConnection.InsertGame(GameToAdd);

            if (newid == 0)
            {
                LogInstance.WriteToFile(4, "Somehow we were unable to add the game to the database.", LogSource);
                MessageBox.Show("Unable to add the game to the database.");
            }
            else
            {
                GameToAdd = DBConnection.GetGame(newid);

                if (CurGameList == null)
                    lboxGameList.Items.Clear();

                CurGameList = DBConnection.AllGamesByPlatform("PC");
                if (GameToAdd.Platform == "PC")
                    lboxGameList.Items.Add((lboxGameList.Items.Count + 1) + ". " + GameToAdd.Name + " (ID: " + GameToAdd.ID + ")");

                lboxGameList.Refresh();
                lboxGameList.SelectedIndex = 0;

                lblNameOfGame.Visible = true;
                lblPublisher.Visible = true;
                lblPlayers.Visible = true;
                lblCoOp.Visible = true;
                lblRelease.Visible = true;
                lblContent.Visible = true;
                lblYoutube.Visible = true;
                lblGenres.Visible = true;
                pbGamePic.Show();
                btAddGame.Enabled = false;
                btAddGame.Visible = false;
                cBSearchResultPicker.Items.Clear();
                cBSearchResultPicker.Enabled = false;
                cBSearchResultPicker.Visible = false;
            }
        }
Example #4
0
        private void InitializeDatabase()
        {
            //Create the tables for a fresh database
            LogInstance.WriteToFile(1, "Creating tables for a fresh database.", LogSource);
            if (!connectionopen)
            {
                DBConnector.Open();
                connectionopen = true;
            }
            LogInstance.WriteToFile(4, "Beginning transaction for database initialization", LogSource);
            FbTransaction DBTransaction = DBConnector.BeginTransaction();
            //Create a boolish-type
            FbCommand DBCommand = new FbCommand("CREATE DOMAIN BOOLEAN AS INT CHECK (value is null or value in (0, 1))", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();

            LogInstance.WriteToFile(4, "Creating settings table.", LogSource);
            //Create our settings with ID-Generators
            #region table - settings
            DBCommand = new FbCommand("CREATE TABLE settings (ID integer not null, name_of_setting varchar(150), content varchar(450), active boolean, primary key(ID))", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE GENERATOR gen_settings_id", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("SET GENERATOR gen_settings_id TO 0", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE TRIGGER settings_TR for settings ACTIVE BEFORE INSERT POSITION 0 AS BEGIN if (NEW.ID is NULL) then NEW.ID = GEN_ID(gen_settings_id, 1); END", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion

            LogInstance.WriteToFile(4, "Creating games table.", LogSource);
            //Create our games
            #region table - games
            DBCommand = new FbCommand("CREATE TABLE games (ID integer not null, name_of_game varchar(250), info_xml BLOB SUB_TYPE TEXT, downloaded boolean, snatched boolean, wanted boolean, ReleaseDate varchar(12), InstallPath varchar(256), TGDB_id integer, Platform varchar(100), primary key (ID))", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE GENERATOR gen_game_id", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("SET GENERATOR gen_game_id TO 0", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE TRIGGER game_TR FOR games ACTIVE BEFORE INSERT POSITION 0 AS BEGIN if (NEW.ID is NULL) then NEW.ID = GEN_ID(gen_settings_id, 1); END", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion

            LogInstance.WriteToFile(4, "Creating table for scene-exceptions.", LogSource);
            //Create a table for scene-exceptions
            #region table - exceptions
            DBCommand = new FbCommand("CREATE TABLE exceptions (ID integer not null, exception varchar(250), primary key(ID))", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE GENERATOR gen_exceptions_id", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("SET GENERATOR gen_exceptions_id TO 0", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE TRIGGER exceptions_TR for exceptions ACTIVE BEFORE INSERT POSITION 0 AS BEGIN if (NEW.ID is NULL) then NEW.ID = GEN_ID(gen_exceptions_id, 1); END", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion

            LogInstance.WriteToFile(4, "Creating table for plattforms.", LogSource);
            //Create the platform table
            #region table - platforms
            DBCommand = new FbCommand("CREATE TABLE platforms (ID integer not null, name_of_platform varchar(100), gamedbid integer, active boolean, primary key(ID))", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE GENERATOR gen_platforms_id", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("SET GENERATOR gen_platforms_id TO 0", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("CREATE TRIGGER platforms_TR for platforms ACTIVE BEFORE INSERT POSITION 0 AS BEGIN if (NEW.ID is NULL) then NEW.ID = GEN_ID(gen_platforms_id, 1); END", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion

            LogInstance.WriteToFile(4, "Commiting the changes to the database.", LogSource);
            //Commit all of our work
            DBTransaction.Commit();

            LogInstance.WriteToFile(4, "Beginning a new transaction for the default settings.", LogSource);
            //Start a new transaction
            DBTransaction = DBConnector.BeginTransaction();

            //Set default settings
            LogInstance.WriteToFile(4, "Setting the default settings - General.", LogSource);
            #region default settings - general
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('Fanartfolder', 'C:\\fanart', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('Posterfolder', 'C:\\poster', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('Shortcutfolder', 'C:\\shotcuts', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('NFOFolder', 'C:\\NFO', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('AL_Launchers.xml_Location', 'C:\\Launcher', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion
            LogInstance.WriteToFile(4, "Setting the default settings - Provider.", LogSource);
            #region default settings - provider
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('nzbsorgenabled', 'False', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('nzbmatrixenabled', 'False', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('nzbclubenabled', 'True', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion
            LogInstance.WriteToFile(4, "Setting the default settings - sabnzbd.", LogSource);
            #region default settings - sabnzbd
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('sabnzbdenabled', 'False', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion
            LogInstance.WriteToFile(4, "Setting the default settings - N64.", LogSource);
            #region default settings - N64
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64Romfolder', 'C:\\Games\\N64Roms', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64Downloadfolder', 'C:\\Games\\N64Downloads', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64PPEnabled', 'false', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64MetaEnabled', 'false', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64MovingEnabled', 'false', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64RenamingEnabled', 'false', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            DBCommand = new FbCommand("INSERT INTO settings (name_of_setting, content, active) VALUES ('N64SpaceChar', '_', 1)", DBConnector, DBTransaction);
            DBCommand.ExecuteNonQuery();
            #endregion

            //Get a recent platform list and insert it
            LogInstance.WriteToFile(4, "Calling TheGamesDB for a current list of platforms.", LogSource);
            TheGamesDB PlatformScraper = new TheGamesDB(LogInstance);
            List<Platform> scrapedplatforms = PlatformScraper.GetAvailablePlatforms();
            if (scrapedplatforms != null)
            {
                foreach (Platform platform in scrapedplatforms)
                {
                    DBCommand = new FbCommand("INSERT INTO platforms(name_of_platform, gamedbid, active) VALUES ('" + platform.Name + "'," + platform.ID + ", 1)", DBConnector, DBTransaction);
                    LogInstance.WriteToFile(4, "Executing SQL Command: " + DBCommand.CommandText, LogSource);
                    DBCommand.ExecuteNonQuery();
                }
            }
            else
            {
                DBCommand = new FbCommand("INSERT INTO platforms(name_of_platform) VALUES ('Nothing available')", DBConnector, DBTransaction);
                LogInstance.WriteToFile(4, "NO PLATFORMS AVAILABLE! We just might as well kill the whole program...(but we don't).", LogSource);
                DBCommand.ExecuteNonQuery();
            }

            LogInstance.WriteToFile(4, "Commiting the changes to the database.", LogSource);
            DBTransaction.Commit();
            DBConnector.Close();
            connectionopen = false;
        }