/// <summary> /// Add a new surveyed surface to a site model via direct manipulation of the information in the grid /// </summary> /// <param name="SiteModelID"></param> /// <param name="designDescriptor"></param> /// <param name="asAtDate"></param> /// <param name="extents"></param> /// <param name="SuveyedSurfaceID"></param> public void AddDirect(Guid SiteModelID, DesignDescriptor designDescriptor, DateTime asAtDate, BoundingWorldExtent3D extents, out Guid SurveyedSurfaceID) { // This should be done under a lock on the cache key. For now, we will live with the race condition... INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID); SurveyedSurfaceID = Guid.NewGuid(); // Get the surveyed surfaces, creating it if it does not exist ISurveyedSurfaces ssList = DIContext.Obtain <ISurveyedSurfaces>(); try { ssList.FromBytes(mutableNonSpatialCache.Get(cacheKey)); } catch (KeyNotFoundException) { // Swallow exception, the list will be empty } // Add the new surveyed surface, generating a random ID from a GUID ssList.AddSurveyedSurfaceDetails(SurveyedSurfaceID, designDescriptor, asAtDate, extents); // Put the list back into the cache with the new entry mutableNonSpatialCache.Put(cacheKey, ssList.ToBytes()); }
/// <summary> /// Remove a given surveyed surface from a site model /// </summary> /// <param name="SiteModelID"></param> /// <param name="SurveySurfaceID"></param> /// <returns></returns> public bool RemoveDirect(Guid SiteModelID, Guid SurveySurfaceID) { // TODO: This should be done under a lock on the cache key. For now, we will live with the race condition try { INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID); // Get the surveyed surfaces, creating it if it does not exist ISurveyedSurfaces ssList = DIContext.Obtain <ISurveyedSurfaces>(); ssList.FromBytes(mutableNonSpatialCache.Get(cacheKey)); // Add the new surveyed surface, generating a random ID from a GUID bool result = ssList.RemoveSurveyedSurface(SurveySurfaceID); // Put the list back into the cache with the new entry if (result) { mutableNonSpatialCache.Put(cacheKey, ssList.ToBytes()); } return(result); } catch (KeyNotFoundException) { return(false); } }
public bool Process(IMutableCacheEntry <INonSpatialAffinityKey, byte[]> entry, Guid arg) { ISurveyedSurfaces ss = DIContext.Obtain <ISurveyedSurfaces>(); if (entry.Exists) { ss.FromBytes(entry.Value); } if (ss.RemoveSurveyedSurface(arg)) { entry.Value = ss.ToBytes(); return(true); } return(false); }
public bool Process(IMutableCacheEntry <INonSpatialAffinityKey, byte[]> entry, ISurveyedSurface arg) { try { ISurveyedSurfaces ss = DIContext.Obtain <ISurveyedSurfaces>(); if (entry.Exists) { ss.FromBytes(entry.Value); } ss.AddSurveyedSurfaceDetails(arg.ID, arg.Get_DesignDescriptor(), arg.AsAtDate, arg.Extents); entry.Value = ss.ToBytes(); return(true); } catch { throw; // return false; } }