Example #1
0
        public static void Import(string serverIP, string database, string siteFilter, string networkListName)
        {
            string      fn    = @"C:\temp\mcf.xml";
            Performance perf  = new Performance();
            var         pnMcf = new McfDataSet();

            if (File.Exists(fn) && File.GetLastWriteTime(fn).Date != DateTime.Now.Date)
            { // read existing file.
                Logger.WriteLine("Reading existing XML");
                pnMcf.ReadXml(fn);
            }
            else
            {
                Logger.WriteLine("Reading csv files from MCF");
                pnMcf = McfUtility.GetDataSetFromCsvFiles(Globals.LocalConfigurationDataPath);
                pnMcf.WriteXml(fn);
            }

            DumpInfo(pnMcf);

            Application.DoEvents();

            Logger.WriteLine(serverIP);

            var                 cs      = PostgreSQL.CreateADConnectionString(serverIP, database, "decodes");
            PostgreSQL          svr     = new PostgreSQL(cs);
            var                 decodes = DecodesUtility.GetDataSet(svr);
            McfDecodesConverter c       = new McfDecodesConverter(svr, pnMcf, decodes);

            c.importMcf(siteFilter.Split(','), networkListName);

            UpdateSequences(svr);
        }
        //private string aaConfigName(McfDataSet.sitemcfRow s)
        //{
        //    string rval = "unknown";

        //    if (s.DCPMFG == "S" && s.REPINT == 60
        //        && s.SCHAN != 42 && s.SCHAN != 54)
        //        rval = "SutronSatlink";

        //    if (s.DCPMFG == "S")
        //        rval = "Sutron8xxx";
        //    if (s.DCPMFG == "D")
        //        rval = "DesignAnalysis";

        //    if (s.DCPMFG == "V")
        //        rval = "VitelVX1004";

        //    if (s.DCPMFG == "A")
        //        rval = "FTSTX312";


        //    return rval + "-pnusbr";
        //}


//       SetupNetworkList();



        public void InsertSites()
        {
            int id    = NextID(svr, "site");
            int count = 0;

            for (int i = 0; i < mcf.sitemcf.Rows.Count; i++)
            {
                Reclamation.TimeSeries.Hydromet.McfDataSet.sitemcfRow s = mcf.sitemcf[i];

                var usgs_id = "";
                if (!InSiteList(s.SITE))
                {
                    continue;
                }


                if (SiteExists(s.SITE))
                {
                    string msg = "Site " + s.SITE + " " + s.DESCR + " Allready in DECODES ";
                    Logger.WriteLine(msg);
                    continue;
                }

                string active_flag = "TRUE";
                if (s.MASTERSW != 1)
                {
                    active_flag = "FALSE";
                }
                decodes.site.AddsiteRow(id, s.LAT.ToString(), s.LONG.ToString(), "",
                                        s.STATE, "", s.TimeZone(s.TZONE.ToString()),
                                        "USA", s.ELEV, "ft", s.DESCR, active_flag, "", 0, "");

                decodes.site_property.Addsite_propertyRow(id, "accessControlList", s.ACL);
                decodes.site_property.Addsite_propertyRow(id, "alternateID", s.ALTID);
                decodes.site_property.Addsite_propertyRow(id, "catagoryID", s.CATID);
                decodes.site_property.Addsite_propertyRow(id, "stationType", s.STATYPE);
                decodes.site_property.Addsite_propertyRow(id, "group", s.GRP.ToString());
                decodes.site_property.Addsite_propertyRow(id, "telemetryType", s.TTYPE);
                decodes.site_property.Addsite_propertyRow(id, "timeZone", s.TTYPE);
                decodes.site_property.Addsite_propertyRow(id, "codingType", s.CTYPE);
                decodes.site_property.Addsite_propertyRow(id, "masterSwitch", s.MASTERSW.ToString());
                decodes.site_property.Addsite_propertyRow(id, "dayfileSwitch", s.DFMSW.ToString());
                decodes.site_property.Addsite_propertyRow(id, "archiverSwitch", s.ACMSW.ToString());


                decodes.sitename.AddsitenameRow(id, "cbtt", s.SITE.Trim(), "", "");
                decodes.sitename.AddsitenameRow(id, "usgs", usgs_id, "", "");


                count++;
                id++;
            }
            Logger.WriteLine("added " + count + " sites");
            DecodesUtility.UpdateServer(svr, decodes);
            DecodesUtility.UpdateSequences(svr);
        }
        public void importMcf(string networkListName)
        {
            int networklistid = SetupNetworkList(networkListName);

            InsertSites();
            InsertGoesPlatform(networklistid);
            DecodesUtility.UpdateServer(svr, decodes);
            DecodesUtility.UpdateSequences(svr);
            svr.Vacuum();
        }
Example #4
0
        public void importMcf(string[] siteFilter, string networkListName)
        {
            //  DecodesUtility.TruncateTables(svr);
            //DecodesUtility.AddEquipment(decodes);

            int networklistid = SetupNetworkList(networkListName);

            InsertSite(siteFilter);
            platformID       = NextID(svr, "platform");
            platformConfigID = NextID(svr, "platformconfig");
            decodesScriptID  = NextID(svr, "decodesscript");
            InsertGoesPlatform(siteFilter, networklistid);
            DecodesUtility.UpdateServer(svr, decodes);

            svr.Vacuum();
        }
Example #5
0
        public static void Import(string serverIP, string database, string password, string networkListName,
                                  string[] siteList, string mrdbPath)
        {
            string      fn    = @"C:\temp\mcf.xml";
            Performance perf  = new Performance();
            var         pnMcf = new McfDataSet();

            if (File.Exists(fn) && File.GetLastWriteTime(fn).Date == DateTime.Now.Date)
            { // read existing file.
                Logger.WriteLine("Reading existing XML");
                pnMcf.ReadXml(fn);
            }
            else
            {
                Logger.WriteLine("Reading csv files from MCF");
                pnMcf = McfUtility.GetDataSetFromCsvFiles(mrdbPath);
                pnMcf.WriteXml(fn);
            }

            DumpInfo(pnMcf);

            Application.DoEvents();

            Logger.WriteLine(serverIP);


            var svr = PostgreSQL.GetPostgresServer(database, serverIP, "decodes", password) as PostgreSQL;

            DecodesUtility.UpdateSequences(svr);
            DecodesUtility.GenerateDataSet(@"c:\temp\decodes.xsd", svr);

            var decodes           = DecodesUtility.GetDataSet(svr);
            McfDecodesConverter c = new McfDecodesConverter(svr, pnMcf, decodes, siteList);

            c.importMcf(networkListName);
        }