Ejemplo n.º 1
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "CONTENT", param, true);
                _unitTestVm.ReadParameterValue(paramSetId, "HEADER", param, true);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                MgByteReader content = CommonUtility.GetByteReaderFromPath(param["CONTENT"]);
                MgByteReader header  = CommonUtility.GetByteReaderFromPath(param["HEADER"]);

                _resourceService.SetResource(resId, content, header);

                return(TestResult.FromByteReader(null));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Ejemplo n.º 2
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                MgByteReader reader = _resourceService.EnumerateReferences(resId);

                return(TestResult.FromByteReader(reader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
 protected ActionResult ByteReaderResult(MgByteReader rdr, string downloadName = null)
 {
     if (string.IsNullOrEmpty(downloadName))
         return new FileStreamResult(new MgReadOnlyStream(rdr), rdr.MimeType);
     else
         return File(new MgReadOnlyStream(rdr), rdr.MimeType, downloadName);
 }
Ejemplo n.º 4
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "DATANAME", param);
                _unitTestVm.ReadParameterValue(paramSetId, "DATATYPE", param);
                _unitTestVm.ReadParameterValue(paramSetId, "DATA", param, true);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                string       extension  = CommonUtility.GetExtension(param["DATANAME"]);
                string       mimeType   = CommonUtility.GetMimeType(extension);
                MgByteSource dataSource = new MgByteSource(param["DATA"]);
                dataSource.SetMimeType(mimeType);
                MgByteReader dataReader = dataSource.GetReader();

                _resourceService.SetResourceData(resId, param["DATANAME"], param["DATATYPE"], dataReader);

                return(TestResult.FromByteReader(null));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Ejemplo n.º 5
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                NameValueCollection param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "SQL", param);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                MgSqlDataReader reader     = _featureService.ExecuteSqlQuery(resId, param["SQL"]);
                MgByteReader    byteReader = reader.ToXml();
                reader.Close();
                return(TestResult.FromByteReader(byteReader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Ejemplo n.º 6
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();

                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "TYPE", param);
                _unitTestVm.ReadParameterValue(paramSetId, "DEPTH", param);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }
                MgByteReader byteReader = _resourceService.EnumerateResources(resId, Convert.ToInt32(param["DEPTH"]), param["TYPE"] ?? "");

                return(TestResult.FromByteReader(byteReader, "GETRESOURCEDATA"));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Ejemplo n.º 7
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            ByteReaderTestData.Init();
            var nBytes      = ByteReaderTestData.nBytes;
            var nBlocks     = ByteReaderTestData.nBlocks;
            var testBytes   = ByteReaderTestData.testBytes;
            var infileName  = ByteReaderTestData.infileName;
            var outfileName = ByteReaderTestData.outfileName;

            byte[]       buf    = new byte[nBytes];
            MgByteReader reader = new MgByteReader(infileName, "png", false);

            Assert.AreEqual(nBlocks * nBytes, reader.GetLength());
            reader.Read(buf, nBytes);
            Assert.AreEqual(buf, testBytes);
            Assert.AreEqual((nBlocks - 1) * nBytes, reader.GetLength());
            reader.Rewind();
            Assert.AreEqual(nBlocks * nBytes, reader.GetLength());
            reader.ToFile(outfileName);
            reader.Rewind();

            byte[] buf2             = new byte[nBytes];
            System.IO.FileStream fp = System.IO.File.OpenRead(outfileName);
            for (int j = 0; j < nBlocks; j++)
            {
                fp.Read(buf2, 0, nBytes);
                reader.Read(buf, nBytes);
                Assert.AreEqual(buf, buf2);
            }
            fp.Close();
        }
Ejemplo n.º 8
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "LOGTYPE", param);
                _unitTestVm.ReadParameterValue(paramSetId, "NUMENTRIES", param);

                MgByteReader reader = null;
                if (param["NUMENTRIES"] == null)
                {
                    reader = _serverAdmin.GetLog(param["LOGTYPE"]);
                }
                else
                {
                    reader = _serverAdmin.GetLog(param["LOGTYPE"], Convert.ToInt32(param["NUMENTRIES"]));
                }

                return(TestResult.FromByteReader(reader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
        }
Ejemplo n.º 9
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                NameValueCollection param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "ACTIVEONLY", param);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                MgLongTransactionReader reader     = _featureService.GetLongTransactions(resId, (param["ACTIVEONLY"] == "1"));
                MgByteReader            byteReader = reader.ToXml();
                reader.Close();
                return(TestResult.FromByteReader(byteReader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Ejemplo n.º 10
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "USER", param);
                _unitTestVm.ReadParameterValue(paramSetId, "LOGIN", param);
                _unitTestVm.ReadParameterValue(paramSetId, "PASSWORD", param);

                var userInfo = new MgUserInformation();
                userInfo.SetMgUsernamePassword(param["LOGIN"], param["PASSWORD"]);
                userInfo.SetLocale("en");

                var site = new MgSite();
                site.Open(userInfo);

                MgByteReader reader = site.EnumerateGroups(param["USER"]);
                site.Close();

                return(TestResult.FromByteReader(reader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
        }
Ejemplo n.º 11
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                var param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "GROUP", param);
                _unitTestVm.ReadParameterValue(paramSetId, "ROLE", param);
                _unitTestVm.ReadParameterValue(paramSetId, "INCLUDEGROUPS", param);

                MgByteReader reader = null;
                if (param["ROLE"] != null)
                {
                    reader = _site.EnumerateUsers(param["GROUP"] ?? "", param["ROLE"] ?? "", (param["INCLUDEGROUPS"] == "1"));
                }
                else
                {
                    reader = _site.EnumerateUsers(param["GROUP"] ?? "");
                }
                return(TestResult.FromByteReader(reader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
        }
Ejemplo n.º 12
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.º 13
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.º 14
0
        private void InsertRedlineGeometry(MgGeometry geom)
        {
            MgPropertyCollection feature  = new MgPropertyCollection();
            MgByteReader         agf      = _agfRW.Write(geom);
            MgGeometryProperty   geomProp = new MgGeometryProperty("Geometry", agf);

            feature.Add(geomProp);

            _redlineLayer.ForceRefresh();
            var reader   = _redlineLayer.InsertFeatures(feature);
            int inserted = 0;

            while (reader.ReadNext())
            {
                inserted++;
            }
            reader.Close();
            if (inserted > 0)
            {
                _viewer.RefreshMap();
                IMapLegend legend = Shell.Instance.Legend;
                if (legend != null)
                {
                    legend.RefreshLegend();
                }
            }
        }
Ejemplo n.º 15
0
        private static void LoadResourceData(MgResourceService resSvc, string resIdStr, string dataName, string dataType, string path)
        {
            MgResourceIdentifier resId = new MgResourceIdentifier(resIdStr);
            MgByteSource         bs    = new MgByteSource(path);
            MgByteReader         br    = bs.GetReader();

            resSvc.SetResourceData(resId, dataName, dataType, br);
        }
Ejemplo n.º 16
0
        private static void LoadResource(MgResourceService resSvc, string resIdStr, string path)
        {
            MgResourceIdentifier resId = new MgResourceIdentifier(resIdStr);
            MgByteSource         bs    = new MgByteSource(path);
            MgByteReader         br    = bs.GetReader();

            resSvc.SetResource(resId, br, null);
        }
Ejemplo n.º 17
0
        private void CheckValidImage(MgByteReader img, int?imageWidth = null, int?imageHeight = null, string format = null)
        {
            try
            {
                MgByteSink sink = new MgByteSink(img);
                sink.ToFile("tile.img");
                using (Image image = Image.FromFile("tile.img"))
                {
                    Assert.IsNotNull(image);
                    if (imageWidth != null)
                    {
                        Assert.Equals(image.Width, imageWidth.Value);
                    }
                    if (imageHeight != null)
                    {
                        Assert.Equals(image.Height, imageHeight.Value);
                    }

                    if (format != null)
                    {
                        switch (format)
                        {
                        case MgImageFormats.Gif:
                            Assert.Equals(image.RawFormat, ImageFormat.Gif);
                            break;

                        case MgImageFormats.Jpeg:
                            Assert.Equals(image.RawFormat, ImageFormat.Jpeg);
                            break;

                        case MgImageFormats.Png:
                        case MgImageFormats.Png8:
                            Assert.Equals(image.RawFormat, ImageFormat.Png);
                            break;

                        case MgImageFormats.Tiff:
                            Assert.Equals(image.RawFormat, ImageFormat.Tiff);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new AssertException("Invalid image found: " + ex.Message);
            }
            finally
            {
                if (File.Exists("tile.img"))
                {
                    try
                    {
                        File.Delete("tile.img");
                    }
                    catch { }
                }
            }
        }
Ejemplo n.º 18
0
        private void btnSelectDistrict1_Click(object sender, EventArgs e)
        {
            MgMapBase         map       = _viewer.GetMap();
            MgLayerCollection layers    = map.GetLayers();
            MgLayerBase       districts = layers.GetItem("Districts");
            MgLayerBase       parcels   = layers.GetItem("Parcels");

            //Query the geometry of district 1
            MgFeatureQueryOptions districtQuery = new MgFeatureQueryOptions();

            districtQuery.SetFilter("Autogenerated_SDF_ID = 1");

            MgFeatureReader   reader       = districts.SelectFeatures(districtQuery);
            MgGeometry        districtGeom = null;
            MgAgfReaderWriter agfRw        = new MgAgfReaderWriter();

            try
            {
                reader.ReadNext();
                MgByteReader geomAgf = reader.GetGeometry(districts.GetFeatureGeometryName());
                districtGeom = agfRw.Read(geomAgf);
            }
            finally
            {
                reader.Close();
            }

            //Now use this geometry as the basis of our 2nd query

            MgFeatureQueryOptions parcelQuery = new MgFeatureQueryOptions();

            parcelQuery.SetFilter("RNAME LIKE 'SCHMITT%'");
            parcelQuery.SetSpatialFilter(parcels.GetFeatureGeometryName(), districtGeom, MgFeatureSpatialOperations.Inside);

            //Select the features
            reader = parcels.SelectFeatures(parcelQuery);

            MgSelectionBase selection = _viewer.GetSelection();

            try
            {
                selection.FromXml(""); //Clear existing selection data
                selection.AddFeatures(parcels, reader, 0);
            }
            finally
            {
                reader.Close();
            }

            //Because we manipulated the active selection outside the viewer
            //We need to call UpdateSelection() to instruct the viewer to
            //re-render the active selection. The "true" parameter instructs
            //the viewer to raise the SelectionChanged event as well, so that
            //subscribers like the Property Pane get updated as well.
            _viewer.UpdateSelection(true);
            _viewer.RefreshMap();
        }
Ejemplo n.º 19
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            MgByteSource source = new MgByteSource("../../TestData/DrawingService/SpaceShip.dwf");

            source.MimeType = MgMimeType.Dwf;
            MgByteReader reader = source.GetReader();

            Assert.AreEqual(MgMimeType.Dwf, reader.MimeType);
        }
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
        private void btnQueryDistrict1_Click(object sender, EventArgs e)
        {
            MgMapBase         map       = _viewer.GetMap();
            MgLayerCollection layers    = map.GetLayers();
            MgLayerBase       districts = layers.GetItem("Districts");
            MgLayerBase       parcels   = layers.GetItem("Parcels");

            //Query the geometry of district 1
            MgFeatureQueryOptions districtQuery = new MgFeatureQueryOptions();

            districtQuery.SetFilter("Autogenerated_SDF_ID = 1");

            MgFeatureReader   reader       = districts.SelectFeatures(districtQuery);
            MgGeometry        districtGeom = null;
            MgAgfReaderWriter agfRw        = new MgAgfReaderWriter();

            try
            {
                reader.ReadNext();
                MgByteReader geomAgf = reader.GetGeometry(districts.GetFeatureGeometryName());
                districtGeom = agfRw.Read(geomAgf);
            }
            finally
            {
                reader.Close();
            }

            //Now use this geometry as the basis of our 2nd query

            MgFeatureQueryOptions parcelQuery = new MgFeatureQueryOptions();

            parcelQuery.SetFilter("RNAME LIKE 'SCHMITT%'");
            parcelQuery.SetSpatialFilter(parcels.GetFeatureGeometryName(), districtGeom, MgFeatureSpatialOperations.Inside);

            //Select the features
            reader = parcels.SelectFeatures(parcelQuery);
            List <string> results = new List <string>();

            try
            {
                while (reader.ReadNext())
                {
                    if (!reader.IsNull("RPROPAD"))
                    {
                        results.Add(reader.GetString("RPROPAD"));
                    }
                }
            }
            finally
            {
                reader.Close();
            }

            new ParcelQueryResultWindow(results).ShowDialog();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Установка зумирования и активной выборки (запуск через командную строку - отсюда название)
        /// </summary>
        /// <param name="sel_base">выборка, которую следует отобразить</param>
        internal static void ThroughAssZoomAndSelection(MgSelectionBase sel_base)
        {
            internal_saved_selection = AcMapFeatureEntityService.AddFeaturesToSelectionSet(null, sel_base);             // преобразование в SelectionSet и обратно,

            sel_base = AcMapFeatureEntityService.GetSelection(internal_saved_selection);                                // иначе дает сбой метод GetSelectedFeatures()

            MgEnvelope extents = new MgEnvelope();

            MgReadOnlyLayerCollection layers = sel_base.GetLayers();

            foreach (MgLayerBase layer in layers)
            {
                MgFeatureReader ftr_reader     = sel_base.GetSelectedFeatures(layer, layer.FeatureClassName, false);
                string          geom_prop_name = ftr_reader.GetClassDefinition().DefaultGeometryPropertyName;

                while (ftr_reader.ReadNext())
                {
                    MgByteReader      byte_reader       = ftr_reader.GetGeometry(geom_prop_name);
                    MgAgfReaderWriter agf_reader_writer = new MgAgfReaderWriter();
                    MgGeometry        curr_geom         = agf_reader_writer.Read(byte_reader);
                    extents.ExpandToInclude(curr_geom.Envelope());
                }
            }



            // зумирование и вызов функции выбора через командную строку

            Core.no_handle_selection = true;             // чтобы изменение выборки не обрабатывалось

            string zoom_str;

            if ((extents.Width == 0) && (extents.Width == extents.Height))
            {
                zoom_str = "'_zoom _c "
                           + extents.LowerLeftCoordinate.X.ToString() + "," + extents.LowerLeftCoordinate.Y.ToString() + " ";
            }
            else
            {
                zoom_str = "'_zoom _w "
                           + (extents.LowerLeftCoordinate.X - extents.Width / 2).ToString()
                           + ","
                           + (extents.LowerLeftCoordinate.Y - extents.Height / 2).ToString()
                           + " "
                           + (extents.UpperRightCoordinate.X + extents.Width / 2).ToString()
                           + ","
                           + (extents.UpperRightCoordinate.Y + extents.Height / 2).ToString();
            }


            Core.SendStringToExecute(zoom_str + "\n"
                                     + "ThroughAssZoomAndSelectionHelperFunction\n"
                                     , true, false, false);
        }
 protected ActionResult ByteReaderResult(MgByteReader rdr, string downloadName = null)
 {
     if (string.IsNullOrEmpty(downloadName))
     {
         return(new FileStreamResult(new MgReadOnlyStream(rdr), rdr.MimeType));
     }
     else
     {
         return(File(new MgReadOnlyStream(rdr), rdr.MimeType, downloadName));
     }
 }
Ejemplo n.º 24
0
        public static void AddFeatureToCollection(MgBatchPropertyCollection propCollection, MgAgfReaderWriter agfRW, int featureId, MgGeometry featureGeom)
        {
            MgPropertyCollection bufferProps = new MgPropertyCollection();
            MgInt32Property      idProp      = new MgInt32Property("ID", featureId); //NOXLATE

            bufferProps.Add(idProp);
            MgByteReader       geomReader = agfRW.Write(featureGeom);
            MgGeometryProperty geomProp   = new MgGeometryProperty("GEOM", geomReader); //NOXLATE

            bufferProps.Add(geomProp);
            propCollection.Add(bufferProps);
        }
Ejemplo n.º 25
0
 public override TestResult Execute(int paramSetId)
 {
     try
     {
         MgByteReader reader = _site.EnumerateServers();
         return(TestResult.FromByteReader(reader));
     }
     catch (MgException ex)
     {
         return(TestResult.FromMgException(ex));
     }
 }
Ejemplo n.º 26
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                NameValueCollection param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "CLASSNAME", param);
                //_unitTestVm.ReadParameterValue(paramSetId, "PROPERTIES", param);
                //_unitTestVm.ReadParameterValue(paramSetId, "FILTER", param);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                MgFeatureAggregateOptions query = new MgFeatureAggregateOptions();
                //TODO: Set query options

                /*
                 * if (param["FILTER"] != null)
                 * {
                 *  query.SetFilter(param["FILTER"]);
                 * }
                 */
                //PROPERTIES should be stored in the database as comma separated string without spaces

                /*
                 * if (param["PROPERTIES"] != null)
                 * {
                 *  string[] props = param["PROPERTIES"].Split(',');
                 *  foreach (var p in props)
                 *  {
                 *      query.AddFeatureProperty(p);
                 *  }
                 * }*/

                MgDataReader reader     = _featureService.SelectAggregate(resId, param["CLASSNAME"], query);
                MgByteReader byteReader = reader.ToXml();
                reader.Close();
                return(TestResult.FromByteReader(byteReader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Ejemplo n.º 27
0
        private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            MgMapViewerProvider provider  = _viewer.GetProvider();
            MgSelectionBase     selection = _viewer.GetSelection();
            MgMapBase           map       = _viewer.GetMap();
            MgPoint             pt        = map.ViewCenter;
            MgCoordinate        coord     = pt.Coordinate;
            float leftMargin = e.MarginBounds.Left;
            float topMargin  = e.MarginBounds.Top;
            float yPos       = topMargin;
            float pageHeight = e.MarginBounds.Height;

            //Write title
            var titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, GraphicsUnit.Point);
            var sizeTitle = e.Graphics.MeasureString(txtTitle.Text, titleFont);

            e.Graphics.DrawString(txtTitle.Text, titleFont, Brushes.Black, new PointF(leftMargin, yPos));

            yPos += (sizeTitle.Height * 1.1f);

            var scaleFont = SystemFonts.CaptionFont;
            var scaleStr  = string.Format("{0} 1 : {1}", Strings.TextScale, _viewer.GetMap().ViewScale); //NOXLATE
            var sizeScale = e.Graphics.MeasureString(scaleStr, scaleFont);

            //Scale to fit within this page
            var imgHeight = (int)(pageHeight - (sizeTitle.Height * 1.1f) - (sizeScale.Height * 1.1f));
            var imgWidth  = e.MarginBounds.Width;

            using (var state = provider.CreateTransientState())
            {
                var tempState = new MgMapDisplayParameters(coord.X, coord.Y, map.ViewScale, imgWidth, imgHeight, (int)numDPI.Value);
                state.PushState(tempState);
                MgByteReader br = provider.RenderMap(selection, "PNG"); //NOXLATE
                using (MgReadOnlyStream stream = new MgReadOnlyStream(br))
                {
                    Image img = Image.FromStream(stream);
                    e.Graphics.DrawImage(img, leftMargin, yPos, imgWidth, imgHeight);
                    img.Dispose();
                }
            }

            yPos += imgHeight;

            //Render scale
            if (chkScale.Checked)
            {
                e.Graphics.DrawString(scaleStr, scaleFont, Brushes.Black, new PointF(leftMargin, yPos));
            }

            e.HasMorePages = false;
        }
        public ActionResult LoadSampleData(SetupInputModel input)
        {
            MgUserInformation user = new MgUserInformation(input.Username, input.Password);
            MgSiteConnection  conn = new MgSiteConnection();

            conn.Open(user);

            MgResourceService resSvc = (MgResourceService)conn.CreateService(MgServiceType.ResourceService);

            //Load the package file if specified
            if (input.Package != null && input.Package.ContentLength > 0)
            {
                var path = Path.GetTempFileName();
                try
                {
                    input.Package.SaveAs(path);
                    MgByteSource bs = new MgByteSource(path);
                    MgByteReader br = bs.GetReader();

                    resSvc.ApplyResourcePackage(br);
                }
                finally
                {
                    try
                    {
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    catch { }
                }
            }

            //Load in our sample-specific resources
            MgResourceIdentifier sample1 = new MgResourceIdentifier(AJAX_LAYOUT);
            MgResourceIdentifier sample2 = new MgResourceIdentifier(FLEX_LAYOUT);

            MgByteSource bs1 = new MgByteSource(Server.MapPath("~/App_Data/SheboyganAspMvc.WebLayout.xml"));
            MgByteReader br1 = bs1.GetReader();

            resSvc.SetResource(sample1, br1, null);

            MgByteSource bs2 = new MgByteSource(Server.MapPath("~/App_Data/SheboyganAspMvc.ApplicationDefinition.xml"));
            MgByteReader br2 = bs2.GetReader();

            resSvc.SetResource(sample2, br2, null);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 29
0
        public ImageResponseDialog(MgByteReader reader)
            : this()
        {
            byte[] b = new byte[reader.GetLength()];
            reader.Read(b, b.Length);
            using (var ms = new MemoryStream(b))
            {
                var img = Image.FromStream(ms);
                picResult.Image = img;

                this.Width = img.Width;
                this.Height = img.Height;
            }
        }
        public string GetResourceReferences(string resourceId)
        {
            MgResourceIdentifier resId = new MgResourceIdentifier(resourceId);

            if (ResourceService.ResourceExists(resId))
            {
                MgByteReader reader = ResourceService.EnumerateReferences(resId);
                return(reader.ToString());
            }
            else
            {
                return(MSG_RESOURCE_NOT_EXIST);
            }
        }
Ejemplo n.º 31
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            ByteReaderTestData.Init();
            var          testString = ByteReaderTestData.testString;
            MgByteReader reader     = new MgByteReader(testString, "text/html");

            Assert.AreEqual(testString.Length, reader.GetLength());
            string buf = reader.ToString();

            Assert.AreEqual(testString, buf);
            Assert.AreEqual(testString.Length, reader.GetLength());
            reader.Rewind();
            Assert.AreEqual(testString.Length, reader.GetLength());
        }
        public Dictionary <string, string> GetResourcesByType(string resourceType)
        {
            //TODO:
            if (!IsValidMap3DResourceType(resourceType))
            {
                throw new ApplicationException("unspported resource type by Map3D");
            }

            Dictionary <string, string> resources = new Dictionary <string, string>();

            try
            {
                string rootPath = "Library://";
                MgResourceIdentifier rootResId = new MgResourceIdentifier(rootPath);
                rootResId.Validate();

                MgByteReader reader = ResourceService.EnumerateResources(rootResId, -1, resourceType.ToString());

                //Convert to string
                String resStr = reader.ToString();

                //Load into XML document so we can parse and get the names of the maps
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resStr);

                //let's extract the resource names and list them
                XmlNodeList resIdNodeList;
                XmlElement  root = doc.DocumentElement;
                resIdNodeList = root.SelectNodes("//ResourceId");
                int resCount = resIdNodeList.Count;
                for (int i = 0; i < resCount; i++)
                {
                    XmlNode resIdNode = resIdNodeList.Item(i);
                    String  resId     = resIdNode.InnerText;
                    int     index1    = resId.LastIndexOf('/') + 1;
                    int     index2    = resId.IndexOf(resourceType) - 2;
                    int     length    = index2 - index1 + 1;
                    string  resName   = resId.Substring(index1, length);
                    resources.Add(resName, resId);
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                Debug.WriteLine(msg);
            }


            return(resources);
        }
Ejemplo n.º 33
0
        public void MemoryConstructor()
        {
            byte[] buf = new byte[nBytes];
            MgByteReader reader = new MgByteReader(testBytes, nBytes, "png");
            Assert.AreEqual(nBytes, reader.GetLength());
            reader.Read(buf, nBytes);
            Assert.AreEqual(buf, testBytes);
            Assert.AreEqual(0, reader.GetLength());
            reader.Rewind();
            Assert.AreEqual(nBytes, reader.GetLength());

            reader.ToFile(outfileName);

            System.IO.FileStream fp = System.IO.File.OpenRead(outfileName);
            fp.Read(buf, 0, nBytes);
            Assert.AreEqual(buf, testBytes);
            fp.Close();
        }
Ejemplo n.º 34
0
 public static TestResult FromByteReader(MgByteReader byteReader, string operation = "")
 {
     try
     {
         TestResult res = new TestResult();
         if (byteReader != null)
         {
             res.ContentType = byteReader.GetMimeType();
             if (res.ContentType == MgMimeType.Html ||
                 res.ContentType == MgMimeType.Json ||
                 res.ContentType == MgMimeType.Kml ||
                 res.ContentType == MgMimeType.Text ||
                 res.ContentType == MgMimeType.Xml)
             {
                 res.ResultData = byteReader.ToString();
             }
             else
             {
                 MgByteSink sink = new MgByteSink(byteReader);
                 string path = operation + Guid.NewGuid().ToString() + "Result.bin";
                 if (string.IsNullOrEmpty(operation))
                     path = Path.GetTempFileName();
                 sink.ToFile(path);
                 res.ResultData = File.ReadAllBytes(path);
                 if (string.IsNullOrEmpty(operation))
                     File.Delete(path);
                 else
                     System.Diagnostics.Debug.WriteLine(string.Format("[MgTestRunner]: Check out {0} if binary comparison results are strange", path));
                 /*
                 byte[] bytes = new byte[byteReader.GetLength()];
                 byteReader.Read(bytes, bytes.Length);
                 res.ResultData = bytes;
                 */
             }
         }
         return res;
     }
     catch (MgException ex)
     {
         return FromMgException(ex);
     }
 }
Ejemplo n.º 35
0
        public void FileConstructor()
        {
            byte[] buf = new byte[nBytes];
            MgByteReader reader = new MgByteReader(infileName, "png", false);
            Assert.AreEqual(nBlocks * nBytes, reader.GetLength());
            reader.Read(buf, nBytes);
            Assert.AreEqual(buf, testBytes);
            Assert.AreEqual((nBlocks-1) * nBytes, reader.GetLength());
            reader.Rewind();
            Assert.AreEqual(nBlocks * nBytes, reader.GetLength());
            reader.ToFile(outfileName);
            reader.Rewind();

            byte[] buf2 = new byte[nBytes];
            System.IO.FileStream fp = System.IO.File.OpenRead(outfileName);
            for (int j = 0; j < nBlocks; j++)
            {
                fp.Read(buf2, 0, nBytes);
                reader.Read(buf, nBytes);
                Assert.AreEqual(buf, buf2);
            }
            fp.Close();
        }
Ejemplo n.º 36
0
        private MgPropertyCollection CreatePropertyCollection(MgByteReader byteReader)
        {
            MgPropertyCollection propertyValues = new MgPropertyCollection();

            propertyValues.Add(new MgStringProperty("Text", GetParameter(this.args, "TEXT")));
            propertyValues.Add(new MgStringProperty("ReverseText", ReverseString(GetParameter(this.args, "TEXT"))));
            if (_hasProjectIdField)
            {
                propertyValues.Add(new MgInt32Property("ProjectId", GetProjectId()));
            }
            propertyValues.Add(new MgGeometryProperty("Geometry", byteReader));

            return propertyValues;
        }
Ejemplo n.º 37
0
 public ConnectionPoolStatusDialog(MgByteReader reader)
     : this()
 {
     txtXml.Text = FormatXml(reader.ToString());
 }
Ejemplo n.º 38
0
 public bool UpdatePredictLayerDef(string datasource, string featurename, string tooltip, string sPredict)
 {
     bool result;
     try
     {
         if (datasource != "")
         {
             this.LayerDefXml.GetElementsByTagName("ResourceId")[0].InnerText = datasource;
         }
         if (featurename != "")
         {
             this.LayerDefXml.GetElementsByTagName("FeatureName")[0].InnerText = featurename;
         }
         if (this.LayerDefXml.GetElementsByTagName("ToolTip").Count > 0 && tooltip != "")
         {
             this.LayerDefXml.GetElementsByTagName("ToolTip")[0].InnerText = tooltip;
         }
         string[] Arr = sPredict.Split(",".ToCharArray());
         XmlNodeList pnlst = this.LayerDefXml.GetElementsByTagName("LegendLabel");
         for (int i = 0; i < pnlst.Count; i++)
         {
             pnlst.Item(i).InnerText = Arr[i];
             if (Arr.Length < i + 2)
             {
                 break;
             }
         }
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 39
0
 public bool AddLineLayerRule(Page oPage, string sFilter, string width, string linestyle, string color)
 {
     bool result;
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             result = false;
             return result;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("LineRule")[0].Clone();
         pRule.SelectSingleNode("Filter").InnerText = sFilter;
         pRule.SelectSingleNode("LineSymbolization2D/LineStyle").InnerText = linestyle;
         pRule.SelectSingleNode("LineSymbolization2D/Thickness").InnerText = width;
         pRule.SelectSingleNode("LineSymbolization2D/Color").InnerText = color.ToUpper();
         this.LayerDefXml.GetElementsByTagName("LineTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 40
0
 public bool UpdateSignFilterLayerDef(string filter)
 {
     bool result;
     try
     {
         if (this.LayerDefXml.GetElementsByTagName("Filter").Count > 0 && filter != "")
         {
             this.LayerDefXml.GetElementsByTagName("Filter")[0].InnerText = filter;
         }
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 41
0
 public bool AddRedlineMarkLayerRule(string sFilter, string width, string height, string color)
 {
     bool result;
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             result = false;
             return result;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("PointRule")[0];
         if (pRule.SelectSingleNode("Filter").InnerText != "")
         {
             pRule = this.LayerDefXml.GetElementsByTagName("PointRule")[0].Clone();
         }
         pRule.SelectSingleNode("Filter").InnerText = sFilter;
         pRule.SelectSingleNode("PointSymbolization2D/Mark/SizeX").InnerText = width;
         pRule.SelectSingleNode("PointSymbolization2D/Mark/SizeY").InnerText = height;
         pRule.SelectSingleNode("PointSymbolization2D/Mark/Fill/ForegroundColor").InnerText = color.ToUpper();
         pRule.SelectSingleNode("PointSymbolization2D/Mark/Fill/BackgroundColor").InnerText = color.ToUpper();
         pRule.SelectSingleNode("PointSymbolization2D/Mark/Edge/Color").InnerText = color.ToUpper();
         this.LayerDefXml.GetElementsByTagName("PointTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 42
0
 public bool CreateCognosPolygonLayerRule(string Filter, string LegendLabel, string LabelText, string FillColor, string BackgroundStyle, string BackgroundColor, string FontName, string SizeY, bool bDelete)
 {
     bool result;
     try
     {
         XmlNode pRule4Del = null;
         if (bDelete)
         {
             pRule4Del = this.LayerDefXml.GetElementsByTagName("AreaTypeStyle")[0];
         }
         XmlElement pAreaTypeStyle = this.LayerDefXml.CreateElement("AreaTypeStyle");
         XmlElement pElmt = this.LayerDefXml.CreateElement("AreaRule");
         XmlNode pRule = pElmt;
         pElmt = this.LayerDefXml.CreateElement("LegendLabel");
         pElmt.InnerText = LegendLabel;
         pRule.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("Filter");
         pElmt.InnerText = Filter;
         pRule.AppendChild(pElmt);
         if (LabelText != "")
         {
             XmlElement pLabel = this.LayerDefXml.CreateElement("Label");
             pElmt = this.LayerDefXml.CreateElement("Unit");
             pElmt.InnerText = "Points";
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("SizeContext");
             pElmt.InnerText = "DeviceUnits";
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("SizeX");
             pElmt.InnerText = "0.5";
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("SizeY");
             pElmt.InnerText = SizeY;
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("Text");
             pElmt.InnerText = "COGNOS_DATALABEL";
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("FontName");
             pElmt.InnerText = FontName;
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("ForegroundColor");
             pElmt.InnerText = "ff000000";
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("BackgroundColor");
             pElmt.InnerText = BackgroundColor;
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("BackgroundStyle");
             pElmt.InnerText = BackgroundStyle;
             pLabel.AppendChild(pElmt);
             pElmt = this.LayerDefXml.CreateElement("VerticalAlignment");
             pElmt.InnerText = "'Halfline'";
             pLabel.AppendChild(pElmt);
             XmlElement pAdvanced = this.LayerDefXml.CreateElement("AdvancedPlacement");
             pElmt = this.LayerDefXml.CreateElement("ScaleLimit");
             pElmt.InnerText = "0.5";
             pAdvanced.AppendChild(pElmt);
             pLabel.AppendChild(pAdvanced);
             pRule.AppendChild(pLabel);
         }
         XmlElement pSymbol = this.LayerDefXml.CreateElement("AreaSymbolization2D");
         XmlElement pFill = this.LayerDefXml.CreateElement("Fill");
         XmlElement pStroke = this.LayerDefXml.CreateElement("Stroke");
         pElmt = this.LayerDefXml.CreateElement("FillPattern");
         pElmt.InnerText = "Solid";
         pFill.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("ForegroundColor");
         pElmt.InnerText = FillColor;
         pFill.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("BackgroundColor");
         pElmt.InnerText = "FF000000";
         pFill.AppendChild(pElmt);
         pSymbol.AppendChild(pFill);
         pElmt = this.LayerDefXml.CreateElement("LineStyle");
         pElmt.InnerText = "Solid";
         pStroke.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("Thickness");
         pElmt.InnerText = "0";
         pStroke.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("Color");
         pElmt.InnerText = "FF000000";
         pStroke.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("Unit");
         pElmt.InnerText = "Centimeters";
         pStroke.AppendChild(pElmt);
         pElmt = this.LayerDefXml.CreateElement("SizeContext");
         pElmt.InnerText = "DeviceUnits";
         pStroke.AppendChild(pElmt);
         pSymbol.AppendChild(pStroke);
         pRule.AppendChild(pSymbol);
         if (bDelete && pRule4Del != null)
         {
             pAreaTypeStyle.AppendChild(pRule);
             this.LayerDefXml.GetElementsByTagName("VectorScaleRange")[0].RemoveChild(pRule4Del);
             this.LayerDefXml.GetElementsByTagName("VectorScaleRange")[0].AppendChild(pAreaTypeStyle);
         }
         else
         {
             this.LayerDefXml.GetElementsByTagName("AreaTypeStyle")[0].AppendChild(pRule);
         }
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 43
0
 public bool AddTextLayerRule(string sFilter, string width, string color, string sFont, string sFill, string textB, string textI, string textU, string stext, string rotation, string align)
 {
     bool result;
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             result = false;
             return result;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("PointRule")[0].Clone();
         pRule.SelectSingleNode("Filter").InnerText = sFilter;
         pRule.SelectSingleNode("Label/SizeY").InnerText = width;
         pRule.SelectSingleNode("Label/Text").InnerText = stext;
         pRule.SelectSingleNode("Label/FontName").InnerText = sFont;
         pRule.SelectSingleNode("Label/ForegroundColor").InnerText = color.ToUpper();
         if (sFill != "")
         {
             pRule.SelectSingleNode("Label/BackgroundStyle").InnerText = "Opaque";
             pRule.SelectSingleNode("Label/BackgroundColor").InnerText = sFill;
         }
         else
         {
             pRule.SelectSingleNode("Label/BackgroundStyle").InnerText = "Transparent";
             pRule.SelectSingleNode("Label/BackgroundColor").InnerText = "ffffffff";
         }
         if (rotation != "")
         {
             pRule.SelectSingleNode("Label/Rotation").InnerText = rotation;
         }
         if (align != "")
         {
             pRule.SelectSingleNode("Label/HorizontalAlignment").InnerText = "'" + align + "'";
         }
         pRule.SelectSingleNode("Label/Bold").InnerText = textB;
         pRule.SelectSingleNode("Label/Italic").InnerText = textI;
         pRule.SelectSingleNode("Label/Underlined").InnerText = textU;
         this.LayerDefXml.GetElementsByTagName("PointTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 44
0
 public XmlResponseDialog(MgByteReader reader)
     : this()
 {
     this.Content = reader.ToString();
 }
Ejemplo n.º 45
0
 public bool CreateLayerDef(string name, string datasource, string featurename, string geomName, string tooltip)
 {
     bool result;
     try
     {
         this.LayerDefXml = new XmlDocument();
         this.LayerDefXml.Load(ConfigurationManager.AppSettings["PHYSICALPATH"] + "\\App_Data\\" + name + ".xml");
         this.LayerDefXml.GetElementsByTagName("ResourceId")[0].InnerText = datasource;
         this.LayerDefXml.GetElementsByTagName("FeatureName")[0].InnerText = featurename;
         this.LayerDefXml.GetElementsByTagName("Geometry")[0].InnerText = geomName;
         if (this.LayerDefXml.GetElementsByTagName("ToolTip").Count > 0 && tooltip != "")
         {
             this.LayerDefXml.GetElementsByTagName("ToolTip")[0].InnerText = tooltip;
         }
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 46
0
 public bool CreateLayerDef(string sContent)
 {
     bool result;
     try
     {
         this.LayerDefXml = new XmlDocument();
         this.LayerDefXml.PreserveWhitespace = true;
         this.LayerDefXml.LoadXml(sContent);
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 47
0
 public bool CreateFireCarsLayerDef(string name, string datasource, string featurename, string color)
 {
     bool result;
     try
     {
         this.LayerDefXml = new XmlDocument();
         this.LayerDefXml.Load(ConfigurationManager.AppSettings["PHYSICALPATH"] + "\\App_Data\\" + name + ".xml");
         this.LayerDefXml.GetElementsByTagName("ResourceId")[0].InnerText = datasource;
         this.LayerDefXml.GetElementsByTagName("FeatureName")[0].InnerText = featurename;
         XmlNodeList lst = this.LayerDefXml.GetElementsByTagName("ForegroundColor");
         for (int i = 1; i < lst.Count; i++)
         {
             lst[i].InnerText = color;
         }
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
 IActionResult OutputReaderContent(MgByteReader outputReader)
 {
     using (MemoryStream memBuf = new MemoryStream())
     {
         byte[] byteBuffer = new byte[1024];
         int numBytes = outputReader.Read(byteBuffer, 1024);
         while (numBytes > 0)
         {
             memBuf.Write(byteBuffer, 0, numBytes);
             numBytes = outputReader.Read(byteBuffer, 1024);
         }
         byte[] content = memBuf.ToArray();
         return File(content, outputReader.MimeType);
     }
 }
Ejemplo n.º 49
0
        public override void UpdateRepository(string resourceId, ResourceFolderHeaderType header)
        {
            MgResourceService res = this.Connection.CreateService(MgServiceType.ResourceService) as MgResourceService;

            if (header == null)
            {
                res.UpdateRepository(new MgResourceIdentifier(resourceId), null, null);
                LogMethodCall("MgResourceService::UpdateRepository", true, resourceId, "null", "null");
            }
            else
            {
                byte[] data = this.SerializeObject(header).ToArray();
                MgByteReader rd = new MgByteReader(data, data.Length, "text/xml");
                res.UpdateRepository(new MgResourceIdentifier(resourceId), null, rd);

                LogMethodCall("MgResourceService::UpdateRepository", true, resourceId, "null", "MgByteReader");
            }
        }
Ejemplo n.º 50
0
 public string ChangeNewRasterLocation(string sXml, string newName)
 {
     string result;
     try
     {
         this.LayerDefXml = new XmlDocument();
         this.LayerDefXml.PreserveWhitespace = true;
         this.LayerDefXml.LoadXml(sXml);
         string val = this.LayerDefXml.SelectSingleNode("FeatureSource/Parameter/Value").InnerText;
         string[] arrVal = val.Split(new char[]
         {
             '/'
         });
         string oldName = arrVal[1];
         string vv = sXml.Replace(oldName, newName);
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = vv;
     }
     catch
     {
         result = "";
     }
     return result;
 }
Ejemplo n.º 51
0
 public bool UpdateFilterLayerDef(string filter, bool bReplace, out string sfilterNew)
 {
     sfilterNew = "";
     bool result;
     try
     {
         XmlNode pnode = this.LayerDefXml.SelectSingleNode("LayerDefinition/VectorLayerDefinition/Filter");
         if (pnode != null && filter != "")
         {
             sfilterNew = pnode.InnerText.Replace("\"", "");
             if (bReplace)
             {
                 pnode.InnerText = filter;
                 sfilterNew = filter;
             }
             else
             {
                 XmlNode expr_67 = pnode;
                 expr_67.InnerText = expr_67.InnerText + " AND " + filter;
                 sfilterNew = sfilterNew + " AND " + filter;
             }
         }
         else
         {
             XmlElement pFilter = this.LayerDefXml.CreateElement("Filter");
             pFilter.InnerText = filter;
             pnode = this.LayerDefXml.SelectSingleNode("LayerDefinition/VectorLayerDefinition");
             XmlNode pAfterNode = this.LayerDefXml.SelectSingleNode("LayerDefinition/VectorLayerDefinition/FeatureNameType");
             if (pnode != null)
             {
                 pnode.InsertAfter(pFilter, pAfterNode);
             }
             sfilterNew = filter;
         }
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 52
0
 public void StringConstructor()
 {
     MgByteReader reader = new MgByteReader(testString, "text/html");
     Assert.AreEqual(testString.Length, reader.GetLength());
     string buf = reader.ToString();
     Assert.AreEqual(testString, buf);
     Assert.AreEqual(testString.Length, reader.GetLength());
     reader.Rewind();
      Assert.AreEqual(testString.Length, reader.GetLength());
 }
Ejemplo n.º 53
0
 public void UpdateTabaLayerDef(string QXml)
 {
     try
     {
         XmlDocument pXml = new XmlDocument();
         QXml = QXml.Replace("Join1", "Join");
         pXml.LoadXml(QXml);
         XmlNode pRule = pXml.GetElementsByTagName("VectorScaleRange")[0].Clone();
         this.LayerDefXml.GetElementsByTagName("VectorLayerDefinition")[0].AppendChild(this.LayerDefXml.ImportNode(pRule, true));
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
     }
     catch
     {
     }
 }
Ejemplo n.º 54
0
 public bool UpdateTabaLayerDef(string datasource, string featurename, string tooltip)
 {
     bool result;
     try
     {
         this.LayerDefXml.GetElementsByTagName("ResourceId")[0].InnerText = datasource;
         this.LayerDefXml.GetElementsByTagName("FeatureName")[0].InnerText = featurename;
         if (this.LayerDefXml.GetElementsByTagName("ToolTip").Count > 0)
         {
             this.LayerDefXml.GetElementsByTagName("ToolTip")[0].InnerText = tooltip;
         }
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 55
0
 public bool AddRedlinePolygonLayerRule(string sFilter, string width, string linestyle, string LineColor, string FillType, string FillColor)
 {
     bool result;
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             result = false;
             return result;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("AreaRule")[0];
         if (pRule.SelectSingleNode("Filter").InnerText != "")
         {
             pRule = this.LayerDefXml.GetElementsByTagName("AreaRule")[0].Clone();
         }
         pRule.SelectSingleNode("Filter").InnerText = sFilter;
         pRule.SelectSingleNode("AreaSymbolization2D/Stroke/LineStyle").InnerText = linestyle;
         pRule.SelectSingleNode("AreaSymbolization2D/Stroke/Thickness").InnerText = width;
         pRule.SelectSingleNode("AreaSymbolization2D/Stroke/Color").InnerText = LineColor.ToUpper();
         pRule.SelectSingleNode("AreaSymbolization2D/Fill/FillPattern").InnerText = FillType;
         pRule.SelectSingleNode("AreaSymbolization2D/Fill/ForegroundColor").InnerText = FillColor.ToUpper();
         this.LayerDefXml.GetElementsByTagName("AreaTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 56
0
        void OutputReaderContent(HttpResponse response, MgByteReader byteReader)
        {
            MemoryStream memBuf = new MemoryStream();

            byte[] byteBuffer = new byte[1024];
            int numBytes = byteReader.Read(byteBuffer, 1024);
            while (numBytes > 0)
            {
                memBuf.Write(byteBuffer, 0, numBytes);
                numBytes = byteReader.Read(byteBuffer, 1024);
            }

            response.ContentType = byteReader.GetMimeType();
            byte[] content = memBuf.ToArray();
            response.OutputStream.Write(content, 0, content.Length);
        }
Ejemplo n.º 57
0
        public void CreateMarkup(string mgSessionId,string  mgMap)
        {
            //Response.Write("CreateMarkup" );
            MgUserInformation userInfo = new MgUserInformation(mgSessionId);
            MgSiteConnection siteConnection = new MgSiteConnection();
            siteConnection.Open(userInfo);

            MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
            MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);

            MgMap map = new MgMap();
            map.Open(resourceService, mgMap);
            //    map.Open(resourceService, GetParameter(args, "MAPNAME"));

            // Create the Markup Feature Source (SDF)

            MgResourceIdentifier markupSdfResId = new MgResourceIdentifier(libraryPath + GetParameter(this.args, "MARKUPNAME") + ".FeatureSource");

            MgFeatureSchema markupSchema = MarkupSchemaFactory.CreateMarkupSchema();
            MgCreateSdfParams sdfParams = new MgCreateSdfParams("XY-M", map.MapSRS, markupSchema);
            featureService.CreateFeatureSource(markupSdfResId, sdfParams);

            String url = "concat(&apos;" + GetParameter(this.args, "MARKUPURL") + "&apos;, concat(&apos;?key=&apos;, &quot;ID&quot;))";
            //Link to ProjectManager
              /*  if (GetParameter(this.args, "LINKTOPROJECTMANAGER").ToLower() == "on"
                && !String.IsNullOrEmpty(GetParameter(this.args, "ProjectCollectionName"))
                && GetParameter(this.args, "ProjectCollectionName") != "áçø îøùéîä")
            {
                string projectCollectionName = GetParameter(this.args, "ProjectCollectionName");
                if (projectCollectionName == "àçø...")
                {
                    projectCollectionName = GetParameter(this.args, "ProjectCollectionOtherName");
                }
                int projectId = 0;
                using (var conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["ProjectManagerConnectionString"].ConnectionString))
                {
                    var cmd = conn.CreateCommand();
                    cmd.CommandText = "INSERT INTO ProjectCollections(LayoutId, FeatureId, ProjectCollectionName) VALUES(@LayoutId, @FeatureId, @ProjectCollectionName); SELECT @@IDENTITY AS [NEWID]";
                    cmd.CommandType = System.Data.CommandType.Text;

                    var layoutIdParam = new System.Data.SqlClient.SqlParameter("@LayoutId", System.Data.SqlDbType.NVarChar, 255);
                    layoutIdParam.Value = GetParameter(args, "LAYOUT");
                    cmd.Parameters.Add(layoutIdParam);

                    var featureIdParam = new System.Data.SqlClient.SqlParameter("@FeatureId", System.Data.SqlDbType.NVarChar, 255);
                    featureIdParam.Value = markupSdfResId.ToString();
                    cmd.Parameters.Add(featureIdParam);

                    var pcNameParam = new System.Data.SqlClient.SqlParameter("@ProjectCollectionName", System.Data.SqlDbType.NVarChar, 50);
                    pcNameParam.Value = projectCollectionName;
                    cmd.Parameters.Add(pcNameParam);

                    conn.Open();
                    //projectId = (int)cmd.ExecuteScalar();
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            projectId = Convert.ToInt32(reader[0]);
                        }
                    }
                }
                string host = HttpContext.Current.Request.Url.Host;
                url = String.Format("concat('http://{0}/MgExtensions/ProjectManager/default.aspx?ProjectId={1}&UID=', \"UID\")", host, projectId);
            }
            */
            // Create the Markup Layer Definition

            String hexFgTransparency = String.Format("{0:X2}", 255 * (100 - Int32.Parse(GetParameter(this.args, "FILLTRANSPARENCY"))) / 100); // Convert % to an alpha value
            String hexBgTransparency = GetParameter(this.args, "FILLBACKTRANS").Length > 0 ? "FF" : "00";							 // All or nothing
            String bold = GetParameter(this.args, "LABELBOLD").Length > 0 ? "true" : "false";
            String italic = GetParameter(this.args, "LABELITALIC").Length > 0 ? "true" : "false";
            String underline = GetParameter(this.args, "LABELUNDERLINE").Length > 0 ? "true" : "false";

            String markupLayerDefinition = File.ReadAllText(HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Extensions\\markup\\templates\\markuplayerdefinition.xml");
            markupLayerDefinition = String.Format(markupLayerDefinition,
                markupSdfResId.ToString(),						                //<ResourceId> - Feature Source
                GetParameter(this.args, "LABELSIZEUNITS"),						//<Unit> - Mark Label
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeX> - Mark Label Size
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeY> - Mark Label Size
                "FF" + GetParameter(this.args, "LABELFORECOLOR"),				//<ForegroundColor> - Mark Label
                "FF" + GetParameter(this.args, "LABELBACKCOLOR"),				//<BackgroundColor> - Mark Label
                GetParameter(this.args, "LABELBACKSTYLE"),						//<BackgroundStyle> - Mark Label
                bold,												            //<Bold> - Mark Label
                italic,											                //<Bold> - Mark Label
                underline,											            //<Underlined> - Mark Label
                GetParameter(this.args, "MARKERSIZEUNITS"),						//<Unit> - Mark
                GetParameter(this.args, "MARKERSIZE"),							//<SizeX> - Mark
                GetParameter(this.args, "MARKERSIZE"),							//<SizeY> - Mark
                GetParameter(this.args, "MARKERTYPE"),							//<Shape> - Mark
                "FF" + GetParameter(this.args, "MARKERCOLOR"),					//<ForegroundColor> - Mark
                "FF" + GetParameter(this.args, "MARKERCOLOR"),					//<Color> - Mark
                GetParameter(this.args, "LABELSIZEUNITS"),						//<Unit> - Line Label
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeX> - Line Label Size
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeY> - Line Label Size
                "FF" + GetParameter(this.args, "LABELFORECOLOR"),				//<ForegroundColor> - Line Label
                "FF" + GetParameter(this.args, "LABELBACKCOLOR"),				//<BackgroundColor> - Line Label
                GetParameter(this.args, "LABELBACKSTYLE"),						//<BackgroundStyle> - Line Label
                bold,												            //<Bold> - Line Label
                italic,											                //<Bold> - Line Label
                underline,											            //<Underlined> - Line Label
                GetParameter(this.args, "LINEPATTERN"),							//<LineStyle> - Line
                GetParameter(this.args, "LINETHICKNESS"),						//<Thickness> - Line
                "FF" + GetParameter(this.args, "LINECOLOR"),					//<Color> - Line
                GetParameter(this.args, "LINESIZEUNITS"),						//<Unit> - Line
                GetParameter(this.args, "LABELSIZEUNITS"),						//<Unit> - Polygon Label
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeX> - Polygon Label Size
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeY> - Polygon Label Size
                "FF" + GetParameter(this.args, "LABELFORECOLOR"),				//<ForegroundColor> - Polygon Label
                "FF" + GetParameter(this.args, "LABELBACKCOLOR"),				//<BackgroundColor> - Polygon Label
                GetParameter(this.args, "LABELBACKSTYLE"),						//<BackgroundStyle> - Polygon Label
                bold,												            //<Bold> - Polygon Label
                italic,											                //<Bold> - Polygon Label
                underline,											            //<Underlined> - Polygon Label
                GetParameter(this.args, "FILLPATTERN"), 						//<FillPattern> - Fill
                hexFgTransparency + GetParameter(this.args, "FILLFORECOLOR"), 	//<ForegroundColor> - Fill
                hexBgTransparency + GetParameter(this.args, "FILLBACKCOLOR"), 	//<BackgroundColor> - Fill
                GetParameter(this.args, "BORDERPATTERN"),						//<LineStyle> - Fill
                GetParameter(this.args, "BORDERTHICKNESS"), 					//<Thickness> - Fill
                "FF" + GetParameter(this.args, "BORDERCOLOR"), 					//<Color> - Fill
                GetParameter(this.args, "BORDERSIZEUNITS"), 					//<Unit> - Fill
                HttpContext.Current.Server.HtmlEncode(url)); //<Url> - url link

            MgByteReader byteReader = new MgByteReader(markupLayerDefinition, "text/xml");
            resourceService.SetResource(new MgResourceIdentifier(libraryPath + GetParameter(this.args, "MARKUPNAME") + ".LayerDefinition"), byteReader, null);
        }
Ejemplo n.º 58
0
 public bool AddSignSymbolLayerRule(string symbol, string sRot, string symDesc)
 {
     bool result;
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             result = false;
             return result;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("PointRule")[0].Clone();
         pRule.SelectSingleNode("PointSymbolization2D/W2D/W2DSymbol/LibraryItemName").InnerText = symbol;
         pRule.SelectSingleNode("PointSymbolization2D/W2D/Rotation").InnerText = sRot;
         this.LayerDefXml.GetElementsByTagName("PointTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Ejemplo n.º 59
0
    public bool ShowSpatialFilter()
    {
        bool result = true;
        MgUserInformation userInfo = new MgUserInformation(Request["SESSION"]);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);

        MgResourceIdentifier sdfResId = new MgResourceIdentifier("Session:" + Request["SESSION"] + "//Filter.FeatureSource");

        MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
        MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;

        MgFeatureCommandCollection updateCommands = new MgFeatureCommandCollection();

        MgMap map = new MgMap();
        map.Open(resourceService, Request["MAPNAME"]);

        MgLayer layer = null;
        MgLayerCollection layers = map.GetLayers();
        if (layers.Contains("_QuerySpatialFilter"))
        {
            layer = (MgLayer)layers.GetItem("_QuerySpatialFilter");
            //updateCommands.Add(new MgDeleteFeatures("Filter", "ID > 0"));
        }
        else
        {
            // Create the Feature Source (SDF)

            MgFeatureSchema sdfSchema = this.CreateFilterSchema();
            MgCreateSdfParams sdfParams = new MgCreateSdfParams("MAPCS", map.GetMapSRS(), sdfSchema);
            featureService.CreateFeatureSource(sdfResId, sdfParams);

            // Create the Layer

            MgResourceIdentifier layerResId = new MgResourceIdentifier("Session:" + Request["SESSION"] + "//Filter.LayerDefinition");
            String layerDefinition = File.ReadAllText(GetQueryXmlTemplatePath());
            layerDefinition = layerDefinition.Replace("%s", sdfResId.ToString());

            MgByteReader reader = new MgByteReader(layerDefinition, "text/xml");
            resourceService.SetResource(layerResId, reader, null);

            layer = new MgLayer(layerResId, resourceService);

            layer.SetName("_QuerySpatialFilter");
            layer.SetLegendLabel("תחום זמני");
            layer.SetDisplayInLegend(true);
            layer.SetSelectable(true);
            layer.ForceRefresh();
            layer.NeedsRefresh();

            layers.Insert(0, layer);
        }

        // Make the layer visible

        layer.SetVisible(true);
        map.Save(resourceService);

        // Add the geometry to the filter feature source
        MgPolygon polygon = this.CreatePolygonFromGeomText(Request["GEOMTEXT"].ToString());
        MgAgfReaderWriter agfWriter = new MgAgfReaderWriter();
        MgByteReader byteReader = agfWriter.Write(polygon);

        MgPropertyCollection propertyValues = new MgPropertyCollection();
        propertyValues.Add(new MgGeometryProperty("Geometry", byteReader));
        try
        {
            updateCommands.Add(new MgInsertFeatures("Filter", propertyValues));

            featureService.UpdateFeatures(sdfResId, updateCommands, false);
        }
        catch { }

        return result;
    }
Ejemplo n.º 60
0
 public bool AddSymbolLayerRule(string sFilter, string width, string height, string color, string symbol, string Symbolres)
 {
     bool result;
     try
     {
         if (this.LayerDefXmlString != "")
         {
             this.LayerDefXml = new XmlDocument();
             this.LayerDefXml.LoadXml(this.LayerDefXmlString);
         }
         else if (this.LayerDefXml == null)
         {
             result = false;
             return result;
         }
         XmlNode pRule = this.LayerDefXml.GetElementsByTagName("PointRule")[0].Clone();
         pRule.SelectSingleNode("Filter").InnerText = sFilter;
         pRule.SelectSingleNode("PointSymbolization2D/W2D/W2DSymbol/LibraryItemName").InnerText = symbol;
         pRule.SelectSingleNode("PointSymbolization2D/W2D/W2DSymbol/ResourceId").InnerText = Symbolres;
         pRule.SelectSingleNode("PointSymbolization2D/W2D/SizeX").InnerText = width;
         pRule.SelectSingleNode("PointSymbolization2D/W2D/SizeY").InnerText = height;
         pRule.SelectSingleNode("PointSymbolization2D/W2D/FillColor").InnerText = color.ToUpper();
         this.LayerDefXml.GetElementsByTagName("PointTypeStyle")[0].AppendChild(pRule);
         this.LayerDefXmlString = this.LayerDefXml.OuterXml;
         this.layerDefContent = new MgByteReader(this.LayerDefXml.OuterXml, "text/xml");
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }