Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);

                MgResourceIdentifier mdfId = new MgResourceIdentifier(txtMapDefinition.Text);
                var sw = new Stopwatch();
                sw.Start();
                MgdMap map = new MgdMap(mdfId);
                sw.Stop();
                Trace.TraceInformation("Runtime map created in {0}ms", sw.ElapsedMilliseconds);

                map.SetViewScale(Convert.ToDouble(txtScale.Text));
                sw.Reset();
                sw.Start();
                MgByteReader response = renSvc.RenderTile(map, txtBaseGroup.Text, Convert.ToInt32(txtCol.Text), Convert.ToInt32(txtRow.Text));
                sw.Stop();
                Trace.TraceInformation("RenderTile executed in {0}ms", sw.ElapsedMilliseconds);
                new ImageResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }
Ejemplo n.º 2
0
        public void TestEnd()
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdResourceService service = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier mapres1 = new MgResourceIdentifier("Library://UnitTests/Data/Shuttle.DrawingSource");
                service.DeleteResource(mapres1);

                if (service.ResourceExists(resourceIdentifier))
                    service.DeleteResource(resourceIdentifier);

                if (service.ResourceExists(resourceIdentifier2))
                    service.DeleteResource(resourceIdentifier2);

                if (service.ResourceExists(resourceIdentifier3))
                    service.DeleteResource(resourceIdentifier3);

                if (service.ResourceExists(resourceIdentifier4))
                    service.DeleteResource(resourceIdentifier4);
            }
            catch (MgException ex)
            {
                ex.Dispose();
            }
        }
Ejemplo n.º 3
0
        public void TestCase_SetResourceData()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                Assert.Throws <MgNullArgumentException>(() => service.SetResourceData(null, "", "", null));

                var dataSource = new MgByteSource(dataFileName);
                var dataReader = dataSource.GetReader();

                Assert.Throws <MgNullArgumentException>(() => service.SetResourceData(resourceIdentifier, "", "File", dataReader));

                dataSource = new MgByteSource(dataFileName);
                dataReader = dataSource.GetReader();
                service.SetResourceData(resourceIdentifier, resourceDataName, "File", dataReader);

                var    reader = service.EnumerateResourceData(resourceIdentifier);
                string xml    = reader.ToString();

                Assert.True(xml.Contains("<Name>" + resourceDataName + "</Name>"));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            MgdPlatform.Initialize("Platform.ini");

            string currentDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            //Test mapguide-api-base
            MgCoordinateSystemFactory csFact = new MgCoordinateSystemFactory();

            Console.WriteLine("Testing coordinate system categories");
            MgStringCollection csCategories = csFact.EnumerateCategories();

            for (int i = 0; i < csCategories.GetCount(); i++)
            {
                Console.WriteLine(csCategories.GetItem(i));
            }

            //Test mg-desktop
            MgdServiceFactory serviceFact = new MgdServiceFactory();

            Console.Write("Can we create a MgdFeatureService? ");
            MgdFeatureService featSvc = (MgdFeatureService)serviceFact.CreateService(MgServiceType.FeatureService);

            Console.WriteLine("yes");
            Console.Write("Can we create a MgdResourceService? ");
            MgdResourceService resSvc = (MgdResourceService)serviceFact.CreateService(MgServiceType.ResourceService);

            Console.WriteLine("yes");

            MgdPlatform.Terminate();
            Console.WriteLine("Things look all good :) Press any key to continue");
            Console.Read();
        }
Ejemplo n.º 5
0
        public void TestEnd()
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdResourceService   service = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier mapres1 = new MgResourceIdentifier("Library://UnitTests/Data/Shuttle.DrawingSource");
                service.DeleteResource(mapres1);

                if (service.ResourceExists(resourceIdentifier))
                {
                    service.DeleteResource(resourceIdentifier);
                }

                if (service.ResourceExists(resourceIdentifier2))
                {
                    service.DeleteResource(resourceIdentifier2);
                }

                if (service.ResourceExists(resourceIdentifier3))
                {
                    service.DeleteResource(resourceIdentifier3);
                }

                if (service.ResourceExists(resourceIdentifier4))
                {
                    service.DeleteResource(resourceIdentifier4);
                }
            }
            catch (MgException ex)
            {
                ex.Dispose();
            }
        }
Ejemplo n.º 6
0
        public void TestCase_GetResourceContents()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to get the content using NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.GetResourceContents(null, null));

                //Try to get the content of a resource that doesn't exist
                MgStringCollection resourceNotExistCol = new MgStringCollection();
                resourceNotExistCol.Add(resourceNotExist.ToString());
                resourceNotExistCol.Add(resourceIdentifier.ToString());
                Assert.Throws <MgResourceNotFoundException>(() => service.GetResourceContents(resourceNotExistCol, null));

                //Get the content of the resource that was added in TestCase_SetResource
                MgStringCollection resIds = new MgStringCollection();
                resIds.Add(resourceIdentifier.ToString());
                resIds.Add(resourceIdentifier4.ToString());
                var ret = service.GetResourceContents(resIds, null);
                Assert.AreEqual(2, ret.GetCount());

                for (int i = 0; i < ret.GetCount(); i++)
                {
                    Assert.False(string.IsNullOrEmpty(ret.GetItem(i)));
                }
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);

                MgResourceIdentifier mdfId = new MgResourceIdentifier(txtMapDefinition.Text);
                var sw = new Stopwatch();
                sw.Start();
                MgdMap map = new MgdMap(mdfId);
                sw.Stop();
                Trace.TraceInformation("Runtime map created in {0}ms", sw.ElapsedMilliseconds);

                map.SetViewScale(Convert.ToDouble(txtScale.Text));
                sw.Reset();
                sw.Start();
                MgByteReader response = renSvc.RenderTile(map, txtBaseGroup.Text, Convert.ToInt32(txtCol.Text), Convert.ToInt32(txtRow.Text));
                sw.Stop();
                Trace.TraceInformation("RenderTile executed in {0}ms", sw.ElapsedMilliseconds);
                new ImageResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }
Ejemplo n.º 8
0
        public void TestCase_CopyResource()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to use NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.CopyResource(null, null, true));
                Assert.Throws <MgNullArgumentException>(() => service.CopyResource(resourceIdentifier, null, true));
                Assert.Throws <MgNullArgumentException>(() => service.CopyResource(null, resourceIdentifier2, true));

                //Try to use source & destination as the same thing
                Assert.Throws <MgInvalidArgumentException>(() => service.CopyResource(resourceIdentifier2, resourceIdentifier2, false));

                //Copy the moved resource to another location
                service.CopyResource(resourceIdentifier, resourceIdentifier2, false);

                //Try to copy a resource to one that should now exist
                Assert.Throws <MgDuplicateResourceException>(() => service.CopyResource(resourceIdentifier2, resourceIdentifier, false));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 9
0
        public void TestCase_GetResourceContent()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to get the content using NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.GetResourceContent(null));

                //Try to get the content of a resource that doesn't exist
                Assert.Throws <MgResourceNotFoundException>(() => service.GetResourceContent(resourceNotExist));

                //Get the content of the resource that was added in TestCase_SetResource
                var byteReader = service.GetResourceContent(resourceIdentifier);
                var mimeType   = byteReader.GetMimeType();
                Assert.True(mimeType.Equals(MgMimeType.Xml));

                string xml = byteReader.ToString();
                Assert.True(xml.Length > 0);
                Assert.True(xml.Contains("<FeatureSource"));
                Assert.True(xml.EndsWith("</FeatureSource>"));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 10
0
        // public void TestCase_EnumerateResources() {}

        public void TestCase_SetResource()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to use NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.SetResource(null, null, null));
                Assert.Throws <MgNullArgumentException>(() => service.SetResource(resourceIdentifier, null, null));

                //Add a new resource
                MgByteSource source = new MgByteSource(resourceContentFileName);
                MgByteReader reader = source.GetReader();
                service.SetResource(resourceIdentifier, reader, null);

                //Try to add the same resource again (should be fine and just update it)
                source = new MgByteSource(resourceContentFileName);
                reader = source.GetReader();
                service.SetResource(resourceIdentifier, reader, null);

                //Add another resource layer definition, which references to the feature source. This is for cascade MoveResource test.
                source = new MgByteSource(resourceContentFileName2);
                reader = source.GetReader();
                service.SetResource(resourceIdentifier4, reader, null);
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgFeatureQueryOptions query = new MgFeatureQueryOptions();
                string[] propNames = txtProps.Text.Split(',');
                foreach (var p in propNames)
                {
                    if (string.IsNullOrEmpty(p))
                        continue;

                    query.AddFeatureProperty(p);
                }

                foreach (Pair p in lstComputed.Items)
                {
                    query.AddComputedProperty(p.Name, p.Expr);
                }

                if (!string.IsNullOrEmpty(txtFilter.Text.Trim()))
                    query.SetFilter(txtFilter.Text.Trim());

                MgResourceIdentifier fsId = new MgResourceIdentifier(txtFeatureSource.Text);

                MgFeatureReader reader = featSvc.SelectFeatures(fsId, txtClass.Text, query);
                new ReaderResponseDialog(reader).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 12
0
        private void btnCreateFile_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                var param = new MgFileFeatureSourceParams();
                param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;
                param.FileName = txtFileName.Text;

                var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
                param.FeatureSchema = schemas.GetItem(0);

                param.ProviderName = txtProvider.Text;
                param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
                param.SpatialContextName = txtCoordinateSystemName.Text;
                param.XYTolerance = double.Parse(txtXYTolerance.Text);
                param.ZTolerance = double.Parse(txtZTolerance.Text);

                var fsId = new MgResourceIdentifier(txtResourceId.Text);

                featureSvc.CreateFeatureSource(fsId, param);
                MessageBox.Show("Success");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 13
0
        public void TestCase_RenameResourceData()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                Assert.Throws <MgNullArgumentException>(() => service.RenameResourceData(null, resourceDataName, resourceDataName2, true));
                Assert.Throws <MgResourceNotFoundException>(() => service.RenameResourceData(resourceNotExist, resourceDataName, resourceDataName2, true));
                Assert.Throws <MgResourceDataNotFoundException>(() => service.RenameResourceData(resourceIdentifier, "DoesNotExist", resourceDataName2, true));
                Assert.Throws <MgNullArgumentException>(() => service.RenameResourceData(resourceIdentifier, resourceDataName, "", true));

                service.RenameResourceData(resourceIdentifier, resourceDataName, resourceDataName2, false);
                var    reader = service.EnumerateResourceData(resourceIdentifier);
                string xml    = reader.ToString();
                Assert.True(xml.Contains("<Name>" + resourceDataName2 + "</Name>"));
                Assert.False(xml.Contains("<Name>" + resourceDataName + "</Name>"));

                service.RenameResourceData(resourceIdentifier, resourceDataName2, resourceDataName, false);
                reader = service.EnumerateResourceData(resourceIdentifier);
                xml    = reader.ToString();
                Assert.True(xml.Contains("<Name>" + resourceDataName + "</Name>"));
                Assert.False(xml.Contains("<Name>" + resourceDataName2 + "</Name>"));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            MgdPlatform.Initialize("Platform.ini");

            string currentDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            //Test mapguide-api-base
            MgCoordinateSystemFactory csFact = new MgCoordinateSystemFactory();

            Console.WriteLine("Testing coordinate system categories");
            MgStringCollection csCategories = csFact.EnumerateCategories();
            for (int i = 0; i < csCategories.GetCount(); i++)
            {
                Console.WriteLine(csCategories.GetItem(i));
            }

            //Test mg-desktop
            MgdServiceFactory serviceFact = new MgdServiceFactory();
            Console.Write("Can we create a MgdFeatureService? ");
            MgdFeatureService featSvc = (MgdFeatureService)serviceFact.CreateService(MgServiceType.FeatureService);
            Console.WriteLine("yes");
            Console.Write("Can we create a MgdResourceService? ");
            MgdResourceService resSvc = (MgdResourceService)serviceFact.CreateService(MgServiceType.ResourceService);
            Console.WriteLine("yes");

            MgdPlatform.Terminate();
            Console.WriteLine("Things look all good :) Press any key to continue");
            Console.Read();
        }
        public LocalGetResourceContents(LocalConnection conn)
        {
            this.Parent = conn;
            var fact = new MgdServiceFactory();

            _resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
        }
Ejemplo n.º 16
0
        private void btnCreateFile_Click(object sender, EventArgs e)
        {
            try
            {
                var fact       = new MgdServiceFactory();
                var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                var param      = new MgFileFeatureSourceParams();
                param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;
                param.FileName            = txtFileName.Text;

                var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
                param.FeatureSchema = schemas.GetItem(0);

                param.ProviderName = txtProvider.Text;
                param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
                param.SpatialContextName        = txtCoordinateSystemName.Text;
                param.XYTolerance = double.Parse(txtXYTolerance.Text);
                param.ZTolerance  = double.Parse(txtZTolerance.Text);

                var fsId = new MgResourceIdentifier(txtResourceId.Text);

                featureSvc.CreateFeatureSource(fsId, param);
                MessageBox.Show("Success");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 17
0
 protected override void SubInit()
 {
     _fact       = new MgdServiceFactory();
     _resSvc     = (MgdResourceService)_fact.CreateService(MgServiceType.ResourceService);
     _renderSvc  = (MgdRenderingService)_fact.CreateService(MgServiceType.RenderingService);
     _mappingSvc = (MgdMappingService)_fact.CreateService(MgServiceType.MappingService);
 }
Ejemplo n.º 18
0
 protected override void SubInit()
 {
     _fact = new MgdServiceFactory();
     _resSvc = (MgdResourceService)_fact.CreateService(MgServiceType.ResourceService);
     _renderSvc = (MgdRenderingService)_fact.CreateService(MgServiceType.RenderingService);
     _mappingSvc = (MgdMappingService)_fact.CreateService(MgServiceType.MappingService);
 }
Ejemplo n.º 19
0
        public override void Run()
        {
            var fact = new MgdServiceFactory();
            MgdFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

            MgByteReader br = featSvc.QueryCacheInfo();
            new ConnectionPoolStatusDialog(br).ShowDialog();
        }
Ejemplo n.º 20
0
        public override void Run()
        {
            var fact = new MgdServiceFactory();
            MgdFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

            MgByteReader br = featSvc.QueryCacheInfo();

            new ConnectionPoolStatusDialog(br).ShowDialog();
        }
Ejemplo n.º 21
0
        static void Main(string [] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

            //Must call MgPlatform.Initialize() before we can work with anything from the MapGuide API
            try
            {
                var sw = new Stopwatch();
                sw.Start();
                MgdPlatform.Initialize("Platform.ini");
                sw.Stop();
                Trace.TraceInformation("Platform initialization took {0}ms", sw.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
                return;
            }

            //MgAppWindow is our Main Window class full of drag-and-drop component goodness. Go ahead and
            //take a look at MgAppWindow.cs source, not much code there except for the 3 generic invoke components and the
            //single custom selection handler. Everything else is encapsulated by designer-friendly drag and drop components
            //Most of the work is dragging and dropping components into the designer surface, and setting lots of properties
            var frm = new MgAppWindow();

            //We can initialize without specifying a map (allowing for components that do not
            //require a loaded map to still be used). You just have to call LoadMap() on the MgMapViewer
            //instance when ready (not demonstrated here). So if you do load a package here, you will
            //have to restart the application
            MgResourceIdentifier resId = null;

            if (args.Length == 1)
            {
                resId = new MgResourceIdentifier(args[0]);
                resId.Validate();
            }

            var    fact   = new MgdServiceFactory();
            var    resSvc = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
            MgdMap map    = null;

            if (resId != null && resSvc.ResourceExists(resId))
            {
                map = new MgdMap(resId);
            }

            //This is just a pass-through call to MgMapViewer.Init()
            frm.LoadMap(new MgDesktopMapViewerProvider(map));

            Application.ApplicationExit += new EventHandler(OnAppExit);
            Application.Run(frm);
        }
Ejemplo n.º 22
0
        protected LocalConnection(NameValueCollection initParams)
            : base()
        {
            _fact = new MgdServiceFactory();
            _sessionId = Guid.NewGuid().ToString();
            _configFile = initParams[PARAM_CONFIG];

            var sw = new Stopwatch();
            sw.Start();
            MgdPlatform.Initialize(_configFile);
            sw.Stop();
            Trace.TraceInformation("MapGuide Platform initialized in {0}ms", sw.ElapsedMilliseconds);
        }
Ejemplo n.º 23
0
        static void Main(string [] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            
            //Must call MgPlatform.Initialize() before we can work with anything from the MapGuide API
            try
            {
                var sw = new Stopwatch();
                sw.Start();
                MgdPlatform.Initialize("Platform.ini");
                sw.Stop();
                Trace.TraceInformation("Platform initialization took {0}ms", sw.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
                return;
            }
            
            //MgAppWindow is our Main Window class full of drag-and-drop component goodness. Go ahead and
            //take a look at MgAppWindow.cs source, not much code there except for the 3 generic invoke components and the
            //single custom selection handler. Everything else is encapsulated by designer-friendly drag and drop components
            //Most of the work is dragging and dropping components into the designer surface, and setting lots of properties
            var frm = new MgAppWindow();
            
            //We can initialize without specifying a map (allowing for components that do not 
            //require a loaded map to still be used). You just have to call LoadMap() on the MgMapViewer
            //instance when ready (not demonstrated here). So if you do load a package here, you will
            //have to restart the application
            MgResourceIdentifier resId = null;
            if (args.Length == 1)
            {
                resId = new MgResourceIdentifier(args[0]);
                resId.Validate();
            }

            var fact = new MgdServiceFactory();
            var resSvc = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
            MgdMap map = null;

            if (resId != null && resSvc.ResourceExists(resId))
                map = new MgdMap(resId);

            //This is just a pass-through call to MgMapViewer.Init()
            frm.LoadMap(new MgDesktopMapViewerProvider(map));

            Application.ApplicationExit += new EventHandler(OnAppExit);
            Application.Run(frm);
        }
Ejemplo n.º 24
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         featureSvc.RegisterProvider(txtProviderPath.Text);
         MessageBox.Show("Success");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 25
0
 private void btnExecute_Click(object sender, EventArgs e)
 {
     try
     {
         var fact       = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         var response   = featureSvc.GetSchemaMapping(txtProvider.Text, txtConnString.Text);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 26
0
 public void TestCase_ChangeResourceOwner()
 {
     try
     {
         var fact    = new MgdServiceFactory();
         var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         Assert.Throws <MgNotImplementedException>(() => service.ChangeResourceOwner(null, "", false));
     }
     catch (MgException ex)
     {
         Assert.Fail(ex.Message);
         ex.Dispose();
     }
 }
Ejemplo n.º 27
0
 public void TestCase_InheritPermissionsFrom()
 {
     try
     {
         var fact    = new MgdServiceFactory();
         var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         Assert.Throws <MgNotImplementedException>(() => service.InheritPermissionsFrom(null));
     }
     catch (MgException ex)
     {
         Assert.Fail(ex.Message);
         ex.Dispose();
     }
 }
Ejemplo n.º 28
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         var fact       = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         featureSvc.RegisterProvider(txtProviderPath.Text);
         MessageBox.Show("Success");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 29
0
 public void TestCase_EnumerateUnmanagedData()
 {
     try
     {
         var fact    = new MgdServiceFactory();
         var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         Assert.Throws <MgNotImplementedException>(() => service.EnumerateUnmanagedData("", true, "", ""));
     }
     catch (MgException ex)
     {
         Assert.Fail(ex.Message);
         ex.Dispose();
     }
 }
Ejemplo n.º 30
0
 private void btnExecute_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         var response = featureSvc.GetSchemaMapping(txtProvider.Text, txtConnString.Text);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 31
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                bool res = featSvc.TestConnection(txtFdoProvider.Text, txtConnectionString.Text);
                MessageBox.Show("Result: " + res);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 32
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                MgByteReader response = featSvc.EnumerateDataStores(textBox1.Text, textBox2.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 33
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MgdServiceFactory fact   = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgByteReader response = resSvc.EnumerateUnmanagedData(txtPath.Text, chkRecursive.Checked, txtType.Text, txtFilter.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 34
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                bool res = featSvc.TestConnection(txtFdoProvider.Text, txtConnectionString.Text);
                MessageBox.Show("Result: " + res);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 35
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc  = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgByteReader     response = featSvc.GetFeatureProviders();

                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 36
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MgdServiceFactory fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgByteReader response = resSvc.EnumerateUnmanagedData(txtPath.Text, chkRecursive.Checked, txtType.Text, txtFilter.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 37
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                MgByteReader response = resSvc.EnumerateResourceData(resId);

                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 38
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService       featSvc  = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier   fsId     = new MgResourceIdentifier(textBox1.Text);
                MgSpatialContextReader response = featSvc.GetSpatialContexts(fsId, checkBox1.Checked);

                new SpatialContextResultDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 39
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                resSvc.DeleteResourceData(resId, textBox2.Text);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 40
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService    resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId  = new MgResourceIdentifier(textBox1.Text);
                resSvc.DeleteResourceData(resId, textBox2.Text);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 41
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier fsId = new MgResourceIdentifier(textBox1.Text);
                MgSpatialContextReader response = featSvc.GetSpatialContexts(fsId, checkBox1.Checked);

                new SpatialContextResultDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 42
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                bool exists = resSvc.ResourceExists(resId);
                MessageBox.Show("Exists: " + exists);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 43
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                bool exists = resSvc.ResourceExists(resId);
                MessageBox.Show("Exists: " + exists);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 44
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService    resSvc   = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId    = new MgResourceIdentifier(textBox1.Text);
                MgByteReader         response = resSvc.EnumerateResourceData(resId);

                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 45
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService     featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier fsId    = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                MgSqlDataReader reader = featSvc.ExecuteSqlQuery(fsId, sql);
                new ReaderResponseDialog(reader).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 46
0
        // Test Resource Management APIs

        public void TestCase_ResourceExists()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                Assert.Throws <MgNullArgumentException>(() => service.ResourceExists(null));

                Assert.True(service.ResourceExists(libraryRepositoryIdentifier));
                Assert.False(service.ResourceExists(resourceNotExist));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 47
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier fsId = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                MgSqlDataReader reader = featSvc.ExecuteSqlQuery(fsId, sql);
                new ReaderResponseDialog(reader).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 48
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         MgResourceIdentifier resId = new MgResourceIdentifier(txtResourceId.Text);
         string type = txtType.Text;
         int depth = Convert.ToInt32(txtDepth.Text);
         MgByteReader response = resSvc.EnumerateResources(resId, depth, type);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (MgException ex)
     {
         MessageBox.Show(ex.ToString(), "Error from MapGuide");
     }
 }
Ejemplo n.º 49
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService     featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier resId   = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                int res = featSvc.ExecuteSqlNonQuery(resId, sql);
                MessageBox.Show(res + " results affected");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 50
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                int res = featSvc.ExecuteSqlNonQuery(resId, sql);
                MessageBox.Show(res + " results affected");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 51
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         MgResourceService    resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         MgResourceIdentifier resId  = new MgResourceIdentifier(txtResourceId.Text);
         string       type           = txtType.Text;
         int          depth          = Convert.ToInt32(txtDepth.Text);
         MgByteReader response       = resSvc.EnumerateResources(resId, depth, type);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (MgException ex)
     {
         MessageBox.Show(ex.ToString(), "Error from MapGuide");
     }
 }
Ejemplo n.º 52
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);

                MgdMap map = new MgdMap(resId);

                double x;
                double y;
                if (double.TryParse(textBox2.Text, out x) &&
                    double.TryParse(textBox3.Text, out y))
                {
                    map.SetViewCenterXY(x, y);
                }

                int w;
                int h;
                if (int.TryParse(txtWidth.Text, out w) &&
                    int.TryParse(txtHeight.Text, out h))
                {
                    map.SetDisplaySize(w, h);
                }

                double scale;
                if (double.TryParse(textBox4.Text, out scale))
                {
                    map.SetViewScale(scale);
                }

                var sw = new Stopwatch();
                sw.Start();
                MgByteReader response = renSvc.RenderMap(map, null, textBox5.Text);
                sw.Stop();
                Trace.TraceInformation("RenderMap executed in {0}ms", sw.ElapsedMilliseconds);

                new ImageResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 53
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier source = new MgResourceIdentifier(textBox1.Text);
                MgResourceIdentifier target = new MgResourceIdentifier(textBox2.Text);

                resSvc.CopyResource(source, target, checkBox1.Checked);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 54
0
        private void btnCreateRdbms_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                var param = new MgdRdbmsFeatureSourceParams();
                param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;

                param.Service = txtService.Text;
                param.DataStore = txtDataStore.Text;
                param.Username = txtUsername.Text;
                param.Password = txtPassword.Text;

                var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
                param.FeatureSchema = schemas.GetItem(0);

                param.ProviderName = txtProvider.Text;
                param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
                param.SpatialContextName = txtCoordinateSystemName.Text;
                param.XYTolerance = double.Parse(txtXYTolerance.Text);
                param.ZTolerance = double.Parse(txtZTolerance.Text);

                string[] tokens = txtExtents.Text.Split(',').Select(x => x.Trim()).ToArray();
                MgEnvelope env = new MgEnvelope(
                    double.Parse(tokens[0]),
                    double.Parse(tokens[1]),
                    double.Parse(tokens[2]),
                    double.Parse(tokens[3]));

                param.SpatialContextExtents = env;
                

                var fsId = new MgResourceIdentifier(txtResourceId.Text);

                featureSvc.CreateFeatureSource(fsId, param);
                MessageBox.Show("Success");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 55
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgByteSource source = new MgByteSource(textBox1.Text);
                MgByteReader reader = source.GetReader();

                resSvc.ApplyResourcePackage(reader);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 56
0
        public void TestCase_ApplyResourcePackage()
        {
            try
            {
                var fact = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                Assert.Throws<MgNullArgumentException>(() => service.ApplyResourcePackage(null));

                MgByteSource source = new MgByteSource(packageName);
                source.SetMimeType(MgMimeType.Binary);
                MgByteReader reader = source.GetReader();

                service.ApplyResourcePackage(reader);
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Ejemplo n.º 57
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                string dataName = textBox2.Text;
                MgByteSource source = new MgByteSource(textBox3.Text);
                MgByteReader reader = source.GetReader();

                resSvc.SetResourceData(resId, dataName, "File", reader);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Ejemplo n.º 58
0
 public void Init(MgResourceIdentifier mapResId)
 {
     _map = new MgdMap(mapResId);
     var groups = _map.GetLayerGroups();
     if (groups != null && groups.GetCount() > 0)
     {
         for (int i = 0; i < groups.GetCount(); i++)
         {
             var grp = groups.GetItem(i);
             if (grp.LayerGroupType == MgLayerGroupType.BaseMap)
             {
                 MessageBox.Show(Strings.TiledLayerSupportWarning);
                 break;
             }
         }
     }
     var fact = new MgdServiceFactory();
     viewer.Init(new MgDesktopMapViewerProvider(_map));
     viewer.RefreshMap();
 }
Ejemplo n.º 59
0
        protected override void OnLoad(EventArgs e)
        {
            _wktRw = new MgWktReaderWriter();
            _geomFact = new MgGeometryFactory();
            new MapViewerController(mgMapViewer1,          //The MgMapViewer
                                    mgLegend1,             //The MgLegend
                                    this,                  //The IMapStatusBar
                                    mgPropertyPane1);      //The MgPropertyPane

            MgdServiceFactory factory = new MgdServiceFactory();
            MgdResourceService resSvc = (MgdResourceService)factory.CreateService(MgServiceType.ResourceService);
            MgResourceIdentifier mapDefId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
            //If this map definition doesn't exist, we ask the user to
            //load the Sheboygan package
            if (!resSvc.ResourceExists(mapDefId))
            {
                using (OpenFileDialog diag = new OpenFileDialog())
                {
                    diag.Filter = "MapGuide Packages (*.mgp)|*.mgp";
                    if (diag.ShowDialog() == DialogResult.OK)
                    {
                        MgByteSource source = new MgByteSource(diag.FileName);
                        MgByteReader reader = source.GetReader();
                        resSvc.ApplyResourcePackage(reader);
                    }
                    else
                    {
                        //No map, nothing to do here
                        Application.Exit();
                    }
                }
            }

            //Create our runtime map
            MgdMap map = new MgdMap(mapDefId);
            //Create our viewer provider
            MgMapViewerProvider provider = new MgDesktopMapViewerProvider(map);
            //Initialize our viewer with this provider
            mgMapViewer1.Init(provider);
            UpdateButtonCheckedState();
        }
Ejemplo n.º 60
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                MgByteReader response = resSvc.GetResourceData(resId, textBox2.Text);

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    MgByteSink sink = new MgByteSink(response);
                    sink.ToFile(saveFileDialog1.FileName);
                    MessageBox.Show("Saved to: " + saveFileDialog1.FileName);
                }
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }