Example #1
0
        private void Save2DB()
        {
            ODMSource odm = new ODMSource();
            string    msg = "";

            odm.Open(@"F:\System\Database\Pearl River Basin.mdb", ref msg);
            var          sites            = odm.GetSites("select * from Sites");
            StreamReader sr               = new StreamReader(Filename);
            Dictionary <string, Site> dic = new Dictionary <string, Site>();

            foreach (var ss in sites)
            {
                dic.Add(ss.Name, ss);
            }
            var line = sr.ReadLine();

            line = sr.ReadLine();
            var varid = TypeConverterEx.SkipSplit <int>(line, 6);

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                var buf = TypeConverterEx.Split <string>(line, TypeConverterEx.Comma);
                for (int i = 0; i < varid.Length; i++)
                {
                    odm.SaveDataValue(dic[buf[1].Trim()], varid[i], DateTime.Parse(buf[2].Trim()), double.Parse(buf[6 + i].Trim()));
                }
            }
            odm.UpdateSeriesCatalog();
            sr.Close();
            odm.Close();
        }
Example #2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            string msg = "";

            DBSource = new ODMSource();
            DBSource.Open(Settings.Default.DBPath, ref msg);
            HdyroCloud.Web.RS.RSConfig.Load();
        }
 private void btnConectODM_Click(object sender, EventArgs e)
 {
     if (viewModel.Value.ODMSource != null)
     {
         if (_SeriesCatalog == null)
         {
             _SeriesCatalog = new SeriesCatalog(viewModel.Value.ODMSource);
             btnRefresh_Click(null, null);
         }
         else
         {
             MessageBox.Show("An ODM database has been connected. If you want to connect to another database, please removec connection to current database at first"
                             , "Database Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         OpenFileDialog form = new OpenFileDialog();
         form.Filter = "access 2003 file |*.mdb|access 2007-2013 file|*.accdb";
         if (form.ShowDialog() == DialogResult.OK)
         {
             ODMSource odm = new ODMSource();
             string    msg = "";
             if (odm.Open(form.FileName, ref msg))
             {
                 viewModel.Value.ProjectService.Project.ODMSource = odm;
                 viewModel.Value.ODMSource = odm;
                 _SeriesCatalog            = new SeriesCatalog(odm);
                 btnRefresh_Click(null, null);
             }
             else
             {
                 MessageBox.Show("Failed to connect to the database. Error message: " + msg, "Database Connection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
 }