public JsonResult UpdateArea(string id, string name, string description, string encodeLatLon, int mapType) { AjaxResult ar = new AjaxResult(); try { VAreaElement newAreaInfo = new VAreaElement(); newAreaInfo.RecordID = id; newAreaInfo.Name = name; newAreaInfo.Description = description; newAreaInfo.MapType = (EnumMapType)mapType; newAreaInfo.TenantCode = this.SelectedUser.TenantCode; var res = ModelFacade.Position.PositionModel.UpdateArea(newAreaInfo); ar.State = AjaxResultState.Success; ar.Data = res; return Json(ar, null, Encoding.UTF8, JsonRequestBehavior.AllowGet); } catch (Exception ex) { Logger.Error(ex); ar.State = AjaxResultState.Error; ar.Message = ex.Message; return Json(ar, JsonRequestBehavior.AllowGet); } }
public JsonResult AddArea(string name, string description, int shapeType, string acreage, string color, string length, string width, int zoom, string encodeLatLon, int mapType) { AjaxResult ar = new AjaxResult(); try { VAreaElement areaInfo = new VAreaElement(); if (this.SelectedUser == null) { areaInfo.Msg = "error"; return Json(areaInfo, null, Encoding.UTF8, JsonRequestBehavior.AllowGet); } areaInfo.Name = name; areaInfo.Description = description; areaInfo.BorderColor = color; areaInfo.ShapeType = shapeType; if (!string.IsNullOrEmpty(acreage)) areaInfo.Acreage = Convert.ToDecimal(acreage); if (!string.IsNullOrEmpty(length)) areaInfo.Length = Convert.ToDecimal(length); if (!string.IsNullOrEmpty(width)) areaInfo.Width = Convert.ToDecimal(width); areaInfo.Zoom = zoom; areaInfo.MapType = (EnumMapType)mapType; areaInfo.TenantCode = this.SelectedUser.TenantCode; areaInfo.UserCode = this.SelectedUser.UserCode; if (areaInfo.MapType == EnumMapType.MapBar) areaInfo.Points = ModelFacade.Position.PositionModel.ConvertToPoints(encodeLatLon); else areaInfo.Points = encodeLatLon; var res = ModelFacade.Position.PositionModel.AddArea(areaInfo); ar.State = AjaxResultState.Success; ar.Data = res; return Json(ar, null, Encoding.UTF8, JsonRequestBehavior.AllowGet); } catch (Exception ex) { Logger.Error(ex); ar.State = AjaxResultState.Error; ar.Message = ex.Message; return Json(ar, JsonRequestBehavior.AllowGet); } }
private VAreaElement ConvertAreaElementEntityToViewModel(EMapArea entity, EnumMapType mapType) { VAreaElement returnValue = new VAreaElement(); returnValue.RecordID = entity.RecordID.ToString(); returnValue.Name = entity.Name; returnValue.UserCode = entity.UserCode.ToString(); returnValue.TenantCode = entity.TenantCode.ToString(); returnValue.Description = entity.Description; returnValue.Type = entity.Type; returnValue.Points = entity.Points; returnValue.Acreage = entity.Acreage; returnValue.ShapeType = entity.ShapeType; returnValue.BorderColor = entity.BorderColor; returnValue.Length = entity.Length; returnValue.Width = entity.Width; returnValue.Radius = entity.Radius; returnValue.Zoom = entity.Zoom; return returnValue; }
public VAreaElement AddArea(VAreaElement model) { EMapArea entity = new EMapArea(); bool isExists = DACFacade.Gps.MapAreaDAC.Select(model.Name, model.TenantCode) == null ? false : true; if (isExists) { model.Msg = "exist"; return model; } entity.RecordID = Guid.NewGuid().ToString(); entity.Description = model.Description; entity.Name = model.Name; entity.Type = model.Type; entity.Zoom = model.Zoom; entity.CreateTime = DateTime.Now; entity.UserCode = ulong.Parse(model.UserCode); entity.TenantCode = ulong.Parse(model.TenantCode); entity.Points = model.Points; IList<LatLon> latlon = LatLon.ConvertToLatLon(model.Points); latlon = LatLonModel.GeRealLatLon(latlon, model.MapType); entity.Points = LatLon.ToParasString(latlon.ToArray()); entity.Acreage = model.Acreage; entity.BorderColor = model.BorderColor; entity.Length = model.Length; entity.Width = model.Width; entity.ShapeType = model.ShapeType; int result = DACFacade.Gps.MapAreaDAC.Insert(null, entity); VAreaElement viewResult = ConvertAreaElementEntityToViewModel(entity, model.MapType); viewResult.IsLcosuArea = model.IsLcosuArea; return viewResult; }
public VAreaElement UpdateArea(VAreaElement model) { VAreaElement returnValue = new VAreaElement(); EMapArea entity = DACFacade.Gps.MapAreaDAC.Select(model.RecordID); entity.Name = model.Name; entity.Description = model.Description; bool isExists = DACFacade.Gps.MapAreaDAC.Select(entity.Name, entity.TenantCode.ToString()) == null ? false : true; if (!isExists) { DACFacade.Gps.MapAreaDAC.Update(null, entity); returnValue = ConvertAreaElementEntityToViewModel(entity, model.MapType); } else { returnValue.Msg = "exist"; } return returnValue; }