예제 #1
0
 public Boolean STIntersect(Geospatial x)
 {
     if (_innerValue != null && x.InnerValue != null &&
         !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
         !x.InnerValue.ToString().Equals(EMPTY_GEOGRAPHY))
     {
         try
         {
             return(NTSGeographyWrapper.STIntersects(_innerValue, x.InnerValue));
         }
         catch (Exception ex)
         {
             GXLogging.Debug(log, "Error calling Intersect() exception:");
             GXLogging.Debug(log, ex.ToString());
             return(false);
         }
     }
     else
     {
         if (_innerValue == null)
         {
             GXLogging.Debug(log, "STIntersect: _innerValue is not valid");
         }
         else
         {
             GXLogging.Debug(log, "STIntersect: x.InnerValue is not valid");
         }
         return(false);
     }
 }
예제 #2
0
        private void Receive(GXMailMessage msg)
        {
            GXLogging.Debug(log, "Receiving Message");
            if (session == null)
            {
                GXLogging.Error(log, "Could not start Outlook");
                throw new GXMailException("Could not start Outlook", 4);
            }

            msg.Clear();
            message = null;

            try
            {
                if (readItems == null)
                {
                    ChangeFolder("inbox");
                }

                if (newMessages == 1)
                {
                    if (firstRead)
                    {
                        message   = (MailItem)readItems.Find("[Unread] = True");
                        firstRead = false;
                    }
                    else
                    {
                        message = (MailItem)readItems.GetNext();
                    }
                }
                else
                {
                    if (firstRead)
                    {
                        message   = (MailItem)readItems.GetFirst();
                        firstRead = false;
                    }
                    else
                    {
                        message = (MailItem)readItems.GetNext();
                    }
                }
            }
            catch (System.Exception exc)
            {
                GXLogging.Error(log, "Could not receive message", exc);
                throw new GXMailException("Could not receive message", 22);
            }

            if (message != null)
            {
                CopyMessage(message, msg);
            }
            else
            {
                GXLogging.Debug(log, "No messages to receive");
                throw new NoMessagesException();
            }
        }
        public override short[] preExecute(int cursorNum, IDataStoreProviderBase connectionProvider, IGxDataStore ds)
        {
            base.preExecute(cursorNum, connectionProvider, ds);
            short[] parmHasValue = null;

            if (dynamicStmt)
            {
                Object[] dynStmt = parent.getDynamicStatement(cursorNum, connectionProvider.context, connectionProvider.getDynConstraints());
                if (dynStmt == null && parent is DataStoreHelperBase)
                {
                    dynStmt = ((DataStoreHelperBase)parent).getDynamicStatement(cursorNum, connectionProvider.getDynConstraints());
                }
                _stmt = (string)dynStmt[0];

                List <object> newParmBinds = new List <object>();
                parmHasValue = (short[])dynStmt[1];
                for (int i = 0; i < _parmBinds.Length; i++)
                {
                    if (parmHasValue[i] == 0)
                    {
                        newParmBinds.Add(_parmBinds[i]);
                    }
                }
                base.bindParms(newParmBinds.ToArray());
                GXLogging.Debug(log, "ForEachCursor.preExecute, DynamicStatement: " + _stmt);
                _gxDbCommand.CommandText = _stmt;
            }
            _gxDbCommand.DynamicStmt = dynamicStmt;
            _gxDbCommand.CursorDef   = _cursorDef;
            return(parmHasValue);
        }
예제 #4
0
        public static bool GetHttpRequestPostedFile(HttpContext httpContext, string varName, out string filePath)
        {
            filePath = null;
            if (httpContext != null)
            {
                var pf = GetFormFile(httpContext, varName);
                if (pf != null)
                {
#pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}'
                    FileInfo fi = new FileInfo(pf.FileName);
#pragma warning restore SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}'
                    string tempDir = Preferences.getTMP_MEDIA_PATH();
                    string ext     = fi.Extension;
                    if (ext != null)
                    {
                        ext = ext.TrimStart('.');
                    }
                    filePath = FileUtil.getTempFileName(tempDir, "BLOB", ext);
                    GXLogging.Debug(log, "cgiGet(" + varName + "), fileName:" + filePath);
                    GxFile file = new GxFile(tempDir, filePath);
#if NETCORE
                    filePath = file.Create(pf.OpenReadStream());
#else
                    filePath = file.Create(pf.InputStream);
#endif
                    GXFileWatcher.Instance.AddTemporaryFile(file);
                    return(true);
                }
            }
            return(false);
        }
예제 #5
0
        private void Delete()
        {
            GXLogging.Debug(log, "Deleting message");
            if (session == null)
            {
                GXLogging.Error(log, "Could not start Outlook");
                throw new GXMailException("Could not start Outlook", 4);
            }

            if (message != null)
            {
                try
                {
                    message.Delete();
                    message = null;
                }
                catch (System.Exception exc)
                {
                    GXLogging.Error(log, "Error deleting message", exc);
                }
            }
            else
            {
                GXLogging.Error(log, "No current message");
                throw new GXMailException("No current message", 26);
            }
        }
예제 #6
0
        public static string getPRINT_LAYOUT_METADATA_DIR()
        {
            if (mediaPath == null)
            {
                lock (syncRoot)
                {
                    if (mediaPath == null)
                    {
                        if (Config.GetValueOf("PRINT_LAYOUT_METADATA_DIR", out mediaPath))
                        {
                            mediaPath = mediaPath.Trim();

                            if (!String.IsNullOrEmpty(mediaPath) && !mediaPath.EndsWith("\\") && !mediaPath.EndsWith("/"))
                            {
                                mediaPath += Path.DirectorySeparatorChar;
                            }
                        }
                        else
                        {
                            mediaPath = "";
                        }
                        GXLogging.Debug(log, "PRINT_LAYOUT_METADATA_DIR:", mediaPath);
                    }
                }
            }
            return(mediaPath);
        }
예제 #7
0
        public int ExecProcess(string filename, string[] args, string basePath, string executable, DataReceivedEventHandler dataReceived)
        {
            Process p = new Process();

            p.StartInfo.FileName = string.Format("\"{0}\"", filename);

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToLower().StartsWith("\\config:") || args[i].ToLower().StartsWith("-config:"))
                {
                    args[i] = string.Format("\"{0}\"", args[i]);
                }
            }
            p.StartInfo.Arguments              = string.Format("\"{0}\" {1}", Path.Combine(basePath, executable), string.Join(" ", args));
            p.StartInfo.CreateNoWindow         = true;
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError  = true;
            p.StartInfo.RedirectStandardInput  = true;
            if (dataReceived != null)
            {
                p.OutputDataReceived += dataReceived;
                p.ErrorDataReceived  += dataReceived;
            }
            p.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();             //It must run in the same directory as the current process
            GXLogging.Debug(log, filename, p.StartInfo.WorkingDirectory, p.StartInfo.Arguments);
            p.Start();
            p.BeginOutputReadLine();
            p.BeginErrorReadLine();
            p.WaitForExit();
            return(p.ExitCode);
        }
예제 #8
0
 public Boolean STIntersect(Geospatial x)
 {
     if (_innerValue != null && x.InnerValue != null &&
         !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
         !x.InnerValue.ToString().Equals(EMPTY_GEOGRAPHY))
     {
         try
         {
             return(((SqlBoolean)(ClassLoader.Invoke(_innerValue, "STIntersects", new object[] { x.InnerValue }))).Equals(SqlBoolean.True));
         }
         catch (Exception ex)
         {
             GXLogging.Debug(log, "Error calling Intersect() exception:");
             GXLogging.Debug(log, ex.ToString());
             return(false);
         }
     }
     else
     {
         if (_innerValue == null)
         {
             GXLogging.Debug(log, "STIntersect: _innerValue is not valid");
         }
         else
         {
             GXLogging.Debug(log, "STIntersect: x.InnerValue is not valid");
         }
         return(false);
     }
 }
예제 #9
0
        public short SelectSheet(String sheetName)
        {
            GXLogging.Debug(log, "selectSheet " + sheetName);
            if (!string.IsNullOrEmpty(sheetName))
            {
                ExcelWorksheet pSheet = workBook.Worksheets[sheetName];
                if ((pSheet == null) && IsReadOnly())
                {
                    this.errCod         = 5;
                    this.errDescription = "Invalid worksheet name";
                    return(errCod);
                }

                if (pSheet == null)
                {
                    GXLogging.Debug(log, "create Sheet " + sheetName);
                    pSheet = workBook.Worksheets.Add(sheetName);
                }
                currentSheet = pSheet;
                GXLogging.Debug(log, "currentSheet " + currentSheet);
                return(0);
            }
            else
            {
                this.errCod         = 5;
                this.errDescription = "Invalid worksheet name";
                return(errCod);
            }
        }
예제 #10
0
        public GxMySQLDriverCSCursorDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters,
                                               string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt)
        {
            this.parameters = parameters;
            this.stmt       = stmt;
            this.fetchSize  = fetchSize;
            this.cache      = connection.ConnectionCache;
            this.cached     = cached;
            this.handle     = handle;
            this.isForFirst = forFirst;
            _connManager    = connManager;
            this.m_dr       = dr;
            this.readBytes  = 0;
            this.dynStmt    = dynStmt;
            con             = _connManager.IncOpenHandles(handle, m_dr.DataSource);
            con.CurrentStmt = stmt;
            con.MonitorEnter();
            GXLogging.Debug(log, "Open GxMySQLCursorDataReader handle:'" + handle);
            MySQLCommand cmd = (MySQLCommand)dr.GetCommand(con, stmt, parameters);

            cmd.ServerCursor = hasNested;
            cmd.FetchSize    = (uint)fetchSize;
            reader           = cmd.ExecuteReader();
            cache.SetAvailableCommand(stmt, false, dynStmt);
            open  = true;
            block = new GxArrayList(fetchSize);
            pos   = -1;
            if (cached)
            {
                key             = SqlUtil.GetKeyStmtValues(parameters, stmt, isForFirst);
                this.expiration = expiration;
            }
        }
예제 #11
0
        public double STDistance(Geospatial x)
        {
            if (_innerValue != null && x.InnerValue != null &&
                !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
                !x.InnerValue.ToString().Equals(EMPTY_GEOGRAPHY))
            {
                try
                {
                    return(((SqlDouble)(ClassLoader.Invoke(_innerValue, "STDistance", new object[] { x.InnerValue }))).Value);
                }
                catch (Exception ex)
                {
                    GXLogging.Debug(log, "Error calling Distance() exception:");
                    GXLogging.Debug(log, ex.ToString());
                    return(0);
                }
            }
            else
            {
                if (_innerValue == null)
                {
                    GXLogging.Debug(log, "STDistance: _innerValue is not valid");
                }
                else
                {
                    GXLogging.Debug(log, "STDistance: x.InnerValue is not valid");
                }

                return(0);
            }
        }
예제 #12
0
        public string userId()
        {
            GxConnection gxconn = _ds.Connection as GxConnection;

            if (gxconn != null && !String.IsNullOrEmpty(gxconn.InternalUserId))
            {
                return(gxconn.InternalUserId);
            }
            else
            {
                GXLogging.Debug(log, "UserId method");
                string stmt = ((GxDataRecord)_ds.Db).GetServerUserIdStmt();
                if (string.IsNullOrEmpty(stmt))
                {
                    return(string.Empty);
                }
                else
                {
                    GxCommand cmd = new GxCommand(_ds.Db, stmt, _ds, 0, false, true, _errorHandler);
                    cmd.ErrorMask = GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK;
                    IDataReader reader;
                    cmd.FetchData(out reader);
                    string s = string.Empty;
                    if (reader != null)
                    {
                        s = reader.GetString(0);
                        reader.Close();
                    }
                    return(s);
                }
            }
        }
예제 #13
0
        private int GetIntValue(string cmdStr)
        {
            SendNL(cmdStr);

            string response = GetResponse();

            GXLogging.Debug(log, "GetIntValue Server response: " + response);
            int firstBlank = response.IndexOf(" ");

            if (firstBlank == -1)
            {
                return(0);
            }
            int scndBlank = response.IndexOf(" ", firstBlank + 1);
            int retVal    = 0;

            try
            {
                if (scndBlank > 0)
                {
                    retVal = int.Parse(response.Substring(firstBlank, scndBlank - firstBlank).Trim());
                }
                else
                {
                    retVal = int.Parse(response.Substring(firstBlank).Trim());
                }
            }
            catch (Exception) {}

            return(retVal);
        }
예제 #14
0
        private void SendAndWaitResponse(string cmdMsg, short errorCode)
        {
            SendTCP(cmdMsg + CRLF);

            string response = GetResponse();

            GXLogging.Debug(log, "SendAndWait Server response: " + response);
            string serverResponse = response;

            int firstBlank = serverResponse.IndexOf(" ");

            if (firstBlank != -1)
            {
                serverResponse = serverResponse.Substring(firstBlank).Trim();
            }
            if (response.StartsWith("-ERR"))
            {
                GXLogging.Error(log, "Command error, server response: " + serverResponse);
                throw new GXMailException("Server replied with an error: " + serverResponse, MailConstants.MAIL_ServerRepliedErr);
            }
            if (!response.StartsWith("+OK"))
            {
                GXLogging.Error(log, "Command error, server response: " + serverResponse);
                throw new GXMailException(response, errorCode);
            }
        }
예제 #15
0
 private bool Get <T>(string key, out T value)
 {
     if (default(T) == null)
     {
         value = Deserialize <T>(RedisDatabase.StringGet(key));
         if (value == null)
         {
             GXLogging.Debug(log, "Get<T>, misses key '" + key + "'");
         }
         return(value != null);
     }
     else
     {
         if (RedisDatabase.KeyExists(key))
         {
             value = Deserialize <T>(RedisDatabase.StringGet(key));
             return(true);
         }
         else
         {
             GXLogging.Debug(log, "Get<T>, misses key '" + key + "'");
             value = default(T);
             return(false);
         }
     }
 }
예제 #16
0
        static public Object GetInstance(string assemblyName, string fullClassName, Object[] constructorArgs)
        {
            GXLogging.Debug(log, "GetInstance '" + fullClassName + "', assembly '" + assemblyName + "'");
            try{
#if NETCORE
                var      asl       = new AssemblyLoader(FileUtil.GetStartupDirectory());
                Assembly assem     = asl.LoadFromAssemblyPath(Path.Combine(FileUtil.GetStartupDirectory(), assemblyName + ".dll"));
                Type     classType = assem.GetType(fullClassName, true, true);
#else
                Assembly assem     = Assembly.Load(new AssemblyName(assemblyName));
                Type     classType = assem.GetType(fullClassName, false, true);
#endif
                return(Activator.CreateInstance(classType, constructorArgs));
            }
            catch (Exception e)
            {
                GXLogging.Error(log, "Error in invoke GetInstance", e);
#if !NETCORE
                if (!GxContext.isReorganization)
                {
                    GXUtil.WinMessage(e.Message, string.Empty);
                }
#endif
                throw GxClassLoaderException.ProcessException(e);
            }
        }
예제 #17
0
        public override IDataReader GetDataReader(
            IGxConnectionManager connManager,
            IGxConnection con,
            GxParameterCollection parameters,
            string stmt, ushort fetchSize,
            bool forFirst, int handle,
            bool cached, SlidingTime expiration,
            bool hasNested,
            bool dynStmt)
        {
            IDataReader idatareader;

            if (NpgsqlAssembly.GetName().Version.Major == 1)
            {
                GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode());
                idatareader = new GxDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt);
            }
            else
            {
                if (!hasNested)                //Client Cursor
                {
                    GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode());
                    idatareader = new GxDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt);
                }
                else                 //Server Cursor
                {
                    GXLogging.Debug(log, "ExecuteReader: server cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode());
                    idatareader = new GxPostgresqlMemoryDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt);
                }
            }
            return(idatareader);
        }
예제 #18
0
        static public object FindInstance(string defaultAssemblyName, string nspace, string clss, Object[] constructorArgs, Assembly defaultAssembly, bool ignoreCase = false)
        {
            Type objType = FindType(defaultAssemblyName, nspace, clss, defaultAssembly, ignoreCase);

            GXLogging.Debug(log, "CreateInstance, Args ", ConstructorArgsString(constructorArgs));
            return(Activator.CreateInstance(objType, constructorArgs));
        }
예제 #19
0
        private static void logConfig(string filename)
        {
            if (configLog)
            {
                try
                {
#if NETCORE
                    var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
                    if (filename != null)
                    {
                        XmlConfigurator.ConfigureAndWatch(logRepository, new FileInfo(filename));
                        GXLogging.Debug(log, "DOMConfigurator log4net configured with ", filename);
                    }
#else
                    if (filename != null)
                    {
                        XmlConfigurator.ConfigureAndWatch(new FileInfo(filename));
                        GXLogging.Debug(log, "DOMConfigurator log4net configured with ", filename);
                    }
                    else
                    {
                        XmlConfigurator.Configure();
                        GXLogging.Debug(log, "DOMConfigurator log4net configured with web.config");
                    }
#endif
                    GXLogging.Debug(log, "GxClasses version:", GxContext.StdClassesVersion());
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Could not load log4net configuration: " + ex.Message);
                }
                configLog = false;
            }
        }
예제 #20
0
        static public void Execute(string assmbly, string ns, string clss, Object[] constructorArgs, string mthd, Object[] args)
        {
            GXLogging.Debug(log, "Execute assembly '" + assmbly + "', class '" + clss + "' mthd '" + mthd + "'");
            Object o = FindInstance(assmbly, ns, clss, constructorArgs, Assembly.GetCallingAssembly());

            ExecuteVoidRef(o, mthd, args);
        }
예제 #21
0
 public GXReorganization()
 {
     DataStoreUtil.LoadDataStores(new GxContext()); //force to load dbms library (p.e. libmysql.dll 32x)
     _isMain = true;
     GxContext.isReorganization = true;
     GXLogging.Debug(log, "GXReorganization.Ctr()");
 }
예제 #22
0
 private bool Get <T>(string key, out T result)
 {
     result = default(T);
     if (key != null)
     {
         Notify(key);
         object value = cacheStorage.GetData(key);
         if (value != null && typeof(T) == value.GetType())
         {
             result = (T)value;
             if (Preferences.Instrumented)
             {
                 CacheItem item = result as CacheItem;
                 if (item != null)
                 {
                     item.Hits++;
                 }
             }
             hits++;
             return(true);
         }
         else
         {
             GXLogging.Debug(log, "Get<T>, misses key '", key, "'");
             misses++;
             return(false);
         }
     }
     else
     {
         GXLogging.Error(log, "GetData, Error: Key is null");
         return(false);
     }
 }
예제 #23
0
        public override void SetTimeout(IGxConnectionManager connManager, IGxConnection connection, int handle)
        {
            GXLogging.Debug(log, "Set Lock Timeout to " + m_lockTimeout / 1000);
            IDbCommand cmd = GetCommand(connection, SetTimeoutSentence(m_lockTimeout), new GxParameterCollection());

            cmd.ExecuteNonQuery();
        }
예제 #24
0
        public bool Get <T>(string cacheid, string keyvalue, out T result)
        {
            string key = Key(cacheid, keyvalue);

            GXLogging.Debug(log, "Get<T> cacheid:", cacheid, " key:", key);
            return(Get <T>(key, out result));
        }
예제 #25
0
        private void MarkAsRead()
        {
            GXLogging.Debug(log, "Marking as read");
            if (session == null)
            {
                GXLogging.Error(log, "Could not start Outlook");
                throw new GXMailException("Could not start Outlook", 4);
            }

            if (message != null)
            {
                try
                {
                    message.UnRead = false;
                }
                catch (System.Exception exc)
                {
                    GXLogging.Error(log, "Error marking as read", exc);
                }
            }
            else
            {
                GXLogging.Error(log, "No current message");
                throw new GXMailException("No current message", 26);
            }
        }
예제 #26
0
        void IScavengingAlgorithm.Execute()
        {
            long storageSize = cacheStorage.Size;

            if (maxCacheStorageSize > 0 && storageSize >= maxCacheStorageSize)
            {
                GXLogging.Debug(log, "Start LruScavenging.Execute, maxCacheStorageSize '", () => maxCacheStorageSize + "',storageSize='" + storageSize + "'");

                while (storageSize >= maxCacheStorageSize)
                {
                    string key = GetLruItem();

                    cacheStorage.Remove(key);
                    if (cacheMetadata != null)
                    {
                        lock (cacheMetadata)
                        {
                            cacheMetadata.Remove(key);
                        }
                    }

                    cachingService.ClearKey(key);

                    lock (itemsLastUsed)
                    {
                        itemsLastUsed.Remove(key);
                    }
                    storageSize = cacheStorage.Size;
                }
            }
        }
예제 #27
0
        private bool Get <T>(string key, out T value)
        {
            if (default(T) == null)
            {
                value = (T)_cache.Get(key);
                if (value == null)
                {
                    GXLogging.Debug(log, "Get<T>, misses key '" + key + "'");
                }

                return(value != null);
            }
            else
            {
                object oValue = _cache.Get(key);
                if (oValue != null)
                {
                    value = (T)Convert.ChangeType(oValue, typeof(T));
                    return(true);
                }
                else
                {
                    GXLogging.Debug(log, "Get<T>, misses key '" + key + "'");
                    value = default(T);
                    return(false);
                }
            }
        }
        private Assembly OnResolving(AssemblyLoadContext context, AssemblyName name)
        {
            GXLogging.Debug(log, "AssemblyResolver OnResolving for ", name.FullName);
            bool NamesMatch(RuntimeLibrary runtime)
            {
                return(string.Equals(runtime.Name, name.Name, StringComparison.OrdinalIgnoreCase));
            }

            RuntimeLibrary library =
                this.dependencyContext.RuntimeLibraries.FirstOrDefault(NamesMatch);

            if (library != null)
            {
                var wrapper = new CompilationLibrary(
                    library.Type,
                    library.Name,
                    library.Version,
                    library.Hash,
                    library.RuntimeAssemblyGroups.SelectMany(g => g.AssetPaths),
                    library.Dependencies,
                    library.Serviceable);

                var assemblies = new List <string>();
                this.assemblyResolver.TryResolveAssemblyPaths(wrapper, assemblies);
                if (assemblies.Count > 0)
                {
                    return(this.loadContext.LoadFromAssemblyPath(assemblies[0]));
                }
            }

            return(null);
        }
        public override void execute()
        {
            GXLogging.Debug(log, "CallCursor.Execute, name'" + _name + "'");
            if (_state < 2)
            {
                throw (new GxADODataException("Could not execute CallCursor:" + _name + " not defined."));
            }
            _status = 0;

            _gxDbCommand.FetchDataRPC(out _DR);
            _gxDbCommand.Conn.UncommitedChanges = true;

            _fldGetter.DataReader = _DR;


            if (_gxDbCommand.Status == 1 || _gxDbCommand.Status == 103 || _gxDbCommand.Status == 500)
            {
                _status = _gxDbCommand.Status;
            }
            else if (!_gxDbCommand.HasMoreRows)
            {
                _status = Cursor.EOF;
            }
            _closed = false;
        }
예제 #30
0
        public double STDistance(Geospatial x)
        {
            if (_innerValue != null && x.InnerValue != null &&
                !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
                !x.InnerValue.ToString().Equals(EMPTY_GEOGRAPHY))
            {
                try
                {
                    return(NTSGeographyWrapper.STDistance(_innerValue, x.InnerValue));
                }
                catch (Exception ex)
                {
                    GXLogging.Debug(log, "Error calling Distance() exception:");
                    GXLogging.Debug(log, ex.ToString());
                    return(0);
                }
            }
            else
            {
                if (_innerValue == null)
                {
                    GXLogging.Debug(log, "STDistance: _innerValue is not valid");
                }
                else
                {
                    GXLogging.Debug(log, "STDistance: x.InnerValue is not valid");
                }

                return(0);
            }
        }