Пример #1
0
        private void ReadSettings()
        {
            var svr = HydrometInfoUtility.HydrometServerFromPreferences();

            // retiring PN
            if (svr == HydrometHost.PNLinux || svr == HydrometHost.PN)
            {
                this.radioButtonBoiseLinux.Checked = true;
            }
            else
            if (svr == HydrometHost.Yakima)
            {
                this.radioButtonYakHydromet.Checked = true;
            }
            else
            if (svr == HydrometHost.GreatPlains)
            {
                this.radioButtonGP.Checked = true;
            }
            else if (svr == HydrometHost.LocalSource)
            {
                radioButtonLocal.Checked = true;
            }

            this.textBoxDbName.Text = UserPreference.Lookup("TimeSeriesDatabaseName", "timeseries");
        }
Пример #2
0
        private void importFromDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                DB.SuspendTreeUpdates();
                var path = UserPreference.Lookup("bulk_import_folder");

                FolderBrowserDialog dlg = new FolderBrowserDialog();
                if (Directory.Exists(path))
                {
                    dlg.SelectedPath = path;
                }
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    UserPreference.Save("bulk_import_folder", dlg.SelectedPath);
                    BulkImportForm f = new BulkImportForm();
                    f.ImportClick += delegate {
                        BulkImportDirectory.Import(DB, f.SelectedPath, f.Filter, f.RegexFilter);
                    };
                    f.SelectedPath = dlg.SelectedPath;

                    f.ShowDialog();
                    DatabaseChanged();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DB.ResumeTreeUpdates();
            }
        }
Пример #3
0
        public static void ShowStatus(string status, bool showAllways = false)
        {
            var lines = status.Split('\n');

            foreach (var item in lines)
            {
                Logger.WriteLine(item);
            }

            if (UserPreference.Lookup("HideStatusDialog") != "True" || showAllways)
            {
                var f = new FormStatus();
                f.Lines = lines;
                f.ShowDialog();

                if (f.HideDialogNextTime)
                {
                    UserPreference.Save("HideStatusDialog", "True");
                }
                else
                {
                    UserPreference.Save("HideStatusDialog", "False");
                }
            }
        }
Пример #4
0
        public SnowGG()
        {
            InitializeComponent();
            this.comboBoxCbtt.Text  = UserPreference.Lookup("Snowgg->cbtt");
            this.comboBoxPcode.Text = UserPreference.Lookup("Snowgg->pcode");


            //
            // timeSeriesGraph1
            //
            this.timeSeriesGraph1 = new Reclamation.TimeSeries.Graphing.TimeSeriesTeeChartGraph();
            Reclamation.TimeSeries.Forms.Graphing.GraphSettings graphSettings2 = new GraphSettings();
            this.timeSeriesGraph1.AnnotationOnMouseMove = false;
            this.timeSeriesGraph1.Dock                    = System.Windows.Forms.DockStyle.Fill;
            this.timeSeriesGraph1.GraphSettings           = graphSettings2;
            this.timeSeriesGraph1.Location                = new System.Drawing.Point(0, 131);
            this.timeSeriesGraph1.Margin                  = new System.Windows.Forms.Padding(4);
            this.timeSeriesGraph1.MissingDataValue        = -999D;
            this.timeSeriesGraph1.MonthlySummaryMultiYear = false;
            this.timeSeriesGraph1.MultiLeftAxis           = false;
            this.timeSeriesGraph1.Name                    = "timeSeriesGraph1";
            this.timeSeriesGraph1.Size                    = new System.Drawing.Size(732, 296);
            this.timeSeriesGraph1.SubTitle                = "";
            this.timeSeriesGraph1.TabIndex                = 1;
            this.timeSeriesGraph1.Title                   = "";
            this.Controls.Remove(this.panel1);
            this.Controls.Add(this.timeSeriesGraph1);
            this.Controls.Add(this.panel1);


            Reset();
            this.timeSeriesGraph1.AfterEditGraph  += timeSeriesGraph1_AfterEditGraph;
            timeSeriesGraph1.AnnotationOnMouseMove = true;
        }
Пример #5
0
        public static HydrometHost HydrometServerFromPreferences()
        {
            HydrometHost svr = HydrometInfoUtility.HydrometServerFromString(
                UserPreference.Lookup("HydrometServer"));

            return(svr);
        }
Пример #6
0
        private void RefreshClick(object sender, System.EventArgs e)
        {
            if (this.comboBoxInputs.Text.IndexOf(":") == 0)
            {
                return;
            }

            UserPreference.Save("Inputs" + m_db.ToString(), this.comboBoxInputs.Text);

            this.dragPoint1.Active = false;
            Cursor = Cursors.WaitCursor;
            timeSeriesSpreadsheet1.Clear();
            Application.DoEvents();
            try
            {
                dataTable = this.GetTimeSeries();
                dataTable.AcceptChanges();
                dataTable.RowChanged += new DataRowChangeEventHandler(dataTable_RowChanged);
                Logger.WriteLine(UserPreference.Lookup("HydrometServer"), "ui");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Logger.WriteLine("error reading data from " + UserPreference.Lookup("HydrometServer") + " " + ex.ToString(), "ui");
                Logger.WriteLine(ex.ToString());
            }
            finally
            {
                Cursor = Cursors.Default;
            }
            if (dataTable == null)
            {
                return;
            }


            Logger.WriteLine(dataTable.Rows.Count + " rows of data read", "ui");
            if (dataTable.Rows.Count > 0)
            {
                dataTable.WriteXml(originalDataXmlFilename, XmlWriteMode.WriteSchema);
            }

            Graph();

            SetupUsgsLink();
            timeSeriesSpreadsheet1.SetDataTable(dataTable, m_db, true);
            timeSeriesSpreadsheet1.AutoFlagDayFiles = UserPreference.Lookup("AutoFlagDayFiles") == "True";

            //this.comboBoxEditSeries.Items.Clear();
            //this.comboBoxEditSeries.Items.Add("None");
            //for(int i=0; i<tChart1.Series.Count; i++)
            //{
            //    string columnName = tChart1.Series[i].Title;
            //    this.comboBoxEditSeries.Items.Add(columnName);
            //}

            //this.comboBoxEditSeries.SelectedIndex =0;
        }
Пример #7
0
 private void Init()
 {
     SaveToVMS           = UserPreference.Lookup("SaveToVMS") == "True";
     ComputeDependencies = UserPreference.Lookup("ComputeDependencies") == "True";
     if (m_interval == TimeInterval.Monthly)
     {
         checkBoxDependencies.Enabled = false;
         checkBoxDependencies.Checked = false;
     }
 }
Пример #8
0
        private static string GetPassword()
        {
            var pw = UserPreference.Lookup("timeseries_database_password", "");

            if (pw != "")
            {
                pw = StringCipher.Decrypt(pw, "");
            }
            return(pw);
        }
Пример #9
0
        //public bool AgrimetOptionsVisible
        //{
        //   // get { return this.groupBoxAgrimet.Visible; }
        //    set { this.groupBoxAgrimet.Visible = value; }
        //}


        //public bool ComputeET
        //{
        //    get { return checkBoxET.Checked; }
        //}
        ////public bool SendToWeb
        //{
        //    get { return checkBoxWeb.Checked; }
        //}
        //public bool CropCharts
        //{
        //    get { return checkBoxCropCharts.Checked; }
        //}


        void ReadPreferences()
        {
            this.textBoxUser.Text = UserPreference.Lookup("UserName");
            this.Text             = "Save changes " + UserPreference.Lookup("HydrometServer");

            //  this.checkBoxCropCharts.Checked = (UserPreference.Lookup("BuildCropCharts") == "True");
            //this.checkBoxET.Checked = (UserPreference.Lookup("ComputeET") == "True");
            this.checkBoxArchiver.Checked = (UserPreference.Lookup("RunArchiver") == "True");
//            this.checkBoxWeb.Checked = (UserPreference.Lookup("SendToWeb") == "True");
        }
Пример #10
0
        public SnowGG()
        {
            InitializeComponent();
            this.comboBoxCbtt.Text  = UserPreference.Lookup("Snowgg->cbtt");
            this.comboBoxPcode.Text = UserPreference.Lookup("Snowgg->pcode");


            Reset();
            this.timeSeriesGraph1.AfterEditGraph  += timeSeriesGraph1_AfterEditGraph;
            timeSeriesGraph1.AnnotationOnMouseMove = true;
        }
Пример #11
0
        public TimeSeriesHydrographEditor(TimeInterval db)
        {
            InitializeComponent();

#if SpreadsheetGear
            var uc = new TimeSeriesSpreadsheetSG();
#else
            var uc = new TimeSeriesSpreadsheet();
#endif
            uc.Parent = this.panelGraphTable;
            uc.Dock   = DockStyle.Fill;
            uc.BringToFront();

            timeSeriesSpreadsheet1 = uc;

            m_db = db;
            //SetupTimeSelector(db);

            this.checkBoxShowPoints.Checked = UserPreference.Lookup("ShowPoints") == "True";


            annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);

            originalDataXmlFilename = Path.Combine(FileUtility.GetTempPath(), db.ToString() + DateTime.Now.Ticks + "_download.xml");

            checkBoxShowBadData.Visible = false;

            Logger.WriteLine(m_db.ToString(), "ui");
            if (m_db == TimeInterval.Daily)
            {
                BackColor = Color.Lavender;
            }


            dragPoint1            = new Steema.TeeChart.Tools.DragPoint();
            this.dragPoint1.Style = Steema.TeeChart.Tools.DragPointStyles.Y;
            this.tChart1.Tools.Add(this.dragPoint1);
            this.dragPoint1.Drag += new Steema.TeeChart.Tools.DragPointEventHandler(this.dragPoint1_Drag);


            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
            var nearest = new Steema.TeeChart.Tools.NearestPoint(tChart1.Chart);

            LoadSiteList();
            this.comboBoxInputs.Text = UserPreference.Lookup("Inputs" + m_db.ToString());


            this.dragPoint1.Active = false;
            this.dragPoint1.Series = null;
            //    HydrometEdits.Progress += new ProgressEventHandler(HydrometEdits_Progress);

            timeSeriesSpreadsheet1.UpdateCompleted += new EventHandler <EventArgs>(timeSeriesSpreadsheet1_UpdateCompleted);
        }
Пример #12
0
        public MainForm()
        {
            InitializeComponent();
            var fn = UserPreference.Lookup("FileName");

            if (File.Exists(fn))
            {
                OpenFile(fn);
            }

            Text += " " + Application.ProductVersion;
        }
Пример #13
0
        private void Init()
        {
            SaveToVMS           = UserPreference.Lookup("SaveToVMS") == "True";
            ComputeDependencies = UserPreference.Lookup("ComputeDependencies") == "True";
            if (m_interval == TimeInterval.Monthly)
            {
                checkBoxDependencies.Enabled = false;
                checkBoxDependencies.Checked = false;
            }
            HydrometHost svr = HydrometInfoUtility.HydrometServerFromPreferences();

            this.checkBoxSaveVMS.Enabled = !(svr == HydrometHost.PNLinux || svr == HydrometHost.YakimaLinux);
        }
Пример #14
0
        public void ReadUserPref()
        {
            this.checkBoxAdmin.Checked      = UserPreference.Lookup("Admin") == "True";
            this.checkBoxHideStatus.Checked = UserPreference.Lookup("HideStatusDialog") == "True";
            this.checkBoxCompute.Checked    = UserPreference.Lookup("EnableComputations") == "True";
            //this.checkBoxAgrimet.Checked = UserPreference.Lookup("AgrimetCalculations") == "True";
            this.checkBoxMultipleYAxis.Checked    = UserPreference.Lookup("MultipleYAxis") == "True";
            this.checkBoxAutoFlagDayfiles.Checked = UserPreference.Lookup("AutoFlagDayFiles") == "True";

            string pw = UserPreference.Lookup("timeseries_database_password");;

            if (pw != "")
            {
                this.textBoxDbPassword.Text = StringCipher.Decrypt(pw, "");
            }
        }
Пример #15
0
        private void linkLabelSelectDirectory_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            var path = UserPreference.Lookup("bulk_import_folder");

            if (Directory.Exists(path))
            {
                dlg.SelectedPath = path;
            }

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.linkLabelSelectDirectory.Text = dlg.SelectedPath;
                buttonApplyFilter_Click(this, EventArgs.Empty);
            }
        }
Пример #16
0
        private void ReadGroups()
        {
            var pw = UserPreference.Lookup("timeseries_database_password");

            pw = StringCipher.Decrypt(pw, "");

            if (pw == "")
            {
                throw new Exception("Notifications require a database password. Please enter that in the settings/general tab");
            }

            var svr = PostgreSQL.GetPostgresServer("hydromet", password: pw);

            HydrometNotifications.AlarmDataSet.DB = svr;
            dataGridView1.AutoGenerateColumns     = false;
            dataGridView1.DataSource =
                HydrometNotifications.AlarmDataSet.GetGroups();
        }
Пример #17
0
        public Settings(bool compilePublic = false)
        {
            serverSelection1 = new Reclamation.TimeSeries.Forms.Hydromet.ServerSelection();
            InitializeComponent();
            ReadUserPref();
            Ready = true;
            var c = new HydrometNotifications.UserInterface.NotificationMain();

            c.Parent  = tabPageNotifications;
            c.Dock    = DockStyle.Fill;
            c.Visible = true;
            if (compilePublic)
            {
                groupBox1.Visible = false;
                this.tabControl1.Controls.Remove(tabPageAlarms);
                this.tabControl1.Controls.Remove(tabPageLog);
                this.tabControl1.Controls.Remove(tabPageNotifications);
                this.checkBoxForceWebService.Checked = Convert.ToBoolean(UserPreference.Lookup("CompilePublic"));
            }
        }
Пример #18
0
        private static string GetFileName(string[] args)
        {
            string fileName = "";

            if (args.Length == 1)
            {
                fileName = args[0];
            }

            else if (UserPreference.Lookup("fileName") != "" &&
                     File.Exists(UserPreference.Lookup("fileName")) &&
                     Path.GetExtension(UserPreference.Lookup("fileName")) != ".sdf")
            {
                fileName = UserPreference.Lookup("fileName");
            }
            else
            {// open default database
                var paths = new List <string>()
                {
                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                    FileUtility.GetLocalApplicationPath(),
                    FileUtility.GetTempPath()
                };

                foreach (var item in paths)
                {
                    if (HasWriteAccessToFolder(item))
                    {
                        fileName = Path.Combine(item, "tsdatabase.pdb");
                        break;
                    }
                }
            }

            if (!File.Exists(fileName))
            {
                SQLiteServer.CreateNewDatabase(fileName);
            }
            return(fileName);
        }
Пример #19
0
        private void LoadDatabaseList()
        {
            if (dbList.Count == 0)
            {
                return;
            }

            if (!dbList.Contains(clearItems))
            {
                dbList.Add(clearItems);
            }

            string[] items = new string[dbList.Count];
            dbList.CopyTo(items, 0);
            this.comboBox1.Items.Clear();
            comboBox1.Items.AddRange(items);

            var s = UserPreference.Lookup("SelectedDatabaseServer");

            comboBox1.SelectedItem = s;
            comboBox1_SelectionChangeCommitted(comboBox1, EventArgs.Empty);
        }
Пример #20
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                Application.DoEvents();
                timeSeriesGraph1.Clear();
                string   data  = graphProperties1.SelectedItem.Trim();
                string   title = "";
                int[]    wy    = null;
                string[] cbtt;
                string[] pcode;
                ParseInput(data, out title, out wy, out cbtt, out pcode);

                var list = new SeriesList();
                for (int i = 0; i < cbtt.Length; i++)
                {
                    YearRange yr = new YearRange(wy[i], this.monthDayRangePicker1.BeginningMonth);
                    var       s  = new HydrometDailySeries(cbtt[i], pcode[i]);
                    DateTime  t1 = new DateTime(yr.DateTime1.Year, monthDayRangePicker1.MonthDayRange.Month1, monthDayRangePicker1.MonthDayRange.Day1);
                    DateTime  t2 = new DateTime(yr.DateTime2.Year, monthDayRangePicker1.MonthDayRange.Month2, monthDayRangePicker1.MonthDayRange.Day2);

                    s.Read(t1, t2);
                    Series s2 = Reclamation.TimeSeries.Math.ShiftToYear(s, 2000);
                    s2.Appearance.LegendText = cbtt[i] + " " + pcode[i] + " " + wy[i];
                    list.Add(s2);
                }

                this.timeSeriesGraph1.AnalysisType = AnalysisType.WaterYears;
                this.timeSeriesGraph1.Series       = list;
                timeSeriesGraph1.MultiLeftAxis     = UserPreference.Lookup("MultipleYAxis") == "True";
                this.timeSeriesGraph1.Title        = title;
                this.timeSeriesGraph1.Draw(true);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Пример #21
0
        void LoadSiteList()
        {
            string fn = "site.txt";

            if (m_db == TimeInterval.Irregular)
            {
                fn = "day_site.txt";
            }
            else if (m_db == TimeInterval.Daily)
            {
                fn = "arc_site.txt";
            }
            else if (m_db == TimeInterval.Monthly)
            {
                fn = "mpoll_site.txt";
            }

            string property = m_db.ToString() + "FileName";

            UserPreference.SetDefault(property, fn, false);

            fn = UserPreference.Lookup(property);
            ReadFile(fn);
        }
Пример #22
0
        internal static TimeSeriesDatabase DB()
        {
            HydrometHost h = HydrometInfoUtility.HydrometServerFromPreferences();

            var dbname = UserPreference.Lookup("TimeSeriesDatabaseName");

            if (File.Exists(dbname))
            { // local sqlite
                Logger.WriteLine("reading: " + dbname);
                var x = TryLocalDatabase(dbname, h);
                if (x != null)
                {
                    return(x);
                }
            }

            if (s_db == null || s_db.Server.Name != dbname ||
                HydrometHostDiffers(h))
            {
                if (IsPasswordBlank())
                {
                    return(null);
                }

                BasicDBServer svr = GetServer(dbname);
                if (svr == null)
                {
                    return(null);
                }
                s_db = new TimeSeriesDatabase(svr, LookupOption.TableName, false);
                s_db.Parser.VariableResolver = new HydrometVariableResolver(h);
                s_db.Parser.VariableResolver.LookupOption = LookupOption.TableName;
            }

            return(s_db);
        }
Пример #23
0
        public void GraphData(bool showFlows = false)
        {
            linkLabelReport.Visible = false;
            if (comboBoxSite.Text.ToString() == "" || this.comboBoxSite.SelectedItem.ToString().IndexOf("--") != -1)
            {
                return;
            }
            try
            {
                optionalPercents = ParseOptionalPercentages();
                Series     alternateRequiredContent = new Series();
                Series     alternateActualContent   = new Series();
                Series     actualContent            = new Series();
                Series     requiredContent          = new Series();
                SeriesList targets           = new SeriesList();
                SeriesList hmList            = new SeriesList();
                SeriesList hmList2           = new SeriesList();
                SeriesList ruleCurves        = new SeriesList();
                var        cache             = new HydrometDataCache();
                var        cbttList          = new List <string>();
                var        cbttListAlternate = new List <string>();
                var        labelDates        = new List <DateTime>();
                bool       showRuleCurve     = true;
                Reclamation.TimeSeries.Hydromet.HydrometHost svr;
                var hydSvr = UserPreference.Lookup("HydrometServer");
                if (hydSvr.ToLower() == "greatplains")
                {
                    svr = HydrometHost.GreatPlains;
                }
                else
                {
                    svr = HydrometHost.PNLinux;
                }


                Cursor = Cursors.WaitCursor;
                Application.DoEvents();
                FloodControlPoint pt = new FloodControlPoint(this.comboBoxSite.Text.ToString());

                if (compilePublic)
                {
                    pt.StationFC      = "NA";
                    pt.StationQU      = "NA";
                    pt.RequiredLegend = "Full Storage";
                    showRuleCurve     = false;
                }

                if (pt.DailyStationQU == "NA")
                {
                    return;
                }
                if (showFlows)
                {
                    this.pcodeInitial.Text = (pt.ResOpsInflow + "," + pt.ResOpsOutflow).ToLower();
                    hydrometChart1.SetRightLabels("Flows (cfs)");
                }

                checkBoxDashed.Visible = pt.StationFC.ToLower() == "heii";

                residForecast        = new ResidualForecast(pt, checkBoxDashed.Checked);
                residForecastCompare = new ResidualForecast(pt, checkBoxDashed.Checked);

                DateRange requiredRange  = GetRequiredRange();
                DateRange curveRange     = GetRuleCurveRange();
                DateRange alternateRange = GetComparisonRange();

                //setup cache for required
                cbttList.AddRange(residForecast.DailyCbttPcodeList());
                if (this.pcodeInitial.Text.Length >= 1 && this.textBoxWaterYear.Text.Length >= 1)
                {
                    cbttList.AddRange(OptionalCbttList(this.pcodeInitial.Text));
                }
                cache.Add(cbttList.ToArray(), requiredRange.DateTime1.AddDays(-1), requiredRange.DateTime2.AddDays(1), svr, TimeInterval.Daily);
                cache.Add(residForecast.MonthlyCbttPcodeList(), requiredRange.DateTime1, requiredRange.DateTime2, svr, TimeInterval.Monthly);

                // setup cache for alternate range
                if (alternateRange.IsValid)
                {
                    cbttListAlternate.AddRange(residForecast.DailyCbttPcodeList());
                    if (this.pcodeComparison.Text.Length >= 1)
                    {
                        cbttListAlternate.AddRange(OptionalCbttList(this.pcodeComparison.Text));
                    }
                    cache.Add(cbttListAlternate.ToArray(), alternateRange.DateTime1.AddDays(-1), alternateRange.DateTime2.AddDays(1), svr, TimeInterval.Daily);
                    cache.Add(residForecast.MonthlyCbttPcodeList(), alternateRange.DateTime1.AddDays(-1), alternateRange.DateTime2.AddDays(1), svr, TimeInterval.Monthly);
                }

                //add cache
                HydrometDailySeries.Cache   = cache;
                HydrometMonthlySeries.Cache = cache;

                //compute residual forecast
                residForecast.Compute(requiredRange.DateTime1, requiredRange.DateTime2, svr);
                requiredContent      = -residForecast.SpaceRequired + pt.TotalUpstreamActiveSpace;
                actualContent        = residForecast.TotalContent;
                requiredContent.Name = this.textBoxWaterYear.Text;
                actualContent.Name   = this.textBoxWaterYear.Text + " Actual";

                if (this.pcodeInitial.Text.Length >= 1)
                {
                    hmList = ReadHydrometOptionalData(Convert.ToInt32(this.textBoxWaterYear.Text), this.pcodeInitial.Text, requiredRange);
                }

                //compute comparison year residual forecast
                if (alternateRange.IsValid)
                {
                    residForecastCompare.Compute(alternateRange.DateTime1, alternateRange.DateTime2, svr);
                    alternateRequiredContent      = -residForecastCompare.SpaceRequired + pt.TotalUpstreamActiveSpace;
                    alternateRequiredContent.Name = this.textBoxAlternateWaterYear.Text;
                    alternateActualContent        = residForecastCompare.TotalContent;
                    alternateActualContent.Name   = this.textBoxAlternateWaterYear.Text + " Actual";
                    if (this.pcodeComparison.Text.Length >= 1)
                    {
                        hmList2 = ReadHydrometOptionalData(Convert.ToInt32(this.textBoxAlternateWaterYear.Text), this.pcodeComparison.Text, alternateRange);
                        hmList.AddRange(hmList2);
                    }
                }

                if (showGreenLines.Checked == true && !compilePublic) // display flood rule curves for various forecast levels
                {
                    showRuleCurve = true;
                    // Green lines
                    if (residForecast.RuleCurve.FillType == FillType.Fixed)
                    {
                        ruleCurves = residForecast.RuleCurve.CalculateFixedRuleCurve(curveRange.DateTime1, curveRange.DateTime2, pt.TotalUpstreamActiveSpace);
                        labelDates.Add(curveRange.DateTime1);
                    }
                    else
                    {
                        ruleCurves = residForecast.RuleCurve.CalculateVariableRuleCurves(curveRange.DateTime1, curveRange.DateTime2, pt.TotalUpstreamActiveSpace, pt.PercentSpace / 100.0);
                        labelDates.AddRange(FcPlotDataSet.GetVariableForecastLabelDates(residForecast.RuleCurve.CurveName));
                    }
                }
                else
                {
                    showRuleCurve = false;
                }
                hydrometChart1.SetLabels(pt.Name, "Storage Content (acre-feet)");

                bool dashedLines = checkBoxDashed.Checked && pt.StationFC.ToLower() == "heii";

                // DEFAULT - Plots daily storage content data
                if (!checkBoxShowInstantAF.Checked && !checkBoxShowElevation.Checked)
                {
                    hydrometChart1.Fcplot(residForecast.TotalContent, requiredContent, alternateRequiredContent,
                                          alternateActualContent, ruleCurves, labelDates.ToArray(), pt.RequiredLegend, hmList, showRuleCurve,
                                          dashedLines);

                    //compute the targets
                    if (pt.FillType == FillType.Variable && (showTarget.Checked == true || checkBoxOverrideFcast.Checked == true))
                    {
                        if (Convert.ToInt32(this.textBoxWaterYear.Text) == DateTime.Now.WaterYear())
                        {
                            actualContent.RemoveMissing();
                            var startPt = actualContent[actualContent.Count - 1];
                            targets = FloodOperation.ComputeTargets(pt, Convert.ToInt32(this.textBoxWaterYear.Text), startPt,
                                                                    optionalPercents, checkBoxDashed.Checked, this.checkBoxOverrideFcast.Checked, this.textBoxOverrideFcast.Text);
                            var aColors = new Color[] { Color.Black, Color.Maroon, Color.Indigo, Color.DarkSlateGray, Color.SaddleBrown };
                            for (int i = 0; i < targets.Count; i++)
                            {
                                var s = targets[i];
                                var c = Color.Black;
                                if (i < aColors.Length)
                                {
                                    c = aColors[i];
                                }
                                hydrometChart1.CreateTarget(c, s.Name, s, "left");
                                // Add target to datatable
                                residForecast.AddColumnToReportTable(s);
                            }
                        }
                    }
                }
                else
                {
                    string leftPcode = "af";;
                    if (this.checkBoxShowElevation.Checked)
                    {
                        leftPcode = "fb";
                        hydrometChart1.SetLabels(pt.Name, "Water Level Elevation (feet)");

                        if (alternateRange.IsValid)
                        {
                            var sAlternate = new Series();
                            if (checkBoxShowInstantAF.Checked)
                            {
                                sAlternate = new HydrometInstantSeries(pt.UpstreamReservoirs[0], leftPcode, svr);
                            }
                            else
                            {
                                sAlternate = new HydrometDailySeries(pt.UpstreamReservoirs[0], leftPcode, svr);
                            }
                            sAlternate.Read(alternateRange.DateTime1, alternateRange.DateTime2);
                            sAlternate.Name        = this.textBoxAlternateWaterYear.Text + " Actual";
                            sAlternate.Units       = residForecast.TotalContent.Units;
                            alternateActualContent = sAlternate;
                        }
                    }

                    if (pt.UpstreamReservoirs.Length == 1)
                    {
                        var s = new Series();
                        if (checkBoxShowInstantAF.Checked)
                        {
                            var sInstant = new HydrometInstantSeries(pt.UpstreamReservoirs[0], leftPcode, svr);
                            s = sInstant;
                        }
                        else
                        {
                            var sDaily = new HydrometDailySeries(pt.UpstreamReservoirs[0], leftPcode, svr);
                            s = sDaily;
                        }
                        s.Read(residForecast.TotalContent.MinDateTime, residForecast.TotalContent.MaxDateTime.AddDays(1));
                        s.Name  = residForecast.TotalContent.Name;
                        s.Units = residForecast.TotalContent.Units;

                        hydrometChart1.Fcplot(s, requiredContent, alternateRequiredContent,
                                              alternateActualContent, ruleCurves, labelDates.ToArray(), pt.RequiredLegend, hmList, showRuleCurve,
                                              dashedLines, checkBoxShowElevation.Checked);
                    }
                }

                linkLabelReport.Visible  = true;
                labelFlagLegend.Text     = pt.FlagLegend;
                dataGridView1.DataSource = residForecast.ReportTable;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            Cursor = Cursors.Default;
        }
Пример #24
0
        /// <summary>
        /// graphs data in dataTable
        /// </summary>
        void Graph()
        {
            UserPreference.Save("ShowPoints", this.checkBoxShowPoints.Checked.ToString());

            tChart1.Text = "";
            if (dataTable == null)
            {
                return;
            }
            Console.WriteLine("graph()");

            tChart1.Series.Clear();
            tChart1.Zoom.Undo();
            int sz = dataTable.Columns.Count;

            if (sz == 2 || (sz == 3 && m_db == TimeInterval.Irregular) ||
                (sz == 3 && m_db == TimeInterval.Monthly))     // single graph series.
            {
                this.tChart1.Legend.Visible = false;
            }
            else
            {
                this.tChart1.Legend.Visible = true;
            }
            string subTitle = "";

            this.tChart1.Header.Text       = GetHeaderTitle(out subTitle);
            this.tChart1.SubHeader.Visible = false;
            if (subTitle.Trim() != "")
            {
                this.tChart1.SubHeader.Text    = subTitle;
                this.tChart1.SubHeader.Visible = true;
            }
            int increment = 1;

            if (m_db == TimeInterval.Irregular || m_db == TimeInterval.Monthly)
            {
                increment = 2;
            }
            tChart1.Axes.Custom.RemoveAll();
            tChart1.Panel.MarginLeft                  = 3;
            tChart1.Axes.Left.Title.Text              = "";
            tChart1.Axes.Right.Title.Text             = "";
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "MM/dd";
            for (int i = 1; i < sz; i += increment)
            {
                try
                {
                    string columnName = dataTable.Columns[i].ColumnName;
                    double avg        = AverageOfColumn(dataTable, columnName);
                    Steema.TeeChart.Styles.Line series = MakeSeries(dataTable, columnName, avg);

                    series.VertAxis        = Steema.TeeChart.Styles.VerticalAxis.Left;
                    series.Pointer.Visible = this.checkBoxShowPoints.Checked;

                    var    tokens = TextFile.Split(columnName);
                    string pcode  = "";
                    string cbtt   = "";
                    if (tokens.Length == 2)
                    {
                        cbtt  = tokens[0].Trim();
                        pcode = tokens[1].Trim();
                    }


                    string units = LookupUnits(pcode);


                    if (UserPreference.Lookup("MultipleYAxis") == "True")
                    {
                        TChartDataLoader.SetupMultiLeftAxis(tChart1, series, units);
                    }
                    else
                    {
                        TChartDataLoader.SetupAxisLeftRight(tChart1, series, units);
                    }

                    /*    //if (i == 1)
                     *  //{
                     *  //    vertLabel1 = Hydromet.LookupMcfPcodeDescription(cbtt, pcode);
                     *  //    tChart1.Axes.Left.Title.Text = vertLabel1;
                     *  //    firstPcode = pcode;
                     *  //}
                     *  //else
                     *  //{ // determine if we should use right vertical axis.
                     *  //    if (firstPcode.ToLower().Trim() != pcode.Trim().ToLower())
                     *  //    {
                     *  //        series.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
                     *  //    }
                     *  //}
                     */


                    tChart1.Series.Add(series);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString() + " series index " + i);
                    Logger.WriteLine(e.ToString(), "ui");
                }

                if (tChart1.Series.Count > 0)
                {
                    dragPoint1.Series = tChart1[0];
                    dragPoint1.Active = true;
                }
                else
                {
                    dragPoint1.Active = false;
                }
            }
            //tChart1.Zoom.ZoomPercent(94);
            this.comboBoxEditSeries_SelectedIndexChanged(null, null);
        }
Пример #25
0
        static void Main(string[] args)
        {
            Logger.EnableLogger(true);
            var x = HdbPoet.Hdb.Instance; // force this assembly to load.

            try
            {
                string fileName = "";
                if (args.Length == 1)
                {
                    fileName = args[0];
                    if (!File.Exists(fileName))
                    {
                        MessageBox.Show("Could not open file '" + fileName + "'");
                        return;
                    }
                }

                else if (UserPreference.Lookup("fileName") != "" &&
                         File.Exists(UserPreference.Lookup("fileName")) &&
                         Path.GetExtension(UserPreference.Lookup("fileName")) != ".sdf")
                {
                    fileName = UserPreference.Lookup("fileName");
                }
                else
                {// open default database
                    fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tsdatabase.pdb";
                }

                if (!File.Exists(fileName))
                {
                    SQLiteServer.CreateNewDatabase(fileName);
                }

                HydrometInfoUtility.SetDefaultHydrometServer();


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadExit      += new EventHandler(Application_ThreadExit);
                Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
                //Application.Idle += new EventHandler(Application_Idle);
                //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);


                explorer = new PiscesSettings(new ExplorerView());
                // explorer.Database

                explorer.Open(fileName);
                db = explorer.Database;

                piscesForm1 = new PiscesForm(explorer);



                piscesForm1.FormClosed += new FormClosedEventHandler(explorerForm1_FormClosed);
                //Pisces2 p2 = new Pisces2(explorer);
                //p2.FormClosed += new FormClosedEventHandler(explorerForm1_FormClosed);

                Application.Run(piscesForm1);
                explorer.Database.SaveSettingsToDatabase(explorer.TimeWindow);
                //db.SaveSettingsToDatabase(explorer.TimeWindow);

                PostgreSQL.ClearAllPools();

                FileUtility.CleanTempPath();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }
Пример #26
0
 public static bool AdminPasswordIsValid()
 {
     return(UserPreference.Lookup("Admin") == "True");
 }