// разлив на техногенном объекте public SpreadPoint(RiskObject riskobject, PetrochemicalType petrochemicaltype, float volume) : base(riskobject) { this.petrochemicaltype = petrochemicaltype; this.volume = volume; this.riskobject = riskobject; // разлив на техногенном объекте this.cadastretype = riskobject.cadastretype; }
public SpreadingCoefficient(XmlNode node) { this.code = Helper.GetIntAttribute(node, "code", -1); XmlNode g = node.SelectSingleNode(".//GroundType"); if (g != null) { this.ground_type = new GroundType(g); } else { this.ground_type = null; } XmlNode petr = node.SelectSingleNode(".//PetrochemicalType"); if (petr != null) { this.petrochemical_type = new PetrochemicalType(petr); } else { this.petrochemical_type = null; } this.min_volume = Helper.GetIntAttribute(node, "min_volume", -1); this.max_volume = Helper.GetIntAttribute(node, "max_volume", -1); this.min_angle = Helper.GetIntAttribute(node, "min_angle", -1); this.max_angle = Helper.GetIntAttribute(node, "max_angle", -1); this.koef = Helper.GetIntAttribute(node, "koef", -1); }
// разлив в произвольной точке public SpreadPoint(Point point, CadastreType cadastretype, PetrochemicalType petrochemicaltype, float volume) : base(point) { this.petrochemicaltype = petrochemicaltype; this.volume = volume; this.riskobject = null; // разлив не связан с техногенным объектом this.cadastretype = cadastretype; }
public SpreadingCoefficient(int code) { this.code = code; this.ground_type = new GroundType(); this.petrochemical_type = new PetrochemicalType(); this.min_volume = 0.0f; this.max_volume = 0.0f; this.min_angle = 0.0f; this.max_angle = 0.0f; this.koef = -1.0f; }
public SpreadingCoefficient(int code, GroundType groundtype, PetrochemicalType petrochemical_type, float min_volume, float max_volume, float min_angle, float max_angle, float koef) { this.code = code; this.ground_type = groundtype; this.petrochemical_type = petrochemical_type; this.min_volume = min_volume; this.max_volume = max_volume; this.min_angle = min_angle; this.max_angle = max_angle; this.koef = koef; }
public bool AddRange(Point center, EcoObjectsList list, PetrochemicalType petrochemicaltype, float concentration = 0.0f, float watertime = 0.0f) { list.ForEach(p => this.Add(new GroundPollution(p, p.coordinates.Distance(center.coordinates), Helper.GeoAngle(center, p), petrochemicaltype, concentration, watertime ))); return(true); }
public static float GetByData(EGH01DB.IDBContext dbcontext, GroundType type, PetrochemicalType petrochemical_type, float volume, float angle) { float rc = -1.0f; float koefficient = -1.0f; using (SqlCommand cmd = new SqlCommand("EGH.GetSpreadingCoefficientByData", dbcontext.connection)) { cmd.CommandType = CommandType.StoredProcedure; { SqlParameter parm = new SqlParameter("@ТипГрунта", SqlDbType.Int); parm.Value = type.type_code; cmd.Parameters.Add(parm); } { SqlParameter parm = new SqlParameter("@КодТипаНефтепродукта", SqlDbType.Int); parm.Value = petrochemical_type.code_type; cmd.Parameters.Add(parm); } { SqlParameter parm = new SqlParameter("@Объем", SqlDbType.Real); parm.Value = volume; cmd.Parameters.Add(parm); } { SqlParameter parm = new SqlParameter("@УголНаклона", SqlDbType.Real); parm.Value = angle; cmd.Parameters.Add(parm); } { SqlParameter parm = new SqlParameter("@КоэффициентРазлива", SqlDbType.Float); parm.Direction = ParameterDirection.Output; cmd.Parameters.Add(parm); } { SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int); parm.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(parm); } try { cmd.ExecuteNonQuery(); double k = (double)cmd.Parameters["@КоэффициентРазлива"].Value; koefficient = (float)k; } catch (Exception e) { rc = -1; }; } return(koefficient); }
public GroundPollution(EcoObject ecojbject, float distance, float angle, PetrochemicalType petrochemicatype, float concentration = 0.0f, float watertime = 0.0f) : base(ecojbject) { this.pointtype = POINTTYPE.ECO; this.comment = string.Format(comment_format, EcoObject.PREFIX, ecojbject.id); this.watertime = watertime; this.concentration = concentration; this.petrochemicatype = petrochemicatype; this.cadastretype = ecojbject.cadastretype; this.distance = distance; this.angle = angle; this.name = ecojbject.name; }
public GroundPollution(AnchorPoint anchorpoint, float distance, float angle, PetrochemicalType petrochemicatype, float concentration = 0.0f, float watertime = 0.0f) : base(anchorpoint) { this.pointtype = POINTTYPE.ANCHOR; this.comment = string.Format(comment_format, AnchorPoint.PREFIX, anchorpoint.id); this.watertime = watertime; this.concentration = concentration; this.petrochemicatype = petrochemicatype; this.cadastretype = anchorpoint.cadastretype; this.distance = distance; this.angle = angle; this.name = this.comment; }
public WaterPollution(EcoObject ecojbject, float distance, float angle, PetrochemicalType petrochemicatype, float speedhorizontal, float maxconcentration = 0.0f, float timemaxconcentration = 0.0f, WaterPollutionCategories waterpollutioncategories = null) : base(ecojbject) { this.pointtype = POINTTYPE.ECO; this.comment = string.Format(comment_format, EcoObject.PREFIX, ecojbject.id); this.petrochemicatype = petrochemicatype; this.cadastretype = ecojbject.cadastretype; this.distance = distance; this.angle = angle; this.name = ecojbject.name; this.speedhorizontal = speedhorizontal; this.maxconcentration = maxconcentration; this.timemaxconcentration = timemaxconcentration; this.datemaxconcentration = Const.DATE_INFINITY; this.iswaterobject = ecojbject.iswaterobject; this.waterpollutioncategories = waterpollutioncategories; }
public GroundPollutionList(Point center, EcoObjectsList list, PetrochemicalType petrochemicaltype, float concentration = 0.0f, float watertime = 0.0f) { this.AddRange(center, list, petrochemicaltype, concentration, watertime); }
public ActionResult PetrochemicalType() { CCOContext db = null; ViewBag.EGHLayout = "CCO"; ActionResult view = View("Index"); string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty"; try { db = new CCOContext(); ViewBag.msg = "Соединение с базой данных установлено"; view = View("PetrochemicalType", db); if (menuitem.Equals("PetrochemicalType.Create")) { view = View("PetrochemicalTypeCreate"); } else if (menuitem.Equals("PetrochemicalType.Delete")) { string type_code_item = this.HttpContext.Request.Params["type_code"]; if (type_code_item != null) { int c = 0; if (int.TryParse(type_code_item, out c)) { PetrochemicalType pt = new PetrochemicalType(); if (EGH01DB.Types.PetrochemicalType.GetByCode(db, c, ref pt)) { view = View("PetrochemicalTypeDelete", pt); } } } } else if (menuitem.Equals("PetrochemicalType.Update")) { string type_code_item = this.HttpContext.Request.Params["type_code"]; if (type_code_item != null) { int c = 0; if (int.TryParse(type_code_item, out c)) { EGH01DB.Types.PetrochemicalType pt = new EGH01DB.Types.PetrochemicalType(); if (EGH01DB.Types.PetrochemicalType.GetByCode(db, c, ref pt)) { view = View("PetrochemicalTypeUpdate", pt); } } } } else if (menuitem.Equals("PetrochemicalType.Excel")) { EGH01DB.Types.PetrochemicalTypeList list = new PetrochemicalTypeList(db); XmlNode node = list.toXmlNode(); XmlDocument doc = new XmlDocument(); XmlNode nnode = doc.ImportNode(node, true); doc.AppendChild(nnode); doc.Save(Server.MapPath("~/App_Data/PetrochemicalType.xml")); view = View("Index"); view = File(Server.MapPath("~/App_Data/PetrochemicalType.xml"), "text/plain", "Химический состав нефтей.xml"); } } catch (RGEContext.Exception e) { ViewBag.msg = e.message; } catch (Exception e) { ViewBag.msg = e.Message; } return(view); }
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); }
// заглушка 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); }
public ActionResult PetrochemicalTypeCreate(PetrochemicalTypeView ptv) { CCOContext db = null; ViewBag.EGHLayout = "CCO"; ActionResult view = View("Index"); string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty"; try { db = new CCOContext(); view = View("PetrochemicalType", db); if (menuitem.Equals("PetrochemicalType.Create.Create")) { int id = -1; if (EGH01DB.Types.PetrochemicalType.GetNextCode(db, out id)) { int type_code = ptv.code_type; string name = ptv.name; string strboilingtemp = this.HttpContext.Request.Params["boilingtemp"] ?? "Empty"; float boilingtemp; Helper.FloatTryParse(strboilingtemp, out boilingtemp); string strdensity = this.HttpContext.Request.Params["density"] ?? "Empty"; float density; Helper.FloatTryParse(strdensity, out density); string strviscosity = this.HttpContext.Request.Params["viscosity"] ?? "Empty"; float viscosity; Helper.FloatTryParse(strviscosity, out viscosity); string strsolubility = this.HttpContext.Request.Params["solubility"] ?? "Empty"; float solubility; Helper.FloatTryParse(strsolubility, out solubility); string strtension = this.HttpContext.Request.Params["tension"] ?? "Empty"; float tension; Helper.FloatTryParse(strtension, out tension); string strdynamicviscosity = this.HttpContext.Request.Params["dynamicviscosity"] ?? "Empty"; float dynamicviscosity; Helper.FloatTryParse(strdynamicviscosity, out dynamicviscosity); string strdiffusion = this.HttpContext.Request.Params["diffusion"] ?? "Empty"; float diffusion; Helper.FloatTryParse(strdiffusion, out diffusion); int petrochemicalcategories_type_code = ptv.list_PetrochemicalCategories; PetrochemicalCategories petrochemicalcategories = new PetrochemicalCategories((int)petrochemicalcategories_type_code); if (EGH01DB.Types.PetrochemicalCategories.GetByCode(db, petrochemicalcategories_type_code, out petrochemicalcategories)) { PetrochemicalType pt = new PetrochemicalType((int)type_code, (string)name, (float)boilingtemp, (float)density, (float)viscosity, (float)solubility, (float)tension, (float)dynamicviscosity, (float)diffusion, petrochemicalcategories); if (EGH01DB.Types.PetrochemicalType.Create(db, pt)) { view = View("PetrochemicalType", db); } } else if (menuitem.Equals("PetrochemicalType.Create.Cancel")) { view = View("PetrochemicalType", db); } } } else if (menuitem.Equals("PetrochemicalType.Create.Cancel")) { view = View("PetrochemicalType", db); } } catch (RGEContext.Exception e) { ViewBag.msg = e.message; } catch (Exception e) { ViewBag.msg = e.Message; } return(view); }
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 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 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); }