Beispiel #1
0
        private void ReadSeriesProperties()
        {
            textBoxName.Text          = m_series.Name;
            textBoxSiteName.Text      = m_series.SiteID;
            textBoxConnectString.Text = m_series.ConnectionString;
            textBoxProvider.Text      = m_series.Provider;
            textBoxNotes.Text         = m_series.Notes;
            textBoxExpression.Text    = m_series.Expression;
            checkBoxActive.Checked    = m_series.Enabled == 1;

            textBoxSource.Text = m_series.Source;
            if (m_series.Table == null)
            {
                textBoxDBTableName.Text = "";
            }
            else
            {
                textBoxDBTableName.Text = m_series.SeriesCatalogRow.TableName;
            }

            textBoxParameter.Text = m_series.Parameter;
            textBoxParentID.Text  = m_series.Parent.ID.ToString();
            PeriodOfRecord por = m_series.GetPeriodOfRecord();

            textBoxPOR1.Text        = por.T1.ToString();
            textBoxPOR2.Text        = por.T2.ToString();
            textBoxRecordCount.Text = por.Count.ToString();
            textBoxSiteID.Text      = m_series.ID.ToString();
            textBoxSortOrder.Text   = m_series.SortOrder.ToString();
            //textBoxAlias.Text = s.Alias;

            comboBoxUnits.SelectedItem = m_series.Units;

            //comboBoxDisplayUnits.Items.Clear();
            //comboBoxDisplayUnits.Items.Add("");
            //comboBoxDisplayUnits.Items.Add("degrees C");
            //comboBoxDisplayUnits.SelectedItem = s.DisplayUnits;
            //this.textBoxMath.Text = m_series.Expression;
            comboBoxTimeInterval.SelectedIndex = 0;
            comboBoxTimeInterval.SelectedItem  = m_series.TimeInterval.ToString();

            tblSeriesProperties = m_db.GetSeriesProperties();
            tblSeriesProperties.Columns["id"].AutoIncrement      = true;
            tblSeriesProperties.Columns["id"].AutoIncrementSeed  = tblSeriesProperties.NextID();
            tblSeriesProperties.Columns["seriesid"].DefaultValue = m_series.ID;
            dgvProperties.DataSource = tblSeriesProperties;
            tblSeriesProperties.DefaultView.RowFilter = "seriesid=" + m_series.ID;
            dgvProperties.Columns["id"].Visible       = false;
            dgvProperties.Columns["seriesid"].Visible = false;
        }
Beispiel #2
0
        public override PeriodOfRecord GetPeriodOfRecord()
        {
            string sql = "select min(start_date_time),max(end_date_time),count(*) from " + hdb_r_table + " where site_datatype_id = " + hdb_site_datatype_id;

            var hdb1 = HdbPoet.Hdb.GetInstance(hdb_host_name);
            var tbl  = hdb1.Server.Table("stat", sql);

            if (tbl.Rows[0][0] == DBNull.Value || tbl.Rows[0][1] == DBNull.Value)
            {
                return(base.GetPeriodOfRecord());
            }

            var t1    = Convert.ToDateTime(tbl.Rows[0][0]);
            var t2    = Convert.ToDateTime(tbl.Rows[0][1]);
            var count = Convert.ToInt32(tbl.Rows[0][2]);
            var rval  = new PeriodOfRecord(t1, t2, count);

            return(rval);
        }
Beispiel #3
0
        private void ProcessSelectedSeries(SeriesProcess process, Series[] list)
        {
            DateTime t1 = DateTime.Now.AddDays(-7);
            DateTime t2 = DateTime.Now.Date.AddHours(23).AddMinutes(59).AddSeconds(59);

            //Series[] list = tree1.GetSelectedSeries();

            // Causing stange results when using Hydromet years 9999, 7170,
            // added extract check (not into the future)
            PeriodOfRecord p = list[0].GetPeriodOfRecord();

            if (list.Length > 0 && p.Count > 0 && p.T2 < DateTime.Now.Date) // begin at the end of data
            {
                t1 = p.T2;
            }

            for (int i = 1; i < list.Length; i++)
            {
                PeriodOfRecord por = list[i].GetPeriodOfRecord();
                if (por.Count > 0 && por.T2 < t1 && por.T2 < DateTime.Now.Date)
                {
                    t1 = por.T2;
                }
            }

            try
            {
                Update u = new Update(t1, t2, process);

                if (u.ShowDialog() == DialogResult.OK)
                {
                    ShowAsBusy("");
                    Logger.WriteLine(process + " t1 = " + u.T1 + " t2= " + u.T2);
                    for (int i = 0; i < list.Length; i++)
                    {
                        Logger.WriteLine(process.ToString() + " " + list[i].Name);
                        Application.DoEvents();

                        if (process == SeriesProcess.Update && !(list[i] is CalculationSeries))
                        {
                            list[i].Update(u.T1, u.T2);
                        }
                        if (process == SeriesProcess.Calculate || list[i] is CalculationSeries)
                        {
                            var cs = list[i] as CalculationSeries;
                            if (DB.Settings.ReadBoolean("HydrometVariableResolver", false))
                            { // this reads data from hydromet server, over http, instead of 'this' database
                                var svr = HydrometInfoUtility.HydrometServerFromPreferences();
                                cs.Parser.VariableResolver = new HydrometVariableResolver(svr);
                            }

                            if (u.FullPeriodOfRecord)
                            {
                                cs.Calculate();
                            }
                            else
                            {
                                cs.Calculate(u.T1, u.T2);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                ShowAsReady("");
            }
        }