public Report(CEQContext db, RGEContext.Report report) { CadastreType _cadastretype = CadastreType.defaulttype; RiskObject _riskobject = RiskObject.defaulttype; this.report = report; this.pdk_coef = _cadastretype.pdk_coef; this.water_pdk_coef = _cadastretype.water_pdk_coef; if (report.riskobject_id > 0) { if (RiskObject.GetById(db, report.riskobject_id, ref _riskobject)) { if (_riskobject.cadastretype.pdk_coef > 0) { this.pdk_coef = _riskobject.cadastretype.pdk_coef; } if (_riskobject.cadastretype.water_pdk_coef > 0) { this.water_pdk_coef = _riskobject.cadastretype.water_pdk_coef; } } } this.excessgroundconcentration = this.report.C3 / (this.pdk_coef); this.exesswaterconcentration = this.report.C4 / this.water_pdk_coef; }
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 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); }