Merge pull request 'take gateway from localhost' (#8) from fix_Take_gateway_from_localhost into master
Reviewed-on: #8
This commit is contained in:
commit
5291e2cb5b
@ -376,34 +376,8 @@ namespace MotoTrbo_GW
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ContinueConstructor()
|
private void FetchAudioSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!registeredIP)
|
|
||||||
{
|
|
||||||
tabVoice.Enabled = false;
|
|
||||||
|
|
||||||
DialogResult result = FeedbackRadMessageBox.ShowExclamation("Please register your copy of MotoTrbo Gateway using the Administrative Module.\n Your IP address is:" + YourIPaddress, "Info");
|
|
||||||
if (result == DialogResult.OK)
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
else if (registeredIP && !App.isValidVersion(APP_SERVER_VERSION,
|
|
||||||
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()))
|
|
||||||
{
|
|
||||||
DialogResult dr = RadMessageBox.Show("Please update your version of software to the latest one required by Application Server. Do you wish to update now?",
|
|
||||||
"Update required...", MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
|
|
||||||
|
|
||||||
if (dr == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
CheckForUpdate(true);
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get Audio settings
|
|
||||||
DBsettingsManager dbSettings = new DBsettingsManager(DBServer, DBSchema, DBUser, DBPass, DBPort);
|
DBsettingsManager dbSettings = new DBsettingsManager(DBServer, DBSchema, DBUser, DBPass, DBPort);
|
||||||
|
|
||||||
string tmpSamplaRate = dbSettings.getSettingValue(0, "sampleRate");
|
string tmpSamplaRate = dbSettings.getSettingValue(0, "sampleRate");
|
||||||
@ -434,6 +408,99 @@ namespace MotoTrbo_GW
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ContinueConstructor()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!registeredIP)
|
||||||
|
{
|
||||||
|
tabVoice.Enabled = false;
|
||||||
|
|
||||||
|
DialogResult result = FeedbackRadMessageBox.ShowExclamation("Please register your copy of MotoTrbo Gateway using the Administrative Module.\n Your IP address is:" + YourIPaddress, "Info");
|
||||||
|
if (result == DialogResult.OK)
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
else if (registeredIP && !App.isValidVersion(APP_SERVER_VERSION,
|
||||||
|
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()))
|
||||||
|
{
|
||||||
|
DialogResult dr = RadMessageBox.Show("Please update your version of software to the latest one required by Application Server. Do you wish to update now?",
|
||||||
|
"Update required...", MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
|
||||||
|
|
||||||
|
if (dr == DialogResult.Yes)
|
||||||
|
CheckForUpdate(true);
|
||||||
|
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//new code
|
||||||
|
List <Gateway> listGW = new List<Gateway>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(DBServer))
|
||||||
|
{
|
||||||
|
listGW = getGWidFromDB(DBServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (listGW.Count == 0)
|
||||||
|
{
|
||||||
|
DBServer = "127.0.0.1";
|
||||||
|
listGW = getGWidFromDB(DBServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SafeMobileLib.Utils.WriteLine("Ex on find automat the gateway ID:" + ex.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (listGW.Count == 0)
|
||||||
|
{
|
||||||
|
FeedbackRadMessageBox.ShowError("Gateway IP not present in DB\n\r Please go to Administrative module and register this GW with IP:!!!" + DBServer, "IP missing");
|
||||||
|
|
||||||
|
System.Environment.Exit(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GWID = ((Gateway)listGW[0]).Id;
|
||||||
|
source = new IniConfigSource(Main.CFG_FILE);
|
||||||
|
source.Configs["Gateway"].Set("id", GWID);
|
||||||
|
// source.Configs["NAI"].Set("peerID", ((Gateway)listGW[0]).Peer_id);
|
||||||
|
source.Save();
|
||||||
|
|
||||||
|
SafeMobileLib.Utils.WriteLine("Gateway ID is " + GWID, ConsoleColor.Cyan);
|
||||||
|
|
||||||
|
//SafeMobileLib.Utils.WriteLine("ID:" + GWID + " saved to config file.");
|
||||||
|
btGWID.Text = GWID.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SafeMobileLib.Utils.WriteLine("DB error!!!");
|
||||||
|
SafeMobileLib.Utils.WriteLine(ex.ToString());
|
||||||
|
|
||||||
|
FeedbackRadMessageBox.ShowError("DB error.\n\rPlease turn down the firewall or add an exception for the Datebase in the firewall and try again!!!\n\r DB ip:" + DBServer,
|
||||||
|
"DB error");
|
||||||
|
|
||||||
|
|
||||||
|
System.Environment.Exit(0);
|
||||||
|
//System.Windows.Forms.Application.Exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//end of new code
|
||||||
|
|
||||||
|
|
||||||
|
// Get Audio settings
|
||||||
|
FetchAudioSettings();
|
||||||
|
|
||||||
|
|
||||||
//int asio driver object
|
//int asio driver object
|
||||||
if (Main.AudioDriver == AudioDriverType.Asio)
|
if (Main.AudioDriver == AudioDriverType.Asio)
|
||||||
@ -469,91 +536,7 @@ namespace MotoTrbo_GW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//old code
|
|
||||||
/*if (GWID == -1)
|
|
||||||
{
|
|
||||||
int id = getGWidFromDB(YourIPaddress);
|
|
||||||
if (id == -1)
|
|
||||||
{
|
|
||||||
RadMessageBox.Show("Gateway IP not present in DB\n\r Please go to Administrative module and register this GW with IP:!!!" + YourIPaddress, "IP missing", MessageBoxButtons.OK, RadMessageIcon.Error);
|
|
||||||
System.Environment.Exit(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GWID = id;
|
|
||||||
source = new IniConfigSource(Main.CFG_FILE);
|
|
||||||
source.Configs["Gateway"].Set("id", id);
|
|
||||||
source.Save();
|
|
||||||
SafeMobileLib.Utils.WriteLine("ID:" + id +" saved to config file.");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//new code
|
|
||||||
List <Gateway> listGW = new List<Gateway>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
listGW = getGWidFromDB(YourIPaddress);
|
|
||||||
|
|
||||||
if (listGW.Count == 0)
|
|
||||||
{
|
|
||||||
if (DBServer.Contains("127.0.0.1") || (DBServer.ToUpper().Contains("LOCALHOST")))
|
|
||||||
listGW = getGWidFromDB("127.0.0.1");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GWID != -1)
|
|
||||||
{
|
|
||||||
Boolean find = false;
|
|
||||||
foreach (Gateway obj in listGW)
|
|
||||||
if (obj.Id == GWID) { find = true; break; }
|
|
||||||
if ((!find) && (DBServer.Contains("127.0.0.1") || (DBServer.ToUpper().Contains("LOCALHOST"))))
|
|
||||||
listGW = getGWidFromDB("127.0.0.1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SafeMobileLib.Utils.WriteLine("Ex on find automat the gateway ID:" + ex.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (listGW.Count == 0)
|
|
||||||
{
|
|
||||||
FeedbackRadMessageBox.ShowError("Gateway IP not present in DB\n\r Please go to Administrative module and register this GW with IP:!!!" + YourIPaddress, "IP missing");
|
|
||||||
|
|
||||||
System.Environment.Exit(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GWID = ((Gateway)listGW[0]).Id;
|
|
||||||
source = new IniConfigSource(Main.CFG_FILE);
|
|
||||||
source.Configs["Gateway"].Set("id", GWID);
|
|
||||||
// source.Configs["NAI"].Set("peerID", ((Gateway)listGW[0]).Peer_id);
|
|
||||||
source.Save();
|
|
||||||
|
|
||||||
SafeMobileLib.Utils.WriteLine("Gateway ID is " + GWID, ConsoleColor.Cyan);
|
|
||||||
|
|
||||||
//SafeMobileLib.Utils.WriteLine("ID:" + GWID + " saved to config file.");
|
|
||||||
btGWID.Text = GWID.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SafeMobileLib.Utils.WriteLine("DB error!!!");
|
|
||||||
SafeMobileLib.Utils.WriteLine(ex.ToString());
|
|
||||||
|
|
||||||
FeedbackRadMessageBox.ShowError("DB error.\n\rPlease turn down the firewall or add an exception for the Datebase in the firewall and try again!!!\n\r DB ip:" + YourIPaddress,
|
|
||||||
"DB error");
|
|
||||||
|
|
||||||
|
|
||||||
System.Environment.Exit(0);
|
|
||||||
//System.Windows.Forms.Application.Exit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//end of new code
|
|
||||||
|
|
||||||
/*try
|
/*try
|
||||||
{
|
{
|
||||||
@ -1274,7 +1257,7 @@ because base station {radioGwID} failed to send PTT", ConsoleColor.Red);
|
|||||||
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Main.ApplicationServer), registrationPort);
|
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Main.ApplicationServer), registrationPort);
|
||||||
client.Connect(serverEndPoint);
|
client.Connect(serverEndPoint);
|
||||||
NetworkStream clientStream = client.GetStream();
|
NetworkStream clientStream = client.GetStream();
|
||||||
YourIPaddress = (client.Client.LocalEndPoint.ToString().Split(':'))[0];
|
YourIPaddress = (client.Client.LocalEndPoint.ToString().Split(":".ToCharArray()))[0];
|
||||||
|
|
||||||
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user