Пример #1
0
        /// <summary>
        /// Checks certain file existances, etc.
        /// </summary>
        /// <returns></returns>
        private void BootChecks()
        {
            //Check if correct thread...
            if (this.InvokeRequired)
            {
                Debug.WriteLine("InvokeRequired...");
                BootChecksCallback bcc = new BootChecksCallback(BootChecks);
                this.Invoke(bcc);
                return;
            }

            if (NUSDFileExists("database.json") == true)
            {
                Database db = new Database();
                db.LoadDatabaseToStream();
                string version = Database.GetDatabaseVersion();
                WriteStatus("Database.json detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                databaseButton.Text  = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.databaseWorker.RunWorkerAsync();
            }

            // Check for Proxy Settings file...
            if (NUSDFileExists("proxy.txt") == true)
            {
                WriteStatus("Proxy settings detected.");
                string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt"));
                proxy_url = proxy_file[0];

                // If proxy\nuser\npassword
                if (proxy_file.Length > 2)
                {
                    proxy_usr = proxy_file[1];
                    proxy_pwd = proxy_file[2];
                }
                else if (proxy_file.Length > 1)
                {
                    proxy_usr = proxy_file[1];
                    SetAllEnabled(false);
                    ProxyVerifyBox.Visible = true;
                    ProxyVerifyBox.Enabled = true;
                    ProxyPwdBox.Enabled    = true;
                    SaveProxyBtn.Enabled   = true;
                    ProxyVerifyBox.Select();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Checks certain file existances, etc.
        /// </summary>
        /// <returns></returns>
        private void BootChecks()
        {
            //Check if correct thread...
            if (this.InvokeRequired)
            {
                Debug.WriteLine("InvokeRequired...");
                BootChecksCallback bcc = new BootChecksCallback(BootChecks);
                this.Invoke(bcc);
                return;
            }

            /* Check for DSi common key bin file...
            if (NUSDFileExists("dsikey.bin") == true)
            {
                WriteStatus("DSi Common Key detected.");
                dsidecrypt = true;
            }*/
            /*
            // Check for database.xml
            if (NUSDFileExists("database.xml") == false)
            {
                WriteStatus("Database.xml not found. Title database not usable!");
                DatabaseEnabled(false);
                updateDatabaseToolStripMenuItem.Enabled = true;
                updateDatabaseToolStripMenuItem.Visible = true;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("Database.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                //databaseButton.Enabled = false;
                //databaseButton.Text = "DB Loading";
                databaseButton.Text = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.fds.RunWorkerAsync();
            }

            // Check for database.xml
            if (NUSDFileExists("dsidatabase.xml") == false)
            {
                WriteStatus("DSiDatabase.xml not found. DSi database not usable!");
                DatabaseEnabled(false);
                updateDatabaseToolStripMenuItem.Enabled = true;
                updateDatabaseToolStripMenuItem.Visible = true;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("Database.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                //databaseButton.Enabled = false;
                //databaseButton.Text = "DB Loading";
                databaseButton.Text = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.fds.RunWorkerAsync();
            }*/

            if (NUSDFileExists("database.xml") == true)
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("Database.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                databaseButton.Text = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.databaseWorker.RunWorkerAsync();
            }

            if (NUSDFileExists("dsidatabase.xml") == true)
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "dsidatabase.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("DSiDatabase.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                databaseButton.Text = "    [  ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.dsiDatabaseWorker.RunWorkerAsync();
            }

            // Load scripts (local)
            RunScriptOrganizer();

            // Check for Proxy Settings file...
            if (NUSDFileExists("proxy.txt") == true)
            {
                WriteStatus("Proxy settings detected.");
                string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt"));
                proxy_url = proxy_file[0];

                // If proxy\nuser\npassword
                if (proxy_file.Length > 2)
                {
                    proxy_usr = proxy_file[1];
                    proxy_pwd = proxy_file[2];
                }
                else if (proxy_file.Length > 1)
                {
                    proxy_usr = proxy_file[1];
                    SetAllEnabled(false);
                    ProxyVerifyBox.Visible = true;
                    ProxyVerifyBox.Enabled = true;
                    ProxyPwdBox.Enabled = true;
                    SaveProxyBtn.Enabled = true;
                    ProxyVerifyBox.Select();
                }
            }
        }
Пример #3
0
        private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            string database = e.Result.ToString();

            string databaseFilename = "";
            if (database.Contains("DSISYSTEM"))
            {
                databaseFilename = "dsidatabase.xml";
            }
            else if (database.Contains("0000000100000002"))
            {
                databaseFilename = "database.xml";
            }

            try
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, databaseFilename));
                string currentversion = db.GetDatabaseVersion();
                string onlineversion = Database.GetDatabaseVersion(database);
                WriteStatus(String.Format(" - Database successfully parsed! ({0})", databaseFilename));
                WriteStatus("   - Current Database Version: " + currentversion);
                WriteStatus("   - Online Database Version: " + onlineversion);

                if (currentversion == onlineversion)
                {
                    WriteStatus(" - You have the latest database version!");
                    return;
                }
            }
            catch (FileNotFoundException)
            {
                WriteStatus(" - Database does not yet exist.");
                WriteStatus("   - Online Database Version: " + Database.GetDatabaseVersion(database));
            }

            bool isCreation = false;
            if (File.Exists(databaseFilename))
            {
                WriteStatus(" - Overwriting your current database...");
                WriteStatus(String.Format(" - The old database will become 'old{0}' in case the new one is faulty.", databaseFilename));

                string olddatabase = File.ReadAllText(databaseFilename);
                File.WriteAllText("old" + databaseFilename, olddatabase);
                File.Delete(databaseFilename);
                File.WriteAllText(databaseFilename, database);
            }
            else
            {
                WriteStatus(String.Format(" - {0} has been created.", databaseFilename));
                File.WriteAllText(databaseFilename, database);
                isCreation = true;
            }

            // Load it up...
            this.databaseWorker.RunWorkerAsync();

            if (isCreation)
            {
                WriteStatus("Database successfully created!");
                databaseButton.Visible = true;
                //databaseButton.Enabled = false;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                WriteStatus("Database successfully updated!");
            }
        }
Пример #4
0
        private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            string database         = e.Result.ToString();
            string databaseFilename = "database.json";

            try
            {
                Database db = new Database();
                db.LoadDatabaseToStream();
                string currentversion = Database.GetDatabaseVersion();
                string onlineversion  = Database.GetDatabaseVersion();
                WriteStatus(String.Format(" - Database successfully parsed! ({0})", databaseFilename));
                WriteStatus("   - Current Database Version: " + currentversion);
                WriteStatus("   - Online Database Version: " + onlineversion);

                if (currentversion == onlineversion)
                {
                    WriteStatus(" - You have the latest database version!");
                    return;
                }
            }
            catch (FileNotFoundException)
            {
                WriteStatus(" - Database does not yet exist.");
                WriteStatus("   - Online Database Version: " + Database.GetDatabaseVersion());
            }

            bool isCreation = false;

            if (File.Exists(databaseFilename))
            {
                WriteStatus(" - Overwriting your current database...");
                WriteStatus(String.Format(" - The old database will become 'old{0}' in case the new one is faulty.", databaseFilename));

                string olddatabase = File.ReadAllText(databaseFilename);
                File.WriteAllText("old" + databaseFilename, olddatabase);
                File.Delete(databaseFilename);
                File.WriteAllText(databaseFilename, database);
            }
            else
            {
                WriteStatus(String.Format(" - {0} has been created.", databaseFilename));
                File.WriteAllText(databaseFilename, database);
                isCreation = true;
            }

            // Load it up...
            this.databaseWorker.RunWorkerAsync();

            if (isCreation)
            {
                WriteStatus("Database successfully created!");
                databaseButton.Visible = true;
                //databaseButton.Enabled = false;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                WriteStatus("Database successfully updated!");
            }
        }