示例#1
0
        public void DBWrite()
        {
            FileId = DatUpdate.NoFilesInDB ? null : FindAFile.Execute(this);

            SqlWrite.Parameters["GameId"].Value = GameId;
            SqlWrite.Parameters["name"].Value   = Name;
            SqlWrite.Parameters["size"].Value   = Size;
            SqlWrite.Parameters["crc"].Value    = VarFix.ToDBString(CRC);
            SqlWrite.Parameters["sha1"].Value   = VarFix.ToDBString(SHA1);
            SqlWrite.Parameters["md5"].Value    = VarFix.ToDBString(MD5);
            SqlWrite.Parameters["merge"].Value  = Merge;
            SqlWrite.Parameters["status"].Value = Status;
            SqlWrite.Parameters["FileID"].Value = FileId;
            SqlWrite.ExecuteNonQuery();
        }
示例#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 Found DAT List"));
                DataAccessLayer.ClearFoundDATs();

                const string datRoot = @"";
                uint         DirId   = FindOrInsert.FindOrInsertIntoDir(0, "DatRoot", "DatRoot\\");

                _bgw.ReportProgress(0, new bgwText("Pull File DB into memory"));
                NoFilesInDB = FindAFile.copyDBtoMem();

                _bgw.ReportProgress(0, new bgwText("Finding Dats"));
                _datCount = 0;
                DatCount(datRoot, "DatRoot");

                int  dbDatCount = DataAccessLayer.DatDBCount();
                bool dropIndex  = false;

                dropIndex = (_datCount - dbDatCount > 10);

                if (dropIndex)
                {
                    _bgw.ReportProgress(0, new bgwText("Removing Indexes"));
                    DataAccessLayer.DropIndex();
                }

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

                _bgw.ReportProgress(0, new bgwSetRange(_datCount - 1));
                ReadDats(DirId, datRoot, "DatRoot");

                _bgw.ReportProgress(0, new bgwText("Removing old DATs"));
                DataAccessLayer.RemoveNotFoundDATs();

                if (dropIndex)
                {
                    _bgw.ReportProgress(0, new bgwText("Re-Creating Indexes"));
                    DataAccessLayer.MakeIndex();
                }

                _bgw.ReportProgress(0, new bgwText("Re-calculating DIR Got Totals"));
                DataAccessLayer.UpdateGotTotal();

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


                _bgw             = null;
                Program.SyncCont = null;
            }
        }