Exemple #1
0
 private void CompleteJoinQuery(StringBuilder query, SearchFilter filter, PcdbGameVersion ver)
 {
     var cop = ver == PcdbGameVersion.COP;
     query.AppendLine(" from hashes");
     query.AppendLine("join names on hashes.hash = names.hash");
     query.AppendLine("join ips on hashes.hash = ips.hash");
     if (cop)
         query.AppendLine("join gsids on hashes.hash = gsids.hash");
     query.AppendLine("where");
     var andRequired = false;
     if (filter.Hashes.Length > 0)
     {
         andRequired = true;
         AppendFilter(query, "hashes.hash", filter.Hashes, false);
     }
     if (filter.Names.Length > 0)
     {
         if (andRequired)
             query.AppendLine("and");
         andRequired = true;
         AppendFilter(query, "name", filter.Names, filter.UseNamePattern);
     }
     if (filter.Ips.Length > 0)
     {
         if (andRequired)
             query.AppendLine("and");
         andRequired = true;
         AppendFilter(query, "ip", filter.Ips, filter.UseIpPattern);
     }
     if (cop && filter.Gsids.Length > 0)
     {
         if (andRequired)
             query.AppendLine("and");
         AppendFilter(query, "gsid", filter.Gsids, false);
     }
 }
Exemple #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());
     }
 }
Exemple #3
0
 public DataTable SelectHashes(SearchFilter filter)
 {
     if (filter.Empty)
         return null;
     var query = new StringBuilder("select distinct hashes.hash");
     CompleteJoinQuery(query, filter, GetGameVersion());
     return database.Execute(query.ToString());
 }
 private SearchFilter GetSearchFilter()
 {
     var filter = new SearchFilter
     {
         IncludeRelatedData = chkAllRelatedData.Checked,
         UseNamePattern     = chkNamePattern.Checked,
         UseIpPattern       = chkIpPattern.Checked,
         Hashes             = tbSearchHash.Lines,
         Names              = tbSearchName.Lines,
         Ips                = tbSearchIp.Lines,
         Gsids              = tbSearchGsid.Lines
     };
     return filter;
 }