예제 #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 SetDatabaseAsEdit(DatabaseData srcDatabaseData)
      {
         if (!databases.ContainsKey(srcDatabaseData.Definition.Path))
            throw new ApplicationException("Database not open in model");

         // Make a clone of the source database definition and give it a new name
         RrdDb rrdDb = new RrdDb(srcDatabaseData.Definition.Path, true);
         databaseDefinition = rrdDb.getRrdDef();
         rrdDb.close();

         DatabaseData dstDatabaseData = new DatabaseData();
         dstDatabaseData.SourceDatabasePath = srcDatabaseData.Definition.Path;
         dstDatabaseData.Saved = false;
         dstDatabaseData.Definition = databaseDefinition;
         dstDatabaseData.Definition.Path = Path.GetFileNameWithoutExtension(databaseDefinition.Path) + "_";
         dstDatabaseData.LastUpdated = dstDatabaseData.Definition.getStartDateTime();
         dstDatabaseData.LastValue = double.NaN;
         DatabaseDirty = true;
         EditingDatabaseData = dstDatabaseData;
         databases.Add(dstDatabaseData.Definition.Path,dstDatabaseData);
         return dstDatabaseData;
      }
예제 #3
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;
    }
 }