Exemple #1
0
        public static bool Delete(EGH01DB.IDBContext dbcontext, SpreadingCoefficient spreading_coefficient)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.DeleteSpreadingCoefficient", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@КодКоэффициентаРазлива", SqlDbType.Int);
                    parm.Value = spreading_coefficient.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);
        }
Exemple #2
0
        public static bool Create(EGH01DB.IDBContext dbcontext, SpreadingCoefficient spreading_coefficient)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.CreateSpreadingCoefficient", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@ТипГрунта", SqlDbType.Int);
                    parm.Value = spreading_coefficient.ground_type.type_code;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КодТипаНефтепродукта", SqlDbType.Int);
                    parm.Value = spreading_coefficient.petrochemical_type.code_type;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МинПролива", SqlDbType.Real);
                    parm.Value = spreading_coefficient.min_volume;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МаксПролива", SqlDbType.Real);
                    parm.Value = spreading_coefficient.max_volume;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МинУклона", SqlDbType.Real);
                    parm.Value = spreading_coefficient.min_angle;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МаксУклона", SqlDbType.Real);
                    parm.Value = spreading_coefficient.max_angle;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КоэффициентРазлива", SqlDbType.Float);
                    parm.Value = spreading_coefficient.koef;
                    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 == 1);
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }

            return(rc);
        }
        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);
        }
        public ActionResult SpreadingCoefficient()
        {
            RGEContext   db   = null;
            ActionResult view = View("Index");

            ViewBag.EGHLayout = "RGE.SpreadingCoefficient";
            string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";

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


                if (menuitem.Equals("SpreadingCoefficient.Create"))
                {
                    view = View("SpreadingCoefficientCreate");
                }

                else if (menuitem.Equals("SpreadingCoefficient.Delete"))
                {
                    string code = this.HttpContext.Request.Params["code"];
                    if (code != null)
                    {
                        int c = 0;
                        if (int.TryParse(code, out c))
                        {
                            EGH01DB.Primitives.SpreadingCoefficient sc = new EGH01DB.Primitives.SpreadingCoefficient();
                            if (EGH01DB.Primitives.SpreadingCoefficient.GetByCode(db, c, out sc))
                            {
                                view = View("SpreadingCoefficientDelete", sc);
                            }
                        }
                    }
                }


                else if (menuitem.Equals("SpreadingCoefficient.Update"))
                {
                    string code = this.HttpContext.Request.Params["code"];

                    if (code != null)
                    {
                        int c = 0;
                        if (int.TryParse(code, out c))
                        {
                            SpreadingCoefficient sc = new SpreadingCoefficient();
                            if (EGH01DB.Primitives.SpreadingCoefficient.GetByCode(db, c, out sc))
                            {
                                view = View("SpreadingCoefficientUpdate", sc);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("SpreadingCoefficient.Excel"))
                {
                    EGH01DB.Primitives.SpreadingCoefficientList list = new SpreadingCoefficientList(db);
                    XmlNode     node  = list.toXmlNode();
                    XmlDocument doc   = new XmlDocument();
                    XmlNode     nnode = doc.ImportNode(node, true);
                    doc.AppendChild(nnode);
                    doc.Save(Server.MapPath("~/App_Data/SpreadingCoefficient.xml"));
                    view = View("Index");
                    view = File(Server.MapPath("~/App_Data/SpreadingCoefficient.xml"), "text/plain", "Коэффициент растекания.xml");
                }
            }

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

            return(view);
        }
Exemple #5
0
        public static bool GetByCode(EGH01DB.IDBContext dbcontext, int code, out SpreadingCoefficient spreading_coefficient)
        {
            bool rc = false;

            spreading_coefficient = new SpreadingCoefficient();
            using (SqlCommand cmd = new SqlCommand("EGH.GetSpreadingCoefficientByCode", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@КодКоэффициентаРазлива", SqlDbType.Int);
                    parm.Value = 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())
                    {
                        int    ground_type_code = (int)reader["ТипГрунта"];
                        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)ground_type_code,
                                                                    (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);
                        int    petrochemical_type_code = (int)reader["КодТипаНефтепродукта"];
                        string name                                = (string)reader["НаименованиеТипаНефтепродукта"];
                        float  boilingtemp                         = (float)reader["ТемператураКипения"];
                        float  petrochemical_density               = (float)reader["Плотность"];
                        float  viscosity                           = (float)reader["КинематическаяВязкость"];
                        float  solubility                          = (float)reader["Растворимость"];
                        float  tension                             = (float)reader["КоэфНатяжения"];
                        float  dynamicviscosity                    = (float)reader["ДинамическаяВязкость"];
                        float  petrochemical_diffusion             = (float)reader["КоэфДиффузииНП"];
                        int    petrochemicalcategories             = (int)reader["КодКатегорииНефтепродукта"];
                        string petrochemicalcategoriesname         = (string)reader["НаименованиеКатегорииНефтепродукта"];
                        PetrochemicalCategories petro_cat          = new PetrochemicalCategories(petrochemicalcategories, petrochemicalcategoriesname);
                        PetrochemicalType       petrochemical_type = new PetrochemicalType(petrochemical_type_code,
                                                                                           name,
                                                                                           (float)boilingtemp,
                                                                                           (float)petrochemical_density,
                                                                                           (float)viscosity,
                                                                                           (float)solubility,
                                                                                           (float)tension,
                                                                                           (float)dynamicviscosity,
                                                                                           (float)petrochemical_diffusion, petro_cat);

                        float  min_volume = (float)reader["МинПролива"];
                        float  max_volume = (float)reader["МаксПролива"];
                        float  min_angle  = (float)reader["МинУклона"];
                        float  max_angle  = (float)reader["МаксУклона"];
                        double koef       = (double)reader["КоэффициентРазлива"];
                        if (rc = (int)cmd.Parameters["@exitrc"].Value > 0)
                        {
                            spreading_coefficient = new SpreadingCoefficient(code, ground_type,
                                                                             petrochemical_type,
                                                                             (float)min_volume,
                                                                             (float)max_volume,
                                                                             (float)min_angle,
                                                                             (float)max_angle,
                                                                             (float)koef);
                        }
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    rc = false;
                };
            }
            return(rc);
        }
Exemple #6
0
        // круглое пятно: грунт, объем, угол наклона
        public static float Get(EGH01DB.IDBContext dbcontext, SpreadingCoefficient spreading_coefficient) // получить коэффициент растекания, -1 - такого нет
        {
            int   rc          = -1;
            float koefficient = -1.0f;

            using (SqlCommand cmd = new SqlCommand("EGH.GetSpreadingCoefficientByDelta", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm = new SqlParameter("@ТипГрунта", SqlDbType.Int);
                    parm.Value = spreading_coefficient.ground_type.type_code;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МинПролива", SqlDbType.Real);
                    parm.Value = spreading_coefficient.min_volume;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МаксПролива", SqlDbType.Real);
                    parm.Value = spreading_coefficient.max_volume;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МинУклона", SqlDbType.Real);
                    parm.Value = spreading_coefficient.min_angle;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@МаксУклона", SqlDbType.Real);
                    parm.Value = spreading_coefficient.max_angle;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@КодТипаНефтепродукта", SqlDbType.Int);
                    parm.Value = spreading_coefficient.petrochemical_type.code_type;
                    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())
                    {
                        double kof = (double)reader["КоэффициентРазлива"];
                        if ((int)cmd.Parameters["@exitrc"].Value > 0)
                        {
                            rc          = (int)cmd.Parameters["@exitrc"].Value;
                            koefficient = (float)kof;
                        }
                    }
                    reader.Close();
                }
                catch (Exception e)
                {
                    rc = -1;
                };
            }
            return(koefficient);
        }
Exemple #7
0
        // заглушка
        public static bool GetByParms(GroundType groundtype, PetrochemicalType petrochemicaltype, float volume, float angle, out SpreadingCoefficient spreadingcoefficient)
        {
            spreadingcoefficient = new SpreadingCoefficient(0, groundtype, petrochemicaltype, 0.0f, 80.0f, 0.0f, 0.02f, 4.0f);

            return(true);
        }