Ejemplo n.º 1
0
        public ActionResult SaveParsedObjects(int eventId, List <string> styleInfo)
        {
            long sessionID = sessionService.GetSessionID(this.HttpContext, true, true);

            string errMsg = "Please check input information";
            bool   ret    = styleInfo == null ? false :
                            styleInfo.Count == 0 ? false :
                            verifyTypeAndStyle(styleInfo, out errMsg);

            // if succed deletion, process insertion.
            if (ret && DeleteEventObjects(eventId))
            {
                Polygons poly = Polygons.GetInstance();
                // save styleUrl
                MySqlBulkInsert.InsertStyleUrl(poly, eventId);

                //  -> retrieve styleUrl to link type's styleUrl
                poly.AddStyle(styles.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());

                // set type's styleUrl
                updateType_idStyleUrl(eventId, styleInfo);

                //  -> retrieve siteType to link placeinmap's siteType
                poly.AddType(types.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());

                //  -> build site's siteType
                poly.MakeSiteRelation(eventId);

                // save placeinmap
                MySqlBulkInsert.InsertPlaceInMap(poly, eventId);

                //  -> retrieve placeinmap to link coordinate's placeinmap
                poly.AddSite(places.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());

                // set coord's placeId
                poly.SetPlaceIdInCoords();

                // save coordinates
                MySqlBulkInsert.InsertCoordinates(poly);

                //  -> retrieve coordinate to change init=true
                poly.AddCoordinates(coords.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());

                // update placeinmap with isRVSite
                MySqlBulkInsert.UpdateIsRVSite_PlaceInMap(poly);

                //poly.Initialized = true;
                //poly.eventId = eventId;

                // reset msg with no error
                errMsg = "";
            }

            // return
            return(Json(new
            {
                success = ret,
                msg = errMsg
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public void resetPolygons(Polygons poly, long eventId, long year)
        {
            if (poly.eventId != eventId || !poly.Initialized)
            {
                poly.AddSize(sizes.GetAll());
                poly.AddService(services.GetAll());
                poly.AddStyle(styles.GetQueryable().Where(x => x.idIPMEvent == eventId).OrderByDescending(x => x.ID).ToList());
                poly.AddType(types.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());
                poly.AddSite(places.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());
                poly.AddCoordinates(coords.GetQueryable().Where(x => x.idIPMEvent == eventId).ToList());
                poly.UpdateSite(status.GetQueryable().Where(x => x.Year == year).ToList());

                poly.Initialized = true;
                poly.eventId     = eventId;
            }
        }