private RDESiteViewModel CreateSiteViewModel(RDESite site, bool addChangedHandler = true) { var supportService = new SupportService(User); var vm = new RDESiteViewModel(site) { Locked = !User.HasPermission(PermissionCategory.SPARC_SITE, PERMISSION_MASK.UPDATE) || _startLockMode }; if (site.SiteID >= 0) { vm.Traits = supportService.GetTraits(TraitCategoryType.Site.ToString(), site.SiteID); } if (addChangedHandler) { vm.DataChanged += SiteViewModelDataChanged; } return vm; }
public void UpdateSiteRDE(RDESite site) { if (!site.PosAreaType.HasValue) { if (site.Latitude.GetValueOrDefault(0) != 0 || site.Longitude.GetValueOrDefault(0) != 0) { site.PosAreaType = (int)AreaType.Point; } } StoredProcUpdate("spSiteUpdateRDE", _P("intSiteID", site.SiteID), _P("vchrSiteName", site.SiteName), _P("intPoliticalRegionID", site.PoliticalRegionID), _P("tintLocalType", site.LocalType), _P("vchrLocal", site.Locality), _P("tintPosCoordinates", site.PosCoordinates), _P("tintPosAreaType", site.PosAreaType), _P("fltPosX1", site.Longitude), _P("fltPosY1", site.Latitude), _P("tintPosXYDisplayFormat", site.PosCoordinates), _P("vchrPosSource", site.LLSource), _P("vchrPosError", site.LLError), _P("tintElevType", site.ElevType), _P("fltElevUpper", site.ElevUpper), _P("fltElevLower", site.ElevLower), _P("vchrElevUnits", site.ElevUnits), _P("vchrElevSource", site.ElevSource), _P("vchrElevError", site.ElevError) ); }
private RDESite CreateNewSite(out List<Trait> traits) { traits = null; RDESiteViewModel copyFrom = null; switch (_autoFillMode) { case AutoFillMode.CopyCurrentData: copyFrom = grpSites.SelectedItem as RDESiteViewModel; break; case AutoFillMode.TemplateData: copyFrom = _siteTemplate; break; } RDESite ret; if (copyFrom != null) { ret = ReflectionUtils.Clone(copyFrom.Model); ret.SiteID = -1; ret.SiteName = null; traits = new List<Trait>(); var control = grpSites.Content as SiteRDEControl; if (control != null) { foreach (Trait t in control.GetTraits()) { var newTrait = ReflectionUtils.Clone(t); newTrait.IntraCatID = -1; newTrait.TraitID = -1; traits.Add(newTrait); } } } else { ret = new RDESite(); } ret.PosAreaType = (int)AreaType.Point; // RDE only shows one set of coords, so its always going to be a point ret.LocalType = 0; // Locality ret.Locked = false; return ret; }