Esempio n. 1
0
        static public bool Delete(EGH01DB.IDBContext dbcontext, GroundType ground_type)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.DeleteGroundType", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@КодТипаГрунта", SqlDbType.Int);
                    parm.Value = ground_type.type_code;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    cmd.ExecuteNonQuery();
                    rc = (int)cmd.Parameters["@exitrc"].Value > 0;
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
Esempio n. 2
0
        public bool GetByCoordinates(float x, float y, EGH01DB.IDBContext dbcontext, out GroundType ground_type)  // smw: Coordinates
        {
            bool rc = false;

            ground_type = new GroundType();
            using (SqlCommand cmd = new SqlCommand("EGH.InSoilMap", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@point1", SqlDbType.VarChar);
                    parm.Value = x;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@point2", SqlDbType.VarChar);
                    parm.Value = y;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    cmd.ExecuteNonQuery();
                    string name        = (string)cmd.Parameters["@OutName"].Value;
                    float  filtration  = (float)cmd.Parameters["@OutFiltration"].Value;
                    float  poristost   = (float)cmd.Parameters["@OutPoristost"].Value;
                    float  vlagoemkost = (float)cmd.Parameters["@OutVlagoemkost"].Value;
                    float  gumus_depth = (float)cmd.Parameters["@OutGumusDepth"].Value;
                    string klass       = (string)cmd.Parameters["@OutKlass"].Value;
                    string soil_type   = (string)cmd.Parameters["@OutType"].Value;
                    ground_type = new GroundType();
                    rc          = (int)cmd.Parameters["@exitrc"].Value > 0;
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
Esempio n. 3
0
        public static bool GetByMap(IDBContext db, Coordinates coordinates, out GroundType groundtype)
        {
            bool rc = false;

            groundtype = new GroundType();
            string aeration_power;
            float  average_aeration_power;
            float  max_aeration_power;
            string litology;

            if (rc = MapHelper.GetAerationZone(db, coordinates, out aeration_power, out average_aeration_power, out max_aeration_power, out litology))
            {
                if (!(rc = MapHelper.GetGroundCoef(db, coordinates, out groundtype)))
                {
                    groundtype = GroundType.defaulttype;
                }
                else
                {
                    groundtype.name = litology;
                }
            }

            return(rc);
        }
Esempio n. 4
0
        public ActionResult RiskObjectCreate(EGH01.Models.EGHCAI.RiskObject rs)
        {
            CAIContext db = null;

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

            try
            {
                db   = new CAIContext();
                view = View("RiskObject", db);
                if (menuitem.Equals("RiskObject.Create.Create"))
                {
                    int id = -1;
                    if (EGH01DB.Objects.RiskObject.GetNextId(db, out id))
                    {
                        String  ownership             = "f";
                        int     numberofrefuel        = 1;
                        int     volume                = 1;
                        Boolean watertreatment        = rs.watertreatment;
                        Boolean watertreatmentcollect = rs.watertreatmentcollect;
                        string  base64                = rs.base64;
                        Byte[]  map;
                        if (base64 == null)
                        {
                            map = new byte[0];
                        }
                        else
                        {
                            map = ASCIIEncoding.ASCII.GetBytes(base64);
                        }


                        int    groundtank      = rs.groundtank;
                        int    undergroundtank = rs.undergroundtank;
                        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(rs.latitude, rs.lat_m, lat_s, rs.lngitude, rs.lng_m, lng_s);
                        float       latitude    = EGH01DB.Primitives.Coordinates.dms_to_d(rs.latitude, rs.lat_m, rs.lat_s);
                        EGH01DB.Types.GroundType ground_type = new EGH01DB.Types.GroundType();
                        if (EGH01DB.Types.GroundType.GetByCode(db, rs.list_groundType, out ground_type))
                        {
                            Point point = new Point(coordinates, ground_type, waterdeep, height);
                            EGH01DB.Types.RiskObjectType risk_object_type = new EGH01DB.Types.RiskObjectType();
                            if (EGH01DB.Types.RiskObjectType.GetByCode(db, rs.selectlist, out risk_object_type))
                            {
                                EGH01DB.Types.CadastreType cadastre_type = new EGH01DB.Types.CadastreType();
                                if (EGH01DB.Types.CadastreType.GetByCode(db, rs.list_cadastre, out cadastre_type))
                                {
                                    EGH01DB.Types.District district = new EGH01DB.Types.District();
                                    if (EGH01DB.Types.District.GetByCode(db, rs.list_district, out district))
                                    {
                                        EGH01DB.Types.Region region = new EGH01DB.Types.Region();
                                        if (EGH01DB.Types.Region.GetByCode(db, rs.list_region, out region))
                                        {
                                            DateTime foundationdate = rs.foundationdate;
                                            if (foundationdate.Year == 0001)
                                            {
                                                foundationdate = new DateTime(1900, 01, 01);
                                            }

                                            DateTime reconstractiondate = rs.reconstractiondate;
                                            if (reconstractiondate.Year == 0001)
                                            {
                                                reconstractiondate = new DateTime(1900, 01, 01);
                                            }
                                            string name    = rs.name;
                                            String phone   = rs.phone;
                                            String fax     = rs.fax;
                                            string address = rs.adress;
                                            String email   = rs.email;



                                            String fueltype       = rs.fax;
                                            String geodescription = rs.fax;
                                            EGH01DB.Objects.RiskObject risk_object = new EGH01DB.Objects.RiskObject(id, point, risk_object_type, cadastre_type, name,
                                                                                                                    district, region, address, ownership, phone, fax, email, foundationdate, reconstractiondate, numberofrefuel, volume, watertreatment,
                                                                                                                    watertreatmentcollect, map, groundtank, undergroundtank, fueltype, 0, 0.0f, 0.0f, geodescription);

                                            if (EGH01DB.Objects.RiskObject.Create(db, risk_object))
                                            {
                                                view = View("RiskObject", db);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (menuitem.Equals("RiskObject.Create.Cancel"))
                            {
                                view = View("RiskObject", db);
                            }
                        }
                    }
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }
        public ActionResult SpreadingCoefficientCreate(SpreadingCoefficientView scv)
        {
            RGEContext db = null;

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

            try
            {
                db   = new RGEContext();
                view = View("SpreadingCoefficient", db);
                if (menuitem.Equals("SpreadingCoefficient.Create.Create"))
                {
                    EGH01DB.Types.GroundType type_groud = new EGH01DB.Types.GroundType();
                    if (EGH01DB.Types.GroundType.GetByCode(db, scv.list_groundType, out type_groud))
                    {
                        EGH01DB.Types.PetrochemicalType petrochemical_type = new PetrochemicalType();
                        if (EGH01DB.Types.PetrochemicalType.GetByCode(db, scv.list_petrochemicalType, ref petrochemical_type))
                        {
                            int code = scv.code;

                            string strmin_angle = this.HttpContext.Request.Params["min_angle"] ?? "Empty";
                            float  min_angle;
                            Helper.FloatTryParse(strmin_angle, out min_angle);

                            string strmax_angle = this.HttpContext.Request.Params["max_angle"] ?? "Empty";
                            float  max_angle;
                            Helper.FloatTryParse(strmax_angle, out max_angle);

                            string strmin_volume = this.HttpContext.Request.Params["min_volume"] ?? "Empty";
                            float  min_volume;
                            Helper.FloatTryParse(strmin_volume, out min_volume);

                            string strmax_volume = this.HttpContext.Request.Params["max_volume"] ?? "Empty";
                            float  max_volume;
                            Helper.FloatTryParse(strmax_volume, out max_volume);

                            string strkoef = this.HttpContext.Request.Params["koef"] ?? "Empty";
                            float  koef;
                            Helper.FloatTryParse(strkoef, out koef);

                            SpreadingCoefficient sc = new EGH01DB.Primitives.SpreadingCoefficient((int)code, type_groud, petrochemical_type, (float)min_volume, (float)max_volume, (float)min_angle, (float)max_angle, (float)koef);
                            // исправить тип нефтепродукта
                            //koef = EGH01DB.Primitives.SpreadingCoefficient.Get(db, sc);
                            //sc = new EGH01DB.Primitives.SpreadingCoefficient((int)code, type_groud, (float)min_volume, (float)max_volume, (float)min_angle, (float)max_angle, (float)koef);
                            if (EGH01DB.Primitives.SpreadingCoefficient.Create(db, sc))
                            {
                                view = View("SpreadingCoefficient", db);
                            }
                            else if (menuitem.Equals("SpreadingCoefficient.Create.Cancel"))
                            {
                                view = View("SpreadingCoefficient", db);
                            }
                        }

                        else if (menuitem.Equals("SpreadingCoefficient.Create.Cancel"))
                        {
                            view = View("SpreadingCoefficient", db);
                        }
                    }
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }
Esempio n. 6
0
        static public bool Update(EGH01DB.IDBContext dbcontext, GroundType ground_type)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.UpdateGroundType", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@КодТипаГрунта", SqlDbType.Int);
                    parm.Value = ground_type.type_code;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@НаименованиеТипаГрунта", SqlDbType.VarChar);
                    parm.Value = ground_type.name;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфПористости", SqlDbType.Real);
                    parm.Value = ground_type.porosity;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфЗадержкиМиграции", SqlDbType.Real);
                    parm.Value = ground_type.holdmigration;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфФильтрацииВоды", SqlDbType.Real);
                    parm.Value = ground_type.waterfilter;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфДиффузии", SqlDbType.Real);
                    parm.Value = ground_type.diffusion;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфРаспределения", SqlDbType.Real);
                    parm.Value = ground_type.distribution;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфСорбции", SqlDbType.Real);
                    parm.Value = ground_type.sorption;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфКапВлагоемкости", SqlDbType.Real);
                    parm.Value = ground_type.watercapacity;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ВлажностьГрунта", SqlDbType.Real);
                    parm.Value = ground_type.soilmoisture;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэфАверьянова", SqlDbType.Real);
                    parm.Value = ground_type.аveryanovfactor;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@Водопроницаемость", SqlDbType.Real);
                    parm.Value = ground_type.permeability;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@СредняяПлотностьГрунта", SqlDbType.Real);
                    parm.Value = ground_type.density;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }
                try
                {
                    cmd.ExecuteNonQuery();
                    rc = (int)cmd.Parameters["@exitrc"].Value > 0;
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
Esempio n. 7
0
        static public bool GetByCode(EGH01DB.IDBContext dbcontext, int type_code, out GroundType ground_type)
        {
            bool rc = false;

            ground_type = new GroundType();
            using (SqlCommand cmd = new SqlCommand("EGH.GetGroundTypeByCode", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@КодТипаГрунта", SqlDbType.Int);
                    parm.Value = type_code;
                    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())
                    {
                        string name            = (string)reader["НаименованиеТипаГрунта"];
                        float  porosity        = (float)reader["КоэфПористости"];
                        float  holmigration    = (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["СредняяПлотностьГрунта"];
                        if (rc = (int)cmd.Parameters["@exitrc"].Value > 0)
                        {
                            ground_type = new GroundType((int)type_code,
                                                         (string)name,
                                                         (float)porosity,
                                                         (float)holmigration,
                                                         (float)waterfilter,
                                                         (float)diffusion,
                                                         (float)distribution,
                                                         (float)sorption,
                                                         (float)watercapacity,
                                                         (float)soilmoisture,
                                                         (float)аveryanovfactor,
                                                         (float)permeability,
                                                         (float)density);
                        }
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public ActionResult GroundTypeCreate(EGH01.Models.EGHRGE.GroundTypeView gt)
        {
            RGEContext db = null;

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

            try
            {
                db = new RGEContext(this);
                if (!GroundTypeView.Handler(db, this.HttpContext.Request.Params))
                {
                }
                view = View(db);
                if (menuitem.Equals("GroundType.Create.Create"))
                {
                    GroundTypeView viewcontext = db.GetViewContext(GroundTypeView.VIEWNAME) as GroundTypeView;
                    if (viewcontext != null)
                    {
                        int    type_code = -1;
                        float  diffusion;
                        string strdiffusion = this.HttpContext.Request.Params["diffusion"] ?? "Empty";
                        if (!Helper.FloatTryParse(strdiffusion, out diffusion))
                        {
                            diffusion = 0.0f;
                        }
                        float  distribution;
                        string strdistribution = this.HttpContext.Request.Params["distribution"] ?? "Empty";
                        if (!Helper.FloatTryParse(strdistribution, out distribution))
                        {
                            distribution = 0.0f;
                        }
                        float  sorption    = 0.0f;
                        string strsorption = this.HttpContext.Request.Params["sorption"] ?? "Empty";
                        if (!Helper.FloatTryParse(strsorption, out sorption))
                        {
                            sorption = 0.0f;
                        }
                        float  permeability    = 0.2f;
                        string strpermeability = this.HttpContext.Request.Params["permeability"] ?? "Empty";
                        if (!Helper.FloatTryParse(strpermeability, out permeability))
                        {
                            permeability = 0.0f;
                        }
                        String name        = gt.name;
                        string strporosity = this.HttpContext.Request.Params["porosity"] ?? "Empty";
                        float  porosity    = 0.1f;
                        if (!Helper.FloatTryParse(strporosity, out porosity))
                        {
                            porosity = 0.0f;
                        }
                        string strsoilmoisture = this.HttpContext.Request.Params["soilmoisture"] ?? "Empty";
                        float  soilmoisture    = 0.1f;//влажность
                        if (!Helper.FloatTryParse(strsoilmoisture, out soilmoisture))
                        {
                            soilmoisture = 0.0f;
                        }
                        string strwatercapacity = this.HttpContext.Request.Params["watercapacity"] ?? "Empty";
                        float  watercapacity    = 0.1f;//влагоемкость
                        if (!Helper.FloatTryParse(strwatercapacity, out watercapacity))
                        {
                            watercapacity = 0.0f;
                        }
                        string strholdmigration = this.HttpContext.Request.Params["holdmigration"] ?? "Empty";
                        float  holdmigration    = 0.1f;//задержки
                        if (!Helper.FloatTryParse(strholdmigration, out holdmigration))
                        {
                            holdmigration = 0.0f;
                        }
                        string strwaterfilter = this.HttpContext.Request.Params["waterfilter"] ?? "Empty";
                        float  waterfilter    = 0.1f;//фильтрации
                        if (!Helper.FloatTryParse(strwaterfilter, out waterfilter))
                        {
                            waterfilter = 0.0f;
                        }
                        string strаveryanovfactor = this.HttpContext.Request.Params["аveryanovfactor"] ?? "Empty";
                        float  аveryanovfactor    = 0.1f;//аверьянова коэф
                        if (!Helper.FloatTryParse(strаveryanovfactor, out аveryanovfactor))
                        {
                            аveryanovfactor = 0.0f;
                        }

                        string strdensity = this.HttpContext.Request.Params["density"] ?? "Empty";
                        float  density    = 0.1f;
                        if (!Helper.FloatTryParse(strdensity, out density))
                        {
                            density = 0.0f;
                        }

                        if ((watercapacity < porosity) && (soilmoisture >= watercapacity) && (soilmoisture <= porosity))
                        {
                            EGH01DB.Types.GroundType ground_type = new EGH01DB.Types.GroundType(type_code, name, porosity, holdmigration, waterfilter, diffusion, distribution, sorption, watercapacity, soilmoisture, аveryanovfactor, permeability, density);

                            if (EGH01DB.Types.GroundType.Create(db, ground_type))
                            {
                                view = View("GroundType", db);
                            }
                        }
                        else
                        {
                            GroundTypeView viewcontexts = db.GetViewContext("GroundTypeCreate") as GroundTypeView;

                            ViewBag.Error = "Проверьте введенные данные";
                            view          = View("GroundTypeCreate", db);
                            return(view);
                        }
                    }
                }
                if (menuitem.Equals("GroundType.Create.Cancel"))
                {
                    view = View("GroundType", db);
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }
Esempio n. 10
0
        public ActionResult GroundType()
        {
            RGEContext db = null;

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

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

                    view = File(Server.MapPath("~/App_Data/GroundType.xml"), "text/plain", "Типы грунтов.xml");
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }
Esempio n. 11
0
        public ActionResult AnchorPointCreatePoint(AnchorPointView ah)
        {
            RGEContext db = null;

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

            try
            {
                db   = new RGEContext();
                view = View("AnchorPoint", db);

                if (menuitem.Equals("AnchorPointCreate.Create.Create"))
                {
                    int id = -1;
                    if (EGH01DB.Points.AnchorPoint.GetNextId(db, out id))
                    {
                        float  lat_s    = 0.0f;
                        string strlat_s = this.HttpContext.Request.Params["lat_s"] ?? "Empty";
                        if (!Helper.FloatTryParse(strlat_s, out lat_s))
                        {
                            lat_s = 0.0f;
                        }

                        float  angel    = 0.0f;
                        string strangel = this.HttpContext.Request.Params["angel"] ?? "Empty";
                        if (!Helper.FloatTryParse(strangel, out angel))
                        {
                            angel = 0.0f;
                        }

                        float  distance    = 0.0f;
                        string strdistance = this.HttpContext.Request.Params["distance"] ?? "Empty";
                        if (!Helper.FloatTryParse(strdistance, out distance))
                        {
                            distance = 0.0f;
                        }


                        float  lng_s    = 0.0f;
                        string strlng_s = this.HttpContext.Request.Params["lng_s"] ?? "Empty";
                        if (!Helper.FloatTryParse(strlng_s, out lng_s))
                        {
                            lng_s = 0.0f;
                        }


                        Coordinates coordinates   = new Coordinates(ah.Lat_d, ah.lat_m, lat_s, ah.lngitude, ah.lng_m, lng_s);
                        float       waterdeep     = 0.0f;
                        int         list_cadastre = ah.list_cadastre;

                        float  height    = 0.0f;
                        string strheight = this.HttpContext.Request.Params["height"] ?? "Empty";
                        if (!Helper.FloatTryParse(strheight, out height))
                        {
                            height = 0.0f;
                        }

                        string strwaterdeep = this.HttpContext.Request.Params["waterdeep"] ?? "Empty";
                        if (!Helper.FloatTryParse(strwaterdeep, out waterdeep))
                        {
                            waterdeep = 0.0f;
                        }
                        EGH01DB.Types.GroundType ground_type = new EGH01DB.Types.GroundType();
                        if (EGH01DB.Types.GroundType.GetByCode(db, ah.list_groundType, out ground_type))
                        {
                            Point        point         = new Point(coordinates, ground_type, waterdeep, height);
                            CadastreType type_cadastre = new CadastreType();
                            if (EGH01DB.Types.CadastreType.GetByCode(db, ah.list_cadastre, out type_cadastre))
                            {
                                EGH01DB.Points.AnchorPoint anchor_point = new EGH01DB.Points.AnchorPoint(id, point, type_cadastre);


                                if (EGH01DB.Points.AnchorPoint.Create(db, anchor_point, angel, distance))
                                {
                                    view = View("AnchorPoint", db);
                                }
                                else if (menuitem.Equals("AnchorPoint.Create.Cancel"))
                                {
                                    view = View("AnchorPoint", db);
                                }
                                {
                                }
                            }
                        }
                    }
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }