fix Format command twice to get its length
This commit is contained in:
parent
7bb4a6dc66
commit
df1dc2bf15
@ -262,6 +262,7 @@ namespace AppServer
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//get unit system position
|
||||
int unitSC_ID = ((Vehicle_Data)MainForm.VehList[radioID2]).sc_id;
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
@ -271,7 +272,8 @@ namespace AppServer
|
||||
//send radio disable to GW
|
||||
Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan);
|
||||
string test2 = $"#{(int)MessageBusCmds.RadioEnableDisableRequest}#" + dest + "#0#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -349,9 +351,13 @@ namespace AppServer
|
||||
try
|
||||
{
|
||||
string test2 = "#210#1#Can't write GPS data in DB#";
|
||||
if (ex.Message == "AlarmError") test2 = "#210#5#Can't write Alarm data in DB#";
|
||||
else if (ex.Message == "StolenError") test2 = "#210#6#Can't write Stolen data in DB#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
if (ex.Message == "AlarmError")
|
||||
test2 = "#210#5#Can't write Alarm data in DB#";
|
||||
else if (ex.Message == "StolenError")
|
||||
test2 = "#210#6#Can't write Stolen data in DB#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -397,7 +403,10 @@ namespace AppServer
|
||||
{
|
||||
// send callout clear
|
||||
string test = "#178#" + callout.RadioID.ToString() + "#" + callout.Severity + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} ");
|
||||
}
|
||||
}
|
||||
@ -578,7 +587,8 @@ namespace AppServer
|
||||
{
|
||||
//send alarm on message buss
|
||||
test = "#136#" + radioID.ToString() + "#" + tmpresp + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
|
||||
String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString();
|
||||
@ -606,7 +616,10 @@ namespace AppServer
|
||||
tmpX = dbvehs.getSystemPosition(Convert.ToInt32(keyobj));
|
||||
|
||||
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + (String)tmpHashName[keyobj] + "#" + /*"Message from unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " :" +*/ obj2.msgbody + "#" + date + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).Length);
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
Thread.Sleep(100);
|
||||
|
||||
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody}] for unit {(String)tmpHashName[keyobj]} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
|
||||
@ -617,8 +630,9 @@ namespace AppServer
|
||||
if (obj2.sentmsg2 && sendOnMsgBus)
|
||||
{
|
||||
tmpX = dbvehs.getSystemPositionIMEI(radioID);
|
||||
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).Length);
|
||||
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
|
||||
}
|
||||
@ -628,7 +642,8 @@ namespace AppServer
|
||||
{
|
||||
tmpX = dbvehs.getSystemPositionIMEI(radioID);
|
||||
test = "#177#" + radioID.ToString() + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now});
|
||||
Utils.WriteLine($"Zone CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
|
||||
@ -684,14 +699,16 @@ namespace AppServer
|
||||
{
|
||||
//send alarm on message buss
|
||||
string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
|
||||
//send CallOut
|
||||
if(obj2.callout && tmpresp.ToString().Contains("IN "))
|
||||
{
|
||||
string test = "#177#" + radioID + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now });
|
||||
Utils.WriteLine($"Landmark CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} ");
|
||||
@ -760,6 +777,7 @@ namespace AppServer
|
||||
//send alarm on message buss
|
||||
string speed4send = $"{speed}_{speedUnits}";
|
||||
string test = "#135#" + radioID.ToString() + "#" + speed4send + "#";
|
||||
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
}
|
||||
}
|
||||
|
@ -729,8 +729,8 @@ namespace AppServer
|
||||
string message = string.Format("Ticket no. {0} is no longer active!", dec3.delete_ticket_id);
|
||||
string test1 = "#143#" + sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID3 + "#" + message + "#" + 0 + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test1);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
byte[] cmd = Utils.Convert_text_For_multicast("#0.0" + test1);
|
||||
MainForm.udp.Send(cmd, cmd.Length);
|
||||
}
|
||||
//send to email if was sms->email type
|
||||
if (dec3.isEmail)
|
||||
@ -738,12 +738,11 @@ namespace AppServer
|
||||
sendMail(dec3.emailAddr, dec3.messBody, radioID3);
|
||||
}
|
||||
//send ACK back to GW
|
||||
test = "";
|
||||
if (dec3.sqlResp == sqlResponse.done)
|
||||
test = "#232#1#";
|
||||
else
|
||||
test = "#232#0#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test).Length);
|
||||
test = (dec3.sqlResp == sqlResponse.done) ? "#232#1#" : "#232#0#";
|
||||
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID3 + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
if (MainForm.SendPOLLafterSMS)
|
||||
{
|
||||
@ -753,7 +752,7 @@ namespace AppServer
|
||||
string dest = $"0.0.{radioID3}";
|
||||
if (sysPos != null) dest = $"{sysPos.Gw_id}.{sysPos.R_gw_id}.{radioID3}";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
|
||||
dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +215,8 @@ namespace AppServer
|
||||
Thread.Sleep(2000);
|
||||
try
|
||||
{
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#"),
|
||||
Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#").Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
// save all unhandled gps positions
|
||||
MainForm.DumpLocationQueueToFile();
|
||||
@ -240,8 +240,10 @@ namespace AppServer
|
||||
|
||||
Thread.Sleep(2000);
|
||||
try
|
||||
{
|
||||
MainForm.udp?.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#").Length);
|
||||
{
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
MainForm.udp?.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
// save all unhandled gps positions
|
||||
MainForm.DumpLocationQueueToFile();
|
||||
|
@ -107,9 +107,10 @@ namespace AppServer
|
||||
+ Program.cfg.msgBusIP.ToString() + ";" + Program.cfg.msgBusPort + ";" + databaseIP + ";"
|
||||
+ Program.cfg.DB_schema + ";" + Program.cfg.DB_user + ";" + Program.cfg.DB_passwd
|
||||
+ ";" + Program.cfg.DB_port + ";" + Program.cfg.VoicePort + ";"
|
||||
+ audibleAlerts.ToString() + ";" + MainForm.dbAccess.ToString() + ";";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#"), Utils.Convert_text_For_multicast("#0.0#156#"
|
||||
+ command[1].Trim() + "#").Length);
|
||||
+ audibleAlerts.ToString() + ";" + MainForm.dbAccess.ToString() + ";";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
MainForm.RegistrationAnswer = false;
|
||||
Int32 countWait = 0; //maxim 30 = 3 seconds
|
||||
|
@ -171,8 +171,10 @@ namespace AppServer
|
||||
DBrec.addRecording(rec);
|
||||
|
||||
|
||||
test = $"#155#{rec.id}#{rec.hddLocation}#{rec.gwID}#{rec.radioGWID}#{rec.group_cpsId}#{rec.subs_imei}#{rec.startTime}#{rec.endTime}#{rec.typeSD}#{rec.calltype}#{rec.dispatcher_id}#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
test = $"#155#{rec.id}#{rec.hddLocation}#{rec.gwID}#{rec.radioGWID}#{rec.group_cpsId}#{rec.subs_imei}#{rec.startTime}#{rec.endTime}#{rec.typeSD}#{rec.calltype}#{rec.dispatcher_id}#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -90,8 +90,9 @@ namespace SafeMobileLib
|
||||
public void SendOnMsgBuss(string seqID, string test)
|
||||
{
|
||||
if (udpMulticast != null)
|
||||
{
|
||||
udpMulticast.Send(Utils.Convert_text_For_multicast("#" + seqID + test), Utils.Convert_text_For_multicast("#" + seqID + test).Length);
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID + test);
|
||||
udpMulticast.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -835,19 +835,28 @@ namespace SubscriberAndUserManager
|
||||
}
|
||||
|
||||
private void SendBackupListRequest()
|
||||
{
|
||||
if(MainForm.udp != null)
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#53#1#"), Utils.Convert_text_For_multicast("#0.0#53#1#").Length);
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#53#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
private void SendBackupRequest()
|
||||
{
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#51#1#"), Utils.Convert_text_For_multicast("#0.0#51#1#").Length);
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#51#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
private void SendRestoreRequest(string filename)
|
||||
{
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#"), Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#").Length);
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
|
||||
delegate void UpdateList(string fileNames);
|
||||
|
Loading…
Reference in New Issue
Block a user