예제 #1
0
 public void Export(PcdbChunk chunk, string path)
 {
     if (Worker.IsBusy)
         throw new InvalidOperationException("Export has been already started.");
     Chunk = chunk;
     Writer = new StreamWriter(path, false, Encoding.Default);
     View.IsBusy = true;
     View.InvokeAsync(() =>
     {
         MaximumProgress = Chunk.Hashes.Rows.Count;
         CurrentProgress = 0;
         View.ProgressMin = 0;
         View.ProgressMax = MaximumProgress;
         View.ProgressValue = 0;
         View.StatusText = StringTable.ExportEtc;
     });
     Worker.RunWorkerAsync();
 }
예제 #2
0
 public void Select(SearchFilter filter, PcdbChunk chunk)
 {
     if (filter.Empty)
         return;
     var ver = GetGameVersion();
     var query = new StringBuilder("select distinct hashes.hash, info");
     var tailBuilder = new StringBuilder();
     CompleteJoinQuery(tailBuilder, filter, ver);
     var tail = tailBuilder.ToString();
     query.Append(tail);
     chunk.Hashes = database.Execute(query.ToString());
     string[] hashes = null;
     if (filter.IncludeRelatedData)
     {
         hashes = ExtractHashes(chunk.Hashes);
         if (hashes.Length == 0)
             return;
         query.Clear().Append("select distinct hash, name, dateinfo from names where ");
         AppendFilter(query, "hash", hashes, false);
     }
     else
     {
         query.Clear().Append("select distinct hashes.hash, name, names.dateinfo");
         query.Append(tail);
     }
     chunk.Names = database.Execute(query.ToString());
     if (filter.IncludeRelatedData)
     {
         query.Clear().Append("select distinct hash, ip, dateinfo from ips where ");
         AppendFilter(query, "hash", hashes, false);
     }
     else
     {
         query.Clear().Append("select distinct hashes.hash, ip, ips.dateinfo");
         query.Append(tail);
     }
     chunk.Ips = database.Execute(query.ToString());
     if (ver == PcdbGameVersion.COP)
     {
         if (filter.IncludeRelatedData)
         {
             query.Clear().Append("select distinct hash, gsid, dateinfo from gsids where ");
             AppendFilter(query, "hash", hashes, false);
         }
         else
         {
             query.Clear().Append("select distinct hashes.hash, gsid, gsid.dateinfo");
             query.Append(tail);
         }
         chunk.Gsids = database.Execute(query.ToString());
     }
 }
예제 #3
0
 private void SearchProc()
 {
     while (!shutdown)
     {
         lock (syncSearch)
         {
             Monitor.Wait(syncSearch);
         }
         if (shutdown)
             break;
         IsBusy = true;
         var sample = new List<PcdbEntry>();
         lastChunk = CollectData();
         var chunk = lastChunk;
         if (chunk != null)
         {
             var haveTs = database.Revision >= (int)PcdbRevision.Rev1;
             foreach (DataRow hashRow in chunk.Hashes.Rows)
             {
                 if (cancel || shutdown)
                     break;
                 var entry = new PcdbEntry(hashRow[0].ToString());
                 foreach (DataRow row in chunk.Names.Rows)
                 {
                     if (row[0].ToString() == entry.Hash)
                     {
                         var name = new PcdbName();
                         name.Name = row[1].ToString();
                         if (haveTs)
                             name.Timestamp = (DateTime)row[2];
                         entry.Names.Add(name);
                     }
                 }
                 if (cancel || shutdown)
                     break;
                 foreach (DataRow row in chunk.Ips.Rows)
                 {
                     if (row[0].ToString() == entry.Hash)
                     {
                         var ip = new PcdbIp();
                         ip.Ip = row[1].ToString();
                         if (haveTs)
                             ip.Timestamp = (DateTime)row[2];
                         entry.Ips.Add(ip);
                     }
                 }
                 if (cancel || shutdown)
                     break;
                 if (dbGameVersion == PcdbGameVersion.COP && chunk.Gsids != null)
                 {
                     foreach (DataRow row in chunk.Gsids.Rows)
                     {
                         if (row[0].ToString() == entry.Hash)
                         {
                             var gsid = new PcdbGsid();
                             gsid.Gsid = (uint)row[1];
                             if (haveTs)
                                 gsid.Timestamp = (DateTime)row[2];
                             entry.Gsids.Add(gsid);
                         }
                     }
                 }
                 entry.Info.Item = hashRow[1].ToString();
                 sample.Add(entry);
             }
         }
         OnSearchCompleted(sample, cancel);
         cancel = false;
         IsBusy = false;
         syncSearchCompleted.Set();
     }
     IsBusy = false;
     syncSearchCompleted.Set();
 }
예제 #4
0
 private PcdbChunk CollectData()
 {
     database.BeginTransaction();
     var chunk = new PcdbChunk();
     database.Select(Filter, chunk);
     database.CommitTransaction();
     return chunk;
 }