Exemple #1
0
        private static string[] ParseRawCatalog(string[] lines)
        {
            TextFile tf = new TextFile(lines);

            int idx  = tf.IndexOf(" Number   Tag     Program   Date  Time  Type Vers Data        Record Pathname");
            int idx2 = tf.IndexOf("   -----DSS---ZCLOSE");

            if (idx < 0 || idx2 < 0)
            {
                Logger.WriteLine("Error creating catalog ");
                System.Windows.Forms.MessageBox.Show("Error creating DSS catalog \n\n" + String.Join("\n", lines));
                return(new string[] { });
            }

            List <string> paths = new List <string>();

            for (int i = idx + 2; i < idx2; i++)
            {
                string     s = tf[i].Substring(56).Trim();
                HecDssPath p = new HecDssPath(s);
                if (!paths.Contains(p.CondensedName)) // condensed name removes dates,period of record
                {
                    paths.Add(p.CondensedName);
                }
            }
            return(paths.ToArray());
        }
Exemple #2
0
 public DataQueryInfo(HecDssPath path)
 {
     string url = "http://www.nwd-wc.usace.army.mil/perl/dataquery.pl?k=" + path.B;
     results = Reclamation.Core.Web.GetPage(url);
     tf = new TextFile(results);
     this.path = path;
     name = GetName();
     ParseAttributes();
 }
Exemple #3
0
 public HecDssSeries(TimeSeriesDatabase db, Reclamation.TimeSeries.TimeSeriesDatabaseDataSet.SeriesCatalogRow sr)
     : base(db, sr)
 {
     ExternalDataSource = true;
     m_filename         = ConnectionStringToken("FileName");
     if (!Path.IsPathRooted(m_filename))
     {
         string dir = Path.GetDirectoryName(m_db.DataSource);
         m_filename = Path.Combine(dir, m_filename);
     }
     m_dssPath    = ConnectionStringToken("DssPath");
     path         = new HecDssPath(m_dssPath);
     ReadOnly     = true;
     ScenarioName = Path.GetFileNameWithoutExtension(m_filename);
     InitTimeSeries(null, this.Units, this.TimeInterval, this.ReadOnly, true, true);
     Appearance.LegendText = Name;
 }
Exemple #4
0
        public static void AddDssFileToDatabase(string dssFilename, PiscesFolder parent,
                                                TimeSeriesDatabase db)
        {
            if (parent == null)
            {
                parent = db.RootFolder;
            }

            PiscesFolder root = parent;

            try
            {
                string[] paths = GetCatalog(dssFilename);
                root = db.AddFolder(parent, Path.GetFileName(dssFilename));
                var    sc        = db.GetSeriesCatalog();
                int    folderID  = root.ID;
                string previousA = "";
                //db.SuspendTreeUpdates();
                for (int i = 0; i < paths.Length; i++)
                {
                    HecDssPath p = new HecDssPath(paths[i]);
                    if (i == 0 || p.A != previousA)
                    {
                        folderID  = sc.AddFolder(p.A, root.ID);
                        previousA = p.A;
                    }

                    HecDssSeries s = new HecDssSeries(dssFilename, paths[i]);
                    sc.AddSeriesCatalogRow(s, sc.NextID(), folderID);
                }
                db.Server.SaveTable(sc);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
            finally
            {
                //db.ResumeTreeUpdates();
                //db.RefreshFolder(parent);
            }
        }
Exemple #5
0
        public HecDssSeries(string filename, string dssPath)
        {
            ExternalDataSource = true;
            path       = new HecDssPath(dssPath);
            m_filename = filename;
            m_dssPath  = dssPath;

            FileInfo fi = new FileInfo(filename);

            Name   = path.B + " " + path.C + " " + path.E + " " + path.F;
            SiteID = path.B;
            this.ConnectionString = "FileName=" + filename
                                    + ";LastWriteTime=" + fi.LastWriteTime.ToString(DateTimeFormatInstantaneous)
                                    + ";DssPath=" + dssPath;
            Provider = "HecDssSeries";
            EstimateInterval();
            Source   = "hecdss"; // for icon name
            ReadOnly = true;
            HasFlags = true;
        }