public static bool Handler(RGEContext context, NameValueCollection parms) { bool rc = false; ChoiceRiskObjectContext viewcontext = null; string choicefind = parms["ChoiceRiskObject.choicefind"]; if (!string.IsNullOrEmpty(choicefind)) { if ((viewcontext = context.GetViewContext("_ChoiceRiskObject") as ChoiceRiskObjectContext) != null) { if (rc = choicefind.Equals("init")) { viewcontext.Regim = ChoiceRiskObjectContext.REGIM.INIT; } else if (rc = choicefind.Equals("choice")) { string template = parms["ChoiceRiskObject.template"]; if (!string.IsNullOrEmpty(template)) { viewcontext.Regim = ChoiceRiskObjectContext.REGIM.CHOICE; viewcontext.Template = template; } } else if (rc = choicefind.Equals("set")) { int id = 0; string formid = parms["ChoiceRiskObject.id"]; if (!string.IsNullOrEmpty(formid) && int.TryParse(formid, out id)) { viewcontext.Regim = ChoiceRiskObjectContext.REGIM.SET; viewcontext.RiskObjectID = id; } } } } return(rc); }
public static ChoiceRiskObjectViewContext Handler(RGEContext context, NameValueCollection parms) { ChoiceRiskObjectViewContext viewcontext = context.GetViewContext(VIEWNAME) as ChoiceRiskObjectViewContext; if (viewcontext != null) { string choicefind = parms["ChoiceRiskObject.choicefind"]; if (!string.IsNullOrEmpty(choicefind)) { switch (choicefind) { case "init": viewcontext.Regim = ChoiceRiskObjectViewContext.REGIM.INIT; break; case "choice": string template = parms["ChoiceRiskObject.template"]; if (!string.IsNullOrEmpty(template)) { viewcontext.Regim = ChoiceRiskObjectViewContext.REGIM.CHOICE; viewcontext.Template = template; } break; case "set": int id = 0; string formid = parms["ChoiceRiskObject.id"]; if (!string.IsNullOrEmpty(formid) && int.TryParse(formid, out id)) { viewcontext.Regim = ChoiceRiskObjectViewContext.REGIM.SET; viewcontext.RiskObjectID = id; if (viewcontext.riskobject == null || viewcontext.riskobject.id != id) { viewcontext.riskobject = new RiskObject(); if (!RiskObject.GetById(context, id, ref viewcontext.riskobject)) { viewcontext.Regim = REGIM.ERROR; } } } break; case "geopinit": viewcontext.Regim = ChoiceRiskObjectViewContext.REGIM.INIT; break; case "geopchoice": viewcontext.Regim = ChoiceRiskObjectViewContext.REGIM.CHOICE; viewcontext.coordinates = viewcontext.getCoordinatesParm(viewcontext, parms); break; case "geopset": viewcontext.Regim = REGIM.SET; if ((viewcontext.coordinates = viewcontext.getCoordinatesParm(viewcontext, parms)) != null) { MapePoint mp = new MapePoint(context, viewcontext.coordinates); viewcontext.riskobject = new RiskObject(mp); } break; default: break; } } } else { viewcontext = new ChoiceRiskObjectViewContext(); viewcontext.Regim = REGIM.INIT; } return(viewcontext); }
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); }
public static ForecastViewConext Handler(RGEContext context, NameValueCollection parms) { ForecastViewConext viewcontext = context.GetViewContext(VIEWNAME) as ForecastViewConext; if (viewcontext == null) { context.SaveViewContext(new RGEContext.ViewContextEntry(ForecastViewConext.VIEWNAME, viewcontext = new ForecastViewConext(context))); } if (viewcontext.Regim != REGIM.INIT) { viewcontext.Regim = REGIM.CHOICE; string date = parms["date"]; if (String.IsNullOrEmpty(date)) { viewcontext.Regim = REGIM.ERROR; } else { DateTime incident_date = DateTime.MinValue; if (DateTime.TryParse(date, out incident_date)) { viewcontext.Incident_date = (DateTime?)incident_date; } else { viewcontext.Regim = REGIM.ERROR; } } string date_message = parms["date_message"]; if (String.IsNullOrEmpty(date_message)) { viewcontext.Regim = REGIM.ERROR; } else { DateTime incident_date_message = DateTime.MinValue; if (DateTime.TryParse(date_message, out incident_date_message)) { viewcontext.Incident_date_message = (DateTime?)incident_date_message; } else { viewcontext.Regim = REGIM.ERROR; } } string parmpetrochemicaltype = parms["petrochemicaltype"]; if (String.IsNullOrEmpty(parmpetrochemicaltype)) { viewcontext.Regim = REGIM.ERROR; } else { int code = -1; if (int.TryParse(parmpetrochemicaltype, out code)) { if (viewcontext.petrochemicaltype == null || viewcontext.petrochemicaltype.code_type != code) { viewcontext.petrochemicaltype = new PetrochemicalType(); if (!PetrochemicalType.GetByCode(context, code, ref viewcontext.petrochemicaltype)) { viewcontext.Regim = REGIM.ERROR; } } } else { viewcontext.Regim = REGIM.ERROR; } } string incidenttype = parms["incidenttype"]; if (String.IsNullOrEmpty(incidenttype)) { viewcontext.Regim = REGIM.ERROR; } else { int code = -1; if (int.TryParse(incidenttype, out code)) { viewcontext.Incident_type_code = (int?)code; if (viewcontext.incidenttype == null || viewcontext.incidenttype.type_code != code) { if (!IncidentType.GetByCode(context, code, out viewcontext.incidenttype)) { viewcontext.Regim = REGIM.ERROR; } } } else { viewcontext.Regim = REGIM.ERROR; } } string volume = parms["volume"]; if (String.IsNullOrEmpty(volume)) { viewcontext.Regim = REGIM.ERROR; } else { float v = 0.0f; if (float.TryParse(volume, out v)) { viewcontext.Volume = (float?)v; } else { viewcontext.Regim = REGIM.ERROR; } } string temperature = parms["temperature"]; if (String.IsNullOrEmpty(temperature)) { viewcontext.Regim = REGIM.ERROR; } else { float t = 0.0f; if (float.TryParse(temperature, out t)) { viewcontext.Temperature = (float?)t; } else { viewcontext.Regim = REGIM.ERROR; } } if (viewcontext.Regim == REGIM.CHOICE) { viewcontext.Regim = REGIM.SET; } } else { viewcontext.Regim = REGIM.CHOICE; } return(viewcontext); }
public static bool Handler(RGEContext context, NameValueCollection parms) { bool rc = false; ForecastViewConext viewcontext = null; string menuitem = parms["menuitem"]; if ((viewcontext = context.GetViewContext(VIEWNAME) as ForecastViewConext) != null) { viewcontext.Regim = REGIM.INIT; string date = parms["date"]; if (String.IsNullOrEmpty(date)) { viewcontext.Regim = REGIM.ERROR; } else { DateTime incident_date = DateTime.MinValue; if (DateTime.TryParse(date, out incident_date)) { viewcontext.Incident_date = (DateTime?)incident_date; } else { viewcontext.Regim = REGIM.ERROR; } } string date_message = parms["date_message"]; if (String.IsNullOrEmpty(date_message)) { viewcontext.Regim = REGIM.ERROR; } else { DateTime incident_date_message = DateTime.MinValue; if (DateTime.TryParse(date_message, out incident_date_message)) { viewcontext.Incident_date_message = (DateTime?)incident_date_message; } else { viewcontext.Regim = REGIM.ERROR; } } string petrochemicaltype = parms["petrochemicaltype"]; if (String.IsNullOrEmpty(petrochemicaltype)) { viewcontext.Regim = REGIM.ERROR; } else { int code = -1; if (int.TryParse(petrochemicaltype, out code)) { viewcontext.Petrochemical_type_code = (int?)code; } else { viewcontext.Regim = REGIM.ERROR; } } string incidenttype = parms["incidenttype"]; if (String.IsNullOrEmpty(incidenttype)) { viewcontext.Regim = REGIM.ERROR; } else { int code = -1; if (int.TryParse(incidenttype, out code)) { viewcontext.Incident_type_code = (int?)code; } else { viewcontext.Regim = REGIM.ERROR; } } string volume = parms["volume"]; if (String.IsNullOrEmpty(volume)) { viewcontext.Regim = REGIM.ERROR; } { float v = 0.0f; if (float.TryParse(volume, out v)) { viewcontext.Volume = (float?)v; } else { viewcontext.Regim = REGIM.ERROR; } } string riskobjectid = parms["riskobjectid"]; if (String.IsNullOrEmpty(riskobjectid)) { viewcontext.Regim = REGIM.ERROR; } { int id = 0; if (int.TryParse(riskobjectid, out id)) { viewcontext.RiskObjectId = (int?)id; } else { viewcontext.Regim = REGIM.ERROR; } } if (menuitem != null) { rc = menuitem.Equals("Forecast.Forecast") || menuitem.Equals("Forecast.Cancel") || menuitem.Equals("Forecast.Save"); } else { viewcontext.Regim = REGIM.INIT; } } return(rc); }
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); }
public ActionResult Forecast( ) { RGEContext context = null; ActionResult view = View("Index"); ViewBag.EGHLayout = "RGE.Forecast"; try { context = new RGEContext(this); view = View(context); if (!ForecastViewConext.Handler(context, this.HttpContext.Request.Params)) { if (ChoiceRiskObjectContext.Handler(context, this.HttpContext.Request.Params)) { } } else { string menuitem = this.HttpContext.Request.Params["menuitem"]; if (menuitem.Equals("Forecast.Forecast")) { ForecastViewConext viewcontext = context.GetViewContext("Forecast") as ForecastViewConext; if (viewcontext != null) { RiskObject riskobject = new RiskObject(); if (RiskObject.GetById(context, (int)viewcontext.RiskObjectId, ref riskobject)) { PetrochemicalType petrochemicaltype = new PetrochemicalType(); if (PetrochemicalType.GetByCode(context, (int)viewcontext.Petrochemical_type_code, ref petrochemicaltype)) { SpreadPoint spreadpoint = new SpreadPoint(riskobject, petrochemicaltype, (float)viewcontext.Volume); EGH01DB.Types.IncidentType incidenttype = new EGH01DB.Types.IncidentType(); if (EGH01DB.Types.IncidentType.GetByCode(context, (int)viewcontext.Incident_type_code, out incidenttype)) { Incident incident = new Incident( (DateTime)viewcontext.Incident_date, (DateTime)viewcontext.Incident_date_message, incidenttype, spreadpoint ); viewcontext.ecoforecast = new RGEContext.ECOForecast(incident); viewcontext.Regim = ForecastViewConext.REGIM.REPORT; } else { viewcontext.Regim = ForecastViewConext.REGIM.RUNERROR; } } else { viewcontext.Regim = ForecastViewConext.REGIM.RUNERROR; } } else { viewcontext.Regim = ForecastViewConext.REGIM.RUNERROR; } } else { viewcontext.Regim = ForecastViewConext.REGIM.RUNERROR; } } else if (menuitem.Equals("Forecast.Cancel")) { view = View("Index", context); //view = Redirect("Index"); } else if (menuitem.Equals("Forecast.Save")) { ForecastViewConext viewcontext = context.GetViewContext("Forecast") as ForecastViewConext; EGH01DB.RGEContext.ECOForecast forecast = viewcontext.ecoforecast; //XmlNode node = forecast.toXmlNode("Отладка"); //XmlDocument doc = new XmlDocument(); //doc.AppendChild(doc.ImportNode(node, true)); //doc.Save(@"C:\Report.xml"); if (RGEContext.ECOForecast.Create(context, forecast, "отладка")) { } } } } catch (RGEContext.Exception e) { ViewBag.msg = e.message; } catch (Exception e) { ViewBag.msg = e.Message; } return(view); }