Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8134


Ignore:
Timestamp:
06/27/12 16:53:45 (12 years ago)
Author:
jkarder
Message:

#1648: the client configuration's hash now gets calculated and collected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Access/3.3/ClientInformationUtils.cs

    r8042 r8134  
    2222using System;
    2323using System.Diagnostics;
     24using System.IO;
    2425using System.Management;
    2526using System.Reflection;
     27using System.Security.Cryptography;
     28using System.Text;
    2629using HeuristicLab.Algorithms.Benchmarks;
    2730using HeuristicLab.Data;
     
    4649      client.ProcessorType = GetCpuInfo();
    4750      client.ClientType = cType;
    48       //client.ClientConfiguration = GetClientConfiguration();
     51      client.ClientConfiguration = GetClientConfiguration();
    4952      client.Timestamp = DateTime.Now;
    5053      client.PerformanceValue = RunBenchmark();
     
    5356    }
    5457
    55     public static string GetClientConfiguration() {
    56       //TODO: does it make sense to send the client configuration to the server? for what do we need this?
    57       return string.Empty;
     58    public static ClientConfiguration GetClientConfiguration() {
     59      try {
     60        string filePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
     61        byte[] fileContent = File.ReadAllBytes(filePath);
     62        byte[] hashBytes;
     63        using (SHA1 sha1 = SHA1.Create()) hashBytes = sha1.ComputeHash(fileContent);
     64        StringBuilder sb = new StringBuilder();
     65        foreach (byte b in hashBytes) sb.Append(b.ToString("x2"));
     66        return new ClientConfiguration { Hash = sb.ToString() };
     67      }
     68      catch {
     69        return null;
     70      }
    5871    }
    5972
Note: See TracChangeset for help on using the changeset viewer.