Hi,thanks Alexander,
I've put that condition:
If ",localhost,127.0.0.1,".Contains("," + My.Settings.Server_Name.Trim.ToLower
+ ",")
..................
EndIf
I don't know if that is the best way
thanks
On Saturday, December 14, 2013 1:55 PM, Alexander Muylaert-Gelein
<amuylaert_gel...@hotmail.com> wrote:
Hi
This parses a firebird path and scans for "loopback" or computername. You just
need to add all possible IP's from you local PC and localhost.
good luck
a
private static void ReplaceLocalHost(ref string aServer)
{
s_OriginalDatabaseServer = aServer;
if (System.Environment.MachineName.Equals(aServer,
StringComparison.OrdinalIgnoreCase) || ("127.0.0.1".Equals(aServer,
StringComparison.Ordinal)))
{
aServer = "localhost";
}
}
private static char[] s_Splitter = new char[] { ':' };
private static bool SplitServerAndPort(string aPart, out string
aServer, out int aPort)
{
var p = aPart.IndexOf('/');
if (p >= 0)
{
aServer = aPart.Substring(0, p);
if (int.TryParse(aPart.Substring(p + 1), out aPort))
{
ReplaceLocalHost(ref aServer);
return true;
}
return false;
}
else
{
aServer = aPart;
ReplaceLocalHost(ref aServer);
aPort = 3050;
return true;
}
}
public static bool SplitDatabaseTarget(string aDatabaseTarget, out
string aServer, out int aPort,
out string aPath)
{
aServer = "localhost";
aPort = 3050;
aPath = null;
if (string.IsNullOrWhiteSpace(aDatabaseTarget))
{
return false;
}
var parts = aDatabaseTarget.Split(s_Splitter,
StringSplitOptions.RemoveEmptyEntries);
switch (parts.Length)
{
case 0:
return false;
case 1:
// "webdb"
aPath = parts[0];
return true;
case 2:
// "c:\fast.fdb"
// "fast-server:webdb
// "fast-server/3052:webdb"
if (parts[0].Length == 1 && parts[1].StartsWith("\\"))
{
aPath = parts[0] + ":" + parts[1];
}
else
{
if (!SplitServerAndPort(parts[0], out aServer, out
aPort))
{
return false;
}
aPath = parts[1];
}
return true;
case 3:
// "fast-server:c:\fast\fast.fdb
// "fast-server/3052:c:\fast\fast.fdb"
if (!SplitServerAndPort(parts[0], out aServer, out aPort))
{
return false;
}
if (parts[1].Length == 1 && parts[2].StartsWith("\\"))
{
aPath = parts[1] + ":" + parts[2];
return true;
}
return false;
default:
return false;
}
}
________________________________
Date: Fri, 13 Dec 2013 23:27:55 -0800
From: mr_joh...@yahoo.com
To: firebird-net-provider@lists.sourceforge.net
Subject: Re: [Firebird-net-provider] Detect current connection is local or
network
Hi !
"local" = database is on the same machine as application is
thanks.
On Friday, December 13, 2013 3:10 PM, Jiri Cincura <disk...@cincura.net> wrote:
>Depends on what you think "local" (your original question) is.
On Fri, Dec 13, 2013 at 12:40 PM, Mr. John <mr_joh...@yahoo.com> wrote:
> solution is to search in connecton string for 'localhost' or '127.0.0.1'
> ?
On Friday, December 13, 2013 3:10 PM, Jiri Cincura <disk...@cincura.net> wrote:
On Fri, Dec 13, 2013 at 12:40 PM, Mr. John <mr_joh...@yahoo.com> wrote:
> solution is to search in connecton string for 'localhost' or '127.0.0.1'
> ?
Depends on what you think "local" (your original question) is.
--
Jiri {x2} Cincura (x2develop.com founder)
http://blog.cincura.net/ | http://www.ID3renamer.com
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider