示例#1
0
        /// <summary>
        /// Returns a list of paths with dates (part D ) removed
        /// </summary>
        /// <param name="dssFilename"></param>
        /// <returns></returns>
        public static string[] GetCatalog(string dssFilename)
        {
            string       dir      = Path.GetDirectoryName(dssFilename);
            string       fnScript = FileUtility.GetTempFileNameInDirectory(dir, ".txt");
            StreamWriter sw       = new StreamWriter(fnScript);


            if (Path.GetFileName(dssFilename).IndexOf(" ") >= 0)
            {
                System.Windows.Forms.MessageBox.Show("Warning: The dss filename has a space.  ");
            }

            sw.WriteLine(Path.GetFileName(dssFilename));

            sw.WriteLine("CA");// create (N)ew (C)ondenced catalog  (F)ull batch mode.
            sw.Close();

            string dssutl = HecDssSeries.GetPathToDssUtl();

            ProgramRunner pr = new ProgramRunner();

            pr.Run(dssutl, "input=" + Path.GetFileName(fnScript), dir);
            pr.WaitForExit();
            return(ParseRawCatalog(pr.Output));
        }
示例#2
0
        /// <summary>
        /// Creates Scenario based on scenaroName as dss filename without extension (.dss)
        /// </summary>
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            if (scenario.Name == ScenarioName)
            {
                this.Appearance.LegendText = scenario.Name + " " + Name;
                return(this);
            }

            string path = Path.GetDirectoryName(m_filename);
            string fn   = Path.Combine(path, scenario.Name + ".dss");

            Logger.WriteLine("Reading series from " + fn);
            if (!File.Exists(fn))
            {
                Logger.WriteLine("Error: Can't create scenario");
                return(new Series());
            }


            var rval = new HecDssSeries(m_filename, m_dssPath);

            rval.Name = this.Name;
            rval.Appearance.LegendText = scenario.Name + " " + Name;

            rval.SiteID       = this.SiteID;
            rval.TimeInterval = this.TimeInterval;
            return(rval);
        }
示例#3
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);
            }
        }