Compare commits
No commits in common. "master" and "refactor_code1" have entirely different histories.
master
...
refactor_c
@ -262,7 +262,6 @@ namespace AppServer
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//get unit system position
|
||||
int unitSC_ID = ((Vehicle_Data)MainForm.VehList[radioID2]).sc_id;
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
@ -272,8 +271,7 @@ 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#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -351,13 +349,9 @@ 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#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.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#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -403,10 +397,7 @@ namespace AppServer
|
||||
{
|
||||
// send callout clear
|
||||
string test = "#178#" + callout.RadioID.ToString() + "#" + callout.Severity + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} ");
|
||||
}
|
||||
}
|
||||
@ -424,7 +415,7 @@ namespace AppServer
|
||||
{
|
||||
if (MainForm.IsBlacklistedAddress(mailAdr))
|
||||
{
|
||||
Utils.WriteLine($"sendMailGeo : The email '{subj}' was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
|
||||
Utils.WriteLine($"sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist ");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -451,8 +442,7 @@ namespace AppServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.ToString().Contains("timed out") ||
|
||||
ex.ToString().Contains("the client was not authenticated"))
|
||||
if (ex.ToString().Contains("timed out"))
|
||||
MainForm.HandleTimeoutError(mailAdr);
|
||||
|
||||
Utils.WriteLine($"Exception in sendMailGeo: {ex.ToString()}");
|
||||
@ -480,7 +470,7 @@ namespace AppServer
|
||||
|
||||
if (MainForm.IsBlacklistedAddress(mailAdr))
|
||||
{
|
||||
Utils.WriteLine($" sendAlarmMail : The email '{title}' was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
|
||||
Utils.WriteLine($" sendAlarmMail : The email was not sent. Email address '{mailAdr}' is in blacklist ");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -495,8 +485,7 @@ namespace AppServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if ( ex.ToString().Contains("timed out") ||
|
||||
ex.ToString().Contains("the client was not authenticated"))
|
||||
if (ex.ToString().Contains("timed out"))
|
||||
MainForm.HandleTimeoutError(mailAdr);
|
||||
|
||||
Utils.WriteLine("Exception in sendMailAlarm2: {0}" + ex.ToString(), ConsoleColor.Red);
|
||||
@ -587,8 +576,7 @@ namespace AppServer
|
||||
{
|
||||
//send alarm on message buss
|
||||
test = "#136#" + radioID.ToString() + "#" + tmpresp + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
}
|
||||
|
||||
String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString();
|
||||
@ -616,10 +604,7 @@ 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 + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).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)}]");
|
||||
@ -630,9 +615,8 @@ 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() + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
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);
|
||||
|
||||
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
|
||||
}
|
||||
@ -642,8 +626,7 @@ namespace AppServer
|
||||
{
|
||||
tmpX = dbvehs.getSystemPositionIMEI(radioID);
|
||||
test = "#177#" + radioID.ToString() + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).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)}]");
|
||||
@ -699,16 +682,14 @@ namespace AppServer
|
||||
{
|
||||
//send alarm on message buss
|
||||
string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
}
|
||||
|
||||
//send CallOut
|
||||
if(obj2.callout && tmpresp.ToString().Contains("IN "))
|
||||
{
|
||||
string test = "#177#" + radioID + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).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} ");
|
||||
@ -777,7 +758,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -1057,9 +1057,8 @@ namespace AppServer
|
||||
catch (Exception exe)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#AppServer stoped#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#AppServer stoped#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#AppServer stoped#").Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -1106,9 +1105,8 @@ namespace AppServer
|
||||
errorOnScreen = true;
|
||||
error = true;
|
||||
try
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#2#Dongle missing Application server stopped#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#2#Dongle missing Application server stopped#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#2#Dongle missing Application server stopped#").Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -1228,10 +1226,8 @@ namespace AppServer
|
||||
|
||||
|
||||
MainForm.websocketLocationQueue.PostItem(data);
|
||||
|
||||
if (!sendWebsocketTimer.Enabled)
|
||||
if(!sendWebsocketTimer.Enabled)
|
||||
sendWebsocketTimer.Enabled = true;
|
||||
|
||||
if (!checkWebsocketServerStatus.Enabled)
|
||||
checkWebsocketServerStatus.Enabled = true;
|
||||
}
|
||||
@ -1283,12 +1279,10 @@ namespace AppServer
|
||||
}
|
||||
try
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
|
||||
dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
udp.Send(Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#"),
|
||||
Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#").Length);
|
||||
udp.Send(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);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -1303,9 +1297,8 @@ namespace AppServer
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#5#Application server restart#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#5#Application server restart#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#5#Application server restart#").Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
|
@ -606,8 +606,7 @@ namespace AppServer
|
||||
Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan);
|
||||
//send radio disable to GW
|
||||
string test2 = "#150#" + dest + "#0#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -727,10 +726,8 @@ namespace AppServer
|
||||
int unitSC_ID = DBvehInfo.getSCID(radioID3.ToString());
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
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[] cmd = Utils.Convert_text_For_multicast("#0.0" + test1);
|
||||
MainForm.udp.Send(cmd, cmd.Length);
|
||||
string test1 = "#143#" + sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID3 + "#" + message + "#" + 0 + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0"+test1), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0"+test1).Length);
|
||||
}
|
||||
//send to email if was sms->email type
|
||||
if (dec3.isEmail)
|
||||
@ -738,11 +735,12 @@ namespace AppServer
|
||||
sendMail(dec3.emailAddr, dec3.messBody, radioID3);
|
||||
}
|
||||
//send ACK back to GW
|
||||
test = (dec3.sqlResp == sqlResponse.done) ? "#232#1#" : "#232#0#";
|
||||
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID3 + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
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);
|
||||
|
||||
if (MainForm.SendPOLLafterSMS)
|
||||
{
|
||||
@ -751,9 +749,8 @@ namespace AppServer
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
string dest = $"0.0.{radioID3}";
|
||||
if (sysPos != null) dest = $"{sysPos.Gw_id}.{sysPos.R_gw_id}.{radioID3}";
|
||||
|
||||
dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#").Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -930,10 +927,8 @@ namespace AppServer
|
||||
DBtel.AddTelemetryHist(radioID, tObj.Id, 1);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
SM.Debug("Sending telemetry alarm to SD; digital:" + tObj.DigitalNr);
|
||||
test = $"#140#{radioID}#{tObj.Name}#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
test = $"#140#{radioID}#{tObj.Name}#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0"+test).Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -943,9 +938,8 @@ namespace AppServer
|
||||
}
|
||||
}
|
||||
if (IhaveData)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#").Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1038,9 +1032,8 @@ namespace AppServer
|
||||
object[] param = { dirBackup, posgresPath };
|
||||
bgWorkerDBbackup.RunWorkerAsync(param);
|
||||
|
||||
//send ACK back to SUM
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#71#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
//send ACK back to SUM
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#71#1#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#71#1#").Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1068,14 +1061,12 @@ namespace AppServer
|
||||
object[] param2 = { completeFileName, posgresPath };
|
||||
bgWorkerDBrestore.RunWorkerAsync(param2);
|
||||
//send ACK back to SUM
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#72#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#72#1#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#72#1#").Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
SM.Debug("DB restored failed !!!" + "File " + completeFileName + " missing!!!");
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#62#0#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
SM.Debug("DB restored failed !!!" + "File " + completeFileName + " missing!!!");
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#62#0#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#62#0#").Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1147,9 +1138,7 @@ namespace AppServer
|
||||
//send broadcast messages I'm back in business
|
||||
Utils.WriteLine(string.Format("receive 500 from radio: Gateway {0} is ON", ((RadioGateway)MainForm.RadioGWHash[key]).Name), ConsoleColor.Green);
|
||||
string test1 = "#501#" + tempArr[4] + "#" + tempArr[5] + "#" + "ON#" + ((RadioGateway)MainForm.RadioGWHash[key]).Name + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID4 + test1);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID4 + test1), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID4 + test1).Length);
|
||||
}
|
||||
((RadioGateway)MainForm.RadioGWHash[key]).Alive = true;
|
||||
((RadioGateway)MainForm.RadioGWHash[key]).LastUpdate = DateTime.UtcNow;
|
||||
@ -1176,9 +1165,7 @@ namespace AppServer
|
||||
string status = ((RadioGateway)(entry.Value)).Alive ? "ON" : "OFF";
|
||||
Utils.WriteLine(string.Format("Response for SD request: Gateway {0} is {1}", ((RadioGateway)(entry.Value)).Name, status), status == "ON" ? ConsoleColor.Green : ConsoleColor.Red);
|
||||
string test1 = "#501#" + ((RadioGateway)(entry.Value)).Gw_id + "#" + ((RadioGateway)(entry.Value)).Id + "#" + status + "#" + ((RadioGateway)(entry.Value)).Name + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + "0.0" + test1);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test1), SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test1).Length);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1301,14 +1288,11 @@ namespace AppServer
|
||||
if (sysPos != null) dest = sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID.ToString();
|
||||
|
||||
String test = "#154#" + dest + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqId + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test).Length);
|
||||
|
||||
//send emergency alarm to SD
|
||||
test = "#134#" + radioID.ToString() + "#" + emergencyType;
|
||||
dataToSend = Utils.Convert_text_For_multicast("#" + seqId + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test).Length);
|
||||
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID]).curentStatus = Status_for_tab.EMERG;
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID]).lastArsTime = DateTime.Now;
|
||||
@ -1389,9 +1373,7 @@ namespace AppServer
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition(msg.sc_id_dest);
|
||||
//string test = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id+"."+msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#";
|
||||
string test = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test).Length);
|
||||
}
|
||||
else
|
||||
SM.Debug("message will be sent at a later time - schedule: " + msg.sched_timeGMT + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format());
|
||||
@ -1423,8 +1405,7 @@ namespace AppServer
|
||||
string test = "";
|
||||
String cmdok = "";
|
||||
var subsBlackList = new List<int> { (int)Status_for_tab.OFF, (int)Status_for_tab.DISABLE, (int)Status_for_tab.MADEOFF };
|
||||
byte[] dataToSend = null;
|
||||
|
||||
|
||||
foreach (smsmessage msg in smss)
|
||||
{
|
||||
long sc_id = msg.sc_id_dest;
|
||||
@ -1435,10 +1416,8 @@ namespace AppServer
|
||||
{
|
||||
if (SysPosList[sc_id]!=null)
|
||||
test = "#143#" + ((UnitSysPosition)SysPosList[sc_id]).Gw_id + "." + ((UnitSysPosition)SysPosList[sc_id]).R_gw_id + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
else test = "#143#" + "0.0" + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
|
||||
dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
else test = "#143#" + "0.0" + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test).Length);
|
||||
}
|
||||
else
|
||||
SM.Debug("message will be sent at a later time - schedule: " + msg.sched_timeGMT + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format());
|
||||
@ -1450,9 +1429,8 @@ namespace AppServer
|
||||
{
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition_for_group(msg.imei_dest);
|
||||
|
||||
test = "#145#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + msg.sc_id_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#";
|
||||
dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
test = "#145#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + msg.sc_id_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test).Length);
|
||||
}
|
||||
|
||||
Utils.WriteLine($"Undelivered {undeliveredSMS} private messages and {smss.Count} group messages", ConsoleColor.White);
|
||||
@ -1468,19 +1446,19 @@ namespace AppServer
|
||||
{
|
||||
//Check4ExpiredTickets
|
||||
List<JobTickets> jtlist = new List<JobTickets>();
|
||||
|
||||
string list_of_id_text = "";
|
||||
try
|
||||
{
|
||||
DBTicketingManager DBT = new DBTicketingManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
List<Int32> ExpiredTicketsIdList = DBT.updateTicketExpireDate(DateTo70Format(DateTime.UtcNow));
|
||||
if(ExpiredTicketsIdList.Count>0)
|
||||
{
|
||||
|
||||
// get comma separated list
|
||||
string list_of_id_text = string.Join<string>(",", ExpiredTicketsIdList.Select(x => $"{x}"));
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast($"#0.0#251#{list_of_id_text}#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
foreach(Int32 id in ExpiredTicketsIdList)
|
||||
{
|
||||
list_of_id_text += id + ",";
|
||||
}
|
||||
list_of_id_text = list_of_id_text.Substring(0, list_of_id_text.Length - 1);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#251#" + list_of_id_text + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#251#" + list_of_id_text + "#").Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1517,11 +1495,8 @@ namespace AppServer
|
||||
string message = string.Format("You need to finish job no.{0}, {1} in 10 minutes!", ticket.Ticket_id, ticket.Name);
|
||||
string head = "#143#0.0." + ticket.Imei + "#";
|
||||
if (SysPosList[ticket.sc_id] != null) head = "#143#" + ((UnitSysPosition)SysPosList[ticket.sc_id]).Gw_id + "." + ((UnitSysPosition)SysPosList[ticket.sc_id]).R_gw_id + "." + ticket.Imei + "#";
|
||||
string test = head + message + "#" + 0 + "#";
|
||||
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + ticket.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
string test = head + message + "#" + 0 + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test).Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1546,9 +1521,8 @@ namespace AppServer
|
||||
string head = "#143#0.0." + ticket.Imei + "#";
|
||||
if (SysPosList[ticket.sc_id] != null) head = "#143#" + ((UnitSysPosition)SysPosList[ticket.sc_id]).Gw_id + "." + ((UnitSysPosition)SysPosList[ticket.sc_id]).R_gw_id + "." + ticket.Imei + "#";
|
||||
|
||||
string test = head + ticket.Name + "#" + 0 + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + ticket.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
string test = head + ticket.Name + "#" + 0 + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test).Length);
|
||||
}
|
||||
else
|
||||
SM.Debug("ticket will be sent at a later time - schedule: " + ticket.sched_timegmt + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format());
|
||||
@ -1579,10 +1553,8 @@ namespace AppServer
|
||||
{
|
||||
if (DateTime.Now.ToUniversalTime() > item.Timegmt.AddSeconds(item.ArsInterval + 10))// added 10 seconds; marja erroare
|
||||
{
|
||||
SM.Debug("Unit:" + item.Imei + " ARS interval expired. Marking unit as OFF");
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#130#" + item.Imei + "#OFF#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
SM.Debug("Unit:" + item.Imei + " ARS interval expired. Marking unit as OFF");
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#130#" + item.Imei + "#OFF#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#130#" + item.Imei + "#OFF#").Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1628,9 +1600,7 @@ namespace AppServer
|
||||
|
||||
|
||||
string test = "#501#" + ((RadioGateway)(entry.Value)).Gw_id + "#" + ((RadioGateway)(entry.Value)).Id + "#" + "OFF" + "#" + ((RadioGateway)(entry.Value)).Name + "#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + "0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test).Length);
|
||||
((RadioGateway)(entry.Value)).Alive = false;
|
||||
}
|
||||
}
|
||||
@ -1715,9 +1685,7 @@ namespace AppServer
|
||||
public static void PushStatus(String IMEI,Status_for_tab stat)
|
||||
{
|
||||
Utils.WriteLine("Send PushStatus:" + stat+" Imei:"+IMEI,ConsoleColor.Yellow);
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#153#" + IMEI + "#" + (Int32)stat + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#153#" + IMEI + "#" + (Int32)stat + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#153#" + IMEI + "#" + (Int32)stat + "#").Length);
|
||||
}
|
||||
|
||||
|
||||
@ -2115,9 +2083,8 @@ namespace AppServer
|
||||
{
|
||||
messageOnScreen = true;
|
||||
try
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#Application server database connection failed#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#Application server database connection failed#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#3#Application server database connection failed#").Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -2298,7 +2265,6 @@ namespace AppServer
|
||||
if (Program.cfg.enableEmailService)
|
||||
{
|
||||
SM.Debug(new string[] { "Checking mail at:" + DateTime.Now.ToString(), "For " + Program.cfg.emailAddress.ToString() + " on " + Program.cfg.pop3Server.ToString() });
|
||||
|
||||
emailHT = dbsubsoperManage.getAll_imei_sc_id("ByMail");
|
||||
if (emailHT.Count > 0)
|
||||
{
|
||||
@ -2322,23 +2288,19 @@ namespace AppServer
|
||||
DB.SetLastEmailTime(sslServer.getLastEmailTime());
|
||||
}
|
||||
|
||||
|
||||
DBsmsManager DBsms = new DBsmsManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
DBvehiclesManager dbvehs = new DBvehiclesManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
|
||||
|
||||
foreach (EmailtoSMS obj in EmailList)
|
||||
{
|
||||
String seqID = "0." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Millisecond.ToString();
|
||||
|
||||
SM.Debug(new string[] { "-----START OK----",
|
||||
"From: " + obj.from,
|
||||
"ID: " + obj.id,
|
||||
"Text: " + obj.text});
|
||||
SM.Debug(new string[] {"-----START OK----",
|
||||
"From: " + obj.from,
|
||||
"ID: " + obj.id,
|
||||
"Text: " + obj.text});
|
||||
try
|
||||
{
|
||||
// app server idx =0
|
||||
|
||||
DBsmsManager DB = new DBsmsManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
//bigu code remove # from text and also replace "'"
|
||||
try
|
||||
{
|
||||
@ -2349,15 +2311,13 @@ namespace AppServer
|
||||
{
|
||||
SM.Debug("Error on converting email:" + ex.ToString());
|
||||
}
|
||||
|
||||
//end bigu code
|
||||
if (!obj.is_group) DBsms.insert_sms_received(obj.id, obj.text, 7, obj.from, seqID);
|
||||
if (!obj.is_group) DB.insert_sms_received(obj.id, obj.text, 7, obj.from, seqID);
|
||||
if (obj.is_sierra)
|
||||
{
|
||||
if (emailHT.Contains(obj.from))
|
||||
{
|
||||
SM.Debug("Email received <<" + obj.text + ">> from address: " + obj.from);
|
||||
|
||||
seqID = "1." + Utils.GetSecondsLocalFromDT(DateTime.Now).ToString() + DateTime.Now.Millisecond.ToString();
|
||||
string test = "#132#" + ((SW_Subscriber)emailHT[obj.from]).imei + "#" + obj.text + "#hyt#";
|
||||
String cmdok = "#" + seqID + test; Int32 tmp = cmdok.Length + 1; tmp += tmp.ToString().Length; cmdok = "#" + tmp.ToString() + cmdok;
|
||||
@ -2365,7 +2325,6 @@ namespace AppServer
|
||||
byte[] buf = enc.GetBytes(cmdok);
|
||||
//send to messagebus
|
||||
MainForm.udp.Send(buf, buf.Length);
|
||||
|
||||
SM.Debug("Email thread successfully sent data to message bus");
|
||||
}
|
||||
}
|
||||
@ -2380,36 +2339,26 @@ namespace AppServer
|
||||
obj.text = obj.text.Remove(140 - 3 - obj.from.Length) + " [" + obj.from + "]";
|
||||
else
|
||||
obj.text = obj.text + " [" + obj.from + "]";
|
||||
|
||||
//send SMS on message buss
|
||||
if (!obj.is_sierra)
|
||||
{
|
||||
|
||||
if (dbvehs != null)
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition(dbvehs.getSCID(obj.id));
|
||||
|
||||
string msg = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + obj.id + "#" + obj.text + "#" + (DateTime.Now.GetSecondsLocalFromDT()) + "#";
|
||||
if (obj.is_group) msg = "#144#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + obj.id + "#" + obj.text + "#" + (DateTime.Now.GetSecondsLocalFromDT()) + "#";
|
||||
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + msg), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + msg).Length);
|
||||
|
||||
if (obj.is_group)
|
||||
{
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition(dbvehs.getSCID(obj.id));
|
||||
|
||||
string cmd = $"{tmpX.Gw_id}.{tmpX.R_gw_id}.{obj.id}#{obj.text}#{DateTime.Now.GetSecondsLocalFromDT()}#";
|
||||
string code = (obj.is_group) ? "#144#" : "#143#" ;
|
||||
byte[] msg = Utils.Convert_text_For_multicast("#0.0" + code + cmd);
|
||||
|
||||
if (msg != null && msg.Length > 0)
|
||||
MainForm.udp.Send(msg, msg.Length);
|
||||
|
||||
if (obj.is_group)
|
||||
Int32 oldgatewayID = 0;
|
||||
foreach (RadioGateway obj2 in RadioListIP)
|
||||
{
|
||||
Int32 oldgatewayID = 0;
|
||||
foreach (RadioGateway obj2 in RadioListIP)
|
||||
if (oldgatewayID != obj2.Gw_id)
|
||||
{
|
||||
if (oldgatewayID != obj2.Gw_id)
|
||||
{
|
||||
oldgatewayID = (Int32)obj2.Gw_id;
|
||||
cmd = $"#144#{obj2.Gw_id}.{obj2.Id}.{obj.id}#{obj.text}#{DateTime.Now.GetSecondsLocalFromDT()}#";
|
||||
byte[] msg2 = Utils.Convert_text_For_multicast("#1." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Ticks.ToString() + cmd);
|
||||
|
||||
if( msg2 != null && msg2.Length > 0)
|
||||
MainForm.udp.Send(msg2, msg2.Length);
|
||||
}
|
||||
oldgatewayID = (Int32)obj2.Gw_id;
|
||||
string msg2 = "#144#" + obj2.Gw_id + "." + obj2.Id + "." + obj.id + "#" + obj.text + "#" + (DateTime.Now.GetSecondsLocalFromDT()) + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#1." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Ticks.ToString() + msg2), SafeMobileLib.Utils.Convert_text_For_multicast("#1." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Ticks.ToString() + msg2).Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2438,7 +2387,7 @@ namespace AppServer
|
||||
|
||||
if (MainForm.IsBlacklistedAddress(mailAdr))
|
||||
{
|
||||
Utils.WriteLine($"sendMail : The email was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
|
||||
Utils.WriteLine($"sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist ");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2460,8 +2409,7 @@ namespace AppServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.ToString().Contains("timed out") ||
|
||||
ex.ToString().Contains("the client was not authenticated"))
|
||||
if (ex.ToString().Contains("timed out"))
|
||||
MainForm.HandleTimeoutError(mailAdr);
|
||||
|
||||
Utils.WriteLine("Exception in sendMail: " + ex.ToString(), ConsoleColor.Red);
|
||||
@ -2489,7 +2437,7 @@ namespace AppServer
|
||||
|
||||
if (MainForm.IsBlacklistedAddress(mailAdr))
|
||||
{
|
||||
Utils.WriteLine($"sendMail_SW : The email was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
|
||||
Utils.WriteLine($"sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist ");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2507,8 +2455,7 @@ namespace AppServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.ToString().Contains("timed out") ||
|
||||
ex.ToString().Contains("the client was not authenticated"))
|
||||
if (ex.ToString().Contains("timed out"))
|
||||
MainForm.HandleTimeoutError(mailAdr);
|
||||
|
||||
Utils.WriteLine("Exception in sendMail Sierra Wireless Gateway: " + ex.ToString(), ConsoleColor.Red);
|
||||
@ -2553,9 +2500,8 @@ namespace AppServer
|
||||
{
|
||||
//send emergency alarm to SD
|
||||
//send ACK back to GW
|
||||
string code = (backupDOne == true) ? "#61#1#" : "#61#0#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + code);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
string test = (backupDOne == true) ? "#61#1#" : "#61#0#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -2582,10 +2528,8 @@ namespace AppServer
|
||||
{
|
||||
//send emergency alarm to SD
|
||||
//send ACK back to GW
|
||||
string code = (restoreDOne == true) ? "#62#1#" : "#252#0#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + code);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
string test = (restoreDOne == true) ? "#62#1#" : "#252#0#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -215,8 +215,8 @@ namespace AppServer
|
||||
Thread.Sleep(2000);
|
||||
try
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
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);
|
||||
|
||||
// save all unhandled gps positions
|
||||
MainForm.DumpLocationQueueToFile();
|
||||
@ -240,10 +240,8 @@ namespace AppServer
|
||||
|
||||
Thread.Sleep(2000);
|
||||
try
|
||||
{
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
MainForm.udp?.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
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);
|
||||
|
||||
// save all unhandled gps positions
|
||||
MainForm.DumpLocationQueueToFile();
|
||||
|
@ -107,10 +107,9 @@ 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() + ";";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
+ 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);
|
||||
|
||||
MainForm.RegistrationAnswer = false;
|
||||
Int32 countWait = 0; //maxim 30 = 3 seconds
|
||||
|
@ -171,10 +171,8 @@ 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}#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.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}#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -452,36 +452,34 @@ namespace SafeMobileLib
|
||||
|
||||
BatchHistoryData batchHistObj = null;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
|
||||
lat = Convert.ToDouble(dr["lat"]);
|
||||
lng = Convert.ToDouble(dr["lng"]);
|
||||
timegmt = Convert.ToInt32(dr["timegmt"]);
|
||||
|
||||
batchHistObj = new BatchHistoryData
|
||||
{
|
||||
batchHistObj = new BatchHistoryData
|
||||
{
|
||||
|
||||
Department = dr["department"].ToString(),
|
||||
Unit = dr["unit"].ToString(),
|
||||
Location = ((getAddress && dr["address"] != DBNull.Value) ? dr["address"].ToString() : "LAT:" + Math.Round(lat, 5).ToString() + " , LNG:" + Math.Round(lat, 5).ToString()),
|
||||
Speed = (isInMile) ? ((int)(Convert.ToInt32(dr["speed"]) * 0.621371192)).ToString() : Convert.ToInt32(dr["speed"]).ToString(),
|
||||
Lat = lat,
|
||||
Lng = lng,
|
||||
Address = string.Empty,
|
||||
Address = dr["address"].ToString(),
|
||||
Time = timegmt.TimeOfDayHHMMSSLocal(!is24hours),
|
||||
Date = timegmt.GetDTLocalFromSeconds().Date.ToShortDateString()
|
||||
|
||||
};
|
||||
|
||||
if (getAddress)
|
||||
{
|
||||
batchHistObj.Location = dr["address"].ToString();
|
||||
batchHistObj.Address = dr["address"].ToString();
|
||||
}
|
||||
else
|
||||
batchHistObj.Location = "LAT:" + Math.Round(lat, 5).ToString() + " , LNG:" + Math.Round(lat, 5).ToString();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -25,8 +25,6 @@ namespace SafeMobileLib
|
||||
private bool isSSL = true;
|
||||
private Int64 lastEmailTime = 0;
|
||||
private Int64 startEmailServiceTime = 0;
|
||||
public static Dictionary<string, int> blackList = new Dictionary<string, int>();
|
||||
public const int MAX_ATTEMPTS = 100;
|
||||
|
||||
// blank constructor in order to be used in Email Checking
|
||||
public EmailServerSSL()
|
||||
@ -380,46 +378,11 @@ namespace SafeMobileLib
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static void HandleBlacklist(string key)
|
||||
{
|
||||
// add key to backlist
|
||||
if (!blackList.ContainsKey(key))
|
||||
blackList.Add(key, MAX_ATTEMPTS);
|
||||
}
|
||||
|
||||
public static bool IsBlacklisted(string key)
|
||||
{
|
||||
|
||||
if (!blackList.ContainsKey(key))
|
||||
return false;
|
||||
|
||||
// avoid to connect to pop3 MAX_ATTEMPTS times => give another chance to try to connect to pop 3 when count = 0
|
||||
int count = blackList[key];
|
||||
if (count == 0)
|
||||
{
|
||||
blackList.Remove(key);
|
||||
return false;
|
||||
}
|
||||
|
||||
blackList[key] = count - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Connect to the Pop Server in order to be used to get the emails
|
||||
/// </summary>
|
||||
private void ConnectEmailPopServer()
|
||||
{
|
||||
if (IsBlacklisted(serverIP))
|
||||
{
|
||||
|
||||
Utils.WriteLine($"ConnectEmailPopServer : Could not conenct to the pop server '{serverIP}'. The pop server '{serverIP}' is in blacklist count = {blackList[serverIP]}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
ConnectAsync();
|
||||
@ -430,17 +393,8 @@ namespace SafeMobileLib
|
||||
|
||||
private void ConnectAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (popClient != null && popClient.Connected)
|
||||
popClient.Disconnect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
|
||||
}
|
||||
if (popClient != null && popClient.Connected)
|
||||
popClient.Disconnect();
|
||||
|
||||
popClient = null;
|
||||
popClient = new Pop3Client();
|
||||
@ -458,25 +412,18 @@ namespace SafeMobileLib
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("PopServerNotFoundException -> " + ee.ToString());
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
HandleBlacklist(serverIP);
|
||||
|
||||
}
|
||||
catch (InvalidLoginException e)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("InvalidLoginException -> " + e.ToString());
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
HandleBlacklist(serverIP);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("ConnectEmailPopServer -> " + ex.ToString());
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
HandleBlacklist(serverIP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,8 @@ namespace SafeMobileLib
|
||||
public void SendOnMsgBuss(string seqID, string test)
|
||||
{
|
||||
if (udpMulticast != null)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID + test);
|
||||
udpMulticast.Send(dataToSend, dataToSend.Length);
|
||||
{
|
||||
udpMulticast.Send(Utils.Convert_text_For_multicast("#" + seqID + test), Utils.Convert_text_For_multicast("#" + seqID + test).Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -42,28 +42,36 @@ namespace SafeMobileLib
|
||||
recv = s.Receive(b);
|
||||
else
|
||||
break;//break if socket == null
|
||||
|
||||
if (recv == 0)
|
||||
continue;//continue if return nr bytes == 0
|
||||
|
||||
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
if (OnNewDataRecv != null)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
|
||||
byte[] decByte = Encrypted ? Encryption.Decrypt(tmp, EncryptionAlgorithm.Des64) : tmp;
|
||||
|
||||
// trigger event
|
||||
OnNewDataRecv(decByte, decByte.Length);
|
||||
}
|
||||
|
||||
byte[] decByte = Encrypted ? Encryption.Decrypt(tmp, EncryptionAlgorithm.Des64) : tmp;
|
||||
|
||||
// trigger event
|
||||
if (OnNewDataRecv != null)
|
||||
OnNewDataRecv(decByte, decByte.Length);
|
||||
|
||||
|
||||
// trigger event
|
||||
if (OnNewDataReceived != null)
|
||||
{
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
|
||||
byte[] decByte = Encrypted ? Encryption.Decrypt(tmp, EncryptionAlgorithm.Des64) : tmp;
|
||||
|
||||
// trigger event
|
||||
OnNewDataReceived(mcastGroup, decByte, decByte.Length);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (s == null)
|
||||
@ -100,19 +108,27 @@ namespace SafeMobileLib
|
||||
byte[] b = new byte[65507];
|
||||
Thread.Sleep(1);
|
||||
int recv = s.Receive(b);
|
||||
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
if (OnNewDataRecv != null)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
if (this.OnNewDataRecv != null)
|
||||
this.OnNewDataRecv(tmp, tmp.Length);
|
||||
}
|
||||
|
||||
if (this.OnNewDataRecv != null)
|
||||
this.OnNewDataRecv(tmp, tmp.Length);
|
||||
|
||||
if (this.OnNewDataReceived != null)
|
||||
this.OnNewDataReceived(mcastGroup, tmp, tmp.Length);
|
||||
|
||||
if (OnNewDataReceived != null)
|
||||
{
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
if (this.OnNewDataReceived != null)
|
||||
this.OnNewDataReceived(mcastGroup, tmp, tmp.Length);
|
||||
}
|
||||
|
||||
if (s == null)
|
||||
{
|
||||
@ -201,17 +217,16 @@ namespace SafeMobileLib
|
||||
IPEndPoint ipep = new IPEndPoint(myIP, port);
|
||||
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
|
||||
s.Bind(ipep);
|
||||
|
||||
IPAddress ip = IPAddress.Parse(mcastGroup);
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, myIP));
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
s.SetSocketOption(SocketOptionLevel.IP,
|
||||
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
listenThread = new Thread(new ThreadStart(Listen));
|
||||
listenThread.IsBackground = true;
|
||||
}
|
||||
|
||||
if (listenThread != null)
|
||||
listenThread.Start();
|
||||
|
||||
ret = true;
|
||||
|
||||
Utils.WriteLine($"++++++++++++++++++++++++++++++++++++++++++\nUdpMulticast bind on {mcastGroup}:{port} Ethernet: {myIP}\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
@ -228,14 +243,12 @@ namespace SafeMobileLib
|
||||
bool ret = false;
|
||||
working = true;
|
||||
useThreadPool = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
}
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port));
|
||||
@ -244,7 +257,8 @@ namespace SafeMobileLib
|
||||
s.Bind(ipep);
|
||||
IPAddress ip = IPAddress.Parse(mcastGroup);
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
s.SetSocketOption(SocketOptionLevel.IP,
|
||||
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(Listen_pool));
|
||||
|
||||
@ -268,7 +282,6 @@ namespace SafeMobileLib
|
||||
{
|
||||
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
}
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port));
|
||||
@ -277,14 +290,13 @@ namespace SafeMobileLib
|
||||
s.Bind(ipep);
|
||||
IPAddress ip = IPAddress.Parse(mcastGroup);
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
s.SetSocketOption(SocketOptionLevel.IP,
|
||||
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
listenThread = new Thread(new ThreadStart(Listen_Decoded));
|
||||
listenThread.IsBackground = true;
|
||||
}
|
||||
|
||||
if (listenThread != null)
|
||||
listenThread.Start();
|
||||
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -441,10 +441,8 @@ namespace SafeMobileLib
|
||||
Int32 tmp = cmdok.Length + 1;
|
||||
tmp += tmp.ToString().Length;
|
||||
String TMPcmdok = "#" + tmp.ToString() + cmdok;
|
||||
if (tmp != TMPcmdok.Length)
|
||||
cmdok = "#" + TMPcmdok.Length + cmdok;
|
||||
else
|
||||
cmdok = TMPcmdok;
|
||||
if (tmp != TMPcmdok.Length) cmdok = "#" + TMPcmdok.Length + cmdok;
|
||||
else cmdok = TMPcmdok;
|
||||
|
||||
System.Text.Encoding enc = System.Text.Encoding.ASCII;
|
||||
byte[] buf = enc.GetBytes(cmdok);
|
||||
|
@ -835,28 +835,19 @@ namespace SubscriberAndUserManager
|
||||
}
|
||||
|
||||
private void SendBackupListRequest()
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#53#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
private void SendBackupRequest()
|
||||
{
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#51#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#51#1#"), Utils.Convert_text_For_multicast("#0.0#51#1#").Length);
|
||||
}
|
||||
private void SendRestoreRequest(string filename)
|
||||
{
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#"), Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#").Length);
|
||||
}
|
||||
|
||||
delegate void UpdateList(string fileNames);
|
||||
|
@ -112,9 +112,7 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="prebuild.sh" />
|
||||
<None Include="RunMessagesPartitioning.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="RunMessagesPartitioning.bat" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
|
||||
@ -146,9 +144,7 @@
|
||||
<Content Include="7toLatest7.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="call_messages_partitioning.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="call_messages_partitioning.sql" />
|
||||
<Content Include="CreateMissingForeignKeys.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@ -158,12 +154,8 @@
|
||||
<Content Include="CreateMissingPrimaryKeys.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="generate_partitioning_of_an_existing_table_by_date_unix_time.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="get_query_partitioning_of_an_existing_table_by_date_unix_time.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="generate_partitioning_of_an_existing_table_by_date_unix_time.sql" />
|
||||
<Content Include="get_query_partitioning_of_an_existing_table_by_date_unix_time.sql" />
|
||||
<Content Include="NewFields.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
Loading…
Reference in New Issue
Block a user