예제 #1
0
 public void StoreData(rrd4n.DataAccess.Data.Sample sample)
 {
    RrdDb rrdDb = null;
    try
    {
       rrdDb = new RrdDb(DataPath + sample.DatabasePath, false);
       Sample coreSample = new Sample(rrdDb.getPath(),rrdDb.getDsNames(), sample.Time);
       coreSample.setValues(sample.Values);
       rrdDb.store(coreSample);
    }
    finally
    {
       if (rrdDb != null)
          rrdDb.close();
    }
 }
예제 #2
0
 public void StoreData(string databaseName, long timeStamp, double[] newValues)
 {
    RrdDb database = null;
    try
    {
       database = new RrdDb(databaseName, false);
       database.store(timeStamp, newValues);
    }
    catch (Exception ex)
    {
       log.Error("Store data exception", ex);
       throw;
    }
    finally
    {
       if (database != null)
          database.close();
    }
 }
예제 #3
0
      public void ImportData(string dataPath, DatabaseData databaseData, TimeSpan expectedTick )
      {
         if (model.ReadOnly)
            throw new ApplicationException("Can't import data. Database readonly");


         List<string> columns = new List<string>();
         List<FetchedData> unifiedData = ReadAndUnifyData(dataPath, out columns);

         string databasePath = databaseData.Definition.Path;
         RrdDb database = new RrdDb(databasePath, false);

         int[] dsIndexes = new int[columns.Count];
         for (int i = 0; i < columns.Count; i++)
         {
            dsIndexes[i] = database.getDsIndex(columns[i]);
         }


         string[] dsNames = database.getDsNames();
         rrd4n.DataAccess.Data.Sample sample = new rrd4n.DataAccess.Data.Sample(databasePath, dsNames, 0);
         
         foreach (var data in unifiedData)
         {
            sample.setDateTime(data.TimeStamp);
            for (int i = 0; i < data.Values.Count; i++ )
            {
               sample.setValue(dsIndexes[i], data.Values[i]); 
            }

            try
            {
               // When using file access abstraction
               //dbAccess.StoreData(sample);

               //Without abstraction
               database.store(sample);
               sample.clearValues();
            }
            catch (ArgumentException)
            {
            }
            model.DatabaseDirty = true;
         }
         database.close();
         OpenDatabase(databasePath);
      }
예제 #4
0
 /**
  * Stores sample in the corresponding RRD. If the update operation succeedes,
  * all datasource values in the sample will be set to Double.NaN (unknown) values.
  *
  * @Thrown in case of I/O error.
  */
 public void update()
 {
     parentDb.store(this);
     clearValues();
 }