public void CalculatesAggregates() { DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Monthly/BiMonthly Aggregation Has Begun Running"); foreach (AggregateSeries variable in aggregatelist) { ClsDBAccessor dba = new ClsDBAccessor(variable, db); try { if (variable.DataTimePeriod == "Monthly") { //MonthlyAggregate DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} Monthly Aggregation Has Begun Running .", variable.SiteType)); int rows = dba.SummaryDB.monthlyAggregate(variable); DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} Monthly Aggregation Has Completed Running.", variable.SiteType, rows)); } else { //BiMonthlyAggregate DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} BiMonthly Aggregation Has Begun Running.", variable.SiteType)); int rows = dba.SummaryDB.biMonthlyAggregate(variable); DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} BiMonthly Aggregation Has Completed Running.", variable.SiteType, rows)); } } catch (Exception ex) { if (ex.Message.Contains("See the InnerException")) { DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{0}. {1}, {2}. ", ex.InnerException.Message, variable.SiteType, variable.DataTimePeriod)); } else { try { DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{1}: {0}. {2}, {3}. ", ex.Message, ex.InnerException.Message, variable.SiteType, variable.DataTimePeriod)); } catch { DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{0}. {1}, {2}. ", ex.Message, variable.SiteType, variable.DataTimePeriod)); } } } Thread.Sleep(10); } DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Monthly/BiMonthly Aggregation Completed Running"); }
/// <summary> /// Initializes a new instance of the OriginalAgencyData1_0 class. Builds a table to hold the DataValue information /// </summary> public Level1Data1_0(ClsDBAccessor dba) { this.db = dba; this.values = new DataTable("DataValues"); this.values.Columns.Add("ValueID", typeof(SqlInt64)); this.values.Columns.Add("DataValue", typeof(SqlDouble)); this.values.Columns.Add("valAccuracy", typeof(SqlDouble)); this.values.Columns.Add("LocalDT", typeof(SqlDateTime)); this.values.Columns.Add("UTCOffset", typeof(SqlDouble)); this.values.Columns.Add("DateUTC", typeof(SqlDateTime)); this.values.Columns.Add("varID", typeof(SqlInt32)); this.values.Columns.Add("siteID", typeof(SqlInt32)); this.values.Columns.Add("offsetVal", typeof(SqlDouble)); this.values.Columns.Add("offsetTypeID", typeof(SqlInt32)); this.values.Columns.Add("censorcode", typeof(SqlString)); this.values.Columns.Add("qualifierID", typeof(SqlInt32)); this.values.Columns.Add("methodID", typeof(SqlInt32)); this.values.Columns.Add("sourceID", typeof(SqlInt32)); this.values.Columns.Add("sampleID", typeof(SqlInt32)); this.values.Columns.Add("derivedfromID", typeof(SqlInt32)); this.values.Columns.Add("qclID", typeof(SqlInt32)); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { ClsDBAccessor dba = new ClsDBAccessor(); DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "DataSummary Running" + listAgencies(args)); var options = new Options(); if (CommandLineParser.Default.ParseArguments(args, options)) { // consume Options type properties if (options.Levels == null) { options.Levels = new List <string>(); options.Levels.Add("1"); options.Levels.Add("2"); options.Levels.Add("3"); options.Levels.Add("4"); } } foreach (string level in options.Levels) { switch (level) { case "1": if (options.Agency == null) { new getOriginalAgency(); } else { new getOriginalAgency(options.Agency.ToArray()); } // dba.SummaryDB.updateSeriesCatalag(); break; case "2": if (options.Agency == null) { new TimeAggregated(); } else { new TimeAggregated(options.Agency.ToArray()); } // dba.SummaryDB.updateSeriesCatalag(); break; case "3": if (options.Agency == null) { new IndexVariables(); } else { new IndexVariables(options.Agency.ToArray()); } // dba.SummaryDB.updateSeriesCatalag(); break; case "4": if (options.Agency == null) { new IndexValues(); } else { new IndexValues(options.Agency.ToArray()); } // dba.SummaryDB.updateSeriesCatalag(); break; } } DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Updating SeriesCatalog of Summary Database"); dba.SummaryDB.updateSeriesCatalag(); DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "DataSummary Completed Running" + listAgencies(args)); SendEmail.SendMessage("DataSummary Completed", "DataSummary has completed running, view the attached file for details", Properties.Settings.Default.projectName, new TimeSpan(7, 0, 0, 0)); }
private void downloadOriginal() { DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "getOriginalAgency" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 1 Data Harvesting Has Begun Running"); int count = 0; foreach (L1HarvestList variable in aggregatelist) { { count++; ClsDBAccessor dba = new ClsDBAccessor(variable, db); DateTime start = new DateTime(1900, 01, 01); DateTime end; //test to see if the series exits. int sID = dba.TooDB.SeriesExists(variable.SiteID, variable.VariableID); DateTime today = DateTime.Today; if (sID > 0) { DateTime s = dba.TooDB.GetLastDateOfSeries(sID); start = s.AddDays(1); } // set end date to yesterday end = new DateTime(today.Year, today.Month, today.Day).AddDays(-1); TimeSpan span = Convert.ToDateTime(end).Subtract(Convert.ToDateTime(start)); if (span > new TimeSpan(1, 0, 0, 0)) { try { if (variable.WebServiceURL.Contains("1_1")) { Level1Data1_1 m = new Level1Data1_1(dba); m.AgencyDataFill(variable, start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"), count); } else { try { Level1Data1_0 m = new Level1Data1_0(dba); m.AgencyDataFill(variable, start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"), count); } catch (Exception ex) { if (ex.Message.Contains("Server did not recognize the value of HTTP Header SOAPAction")) { Level1Data1_1 m = new Level1Data1_1(dba); m.AgencyDataFill(variable, start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"), count); } else { throw; } } } } catch (Exception ex) { if (ex.Message.Contains("See the InnerException")) { DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{0}. {3} {1}, {2}-{4}. ", ex.InnerException.Message, variable.SiteCode, variable.VariableCode, variable.SiteName, "Level1")); } else { try { DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{1}: {0}. {4} {2}, {3}-{5}. ", ex.Message, ex.InnerException.Message, variable.SiteCode, variable.VariableCode, variable.SiteName, "Level1")); } catch { DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{0}. {3} {1}, {2}-{4}. ", ex.Message, variable.SiteCode, variable.VariableCode, variable.SiteName, "Level1")); } } } } } Thread.Sleep(100); // variable = this.db.GetNextAggregateEntry(variable.AggregateID); } db.updateSeriesCatalag(); DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "getOriginalAgency" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 1 Data Harvesting Has Completed Running"); }