Ejemplo n.º 1
0
        private void ProfileMapDefinition(IMapDefinition mapDef)
        {
            //TODO: This was a line-by-line port from 2.x to match the 3.x APIs
            //we should find time to clean this up and ensure the profiling numbers are
            //truly reflective of actual performance metrics
            var mdef = (IMapDefinition)mapDef.Clone();

            if (backgroundWorker.CancellationPending)
            {
                return;
            }

            string resourceId = mdef == m_item ? m_resourceId : mdef.ResourceID;

            backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LogMessageMapDefinition, resourceId)));

            using (new Timer(Strings.Prof_LogMessageRuntimeMap, backgroundWorker))
            {
                foreach (var ml in mdef.MapLayer)
                {
                    try
                    {
                        if (backgroundWorker.CancellationPending)
                        {
                            return;
                        }

                        ILayerDefinition ldef = (ILayerDefinition)m_connection.ResourceService.GetResource(ml.ResourceId);
                        ProfileLayerDefinition(ldef);
                    }
                    catch (Exception ex)
                    {
                        //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                        backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, ml.ResourceId, ex.ToString(), Environment.NewLine)));
                    }
                }

                if (mdef.BaseMap != null)
                {
                    foreach (var g in mdef.BaseMap.BaseMapLayerGroups)
                    {
                        if (g.BaseMapLayer != null)
                        {
                            foreach (var ml in g.BaseMapLayer)
                            {
                                try
                                {
                                    if (backgroundWorker.CancellationPending)
                                    {
                                        return;
                                    }

                                    ILayerDefinition ldef = (ILayerDefinition)m_connection.ResourceService.GetResource(ml.ResourceId);
                                    ProfileLayerDefinition(ldef);
                                }
                                catch (Exception ex)
                                {
                                    //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                                    backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, ml.ResourceId, ex.ToString(), Environment.NewLine)));
                                }
                            }
                        }
                    }
                }
            }

            if (backgroundWorker.CancellationPending)
            {
                return;
            }

            var mpsvc = (IMappingService)m_connection.GetService((int)ServiceType.Mapping);

            try
            {
                if (backgroundWorker.CancellationPending)
                {
                    return;
                }

                //m_connection.ResetFeatureSourceSchemaCache();
                using (new Timer(Strings.Prof_LogMessageRuntimeMapTotal, backgroundWorker))
                    mpsvc.CreateMap(mdef);
            }
            catch (Exception ex)
            {
                //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_RuntimeMapProfilingError, resourceId, ex.ToString(), Environment.NewLine)));
            }

            try
            {
                if (backgroundWorker.CancellationPending)
                {
                    return;
                }

                //We cannot flub this anymore. AIMS 2012 demands the Map Definition id specified checks out
                mdef.ResourceID = "Session:" + m_connection.SessionID + "//ProfilingTest.MapDefinition"; //NOXLATE
                m_connection.ResourceService.SaveResource(mdef);

                var rtmap = mpsvc.CreateMap(mdef);

                if (m_connection.ResourceService.ResourceExists(rtmap.ResourceID))
                {
                    m_connection.ResourceService.DeleteResource(rtmap.ResourceID);
                }

                rtmap.Save();

                using (new Timer(Strings.Prof_LogMessageRenderingMap, backgroundWorker))
                {
                    //TODO: Use extents rather than scale
                    //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, mdef.Extents, 1024, 800, 96))
                    using (System.IO.Stream s = mpsvc.RenderRuntimeMap(rtmap, ((mdef.Extents.MaxX - mdef.Extents.MinX) / 2) + mdef.Extents.MinX, ((mdef.Extents.MaxY - mdef.Extents.MinY) / 2) + mdef.Extents.MinY, 50000, 1024, 800, 96))
                    {
                        //Just dispose it after being read
                        backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingImageSize, s.Length)));
                    }
                }
            }
            catch (Exception ex)
            {
                //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingError, resourceId, ex.ToString(), Environment.NewLine)));
            }
        }
Ejemplo n.º 2
0
        private void ProfileMapDefinition(IMapDefinition mapDef)
        {
            //TODO: This was a line-by-line port from 2.x to match the 3.x APIs
            //we should find time to clean this up and ensure the profiling numbers are
            //truly reflective of actual performance metrics
            var mdef = (IMapDefinition)mapDef.Clone();
            if (backgroundWorker.CancellationPending)
                return;

            string resourceId = mdef == m_item ? m_resourceId : mdef.ResourceID;

            backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LogMessageMapDefinition, resourceId)));

            using (new Timer(Strings.Prof_LogMessageRuntimeMap, backgroundWorker))
            {
                foreach (var ml in mdef.MapLayer)
                {
                    try
                    {
                        if (backgroundWorker.CancellationPending)
                            return;

                        ILayerDefinition ldef = (ILayerDefinition)mdef.CurrentConnection.ResourceService.GetResource(ml.ResourceId);
                        ProfileLayerDefinition(ldef);
                    }
                    catch (Exception ex)
                    {
                        //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                        backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, ml.ResourceId, ex.ToString(), Environment.NewLine)));
                    }
                }

                if (mdef.BaseMap != null)
                {
                    foreach (var g in mdef.BaseMap.BaseMapLayerGroup)
                    {
                        if (g.BaseMapLayer != null)
                        {
                            foreach (var ml in g.BaseMapLayer)
                            {
                                try
                                {
                                    if (backgroundWorker.CancellationPending)
                                        return;

                                    ILayerDefinition ldef = (ILayerDefinition)mdef.CurrentConnection.ResourceService.GetResource(ml.ResourceId);
                                    ProfileLayerDefinition(ldef);
                                }
                                catch (Exception ex)
                                {
                                    //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                                    backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, ml.ResourceId, ex.ToString(), Environment.NewLine)));
                                }
                            }
                        }
                    }
                }
            }

            if (backgroundWorker.CancellationPending)
                return;

            var mpsvc = (IMappingService)m_connection.GetService((int)ServiceType.Mapping);

            try
            {
                if (backgroundWorker.CancellationPending)
                    return;

                //m_connection.ResetFeatureSourceSchemaCache();
                using (new Timer(Strings.Prof_LogMessageRuntimeMapTotal, backgroundWorker))
                    mpsvc.CreateMap(mdef);
            }
            catch (Exception ex)
            {
                //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_RuntimeMapProfilingError, resourceId, ex.ToString(), Environment.NewLine)));
            }

            try
            {
                if (backgroundWorker.CancellationPending)
                    return;

                //We cannot flub this anymore. AIMS 2012 demands the Map Definition id specified checks out
                mdef.ResourceID = "Session:" + m_connection.SessionID + "//ProfilingTest.MapDefinition"; //NOXLATE
                m_connection.ResourceService.SaveResource(mdef);

                var rtmap = mpsvc.CreateMap(mdef);

                if (m_connection.ResourceService.ResourceExists(rtmap.ResourceID))
                    m_connection.ResourceService.DeleteResource(rtmap.ResourceID);

                rtmap.Save();

                using (new Timer(Strings.Prof_LogMessageRenderingMap, backgroundWorker))
                {
                    //TODO: Use extents rather than scale
                    //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, mdef.Extents, 1024, 800, 96))
                    using (System.IO.Stream s = mpsvc.RenderRuntimeMap(rtmap, ((mdef.Extents.MaxX - mdef.Extents.MinX) / 2) + mdef.Extents.MinX, ((mdef.Extents.MaxY - mdef.Extents.MinY) / 2) + mdef.Extents.MinY, 50000, 1024, 800, 96))
                    {
                        //Just dispose it after being read
                        backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingImageSize, s.Length)));
                    }
                }
            }
            catch (Exception ex)
            {
                //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingError, resourceId, ex.ToString(), Environment.NewLine)));
            }
        }