//       SetupNetworkList();



        private void InsertSite(string[] siteFilter)
        {
            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];


                if (siteFilter.Length > 0 && Array.IndexOf(siteFilter, s.SITE.Trim()) < 0)
                {
                    continue;
                }

                var existing = decodes.site.Select("description = '" + s.DESCR + "'");
                if (existing.Length > 0)
                {
                    string msg = "Site " + s.SITE + " " + s.DESCR + " Allready in DECODES ";
                    Logger.WriteLine(msg);
                    throw new Exception(msg);
                    //continue;
                }

                decodes.site.AddsiteRow(id, s.LAT.ToString(), s.LONG.ToString(), "",
                                        s.STATE, "", s.TimeZone(s.TZONE.ToString()),
                                        "USA", s.ELEV, "feet", s.DESCR);

                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(), "", "");
                if (s.IsUsgs)
                {
                    decodes.sitename.AddsitenameRow(id, "usgs", s.ALTID.Trim(), "", "");
                }

                if (s.IsSnotel)
                {
                    decodes.sitename.AddsitenameRow(id, "snotel", s.ALTID.Trim(), "", "");
                }

                count++;
                id++;
            }
            if (count == 0)
            {
                throw new Exception("CBTT/Site not found in MCF " + String.Join(",", siteFilter));
            }
        }
        //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);
        }