Beispiel #1
0
        public ActionResult ChoiceForecastResult()
        {
            ViewBag.EGHLayout = "CEQ";
            ActionResult rc = View("Index");

            try
            {
                CEQContext     ceq     = new CEQContext(this);
                CEQViewContext context = CEQViewContext.HandlerChoiceForecast(ceq, this.HttpContext.Request.Params);
                if (context != null && context.RegimChoice == CEQViewContext.REGIM_CHOICE.CHOICE)
                {
                    EGH01DB.RGEContext.ECOForecast forecast = new EGH01DB.RGEContext.ECOForecast();
                    string comment = string.Empty;
                    if (EGH01DB.RGEContext.ECOForecast.GetById(ceq, (int)context.idforecat, out forecast, out comment))
                    {
                        context.ecoevalution = new CEQContext.ECOEvalution(forecast);
                        rc = View("Index", ceq);
                    }
                }
                else
                {
                    rc = View(ceq);
                }
            }
            catch (EGHDBException e)
            {
                rc = View("Index");
            }
            catch (Exception e)
            {
                rc = View("Index");
            }
            return(rc);
        }
Beispiel #2
0
        //public static CEQViewContext HandlerEvalutionForecast(CEQContext db, NameValueCollection parms)
        //{
        //     CEQViewContext rc = db.GetViewContext(VIEWNAME) as CEQViewContext;

        //     if ((rc = db.GetViewContext(VIEWNAME) as CEQViewContext) != null)
        //     {
        //        rc.RegimEvalution =  rc.RegimEvalution == REGIM_EVALUTION.CANCEL? REGIM_EVALUTION.INIT: rc.RegimEvalution;
        //        string menuitem = parms["menuitem"];
        //        if (menuitem != null)
        //        {
        //            if       (menuitem.Equals("CEQReport.Save"))    rc.RegimEvalution = REGIM_EVALUTION.SAVE;
        //            else  if (menuitem.Equals("CEQReport.Cancel"))  rc.RegimEvalution = REGIM_EVALUTION.CANCEL;
        //        }
        //     }
        //     return rc;
        //}

        public static CEQViewContext  HandlerChoiceForecast(CEQContext db, NameValueCollection parms)
        {
            CEQViewContext rc = null;

            if ((rc = db.GetViewContext(VIEWNAME) as CEQViewContext) != null)
            {
                rc.RegimChoice = REGIM_CHOICE.INIT;
                string menuitem = parms["menuitem"];
                if (menuitem != null)
                {
                    if (menuitem.Equals("ChoiceForecastResult.Choice"))
                    {
                        string formid = parms["ChoiceForecastResult.id"];
                        int    id     = -1;
                        if (!string.IsNullOrEmpty(formid) && int.TryParse(formid, out id))
                        {
                            rc.idforecat = id;
                            EGH01DB.RGEContext.ECOForecast ef = rc.ecoforecat = null;
                            string comment = string.Empty;
                            if (EGH01DB.RGEContext.ECOForecast.GetById(db, id, out ef, out comment))
                            {
                                rc.ecoforecat  = ef;
                                rc.RegimChoice = REGIM_CHOICE.CHOICE;
                            }
                            else
                            {
                                rc.RegimChoice = REGIM_CHOICE.ERROR;
                            }
                        }
                        else
                        {
                            rc.RegimChoice = REGIM_CHOICE.ERROR;
                        }
                    }
                    else if (menuitem.Equals("ChoiceForecastResult.Cancel"))
                    {
                        rc.RegimChoice = REGIM_CHOICE.CANCEL;
                    }
                    else if (menuitem.Equals("ConfirmChoiceForecastResult.Confirm"))
                    {
                        rc.RegimChoice = REGIM_CHOICE.REPORT;
                    }
                    else if (menuitem.Equals("ConfirmChoiceForecastResult.Cancel"))
                    {
                        rc.RegimChoice = REGIM_CHOICE.INIT;
                    }
                    else if (menuitem.Equals("CEQReport.Save"))
                    {
                        rc.RegimChoice = REGIM_CHOICE.SAVE;
                    }
                    else if (menuitem.Equals("CEQReport.Cancel"))
                    {
                        rc.RegimChoice = REGIM_CHOICE.CANCEL;
                    }
                }
            }

            return(rc);
        }
        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);
        }