Compare commits

..

No commits in common. "master" and "refactor_code2" have entirely different histories.

9 changed files with 52 additions and 94 deletions

View File

@ -262,7 +262,6 @@ namespace AppServer
{ {
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);
@ -272,8 +271,7 @@ 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#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -351,13 +349,9 @@ 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") if (ex.Message == "AlarmError") test2 = "#210#5#Can't write Alarm data in DB#";
test2 = "#210#5#Can't write Alarm data in DB#"; else if (ex.Message == "StolenError") test2 = "#210#6#Can't write Stolen data in DB#";
else if (ex.Message == "StolenError") MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
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)
{ {
@ -403,10 +397,7 @@ 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(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} "); Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} ");
} }
} }
@ -587,8 +578,7 @@ namespace AppServer
{ {
//send alarm on message buss //send alarm on message buss
test = "#136#" + radioID.ToString() + "#" + tmpresp + "#"; test = "#136#" + radioID.ToString() + "#" + tmpresp + "#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString(); String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString();
@ -616,10 +606,7 @@ 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(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).Length);
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test);
MainForm.udp.Send(dataToSend, dataToSend.Length);
Thread.Sleep(100); 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)}]");
@ -631,8 +618,7 @@ namespace AppServer
{ {
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() + "#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).Length);
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)}]");
} }
@ -642,8 +628,7 @@ 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 + "#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + test); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
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)}]");
@ -699,16 +684,14 @@ namespace AppServer
{ {
//send alarm on message buss //send alarm on message buss
string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#"; string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
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 + "#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
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} ");
@ -777,7 +760,6 @@ namespace AppServer
//send alarm on message buss //send alarm on message buss
string speed4send = $"{speed}_{speedUnits}"; string speed4send = $"{speed}_{speedUnits}";
string test = "#135#" + radioID.ToString() + "#" + speed4send + "#"; 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); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
} }
} }

View File

@ -729,8 +729,8 @@ namespace AppServer
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 + "#";
byte[] cmd = Utils.Convert_text_For_multicast("#0.0" + test1); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test1);
MainForm.udp.Send(cmd, cmd.Length); MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
//send to email if was sms->email type //send to email if was sms->email type
if (dec3.isEmail) if (dec3.isEmail)
@ -738,11 +738,12 @@ 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 = (dec3.sqlResp == sqlResponse.done) ? "#232#1#" : "#232#0#"; test = "";
if (dec3.sqlResp == sqlResponse.done)
test = "#232#1#";
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID3 + test); else
MainForm.udp.Send(dataToSend, dataToSend.Length); test = "#232#0#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test).Length);
if (MainForm.SendPOLLafterSMS) if (MainForm.SendPOLLafterSMS)
{ {
@ -752,7 +753,7 @@ namespace AppServer
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}";
dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#"); byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#154#" + dest + "#");
MainForm.udp.Send(dataToSend, dataToSend.Length); MainForm.udp.Send(dataToSend, dataToSend.Length);
} }
} }

View File

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

@ -108,9 +108,8 @@ namespace AppServer
+ 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#"
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#"); + command[1].Trim() + "#").Length);
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

@ -172,9 +172,7 @@ namespace AppServer
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

@ -452,9 +452,13 @@ 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"]);
@ -464,22 +468,16 @@ namespace SafeMobileLib
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 = string.Empty, Address = dr["address"].ToString(),
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();
} }

View File

@ -91,8 +91,7 @@ namespace SafeMobileLib
{ {
if (udpMulticast != null) if (udpMulticast != null)
{ {
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID + test); udpMulticast.Send(Utils.Convert_text_For_multicast("#" + seqID + test), Utils.Convert_text_For_multicast("#" + seqID + test).Length);
udpMulticast.Send(dataToSend, dataToSend.Length);
} }
else else
{ {

View File

@ -837,26 +837,17 @@ 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);

View File

@ -112,9 +112,7 @@
<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">
@ -146,9 +144,7 @@
<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>
@ -158,12 +154,8 @@
<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" />
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <Content Include="get_query_partitioning_of_an_existing_table_by_date_unix_time.sql" />
</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>