Ejemplo n.º 1
0
        public static bool Handler(RGEContext context, NameValueCollection parms)
        {
            bool           rc          = false;
            GroundTypeView viewcontext = null;
            string         menuitem    = parms["menuitem"] ?? "Empty";

            if ((viewcontext = context.GetViewContext(VIEWNAME) as GroundTypeView) != null)
            {
                viewcontext.Regim = REGIM.INIT;
                string namec = parms["name"];
                if (String.IsNullOrEmpty(namec))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    viewcontext.name = namec;
                }
                string Diffusion = parms["diffusion"];
                if (String.IsNullOrEmpty(Diffusion))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float d = 0.0f;
                    if (Helper.FloatTryParse(Diffusion, out d))
                    {
                        viewcontext.diffusion = d;
                    }
                }
                string Porosity = parms["porosity"];
                if (String.IsNullOrEmpty(Porosity))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float p = 0.0f;
                    if (Helper.FloatTryParse(Porosity, out p))
                    {
                        viewcontext.porosity = p;
                    }
                }
                string Soilmoisture = parms["soilmoisture"];
                if (String.IsNullOrEmpty(Soilmoisture))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float s = 0.0f;
                    if (Helper.FloatTryParse(Soilmoisture, out s))
                    {
                        viewcontext.soilmoisture = s;
                    }
                }
                string Watercapacity = parms["watercapacity"];
                if (String.IsNullOrEmpty(Watercapacity))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float w = 0.0f;
                    if (Helper.FloatTryParse(Watercapacity, out w))
                    {
                        viewcontext.watercapacity = w;
                    }
                }
                string Holdmigration = parms["holdmigration"];
                if (String.IsNullOrEmpty(Holdmigration))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float h = 0.0f;
                    if (Helper.FloatTryParse(Holdmigration, out h))
                    {
                        viewcontext.holdmigration = h;
                    }
                }
                string Waterfilter = parms["waterfilter"];
                if (String.IsNullOrEmpty(Waterfilter))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float wa = 0.0f;
                    if (Helper.FloatTryParse(Waterfilter, out wa))
                    {
                        viewcontext.waterfilter = wa;
                    }
                }
                string Averyanovfactor = parms["аveryanovfactor"];
                if (String.IsNullOrEmpty(Averyanovfactor))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float a = 0.0f;
                    if (Helper.FloatTryParse(Averyanovfactor, out a))
                    {
                        viewcontext.аveryanovfactor = a;
                    }
                }
                string Density = parms["density"];
                if (String.IsNullOrEmpty(Density))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float de = 0.0f;
                    if (Helper.FloatTryParse(Density, out de))
                    {
                        viewcontext.density = de;
                    }
                }

                string Distribution = parms["distribution"];
                if (String.IsNullOrEmpty(Distribution))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float di = 0.0f;
                    if (Helper.FloatTryParse(Distribution, out di))
                    {
                        viewcontext.distribution = di;
                    }
                }
                string Sorption = parms["sorption"];
                if (String.IsNullOrEmpty(Sorption))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float so = 0.0f;
                    if (Helper.FloatTryParse(Sorption, out so))
                    {
                        viewcontext.sorption = so;
                    }
                }

                string Permeability = parms["permeability"];
                if (String.IsNullOrEmpty(Permeability))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    float pe = 0.0f;
                    if (Helper.FloatTryParse(Permeability, out pe))
                    {
                        viewcontext.permeability = pe;
                    }
                }
            }
            return(rc);
        }
Ejemplo n.º 2
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);
        }