コード例 #1
0
ファイル: RiskObject.cs プロジェクト: smw60/EGH02
        public static bool Handler(CAIContext context, NameValueCollection parms)
        {
            bool       rc          = false;
            RiskObject viewcontext = null;
            string     menuitem    = parms["menuitem"];

            if ((viewcontext = context.GetViewContext("RiskObject") as RiskObject) != null)
            {
                viewcontext.Regim = REGIM.INIT;
                string foundationdat = parms["foundationdate"];
                if (String.IsNullOrEmpty(foundationdat))
                {
                    viewcontext.Regim = REGIM.ERROR;
                }
                else
                {
                    DateTime foundationdate = DateTime.MinValue;
                    if (DateTime.TryParse(foundationdat, out foundationdate))
                    {
                        viewcontext.foundationdate = (DateTime)foundationdate;
                    }
                    else
                    {
                        viewcontext.Regim = REGIM.ERROR;
                    }
                }
            }
            return(rc);
        }
コード例 #2
0
        public ActionResult RiskObjectCreate(EGH01.Models.EGHCAI.RiskObject rs)
        {
            CAIContext db = null;

            ViewBag.EGHLayout = "CAI";
            ActionResult view     = View("Index");
            string       menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";

            try
            {
                db   = new CAIContext();
                view = View("RiskObject", db);
                if (menuitem.Equals("RiskObject.Create.Create"))
                {
                    int id = -1;
                    if (EGH01DB.Objects.RiskObject.GetNextId(db, out id))
                    {
                        String  ownership             = "f";
                        int     numberofrefuel        = 1;
                        int     volume                = 1;
                        Boolean watertreatment        = rs.watertreatment;
                        Boolean watertreatmentcollect = rs.watertreatmentcollect;
                        string  base64                = rs.base64;
                        Byte[]  map;
                        if (base64 == null)
                        {
                            map = new byte[0];
                        }
                        else
                        {
                            map = ASCIIEncoding.ASCII.GetBytes(base64);
                        }


                        int    groundtank      = rs.groundtank;
                        int    undergroundtank = rs.undergroundtank;
                        string strlat_s        = this.HttpContext.Request.Params["lat_s"] ?? "Empty";
                        string strlng_s        = this.HttpContext.Request.Params["lng_s"] ?? "Empty";
                        string strwaterdeep    = this.HttpContext.Request.Params["waterdeep"] ?? "Empty";
                        string strheight       = this.HttpContext.Request.Params["height"] ?? "Empty";
                        float  lat_s           = 0.0f;
                        float  lng_s           = 0.0f;
                        float  waterdeep       = 0.0f;
                        float  height          = 0.0f;
                        if (!Helper.FloatTryParse(strlat_s, out lat_s))
                        {
                            lat_s = 0.0f;
                        }
                        if (!Helper.FloatTryParse(strlng_s, out lng_s))
                        {
                            lng_s = 0.0f;
                        }
                        if (!Helper.FloatTryParse(strwaterdeep, out waterdeep))
                        {
                            waterdeep = 0.0f;
                        }
                        if (!Helper.FloatTryParse(strheight, out height))
                        {
                            height = 0.0f;
                        }
                        Coordinates coordinates = new Coordinates(rs.latitude, rs.lat_m, lat_s, rs.lngitude, rs.lng_m, lng_s);
                        float       latitude    = EGH01DB.Primitives.Coordinates.dms_to_d(rs.latitude, rs.lat_m, rs.lat_s);
                        EGH01DB.Types.GroundType ground_type = new EGH01DB.Types.GroundType();
                        if (EGH01DB.Types.GroundType.GetByCode(db, rs.list_groundType, out ground_type))
                        {
                            Point point = new Point(coordinates, ground_type, waterdeep, height);
                            EGH01DB.Types.RiskObjectType risk_object_type = new EGH01DB.Types.RiskObjectType();
                            if (EGH01DB.Types.RiskObjectType.GetByCode(db, rs.selectlist, out risk_object_type))
                            {
                                EGH01DB.Types.CadastreType cadastre_type = new EGH01DB.Types.CadastreType();
                                if (EGH01DB.Types.CadastreType.GetByCode(db, rs.list_cadastre, out cadastre_type))
                                {
                                    EGH01DB.Types.District district = new EGH01DB.Types.District();
                                    if (EGH01DB.Types.District.GetByCode(db, rs.list_district, out district))
                                    {
                                        EGH01DB.Types.Region region = new EGH01DB.Types.Region();
                                        if (EGH01DB.Types.Region.GetByCode(db, rs.list_region, out region))
                                        {
                                            DateTime foundationdate = rs.foundationdate;
                                            if (foundationdate.Year == 0001)
                                            {
                                                foundationdate = new DateTime(1900, 01, 01);
                                            }

                                            DateTime reconstractiondate = rs.reconstractiondate;
                                            if (reconstractiondate.Year == 0001)
                                            {
                                                reconstractiondate = new DateTime(1900, 01, 01);
                                            }
                                            string name    = rs.name;
                                            String phone   = rs.phone;
                                            String fax     = rs.fax;
                                            string address = rs.adress;
                                            String email   = rs.email;



                                            String fueltype       = rs.fax;
                                            String geodescription = rs.fax;
                                            EGH01DB.Objects.RiskObject risk_object = new EGH01DB.Objects.RiskObject(id, point, risk_object_type, cadastre_type, name,
                                                                                                                    district, region, address, ownership, phone, fax, email, foundationdate, reconstractiondate, numberofrefuel, volume, watertreatment,
                                                                                                                    watertreatmentcollect, map, groundtank, undergroundtank, fueltype, 0, 0.0f, 0.0f, geodescription);

                                            if (EGH01DB.Objects.RiskObject.Create(db, risk_object))
                                            {
                                                view = View("RiskObject", db);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (menuitem.Equals("RiskObject.Create.Cancel"))
                            {
                                view = View("RiskObject", db);
                            }
                        }
                    }
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }