Exemplo n.º 1
0
        /// <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());
        }
Exemplo n.º 2
0
        /// <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);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// List the surveyed surfaces for a site model
        /// </summary>
        public ISurveyedSurfaces List(Guid SiteModelID)
        {
            INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID);

            Log.LogInformation($"Listing surveyed surfaces from {cacheKey}");

            try
            {
                ISurveyedSurfaces ss = DIContext.Obtain <ISurveyedSurfaces>();
                ss.FromBytes(mutableNonSpatialCache.Get(cacheKey));
                return(ss);
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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;
            }
        }