public ActionResult EcoObjectCreate(EGH01.Models.EGHRGE.EcoObjectView eo) { RGEContext db = null; ViewBag.EGHLayout = "RGE.EcoObject"; ActionResult view = View("Index"); string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty"; try { db = new RGEContext(); view = View("EcoObject", db); if (menuitem.Equals("EcoObjectCreateEco.Create")) { view = View("EcoObjectCreateEco"); return(view); } if (menuitem.Equals("EcoObject.Create.Create")) { int id = -1; if (EGH01DB.Objects.EcoObject.GetNextId(db, out id)) { String name = eo.name; CadastreType type_cadastre = new CadastreType(); if (EGH01DB.Types.CadastreType.GetByCode(db, eo.list_cadastre, out type_cadastre)) { EcoObjectType eco_type = new EcoObjectType(); if (EGH01DB.Types.EcoObjectType.GetByCode(db, eo.list_ecoType, out eco_type)) { bool iswaterobject = eo.iswaterobject; string strlat_s = this.HttpContext.Request.Params["lat_s"] ?? "Empty"; string strlng_s = this.HttpContext.Request.Params["lng_s"] ?? "Empty"; string strwaterdeep = this.HttpContext.Request.Params["waterdeep"] ?? "Empty"; string strheight = this.HttpContext.Request.Params["height"] ?? "Empty"; float lat_s = 0.0f; float lng_s = 0.0f; float waterdeep = 0.0f; float height = 0.0f; if (!Helper.FloatTryParse(strlat_s, out lat_s)) { lat_s = 0.0f; } if (!Helper.FloatTryParse(strlng_s, out lng_s)) { lng_s = 0.0f; } if (!Helper.FloatTryParse(strwaterdeep, out waterdeep)) { waterdeep = 0.0f; } if (!Helper.FloatTryParse(strheight, out height)) { height = 0.0f; } Coordinates coordinates = new Coordinates(eo.latitude, eo.lat_m, lat_s, eo.lngitude, eo.lng_m, lng_s); EGH01DB.Types.GroundType ground_type = new EGH01DB.Types.GroundType(); if (EGH01DB.Types.GroundType.GetByCode(db, eo.list_groundType, out ground_type)) { Point point = new Point(coordinates, ground_type, waterdeep, height); EGH01DB.Objects.EcoObject eco_object = new EGH01DB.Objects.EcoObject(id, point, eco_type, type_cadastre, name, iswaterobject); if (EGH01DB.Objects.EcoObject.Create(db, eco_object)) { view = View("EcoObject", db); } } } } else if (menuitem.Equals("EcoObject.Create.Cancel")) { view = View("EcoObject", db); } } } } catch (RGEContext.Exception e) { ViewBag.msg = e.message; } catch (Exception e) { ViewBag.msg = e.Message; } return(view); }
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 EcoObject() { RGEContext db = null; ViewBag.EGHLayout = "RGE.EcoObject"; ActionResult view = View("Index"); string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty"; try { db = new RGEContext(); ViewBag.msg = "Соединение с базой данных установлено"; view = View("EcoObject", db); if (menuitem.Equals("EcoObject.Create")) { view = View("EcoObjectCreate"); } else if (menuitem.Equals("EcoObject.Delete")) { string id = this.HttpContext.Request.Params["type_code"]; if (id != null) { int c = 0; if (int.TryParse(id, out c)) { EGH01DB.Objects.EcoObject eo = new EGH01DB.Objects.EcoObject(); if (EGH01DB.Objects.EcoObject.GetById(db, c, ref eo)) { view = View("EcoObjectDelete", eo); } } } } else if (menuitem.Equals("EcoObject.Update")) { string id = this.HttpContext.Request.Params["type_code"]; if (id != null) { int c = 0; if (int.TryParse(id, out c)) { EGH01DB.Objects.EcoObject eo = new EGH01DB.Objects.EcoObject(); if (EGH01DB.Objects.EcoObject.GetById(db, c, ref eo)) { view = View("EcoObjectUpdate", eo); } } } } else if (menuitem.Equals("EcoObject.Excel")) { EGH01DB.Objects.EcoObjectsList list = new EGH01DB.Objects.EcoObjectsList(db); XmlNode node = list.toXmlNode(); XmlDocument doc = new XmlDocument(); XmlNode nnode = doc.ImportNode(node, true); doc.AppendChild(nnode); doc.Save(Server.MapPath("~/App_Data/EcoObject.xml")); view = View("Index"); view = File(Server.MapPath("~/App_Data/EcoObject.xml"), "text/plain", "Природоохранные объекты.xml"); } } catch (RGEContext.Exception e) { ViewBag.msg = e.message; } catch (Exception e) { ViewBag.msg = e.Message; } return(view); }
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)); }