예제 #1
0
 public EcoObject(string name, EcoObjectType ecoobjecttype, CadastreType cadastretype, bool iswaterobject)
 {
     this.id                 = -1;
     this.ecoobjecttype      = ecoobjecttype;
     this.cadastretype       = cadastretype;
     this.name               = name;
     this.iswaterobject      = iswaterobject;
     this.angle              = 0.0f;
     this.pollutionecoobject = 0.0f;
 }
예제 #2
0
 public EcoObject(int id, Point point, EcoObjectType ecoobjecttype, CadastreType cadastretype, string name, bool iswaterobject, float angle, float pollutionecoobject)
     : base(point)
 {
     this.id                 = id;
     this.ecoobjecttype      = ecoobjecttype;
     this.cadastretype       = cadastretype;
     this.name               = name;
     this.iswaterobject      = iswaterobject;
     this.angle              = angle;
     this.pollutionecoobject = pollutionecoobject;
 }
예제 #3
0
        // #2 Получение карты водоемов
        static public bool GetWaterPond(EGH01DB.IDBContext dbcontext, Coordinates coordinates, out EcoObject water_object) // водные объекты - озера, водохранилища
        {
            bool rc = false;

            water_object = new EcoObject();
            using (SqlCommand cmd = new SqlCommand("MAP.InPondMap", 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 type = (string)reader["type"];
                        string name = (string)reader["name"];

                        EcoObjectType eco_object_type = new EcoObjectType(type);
                        CadastreType  cadastre_type   = new CadastreType("Водный объект");

                        water_object = new EcoObject(name, eco_object_type, cadastre_type, true);
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
예제 #4
0
        static public bool CreateNear(EGH01DB.IDBContext dbcontext, EcoObject ecoobject, float angle, float distance, out EcoObject eco_object)
        {
            bool rc = false;
            int  id = -1;

            eco_object = new EcoObject();
            using (SqlCommand cmd = new SqlCommand("EGH.GetCoordinatesByAngle", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@lat1", SqlDbType.Real);
                    parm.Value = ecoobject.coordinates.latitude;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@lng1", SqlDbType.Real);
                    parm.Value = ecoobject.coordinates.lngitude;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@angle", SqlDbType.Real);
                    parm.Value = angle;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@distance", SqlDbType.Real);
                    parm.Value = distance;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@lat2", SqlDbType.Real);
                    parm.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@lng2", SqlDbType.Real);
                    parm.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    cmd.ExecuteNonQuery();

                    float       x           = (float)cmd.Parameters["@lat2"].Value;
                    float       y           = (float)cmd.Parameters["@lng2"].Value;
                    Coordinates coordinates = new Coordinates((float)x, (float)y);

                    int        new_ground_type_code = ecoobject.groundtype.type_code;
                    float      new_waterdeep        = ecoobject.waterdeep;
                    float      new_height           = ecoobject.height;
                    GroundType new_ground_type      = new GroundType(new_ground_type_code);
                    Point      point = new Point(coordinates, new_ground_type, new_waterdeep, new_height);

                    int           new_cadastre_type_code = ecoobject.cadastretype.type_code;
                    bool          iswaterobject          = ecoobject.iswaterobject;
                    string        name = ecoobject.name;
                    int           ecoobjecttype_code = ecoobject.ecoobjecttype.type_code;
                    EcoObjectType ecoobjecttype      = new EcoObjectType(ecoobjecttype_code);
                    CadastreType  cadastretype       = new CadastreType(new_cadastre_type_code);

                    eco_object = new EcoObject(id, point, ecoobjecttype, cadastretype, name, iswaterobject);
                    if (EcoObject.Create(dbcontext, eco_object))
                    {
                        rc = true;
                    }
                }
                catch (Exception e)
                {
                    rc = false;
                };
                return(rc);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        public ActionResult EcoObjectType()
        {
            ViewBag.EGHLayout = "RGE.EcoObjectType";
            RGEContext   db       = null;
            ActionResult view     = View("Index");
            string       menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";

            try
            {
                db          = new RGEContext();
                ViewBag.msg = "Соединение с базой данных установлено";
                view        = View("EcoObjectType", db);
                if (menuitem.Equals("EcoObjectType.Create"))
                {
                    view = View("EcoObjectTypeCreate");
                }
                else if (menuitem.Equals("EcoObjectType.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))
                        {
                            EcoObjectType it = new EcoObjectType();
                            if (EGH01DB.Types.EcoObjectType.GetByCode(db, c, out it))
                            {
                                view = View("EcoObjectTypeDelete", it);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("EcoObjectType.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))
                        {
                            EcoObjectType it = new EcoObjectType();
                            if (EGH01DB.Types.EcoObjectType.GetByCode(db, c, out it))
                            {
                                view = View("EcoObjectTypeUpdate", it);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("EcoObjectType.Excel"))
                {
                    EGH01DB.Types.EcoObjectTypeList list = new EcoObjectTypeList(db);
                    XmlNode     node  = list.toXmlNode();
                    XmlDocument doc   = new XmlDocument();
                    XmlNode     nnode = doc.ImportNode(node, true);
                    doc.AppendChild(nnode);
                    doc.Save(Server.MapPath("~/App_Data/EcoObjectType.xml"));
                    view = View("Index");

                    view = File(Server.MapPath("~/App_Data/EcoObjectType.xml"), "text/plain", "Типы природоохранных объектов.xml");
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }