示例#1
0
        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
 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;
     }
 }