コード例 #1
0
        internal static object STGeomFromText(string geoText, int sRID)
        {
            object cwPolygon    = SQLGeographyWrapper.GeometryParse(geoText);
            object stStartPoint = ClassLoader.Invoke(cwPolygon, "STStartPoint", null);
            object validPolygon = ClassLoader.Invoke(cwPolygon, "MakeValid", null);

            cwPolygon = ClassLoader.Invoke(validPolygon, "STUnion", new object[] { stStartPoint });
            object stAsText = ClassLoader.Invoke(cwPolygon, "STAsText", null);

            return(ClassLoader.InvokeStatic(SQLGeographyWrapper.GeoAssembly, SQLGeographyWrapper.SqlGeographyClass, "STGeomFromText", new object[] { stAsText, sRID }));
        }
コード例 #2
0
        public override void webExecute()
        {
            string     commandType = GetNextPar();
            TextWriter cOut        = Console.Out;
            int        code        = 0;

            try
            {
                using (var responseWriter = new HttpResponseWriter(context.HttpContext.Response))
                {
                    Console.SetOut(responseWriter);
                    if (commandType == DataInitialization)
                    {
                        code = (int)ClassLoader.InvokeStatic(DataInitializationAssembly, "GeneXus.Utils.GXDataInitialization", "Main", new object[] { dataArgs });
                    }
                    else                     //REORG
                    {
                        code = (int)ClassLoader.InvokeStatic(ReorAssembly, "GeneXus.Forms.ReorgStartup", "Main", new object[] { reorArgs });
                    }
                }
                if (code != 0)
                {
                    GXLogging.Error(log, "Error executing ", commandType);
                    context.HttpContext.Response.Write(ERROR_LINE);
                }
            }
            catch (Exception ex)
            {
                GXLogging.Error(log, $"Error executing {commandType}:", code.ToString(), ex);
                context.HttpContext.Response.Write(ex.Message);
                context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            finally
            {
                Console.SetOut(cOut);
            }
        }
コード例 #3
0
        public static Geospatial FromGXLocation(String geoText)
        {
            Geospatial geo = new Geospatial();

            if (!String.IsNullOrEmpty(geoText))
            {
                if (geoText.Contains("."))
                {
                    // has . as decimal separator and "," as value sep
                    geoText = geoText.Replace(',', ' ');
                }
                else
                {
                    // has comma as DS and space as value sep
                    geoText = geoText.Replace(',', '.');
                }
                try
                {
                    String[] coord = geoText.Split(new char[] { ' ' }, 2);

                    geo.Point.Longitude = Convert.ToDouble(coord[1].Trim(), CultureInfo.InvariantCulture.NumberFormat);
                    geo.Point.Latitude  = Convert.ToDouble(coord[0].Trim(), CultureInfo.InvariantCulture.NumberFormat);
                    geo.srid            = 4326;
                    // Latitude and Longitud parameters are reversed in the 'Point' constructor:
                    geo.InnerValue = ClassLoader.InvokeStatic(SQLGeographyWrapper.GeoAssembly, SQLGeographyWrapper.SqlGeographyClass, "Point", new object[] { geo.Point.Latitude, geo.Point.Longitude, geo.Srid });
                }
                catch (Exception)
                {
                    // Can't convert to geography set as null.
                    geo.InnerValue      = SQLGeographyWrapper.NullSQLGeography;
                    geo.geoText         = "";
                    geo.Point.Longitude = 0;
                    geo.Point.Latitude  = 0;
                }
            }
            return(geo);
        }
コード例 #4
0
        public void FromString(String s)
        {
            if (IsGeoNull(s))
            {
                geoText = EMPTY_GEOMETRY;
            }
            else
            {
                geoText = s.Trim();
            }


            try
            {
                // Sql Server Text
                _innerValue = SQLGeographyWrapper.Parse(geoText);
                if ((!SQLGeographyWrapper.IsValid(_innerValue)) && _innerValue != null)
                {
                    _innerValue = SQLGeographyWrapper.MakeValid(_innerValue);
                }

                this.srid = ((SqlInt32)ClassLoader.GetPropValue(_innerValue, "STSrid")).Value;

                this.setGXGeoType(SQLGeographyWrapper.STGeometryType(_innerValue).ToString());
                if (GeographicType == GeoGraphicTypeValue.Point)
                {
                    this.Point.Longitude = SQLGeographyWrapper.Long(_innerValue);
                    this.Point.Latitude  = SQLGeographyWrapper.Lat(_innerValue);
                }
            }
            catch (ArgumentException ex)
            {
                if (ex.ToString().Contains("24144")) // makevalid didn´t work
                {
                    _innerValue = null;
                }
                if (ex.ToString().Contains("24200"))                 // Error code for invalid Geo.
                {
                    _innerValue = SQLGeographyWrapper.STGeomFromText(geoText, srid);
                }
                else
                {
                    // Cannot parse value
                    this.InnerValue      = SQLGeographyWrapper.NullSQLGeography;
                    this.geoText         = "";
                    this.Point.Longitude = 0;
                    this.Point.Latitude  = 0;
                }
            }
            catch (FormatException ex)
            {
                String exText = ex.ToString();
                if (!String.IsNullOrEmpty(exText) && (ex.ToString().Contains("24114") || ex.ToString().Contains("24141")))
                {
                    if (GeographicType == GeoGraphicTypeValue.Point && !String.IsNullOrEmpty(geoText))
                    {
                        int commas = geoText.Split(',').Length - 1;
                        if ((commas == 1) && !geoText.Contains(" "))
                        {
                            // has . as decimal separator and "," as value sep
                            geoText = geoText.Replace(',', ' ');
                        }
                        else
                        {
                            if (geoText.Contains(",") && geoText.Contains(" "))
                            {
                                geoText = geoText.Replace(',', '.');
                            }
                        }
                        try
                        {
                            String[] coord = geoText.Split(new char[] { ' ' }, 2);
                            this.Point.Longitude = Convert.ToDouble(coord[1].Trim(), CultureInfo.InvariantCulture.NumberFormat);
                            this.Point.Latitude  = Convert.ToDouble(coord[0].Trim(), CultureInfo.InvariantCulture.NumberFormat);
                            this.srid            = 4326;
                            // Latitude and Longitud parameters are reversed in the 'Point' constructor:
                            _innerValue = ClassLoader.InvokeStatic(SQLGeographyWrapper.GeoAssembly, SQLGeographyWrapper.SqlGeographyClass, "Point", new object[] { this.Point.Latitude, this.Point.Longitude, this.Srid });
                        }
                        catch (Exception)
                        {
                            // Can't convert to geography set as null.
                            _innerValue          = SQLGeographyWrapper.NullSQLGeography;
                            this.geoText         = "";
                            this.Point.Longitude = 0;
                            this.Point.Latitude  = 0;
                        }
                    }
                    else
                    {
                        // Cannot parse value
                        _innerValue          = SQLGeographyWrapper.NullSQLGeography;
                        this.geoText         = "";
                        this.Point.Longitude = 0;
                        this.Point.Latitude  = 0;
                    }
                }
                else
                {
                    // Cannot parse value
                    _innerValue          = SQLGeographyWrapper.NullSQLGeography;
                    this.geoText         = "";
                    this.Point.Longitude = 0;
                    this.Point.Latitude  = 0;
                }
            }
        }
コード例 #5
0
 internal static object Deserialize(SqlBytes bytes)
 {
     return(ClassLoader.InvokeStatic(GeoAssembly, SqlGeographyClass, "Deserialize", new object[] { bytes }));
 }
コード例 #6
0
 internal static object GeometryParse(String geoText)
 {
     return(ClassLoader.InvokeStatic(GeoAssembly, SqlGeometryClass, "Parse", new object[] { geoText }));
 }
コード例 #7
0
        internal static object Parse(String geoText)
        {
            SqlString sqlGeoText = new SqlString(geoText);

            return(ClassLoader.InvokeStatic(GeoAssembly, SqlGeographyClass, "Parse", new object[] { sqlGeoText }));
        }
コード例 #8
0
ファイル: GXSearch.cs プロジェクト: jechague/DotNetClasses
 public static string HTMLClean(string text)
 {
     return((string)ClassLoader.InvokeStatic(m_GxSearchAssembly, "GeneXus.Utils.DocumentHandler", "HTMLClean",
                                             new object[] { text }));
 }
コード例 #9
0
ファイル: GXSearch.cs プロジェクト: jechague/DotNetClasses
 public static string GetText(string filename, string extension)
 {
     return((string)ClassLoader.InvokeStatic(m_GxSearchAssembly, "GeneXus.Utils.DocumentHandler", "GetText",
                                             new object[] { filename, extension }));
 }
コード例 #10
0
ファイル: GXSearch.cs プロジェクト: jechague/DotNetClasses
 public static string HtmlPreview(Object obj, string query, string textType, string preTag, string postTag, int fragmentSize, int maxNumFragments)
 {
     return((string)ClassLoader.InvokeStatic(m_GxSearchAssembly, "GeneXus.Utils.DocumentHandler", "HtmlPreview",
                                             new object[] { obj, query, textType, preTag, postTag, fragmentSize, maxNumFragments }));
 }