Пример #1
0
        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);
        }
Пример #2
0
        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);
        }