Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length != 5 && args.Length != 6)
            {
                Console.WriteLine("Usage: CreateDailyCalculations server user pass outputFile dryrun [sites]");
                Console.WriteLine(" server = hostname ");
                Console.WriteLine(" user = username");
                Console.WriteLine(" pass = passwordfile");
                Console.WriteLine(" outputfile = filename for stats/results");
                Console.WriteLine(" dryrun = true|false -- when true only simulates changes");
                Console.WriteLine(" sites = amfi,anci,...   -- list of sites to filter");
                return;
            }

            var    host           = args[0];
            string user           = args[1];
            string pass           = File.ReadAllLines(args[2])[0];
            var    outputFileName = args[3];
            bool   dryRun         = (args[4] == "true");

            var sites = new string[] { };

            if (args.Length == 6)
            {
                sites = args[5].ToLower().Split(',');
            }


            var svr = PostgreSQL.GetPostgresServer("timeseries", host, user, pass);
            //UpdateVMS_daily_por(svr);
            TimeSeriesDatabase db = new TimeSeriesDatabase(svr);

            Console.WriteLine(db.Server.ConnectionString);

            var fn = @"c:\temp\a.xlsx";

            File.Copy(Path.Combine(FileUtility.GetExecutableDirectory(), "daily_calcs_and_series.xlsx"), fn, true);
            var pcodeLookup = ExcelDB.Read(fn, "daily_instant_pcode");

            DailyCalcGenerator tool = new DailyCalcGenerator(db, outputFileName);

            tool.AddDailyCalculations(pcodeLookup, dryRun, sites);


            // what about years like 6190.....
            //HydrometInfoUtility.ArchiverEnabled(.. ?
        }
        static void Main(string[] args)
        {
            string serverIP = "lrgs1";
            //.Logger.Logger.EnableLogger();

            var fn  = @"V:\PN6200\Hydromet\HelpWanted\migrate to linux.xls";
            var tbl = ExcelDB.Read(fn, "owrd_1");

            var        cs  = PostgreSQL.CreateADConnectionString(serverIP, "timeseries");
            PostgreSQL svr = new PostgreSQL(cs);

            //SQLiteServer svr = new SQLiteServer(@"c:\temp\lrgs1.pdb");
            TimeSeriesDatabase db = new TimeSeriesDatabase(svr);

            AddToPisces(tbl, db);
            AddSitesToDecodes(serverIP, tbl);
        }
Beispiel #3
0
        private DataTable GetTable(string excelName, string sheetName)
        {
            // Performance p = new Performance();
            DataTable rval = new DataTable();

            if (excelDataSet == null)
            {
                excelDataSet = new DataSet();
            }
            if (!excelDataSet.Tables.Contains(sheetName))
            {
                rval = ExcelDB.Read(excelName, sheetName);
                excelDataSet.Tables.Add(rval);
            }

            //  p.Report("read " + sheetName);
            return(excelDataSet.Tables[sheetName]);
        }
Beispiel #4
0
        /// <summary>
        /// Create a SeriesCatalog by looking at each sheet and column names inside
        /// </summary>
        private void BuildSiteCatalog()
        {
            m_treeTable = new DataTable("SeriesCatalog");

            m_treeTable.Columns.Add("Label", typeof(string));
            m_treeTable.Columns.Add("Level", typeof(Int32));
            m_treeTable.Columns.Add("DatabaseName");
            m_treeTable.Columns.Add("SheetName");
            m_treeTable.Columns.Add("DateColumn");
            m_treeTable.Columns.Add("ValueColumn");

            m_treeTable.Rows.Add(Name, 0, "", "", "", "");

            string[] sheetNames = ExcelDB.SheetNames(m_filename);

            for (int i = 0; i < sheetNames.Length; i++)
            {
                string sheetName = sheetNames[i];
                if (sheetName.Trim() != "")
                {
                    string    sql = " Select * from [" + sheetName + "$] WHERE 2 = 1";
                    DataTable t1  = ExcelDB.Read(m_filename, sheetName, sql);

                    if (t1.Columns.Count > 0 && t1.Columns[0].ColumnName.ToLower().IndexOf("date") == 0)
                    {
                        string dateColumn = t1.Columns[0].ColumnName;
                        for (int j = 1; j < t1.Columns.Count; j++)
                        {
                            string valueColumn = t1.Columns[j].ColumnName;

                            m_treeTable.Rows.Add(valueColumn, 1, Name, sheetName, dateColumn, valueColumn);
                        }
                    }
                }
            }
        }