public void ExportLakes()
        {
            Console.WriteLine("Exporting Minnesota lakes...");
            var minnesota = _troutDashContext.states.Single(s => s.short_name == "MN");

            Console.WriteLine("Deleting Minnesota lakes...");
            _troutDashContext.lakes.RemoveRange(minnesota.lakes);
            _troutDashContext.SaveChanges();
            Console.WriteLine("Deleted Minnesota lakes...");
            _sequenceRestarter.RestartSequence("lake_gid_seq");


            var lakes = _minnesotaContext.Lakes.ToList().Select(i => new lake
            {
                Geom          = i.Geom_4326,
                name          = i.pw_pasin_n ?? "Unnamed",
                source_id     = i.dnr_hydro_.ToString(),
                state         = minnesota,
                state_gid     = minnesota.gid,
                is_trout_lake = false
            });

            Console.WriteLine("Saving Minnesota lakes...");
            _troutDashContext.lakes.AddRange(lakes);
            _troutDashContext.SaveChanges();
            Console.WriteLine("Saved Minnesota lakes.");
        }
Exemple #2
0
        public void ExportRestrictionSections()
        {
            Console.WriteLine("Exporting Restriction Sections...");
            var state = _troutDashContext2.states.First(s => s.short_name == "MN");
            var preExistingSections = state.streams.SelectMany(s => s.restriction_section);

            _troutDashContext2.restriction_section.RemoveRange(preExistingSections);
            _troutDashContext2.SaveChanges();
            _sequenceRestarter.RestartSequence("restriction_section_id_seq");
            var restrictions = state.restrictions.ToDictionary(i => i.source_id);

            state.streams.ToList()
            .AsParallel()
            .ForAll(stream => Stuff(stream, restrictions));
        }
Exemple #3
0
        private void ExportRestrictionRoutes()
        {
            using (var context = new MinnesotaShapeDataContext())
                using (var troutDashContext = new TroutDashPrototypeContext())
                {
                    // clear out the old.
                    Console.WriteLine("Caching minnesota restriction routes...");
                    var minnesota = troutDashContext.states.Single(s => s.short_name == "MN");
                    var routes    = minnesota.restrictions.SelectMany(i => i.restrictionRoutes);
                    troutDashContext.restriction_routes.RemoveRange(routes);
                    Console.WriteLine("Deleting minnesota restriction routes...");
                    troutDashContext.SaveChanges();
                    _sequenceRestarter.RestartSequence("restriction_route_id_seq");

                    var restrictions      = troutDashContext.restrictions.ToDictionary(i => i.source_id);
                    var restrictionRoutes = context.strm_regsln3.ToList();
                    Console.WriteLine("Building minnesota restriction routes...");
                    foreach (var restrictionRoute in restrictionRoutes)
                    {
                        var route = new restriction_route();
                        route.Restriction = restrictions[restrictionRoute.new_reg.ToString()];
                        route.Geom        = restrictionRoute.Geom_4326;
                        route.source_id   = restrictionRoute.gid.ToString();
                        troutDashContext.restriction_routes.Add(route);
                    }
                    Console.WriteLine("Saving minnesota restriction routes...");
                    troutDashContext.SaveChanges(); // TODO: MOVE THIS.
                    Console.WriteLine("Saved minnesota restriction routes...");
                }

            using (var context = new MinnesotaShapeDataContext())
                using (var troutDashContext = new TroutDashPrototypeContext())
                {
                    var stuff =
                        troutDashContext.restrictions.SelectMany(r => r.restrictionRoutes).Select(i => i.gid).ToList();
                }
        }