Example #1
0
            private WaterProtectionArea getWaterProtectionArea(IDBContext db)
            {
                WaterProtectionArea rc = WaterProtectionArea.defaulttype;

                foreach (EcoObject eo in this.groundblur.ecoobjecstlist)
                {
                    if (rc != null && rc.type_code < eo.ecoobjecttype.waterprotectionarea.type_code)
                    {
                        rc = eo.ecoobjecttype.waterprotectionarea;
                    }
                    else
                    {
                        rc = eo.ecoobjecttype.waterprotectionarea;
                    }
                }
                if (rc.type_code == 0)
                {
                    int k = 0;
                    while (k < this.waterpolutionlist.Count && this.waterpolutionlist[k].pointtype != Point.POINTTYPE.ECO)
                    {
                        k++;
                    }
                    if (k < this.waterpolutionlist.Count)
                    {
                        if (!WaterProtectionArea.GetByCode(db, 1, out rc))
                        {
                            rc = WaterProtectionArea.defaulttype;
                        }
                    }
                }
                return(rc);
            }
        public ActionResult WaterProtectionAreaUpdate(WaterProtectionAreaView pcv)
        {
            ORTContext db = null;
            ViewBag.EGHLayout = "ORT.WaterProtectionArea";
            ActionResult view = View("Index");
            string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";
            try
            {
                db = new ORTContext();
                if (menuitem.Equals("WaterProtectionArea.Update.Update"))
                {

                    int type_code = pcv.type_code;
                    string name = pcv.name;

                    WaterProtectionArea pc = new WaterProtectionArea(type_code, name);
                    if (EGH01DB.Types.WaterProtectionArea.Update(db, pc))
                        view = View("WaterProtectionArea", db);
                }
                else if (menuitem.Equals("WaterProtectionArea.Update.Cancel")) view = View("WaterProtectionArea", db);
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return view;
        }
        public ActionResult EcoObjectTypeCreate(EcoObjectTypeView itv)
        {
            RGEContext db = null;

            ViewBag.EGHLayout = "RGE.EcoObjectType";
            ActionResult view     = View("Index");
            string       menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";

            try
            {
                db   = new RGEContext();
                view = View("EcoObjectType", db);
                if (menuitem.Equals("EcoObjectType.Create.Create"))
                {
                    EGH01DB.Types.WaterProtectionArea water = new WaterProtectionArea();
                    if (EGH01DB.Types.WaterProtectionArea.GetByCode(db, itv.list_water, out water))
                    {
                        if (EGH01DB.Types.EcoObjectType.Create(db, new EcoObjectType(0, itv.name, water)))
                        {
                            view = View("EcoObjectType", db);
                        }
                        else if (menuitem.Equals("EcoObjectType.Create.Cancel"))
                        {
                            view = View("EcoObjectType", db);
                        }
                    }
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }
Example #4
0
        // #4 Получение карты водоохранных зон поверх вод
        static public bool GetWaterProtectionZone(EGH01DB.IDBContext dbcontext, Coordinates coordinates, out WaterProtectionArea water_protection) // водоохраняемая зона
        {
            bool rc = false;

            water_protection = new WaterProtectionArea(-1, "Не является водоохраняемой зоной");
            using (SqlCommand cmd = new SqlCommand("MAP.InWaterProtectionMap", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@point", SqlDbType.VarChar);
                    parm.Value = coordinates.GetMapPoint();
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (rc = reader.Read())
                    {
                        int    id     = (int)reader["Obj_Id"];
                        string name   = (string)reader["name"];
                        int    buffer = (int)reader["buff_distance"];
                        water_protection = new WaterProtectionArea(-1, name, buffer);
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
Example #5
0
            public ECORehabilitation(GEAContext.ECOClassification ecoclassification) : base(ecoclassification)
            {
                db        = new ORTContext();
                this.date = DateTime.Now;

                int mk = 0;

                {
                    PenetrationDepth x = null;
                    if (PenetrationDepth.GetByDepth(db, this.groundblur.depth, out x))
                    {
                        this.penetrationdepth = x;
                    }
                    else
                    {
                        this.penetrationdepth = PenetrationDepth.defaulttype;
                    }
                }
                {
                    EmergencyClass x = null;
                    if (EmergencyClass.GetByMass(db, this.groundblur.totalmass, out x))
                    {
                        this.emergencyclass = x;
                    }
                    else
                    {
                        this.emergencyclass = EmergencyClass.defaulttype;
                    }
                }


                this.waterprotectionarea = getWaterProtectionArea(db);


                List <RehabilitationMethod> source = new List <RehabilitationMethod>();

                if (Helper.GetListRehabilitationMethod(db, ref source))
                {
                    foreach (RehabilitationMethod rm in source)
                    {
                        bool r1 = (this.isriskobjecttype && this.riskobjecttype.type_code > 0 && this.riskobjecttype.type_code == rm.riskobjecttype.type_code);

                        bool r2 = (rm.cadastretype.type_code == 0 || this.cadastretype.type_code == rm.cadastretype.type_code);

                        bool r3 = (rm.emergencyclass.type_code == 0 || this.emergencyclass.type_code == rm.emergencyclass.type_code);

                        bool r4 = (rm.penetrationdepth.type_code == 0 || this.penetrationdepth.type_code == rm.penetrationdepth.type_code);

                        bool r5 = (rm.soilpollutioncategories.code == 0 || this.soilpollutioncategories.code == rm.soilpollutioncategories.code);

                        bool r6 = (rm.waterpollutioncategories.code == 0 || this.waterpollutioncategories.code == rm.waterpollutioncategories.code);

                        bool r7 = (this.waterachieved == rm.waterachieved);

                        bool r8 = (this.waterprotectionarea.type_code == rm.waterprotectionarea.type_code);

                        int k = (r1?1:0) + (r2?1:0) + (r3?1:0) + (r3?1:0) + (r4?1:0) + (r5?1:0) + (r6?1:0) + (r7?1:0);

                        mk = k > mk?k:mk;

                        // if (r1 && r2 && r3 && r4 && r5 && r6 && r7 ) rehabilitationlist.Add(rm);
                        if (k >= 5)
                        {
                            rehabilitationlist.Add(rm);
                        }
                    }
                }
            }
Example #6
0
        static public bool GetById(EGH01DB.IDBContext dbcontext, int id, ref EcoObject ecoobject)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.GetEcoObjectByID", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@IdПриродоохранногоОбъекта", SqlDbType.Int);
                    parm.Value = id;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    cmd.ExecuteNonQuery();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        float       x           = (float)reader["ШиротаГрад"];
                        float       y           = (float)reader["ДолготаГрад"];
                        Coordinates coordinates = new Coordinates((float)x, (float)y);

                        string ground_type_name = (string)reader["НаименованиеТипаГрунта"];
                        float  porosity         = (float)reader["КоэфПористости"];
                        float  holdmigration    = (float)reader["КоэфЗадержкиМиграции"];
                        float  waterfilter      = (float)reader["КоэфФильтрацииВоды"];
                        float  diffusion        = (float)reader["КоэфДиффузии"];
                        float  distribution     = (float)reader["КоэфРаспределения"];
                        float  sorption         = (float)reader["КоэфСорбции"];
                        float  watercapacity    = (float)reader["КоэфКапВлагоемкости"];
                        float  soilmoisture     = (float)reader["ВлажностьГрунта"];
                        float  аveryanovfactor  = (float)reader["КоэфАверьянова"];
                        float  permeability     = (float)reader["Водопроницаемость"];
                        float  density          = (float)reader["СредняяПлотностьГрунта"];

                        GroundType ground_type = new GroundType((int)reader["ТипГрунта"],
                                                                (string)ground_type_name,
                                                                (float)porosity,
                                                                (float)holdmigration,
                                                                (float)waterfilter,
                                                                (float)diffusion,
                                                                (float)distribution,
                                                                (float)sorption,
                                                                (float)watercapacity,
                                                                (float)soilmoisture,
                                                                (float)аveryanovfactor,
                                                                (float)permeability,
                                                                (float)density);

                        float  waterdeep           = (float)reader["ГлубинаГрунтовыхВод"];
                        float  height              = (float)reader["ВысотаУровнемМоря"];
                        Point  point               = new Point(coordinates, ground_type, (float)waterdeep, (float)height);
                        int    ecoobject_type_code = (int)reader["КодТипаПриродоохранногоОбъекта"];
                        string ecoobject_type_name = (string)reader["НаименованиеТипаПриродоохранногоОбъекта"];

                        int  cat_water_name = (int)reader["КатегорияВодоохрТер"];
                        bool iswaterobject;
                        if (cat_water_name != 0)
                        {
                            iswaterobject = true;
                        }
                        else
                        {
                            iswaterobject = false;
                        }
                        WaterProtectionArea water_protection_area = new WaterProtectionArea(cat_water_name);
                        EcoObjectType       ecoobjecttype         = new EcoObjectType(ecoobject_type_code, ecoobject_type_name, water_protection_area);

                        int    cadastre_type_code = (int)reader["КодТипаНазначенияЗемель"];
                        string cadastre_type_name = (string)reader["НаименованиеНазначенияЗемель"];
                        float  pdk             = (float)reader["ПДК"];
                        float  water_pdk_coef  = (float)reader["ПДКводы"];
                        string ground_doc_name = (string)reader["НормДокументЗемля"];
                        string water_doc_name  = (string)reader["НормДокументВода"];

                        CadastreType cadastre_type = new CadastreType(cadastre_type_code, (string)cadastre_type_name,
                                                                      pdk, water_pdk_coef,
                                                                      ground_doc_name, water_doc_name);
                        string ecoobject_name = (string)reader["НаименованиеПриродоохранногоОбъекта"];


                        ecoobject = new EcoObject(id, point, ecoobjecttype, cadastre_type, ecoobject_name, iswaterobject);
                    }
                    reader.Close();
                    rc = (int)cmd.Parameters["@exitrc"].Value > 0;
                }
                catch (Exception e)
                {
                    rc = false;
                };

                return(rc);
            }
        }
Example #7
0
        public JsonResult CreateFromAjax(EGH01.Models.EGHMAP.MapPointView mp)
        {
            ViewBag.EGHLayout = "MAP";
            RGEContext   db       = null;
            string       menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";
            ActionResult view     = View("Index");

            db   = new RGEContext();
            view = View("Index", db);
            String Latitude = mp.Latitude;

            ViewData["Latitude"] = Latitude;
            String Lat_m = mp.Lat_m;

            ViewData["Lat_m"] = Lat_m;
            String Lat_s = mp.Lat_s;

            ViewData["Lat_s"] = Lat_s;
            String Lngitude = mp.Lngitude;

            ViewData["Lngitude"] = Lngitude;
            String Lng_m = mp.Lng_m;

            ViewData["Lng_m"] = Lng_m;
            String Lng_s = mp.Lng_s;

            ViewData["Lng_s"] = Lng_s;

            float coords = EGH01DB.Primitives.Coordinates.dms_to_d(int.Parse(Latitude), int.Parse(Lat_m), float.Parse(Lat_s));
            float coordm = EGH01DB.Primitives.Coordinates.dms_to_d(int.Parse(Lngitude), int.Parse(Lng_m), float.Parse(Lng_s));

            //EGH01DB.Types.MapType mapPoint = new MapType(coords.ToString("F", CultureInfo.InvariantCulture), coordm.ToString("F", CultureInfo.InvariantCulture));
            EGH01DB.Types.GroundType ground = new GroundType();
            //EGH01DB.Types.MapType.GetGroundType(mapPoint, db, out ground);
            String grounds = "Получено из карты коэффициентов грунта";

            if (String.Compare(ground.name, grounds) == 1)
            {
                ViewData["ground"] = ground.name;
            }


            //
            EGH01DB.Types.WaterProtectionArea waterProtectionArea = new WaterProtectionArea();
            //EGH01DB.Types.MapType.GetWaterProtection(mapPoint, db, out waterProtectionArea);

            String water = "Не является зоной водозабора";

            if (String.Compare(waterProtectionArea.name, water) == 1)
            {
                ViewData["waterProtectionArea"] = waterProtectionArea.name;
            }



            EGH01DB.Types.WaterProtectionArea water_intake = new WaterProtectionArea();
            //EGH01DB.Types.MapType.GetWaterIntake(mapPoint, db, out water_intake);



            float waterdeep = 0.0f;
            //EGH01DB.Types.MapType.GetWaterdeep(mapPoint, db, out waterdeep);



            float height = 0.0f;

            //EGH01DB.Types.MapType.GetHeight(mapPoint, db, out height);



            EGH01DB.Types.SoilType soilType = new SoilType();
            //EGH01DB.Types.MapType.GetSoilType(mapPoint, db, out soilType);



            float time_migration = 0.0f;

            //EGH01DB.Types.MapType.GetTimeMigration(mapPoint, db, out time_migration);



            EGH01DB.Objects.EcoObject ecoW = new EGH01DB.Objects.EcoObject();
            //EGH01DB.Types.MapType.GetWaterObject(mapPoint, db, out ecoW);



            EGH01DB.Types.District district = new District();
            //EGH01DB.Types.MapType.GetDistrict(mapPoint, db, out district);


            string city = "";

            //EGH01DB.Types.MapType.GetCity(mapPoint, db, out city);

            if (!String.IsNullOrEmpty(city))
            {
                ViewData["city"] = city;
            }



            if (!String.IsNullOrEmpty(ecoW.name))
            {
                ViewData["ecoW"] = ecoW.name;
            }


            if (!String.IsNullOrEmpty(soilType.name))
            {
                ViewData["soilType"] = soilType.name;
            }

            //

            string self_cleaning_zone = "";

            //EGH01DB.Types.MapType.GetSelfCleaningZone(mapPoint, db, out self_cleaning_zone);



            EGH01DB.Objects.EcoObject eco = new EGH01DB.Objects.EcoObject();
            // EGH01DB.Types.MapType.GetEcoObject(mapPoint, db, out eco);
            if (!String.IsNullOrEmpty(eco.name))
            {
                ViewData["eco"] = eco.name;
            }


            ViewData["height"]             = height;
            ViewData["district"]           = district.name;
            ViewData["region"]             = district.region.name;
            ViewData["self_cleaning_zone"] = self_cleaning_zone;
            ViewData["time_migration"]     = time_migration;
            ViewData["water_intake"]       = water_intake.name;
            ViewData["waterdeep"]          = waterdeep;
            ViewData["waterfilter"]        = ground.waterfilter;   //
            ViewData["porosity"]           = ground.porosity;      //
            ViewData["watercapacity"]      = ground.watercapacity; //

            var heights = new
            {
                Высота              = height,
                Soil                = soilType.name,
                Waterdeep           = waterdeep,
                District            = district.name,
                Region              = district.region.name,
                Ground              = ground.name,
                Self_cleaning_zone  = self_cleaning_zone,
                Time_migration      = time_migration,
                WaterProtectionArea = waterProtectionArea.name,
                Eco           = eco.name,
                EcoW          = ecoW.name,
                City          = city,
                Water_intake  = water_intake.name,
                Waterfilter   = ground.waterfilter,
                Porosity      = ground.porosity,
                Watercapacity = ground.watercapacity,
            };

            return(Json(heights));
        }
        public ActionResult WaterProtectionArea()
        {
            ORTContext db = null;
            ViewBag.EGHLayout = "ORT.WaterProtectionArea";
            ActionResult view = View("Index");
            string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";
            try
            {
                db = new ORTContext();
                ViewBag.msg = "Соединение с базой данных установлено";
                view = View("WaterProtectionArea", db);


                if (menuitem.Equals("WaterProtectionArea.Create"))
                {

                    view = View("WaterProtectionAreaCreate");

                }
                else if (menuitem.Equals("WaterProtectionArea.Delete"))
                {
                    string type_code_item = this.HttpContext.Request.Params["type_code"];
                    if (type_code_item != null)
                    {
                        int c = 0;
                        if (int.TryParse(type_code_item, out c))
                        {
                            EGH01DB.Types.WaterProtectionArea pt = new WaterProtectionArea();
                            if (EGH01DB.Types.WaterProtectionArea.GetByCode(db, c, out pt))
                            {
                                view = View("WaterProtectionAreaDelete", pt);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("WaterProtectionArea.Update"))
                {
                    string type_code_item = this.HttpContext.Request.Params["type_code"];

                    if (type_code_item != null)
                    {
                        int c = 0;
                        if (int.TryParse(type_code_item, out c))
                        {
                            WaterProtectionArea pt = new WaterProtectionArea();
                            if (EGH01DB.Types.WaterProtectionArea.GetByCode(db, c, out pt))
                            {
                                view = View("WaterProtectionAreaUpdate", pt);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("WaterProtectionArea.Excel"))
                {
                    EGH01DB.Types.WaterProtectionAreaList list = new WaterProtectionAreaList(db);
                    XmlNode node = list.toXmlNode();
                    XmlDocument doc = new XmlDocument();
                    XmlNode nnode = doc.ImportNode(node, true);
                    doc.AppendChild(nnode);
                    doc.Save(Server.MapPath("~/App_Data/WaterProtectionArea.xml"));
                    view = View("Index");

                    view = File(Server.MapPath("~/App_Data/WaterProtectionArea.xml"), "text/plain", "Категории водоохранной территории.xml");

                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return view;
        }
Example #9
0
        public JsonResult CreateFromWATER(EGH01.Models.EGHMAP.MapPointView mp)
        {
            ViewBag.EGHLayout = "MAP";
            RGEContext   db       = null;
            string       menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";
            ActionResult view     = View("EGHMAPWATER");

            db   = new RGEContext();
            view = View("EGHMAPWATER", db);
            String Latitude = mp.Latitude;

            ViewData["Latitude"] = Latitude;
            String Lat_m = mp.Lat_m;

            ViewData["Lat_m"] = Lat_m;
            String Lat_s = mp.Lat_s;

            ViewData["Lat_s"] = Lat_s;
            String Lngitude = mp.Lngitude;

            ViewData["Lngitude"] = Lngitude;
            String Lng_m = mp.Lng_m;

            ViewData["Lng_m"] = Lng_m;
            String Lng_s = mp.Lng_s;

            ViewData["Lng_s"] = Lng_s;

            float coords = EGH01DB.Primitives.Coordinates.dms_to_d(int.Parse(Latitude), int.Parse(Lat_m), float.Parse(Lat_s));
            float coordm = EGH01DB.Primitives.Coordinates.dms_to_d(int.Parse(Lngitude), int.Parse(Lng_m), float.Parse(Lng_s));

            EGH01DB.Primitives.Coordinates mapPoint = new Coordinates(coordm, coords);
            EGH01DB.Types.District         district = new District();
            EGH01DB.Primitives.MapHelper.GetRegion(db, mapPoint, out district);
            ViewData["district"] = district.name;
            ViewData["region"]   = district.region.name;

            EGH01DB.Objects.EcoObject water_Object = new EGH01DB.Objects.EcoObject();
            EGH01DB.Primitives.MapHelper.GetWaterPond(db, mapPoint, out water_Object);

            string watername = "";
            string watertype = "";

            EGH01DB.Types.WaterProtectionArea water_intake = new WaterProtectionArea();
            EGH01DB.Primitives.MapHelper.GetWaterIntake(db, mapPoint, out water_intake);

            string regionW         = "";
            string type            = "";
            string districtW       = "";
            float  network_density = 0.0f;
            float  lenght          = 0.0f;
            float  district_area   = 0.0f;

            EGH01DB.Primitives.MapHelper.GetRiverDensity(db, mapPoint, out districtW, out regionW, out type, out network_density, out lenght, out district_area);

            if (type == string.Empty)
            {
                type = "Не является водным объектом";
            }
            int[] downfall;
            EGH01DB.Primitives.MapHelper.GetDownfall(db, mapPoint, out downfall);

            if (water_Object.iswaterobject)
            {
                watername = water_Object.name;
                watertype = water_Object.ecoobjecttype.name;
            }
            else
            {
                watername = "Не является водным объектом";
                watertype = "Не является водным объектом";
            }
            EGH01DB.Types.WaterProtectionArea water_area = new WaterProtectionArea();
            EGH01DB.Primitives.MapHelper.GetWaterProtectionZone(db, mapPoint, out water_area);
            int WaterAreaBuff = 0;

            if (water_area.type_code != -1)
            {
                WaterAreaBuff = water_area.buffer;
            }
            var heights = new
            {
                District          = district.name,
                Region            = district.region.name,
                Watername         = watername,
                Watertype         = watertype,
                WaterintakeName   = water_intake.name,
                Waterintakebuffer = water_intake.buffer,
                RegionW           = regionW,
                Type            = type,
                DistrictW       = districtW,
                Network_density = network_density,
                Lenght          = lenght,
                District_area   = district_area,
                Downfall        = downfall,
                WaterAreaName   = water_area.name,
                WaterAreaBuff   = WaterAreaBuff
            };

            return(Json(heights));
        }