Esempio n. 1
0
        static public bool Create(EGH01DB.IDBContext dbcontext, AnchorPoint anchor_point)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.CreateAnchorPoint", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@IdОпорнойГеологическойТочки", SqlDbType.Int);
                    int          new_anchor_point_id = 0;
                    if (GetNextId(dbcontext, out new_anchor_point_id))
                    {
                        anchor_point.id = new_anchor_point_id;
                    }
                    parm.Value = anchor_point.id;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ШиротаГрад", SqlDbType.Real);
                    parm.Value = anchor_point.coordinates.latitude;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ДолготаГрад", SqlDbType.Real);
                    parm.Value = anchor_point.coordinates.lngitude;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ТипГрунта", SqlDbType.Int);
                    parm.Value = anchor_point.groundtype.type_code;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ГлубинаГрунтовыхВод", SqlDbType.Real);
                    parm.Value = anchor_point.waterdeep;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ВысотаУровнемМоря", SqlDbType.Real);
                    parm.Value = anchor_point.height;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КодНазначенияЗемель", SqlDbType.Int);
                    parm.Value = anchor_point.cadastretype.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 == anchor_point.id);
                }
                catch (Exception e)
                {
                    rc = false;
                };
                return(rc);
            }
        }
Esempio n. 2
0
        static public bool GetById(EGH01DB.IDBContext dbcontext, int id, ref AnchorPoint anchor_point)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.GetAnchorPointByID", 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);

                        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((int)reader["КодНазначенияЗемель"], (string)cadastre_type_name,
                                                                      (float)pdk, (float)water_pdk_coef,
                                                                      ground_doc_name, water_doc_name);

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

                return(rc);
            }
        }
Esempio n. 3
0
        static public bool Create(EGH01DB.IDBContext dbcontext, AnchorPoint anchor_point, float angle, float distance)
        {
            bool rc = false;
            int  id = -1;

            using (SqlCommand cmd = new SqlCommand("EGH.GetCoordinatesByAngle", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@lat1", SqlDbType.Real);
                    parm.Value = anchor_point.coordinates.latitude;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@lng1", SqlDbType.Real);
                    parm.Value = anchor_point.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);
                }
                //{
                //    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                //    parm.Direction = ParameterDirection.ReturnValue;
                //    cmd.Parameters.Add(parm);
                //}
                try
                {
                    cmd.ExecuteNonQuery();
                    // if (rc = ((int)cmd.Parameters["@exitrc"].Value) > 0)
                    // {
                    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 = anchor_point.groundtype.type_code;
                    float      new_waterdeep        = anchor_point.waterdeep;
                    float      new_height           = anchor_point.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 = anchor_point.cadastretype.type_code;
                    CadastreType cadastretype           = new CadastreType(new_cadastre_type_code);

                    AnchorPoint new_anchor_point = new AnchorPoint(id, point, cadastretype);
                    if (AnchorPoint.Create(dbcontext, new_anchor_point))
                    {
                        rc = true;
                    }
                    // }
                }
                catch (Exception e)
                {
                    rc = false;
                };
                return(rc);
            }
        }
Esempio n. 4
0
        static public bool GetByCoordinates(EGH01DB.IDBContext dbcontext, float x, float y, ref AnchorPoint anchor_point, out int Map)
        {
            bool rc = true;

            Map          = 0;
            anchor_point = new AnchorPoint(1);
            return(rc);
        }
        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);
        }
        public ActionResult AnchorPoint()
        {
            RGEContext db = null;

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

            try
            {
                db          = new RGEContext();
                ViewBag.msg = "Соединение с базой данных установлено";
                view        = View("AnchorPoint", db);

                if (menuitem.Equals("AnchorPoint.Create"))
                {
                    view = View("AnchorPointCreate");
                }

                else if (menuitem.Equals("AnchorPoint.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.Points.AnchorPoint ah = new EGH01DB.Points.AnchorPoint();
                            if (EGH01DB.Points.AnchorPoint.GetById(db, c, ref ah))
                            {
                                view = View("AnchorPointDelete", ah);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("AnchorPoint.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.Points.AnchorPoint ah = new EGH01DB.Points.AnchorPoint();
                            if (EGH01DB.Points.AnchorPoint.GetById(db, c, ref ah))
                            {
                                view = View("AnchorPointUpdate", ah);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("AnchorPointCrearePoint.Create"))
                {
                    view = View("AnchorPointCreatePoint");
                }
                else if (menuitem.Equals("AnchorPoint.Excel"))
                {
                    EGH01DB.Points.AnchorPointList list = new AnchorPointList(db);
                    XmlNode     node  = list.toXmlNode();
                    XmlDocument doc   = new XmlDocument();
                    XmlNode     nnode = doc.ImportNode(node, true);
                    doc.AppendChild(nnode);
                    doc.Save(Server.MapPath("~/App_Data/AnchorPoint.xml"));
                    view = View("Index");

                    view = File(Server.MapPath("~/App_Data/AnchorPoint.xml"), "text/plain", "Опорные точки.xml");
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }