private void StartUpCode(object sender, DoWorkEventArgs e)
        {
            RepairStatus.InitStatusCheck();

            Settings.SetDefaults();

            DB.Read(sender, e);
        }
Ejemplo n.º 2
0
        public static void UpdateDat(object sender, DoWorkEventArgs e)
        {
            try
            {
                _bgw = sender as BackgroundWorker;
                if (_bgw == null)
                {
                    return;
                }

                Program.SyncCont = e.Argument as SynchronizationContext;
                if (Program.SyncCont == null)
                {
                    _bgw = null;
                    return;
                }


                _bgw.ReportProgress(0, new bgwText("Clearing DB Status"));
                RepairStatus.ReportStatusReset(DB.DirTree);

                _datCount = 0;

                _bgw.ReportProgress(0, new bgwText("Finding Dats"));
                RvDir datRoot = new RvDir(FileType.Dir)
                {
                    Name = "RomVault", DatStatus = DatStatus.InDatCollect
                };

                // build a datRoot tree of the DAT's in DatRoot, and count how many dats are found
                if (!RecursiveDatTree(datRoot, out _datCount))
                {
                    _bgw.ReportProgress(0, new bgwText("Dat Update Complete"));
                    _bgw             = null;
                    Program.SyncCont = null;
                    return;
                }

                _bgw.ReportProgress(0, new bgwText("Scanning Dats"));
                _datsProcessed = 0;

                // now compare the database DAT's with datRoot removing any old DAT's
                RemoveOldDats(DB.DirTree.Child(0), datRoot);

                // next clean up the File status removing any old DAT's
                RemoveOldDatsCleanUpFiles(DB.DirTree.Child(0));

                _bgw.ReportProgress(0, new bgwSetRange(_datCount - 1));

                // next add in new DAT and update the files
                UpdateDatList((RvDir)DB.DirTree.Child(0), datRoot);

                // finally remove any unneeded DIR's from the TreeView
                RemoveOldTree(DB.DirTree.Child(0));

                _bgw.ReportProgress(0, new bgwText("Updating Cache"));
                DB.Write();

                _bgw.ReportProgress(0, new bgwText("Dat Update Complete"));
                _bgw             = null;
                Program.SyncCont = null;
            }
            catch (Exception exc)
            {
                ReportError.UnhandledExceptionHandler(exc);

                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Updating Cache"));
                }
                DB.Write();
                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Complete"));
                }

                _bgw             = null;
                Program.SyncCont = null;
            }
        }
Ejemplo n.º 3
0
        public static void ScanFiles(object sender, DoWorkEventArgs e)
        {
            try
            {
                _bgw = sender as BackgroundWorker;
                if (_bgw == null)
                {
                    return;
                }

                Program.SyncCont = e.Argument as SynchronizationContext;
                if (Program.SyncCont == null)
                {
                    _bgw = null;
                    return;
                }

                _bgw.ReportProgress(0, new bgwText("Clearing DB Status"));
                RepairStatus.ReportStatusReset(DB.DirTree);

                List <RvFile> lstRomTableSortedCRCSize;
                List <RvFile> lstRomTableSortedSHA1CHD;

                _bgw.ReportProgress(0, new bgwText("Loading Rom List"));
                DBHelper.GetSelectedFilesSortCRCSize(out lstRomTableSortedCRCSize);
                DBHelper.GetSelectedFilesSortSHA1CHD(out lstRomTableSortedSHA1CHD);

                _bgw.ReportProgress(0, new bgwText("Scanning for Fixes"));
                _bgw.ReportProgress(0, new bgwSetRange(lstRomTableSortedCRCSize.Count));

                int romIndex0 = 0;
                int romIndex1 = 1;
                while (romIndex1 < lstRomTableSortedCRCSize.Count)
                {
                    if (romIndex1 % 100 == 0)
                    {
                        _bgw.ReportProgress(romIndex1);
                    }

                    if (!ArrByte.bCompare(lstRomTableSortedCRCSize[romIndex0].CRC, lstRomTableSortedCRCSize[romIndex1].CRC) || (lstRomTableSortedCRCSize[romIndex0].Size != lstRomTableSortedCRCSize[romIndex1].Size))
                    {
                        ListCheck(lstRomTableSortedCRCSize, romIndex0, romIndex1 - romIndex0);
                        romIndex0 = romIndex1;
                    }
                    romIndex1++;
                }

                ListCheck(lstRomTableSortedCRCSize, romIndex0, romIndex1 - romIndex0);


                _bgw.ReportProgress(0, new bgwSetRange(lstRomTableSortedSHA1CHD.Count));

                romIndex0 = 0;
                romIndex1 = 1;
                while (romIndex1 < lstRomTableSortedSHA1CHD.Count)
                {
                    if (romIndex1 % 100 == 0)
                    {
                        _bgw.ReportProgress(romIndex1);
                    }

                    if (!ArrByte.bCompare(lstRomTableSortedSHA1CHD[romIndex0].SHA1CHD, lstRomTableSortedSHA1CHD[romIndex1].SHA1CHD))
                    {
                        ListCheckSHA1CHD(lstRomTableSortedSHA1CHD, romIndex0, romIndex1 - romIndex0);
                        romIndex0 = romIndex1;
                    }
                    romIndex1++;
                }

                ListCheckSHA1CHD(lstRomTableSortedSHA1CHD, romIndex0, romIndex1 - romIndex0);


                _bgw             = null;
                Program.SyncCont = null;
            }
            catch (Exception exc)
            {
                ReportError.UnhandledExceptionHandler(exc);

                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Updating Cache"));
                }
                DB.Write();
                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Complete"));
                }

                _bgw             = null;
                Program.SyncCont = null;
            }
        }
Ejemplo n.º 4
0
        public static void ScanFiles(object sender, DoWorkEventArgs e)
        {
#if !Debug
            try
            {
#endif
            _fileErrorAbort = false;
            _cacheSaveTimer = new Stopwatch();
            _cacheSaveTimer.Reset();
            if (Settings.CacheSaveTimerEnabled)
            {
                _cacheSaveTimer.Start();
            }

            _bgw = sender as BackgroundWorker;
            if (_bgw == null)
            {
                return;
            }

            Program.SyncCont = e.Argument as SynchronizationContext;
            if (Program.SyncCont == null)
            {
                _bgw = null;
                return;
            }


            _bgw.ReportProgress(0, new bgwText("Clearing DB Status"));
            RepairStatus.ReportStatusReset(DB.DirTree);

            _bgw.ReportProgress(0, new bgwText("Finding Dir's to Scan"));
            //Next get a list of all the directories to be scanned
            List <RvDir> lstDir = new List <RvDir>();
            DBHelper.GetSelectedDirList(ref lstDir);


            _bgw.ReportProgress(0, new bgwText("Scanning Dir's"));
            _bgw.ReportProgress(0, new bgwSetRange(lstDir.Count - 1));
            //Scan the list of directories.
            for (int i = 0; i < lstDir.Count; i++)
            {
                _bgw.ReportProgress(i);
                _bgw.ReportProgress(0, new bgwText("Scanning Dir : " + lstDir[i].FullName));
                string lDir = lstDir[i].FullName;
                Console.WriteLine(lDir);
                if (Directory.Exists(lDir))
                {
                    CheckADir(lstDir[i], true);
                }
                else
                {
                    MarkAsMissing(lstDir[i]);
                }

                if (_bgw.CancellationPending || _fileErrorAbort)
                {
                    break;
                }
            }

            _bgw.ReportProgress(0, new bgwText("Updating Cache"));
            DB.Write();


            _bgw.ReportProgress(0, new bgwText("File Scan Complete"));

            _bgw             = null;
            Program.SyncCont = null;
#if !Debug
        }

        catch (Exception exc)
        {
            ReportError.UnhandledExceptionHandler(exc);

            if (_bgw != null)
            {
                _bgw.ReportProgress(0, new bgwText("Updating Cache"));
            }
            DB.Write();
            if (_bgw != null)
            {
                _bgw.ReportProgress(0, new bgwText("Complete"));
            }

            _bgw             = null;
            Program.SyncCont = null;
        }
#endif
        }
Ejemplo n.º 5
0
        private void StartUpCode(object sender, DoWorkEventArgs e)
        {
            BasicHttpBinding b = new BasicHttpBinding {
                SendTimeout = new TimeSpan(0, 0, 20), ReceiveTimeout = new TimeSpan(0, 0, 20)
            };
            EndpointAddress ep = new EndpointAddress(@"http://services.romvault.com/Service1.svc");
            Service1Client  s  = new Service1Client(b, ep);

            if (string.IsNullOrEmpty(Settings.Username) || string.IsNullOrEmpty(Settings.EMail))
            {
                FrmRegistration freg = new FrmRegistration();
                freg.ShowDialog();
                freg.Dispose();
            }

            bool isNetworkAvailable = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

            string r = "OK";

            try
            {
                if (isNetworkAvailable)
                {
                    r = s.SendUser1(Settings.Username, Settings.EMail, Program.Version, Program.SubVersion);
                }
            }
            catch (Exception)
            {
                r = "OK";
            }

            if (r != "OK")
            {
                Program.ErrorMessage = Resources.Program_Main_You_are_not_Authorised_to_use_this_program;
                return;
            }
            // normal check ends

            string thisV = Program.Version + "." + Program.SubVersion.ToString("0000");
            string v     = thisV;

            try
            {
                if (isNetworkAvailable)
                {
                    v = s.GetLatestVersion1(Program.Version, Program.SubVersion);
                }
            }
            catch (Exception)
            {
                v = thisV;
            }
            if (String.Compare(v, thisV, StringComparison.Ordinal) > 0)
            {
                Program.URL          = s.GetUpdateLink1(Program.Version, Program.SubVersion);
                Program.ErrorMessage = Resources.Program_Main_There_is_a_new_release_download_now_from + Program.URL;
                return;
            }

            s.Close();

            RepairStatus.InitStatusCheck();

            Settings.SetDefaults();

            DB.Read(sender, e);
        }