Compare commits

..

26 Commits

Author SHA1 Message Date
74fa47daa6 Merge pull request 'add_scripts_for_messages_partitioning' (#15) from add_scripts_for_messages_partitiong into master
Reviewed-on: #15
2024-07-05 15:40:32 +00:00
93bfc46d85 add_scripts_for_messages_partitioning 2024-07-05 18:39:46 +03:00
16647ca6c4 Merge pull request 'fix_BatchHistory_report' (#14) from fix_BatchHistory_report into master
Reviewed-on: #14
2024-07-05 15:37:56 +00:00
f70027424c fix_BatchHistory_report 2024-07-05 18:37:18 +03:00
8e1e233826 Merge pull request 'fix Format command twice to get its length' (#13) from refactor_code3 into master
Reviewed-on: #13
2024-07-01 14:39:43 +00:00
df1dc2bf15 fix Format command twice to get its length 2024-07-01 17:39:01 +03:00
7bb4a6dc66 Merge pull request 'refactor code' (#12) from refactor_code2 into master
Reviewed-on: #12
2024-06-27 10:18:13 +00:00
2e5267b6f7 refactor code 2024-06-27 13:17:09 +03:00
6273746693 Merge pull request 'pop server could not connect => add it to black list' (#11) from blacklist_popServer into master
Reviewed-on: #11
2024-06-25 11:01:33 +00:00
377c21c338 pop server could not connect => add it to black list 2024-06-25 14:00:32 +03:00
65a08de6d8 Merge pull request 'give_one_more_chance_to_send_email' (#10) from give_one_more_chance_to_send_email into master
Reviewed-on: #10
2024-06-21 13:27:50 +00:00
44e89bfb87 give_one_more_chance_to_send_email 2024-06-21 16:27:20 +03:00
ccaa256960 Merge pull request 'refactor code' (#9) from refactor_code1 into master
Reviewed-on: #9
2024-06-20 16:05:21 +00:00
126aba5ee5 refactor code 2024-06-20 19:03:35 +03:00
5291e2cb5b Merge pull request 'take gateway from localhost' (#8) from fix_Take_gateway_from_localhost into master
Reviewed-on: #8
2024-06-17 14:59:12 +00:00
df0e2e1796 take gateway from localhost 2024-06-17 17:58:15 +03:00
6737c17c27 Merge pull request 'remove email addresses from blacklist after MAX_ATTEMPTS to give them one more chance' (#7) from handle_email_address_in_blacklist into master
Reviewed-on: #7
2024-06-13 11:04:28 +00:00
4f3c7b5870 remove email addresses from blacklist after MAX_ATTEMPTS to give them one more chance 2024-06-13 14:03:34 +03:00
13f25867b8 Merge pull request 'avoid flooding logs if the email sending failed' (#6) from avoid_flooding_logs_if_failed_sending_email into master
Reviewed-on: #6
2024-06-12 15:19:27 +00:00
f765fe48b9 avoid flooding logs if the email sending failed 2024-06-12 18:18:20 +03:00
61fa677598 Merge pull request 'refactor code' (#5) from refactor_code into master
Reviewed-on: #5
2024-06-07 13:35:46 +00:00
e1c315402f refactor code 2024-06-07 16:20:57 +03:00
23cfa40272 Merge pull request 'change_version_to_8_2_0_10898' (#4) from change_version_to_8_2_0_10898 into master
Reviewed-on: #4
2024-06-06 12:56:45 +00:00
a69dc4c6ef remove unwanted file 2024-06-06 15:55:15 +03:00
0253478eac change_version_to_8_2_0_10898 2024-06-06 15:41:15 +03:00
e973feb124 Merge pull request 'refactor_AppServer_LocationThread' (#3) from refactor_AppServer_LocationThread into master
Reviewed-on: #3
2024-06-06 10:43:15 +00:00
57 changed files with 933 additions and 620 deletions

View File

@ -22,6 +22,7 @@ namespace AppServer
private volatile DBsubsOperationManager dbsubsoperManage; private volatile DBsubsOperationManager dbsubsoperManage;
private volatile DBvehiclesManager dbvehs; private volatile DBvehiclesManager dbvehs;
private DBvehiclesManager DBvehInfo; private DBvehiclesManager DBvehInfo;
public static volatile Int32 LocationCheckQueuesCount = 0; public static volatile Int32 LocationCheckQueuesCount = 0;
Int64 count = 0; Int64 count = 0;
@ -184,12 +185,12 @@ namespace AppServer
{ {
Vehicle_Data v_data = (Vehicle_Data)MainForm.VehList[radioID2.ToString()]; Vehicle_Data v_data = (Vehicle_Data)MainForm.VehList[radioID2.ToString()];
Alarm alarm = v_data.alm; Alarm alarm = v_data.alm;
bool zone = false;
bool landMark = false;
String SpeedProccess = "";
if (alarm.Zone != "") zone = true;
if (alarm.Landmark != "") landMark = true;
bool zone = (alarm.Zone != "") ;
bool landMark = (alarm.Landmark != "") ;
String SpeedProccess = "";
if (zone || landMark) if (zone || landMark)
{ {
SpeedProccess = processZoneAlarm(radioID2, dec2.cell, zone, landMark, alarm.Email, !prevGps); SpeedProccess = processZoneAlarm(radioID2, dec2.cell, zone, landMark, alarm.Email, !prevGps);
@ -256,11 +257,12 @@ namespace AppServer
{ {
try try
{ {
// skip sending enable/disable if the unit is not in the vehicles lis t // skip sending enable/disable if the unit is not in the vehicles list
if (!MainForm.VehList.ContainsKey(radioID2)) if (!MainForm.VehList.ContainsKey(radioID2))
{ {
continue; continue;
} }
//get unit system position //get unit system position
int unitSC_ID = ((Vehicle_Data)MainForm.VehList[radioID2]).sc_id; int unitSC_ID = ((Vehicle_Data)MainForm.VehList[radioID2]).sc_id;
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID); UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
@ -270,7 +272,8 @@ namespace AppServer
//send radio disable to GW //send radio disable to GW
Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan); Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan);
string test2 = $"#{(int)MessageBusCmds.RadioEnableDisableRequest}#" + dest + "#0#"; 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) catch (Exception ex)
{ {
@ -348,9 +351,13 @@ namespace AppServer
try try
{ {
string test2 = "#210#1#Can't write GPS data in DB#"; 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#"; if (ex.Message == "AlarmError")
else if (ex.Message == "StolenError") test2 = "#210#6#Can't write Stolen data in DB#"; test2 = "#210#5#Can't write Alarm data in DB#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test2), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test2).Length); 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) catch (Exception ex2)
{ {
@ -396,7 +403,10 @@ namespace AppServer
{ {
// send callout clear // send callout clear
string test = "#178#" + callout.RadioID.ToString() + "#" + callout.Severity + "#"; string test = "#178#" + callout.RadioID.ToString() + "#" + callout.Severity + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.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()} "); Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} ");
} }
} }
@ -407,56 +417,101 @@ namespace AppServer
private void sendMailGeo(string mes, String subj, string mailAdr) private void sendMailGeo(string mes, String subj, string mailAdr)
{ {
try
if (Program.cfg.enableEmailService)
{ {
MailAddress from = new MailAddress(Program.cfg.emailAddress); if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
String[] address = mailAdr.Split(";".ToCharArray());
MailAddress to = new MailAddress(address[0]);
MailMessage message = new MailMessage(from, to);
if (address.Count() > 1)
{ {
Boolean skipeFirst = true; if (MainForm.IsBlacklistedAddress(mailAdr))
foreach (String obj in address)
{ {
if (skipeFirst) Utils.WriteLine($"sendMailGeo : The email '{subj}' was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
{ skipeFirst = false; } return;
else }
message.To.Add(new MailAddress(obj));
try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
String[] address = mailAdr.Split(";".ToCharArray());
MailAddress to = new MailAddress(address[0]);
MailMessage message = new MailMessage(from, to);
if (address.Count() > 1)
{
Boolean skipeFirst = true;
foreach (String obj in address)
{
if (skipeFirst)
{ skipeFirst = false; }
else
message.To.Add(new MailAddress(obj));
}
}
message.Subject = subj;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out") ||
ex.ToString().Contains("the client was not authenticated"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine($"Exception in sendMailGeo: {ex.ToString()}");
} }
} }
message.Subject = subj; else
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
Console.WriteLine("Exception in sendMailGeo: ", ex.ToString());
}
}
private void sendAlarmMail(string title, string mes, string mailAdr)
{
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(mailAdr))
{
try
{ {
MailAddress from = new MailAddress(Program.cfg.emailAddress); Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Cyan);
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = title;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
Utils.WriteLine("Exception in sendMailAlarm2: {0}" + ex.ToString(), ConsoleColor.Red);
} }
} }
else else
{ {
Utils.WriteLine("Email Server not Set",ConsoleColor.Cyan); Utils.WriteLine("Email Server not Set", ConsoleColor.Cyan);
} }
}
}
private void sendAlarmMail(string title, string mes, string mailAdr)
{
if (Program.cfg.enableEmailService)
{
if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
{
if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($" sendAlarmMail : The email '{title}' was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
return;
}
try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = title;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if ( ex.ToString().Contains("timed out") ||
ex.ToString().Contains("the client was not authenticated"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMailAlarm2: {0}" + ex.ToString(), ConsoleColor.Red);
}
}
else
{
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Cyan);
}
}
else
{
Utils.WriteLine("Email Server not Set", ConsoleColor.Cyan);
}
}
private String processZoneAlarm(string radioID, htCell_t cell, bool zone, bool landMArk, string mailAdr, bool sendOnMsgBus) private String processZoneAlarm(string radioID, htCell_t cell, bool zone, bool landMArk, string mailAdr, bool sendOnMsgBus)
{ {
@ -505,18 +560,19 @@ namespace AppServer
if (validAlarm) if (validAlarm)
{ {
Utils.WriteLine("Add new zone alarm");
DBalarm.Insert_Zone_Alarm(((Vehicle_Data)MainForm.VehList[radioID.ToString()]).sc_id, time, obj2.zone_id, obj2.action, true); DBalarm.Insert_Zone_Alarm(((Vehicle_Data)MainForm.VehList[radioID.ToString()]).sc_id, time, obj2.zone_id, obj2.action, true);
Utils.WriteLine("Done Add new zone alarm");
// send Alert by email if the emailServer is configured
string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph"; if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
string message = "Zone alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp
+ $". Unit speed {speed_km_or_mph} at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]";
string title = "Zone alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
if (mailAdr != "")
{ {
string veh_name = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph";
string message = $"Zone alarm for {veh_name} {tmpresp}. Unit speed {speed_km_or_mph} at time: {Utils.UnixTimeStampToDateTime(time).ToLocalTime()} [{cell.lat},{cell.lng} ]";
string title = $"Zone alarm for {veh_name}";
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
sendAlarmMail(title, message, mailAdr); sendAlarmMail(title, message, mailAdr);
@ -531,8 +587,10 @@ namespace AppServer
{ {
//send alarm on message buss //send alarm on message buss
test = "#136#" + radioID.ToString() + "#" + tmpresp + "#"; test = "#136#" + radioID.ToString() + "#" + tmpresp + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.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(); String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString();
///send SMS ///send SMS
UnitSysPosition tmpX = null; UnitSysPosition tmpX = null;
@ -558,8 +616,11 @@ namespace AppServer
tmpX = dbvehs.getSystemPosition(Convert.ToInt32(keyobj)); 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 + "#"; 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(SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test).Length);
System.Threading.Thread.Sleep(100); 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)}]"); Utils.WriteLine($"Zone alert sms request [{obj2.msgbody}] for unit {(String)tmpHashName[keyobj]} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
} }
@ -569,8 +630,9 @@ namespace AppServer
if (obj2.sentmsg2 && sendOnMsgBus) if (obj2.sentmsg2 && sendOnMsgBus)
{ {
tmpX = dbvehs.getSystemPositionIMEI(radioID); tmpX = dbvehs.getSystemPositionIMEI(radioID);
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#"; test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test), SafeMobileLib.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);
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]"); Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
} }
@ -580,14 +642,15 @@ namespace AppServer
{ {
tmpX = dbvehs.getSystemPositionIMEI(radioID); tmpX = dbvehs.getSystemPositionIMEI(radioID);
test = "#177#" + radioID.ToString() + "#" + obj2.calloutSeverity + "#" + obj2.name + "#"; test = "#177#" + radioID.ToString() + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.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}); 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)}]"); Utils.WriteLine($"Zone CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
} }
///send email // send by email if the emailServer is configured
if (obj2.sentemail) if (Program.cfg.enableEmailService && obj2.sentemail)
{ {
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
@ -607,35 +670,45 @@ namespace AppServer
String speedMiles = Convert.ToString((int)Math.Round(speed * 0.621371192)); String speedMiles = Convert.ToString((int)Math.Round(speed * 0.621371192));
if (tmpresp.Length > 1) if (tmpresp.Length > 1)
{ {
Utils.WriteLine("Insert Landmarks Alarm " + radioID.ToString() + " " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).sc_id);
DBalarm.Insert_Zone_Alarm(((Vehicle_Data)MainForm.VehList[radioID.ToString()]).sc_id, time, obj2.land_id, obj2.action, false);
int sc_id = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).sc_id;
string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph";
string message = "Landmark alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp // insert Alert into database
+ $". Unit speed {speed_km_or_mph} at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]"; Utils.WriteLine("Insert Landmarks Alarm " + radioID.ToString() + " " + sc_id);
string title = "Landmark alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name; DBalarm.Insert_Zone_Alarm(sc_id, time, obj2.land_id, obj2.action, false);
if (mailAdr != "")
// send alert by email if the emailServer is configured
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
{ {
string veh_name = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph";
string message = $"Landmark alarm for {veh_name} {tmpresp}. Unit speed {speed_km_or_mph} at time: {Utils.UnixTimeStampToDateTime(time).ToLocalTime()} [{cell.lat},{cell.lng} ]";
string title = $"Landmark alarm for {veh_name}";
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
sendAlarmMail(title, message, mailAdr); sendAlarmMail(title, message, mailAdr);
}); });
} }
//send Alert on message buss
if (sendOnMsgBus) if (sendOnMsgBus)
{ {
//send alarm on message buss //send alarm on message buss
string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#"; string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.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 //send CallOut
if(obj2.callout && tmpresp.ToString().Contains("IN ")) if(obj2.callout && tmpresp.ToString().Contains("IN "))
{ {
string test = "#177#" + radioID + "#" + obj2.calloutSeverity + "#" + obj2.name + "#"; string test = "#177#" + radioID + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.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 }); callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now });
Utils.WriteLine($"Landmark CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} "); Utils.WriteLine($"Landmark CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} ");
@ -667,47 +740,48 @@ namespace AppServer
{ {
DBalarmManager DBalarm = new DBalarmManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); DBalarmManager DBalarm = new DBalarmManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
int speed = (int)Convert.ToDouble(cell.spd);
int speedMiles = (int)Math.Round(speed * 0.621371192);
uint time = DateTo70Format(cell.location_time);
string speed4send = speed.ToString() + "_" + speedUnits;
int treshold = (int)Convert.ToDouble(speedTreshold); int treshold = (int)Convert.ToDouble(speedTreshold);
if (speedUnits == "m") if (speedUnits == "m")
treshold = (int)(treshold * 1.609); treshold = (int)(treshold * 1.609);
if (speedUnits != "m") int speed = (int)Convert.ToDouble(cell.spd);
if (speed >= treshold)
{ {
if (speed >= treshold) uint time = DateTo70Format(cell.location_time);
// insert alert into database
DBalarm.Insert_Speed_Alarm(radioID, time, speed, cell.lat, cell.lng);
//send Alert by email if EmailServer si configured
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(mailAdr))
{ {
Utils.WriteLine("Speed alarm detected!");
DBalarm.Insert_Speed_Alarm(radioID, time, speed,cell.lat,cell.lng);
Utils.WriteLine("Done inserting speed alarm!");
int speedMiles = (int)Math.Round(speed * 0.621371192);
string veh_name = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
string speed_km_or_mph = (speedUnits != "m") ? $"{speed} km/h" : $"{speedMiles} mph"; string speed_km_or_mph = (speedUnits != "m") ? $"{speed} km/h" : $"{speedMiles} mph";
string message = "Speed alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name string message = $"Speed alarm for {veh_name}. Unit speed {speed_km_or_mph} at time: {Utils.UnixTimeStampToDateTime(time).ToLocalTime()} [{cell.lat},{cell.lng}]";
+ $". Unit speed {speed_km_or_mph} at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]"; string title = $"Speed alarm for unit {veh_name}";
string title = "Speed alarm for unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
if (mailAdr != "")
{
Task.Factory.StartNew(() =>
{
sendAlarmMail(title, message, mailAdr);
});
}
if (sendOnMsgBus)
Task.Factory.StartNew(() =>
{ {
//send alarm on message buss sendAlarmMail(title, message, mailAdr);
string test = "#135#" + radioID.ToString() + "#" + speed4send + "#"; });
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); }
}
//send Alert on message buss
if (sendOnMsgBus)
{
//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);
} }
} }
} }
#endregion #endregion

View File

@ -96,6 +96,9 @@ namespace AppServer
public static String dbAccess; public static String dbAccess;
private WebsocketThread websocket = null; private WebsocketThread websocket = null;
public static Dictionary<string, int> blackListAddress = new Dictionary<string, int>();
public const int MAX_ATTEMPTS = 100;
public delegate void UpdateLicensesUIInvokeCallBack(); public delegate void UpdateLicensesUIInvokeCallBack();
public MainForm() public MainForm()
@ -338,6 +341,37 @@ namespace AppServer
} }
public static void HandleTimeoutError(string mailAdr)
{
// add address to backlist
if (!blackListAddress.ContainsKey(mailAdr))
blackListAddress.Add(mailAdr, MAX_ATTEMPTS);
}
public static bool IsBlacklistedAddress(string mailAdr)
{
if (!blackListAddress.ContainsKey(mailAdr))
return false;
// avoid to send the email MAX_ATTEMPTS times => give another chance to try to send email when count = 0
int count = blackListAddress[mailAdr];
if (count == 0)
{
blackListAddress.Remove(mailAdr);
return false;
}
blackListAddress[mailAdr] = count - 1;
return true;
}
private void ConfigureWebSocket() private void ConfigureWebSocket()
{ {
if (!checkWebsocketServerStatus.Enabled) if (!checkWebsocketServerStatus.Enabled)
@ -1023,8 +1057,9 @@ namespace AppServer
catch (Exception exe) catch (Exception exe)
{ {
try try
{ {
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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#AppServer stoped#");
udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex2) catch (Exception ex2)
{ {
@ -1071,8 +1106,9 @@ namespace AppServer
errorOnScreen = true; errorOnScreen = true;
error = true; error = true;
try try
{ {
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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#2#Dongle missing Application server stopped#");
udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex2) catch (Exception ex2)
{ {
@ -1192,8 +1228,10 @@ namespace AppServer
MainForm.websocketLocationQueue.PostItem(data); MainForm.websocketLocationQueue.PostItem(data);
if(!sendWebsocketTimer.Enabled)
if (!sendWebsocketTimer.Enabled)
sendWebsocketTimer.Enabled = true; sendWebsocketTimer.Enabled = true;
if (!checkWebsocketServerStatus.Enabled) if (!checkWebsocketServerStatus.Enabled)
checkWebsocketServerStatus.Enabled = true; checkWebsocketServerStatus.Enabled = true;
} }
@ -1245,10 +1283,12 @@ namespace AppServer
} }
try try
{ {
udp.Send(Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#"), byte[] dataToSend = 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(dataToSend, dataToSend.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);
dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex2) catch (Exception ex2)
{ {
@ -1263,8 +1303,9 @@ namespace AppServer
try try
{ {
try try
{ {
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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#5#Application server restart#");
udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex2) catch (Exception ex2)
{ {

View File

@ -28,6 +28,7 @@ namespace AppServer
private DBvehiclesManager dbvehs; private DBvehiclesManager dbvehs;
internal DBsubsOperationManager dbsubsoperManage; internal DBsubsOperationManager dbsubsoperManage;
private DBcallPatchManager dbCallPatch; private DBcallPatchManager dbCallPatch;
#region code for zone #region code for zone
private volatile static ArrayList ZoneList = new ArrayList(); private volatile static ArrayList ZoneList = new ArrayList();
private volatile static ArrayList LandList = new ArrayList(); private volatile static ArrayList LandList = new ArrayList();
@ -605,7 +606,8 @@ namespace AppServer
Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan); Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan);
//send radio disable to GW //send radio disable to GW
string test2 = "#150#" + dest + "#0#"; string test2 = "#150#" + 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) catch (Exception ex)
{ {
@ -725,8 +727,10 @@ namespace AppServer
int unitSC_ID = DBvehInfo.getSCID(radioID3.ToString()); int unitSC_ID = DBvehInfo.getSCID(radioID3.ToString());
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID); UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
string message = string.Format("Ticket no. {0} is no longer active!", dec3.delete_ticket_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 + "#"; 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);
byte[] cmd = Utils.Convert_text_For_multicast("#0.0" + test1);
MainForm.udp.Send(cmd, cmd.Length);
} }
//send to email if was sms->email type //send to email if was sms->email type
if (dec3.isEmail) if (dec3.isEmail)
@ -734,12 +738,11 @@ namespace AppServer
sendMail(dec3.emailAddr, dec3.messBody, radioID3); sendMail(dec3.emailAddr, dec3.messBody, radioID3);
} }
//send ACK back to GW //send ACK back to GW
test = ""; test = (dec3.sqlResp == sqlResponse.done) ? "#232#1#" : "#232#0#";
if (dec3.sqlResp == sqlResponse.done)
test = "#232#1#";
else byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID3 + test);
test = "#232#0#"; MainForm.udp.Send(dataToSend, dataToSend.Length);
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test).Length);
if (MainForm.SendPOLLafterSMS) if (MainForm.SendPOLLafterSMS)
{ {
@ -748,8 +751,9 @@ namespace AppServer
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID); UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
string dest = $"0.0.{radioID3}"; string dest = $"0.0.{radioID3}";
if (sysPos != null) dest = $"{sysPos.Gw_id}.{sysPos.R_gw_id}.{radioID3}"; if (sysPos != null) dest = $"{sysPos.Gw_id}.{sysPos.R_gw_id}.{radioID3}";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#").Length); dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -926,8 +930,10 @@ namespace AppServer
DBtel.AddTelemetryHist(radioID, tObj.Id, 1); DBtel.AddTelemetryHist(radioID, tObj.Id, 1);
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
SM.Debug("Sending telemetry alarm to SD; digital:" + tObj.DigitalNr); SM.Debug("Sending telemetry alarm to SD; digital:" + tObj.DigitalNr);
test = $"#140#{radioID}#{tObj.Name}#"; 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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
else else
{ {
@ -937,8 +943,9 @@ namespace AppServer
} }
} }
if (IhaveData) if (IhaveData)
{ {
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#").Length); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -1031,8 +1038,9 @@ namespace AppServer
object[] param = { dirBackup, posgresPath }; object[] param = { dirBackup, posgresPath };
bgWorkerDBbackup.RunWorkerAsync(param); bgWorkerDBbackup.RunWorkerAsync(param);
//send ACK back to SUM //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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#71#1#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -1060,12 +1068,14 @@ namespace AppServer
object[] param2 = { completeFileName, posgresPath }; object[] param2 = { completeFileName, posgresPath };
bgWorkerDBrestore.RunWorkerAsync(param2); bgWorkerDBrestore.RunWorkerAsync(param2);
//send ACK back to SUM //send ACK back to SUM
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#72#1#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#72#1#").Length); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#72#1#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
else else
{ {
SM.Debug("DB restored failed !!!" + "File " + completeFileName + " missing!!!"); 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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#62#0#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -1137,7 +1147,9 @@ namespace AppServer
//send broadcast messages I'm back in business //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); 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 + "#"; string test1 = "#501#" + tempArr[4] + "#" + tempArr[5] + "#" + "ON#" + ((RadioGateway)MainForm.RadioGWHash[key]).Name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID4 + test1), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID4 + test1).Length);
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID4 + test1);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
((RadioGateway)MainForm.RadioGWHash[key]).Alive = true; ((RadioGateway)MainForm.RadioGWHash[key]).Alive = true;
((RadioGateway)MainForm.RadioGWHash[key]).LastUpdate = DateTime.UtcNow; ((RadioGateway)MainForm.RadioGWHash[key]).LastUpdate = DateTime.UtcNow;
@ -1164,7 +1176,9 @@ namespace AppServer
string status = ((RadioGateway)(entry.Value)).Alive ? "ON" : "OFF"; 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); 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 + "#"; string test1 = "#501#" + ((RadioGateway)(entry.Value)).Gw_id + "#" + ((RadioGateway)(entry.Value)).Id + "#" + status + "#" + ((RadioGateway)(entry.Value)).Name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test1), SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test1).Length);
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + "0.0" + test1);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
break; break;
@ -1287,11 +1301,14 @@ namespace AppServer
if (sysPos != null) dest = sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID.ToString(); if (sysPos != null) dest = sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID.ToString();
String test = "#154#" + dest + "#"; String test = "#154#" + dest + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test).Length);
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqId + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
//send emergency alarm to SD //send emergency alarm to SD
test = "#134#" + radioID.ToString() + "#" + emergencyType; test = "#134#" + radioID.ToString() + "#" + emergencyType;
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqId + test).Length); dataToSend = Utils.Convert_text_For_multicast("#" + seqId + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
((VehicleStatus)MainForm.VehicleHashStat[radioID]).curentStatus = Status_for_tab.EMERG; ((VehicleStatus)MainForm.VehicleHashStat[radioID]).curentStatus = Status_for_tab.EMERG;
((VehicleStatus)MainForm.VehicleHashStat[radioID]).lastArsTime = DateTime.Now; ((VehicleStatus)MainForm.VehicleHashStat[radioID]).lastArsTime = DateTime.Now;
@ -1372,7 +1389,9 @@ namespace AppServer
UnitSysPosition tmpX = dbvehs.getSystemPosition(msg.sc_id_dest); 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 + "#";
string test = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#"; string test = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + 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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
else else
SM.Debug("message will be sent at a later time - schedule: " + msg.sched_timeGMT + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format()); SM.Debug("message will be sent at a later time - schedule: " + msg.sched_timeGMT + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format());
@ -1404,7 +1423,8 @@ namespace AppServer
string test = ""; string test = "";
String cmdok = ""; String cmdok = "";
var subsBlackList = new List<int> { (int)Status_for_tab.OFF, (int)Status_for_tab.DISABLE, (int)Status_for_tab.MADEOFF }; 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) foreach (smsmessage msg in smss)
{ {
long sc_id = msg.sc_id_dest; long sc_id = msg.sc_id_dest;
@ -1415,8 +1435,10 @@ namespace AppServer
{ {
if (SysPosList[sc_id]!=null) 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 + "#"; 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 + "#"; 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);
dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
else else
SM.Debug("message will be sent at a later time - schedule: " + msg.sched_timeGMT + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format()); SM.Debug("message will be sent at a later time - schedule: " + msg.sched_timeGMT + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format());
@ -1428,8 +1450,9 @@ namespace AppServer
{ {
UnitSysPosition tmpX = dbvehs.getSystemPosition_for_group(msg.imei_dest); 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 + "#"; 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); dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
Utils.WriteLine($"Undelivered {undeliveredSMS} private messages and {smss.Count} group messages", ConsoleColor.White); Utils.WriteLine($"Undelivered {undeliveredSMS} private messages and {smss.Count} group messages", ConsoleColor.White);
@ -1445,19 +1468,19 @@ namespace AppServer
{ {
//Check4ExpiredTickets //Check4ExpiredTickets
List<JobTickets> jtlist = new List<JobTickets>(); List<JobTickets> jtlist = new List<JobTickets>();
string list_of_id_text = "";
try 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); 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)); List<Int32> ExpiredTicketsIdList = DBT.updateTicketExpireDate(DateTo70Format(DateTime.UtcNow));
if(ExpiredTicketsIdList.Count>0) if(ExpiredTicketsIdList.Count>0)
{ {
foreach(Int32 id in ExpiredTicketsIdList)
{ // get comma separated list
list_of_id_text += id + ","; string list_of_id_text = string.Join<string>(",", ExpiredTicketsIdList.Select(x => $"{x}"));
}
list_of_id_text = list_of_id_text.Substring(0, list_of_id_text.Length - 1); byte[] dataToSend = Utils.Convert_text_For_multicast($"#0.0#251#{list_of_id_text}#");
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); MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -1494,8 +1517,11 @@ namespace AppServer
string message = string.Format("You need to finish job no.{0}, {1} in 10 minutes!", ticket.Ticket_id, ticket.Name); 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 + "#"; 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 + "#"; 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 + "#"; 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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + ticket.seq_id + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
} }
@ -1520,8 +1546,9 @@ namespace AppServer
string head = "#143#0.0." + ticket.Imei + "#"; 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 + "#"; 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 + "#"; 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); byte[] dataToSend = Utils.Convert_text_For_multicast("#" + ticket.seq_id + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
else else
SM.Debug("ticket will be sent at a later time - schedule: " + ticket.sched_timegmt + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format()); SM.Debug("ticket will be sent at a later time - schedule: " + ticket.sched_timegmt + " current:" + DateTime.Now.ToUniversalTime().DateTo70Format());
@ -1552,8 +1579,10 @@ namespace AppServer
{ {
if (DateTime.Now.ToUniversalTime() > item.Timegmt.AddSeconds(item.ArsInterval + 10))// added 10 seconds; marja erroare 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"); 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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#130#" + item.Imei + "#OFF#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
} }
@ -1599,7 +1628,9 @@ namespace AppServer
string test = "#501#" + ((RadioGateway)(entry.Value)).Gw_id + "#" + ((RadioGateway)(entry.Value)).Id + "#" + "OFF" + "#" + ((RadioGateway)(entry.Value)).Name + "#"; string test = "#501#" + ((RadioGateway)(entry.Value)).Gw_id + "#" + ((RadioGateway)(entry.Value)).Id + "#" + "OFF" + "#" + ((RadioGateway)(entry.Value)).Name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + "0.0" + test), SafeMobileLib.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);
((RadioGateway)(entry.Value)).Alive = false; ((RadioGateway)(entry.Value)).Alive = false;
} }
} }
@ -1684,7 +1715,9 @@ namespace AppServer
public static void PushStatus(String IMEI,Status_for_tab stat) public static void PushStatus(String IMEI,Status_for_tab stat)
{ {
Utils.WriteLine("Send PushStatus:" + stat+" Imei:"+IMEI,ConsoleColor.Yellow); Utils.WriteLine("Send PushStatus:" + stat+" Imei:"+IMEI,ConsoleColor.Yellow);
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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#153#" + IMEI + "#" + (Int32)stat + "#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
@ -2082,8 +2115,9 @@ namespace AppServer
{ {
messageOnScreen = true; messageOnScreen = true;
try try
{ {
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); byte[] dataToSend = Utils.Convert_text_For_multicast("#Application server database connection failed#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex2) catch (Exception ex2)
{ {
@ -2150,21 +2184,46 @@ namespace AppServer
private void sendAlarmMail(string mes, string mailAdr) private void sendAlarmMail(string mes, string mailAdr)
{ {
try if (Program.cfg.enableEmailService)
{ {
MailAddress from = new MailAddress(Program.cfg.emailAddress);
MailAddress to = new MailAddress(mailAdr); if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
MailMessage message = new MailMessage(from, to); {
message.Subject = "Alarm"; if (MainForm.IsBlacklistedAddress(mailAdr))
message.Body = mes; {
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState); Utils.WriteLine($" sendAlarmMail : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return;
}
try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = "Alarm";
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMailAlarm: " + ex.ToString(), ConsoleColor.Red);
//Console.WriteLine(e.ToString());
}
}
else
{
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Red);
}
} }
catch (Exception ex) else
{ {
Utils.WriteLine("Exception in sendMailAlarm: " + ex.ToString(), ConsoleColor.Red); SM.Debug("email disabled");
//Console.WriteLine(e.ToString());
} }
} }
public void sendDailyReportMail(String PdfFile, string mailAdr) public void sendDailyReportMail(String PdfFile, string mailAdr)
{ {
@ -2239,11 +2298,20 @@ namespace AppServer
if (Program.cfg.enableEmailService) if (Program.cfg.enableEmailService)
{ {
SM.Debug(new string[] { "Checking mail at:" + DateTime.Now.ToString(), "For " + Program.cfg.emailAddress.ToString() + " on " + Program.cfg.pop3Server.ToString() }); 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"); emailHT = dbsubsoperManage.getAll_imei_sc_id("ByMail");
if (emailHT.Count > 0) if (emailHT.Count > 0)
{ {
SM.Debug("Load " + emailHT.Count + " subscribers emails from DB ..."); SM.Debug("Load " + emailHT.Count + " subscribers emails from DB ...");
} }
if (sslServer == null)
{
SM.Debug("sslServer is null");
return;
}
Int64 latestEmailTime = sslServer.getLastEmailTime(); Int64 latestEmailTime = sslServer.getLastEmailTime();
ArrayList EmailList = sslServer.getEmails(); ArrayList EmailList = sslServer.getEmails();
@ -2254,19 +2322,23 @@ namespace AppServer
DB.SetLastEmailTime(sslServer.getLastEmailTime()); 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); 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) foreach (EmailtoSMS obj in EmailList)
{ {
String seqID = "0." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Millisecond.ToString(); String seqID = "0." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Millisecond.ToString();
SM.Debug(new string[] {"-----START OK----",
"From: " + obj.from, SM.Debug(new string[] { "-----START OK----",
"ID: " + obj.id, "From: " + obj.from,
"Text: " + obj.text}); "ID: " + obj.id,
"Text: " + obj.text});
try try
{ {
// app server idx =0 // 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 "'" //bigu code remove # from text and also replace "'"
try try
{ {
@ -2277,13 +2349,15 @@ namespace AppServer
{ {
SM.Debug("Error on converting email:" + ex.ToString()); SM.Debug("Error on converting email:" + ex.ToString());
} }
//end bigu code //end bigu code
if (!obj.is_group) DB.insert_sms_received(obj.id, obj.text, 7, obj.from, seqID); if (!obj.is_group) DBsms.insert_sms_received(obj.id, obj.text, 7, obj.from, seqID);
if (obj.is_sierra) if (obj.is_sierra)
{ {
if (emailHT.Contains(obj.from)) if (emailHT.Contains(obj.from))
{ {
SM.Debug("Email received <<" + obj.text + ">> from address: " + obj.from); SM.Debug("Email received <<" + obj.text + ">> from address: " + obj.from);
seqID = "1." + Utils.GetSecondsLocalFromDT(DateTime.Now).ToString() + DateTime.Now.Millisecond.ToString(); seqID = "1." + Utils.GetSecondsLocalFromDT(DateTime.Now).ToString() + DateTime.Now.Millisecond.ToString();
string test = "#132#" + ((SW_Subscriber)emailHT[obj.from]).imei + "#" + obj.text + "#hyt#"; 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; String cmdok = "#" + seqID + test; Int32 tmp = cmdok.Length + 1; tmp += tmp.ToString().Length; cmdok = "#" + tmp.ToString() + cmdok;
@ -2291,6 +2365,7 @@ namespace AppServer
byte[] buf = enc.GetBytes(cmdok); byte[] buf = enc.GetBytes(cmdok);
//send to messagebus //send to messagebus
MainForm.udp.Send(buf, buf.Length); MainForm.udp.Send(buf, buf.Length);
SM.Debug("Email thread successfully sent data to message bus"); SM.Debug("Email thread successfully sent data to message bus");
} }
} }
@ -2305,26 +2380,36 @@ namespace AppServer
obj.text = obj.text.Remove(140 - 3 - obj.from.Length) + " [" + obj.from + "]"; obj.text = obj.text.Remove(140 - 3 - obj.from.Length) + " [" + obj.from + "]";
else else
obj.text = obj.text + " [" + obj.from + "]"; obj.text = obj.text + " [" + obj.from + "]";
//send SMS on message buss //send SMS on message buss
if (!obj.is_sierra) if (!obj.is_sierra)
{ {
UnitSysPosition tmpX = dbvehs.getSystemPosition(dbvehs.getSCID(obj.id));
if (dbvehs != null)
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)
{ {
Int32 oldgatewayID = 0; UnitSysPosition tmpX = dbvehs.getSystemPosition(dbvehs.getSCID(obj.id));
foreach (RadioGateway obj2 in RadioListIP)
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)
{ {
if (oldgatewayID != obj2.Gw_id) Int32 oldgatewayID = 0;
foreach (RadioGateway obj2 in RadioListIP)
{ {
oldgatewayID = (Int32)obj2.Gw_id; if (oldgatewayID != 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); 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);
}
} }
} }
} }
@ -2348,24 +2433,43 @@ namespace AppServer
{ {
if (Program.cfg.enableEmailService) if (Program.cfg.enableEmailService)
{ {
SM.Debug("Sending mail to " + mailAdr + " from radioId " + radioID.ToString()); if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
try
{ {
MailMessage message = new MailMessage();
message.From = new MailAddress(Program.cfg.emailAddress);
message.To.Add(mailAdr);
message.Subject = "RadioID: " + radioID.ToString() + " Subject:" + (mailBody.Length < 25 ? mailBody : (mailBody.Remove(25) + "..."));
message.Body = "You received a message from radio id " + radioID.ToString() +
"\n------------------------------\n" +
mailBody +
"\n------------------------------\n ";
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState); if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($"sendMail : The email was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
return;
}
SM.Debug("Sending mail to " + mailAdr + " from radioId " + radioID.ToString());
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(Program.cfg.emailAddress);
message.To.Add(mailAdr);
message.Subject = "RadioID: " + radioID.ToString() + " Subject:" + (mailBody.Length < 25 ? mailBody : (mailBody.Remove(25) + "..."));
message.Body = "You received a message from radio id " + radioID.ToString() +
"\n------------------------------\n" +
mailBody +
"\n------------------------------\n ";
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out") ||
ex.ToString().Contains("the client was not authenticated"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMail: " + ex.ToString(), ConsoleColor.Red);
}
} }
catch (Exception ex) else
{ {
Utils.WriteLine("Exception in sendMail: " + ex.ToString(), ConsoleColor.Red); Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Red);
} }
} }
else else
@ -2378,20 +2482,46 @@ namespace AppServer
//sms-> email Sierra Wireless //sms-> email Sierra Wireless
private void sendMail_SW(string mailAdr, string mailBody) private void sendMail_SW(string mailAdr, string mailBody)
{ {
SM.Debug("Sending mail to " + mailAdr); if (Program.cfg.enableEmailService)
try
{ {
MailMessage message = new MailMessage(); if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
message.From = new MailAddress(Program.cfg.emailAddress); {
message.To.Add(mailAdr);
message.Body = mailBody;
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState); if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($"sendMail_SW : The email was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
return;
}
SM.Debug("Sending mail to " + mailAdr);
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(Program.cfg.emailAddress);
message.To.Add(mailAdr);
message.Body = mailBody;
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out") ||
ex.ToString().Contains("the client was not authenticated"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMail Sierra Wireless Gateway: " + ex.ToString(), ConsoleColor.Red);
}
}
else
{
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Red);
}
} }
catch (Exception ex) else
{ {
Utils.WriteLine("Exception in sendMail Sierra Wireless Gateway: "+ ex.ToString() ,ConsoleColor.Red); SM.Debug("email disabled");
} }
} }
@ -2423,8 +2553,9 @@ namespace AppServer
{ {
//send emergency alarm to SD //send emergency alarm to SD
//send ACK back to GW //send ACK back to GW
string test = (backupDOne == true) ? "#61#1#" : "#61#0#"; string code = (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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + code);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
#endregion #endregion
@ -2451,8 +2582,10 @@ namespace AppServer
{ {
//send emergency alarm to SD //send emergency alarm to SD
//send ACK back to GW //send ACK back to GW
string test = (restoreDOne == true) ? "#62#1#" : "#252#0#"; string code = (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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + code);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
#endregion #endregion

View File

@ -215,8 +215,8 @@ namespace AppServer
Thread.Sleep(2000); Thread.Sleep(2000);
try try
{ {
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#"), byte[] dataToSend = 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); MainForm.udp.Send(dataToSend, dataToSend.Length);
// save all unhandled gps positions // save all unhandled gps positions
MainForm.DumpLocationQueueToFile(); MainForm.DumpLocationQueueToFile();
@ -240,8 +240,10 @@ namespace AppServer
Thread.Sleep(2000); Thread.Sleep(2000);
try 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 // save all unhandled gps positions
MainForm.DumpLocationQueueToFile(); MainForm.DumpLocationQueueToFile();

View File

@ -14,5 +14,5 @@
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -51,7 +51,7 @@ namespace AppServer
String stringData = System.Text.Encoding.ASCII.GetString(data, 0, data.Length); String stringData = System.Text.Encoding.ASCII.GetString(data, 0, data.Length);
String usefulData = stringData.Trim(); String usefulData = stringData.Trim();
Console.WriteLine("Data received:" + usefulData); Console.WriteLine("Data received:" + usefulData);
String[] command = usefulData.Split('#'); String[] command = usefulData.Split("#".ToCharArray());
SDRegistration sdReg = null; SDRegistration sdReg = null;
String header = ""; String header = "";
int digCommand; int digCommand;
@ -107,9 +107,10 @@ namespace AppServer
+ Program.cfg.msgBusIP.ToString() + ";" + Program.cfg.msgBusPort + ";" + databaseIP + ";" + Program.cfg.msgBusIP.ToString() + ";" + Program.cfg.msgBusPort + ";" + databaseIP + ";"
+ Program.cfg.DB_schema + ";" + Program.cfg.DB_user + ";" + Program.cfg.DB_passwd + Program.cfg.DB_schema + ";" + Program.cfg.DB_user + ";" + Program.cfg.DB_passwd
+ ";" + Program.cfg.DB_port + ";" + Program.cfg.VoicePort + ";" + ";" + Program.cfg.DB_port + ";" + Program.cfg.VoicePort + ";"
+ audibleAlerts.ToString() + ";" + MainForm.dbAccess.ToString() + ";"; + 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); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
MainForm.RegistrationAnswer = false; MainForm.RegistrationAnswer = false;
Int32 countWait = 0; //maxim 30 = 3 seconds Int32 countWait = 0; //maxim 30 = 3 seconds

View File

@ -171,8 +171,10 @@ namespace AppServer
DBrec.addRecording(rec); 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}#"; 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);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -376,6 +376,40 @@ namespace MotoTrbo_GW
} }
private void FetchAudioSettings()
{
DBsettingsManager dbSettings = new DBsettingsManager(DBServer, DBSchema, DBUser, DBPass, DBPort);
string tmpSamplaRate = dbSettings.getSettingValue(0, "sampleRate");
if (!string.IsNullOrEmpty(tmpSamplaRate))
sampleRate = int.Parse(tmpSamplaRate);
else
{
SafeMobileLib.Utils.WriteLine("Invalid sample rate", ConsoleColor.Red);
}
string tmpBitDepth = dbSettings.getSettingValue(0, "bitDepth");
if (!string.IsNullOrEmpty(tmpSamplaRate))
{
bitdepth = int.Parse(tmpBitDepth);
bitdepthInBytes = bitdepth / 8;
}
else
{
SafeMobileLib.Utils.WriteLine("Invalid bit depth", ConsoleColor.Red);
}
string tmpBufferMilliseconds = dbSettings.getSettingValue(0, "bufferMilliseconds");
if (!string.IsNullOrEmpty(tmpBufferMilliseconds))
recordedBufferMiliseconds = int.Parse(tmpBufferMilliseconds);
else
{
SafeMobileLib.Utils.WriteLine("Invalid bufferMilliseconds", ConsoleColor.Red);
}
}
private void ContinueConstructor() private void ContinueConstructor()
{ {
@ -394,45 +428,78 @@ namespace MotoTrbo_GW
"Update required...", MessageBoxButtons.YesNo, RadMessageIcon.Exclamation); "Update required...", MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
if (dr == DialogResult.Yes) if (dr == DialogResult.Yes)
{
CheckForUpdate(true); CheckForUpdate(true);
Application.Exit();
} Application.Exit();
else
Application.Exit();
} }
else 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 // Get Audio settings
DBsettingsManager dbSettings = new DBsettingsManager(DBServer, DBSchema, DBUser, DBPass, DBPort); FetchAudioSettings();
string tmpSamplaRate = dbSettings.getSettingValue(0, "sampleRate");
if (!string.IsNullOrEmpty(tmpSamplaRate))
sampleRate = int.Parse(tmpSamplaRate);
else
{
SafeMobileLib.Utils.WriteLine("Invalid sample rate", ConsoleColor.Red);
}
string tmpBitDepth = dbSettings.getSettingValue(0, "bitDepth");
if (!string.IsNullOrEmpty(tmpSamplaRate))
{
bitdepth = int.Parse(tmpBitDepth);
bitdepthInBytes = bitdepth / 8;
}
else
{
SafeMobileLib.Utils.WriteLine("Invalid bit depth", ConsoleColor.Red);
}
string tmpBufferMilliseconds = dbSettings.getSettingValue(0, "bufferMilliseconds");
if (!string.IsNullOrEmpty(tmpBufferMilliseconds))
recordedBufferMiliseconds = int.Parse(tmpBufferMilliseconds);
else
{
SafeMobileLib.Utils.WriteLine("Invalid bufferMilliseconds", ConsoleColor.Red);
}
//int asio driver object //int asio driver object
@ -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;

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -1,10 +0,0 @@
// Generated on Wed, Jun 5, 2024 3:16:51 PM by prebuild script
namespace SafeDispatch-git
{
public class VersionInfo
{
public string Version{ get; set; } = "8.1.0.10898-7-ga2c35ac";
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -452,34 +452,36 @@ namespace SafeMobileLib
BatchHistoryData batchHistObj = null; BatchHistoryData batchHistObj = null;
try try
{ {
lat = Convert.ToDouble(dr["lat"]); lat = Convert.ToDouble(dr["lat"]);
lng = Convert.ToDouble(dr["lng"]); lng = Convert.ToDouble(dr["lng"]);
timegmt = Convert.ToInt32(dr["timegmt"]); timegmt = Convert.ToInt32(dr["timegmt"]);
batchHistObj = new BatchHistoryData batchHistObj = new BatchHistoryData
{ {
Department = dr["department"].ToString(), Department = dr["department"].ToString(),
Unit = dr["unit"].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(), Speed = (isInMile) ? ((int)(Convert.ToInt32(dr["speed"]) * 0.621371192)).ToString() : Convert.ToInt32(dr["speed"]).ToString(),
Lat = lat, Lat = lat,
Lng = lng, Lng = lng,
Address = dr["address"].ToString(), Address = string.Empty,
Time = timegmt.TimeOfDayHHMMSSLocal(!is24hours), Time = timegmt.TimeOfDayHHMMSSLocal(!is24hours),
Date = timegmt.GetDTLocalFromSeconds().Date.ToShortDateString() 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) catch (Exception ex)
{ {

View File

@ -74,7 +74,7 @@ namespace SafeMobileLib
Int32 sc_id = 0; Int32 sc_id = 0;
Int32 job_status = 0; Int32 job_status = 0;
int specified_end_time = -1; int specified_end_time = -1;
string[] messageString = mess.Split('^'); string[] messageString = mess.Split("^".ToCharArray());
string text = messageString[0]; string text = messageString[0];
string comment = messageString[1]; string comment = messageString[1];
string priority = messageString[2]; string priority = messageString[2];

View File

@ -1018,7 +1018,7 @@ namespace SafeMobileLib
vehResponse resp; vehResponse resp;
NpgsqlCommand cmd; NpgsqlCommand cmd;
bool isDeleted; bool isDeleted;
string[] idListArray = idlist.Replace("(", "").Replace(")", "").Split(','); string[] idListArray = idlist.Replace("(", "").Replace(")", "").Split(",".ToCharArray());
isDeleted = isUnitDeleted(idListArray[0]); isDeleted = isUnitDeleted(idListArray[0]);
NpgsqlTransaction transaction = null; NpgsqlTransaction transaction = null;

View File

@ -25,6 +25,8 @@ namespace SafeMobileLib
private bool isSSL = true; private bool isSSL = true;
private Int64 lastEmailTime = 0; private Int64 lastEmailTime = 0;
private Int64 startEmailServiceTime = 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 // blank constructor in order to be used in Email Checking
public EmailServerSSL() public EmailServerSSL()
@ -334,7 +336,7 @@ namespace SafeMobileLib
if (ets.from.Contains("@")) if (ets.from.Contains("@"))
{ {
string temp = (ets.from.Split('@'))[0]; string temp = (ets.from.Split("@".ToCharArray()))[0];
int i_id = 0; int i_id = 0;
bool valid = Int32.TryParse(temp, out i_id); bool valid = Int32.TryParse(temp, out i_id);
@ -378,11 +380,46 @@ namespace SafeMobileLib
return ret; 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> /// <summary>
/// Connect to the Pop Server in order to be used to get the emails /// Connect to the Pop Server in order to be used to get the emails
/// </summary> /// </summary>
private void ConnectEmailPopServer() 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(() => Thread t = new Thread(() =>
{ {
ConnectAsync(); ConnectAsync();
@ -393,8 +430,17 @@ namespace SafeMobileLib
private void ConnectAsync() private void ConnectAsync()
{ {
if (popClient != null && popClient.Connected) try
popClient.Disconnect(); {
if (popClient != null && popClient.Connected)
popClient.Disconnect();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
popClient = null; popClient = null;
popClient = new Pop3Client(); popClient = new Pop3Client();
@ -412,18 +458,25 @@ namespace SafeMobileLib
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("PopServerNotFoundException -> " + ee.ToString()); Console.WriteLine("PopServerNotFoundException -> " + ee.ToString());
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
HandleBlacklist(serverIP);
} }
catch (InvalidLoginException e) catch (InvalidLoginException e)
{ {
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("InvalidLoginException -> " + e.ToString()); Console.WriteLine("InvalidLoginException -> " + e.ToString());
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
HandleBlacklist(serverIP);
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("ConnectEmailPopServer -> " + ex.ToString()); Console.WriteLine("ConnectEmailPopServer -> " + ex.ToString());
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
HandleBlacklist(serverIP);
} }
} }

View File

@ -90,8 +90,9 @@ namespace SafeMobileLib
public void SendOnMsgBuss(string seqID, string test) public void SendOnMsgBuss(string seqID, string test)
{ {
if (udpMulticast != null) 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 else
{ {

View File

@ -24,7 +24,7 @@ namespace SafeMobileLib.Helpers
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(appServerIP), registrationPort); IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(appServerIP), registrationPort);
client.Connect(serverEndPoint); client.Connect(serverEndPoint);
NetworkStream clientStream = client.GetStream(); NetworkStream clientStream = client.GetStream();
GatewayIP = (client.Client.LocalEndPoint.ToString().Split(':'))[0]; GatewayIP = (client.Client.LocalEndPoint.ToString().Split(":".ToCharArray()))[0];
UTF8Encoding encoding = new UTF8Encoding(); UTF8Encoding encoding = new UTF8Encoding();
byte[] buffer = encoding.GetBytes("200"); byte[] buffer = encoding.GetBytes("200");

View File

@ -16,7 +16,7 @@ namespace SafeMobileLib
string strInterface = ""; string strInterface = "";
try try
{ {
string[] arrStr = IPstr.Split('.'); string[] arrStr = IPstr.Split(".".ToCharArray());
int lastPartOfIP = Convert.ToInt32(arrStr[3]); int lastPartOfIP = Convert.ToInt32(arrStr[3]);
arrStr[3] = (lastPartOfIP + 1).ToString(); arrStr[3] = (lastPartOfIP + 1).ToString();
strInterface = arrStr[0] + "." + arrStr[1] + "." + arrStr[2] + "." + arrStr[3]; strInterface = arrStr[0] + "." + arrStr[1] + "." + arrStr[2] + "." + arrStr[3];
@ -34,7 +34,7 @@ namespace SafeMobileLib
string strInterface = ""; string strInterface = "";
try try
{ {
string[] arrStr = IPstr.Split('.'); string[] arrStr = IPstr.Split(".".ToCharArray());
int lastPartOfIP = Convert.ToInt32(arrStr[3]); int lastPartOfIP = Convert.ToInt32(arrStr[3]);
arrStr[3] = (lastPartOfIP - 1).ToString(); arrStr[3] = (lastPartOfIP - 1).ToString();
strInterface = arrStr[0] + "." + arrStr[1] + "." + arrStr[2] + "." + arrStr[3]; strInterface = arrStr[0] + "." + arrStr[1] + "." + arrStr[2] + "." + arrStr[3];
@ -62,9 +62,9 @@ namespace SafeMobileLib
System.Net.WebResponse resp = req.GetResponse(); System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()); System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
string response = sr.ReadToEnd().Trim(); string response = sr.ReadToEnd().Trim();
string[] a = response.Split(':'); string[] a = response.Split(":".ToCharArray());
string a2 = a[1].Substring(1); string a2 = a[1].Substring(1);
string[] a3 = a2.Split('<'); string[] a3 = a2.Split("<".ToCharArray());
a4 = a3[0]; a4 = a3[0];
if(a4 == "") if(a4 == "")
a4 = new WebClient().DownloadString(@"http://icanhazip.com").Trim(); a4 = new WebClient().DownloadString(@"http://icanhazip.com").Trim();

View File

@ -42,36 +42,28 @@ namespace SafeMobileLib
recv = s.Receive(b); recv = s.Receive(b);
else else
break;//break if socket == null break;//break if socket == null
if (recv == 0) if (recv == 0)
continue;//continue if return nr bytes == 0 continue;//continue if return nr bytes == 0
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
if (OnNewDataRecv != null) if (OnNewDataRecv != 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
OnNewDataRecv(decByte, decByte.Length); OnNewDataRecv(decByte, decByte.Length);
}
// trigger event
if (OnNewDataReceived != null) 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); OnNewDataReceived(mcastGroup, decByte, decByte.Length);
}
if (s == null) if (s == null)
@ -108,27 +100,19 @@ namespace SafeMobileLib
byte[] b = new byte[65507]; byte[] b = new byte[65507];
Thread.Sleep(1); Thread.Sleep(1);
int recv = s.Receive(b); int recv = s.Receive(b);
if (OnNewDataRecv != null)
byte[] tmp = new byte[recv];
for (int i = 0; i < recv; i++)
{ {
byte[] tmp = new byte[recv]; tmp[i] = b[i];
for (int i = 0; i < recv; i++)
{
tmp[i] = b[i];
}
if (this.OnNewDataRecv != null)
this.OnNewDataRecv(tmp, tmp.Length);
} }
if (OnNewDataReceived != null) if (this.OnNewDataRecv != null)
{ this.OnNewDataRecv(tmp, tmp.Length);
byte[] tmp = new byte[recv];
for (int i = 0; i < recv; i++) if (this.OnNewDataReceived != null)
{ this.OnNewDataReceived(mcastGroup, tmp, tmp.Length);
tmp[i] = b[i];
}
if (this.OnNewDataReceived != null)
this.OnNewDataReceived(mcastGroup, tmp, tmp.Length);
}
if (s == null) if (s == null)
{ {
@ -217,16 +201,17 @@ namespace SafeMobileLib
IPEndPoint ipep = new IPEndPoint(myIP, port); IPEndPoint ipep = new IPEndPoint(myIP, port);
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
s.Bind(ipep); s.Bind(ipep);
IPAddress ip = IPAddress.Parse(mcastGroup); IPAddress ip = IPAddress.Parse(mcastGroup);
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, myIP)); s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, myIP));
s.SetSocketOption(SocketOptionLevel.IP, s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
listenThread = new Thread(new ThreadStart(Listen)); listenThread = new Thread(new ThreadStart(Listen));
listenThread.IsBackground = true; listenThread.IsBackground = true;
} }
if (listenThread != null) if (listenThread != null)
listenThread.Start(); listenThread.Start();
ret = true; ret = true;
Utils.WriteLine($"++++++++++++++++++++++++++++++++++++++++++\nUdpMulticast bind on {mcastGroup}:{port} Ethernet: {myIP}\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); Utils.WriteLine($"++++++++++++++++++++++++++++++++++++++++++\nUdpMulticast bind on {mcastGroup}:{port} Ethernet: {myIP}\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
@ -243,12 +228,14 @@ namespace SafeMobileLib
bool ret = false; bool ret = false;
working = true; working = true;
useThreadPool = true; useThreadPool = true;
try try
{ {
if (s == null) if (s == null)
{ {
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
} }
if (s != null) if (s != null)
{ {
Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port)); Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port));
@ -257,8 +244,7 @@ namespace SafeMobileLib
s.Bind(ipep); s.Bind(ipep);
IPAddress ip = IPAddress.Parse(mcastGroup); IPAddress ip = IPAddress.Parse(mcastGroup);
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any)); s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
s.SetSocketOption(SocketOptionLevel.IP, s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
ThreadPool.QueueUserWorkItem(new WaitCallback(Listen_pool)); ThreadPool.QueueUserWorkItem(new WaitCallback(Listen_pool));
@ -282,6 +268,7 @@ namespace SafeMobileLib
{ {
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
} }
if (s != null) if (s != null)
{ {
Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port)); Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port));
@ -290,13 +277,14 @@ namespace SafeMobileLib
s.Bind(ipep); s.Bind(ipep);
IPAddress ip = IPAddress.Parse(mcastGroup); IPAddress ip = IPAddress.Parse(mcastGroup);
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any)); s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
s.SetSocketOption(SocketOptionLevel.IP, s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
listenThread = new Thread(new ThreadStart(Listen_Decoded)); listenThread = new Thread(new ThreadStart(Listen_Decoded));
listenThread.IsBackground = true; listenThread.IsBackground = true;
} }
if (listenThread != null) if (listenThread != null)
listenThread.Start(); listenThread.Start();
ret = true; ret = true;
} }
catch (Exception ex) catch (Exception ex)

View File

@ -441,8 +441,10 @@ namespace SafeMobileLib
Int32 tmp = cmdok.Length + 1; Int32 tmp = cmdok.Length + 1;
tmp += tmp.ToString().Length; tmp += tmp.ToString().Length;
String TMPcmdok = "#" + tmp.ToString() + cmdok; String TMPcmdok = "#" + tmp.ToString() + cmdok;
if (tmp != TMPcmdok.Length) cmdok = "#" + TMPcmdok.Length + cmdok; if (tmp != TMPcmdok.Length)
else cmdok = TMPcmdok; cmdok = "#" + TMPcmdok.Length + cmdok;
else
cmdok = TMPcmdok;
System.Text.Encoding enc = System.Text.Encoding.ASCII; System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] buf = enc.GetBytes(cmdok); byte[] buf = enc.GetBytes(cmdok);
@ -1056,7 +1058,7 @@ namespace SafeMobileLib
if (ret == "not_available") if (ret == "not_available")
{ {
string myIp = UdpMulticast.getPreferedIPAdress().ToString(); string myIp = UdpMulticast.getPreferedIPAdress().ToString();
string[] ip = myIp.Split('.'); string[] ip = myIp.Split(".".ToCharArray());
string baseIP = $"{ip[0]}.{ip[1]}.{ip[2]}"; string baseIP = $"{ip[0]}.{ip[1]}.{ip[2]}";
//4. scan lan range :41414/status //4. scan lan range :41414/status
for (int i = 1; i <= 255; i++) for (int i = 1; i <= 255; i++)
@ -1094,7 +1096,7 @@ namespace SafeMobileLib
string rtpstart = o["data"]["ports"]["rtpstart"].ToString(); string rtpstart = o["data"]["ports"]["rtpstart"].ToString();
string rtpend = o["data"]["ports"]["rtpend"].ToString(); string rtpend = o["data"]["ports"]["rtpend"].ToString();
string publicIp = o["data"]["network"]["publicIp"].ToString(); string publicIp = o["data"]["network"]["publicIp"].ToString();
string sipPort = o["data"]["ports"]["udpbindaddr"].ToString().Split(':')[1]; string sipPort = o["data"]["ports"]["udpbindaddr"].ToString().Split(":".ToCharArray())[1];
ret = true; ret = true;
} }
catch { Utils.WriteLine("Error on parse server response!", ConsoleColor.Red); } catch { Utils.WriteLine("Error on parse server response!", ConsoleColor.Red); }

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -152,7 +152,7 @@ namespace MapGoogle
Symbolx ret = new Symbolx(); Symbolx ret = new Symbolx();
NextCount++; NextCount++;
ret.ID = (byte)NextCount; ret.ID = (byte)NextCount;
String[] param = FileName.Split('\\'); String[] param = FileName.Split("\\".ToCharArray());
if (param.Length != 0) if (param.Length != 0)
ret.Name = param[param.Length - 1]; ret.Name = param[param.Length - 1];
symbolsArray.Add(ret); symbolsArray.Add(ret);
@ -659,7 +659,7 @@ namespace MapGoogle
if (MainForm2.MapType == MapTYPE.Google) if (MainForm2.MapType == MapTYPE.Google)
{ {
parent.ListShapeCMD.Add(MainForm2.ShapeCMD); parent.ListShapeCMD.Add(MainForm2.ShapeCMD);
String[] listS = MainForm2.ShapeCMD.Split(','); String[] listS = MainForm2.ShapeCMD.Split(",".ToCharArray());
//String PolyCMD = "poly,false," + "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2") + "," + Weight + "," + listS[1]; //String PolyCMD = "poly,false," + "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2") + "," + Weight + "," + listS[1];
String PolyCMD = "poly,true," + "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2") + "," + Weight + "," + listS[1]; String PolyCMD = "poly,true," + "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2") + "," + Weight + "," + listS[1];
parent.ListShapeCMD.Add(PolyCMD); parent.ListShapeCMD.Add(PolyCMD);

View File

@ -591,10 +591,10 @@ namespace Safedispatch_4_0
foreach (RadTreeNode groupNode in treeViewUnits.Nodes) foreach (RadTreeNode groupNode in treeViewUnits.Nodes)
{ {
// go through each unit and get the checked ones // go through each unit and get the checked ones
string[] splitHandled_by = pd.Handled_by.Split(';'); string[] splitHandled_by = pd.Handled_by.Split(";".ToCharArray());
foreach (RadTreeNode unitNode in groupNode.Nodes) foreach (RadTreeNode unitNode in groupNode.Nodes)
{ {
unitNode.Checked = (Array.IndexOf(splitHandled_by, unitNode.Tag.ToString())>-1); unitNode.Checked = (Array.IndexOf(splitHandled_by, unitNode.Tag.ToString()) > -1);
} }
} }
} }
@ -624,7 +624,7 @@ namespace Safedispatch_4_0
foreach (RadTreeNode groupNode in treeViewUnits.Nodes) foreach (RadTreeNode groupNode in treeViewUnits.Nodes)
{ {
// go through each unit and get the checked ones // go through each unit and get the checked ones
string[] splitHandled_by = CurrentConfiguration.Handled_by.Split(';'); string[] splitHandled_by = CurrentConfiguration.Handled_by.Split(";".ToCharArray());
foreach (RadTreeNode unitNode in groupNode.Nodes) foreach (RadTreeNode unitNode in groupNode.Nodes)
{ {
unitNode.Checked = (Array.IndexOf(splitHandled_by, unitNode.Tag.ToString()) > -1); unitNode.Checked = (Array.IndexOf(splitHandled_by, unitNode.Tag.ToString()) > -1);

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -1151,7 +1151,7 @@ namespace Safedispatch_4_0
{ {
String tmpstr = url.Remove(0, url.IndexOf("points") + 7); String tmpstr = url.Remove(0, url.IndexOf("points") + 7);
//Console.WriteLine("TmpStr:" + tmpstr); //Console.WriteLine("TmpStr:" + tmpstr);
String[] tmp = tmpstr.Split(','); String[] tmp = tmpstr.Split(",".ToCharArray());
//begin //begin
Int32 max = tmp.Length; Int32 max = tmp.Length;
@ -1204,7 +1204,7 @@ namespace Safedispatch_4_0
/// <param name="mapResponse">String containing the response from the map</param> /// <param name="mapResponse">String containing the response from the map</param>
private void ParseLatAndLng(string mapResponse) private void ParseLatAndLng(string mapResponse)
{ {
String[] tmp = mapResponse.Split(','); String[] tmp = mapResponse.Split(",".ToCharArray());
Double lat = 0, lng = 0; Double lat = 0, lng = 0;
string decimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; string decimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
String tmpLat = tmp[0]; String tmpLat = tmp[0];

View File

@ -1015,7 +1015,7 @@ namespace Safedispatch_4_0
else ckSpeedLimit.Checked = false; else ckSpeedLimit.Checked = false;
tbSpeed.Value = (((ZoneClass)((RadListDataItem)cbZoneEdit.SelectedItem).Value)).speed; tbSpeed.Value = (((ZoneClass)((RadListDataItem)cbZoneEdit.SelectedItem).Value)).speed;
String listOfUnits = (((ZoneClass)((RadListDataItem)cbZoneEdit.SelectedItem).Value)).unitids; String listOfUnits = (((ZoneClass)((RadListDataItem)cbZoneEdit.SelectedItem).Value)).unitids;
String[] tmp = listOfUnits.Split(','); String[] tmp = listOfUnits.Split(",".ToCharArray());
Hashtable tmpHashName = new Hashtable(); Hashtable tmpHashName = new Hashtable();
if (tmp.Count() > 1) if (tmp.Count() > 1)
{ {

View File

@ -2103,7 +2103,7 @@ namespace Safedispatch_4_0
} }
// Console.WriteLine("Update cmd:" + updatecomand); // Console.WriteLine("Update cmd:" + updatecomand);
Thread.Sleep(1); Thread.Sleep(1);
String[] tmp = updatecomand.Split(','); String[] tmp = updatecomand.Split(",".ToCharArray());
if (docLoad) if (docLoad)
{ {
//SM.Debug("Oneunit"+MainForm2.oneunit); //SM.Debug("Oneunit"+MainForm2.oneunit);
@ -2116,7 +2116,7 @@ namespace Safedispatch_4_0
//SM.Debug("Value of displayname:" + MainForm2.Displaywithname); //SM.Debug("Value of displayname:" + MainForm2.Displaywithname);
if (((MainForm2.Displaywithname) && (updatecomand.Contains("setDataset,"))) || (MainForm2.ForcePutLabelsONGoogle)) if (((MainForm2.Displaywithname) && (updatecomand.Contains("setDataset,"))) || (MainForm2.ForcePutLabelsONGoogle))
{ {
String[] datas = updatecomand.Split(','); String[] datas = updatecomand.Split(",".ToCharArray());
if (datas.Length > 1) if (datas.Length > 1)
{ {
//System.Threading.Thread.Sleep(100); //System.Threading.Thread.Sleep(100);

View File

@ -817,7 +817,7 @@ namespace Safedispatch_4_0
IPictureMarkerSymbol bitmapPictureMarkerSymbolCls = new IPictureMarkerSymbol bitmapPictureMarkerSymbolCls = new
ESRI.ArcGIS.Display.PictureMarkerSymbolClass(); ESRI.ArcGIS.Display.PictureMarkerSymbolClass();
//check if bmp file is saved for emergency //check if bmp file is saved for emergency
string fileNamePattern = veh.IconName.Split('/')[1].Split('.')[0]; string fileNamePattern = veh.IconName.Split("/".ToCharArray())[1].Split(".".ToCharArray())[0];
string filePath = System.Windows.Forms.Application.StartupPath + @"\resource\cars\" + fileNamePattern + ".png"; string filePath = System.Windows.Forms.Application.StartupPath + @"\resource\cars\" + fileNamePattern + ".png";
Image ArcgisImage = null; Image ArcgisImage = null;
veh.IconID = veh.is_emergency ? 10000 + veh.IconID : veh.IconID % 10000; veh.IconID = veh.is_emergency ? 10000 + veh.IconID : veh.IconID % 10000;

View File

@ -510,7 +510,7 @@ namespace Safedispatch_4_0.Radio
// #seqID#123#gatewayId.gatewayRadioId#result#dispatcherID# // #seqID#123#gatewayId.gatewayRadioId#result#dispatcherID#
string cmd = ""; string cmd = "";
Utils.Convert_text_For_multicast( Utils.Convert_text_For_multicast(
$"#1234#{mBusCmd}#{parent.SipGWIDandRadioID.Split('.')[0]}.{parent.SipGWIDandRadioID.Split('.')[1]}#2#{MainForm2.userIDX}#", $"#1234#{mBusCmd}#{parent.SipGWIDandRadioID.Split(".".ToCharArray())[0]}.{parent.SipGWIDandRadioID.Split(".".ToCharArray())[1]}#2#{MainForm2.userIDX}#",
out cmd); out cmd);
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); })); this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
} }
@ -527,7 +527,7 @@ namespace Safedispatch_4_0.Radio
// #seqID#122#gatewayId.gatewayRadioId#result#dispatcherID# // #seqID#122#gatewayId.gatewayRadioId#result#dispatcherID#
string cmd = ""; string cmd = "";
Utils.Convert_text_For_multicast( Utils.Convert_text_For_multicast(
$"#1234#122#{parent.SipGWIDandRadioID.Split('.')[0]}.{parent.SipGWIDandRadioID.Split('.')[1]}#2#{MainForm2.userIDX}#", $"#1234#122#{parent.SipGWIDandRadioID.Split(".".ToCharArray())[0]}.{parent.SipGWIDandRadioID.Split(".".ToCharArray())[1]}#2#{MainForm2.userIDX}#",
out cmd); out cmd);
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); })); this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
} }
@ -553,7 +553,7 @@ namespace Safedispatch_4_0.Radio
// Show event on System log // Show event on System log
// #seqID#123#gatewayId.gatewayRadioId#result#dispatcherID# // #seqID#123#gatewayId.gatewayRadioId#result#dispatcherID#
Utils.Convert_text_For_multicast( Utils.Convert_text_For_multicast(
$"#1234#{mbusCmd}#{parent.SipGWIDandRadioID.Split('.')[0]}.{parent.SipGWIDandRadioID.Split('.')[1]}#1#{MainForm2.userIDX}#", $"#1234#{mbusCmd}#{parent.SipGWIDandRadioID.Split(".".ToCharArray())[0]}.{parent.SipGWIDandRadioID.Split(".".ToCharArray())[1]}#1#{MainForm2.userIDX}#",
out cmd); out cmd);
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); })); this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
} }
@ -563,7 +563,7 @@ namespace Safedispatch_4_0.Radio
string seqId = parent.GetCallRequestForSip(targetSipID); string seqId = parent.GetCallRequestForSip(targetSipID);
if (seqId != null) if (seqId != null)
{ {
cmd = $"#{seqId}#{mbusCmd}#{parent.SipGWIDandRadioID.Split('.')[0]}.{parent.SipGWIDandRadioID.Split('.')[1]}#1#{MainForm2.userIDX}#"; cmd = $"#{seqId}#{mbusCmd}#{parent.SipGWIDandRadioID.Split(".".ToCharArray())[0]}.{parent.SipGWIDandRadioID.Split(".".ToCharArray())[1]}#1#{MainForm2.userIDX}#";
parent.Send_UDP_cmd_sent_withOutID(cmd); parent.Send_UDP_cmd_sent_withOutID(cmd);
} }
} }
@ -582,7 +582,7 @@ namespace Safedispatch_4_0.Radio
// Show event on System log // Show event on System log
// #seqID#122#gatewayId.gatewayRadioId#result#dispatcherID# // #seqID#122#gatewayId.gatewayRadioId#result#dispatcherID#
Utils.Convert_text_For_multicast( Utils.Convert_text_For_multicast(
$"#1234#122#{parent.SipGWIDandRadioID.Split('.')[0]}.{parent.SipGWIDandRadioID.Split('.')[1]}#1#{MainForm2.userIDX}#", $"#1234#122#{parent.SipGWIDandRadioID.Split(".".ToCharArray())[0]}.{parent.SipGWIDandRadioID.Split(".".ToCharArray())[1]}#1#{MainForm2.userIDX}#",
out cmd); out cmd);
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); })); this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
} }
@ -601,8 +601,10 @@ namespace Safedispatch_4_0.Radio
private void SimulateCallInitiated(string sourceCallSipID, string targetCallSipID, SafeMobileLib.CallType callType, ContactType sourceType) private void SimulateCallInitiated(string sourceCallSipID, string targetCallSipID, SafeMobileLib.CallType callType, ContactType sourceType)
{ {
string gwID = parent.SipGWIDandRadioID.Split('.')[0]; string[] tmpArr = parent.SipGWIDandRadioID.Split(".".ToCharArray());
string radioGwID = parent.SipGWIDandRadioID.Split('.')[1];
string gwID = tmpArr[0];
string radioGwID = tmpArr[1];
parent.Handle125Command(gwID, radioGwID, sourceCallSipID, 1, (int)callType, int.Parse(targetCallSipID), true); parent.Handle125Command(gwID, radioGwID, sourceCallSipID, 1, (int)callType, int.Parse(targetCallSipID), true);
// Add info in system tab // Add info in system tab
//#0.0#125#gatewayId.gatewayRadioId.sourceRadioId#callStatus# callType#targetId# //#0.0#125#gatewayId.gatewayRadioId.sourceRadioId#callStatus# callType#targetId#
@ -623,8 +625,11 @@ namespace Safedispatch_4_0.Radio
private void SimulateHangtime(string sourceCallSipID, string targetCallSipID, SafeMobileLib.CallType typeOfCall, ContactType sourceCallType) private void SimulateHangtime(string sourceCallSipID, string targetCallSipID, SafeMobileLib.CallType typeOfCall, ContactType sourceCallType)
{ {
string gwID = parent.SipGWIDandRadioID.Split('.')[0];
string radioGwID = parent.SipGWIDandRadioID.Split('.')[1]; string[] tmpArr = parent.SipGWIDandRadioID.Split(".".ToCharArray());
string gwID = tmpArr[0];
string radioGwID = tmpArr[1];
parent.Handle125Command(gwID, radioGwID, sourceCallSipID, 2, (int)typeOfCall, int.Parse(targetCallSipID), true); parent.Handle125Command(gwID, radioGwID, sourceCallSipID, 2, (int)typeOfCall, int.Parse(targetCallSipID), true);
// Show info in System Tab // Show info in System Tab
// Add info in system tab // Add info in system tab
@ -640,8 +645,11 @@ namespace Safedispatch_4_0.Radio
private void SimulateCallEnded(string sourceCallSipID, string targetCallSipID, SafeMobileLib.CallType typeOfCall, ContactType sourceCallType) private void SimulateCallEnded(string sourceCallSipID, string targetCallSipID, SafeMobileLib.CallType typeOfCall, ContactType sourceCallType)
{ {
string gwID = parent.SipGWIDandRadioID.Split('.')[0]; string[] tmpArr = parent.SipGWIDandRadioID.Split(".".ToCharArray());
string radioGwID = parent.SipGWIDandRadioID.Split('.')[1]; string gwID = tmpArr[0];
string radioGwID = tmpArr[1];
parent.Handle125Command(gwID, radioGwID, sourceCallSipID, 3, (int)typeOfCall, int.Parse(targetCallSipID), true); parent.Handle125Command(gwID, radioGwID, sourceCallSipID, 3, (int)typeOfCall, int.Parse(targetCallSipID), true);
// Show info in System Tab // Show info in System Tab
// Add info in system tab // Add info in system tab
@ -1233,7 +1241,7 @@ namespace Safedispatch_4_0.Radio
if (obj.group_cpsId == null) if (obj.group_cpsId == null)
{ {
GroupIDFromPath = obj.hddLocation; GroupIDFromPath = obj.hddLocation;
GroupIDFromSplit = GroupIDFromPath.Split('_'); GroupIDFromSplit = GroupIDFromPath.Split("_".ToCharArray());
userWhoWasCalled = GroupIDFromSplit[5]; userWhoWasCalled = GroupIDFromSplit[5];
} }
else else

View File

@ -775,7 +775,7 @@ namespace Safedispatch_4_0
if (RepType == rep_type.JOB_TICKETING) if (RepType == rep_type.JOB_TICKETING)
{ {
//get only checked elements from list //get only checked elements from list
string[] FilterTicketingDateList = rcbTicketingTime.Text.Trim().Split(';'); string[] FilterTicketingDateList = rcbTicketingTime.Text.Trim().Split(";".ToCharArray());
// //
if (FilterTicketingDateList.Count() > 0 && FilterTicketingDateList[0] != "") if (FilterTicketingDateList.Count() > 0 && FilterTicketingDateList[0] != "")
{ {

View File

@ -878,7 +878,7 @@ namespace Safedispatch_4_0
//} //}
// find spaces to add a new line between them // find spaces to add a new line between them
string[] split = DataString.Split(' '); string[] split = DataString.Split(" ".ToCharArray());
if (split.Length == 4) if (split.Length == 4)
DataString = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]); DataString = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
else if (split.Length == 3) else if (split.Length == 3)
@ -968,7 +968,7 @@ namespace Safedispatch_4_0
//} //}
// find spaces to add a new line between them // find spaces to add a new line between them
string[] split = DataString.Split(' '); string[] split = DataString.Split(" ".ToCharArray());
if (split.Length == 4) if (split.Length == 4)
DataString = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]); DataString = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
else if (split.Length == 3) else if (split.Length == 3)
@ -1590,7 +1590,7 @@ namespace Safedispatch_4_0
if (SMSTreeView.SelectedNode == null) if (SMSTreeView.SelectedNode == null)
return; return;
// update text for the LOGGED IN USER // update text for the LOGGED IN USER
labelUser.Text = SMSTreeView.SelectedNode.Text.Split('[')[0].ToUpper(); labelUser.Text = SMSTreeView.SelectedNode.Text.Split("[".ToCharArray())[0].ToUpper();
if (CanSendQuickTextMessage(SMSTreeView.SelectedNode)) if (CanSendQuickTextMessage(SMSTreeView.SelectedNode))
{ {
@ -1627,11 +1627,11 @@ namespace Safedispatch_4_0
} }
SM.Debug("Selected node = " + SMSTreeView.SelectedNode.Name + " with sc_id = " + selectedSC_ID); SM.Debug("Selected node = " + SMSTreeView.SelectedNode.Name + " with sc_id = " + selectedSC_ID);
if(SMSTreeView.SelectedNode.Nodes.Count > 0)
rtbQuickText.NullText = String.Format(MainForm2.returnLNGString("sendquickgroupsms"), SMSTreeView.SelectedNode.Text.Split('[')[0]); string msg = (SMSTreeView.SelectedNode.Nodes.Count > 0) ? MainForm2.returnLNGString("sendquickgroupsms") : MainForm2.returnLNGString("sendquicksms");
else rtbQuickText.NullText = String.Format(msg, SMSTreeView.SelectedNode.Text.Split("[".ToCharArray())[0]);
// update null text for quick send textbox
rtbQuickText.NullText = String.Format(MainForm2.returnLNGString("sendquicksms"), SMSTreeView.SelectedNode.Text.Split('[')[0]);
// display maximum number of characters // display maximum number of characters
rtbQuickText.MaxLength = SmsUtils.GetMaxNumberOfCharacters(MainForm2.radioType); rtbQuickText.MaxLength = SmsUtils.GetMaxNumberOfCharacters(MainForm2.radioType);
if (MainForm2.vehicleHT.Contains(SMSTreeView.SelectedNode.Name)) if (MainForm2.vehicleHT.Contains(SMSTreeView.SelectedNode.Name))

View File

@ -627,7 +627,7 @@ namespace Safedispatch_4_0
public void UpdateExpiredTickets(string listOfExpiredTickets) public void UpdateExpiredTickets(string listOfExpiredTickets)
{ {
string[] expiredTickets = listOfExpiredTickets.Split(','); string[] expiredTickets = listOfExpiredTickets.Split(",".ToCharArray());
try try
{ {
foreach (string expiredTicket in expiredTickets) foreach (string expiredTicket in expiredTickets)
@ -1053,7 +1053,7 @@ namespace Safedispatch_4_0
if (timeValue!= null && timeValue.Length > 0) if (timeValue!= null && timeValue.Length > 0)
{ {
// find spaces to add a new line between them // find spaces to add a new line between them
string[] split = timeValue.Split(' '); string[] split = timeValue.Split(" ".ToCharArray());
if (split.Length == 4) if (split.Length == 4)
cellElement.Text = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]); cellElement.Text = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
else if (split.Length == 3) else if (split.Length == 3)
@ -1079,7 +1079,7 @@ namespace Safedispatch_4_0
{ {
// show tooltip for imei // show tooltip for imei
foreach (String imei in jb.Imei.Split(',')) foreach (String imei in jb.Imei.Split(",".ToCharArray()))
cellElement.ToolTipText = cellElement.ToolTipText + String.Format("{0}: {1}", imei, jb.Status) + System.Environment.NewLine; cellElement.ToolTipText = cellElement.ToolTipText + String.Format("{0}: {1}", imei, jb.Status) + System.Environment.NewLine;
} }
} }

View File

@ -104,7 +104,7 @@ namespace Dispatcher.maptab.UIClasses
string key = $"{LiveTabLocation}_{tabName}"; string key = $"{LiveTabLocation}_{tabName}";
String[] loc = new string[0]; String[] loc = new string[0];
if (MainForm2.HashVal.ContainsKey(key)) if (MainForm2.HashVal.ContainsKey(key))
loc = MainForm2.HashVal[key].ToString().Split(';'); loc = MainForm2.HashVal[key].ToString().Split(";".ToCharArray());
System.Drawing.Point location = loc.Length > 2 ? new System.Drawing.Point(int.Parse(loc[0]), int.Parse(loc[1])) : new System.Drawing.Point(0, 0); System.Drawing.Point location = loc.Length > 2 ? new System.Drawing.Point(int.Parse(loc[0]), int.Parse(loc[1])) : new System.Drawing.Point(0, 0);
System.Drawing.Size size = loc.Length > 3 ? new System.Drawing.Size(int.Parse(loc[2]), int.Parse(loc[3])) : new System.Drawing.Size(800, 640); System.Drawing.Size size = loc.Length > 3 ? new System.Drawing.Size(int.Parse(loc[2]), int.Parse(loc[3])) : new System.Drawing.Size(800, 640);

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -263,19 +263,24 @@ namespace SipComponent
} }
else else
_localIPaddress = localIPAddress; _localIPaddress = localIPAddress;
_sipDomainPort = sipDomainPort; _sipDomainPort = sipDomainPort;
_sipClient = CreateSipClientClass(sipDomain, _sipDomainPort, _localIPaddress, localSipPort, userName, password, requestTimeout); _sipClient = CreateSipClientClass(sipDomain, _sipDomainPort, _localIPaddress, localSipPort, userName, password, requestTimeout);
_bufferMiliseconds = bufferMiliseconds; _bufferMiliseconds = bufferMiliseconds;
// Registration Timer // Registration Timer
_registrationInterval = registrationInterval; _registrationInterval = registrationInterval;
_registrationData = new RegistrationData(userName, _registrationInterval + 2); _registrationData = new RegistrationData(userName, _registrationInterval + 2);
System.Timers.Timer registrationTimer = new System.Timers.Timer(); System.Timers.Timer registrationTimer = new System.Timers.Timer();
// Set up the registration timer // Set up the registration timer
registrationTimer.Interval = _registrationInterval * 1000; registrationTimer.Interval = _registrationInterval * 1000;
registrationTimer.Elapsed += _registrationTimer_Elapsed; registrationTimer.Elapsed += _registrationTimer_Elapsed;
_sipID_regTimer_regStatus_Dict.Add(userName, _sipID_regTimer_regStatus_Dict.Add(userName,
new Tuple<System.Timers.Timer, RegistrationStatus>(registrationTimer, RegistrationStatus.RegistrationNotStarted new Tuple<System.Timers.Timer, RegistrationStatus>(registrationTimer, RegistrationStatus.RegistrationNotStarted
)); ));
_IDsregisteredList.Add(userName); _IDsregisteredList.Add(userName);
StartRegistrationTimer(); StartRegistrationTimer();
@ -304,6 +309,7 @@ namespace SipComponent
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
if (idToInvite == null) if (idToInvite == null)
throw new ArgumentNullException("idToInvite"); throw new ArgumentNullException("idToInvite");
lock (_lockerSipDialog) lock (_lockerSipDialog)
{ {
if (!_IDsentInviteDict.ContainsKey(idToInvite) && !_IDreceivedInviteDict.ContainsKey(idToInvite) if (!_IDsentInviteDict.ContainsKey(idToInvite) && !_IDreceivedInviteDict.ContainsKey(idToInvite)
@ -324,6 +330,7 @@ namespace SipComponent
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
if (groupIDtoInvite == null) if (groupIDtoInvite == null)
throw new ArgumentNullException("groupIDtoInvite"); throw new ArgumentNullException("groupIDtoInvite");
// Check if registered to the group id // Check if registered to the group id
lock (_lockerSipDialog) lock (_lockerSipDialog)
{ {
@ -342,6 +349,7 @@ namespace SipComponent
{ {
if (_sipClassClosed) if (_sipClassClosed)
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
Task t = null; Task t = null;
CancelInvite_private(idToCancel, out t); CancelInvite_private(idToCancel, out t);
} }
@ -370,6 +378,7 @@ namespace SipComponent
{ {
return dialog.CallID == _IDsentInviteDict[idToCancel].CallID; return dialog.CallID == _IDsentInviteDict[idToCancel].CallID;
}); });
if (d != null) if (d != null)
{ {
//Send Cancel Request //Send Cancel Request
@ -387,6 +396,7 @@ namespace SipComponent
} }
}, d); }, d);
} }
// Remove from dict // Remove from dict
_IDsentInviteDict.Remove(idToCancel); _IDsentInviteDict.Remove(idToCancel);
_IDsCalledByMeList.Remove(idToCancel); _IDsCalledByMeList.Remove(idToCancel);
@ -585,6 +595,7 @@ namespace SipComponent
{ {
if (_sipClassClosed) if (_sipClassClosed)
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
lock (_lockerSipDialog) lock (_lockerSipDialog)
{ {
if (_IDdialogTuple.ContainsKey(idToSendVoice)) if (_IDdialogTuple.ContainsKey(idToSendVoice))
@ -603,29 +614,29 @@ namespace SipComponent
{ {
if (_sipClassClosed) if (_sipClassClosed)
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
if (idToRequestGps != null)
{ if (idToRequestGps == null)
// Send Gps request for Linx
// [#msgLen]#seqID#154#
string cmdText = string.Format("#{0}#154#", seqID);
string cmd = AddMsgLenForMBus(cmdText);
Message pollRequestForLinx = GenerateSipMessage(idToRequestGps, UserName, _sipClient.Domain, _sipDomainPort, cmd);
pollRequestForLinx.Header.Add("Ais-Service", "mbus");
Task.Factory.StartNew(() =>
{
try
{
_sipClient.SendRequest(pollRequestForLinx);
}
catch (Exception)
{
; // Probably timeout exception, do not do anything
}
});
}
else
throw new ArgumentNullException("idToRequestGps"); throw new ArgumentNullException("idToRequestGps");
// Send Gps request for Linx
// [#msgLen]#seqID#154#
string cmdText = string.Format("#{0}#154#", seqID);
string cmd = AddMsgLenForMBus(cmdText);
Message pollRequestForLinx = GenerateSipMessage(idToRequestGps, UserName, _sipClient.Domain, _sipDomainPort, cmd);
pollRequestForLinx.Header.Add("Ais-Service", "mbus");
Task.Factory.StartNew(() =>
{
try
{
_sipClient.SendRequest(pollRequestForLinx);
}
catch (Exception)
{
; // Probably timeout exception, do not do anything
}
});
} }
/// <summary> /// <summary>
@ -636,26 +647,26 @@ namespace SipComponent
{ {
if (_sipClassClosed) if (_sipClassClosed)
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
if (linxID != null)
{ if (linxID == null)
// Send [#msgLen]#seqID#238#
string textToSend = string.Format("#{0}#238#", _rand.Next().ToString());
string cmdToSend = AddMsgLenForMBus(textToSend);
Message sipMessage = GenerateSipMessage(linxID, UserName, _sipClient.Domain, _sipDomainPort, cmdToSend);
Task.Factory.StartNew(() =>
{
try
{
_sipClient.SendRequest(sipMessage);
}
catch (Exception)
{
// Do nothing
}
});
}
else
throw new ArgumentNullException("linxID"); throw new ArgumentNullException("linxID");
// Send [#msgLen]#seqID#238#
string textToSend = string.Format("#{0}#238#", _rand.Next().ToString());
string cmdToSend = AddMsgLenForMBus(textToSend);
Message sipMessage = GenerateSipMessage(linxID, UserName, _sipClient.Domain, _sipDomainPort, cmdToSend);
Task.Factory.StartNew(() =>
{
try
{
_sipClient.SendRequest(sipMessage);
}
catch (Exception)
{
// Do nothing
}
});
} }
/// <summary> /// <summary>
@ -669,10 +680,12 @@ namespace SipComponent
{ {
if (_sipClassClosed) if (_sipClassClosed)
throw new ObjectDisposedException("SipClientClass"); throw new ObjectDisposedException("SipClientClass");
if (idToSendSMS != null && text != null) if (idToSendSMS != null && text != null)
{ {
bool sendSipMessage = true; bool sendSipMessage = true;
string unconfirmedSmsKey = null; string unconfirmedSmsKey = null;
if (_smsConfirmationFromServer) if (_smsConfirmationFromServer)
{ {
unconfirmedSmsKey = idToSendSMS + text.GetHashCode(); unconfirmedSmsKey = idToSendSMS + text.GetHashCode();
@ -691,6 +704,7 @@ namespace SipComponent
} }
} }
} }
if (sendSipMessage) if (sendSipMessage)
{ {
// Create a new thread on which: // Create a new thread on which:
@ -743,15 +757,16 @@ namespace SipComponent
throw new ArgumentNullException("text"); throw new ArgumentNullException("text");
} }
private Message GenerateSipMessage(string destinationID, string senderID, string sipServer, private Message GenerateSipMessage(string destinationID, string senderID, string sipServer, int sipServerPort, string text)
int sipServerPort, string text)
{ {
Message sipMessage = new Message(); Message sipMessage = new Message()
sipMessage.Uri = "sip:" + destinationID + "@" + sipServer + ":" + sipServerPort; {
sipMessage.From = new ContactInfo(string.Format("sip:{0}@{1}", senderID, sipServer)); Uri = $"sip:{destinationID}@{sipServer}:{sipServerPort}",
sipMessage.To = new ContactInfo(string.Format("sip:{0}@{1}", destinationID, sipServer)); From = new ContactInfo($"sip:{senderID}@{sipServer}"),
sipMessage.ContentType = "text/plain;charset=UTF-8"; To = new ContactInfo($"sip:{destinationID}@{sipServer}"),
sipMessage.Body = text; ContentType = "text/plain;charset=UTF-8",
Body = text
};
return sipMessage; return sipMessage;
} }
@ -833,10 +848,12 @@ namespace SipComponent
if (!_sipClassClosed) if (!_sipClassClosed)
{ {
_sipClassClosed = true; _sipClassClosed = true;
// Send ARS OFF and disconnect from socket IO // Send ARS OFF and disconnect from socket IO
if (_sendArsOnOff) if (_sendArsOnOff)
_socketIOClass.SendArs(new ArsInfo(false, "0", UserName)); _socketIOClass.SendArs(new ArsInfo(false, "0", UserName));
_socketIOClass.Disconect(); _socketIOClass.Disconect();
// //
List<string> sipIDs = new List<string>(); List<string> sipIDs = new List<string>();
Task task = null; Task task = null;
@ -892,6 +909,7 @@ namespace SipComponent
// Stop sip class // Stop sip class
_sipClient.Disconnect(); _sipClient.Disconnect();
}); });
if (!async) if (!async)
t.Wait(); t.Wait();
} }
@ -911,6 +929,8 @@ namespace SipComponent
zeroRegistrationData = new RegistrationData(id, 0, true); zeroRegistrationData = new RegistrationData(id, 0, true);
else else
zeroRegistrationData = new RegistrationData(id, 0); zeroRegistrationData = new RegistrationData(id, 0);
_sipID_regTimer_regStatus_Dict[id].Item1.Stop(); _sipID_regTimer_regStatus_Dict[id].Item1.Stop();
SendSipRegister(zeroRegistrationData); SendSipRegister(zeroRegistrationData);
} }
@ -1398,10 +1418,11 @@ namespace SipComponent
string lastWord = source.Substring(source.LastIndexOf(' ') + 1); string lastWord = source.Substring(source.LastIndexOf(' ') + 1);
if (lastWord.Contains("delivered")) if (lastWord.Contains("delivered"))
return true; return true;
else if (lastWord.Contains("failed"))
if (lastWord.Contains("failed"))
return false; return false;
else
throw new ApplicationException("Error on parsing the sms confirmation from sip server"); throw new ApplicationException("Error on parsing the sms confirmation from sip server");
} }
#endregion #endregion
@ -1418,11 +1439,13 @@ namespace SipComponent
// Extract ip and port where to send voice to simoco // Extract ip and port where to send voice to simoco
IPAddress ipToSendAudio = null; IPAddress ipToSendAudio = null;
int portToSendAudio; int portToSendAudio;
if (IPAddress.TryParse(receivedSDP.Connection.Address, out ipToSendAudio)) if (IPAddress.TryParse(receivedSDP.Connection.Address, out ipToSendAudio))
{ {
portToSendAudio = receivedSDP.Media[0].Port; portToSendAudio = receivedSDP.Media[0].Port;
} }
else throw new ApplicationException("Canot determine ip where to send audio"); else
throw new ApplicationException("Canot determine ip where to send audio");
// Creez clientul de UDP conectat la portul pe care voi primi voce // Creez clientul de UDP conectat la portul pe care voi primi voce
UdpClient udpClient = new UdpClient(localRTPport); UdpClient udpClient = new UdpClient(localRTPport);
@ -1563,9 +1586,9 @@ namespace SipComponent
private SipClient CreateSipClientClass(string sipDomain, int sipDomainPort, string localIPaddress, int localSipPort, string userName, string password, int requestTimeout) private SipClient CreateSipClientClass(string sipDomain, int sipDomainPort, string localIPaddress, int localSipPort, string userName, string password, int requestTimeout)
{ {
SipClient sipClient;
// Set up the master SIP class // Set up the master SIP class
sipClient = new SipClient(sipDomain, sipDomainPort, Independentsoft.Sip.ProtocolType.Udp, userName, password); SipClient sipClient = new SipClient(sipDomain, sipDomainPort, Independentsoft.Sip.ProtocolType.Udp, userName, password);
sipClient.LocalIPEndPoint = new IPEndPoint(IPAddress.Parse(localIPaddress), localSipPort); sipClient.LocalIPEndPoint = new IPEndPoint(IPAddress.Parse(localIPaddress), localSipPort);
// Turn on logging // Turn on logging
//sipClient.Logger = new Logger(AppDomain.CurrentDomain.BaseDirectory + "\\sipLog.txt"); //sipClient.Logger = new Logger(AppDomain.CurrentDomain.BaseDirectory + "\\sipLog.txt");
@ -1590,6 +1613,7 @@ namespace SipComponent
int rtpPort = ReturnAvailablePort(); int rtpPort = ReturnAvailablePort();
SessionDescription sdp = CreateSDP(rtpPort); SessionDescription sdp = CreateSDP(rtpPort);
Invite inv = new Invite(); Invite inv = new Invite();
inv.Uri = "sip:" + idToCall + "@" + sipServerIP; inv.Uri = "sip:" + idToCall + "@" + sipServerIP;
inv.From = new ContactInfo("sip:" + sipID.ToString() + "@" + sipServerIP); inv.From = new ContactInfo("sip:" + sipID.ToString() + "@" + sipServerIP);
@ -1650,20 +1674,17 @@ namespace SipComponent
private void SendSipRegister(object registrationDataObj) private void SendSipRegister(object registrationDataObj)
{ {
string sipServerIP = _sipClient.Domain; string sipServerIP = _sipClient.Domain;
RegistrationData regData = (RegistrationData)registrationDataObj; RegistrationData regData = (RegistrationData)registrationDataObj;
string sipIDfrom = _sipClient.Username; string sipIDfrom = _sipClient.Username;
string sipIDto = regData.SipID; string sipIDto = regData.SipID;
int expiresValue = regData.Expires; int expiresValue = regData.Expires;
bool isUnregisterRequest = (expiresValue == 0); bool isUnregisterRequest = (expiresValue == 0);
Register reg = new Register(); Register reg = new Register();
reg.Uri = "sip:" + sipServerIP; reg.Uri = "sip:" + sipServerIP;
reg.From = new ContactInfo( reg.From = new ContactInfo( sipIDfrom.ToString(), $"sip:{sipIDfrom}@{sipServerIP}");
sipIDfrom.ToString(), reg.To = new ContactInfo( sipIDto.ToString(), $"sip:{sipIDto}@{sipServerIP}");
"sip:" + sipIDfrom + "@" + sipServerIP);
reg.To = new ContactInfo(
sipIDto.ToString(),
"sip:" + sipIDto.ToString() + "@" + sipServerIP);
reg.Contact = new Contact("sip:" + sipIDfrom.ToString() + "@" + _sipClient.LocalIPEndPoint.ToString()); reg.Contact = new Contact("sip:" + sipIDfrom.ToString() + "@" + _sipClient.LocalIPEndPoint.ToString());
reg.Expires = expiresValue; reg.Expires = expiresValue;
@ -1763,6 +1784,7 @@ namespace SipComponent
{ {
SendSipRegister(state); SendSipRegister(state);
}, _registrationData); }, _registrationData);
// Start registration timer // Start registration timer
_sipID_regTimer_regStatus_Dict[UserName].Item1.Start(); _sipID_regTimer_regStatus_Dict[UserName].Item1.Start();
} }
@ -1807,10 +1829,12 @@ namespace SipComponent
{ {
rtpPort += 2; rtpPort += 2;
} }
if (rtpPort < MaxRtpPortNumber) if (rtpPort < MaxRtpPortNumber)
return rtpPort; return rtpPort;
else
throw new SipClassException(
throw new SipClassException(
string.Format("Nu gasesc port liber in range-ul {0} - {1}", MinRtpPortNumber, MaxRtpPortNumber)); string.Format("Nu gasesc port liber in range-ul {0} - {1}", MinRtpPortNumber, MaxRtpPortNumber));
} }
} }
@ -1821,10 +1845,8 @@ namespace SipComponent
{ {
return invite.SessionDescription.Media[0].Port == portNb; return invite.SessionDescription.Media[0].Port == portNb;
}); });
if (inv != null)
return true; return (inv != null);
else
return false;
} }
private bool IsPortAllreadyInUse(int portNumber) private bool IsPortAllreadyInUse(int portNumber)
@ -1843,15 +1865,12 @@ namespace SipComponent
public static bool ValidRtpPort(int rtpPort) public static bool ValidRtpPort(int rtpPort)
{ {
if (rtpPort < 1024 || rtpPort > 65534) if (rtpPort < 1024 || rtpPort > 65534)
{
return false; return false;
}
else if (rtpPort % 2 == 1) if (rtpPort % 2 == 1)
{
return false; return false;
}
else return true;
return true;
} }
/// <summary> /// <summary>
@ -1870,11 +1889,6 @@ namespace SipComponent
private bool IsInSameSubnet(IPAddress address2, IPAddress address, IPAddress subnetMask) private bool IsInSameSubnet(IPAddress address2, IPAddress address, IPAddress subnetMask)
{ {
IPAddress network1 = GetNetworkAddress(address, subnetMask); IPAddress network1 = GetNetworkAddress(address, subnetMask);

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -266,7 +266,7 @@ namespace SubscriberAndUserManager
public static Boolean TestIP(string IP) public static Boolean TestIP(string IP)
{ {
String[] tmp = IP.Split('.'); String[] tmp = IP.Split(".".ToCharArray());
if (tmp.Length != 4) return false; if (tmp.Length != 4) return false;
Int32 number; Int32 number;
bool result; bool result;
@ -913,7 +913,7 @@ namespace SubscriberAndUserManager
int result = clientStream.Read(message, 0, message.Length); int result = clientStream.Read(message, 0, message.Length);
Console.WriteLine("Received registration from server"); Console.WriteLine("Received registration from server");
String decodedString = encoding.GetString(message).Trim('\0'); String decodedString = encoding.GetString(message).Trim('\0');
String[] options = decodedString.Split(';'); String[] options = decodedString.Split(";".ToCharArray());
Console.WriteLine("Option" + decodedString); Console.WriteLine("Option" + decodedString);
APP_SERVER_VERSION = options[options.Length - 1].Replace("valid-", ""); APP_SERVER_VERSION = options[options.Length - 1].Replace("valid-", "");

View File

@ -32,6 +32,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -1029,7 +1029,7 @@ namespace SubscriberAndUserManager
private void EditRangeVehicles() private void EditRangeVehicles()
{ {
int carID = ((Car)((RadListDataItem)cbImageList.SelectedItem).Value).idx; int carID = ((Car)((RadListDataItem)cbImageList.SelectedItem).Value).idx;
string[] idList = IDList.Replace("(", "").Replace(")", "").Split(','); string[] idList = IDList.Replace("(", "").Replace(")", "").Split(",".ToCharArray());
bool isUnitDeleted = DB.isUnitDeleted(idList[0]); bool isUnitDeleted = DB.isUnitDeleted(idList[0]);
if (cbStatus.Text.Equals(MainForm.returnLNGString("active")) && isUnitDeleted) if (cbStatus.Text.Equals(MainForm.returnLNGString("active")) && isUnitDeleted)

View File

@ -835,19 +835,28 @@ namespace SubscriberAndUserManager
} }
private void SendBackupListRequest() private void SendBackupListRequest()
{ {
if(MainForm.udp != null) 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); {
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#53#1#");
MainForm.udp.Send(dataToSend, dataToSend.Length);
}
} }
private void SendBackupRequest() private void SendBackupRequest()
{ {
if (MainForm.udp != null) 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) private void SendRestoreRequest(string filename)
{ {
if (MainForm.udp != null) 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); delegate void UpdateList(string fileNames);
@ -861,13 +870,15 @@ namespace SubscriberAndUserManager
else else
{ {
listBackups.Items.Clear(); listBackups.Items.Clear();
string[] fileNameArr = fileNames.Split(';'); string[] fileNameArr = fileNames.Split(";".ToCharArray());
foreach (string fName in fileNameArr) if (fileNameArr != null && fileNameArr.Length > 0)
{ {
if (fName != "") foreach (string fName in fileNameArr)
{ {
RadListDataItem r = new RadListDataItem(fName); if (fName != "")
listBackups.Items.Add(r); {
listBackups.Items.Add(new RadListDataItem(fName));
}
} }
} }
} }
@ -888,7 +899,7 @@ namespace SubscriberAndUserManager
{ {
if (text.Contains(".tar")) if (text.Contains(".tar"))
{ {
string[] backupList = text.Substring(0, text.Length - 1).Split(';'); string[] backupList = text.Substring(0, text.Length - 1).Split(";".ToCharArray());
listBackups.Items.Clear(); listBackups.Items.Clear();
foreach (string bk in backupList) foreach (string bk in backupList)
listBackups.Items.Add(bk); listBackups.Items.Add(bk);
@ -1439,7 +1450,7 @@ namespace SubscriberAndUserManager
string rtpstart = o["data"]["ports"]["rtpstart"].ToString(); string rtpstart = o["data"]["ports"]["rtpstart"].ToString();
string rtpend = o["data"]["ports"]["rtpend"].ToString(); string rtpend = o["data"]["ports"]["rtpend"].ToString();
string publicIp = o["data"]["network"]["publicIp"].ToString(); string publicIp = o["data"]["network"]["publicIp"].ToString();
string sipPort = o["data"]["ports"]["udpbindaddr"].ToString().Split(':')[1]; string sipPort = o["data"]["ports"]["udpbindaddr"].ToString().Split(":".ToCharArray())[1];
txLanIP.Value = lanIP; txLanIP.Value = lanIP;
txNatIP.Value = publicIp; txNatIP.Value = publicIp;
txUdpStart.Value = rtpstart; txUdpStart.Value = rtpstart;

View File

@ -852,7 +852,7 @@ namespace SubscriberAndUserManager
if (alm.Speed != "") if (alm.Speed != "")
{ {
chbSpeed.Checked = true; chbSpeed.Checked = true;
string[] arrSpeed = alm.Speed.Split('_'); string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
Int16 speed = 1; Int16 speed = 1;
Int16.TryParse(arrSpeed[0], out speed); Int16.TryParse(arrSpeed[0], out speed);
@ -943,7 +943,7 @@ namespace SubscriberAndUserManager
if (alm.Speed != "") if (alm.Speed != "")
{ {
SpeedStat = 1; SpeedStat = 1;
string[] arrSpeed = alm.Speed.Split('_'); string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
Speedvalue = arrSpeed[0]; Speedvalue = arrSpeed[0];
if (arrSpeed.Length == 2) if (arrSpeed.Length == 2)
{ {
@ -980,7 +980,7 @@ namespace SubscriberAndUserManager
if (((alm.Loneworker != "") && (LoneStat ==0))||((alm.Loneworker == "") && (LoneStat ==1))) LoneStat = 2; if (((alm.Loneworker != "") && (LoneStat ==0))||((alm.Loneworker == "") && (LoneStat ==1))) LoneStat = 2;
if (alm.Speed != "") if (alm.Speed != "")
{ {
string[] arrSpeed = alm.Speed.Split('_'); string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
if (Speedvalue != arrSpeed[0]) if (Speedvalue != arrSpeed[0])
{ {
Speedvalue = "0"; SpeedStat = 2; Speedvalue = "0"; SpeedStat = 2;

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.1.0.10898")] [assembly: AssemblyVersion("8.2.0.10898")]
[assembly: AssemblyFileVersion("8.1.0.10898")] [assembly: AssemblyFileVersion("8.2.0.10898")]

View File

@ -112,7 +112,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="prebuild.sh" /> <None Include="prebuild.sh" />
<None Include="RunMessagesPartitioning.bat" /> <None Include="RunMessagesPartitioning.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5"> <BootstrapperPackage Include=".NETFramework,Version=v4.5">
@ -144,7 +146,9 @@
<Content Include="7toLatest7.sql"> <Content Include="7toLatest7.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="call_messages_partitioning.sql" /> <Content Include="call_messages_partitioning.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="CreateMissingForeignKeys.sql"> <Content Include="CreateMissingForeignKeys.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
@ -154,8 +158,12 @@
<Content Include="CreateMissingPrimaryKeys.sql"> <Content Include="CreateMissingPrimaryKeys.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="generate_partitioning_of_an_existing_table_by_date_unix_time.sql" /> <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" /> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="get_query_partitioning_of_an_existing_table_by_date_unix_time.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="NewFields.sql"> <Content Include="NewFields.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>