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);
        }
Esempio n. 2
0
        public GroundBlur(SpreadPoint spreadpoint)
        {
            this.spreadpoint = spreadpoint;
            RGEContext db = new RGEContext();    // заглушка, выставить правильный контекст //blinova

            this.bordercoordinateslist = new CoordinatesList();

            if (this.spreadpoint.groundtype.watercapacity >= this.spreadpoint.groundtype.porosity)
            {
                throw new EGHDBException(string.Format(errormssageformat, "Влагоемкость грунта не может быть  больше или равна  пористости"));
            }

            if (this.spreadpoint.groundtype.watercapacity >= this.spreadpoint.groundtype.soilmoisture)
            {
                throw new EGHDBException(string.Format(errormssageformat, "Влагоемкость грунта не может быть  больше или равна  влажности грунта"));
            }

            if (this.spreadpoint.petrochemicaltype.tension <= 0)
            {
                throw new EGHDBException(string.Format(errormssageformat, "Коэффициент поверностного натяжение нефтеродукта не может быть меньше или равным нулю "));
            }


            { // коэф. разлива
                float k = SpreadingCoefficient.GetByData(db, this.spreadpoint.groundtype, this.spreadpoint.petrochemicaltype, this.spreadpoint.volume, 0.0f);
                this.spreadingcoefficient = new SpreadingCoefficient(0, this.spreadpoint.groundtype, this.spreadpoint.petrochemicaltype, 0.0f, this.spreadpoint.volume, 0.0f, 0.02f, k);
            }
            if (this.spreadingcoefficient.koef <= 0.0f)
            {
                //this.spreadingcoefficient = new SpreadingCoefficient(0, this.spreadpoint.groundtype, this.spreadpoint.petrochemicaltype, 0.0f, this.spreadpoint.volume, 0.0f, 0.02f, 5.0f);  // заглушка
                throw new EGHDBException(string.Format(errormssageformat, "Коэффициент разлива не может быть меньше или равен нулю"));
            }



            { // свойства воды
                WaterProperties x = new WaterProperties();
                // RGEContext db = new RGEContext();// заглушка, выставить правильный контекст //blinova
                float delta = 0.0f;
                if (WaterProperties.Get(db, 20.0f, out x, out delta))
                {
                    this.waterproperties = x;
                }
            }
            if (this.waterproperties.viscocity <= 0)
            {
                throw new EGHDBException(string.Format(errormssageformat, "Вязкость воды  не может быть меньше или равным нулю "));
            }


            this.square = this.spreadpoint.volume * this.spreadingcoefficient.koef;                  // площадь  пятна

            this.radius = (float)Math.Sqrt(square / Math.PI);                                        // радиус  пятна

            this.petrochemicalheight = this.spreadpoint.volume / this.square;                        // высота слоя разлитого нефтепродукта (м)

            this.totalmass = this.spreadpoint.volume * this.spreadpoint.petrochemicaltype.density;   // масса пролива



            this.anchorpointlist = AnchorPointList.CreateNear(this.spreadpoint.coordinates, this.radius);

            this.ecoobjectsearchradius = this.radius;
            this.ecoobjecstlist        = EcoObjectsList.CreateEcoObjectsList(db, this.spreadpoint, this.ecoobjectsearchradius);

            this.groundpolutionlist = new GroundPollutionList(this.spreadpoint);
            this.groundpolutionlist.AddRange(this.spreadpoint, this.anchorpointlist, this.spreadpoint.petrochemicaltype);
            this.groundpolutionlist.AddRange(this.spreadpoint, this.ecoobjecstlist, this.spreadpoint.petrochemicaltype);


            //  переделать как метод this.groundpolutionlist
            this.avgdeep =                                                                              // средняя глубина грунтовых вод по опорным точкам  и техногенному  объекту
                           (
                anchorpointlist.sumwaterdeep +
                (this.spreadpoint.riskobject != null ? this.spreadpoint.waterdeep : 0.0f)
                           ) /
                           (anchorpointlist.Count + 1);


            this.limitadsorbedmass =                                                                           // максиальная маса нефтепродукта, кот. может быть адсорбирована грунтом (кг)
                                     this.avgdeep *                                                            // средняя глубина грутовы вод
                                     this.square *                                                             // площадь пролива
                                     this.waterproperties.density *                                            // плотность воды
                                     this.spreadpoint.groundtype.porosity * (0.01f) *                          // пористость грунта  * 0.01 (smw 2017.06.18)
                                     this.spreadpoint.groundtype.watercapacity *                               // капилярная влагоемкость грунта                                                     // максиальная маса нефтепродукта, кот. может быть адсорбирована грунтом (кг)
                                     (float)Math.Pow(this.spreadpoint.petrochemicaltype.dynamicviscosity, 2) * // динамическая вязкость
                                     this.waterproperties.tension /                                            // коэфициент поверхностного натяжения воды
                                     (
                this.spreadpoint.petrochemicaltype.tension *                                                   // коэфициент поверхностного натяжения нефтепродукта
                (float)Math.Pow(this.waterproperties.viscocity, 2)                                             //  вязкость воды
                                     );



            this.adsorbedmass = (limitadsorbedmass >= this.totalmass ? this.totalmass : limitadsorbedmass);             // адсорбированная масса нефтепродукта в грунте т - М1

            this.restmass = (this.adsorbedmass >= this.totalmass ? 0 : this.totalmass - this.adsorbedmass);             // масса нефтепродукта достигшая грунтовых вод



            this.depth = (this.restmass > 0 ? this.avgdeep : (float)Math.Round(this.avgdeep * (this.totalmass / this.limitadsorbedmass), 3)); // глубина проникновения нефтепродукта в грунт

            if (this.depth > 0)                                                                                                               // если глубина проникновения > 0
            {
                this.concentrationinsoil =                                                                                                    // средняя концентрация нефтепродуктов в грунте

                                           this.adsorbedmass /                                                                                // адсорбированная масса нефтепродукта в грунте
                                           (
                    this.square *                                                                                                             // площадь  пятна
                    this.depth *                                                                                                              // глубина проникновения нефтепродукта в грунт
                    this.spreadpoint.groundtype.density                                                                                       // средняя плотность грунта
                                           );
            }
            else
            {
                this.concentrationinsoil = 0.0f;
            }



            {                                                        //   вертикальная скорость проникновения нефтепродукта в грунт (м/с)
                float ka =                                           // формула аверьянова
                           this.spreadpoint.groundtype.waterfilter * // коэф. фильтрации воды
                           (
                    this.spreadpoint.groundtype.soilmoisture -       // влажность грунта
                    this.spreadpoint.groundtype.watercapacity        // капилярная влагоемкость грунта
                           ) /
                           (
                    this.spreadpoint.groundtype.porosity -                                        //  пористость грунта
                    this.spreadpoint.groundtype.watercapacity                                     // капилярная влагоемкость грунта
                           );

                float r =                                                                          // коэффициент задержки
                          (
                    this.spreadpoint.petrochemicaltype.dynamicviscosity *                          // вязкость нефтепродукта
                    this.waterproperties.density                                                   // плотность воды
                          ) /
                          (
                    this.waterproperties.viscocity *                                               // вязкость воды
                    this.spreadpoint.petrochemicaltype.density                                     // плотность нефтепродукта
                          );

                this.speedvertical = this.petrochemicalheight *                                    //  А.Авхимович: высота слоя разлитого нефтепродукта (м)             // вы
                                     (ka / r);                                                     // вертикальная скорость проникновения нефтепродукта в грунт (м/с)
            }

            this.timeconcentrationinsoil =                                                         // время достижения усреднееной концентации  в грунте
                                           this.depth /                                            // глубина проникновения нефтепродукта в грунт
                                           this.speedvertical;                                     // вертикальная скорость проникновения нефтепродукта в грунт (м/с)


            if (this.restmass > 0)
            {
                this.timewatercomletion =                                                           // время продвижения нефтепродукта до грунтовых вод
                                          this.avgdeep /                                            // средняя глубина грунтовых вод по опорным точкам (м)
                                          this.speedvertical;                                       // вертикальная скорость проникновения нефтепродукта в грунт (м/с)

                this.dtimemaxwaterconc =                                                            // время (с) достижения  максимальной концентрации  нефтепродуктом грунтовых вод  после достиженич границы грунтовых вод
                                         this.petrochemicalheight /                                 // высота слоя разлитого нефтепродукта (м)
                                         (
                    this.speedvertical *                                                            // вертикальная скорость проникновения нефтепродукта в грунт (м/с)
                    this.spreadpoint.groundtype.porosity                                            // пористость грунта
                                         );

                this.timemaxwaterconc = this.timewatercomletion + this.dtimemaxwaterconc;                // время (с) достижения  максимальной концентрации на уровне грунтовых вод
            }
            else
            {
                this.timewatercomletion = Const.TIME_INFINITY;                                         // никогда
                this.dtimemaxwaterconc  = Const.TIME_INFINITY;                                         // никогда
                this.timemaxwaterconc   = Const.TIME_INFINITY;                                         // никогда
            }


            {
                if (restmass > 0)                                    // если не все адсорбировалось в грунте
                {
                    this.ozcorrection =                              // OZ-поправка
                                        this.petrochemicalheight *   // высота слоя разлитого нефтепродукта (м)
                                        this.restmass /              // масса нефтепродукта достигшая грунтовых вод (кг)
                                        this.totalmass;              // масса пролива (кг)

                    this.maxconcentrationwater = (float)             // максимальной концентрация на уровне грунтовых вод кг/м3
                                                 (
                        this.restmass /                              // масса нефтепродукта достигшая грунтовых вод (кг)
                        (Math.PI * this.radius * this.radius) * 1.0f // объем воды
                        /
                        (this.ozcorrection * Math.Sqrt(2 * Math.PI)) // поправка 0Z
                                                 );
                }
                else // если все адсорбировалось в грунте
                {
                    this.ozcorrection          = 0.0f;
                    this.maxconcentrationwater = 0.0f;
                }
            }
        }