Beispiel #1
0
 public Update(DateTime t1, DateTime t2, SeriesProcess process)
 {
     InitializeComponent();
     this.timeSelectorBeginEnd1.T1 = t1;
     this.timeSelectorBeginEnd1.T2 = t2;
     this.process = process;
     if (process == SeriesProcess.Update)
     {
         Text             = "Update Selected Series";
         textBoxInfo.Text = "Click OK to update the selected series.  Pisces will reload data from the original source.  Existing data will be overwritten.";
         checkBoxFullPeriod.Hide();
     }
     if (process == SeriesProcess.Calculate)
     {
         Text                       = "Calculate Selected Series";
         textBoxInfo.Text           = "Click OK to calculate the selected series.  Pisces will recompute based on the math expression.  Existing data will be overwritten.";
         checkBoxFullPeriod.Checked = true;
         EnableDates(this, EventArgs.Empty);
     }
 }
Beispiel #2
0
 public Update(DateTime t1, DateTime t2, SeriesProcess process)
 {
     InitializeComponent();
     this.timeSelectorBeginEnd1.T1 = t1;
     this.timeSelectorBeginEnd1.T2 = t2;
     this.process = process;
     if (process == SeriesProcess.Update)
     {
         Text = "Update Selected Series";
         textBoxInfo.Text = "Click OK to update the selected series.  Pisces will reload data from the original source.  Existing data will be overwritten.";
         checkBoxFullPeriod.Hide();
     }
     if (process == SeriesProcess.Calculate)
     {
         Text = "Calculate Selected Series";
         textBoxInfo.Text = "Click OK to calculate the selected series.  Pisces will recompute based on the math expression.  Existing data will be overwritten.";
         checkBoxFullPeriod.Checked = true;
         this.timeSelectorBeginEnd1.SetInclusiveDates();
         EnableDates(this, EventArgs.Empty);
     }
 }
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("");
            }
        }
Beispiel #4
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("");
            }
        }