public NrcsSnotelSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { siteNumber = ConnectionStringUtility.GetToken(ConnectionString, "SiteNumber", ""); parameterName = ConnectionStringUtility.GetToken(ConnectionString, "ParameterName", ""); //State = LookupState(siteNumber); }
public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario) { if (ScenarioName == scenario.Name) { return(this); } var sr = m_db.GetNewSeriesRow(false); sr.ItemArray = SeriesCatalogRow.ItemArray; string cs = sr.ConnectionString; string scenario_model_run_id = ConnectionStringUtility.GetToken(scenario.Path, "model_run_id", "-1"); string scenario_model_run_name = ConnectionStringUtility.GetToken(scenario.Path, "model_run_name", ""); string scenario_run_date = ConnectionStringUtility.GetToken(scenario.Path, "run_date", ""); cs = ConnectionStringUtility.Modify(cs, "model_run_id", scenario_model_run_id); cs = ConnectionStringUtility.Modify(cs, "model_run_name", scenario_model_run_name); cs = ConnectionStringUtility.Modify(cs, "run_date", scenario_run_date); sr.ConnectionString = cs; var s = new HdbModelSeries(m_db, sr); s.Appearance.LegendText = BuildScenairoName(scenario_model_run_name, scenario_model_run_id, scenario_run_date) + " " + Name; return(s); }
protected override Series CreateFromConnectionString() { UsgsGroundWaterLevelSeries s = new UsgsGroundWaterLevelSeries( ConnectionStringUtility.GetToken(ConnectionString, "site_no", "")); return(s); }
/// <summary> /// Updates database if the original source text file still exists and has /// been modified. All series data is replaced with the source file contents /// </summary> private void Update() { if (m_db == null) { return; } Logger.WriteLine("Checking series " + Name + " (" + ID + ") for updates"); string dir = Path.GetDirectoryName(m_db.DataSource); bool canUpdate = CanUpdateFromFile(ConnectionString, dir); if (canUpdate) { string fileName = ConnectionStringUtility.GetToken(ConnectionString, "FileName", ""); if (!Path.IsPathRooted(fileName)) { fileName = Path.Combine(dir, fileName); } Logger.WriteLine("Updating: File has changed " + fileName); TextSeries ts = TextSeries.ReadFromFile(fileName); ConnectionString = ts.ConnectionString; ConnectionString = ConnectionStringUtility.MakeFileNameRelative(ConnectionString, m_db.DataSource); m_db.SaveProperties(this); // last write time needs to be updated. m_db.SaveTimeSeriesTable(ID, ts, DatabaseSaveOptions.DeleteAllExisting); } }
private void Init(TimeSeriesDatabase db) { m_fileName = ConnectionStringUtility.GetFileName(ConnectionString, db.DataSource); ScenarioName = Path.GetFileNameWithoutExtension(m_fileName); m_plantName = ConnectionStringUtility.GetToken(ConnectionString, "PlantName", ""); m_dataType = ConnectionStringUtility.GetToken(ConnectionString, "DataType", ""); }
public SimpleMathSeries(TimeSeriesDatabase db, Reclamation.TimeSeries.TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { string[] idList = ConnectionStringUtility.GetToken(ConnectionString, "SeriesList", "").Split(','); string[] opList = ConnectionStringUtility.GetToken(ConnectionString, "OperatorList", "").Split(','); m_operation = new MathOperation[opList.Length]; m_items = new SeriesList(); for (int i = 0; i < idList.Length; i++) { int id = -1; if (!Int32.TryParse(idList[i], out id) || !db.SeriesExists(id)) { Logger.WriteLine("Cannot calculate series. Has the data this calculation needs been deleted?"); Name = "Error: source data missing " + Name; m_sourceDeleted = true; break; } else { Series s = db.GetSeries(id); m_items.Add(s); } } ScenarioName = m_items[0].ScenarioName; // TO DO assuming all scenarioNames are the same. for (int i = 0; i < opList.Length; i++) { m_operation[i] = MathOperationFromString(opList[i]); } }
public ShefSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { m_location = ConnectionStringUtility.GetToken(ConnectionString, "ShefLocation", ""); m_pecode = ConnectionStringUtility.GetToken(ConnectionString, "ShefCode", ""); m_filename = ConnectionStringUtility.GetToken(ConnectionString, "File", ""); InitTimeSeries(null, "", this.TimeInterval, true); }
public ExcelReaderSeries1(string connectionString) { this.filename = ConnectionStringUtility.GetToken(connectionString, "file", ""); this.sheetName = ConnectionStringUtility.GetToken(connectionString, "sheetName", ""); this.dateColumn = ConnectionStringUtility.GetToken(connectionString, "dateColumn", ""); this.valueColumn = ConnectionStringUtility.GetToken(connectionString, "valueColumn", ""); this.Name = valueColumn; }
protected override Series CreateFromConnectionString() { NrcsSnotelSeries s = new NrcsSnotelSeries( ConnectionStringUtility.GetToken(ConnectionString, "SiteNumber", ""), ConnectionStringUtility.GetToken(ConnectionString, "ParameterName", "")); return(s); }
protected override Series CreateFromConnectionString() { IDWRDailySeries s = new IDWRDailySeries( ConnectionStringUtility.GetToken(ConnectionString, "SiteID", ""), ConnectionStringUtility.GetToken(ConnectionString, "Parameter", "")); return(s); }
protected override Series CreateFromConnectionString() { UsgsDailyValueSeries s = new UsgsDailyValueSeries( ConnectionStringUtility.GetToken(ConnectionString, "site_no", ""), m_parameter); return(s); }
public OwrdSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { var str_dataset = ConnectionStringUtility.GetToken(this.ConnectionString, "DataSet", "MDF"); dataset = (OwrdDataSet)System.Enum.Parse(typeof(OwrdDataSet), str_dataset); m_includeProvisional = ConnectionStringUtility.GetBoolean(this.ConnectionString, "Provisional", false); station_nbr = ConnectionStringUtility.GetToken(this.ConnectionString, "StationNumber", ""); }
public HDBWebSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { string str = ConnectionStringUtility.GetToken(ConnectionString, "server", ""); m_server = (HDBServer)Enum.Parse(typeof(HDBServer), str); m_sdi = ConnectionStringUtility.GetIntFromConnectionString(ConnectionString, "sdi"); }
internal static void ParseConnectionString(string connectionString, out HydrometHost svr, out string cbtt, out string pcode) { string str = ConnectionStringUtility.GetToken(connectionString, "server", ""); svr = (HydrometHost)Enum.Parse(typeof(HydrometHost), str); cbtt = ConnectionStringUtility.GetToken(connectionString, "cbtt", ""); pcode = ConnectionStringUtility.GetToken(connectionString, "pcode", ""); }
public UsgsRealTimeSeries(TimeSeriesDatabase db, Reclamation.TimeSeries.TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { var p = ConnectionStringUtility.GetToken(ConnectionString, "UsgsParameter", ""); m_parameter = (UsgsRealTimeParameter)Enum.Parse(typeof(UsgsRealTimeParameter), p); m_site_no = ConnectionStringToken("site_no"); }
private void Init(TimeSeriesDatabase db) { fileName = ConnectionStringUtility.GetFileName(ConnectionString, db.DataSource); ScenarioName = Path.GetFileNameWithoutExtension(fileName); stationID = ConnectionStringUtility.GetToken(ConnectionString, "stationID", ""); varcode = ConnectionStringUtility.GetToken(ConnectionString, "varcode", ""); extra1 = ConnectionStringUtility.GetToken(ConnectionString, "extra1", ""); extra2 = ConnectionStringUtility.GetToken(ConnectionString, "extra2", ""); }
public MonthlySnowCourseSeries(TimeSeriesDatabase db, Reclamation.TimeSeries.TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { m_triplet = ConnectionStringUtility.GetToken(ConnectionString, "Triplet", ""); var p = ConnectionStringUtility.GetToken(ConnectionString, "SnotelParameter", ""); m_parameter = (SnotelParameterCodes)Enum.Parse(typeof(SnotelParameterCodes), p); Init(); }
public SnotelSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { m_triplet = ConnectionStringUtility.GetToken(ConnectionString, "Triplet", ""); var p = ConnectionStringUtility.GetToken(ConnectionString, "SnotelParameter", ""); m_parameter = (SnotelParameterCodes)Enum.Parse(typeof(SnotelParameterCodes), p); TimeInterval = TimeSeries.TimeInterval.Daily; }
public UsgsDailyValueSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { m_parameter = UsgsDailyParameter.DailyMeanDischarge; string str = ConnectionStringUtility.GetToken(ConnectionString, "UsgsDailyParameter", ""); if (Enum.IsDefined(typeof(UsgsDailyParameter), str)) { m_parameter = (UsgsDailyParameter)Enum.Parse(typeof(UsgsDailyParameter), str); } m_site_no = ConnectionStringUtility.GetToken(ConnectionString, "site_no", ""); }
public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario) { var s = new UrgwomSeries(ConnectionStringUtility.GetFileName(scenario.Path, m_db.DataSource), ConnectionStringUtility.GetToken(scenario.Path, "SheetName", ""), valueColumn); s.ScenarioName = scenario.Name; s.Name = ""; s.Appearance.LegendText = scenario.Name; return(s); }
/// <summary> /// Creates UrgsimSeries from TimeSeriesDatabase /// </summary> /// <param name="sdi"></param> /// <param name="db"></param> /// <param name="sr"></param> public UrgsimSeries(int sdi, TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { this.ExternalDataSource = true; m_path = ConnectionStringUtility.GetToken(ConnectionString, "Path", ""); m_projection = ConnectionStringUtility.GetToken(ConnectionString, "Projection", ""); m_variable = Parameter; ScenarioName = m_projection; Appearance.LegendText = ScenarioName; Units = GetUrgsimUnits(Parameter); }
/// <summary> /// CreateFromConnectionString is used when calling Update to /// update a portion of the record for this series. /// </summary> /// <returns></returns> protected override Series CreateFromConnectionString() { string svr = ConnectionStringUtility.GetToken(ConnectionString, "server", ""); m_server = (HDBServer)Enum.Parse(typeof(HDBServer), svr); m_sdi = ConnectionStringUtility.GetIntFromConnectionString(ConnectionString, "sdi"); string sinterval = ConnectionStringUtility.GetToken(ConnectionString, "TimeInterval", ""); TimeInterval = (TimeInterval)Enum.Parse(typeof(TimeInterval), sinterval); HDBWebSeries s = new HDBWebSeries(m_sdi, TimeInterval, m_server); return(s); }
public HdbModelSeries(TimeSeriesDatabase db, Reclamation.TimeSeries.TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { ExternalDataSource = true; ReadOnly = true; m_table = ConnectionStringUtility.GetToken(ConnectionString, "m_table", ""); site_datatype_id = ConnectionStringUtility.GetToken(ConnectionString, "site_datatype_id", "-1"); model_run_id = ConnectionStringUtility.GetToken(ConnectionString, "model_run_id", "-1"); model_run_name = ConnectionStringUtility.GetToken(ConnectionString, "mode_run_name", ""); run_date = ConnectionStringUtility.GetToken(ConnectionString, "run_date", ""); hdb_host_name = ConnectionStringUtility.GetToken(ConnectionString, "hdb_host_name", ""); ScenarioName = BuildScenairoName(model_run_name, model_run_id, run_date); Appearance.LegendText = SiteID + " " + Name; }
/// <summary> /// Creates RiverWareSeries from TimeSeriesDatabase /// </summary> /// <param name="sdi"></param> /// <param name="db"></param> public RiverWareSeries(TimeSeriesDatabase db, TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { m_filename = ConnectionStringUtility.GetFileName(ConnectionString, m_db.DataSource); this.ExternalDataSource = true; m_objectName = ConnectionStringUtility.GetToken(ConnectionString, "ObjectName", ""); m_slotName = ConnectionStringUtility.GetToken(ConnectionString, "SlotName", ""); int.TryParse(ConnectionStringUtility.GetToken(ConnectionString, "ScenarioNumber", ""), out m_scenarioNumber); bool.TryParse(ConnectionStringUtility.GetToken(ConnectionString, "IsSnapShot", ""), out m_isSnapShot); InitTimeSeries(null, this.Units, this.TimeInterval, this.ReadOnly, false, true); ScenarioName = "Run " + m_scenarioNumber; Appearance.LegendText = Name; }
public static ExcelDataReaderSeries CreateFromConnectionString(string connectionString, string dataPath) { string fileName = ConnectionStringUtility.GetToken(connectionString, "FileName", ""); if (!Path.IsPathRooted(fileName)) { fileName = Path.Combine(dataPath, fileName); } ExcelDataReaderSeries rval = new ExcelDataReaderSeries( fileName, ConnectionStringUtility.GetToken(connectionString, "SheetName", ""), ConnectionStringUtility.GetToken(connectionString, "DateColumn", ""), ConnectionStringUtility.GetToken(connectionString, "ValueColumn", "") ); return(rval); }
public void ParseConnectionString() { string s = @"file=c:\temp\myfile.xls;SheetName=sheet1;dateColumn=Date;ValueColumn=JCK AF"; string fn = ConnectionStringUtility.GetToken(s, "File", ""); Assert.AreEqual(@"c:\temp\myfile.xls", fn); string sheet = ConnectionStringUtility.GetToken(s, "sheetName", ""); Assert.AreEqual(@"sheet1", sheet); string dc = ConnectionStringUtility.GetToken(s, "dateColumn", ""); Assert.AreEqual(@"Date", dc); string vc = ConnectionStringUtility.GetToken(s, "valuecolumn", ""); Assert.AreEqual(@"JCK AF", vc); }
public Cr10xSeries(TimeSeriesDatabase db, Reclamation.TimeSeries.TimeSeriesDatabaseDataSet.SeriesCatalogRow sr) : base(db, sr) { ExternalDataSource = true; ReadOnly = true; m_filename = ConnectionStringUtility.GetToken(ConnectionString, "FileName", ""); if (!Path.IsPathRooted(m_filename)) { string dir = Path.GetDirectoryName(m_db.DataSource); m_filename = Path.Combine(dir, m_filename); } m_interval = ConnectionStringToken("Interval"); m_columnNumber = Convert.ToInt32(ConnectionStringUtility.GetToken(ConnectionString, "ColumnNumber", "")); InitTimeSeries(null, this.Units, this.TimeInterval, this.ReadOnly, false, true); Appearance.LegendText = Name; }
//public static SpreadsheetGearSeries ReadFromConnectionString(string connectionString, // string dataPath) //{ // SpreadsheetGearSeries rval = CreateFromConnectionString(connectionString, dataPath); // rval.Read(); // return rval; //} public static SpreadsheetGearSeries CreateFromConnectionString(string connectionString, string dataPath) { string fileName = ConnectionStringUtility.GetToken(connectionString, "FileName", ""); if (!Path.IsPathRooted(fileName)) { fileName = Path.Combine(dataPath, fileName); } SpreadsheetGearSeries rval = new SpreadsheetGearSeries( fileName, ConnectionStringUtility.GetToken(connectionString, "SheetName", ""), ConnectionStringUtility.GetToken(connectionString, "DateColumn", ""), ConnectionStringUtility.GetToken(connectionString, "ValueColumn", ""), ConnectionStringUtility.GetBoolean(connectionString, "IsWaterYearFormat", false), ConnectionStringUtility.GetToken(connectionString, "SiteColumn", ""), ConnectionStringUtility.GetToken(connectionString, "SiteFilter", "") ); return(rval); }
/// <summary> /// checks LastWriteTime in connection string and compares to /// the FileName in the connection string to see if a update is possible and is needed /// </summary> /// <param name="s"></param> /// <param name="fileName"></param> /// <returns></returns> public static bool CanUpdateFromFile(string connectionString, string dataPath) { string d = ConnectionStringUtility.GetToken(connectionString, "LastWriteTime", ""); var fileName = ConnectionStringUtility.GetToken(connectionString, "FileName", ""); if (!Path.IsPathRooted(fileName)) { fileName = Path.Combine(dataPath, fileName); } DateTime t = DateTime.MinValue; if (!DateTime.TryParse(d, out t)) { Logger.WriteLine("Update Error: Could not parse LastWriteTime in '" + connectionString + "'"); return(false); } if (!File.Exists(fileName)) { Logger.WriteLine("Update Error: File does not exist '" + fileName + "'"); return(false); } DateTime fileTime = File.GetLastWriteTime(fileName); fileTime = Convert.ToDateTime(fileTime.ToString(Series.DateTimeFormatInstantaneous)); bool rval = fileTime != t; if (!rval) { Logger.WriteLine("No update required"); } return(rval); }
public string GetConnectionStringParameter(string name, string defaultValue = "") { return(ConnectionStringUtility.GetToken(this.Path, name, defaultValue)); }