Exemplo n.º 1
0
 private void OnFoundData(DatabaseTableId field, int count = 1)
 {
     if (FoundData != null)
         FoundData(field, count);
 }
Exemplo n.º 2
0
 private string GetTableName(DatabaseTableId table)
 {
     switch (table)
     {
     case DatabaseTableId.Hash: return "HASHES";
     case DatabaseTableId.Name: return "NAMES";
     case DatabaseTableId.Ip: return "IPS";
     case DatabaseTableId.Gsid: return "GSIDS";
     default: return null;
     }
 }
Exemplo n.º 3
0
 private void OnAppendedData(DatabaseTableId field, int count = 1)
 {
     if (AppendedData != null)
         AppendedData(field, count);
 }
Exemplo n.º 4
0
 public DataTable SelectHashes(DatabaseTableId table)
 {
     return database.Execute("SELECT DISTINCT HASH FROM " + GetTableName(table));
 }
Exemplo n.º 5
0
 private string GetFieldName(DatabaseTableId table)
 {
     switch (table)
     {
     case DatabaseTableId.Hash: return "HASH";
     case DatabaseTableId.Name: return "NAME";
     case DatabaseTableId.Ip: return "IP";
     case DatabaseTableId.Gsid: return "GSID";
     default: return null;
     }
 }
Exemplo n.º 6
0
 public DataTable Select(DatabaseTableId table, string[] hashes, string[] filter, bool asPattern = false)
 {
     var tableName = GetTableName(table);
     var fieldName = GetFieldName(table);
     DataTable result = null;
     var query = new StringBuilder("SELECT * FROM ");
     query.Append(tableName);
     query.Append(" WHERE");
     var idUsed = false;
     var len = hashes.Length;
     if (len > 0)
     {
         idUsed = true;
         query.Append(" HASH IN ('");
         query.Append(hashes[0]);
         for (var j = 1; j < len; j++)
         {
             query.Append("','");
             query.Append(hashes[j]);
         }
         query.Append("')");
     }
     len = filter.Length;
     if (len > 0)
     {
         if (idUsed)
             query.Append(" AND ");
         if (asPattern)
         {
             query.Append(fieldName);
             query.Append(" LIKE '");
             query.Append(EscapeString(filter[0]));
             query.Append('\'');
             for (var j = 1; j < len; j++)
             {
                 query.Append(" OR ");
                 query.Append(fieldName);
                 query.Append(" LIKE '");
                 query.Append(EscapeString(filter[j]));
                 query.Append('\'');
             }
         }
         else
         {
             query.Append(fieldName);
             query.Append(" IN ('");
             query.Append(EscapeString(filter[0]));
             query.Append('\'');
             for (var j = 1; j < len; j++)
             {
                 query.Append(",'");
                 query.Append(EscapeString(filter[j]));
                 query.Append('\'');
             }
             query.Append(')');
         }
         idUsed = true;
     }
     if (idUsed)
         result = database.Execute(query.ToString());
     return result ?? new DataTable();
 }
Exemplo n.º 7
0
 public DataTable Select(DatabaseTableId table, string hash)
 {
     var query = new StringBuilder("SELECT * FROM ");
     query.Append(GetTableName(table));
     query.Append(" WHERE HASH = '");
     query.Append(hash);
     query.Append('\'');
     return database.Execute(query.ToString());
 }
Exemplo n.º 8
0
 public DataTable SelectIds(DatabaseTableId table, string[] filter, bool asPattern = false)
 {
     var len = filter.Length;
     if (len == 0)
         return null;
     var tableName = GetTableName(table);
     var fieldName = GetFieldName(table);
     var query = new StringBuilder("SELECT DISTINCT ID FROM ");
     query.Append(tableName);
     if (asPattern)
     {
         query.Append(" WHERE ");
         query.Append(fieldName);
         query.Append(" LIKE '");
         query.Append(EscapeString(filter[0]));
         query.Append('\'');
         for (var j = 1; j < len; j++)
         {
             query.Append(" OR ");
             query.Append(fieldName);
             query.Append(" LIKE '");
             query.Append(EscapeString(filter[j]));
             query.Append('\'');
         }
     }
     else
     {
         query.Append(" WHERE ");
         query.Append(fieldName);
         query.Append(" IN ('");
         query.Append(EscapeString(filter[0]));
         query.Append('\'');
         for (var j = 1; j < len; j++)
         {
             query.Append(",'");
             query.Append(EscapeString(filter[j]));
             query.Append('\'');
         }
         query.Append(')');
     }
     return database.Execute(query.ToString());
 }
Exemplo n.º 9
0
 public DataTable Select(DatabaseTableId table, uint id)
 {
     var query = new StringBuilder("SELECT * FROM ");
     query.Append(GetTableName(table));
     query.Append(" WHERE ID = ");
     query.Append(id);
     return database.Execute(query.ToString());
 }
Exemplo n.º 10
0
 protected void OnFoundData(DatabaseTableId field, int count = 1)
 {
     var target = host ?? this;
     if (target.FoundData != null)
         target.FoundData(field, count);
 }
 private void OnFoundData(DatabaseTableId field, int count)
 {
     InvokeAsync(() =>
     {
         switch (field)
         {
         case DatabaseTableId.Hash:
             foundHashes += count;
             tbHashesFound.Text = foundHashes.ToString();
             break;
         case DatabaseTableId.Name:
             foundNames += count;
             tbNamesFound.Text = foundNames.ToString();
             break;
         case DatabaseTableId.Ip:
             foundIps += count;
             tbIpsFound.Text = foundIps.ToString();
             break;
         case DatabaseTableId.Gsid:
             foundGsids += count;
             tbGsidsFound.Text = foundGsids.ToString();
             break;
         }
     });
 }
 private void OnAppendedData(DatabaseTableId field, int count = 1)
 {
     InvokeAsync(() =>
     {
         switch (field)
         {
         case DatabaseTableId.Hash:
             appendedHashes += count;
             tbHashesAppended.Text = appendedHashes.ToString();
             break;
         case DatabaseTableId.Name:
             appendedNames += count;
             tbNamesAppended.Text = appendedNames.ToString();
             break;
         case DatabaseTableId.Ip:
             appendedIps += count;
             tbIpsAppended.Text = appendedIps.ToString();
             break;
         case DatabaseTableId.Gsid:
             appendedGsids += count;
             tbGsidsAppended.Text = appendedGsids.ToString();
             break;
         }
     });
 }