Ejemplo n.º 1
0
    Data.TroubleCodeItem Decrypt(ref TroubleCodeItem item)
    {
      if (item.Content == null)
        return null;

      Data.TroubleCodeItem tc = new Data.TroubleCodeItem();

      tc.Content = DecryptToString(item.Content);
      if (item.Description != null)
        tc.Description = DecryptToString(item.Description);

      return tc;
    }
Ejemplo n.º 2
0
    bool Query(string code, string cls, ref TroubleCodeItem item)
    {
      Command.Prepare();

      var enCode = Encrypt(code);
      var enCls = Encrypt(cls);

      Command.Parameters[0].Value = enCode;
      Command.Parameters[1].Value = Language;
      Command.Parameters[2].Value = enCls;

      using (var reader = Command.ExecuteReader())
      {
        if (reader.Read())
        {
          item.Content = reader.GetFieldValue<byte[]>(0);
          item.Description = reader.GetFieldValue<byte[]>(1);
          return true;
        }
      }

      return false;
    }
Ejemplo n.º 3
0
    public Data.TroubleCodeItem Get(string code, string cls)
    {
      StringBuilder sb = new StringBuilder();
      sb.AppendFormat("{0}_{1}_{2}", code, Settings.Language, cls);
      string key = sb.ToString();

      if (!_troubleCodes.ContainsKey(key))
      {
        TroubleCodeItem item = new TroubleCodeItem();
        if (!(Query(code, cls, ref item)))
          throw new DatabaseException("Query trouble code fail in vehicle database!");

        var tc = Decrypt(ref item);
        if (tc == null)
          throw new DatabaseException("Decrypt trouble code item fail!");

        tc.Code = code;
        _troubleCodes[key] = tc;
      }

      return _troubleCodes[key];
    }