예제 #1
0
파일: Model.cs 프로젝트: mujing/rrd4net
      public DatabaseData ReloadDatabase(DatabaseData srcDatabase)
      {
         if (!databases.ContainsKey(srcDatabase.Definition.Path))
            throw new ApplicationException("Database to reload don't exist");

         try
         {
            RrdDb database = new RrdDb(srcDatabase.Definition.Path);
            DatabaseData data = new DatabaseData();
            data.Saved = true;
            data.Definition = database.getRrdDef();
            data.LastUpdated = database.getLastUpdateDateTime();
            data.LastValue = database.getLastDatasourceValue(database.getDsNames()[0]);
            databases[srcDatabase.Definition.Path] = data;
            database.close();
            return data;
         }
         catch (Exception ex)
         {
            Logger.Error("Fail to add database", ex);
            throw;
         }
      }
예제 #2
0
파일: Model.cs 프로젝트: mujing/rrd4net
 public DatabaseData AddDatabase(string databasePath)
 {
    if (databases.ContainsKey(databasePath))
       return databases[databasePath];
    try
    {
       RrdDb database = new RrdDb(databasePath);
       DatabaseData data = new DatabaseData();
       data.Saved = true;
       data.Definition = database.getRrdDef();
       data.LastUpdated = database.getLastUpdateDateTime();
       data.LastValue = database.getLastDatasourceValue(database.getDsNames()[0]);
       databases.Add(databasePath, data);
       database.close();
       return databases[databasePath];
    }
    catch (Exception ex)
    {
       Logger.Error("Fail to add database", ex);
       throw;
    }
 }