Example #1
0
        public FormMain()
        {
            var host = HydrometInfoUtility.HydrometServerFromPreferences();

            if (host == HydrometHost.PN)
            {
                UserPreference.SetDefault("HydrometServer", HydrometHost.PNLinux.ToString(), false);
            }

            HydrometInfoUtility.SetDefaultHydrometServer();

            UserPreference.SetDefault("HideStatusDialog", "False", false);
            UserPreference.SetDefault("AutoFlagDayFiles", "True", false);

            InitializeComponent();

            this.Text += " " + Application.ProductVersion;

            // FileUtility.CleanTempPath();
            Application.EnableVisualStyles();
            TabPageManager tabManager = new TabPageManager(tabControl1);

            Logger.OnLogEvent += new StatusEventHandler(Logger_OnLogEvent);
            UpdateTabs();
            //MakeMinimalVersion();
            this.Text = "Hydromet/Agrimet Tools V" + Application.ProductVersion;
        }
Example #2
0
        void AddHydrometClick(object sender, System.EventArgs e)
        {
            ImportHydromet dlg = new ImportHydromet();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                UserPreference.SetDefault("HydrometServer", dlg.HydrometServer.ToString(), true);

                string msg = "";
                try
                {
                    ShowAsBusy("connecting to hydromet");
                    Series s = HydrometInfoUtility.Read(dlg.Cbtt, dlg.ParameterCode, dlg.T1, dlg.T2,
                                                        dlg.TimeInterval, dlg.HydrometServer);

                    if (s.Count == 0)
                    {
                        msg = "Error: Could not find any Hydromet Data";
                    }
                    else
                    {
                        msg = "read " + s.Count + " records";
                        if (dlg.UseSimpleName)
                        {
                            s.Name = dlg.Cbtt + " " + dlg.ParameterCode;
                        }
                        DB.AddSeries(s, CurrentFolder);
                    }
                }
                finally
                {
                    ShowAsReady(msg);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Based on configuration settings and IP address determines
        /// the default Hydromet server
        /// </summary>
        public static void SetDefaultHydrometServer()
        {
            var yak = System.Configuration.ConfigurationManager.AppSettings["YakimaNetworkPrefix"];
            var gp  = System.Configuration.ConfigurationManager.AppSettings["GPNetworkPrefix"];

            if (NetworkUtility.MyIpStartsWith(yak))
            {
                UserPreference.SetDefault("HydrometServer", HydrometHost.Yakima.ToString(), false);
            }
            else if (NetworkUtility.MyIpStartsWith(gp))
            {
                UserPreference.SetDefault("HydrometServer", HydrometHost.GreatPlains.ToString(), false);
            }
            else
            {
                UserPreference.SetDefault("HydrometServer", HydrometHost.PN.ToString(), false);
            }
        }
Example #4
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);
        }
Example #5
0
 private void checkBoxForceWebService_CheckedChanged(object sender, EventArgs e)
 {
     UserPreference.SetDefault("CompilePublic", this.checkBoxForceWebService.Checked.ToString(), true);
 }
Example #6
0
        static void Main(string[] args)
        {
            Logger.EnableLogger(true);

            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);
                }


                UserPreference.SetDefault("HydrometServer", HydrometHost.PN.ToString(), false);

                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());
            }
        }