Compare commits
32 Commits
Batch_Hist
...
master
Author | SHA1 | Date | |
---|---|---|---|
74fa47daa6 | |||
93bfc46d85 | |||
16647ca6c4 | |||
f70027424c | |||
8e1e233826 | |||
df1dc2bf15 | |||
7bb4a6dc66 | |||
2e5267b6f7 | |||
6273746693 | |||
377c21c338 | |||
65a08de6d8 | |||
44e89bfb87 | |||
ccaa256960 | |||
126aba5ee5 | |||
5291e2cb5b | |||
df0e2e1796 | |||
6737c17c27 | |||
4f3c7b5870 | |||
13f25867b8 | |||
f765fe48b9 | |||
61fa677598 | |||
e1c315402f | |||
23cfa40272 | |||
a69dc4c6ef | |||
0253478eac | |||
e973feb124 | |||
0be7970c63 | |||
a67b7cc0cd | |||
d79e92ca64 | |||
b5d538cbc3 | |||
c9f57fabb2 | |||
60262a4db1 |
@ -22,6 +22,7 @@ namespace AppServer
|
||||
private volatile DBsubsOperationManager dbsubsoperManage;
|
||||
private volatile DBvehiclesManager dbvehs;
|
||||
private DBvehiclesManager DBvehInfo;
|
||||
|
||||
|
||||
public static volatile Int32 LocationCheckQueuesCount = 0;
|
||||
Int64 count = 0;
|
||||
@ -123,7 +124,7 @@ namespace AppServer
|
||||
while (line != default(string))
|
||||
{
|
||||
BeforeWriteDB = true;
|
||||
string[] tempArr = line.Split('#');
|
||||
string[] tempArr = line.Split("#".ToCharArray());
|
||||
//imei
|
||||
try
|
||||
{
|
||||
@ -184,12 +185,12 @@ namespace AppServer
|
||||
{
|
||||
Vehicle_Data v_data = (Vehicle_Data)MainForm.VehList[radioID2.ToString()];
|
||||
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)
|
||||
{
|
||||
SpeedProccess = processZoneAlarm(radioID2, dec2.cell, zone, landMark, alarm.Email, !prevGps);
|
||||
@ -200,7 +201,7 @@ namespace AppServer
|
||||
|
||||
if (SpeedProccess != "")
|
||||
{
|
||||
string[] temp = SpeedProccess.Split('_');
|
||||
string[] temp = SpeedProccess.Split("_".ToCharArray());
|
||||
int speedT = (int)Convert.ToDouble(temp[0]);
|
||||
string speedU = temp[1];
|
||||
processSpeedAlarm(radioID2, dec2.cell, speedT, speedU, alarm.Email, !prevGps);
|
||||
@ -256,11 +257,12 @@ namespace AppServer
|
||||
{
|
||||
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))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//get unit system position
|
||||
int unitSC_ID = ((Vehicle_Data)MainForm.VehList[radioID2]).sc_id;
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
@ -270,7 +272,8 @@ namespace AppServer
|
||||
//send radio disable to GW
|
||||
Utils.WriteLine("Radio disable was sent on " + sysPos.Gw_id + "." + sysPos.R_gw_id + " gateway", ConsoleColor.Cyan);
|
||||
string test2 = $"#{(int)MessageBusCmds.RadioEnableDisableRequest}#" + dest + "#0#";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -288,37 +291,40 @@ namespace AppServer
|
||||
//Calculate status
|
||||
if (MainForm.VehicleHashStat.ContainsKey(radioID2.ToString()) && !prevGps)
|
||||
{
|
||||
|
||||
VehicleStatus vehicleStatus = (VehicleStatus)MainForm.VehicleHashStat[radioID2];
|
||||
|
||||
//MADE ON status when is the case
|
||||
if ((((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus == Status_for_tab.MADEOFF)
|
||||
|| (((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus == Status_for_tab.OFF))
|
||||
if ((vehicleStatus.curentStatus == Status_for_tab.MADEOFF)
|
||||
|| (vehicleStatus.curentStatus == Status_for_tab.OFF))
|
||||
{
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus = Status_for_tab.MADEON;
|
||||
vehicleStatus.curentStatus = Status_for_tab.MADEON;
|
||||
PushStatus(radioID2, Status_for_tab.MADEON);
|
||||
}
|
||||
|
||||
// update last status location and position time
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID2]).lastPositionTime = DateTime.Now;
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID2]).lat = dec2.cell.d_lat;
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID2]).lng = dec2.cell.d_lng;
|
||||
vehicleStatus.lastPositionTime = DateTime.Now;
|
||||
vehicleStatus.lat = dec2.cell.d_lat;
|
||||
vehicleStatus.lng = dec2.cell.d_lng;
|
||||
|
||||
// do not push any status update if the current status is emergency
|
||||
if (((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus != Status_for_tab.EMERG)
|
||||
if (vehicleStatus.curentStatus != Status_for_tab.EMERG)
|
||||
{
|
||||
|
||||
if (dec2.cell.lat != "0" && dec2.cell.lat != "0.00000")
|
||||
{
|
||||
if (((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus != Status_for_tab.GPS_ON)
|
||||
if (vehicleStatus.curentStatus != Status_for_tab.GPS_ON)
|
||||
{
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus = Status_for_tab.GPS_ON;
|
||||
vehicleStatus.curentStatus = Status_for_tab.GPS_ON;
|
||||
//SM.Debug("Push Status GPS ON for radio:"+radioID2);
|
||||
PushStatus(radioID2, Status_for_tab.GPS_ON);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus != Status_for_tab.NOGPSFIX)
|
||||
if (vehicleStatus.curentStatus != Status_for_tab.NOGPSFIX)
|
||||
{
|
||||
((VehicleStatus)MainForm.VehicleHashStat[radioID2]).curentStatus = Status_for_tab.NOGPSFIX;
|
||||
vehicleStatus.curentStatus = Status_for_tab.NOGPSFIX;
|
||||
PushStatus(radioID2, Status_for_tab.NOGPSFIX);
|
||||
}
|
||||
}
|
||||
@ -345,9 +351,13 @@ namespace AppServer
|
||||
try
|
||||
{
|
||||
string test2 = "#210#1#Can't write GPS data in DB#";
|
||||
if (ex.Message == "AlarmError") test2 = "#210#5#Can't write Alarm data in DB#";
|
||||
else if (ex.Message == "StolenError") test2 = "#210#6#Can't write Stolen data in DB#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test2), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test2).Length);
|
||||
if (ex.Message == "AlarmError")
|
||||
test2 = "#210#5#Can't write Alarm data in DB#";
|
||||
else if (ex.Message == "StolenError")
|
||||
test2 = "#210#6#Can't write Stolen data in DB#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test2);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -393,7 +403,10 @@ namespace AppServer
|
||||
{
|
||||
// send callout clear
|
||||
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()} ");
|
||||
}
|
||||
}
|
||||
@ -404,54 +417,101 @@ namespace AppServer
|
||||
|
||||
private void sendMailGeo(string mes, String subj, string mailAdr)
|
||||
{
|
||||
try
|
||||
|
||||
if (Program.cfg.enableEmailService)
|
||||
{
|
||||
MailAddress from = new MailAddress(Program.cfg.emailAddress);
|
||||
String[] address = mailAdr.Split(';');
|
||||
MailAddress to = new MailAddress(address[0]);
|
||||
MailMessage message = new MailMessage(from, to);
|
||||
if (address.Count() > 1)
|
||||
if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
|
||||
{
|
||||
Boolean skipeFirst = true;
|
||||
foreach (String obj in address)
|
||||
if (MainForm.IsBlacklistedAddress(mailAdr))
|
||||
{
|
||||
if (skipeFirst) { skipeFirst = false; }
|
||||
else message.To.Add(new MailAddress(obj));
|
||||
Utils.WriteLine($"sendMailGeo : The email '{subj}' was not sent. Email address '{mailAdr}' is in blacklist count = {MainForm.blackListAddress[mailAdr]}");
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
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
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
Utils.WriteLine("Exception in sendMailAlarm2: {0}" + ex.ToString(), ConsoleColor.Red);
|
||||
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Cyan);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
@ -497,50 +557,40 @@ namespace AppServer
|
||||
else if ((obj2.AlarmType == 1) && (position == 2)) validAlarm = true;
|
||||
else if ((obj2.AlarmType == 2) && (position == 1)) validAlarm = true;
|
||||
else if (obj2.AlarmType == 4) validAlarm = false;
|
||||
|
||||
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);
|
||||
Utils.WriteLine("Done Add new zone alarm");
|
||||
if (obj2.speedUnit.Equals("k"))
|
||||
|
||||
// send Alert by email if the emailServer is configured
|
||||
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/h 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);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = "Zone alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp
|
||||
+ ". Unit speed " + speedMiles + " 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 != "")
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
sendAlarmMail(title, message, mailAdr);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String test = "";
|
||||
if (sendOnMsgBus)
|
||||
{
|
||||
//send alarm on message buss
|
||||
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();
|
||||
///send SMS
|
||||
UnitSysPosition tmpX = null;
|
||||
@ -548,14 +598,15 @@ namespace AppServer
|
||||
{
|
||||
String listOfUnits = obj2.unitids;
|
||||
String listOfImeis = obj2.imeilist;
|
||||
String[] tmpunits = listOfUnits.Split(',');
|
||||
String[] tmpimeis = listOfImeis.Split(',');
|
||||
String[] tmpunits = listOfUnits.Split(",".ToCharArray());
|
||||
String[] tmpimeis = listOfImeis.Split(",".ToCharArray());
|
||||
Hashtable tmpHashName = new Hashtable();
|
||||
if (tmpunits.Count() > 1)
|
||||
{
|
||||
for (Int32 i = 0; i < tmpunits.Count() - 1; i++)
|
||||
tmpHashName.Add((String)tmpunits[i], (String)tmpimeis[i]);
|
||||
}
|
||||
|
||||
foreach (String keyobj in tmpHashName.Keys)
|
||||
{
|
||||
int obj = -1;
|
||||
@ -565,33 +616,41 @@ namespace AppServer
|
||||
tmpX = dbvehs.getSystemPosition(Convert.ToInt32(keyobj));
|
||||
|
||||
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + (String)tmpHashName[keyobj] + "#" + /*"Message from unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " :" +*/ obj2.msgbody + "#" + date + "#";
|
||||
MainForm.udp.Send(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)}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj2.sentmsg2 && sendOnMsgBus)
|
||||
{
|
||||
tmpX = dbvehs.getSystemPositionIMEI(radioID);
|
||||
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test).Length);
|
||||
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0." + date + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
|
||||
}
|
||||
|
||||
//send Callout
|
||||
if(obj2.callout && tmpresp.ToString().Contains("IN "))
|
||||
{
|
||||
tmpX = dbvehs.getSystemPositionIMEI(radioID);
|
||||
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});
|
||||
Utils.WriteLine($"Zone CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
|
||||
}
|
||||
///send email
|
||||
if (obj2.sentemail)
|
||||
|
||||
// send by email if the emailServer is configured
|
||||
if (Program.cfg.enableEmailService && obj2.sentemail)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
@ -611,46 +670,45 @@ namespace AppServer
|
||||
String speedMiles = Convert.ToString((int)Math.Round(speed * 0.621371192));
|
||||
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);
|
||||
if (obj2.speedUnit.Equals("k"))
|
||||
|
||||
int sc_id = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).sc_id;
|
||||
|
||||
// insert Alert into database
|
||||
Utils.WriteLine("Insert Landmarks Alarm " + radioID.ToString() + " " + sc_id);
|
||||
DBalarm.Insert_Zone_Alarm(sc_id, time, obj2.land_id, obj2.action, false);
|
||||
|
||||
|
||||
// send alert by email if the emailServer is configured
|
||||
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
|
||||
{
|
||||
string message = "Landmark alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp
|
||||
+ ". Unit speed " + speed + " km/h at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]";
|
||||
string title = "Landmark 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 = $"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);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = "Landmark alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp
|
||||
+ ". Unit speed " + speedMiles + " mph at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]";
|
||||
string title = "Landmark alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
|
||||
if (mailAdr != "")
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
sendAlarmMail(title, message, mailAdr);
|
||||
});
|
||||
}
|
||||
sendAlarmMail(title, message, mailAdr);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//send Alert on message buss
|
||||
if (sendOnMsgBus)
|
||||
{
|
||||
//send alarm on message buss
|
||||
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
|
||||
if(obj2.callout && tmpresp.ToString().Contains("IN "))
|
||||
{
|
||||
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 });
|
||||
Utils.WriteLine($"Landmark CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} ");
|
||||
@ -682,63 +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);
|
||||
|
||||
int speed = (int)Convert.ToDouble(cell.spd);
|
||||
|
||||
int treshold = (int)Convert.ToDouble(speedTreshold);
|
||||
uint time = DateTo70Format(cell.location_time);
|
||||
string speed4send = speed.ToString() + "_" + speedUnits;
|
||||
if (speedUnits == "m")
|
||||
treshold = (int)(treshold * 1.609);
|
||||
|
||||
if (speedUnits != "m")
|
||||
int speed = (int)Convert.ToDouble(cell.spd);
|
||||
if (speed >= treshold)
|
||||
{
|
||||
if (speed >= treshold)
|
||||
{
|
||||
Utils.WriteLine("Speed alarm detected!");
|
||||
DBalarm.Insert_Speed_Alarm(radioID, time, speed,cell.lat,cell.lng);
|
||||
Utils.WriteLine("Done inserting speed alarm!");
|
||||
string message = "Speed alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name
|
||||
+ ". Unit speed " + speed + " km/h at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]";
|
||||
string title = "Speed alarm for unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
|
||||
if (mailAdr != "")
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
sendAlarmMail(title, message, mailAdr);
|
||||
});
|
||||
}
|
||||
uint time = DateTo70Format(cell.location_time);
|
||||
// insert alert into database
|
||||
DBalarm.Insert_Speed_Alarm(radioID, time, speed, cell.lat, cell.lng);
|
||||
|
||||
if (sendOnMsgBus)
|
||||
|
||||
//send Alert by email if EmailServer si configured
|
||||
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(mailAdr))
|
||||
{
|
||||
|
||||
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 message = $"Speed alarm for {veh_name}. Unit speed {speed_km_or_mph} at time: {Utils.UnixTimeStampToDateTime(time).ToLocalTime()} [{cell.lat},{cell.lng}]";
|
||||
string title = $"Speed alarm for unit {veh_name}";
|
||||
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
//send alarm on message buss
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (speed >= (treshold * 1.609))
|
||||
{
|
||||
DBalarm.Insert_Speed_Alarm(radioID, time, speed, cell.lat, cell.lng);
|
||||
String speedMiles = Convert.ToString((int)Math.Round(speed * 0.621371192));
|
||||
SM.Debug("Speed alarm generated!");
|
||||
string message = "Speed alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name
|
||||
+ ". Unit speed " + speedMiles + " mph at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]";
|
||||
string title = "Speed alarm for unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name;
|
||||
if (mailAdr != "Speed alarm")
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
sendAlarmMail(title, message, mailAdr);
|
||||
});
|
||||
}
|
||||
|
||||
if (sendOnMsgBus)
|
||||
{
|
||||
//send alarm on message buss
|
||||
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);
|
||||
}
|
||||
sendAlarmMail(title, message, mailAdr);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//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
|
||||
|
@ -96,6 +96,9 @@ namespace AppServer
|
||||
public static String dbAccess;
|
||||
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 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()
|
||||
{
|
||||
if (!checkWebsocketServerStatus.Enabled)
|
||||
@ -1023,8 +1057,9 @@ namespace AppServer
|
||||
catch (Exception exe)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -1071,8 +1106,9 @@ namespace AppServer
|
||||
errorOnScreen = true;
|
||||
error = true;
|
||||
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)
|
||||
{
|
||||
@ -1192,8 +1228,10 @@ namespace AppServer
|
||||
|
||||
|
||||
MainForm.websocketLocationQueue.PostItem(data);
|
||||
if(!sendWebsocketTimer.Enabled)
|
||||
|
||||
if (!sendWebsocketTimer.Enabled)
|
||||
sendWebsocketTimer.Enabled = true;
|
||||
|
||||
if (!checkWebsocketServerStatus.Enabled)
|
||||
checkWebsocketServerStatus.Enabled = true;
|
||||
}
|
||||
@ -1245,10 +1283,12 @@ namespace AppServer
|
||||
}
|
||||
try
|
||||
{
|
||||
udp.Send(Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#"),
|
||||
Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#").Length);
|
||||
udp.Send(Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#"),
|
||||
Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#").Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast($"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#offline#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
|
||||
dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
@ -1263,8 +1303,9 @@ namespace AppServer
|
||||
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)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ namespace AppServer
|
||||
private DBvehiclesManager dbvehs;
|
||||
internal DBsubsOperationManager dbsubsoperManage;
|
||||
private DBcallPatchManager dbCallPatch;
|
||||
|
||||
#region code for zone
|
||||
private volatile static ArrayList ZoneList = 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);
|
||||
//send radio disable to GW
|
||||
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)
|
||||
{
|
||||
@ -725,8 +727,10 @@ namespace AppServer
|
||||
int unitSC_ID = DBvehInfo.getSCID(radioID3.ToString());
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
string message = string.Format("Ticket no. {0} is no longer active!", dec3.delete_ticket_id);
|
||||
string test1 = "#143#" + sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID3 + "#" + message + "#" + 0 + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0"+test1), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0"+test1).Length);
|
||||
string test1 = "#143#" + sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID3 + "#" + message + "#" + 0 + "#";
|
||||
|
||||
byte[] cmd = Utils.Convert_text_For_multicast("#0.0" + test1);
|
||||
MainForm.udp.Send(cmd, cmd.Length);
|
||||
}
|
||||
//send to email if was sms->email type
|
||||
if (dec3.isEmail)
|
||||
@ -734,12 +738,11 @@ namespace AppServer
|
||||
sendMail(dec3.emailAddr, dec3.messBody, radioID3);
|
||||
}
|
||||
//send ACK back to GW
|
||||
test = "";
|
||||
if (dec3.sqlResp == sqlResponse.done)
|
||||
test = "#232#1#";
|
||||
else
|
||||
test = "#232#0#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + seqID3 + test).Length);
|
||||
test = (dec3.sqlResp == sqlResponse.done) ? "#232#1#" : "#232#0#";
|
||||
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID3 + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
if (MainForm.SendPOLLafterSMS)
|
||||
{
|
||||
@ -748,8 +751,9 @@ namespace AppServer
|
||||
UnitSysPosition sysPos = DBvehInfo.getSystemPosition(unitSC_ID);
|
||||
string dest = $"0.0.{radioID3}";
|
||||
if (sysPos != null) dest = $"{sysPos.Gw_id}.{sysPos.R_gw_id}.{radioID3}";
|
||||
|
||||
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)
|
||||
@ -926,8 +930,10 @@ namespace AppServer
|
||||
DBtel.AddTelemetryHist(radioID, tObj.Id, 1);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
SM.Debug("Sending telemetry alarm to SD; digital:" + tObj.DigitalNr);
|
||||
test = $"#140#{radioID}#{tObj.Name}#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0"+test).Length);
|
||||
test = $"#140#{radioID}#{tObj.Name}#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -937,8 +943,9 @@ namespace AppServer
|
||||
}
|
||||
}
|
||||
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)
|
||||
@ -1031,8 +1038,9 @@ namespace AppServer
|
||||
object[] param = { dirBackup, posgresPath };
|
||||
bgWorkerDBbackup.RunWorkerAsync(param);
|
||||
|
||||
//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);
|
||||
//send ACK back to SUM
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#71#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1060,12 +1068,14 @@ namespace AppServer
|
||||
object[] param2 = { completeFileName, posgresPath };
|
||||
bgWorkerDBrestore.RunWorkerAsync(param2);
|
||||
//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
|
||||
{
|
||||
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);
|
||||
SM.Debug("DB restored failed !!!" + "File " + completeFileName + " missing!!!");
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#62#0#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1137,7 +1147,9 @@ namespace AppServer
|
||||
//send broadcast messages I'm back in business
|
||||
Utils.WriteLine(string.Format("receive 500 from radio: Gateway {0} is ON", ((RadioGateway)MainForm.RadioGWHash[key]).Name), ConsoleColor.Green);
|
||||
string test1 = "#501#" + tempArr[4] + "#" + tempArr[5] + "#" + "ON#" + ((RadioGateway)MainForm.RadioGWHash[key]).Name + "#";
|
||||
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]).LastUpdate = DateTime.UtcNow;
|
||||
@ -1164,7 +1176,9 @@ namespace AppServer
|
||||
string status = ((RadioGateway)(entry.Value)).Alive ? "ON" : "OFF";
|
||||
Utils.WriteLine(string.Format("Response for SD request: Gateway {0} is {1}", ((RadioGateway)(entry.Value)).Name, status), status == "ON" ? ConsoleColor.Green : ConsoleColor.Red);
|
||||
string test1 = "#501#" + ((RadioGateway)(entry.Value)).Gw_id + "#" + ((RadioGateway)(entry.Value)).Id + "#" + status + "#" + ((RadioGateway)(entry.Value)).Name + "#";
|
||||
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;
|
||||
@ -1287,11 +1301,14 @@ namespace AppServer
|
||||
if (sysPos != null) dest = sysPos.Gw_id + "." + sysPos.R_gw_id + "." + radioID.ToString();
|
||||
|
||||
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
|
||||
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]).lastArsTime = DateTime.Now;
|
||||
@ -1372,7 +1389,9 @@ namespace AppServer
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition(msg.sc_id_dest);
|
||||
//string test = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id+"."+msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#";
|
||||
string test = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
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
|
||||
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 cmdok = "";
|
||||
var subsBlackList = new List<int> { (int)Status_for_tab.OFF, (int)Status_for_tab.DISABLE, (int)Status_for_tab.MADEOFF };
|
||||
|
||||
byte[] dataToSend = null;
|
||||
|
||||
foreach (smsmessage msg in smss)
|
||||
{
|
||||
long sc_id = msg.sc_id_dest;
|
||||
@ -1415,8 +1435,10 @@ namespace AppServer
|
||||
{
|
||||
if (SysPosList[sc_id]!=null)
|
||||
test = "#143#" + ((UnitSysPosition)SysPosList[sc_id]).Gw_id + "." + ((UnitSysPosition)SysPosList[sc_id]).R_gw_id + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
else test = "#143#" + "0.0" + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + msg.seq_id + test).Length);
|
||||
else test = "#143#" + "0.0" + "." + msg.imei_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#" + msg.dispatcherID + "#";
|
||||
|
||||
dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
else
|
||||
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);
|
||||
|
||||
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);
|
||||
test = "#145#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + msg.sc_id_dest + "#" + msg.mess + "#" + msg.sched_timeGMT + "#";
|
||||
dataToSend = Utils.Convert_text_For_multicast("#" + msg.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
|
||||
Utils.WriteLine($"Undelivered {undeliveredSMS} private messages and {smss.Count} group messages", ConsoleColor.White);
|
||||
@ -1445,19 +1468,19 @@ namespace AppServer
|
||||
{
|
||||
//Check4ExpiredTickets
|
||||
List<JobTickets> jtlist = new List<JobTickets>();
|
||||
string list_of_id_text = "";
|
||||
|
||||
try
|
||||
{
|
||||
DBTicketingManager DBT = new DBTicketingManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
List<Int32> ExpiredTicketsIdList = DBT.updateTicketExpireDate(DateTo70Format(DateTime.UtcNow));
|
||||
if(ExpiredTicketsIdList.Count>0)
|
||||
{
|
||||
foreach(Int32 id in ExpiredTicketsIdList)
|
||||
{
|
||||
list_of_id_text += id + ",";
|
||||
}
|
||||
list_of_id_text = list_of_id_text.Substring(0, list_of_id_text.Length - 1);
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#251#" + list_of_id_text + "#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#251#" + list_of_id_text + "#").Length);
|
||||
|
||||
// get comma separated list
|
||||
string list_of_id_text = string.Join<string>(",", ExpiredTicketsIdList.Select(x => $"{x}"));
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast($"#0.0#251#{list_of_id_text}#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
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 head = "#143#0.0." + ticket.Imei + "#";
|
||||
if (SysPosList[ticket.sc_id] != null) head = "#143#" + ((UnitSysPosition)SysPosList[ticket.sc_id]).Gw_id + "." + ((UnitSysPosition)SysPosList[ticket.sc_id]).R_gw_id + "." + ticket.Imei + "#";
|
||||
string test = head + message + "#" + 0 + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test).Length);
|
||||
string test = head + message + "#" + 0 + "#";
|
||||
|
||||
|
||||
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 + "#";
|
||||
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 + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test), SafeMobileLib.Utils.Convert_text_For_multicast("#" + ticket.seq_id + test).Length);
|
||||
string test = head + ticket.Name + "#" + 0 + "#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + ticket.seq_id + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
else
|
||||
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
|
||||
{
|
||||
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);
|
||||
SM.Debug("Unit:" + item.Imei + " ARS interval expired. Marking unit as OFF");
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#130#" + item.Imei + "#OFF#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1599,7 +1628,9 @@ namespace AppServer
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1684,7 +1715,9 @@ namespace AppServer
|
||||
public static void PushStatus(String IMEI,Status_for_tab stat)
|
||||
{
|
||||
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;
|
||||
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)
|
||||
{
|
||||
@ -2150,21 +2184,46 @@ namespace AppServer
|
||||
|
||||
private void sendAlarmMail(string mes, string mailAdr)
|
||||
{
|
||||
try
|
||||
if (Program.cfg.enableEmailService)
|
||||
{
|
||||
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);
|
||||
|
||||
if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
|
||||
{
|
||||
if (MainForm.IsBlacklistedAddress(mailAdr))
|
||||
{
|
||||
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);
|
||||
//Console.WriteLine(e.ToString());
|
||||
SM.Debug("email disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendDailyReportMail(String PdfFile, string mailAdr)
|
||||
{
|
||||
@ -2239,11 +2298,20 @@ namespace AppServer
|
||||
if (Program.cfg.enableEmailService)
|
||||
{
|
||||
SM.Debug(new string[] { "Checking mail at:" + DateTime.Now.ToString(), "For " + Program.cfg.emailAddress.ToString() + " on " + Program.cfg.pop3Server.ToString() });
|
||||
|
||||
emailHT = dbsubsoperManage.getAll_imei_sc_id("ByMail");
|
||||
if (emailHT.Count > 0)
|
||||
{
|
||||
SM.Debug("Load " + emailHT.Count + " subscribers emails from DB ...");
|
||||
}
|
||||
|
||||
if (sslServer == null)
|
||||
{
|
||||
SM.Debug("sslServer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Int64 latestEmailTime = sslServer.getLastEmailTime();
|
||||
ArrayList EmailList = sslServer.getEmails();
|
||||
|
||||
@ -2254,19 +2322,23 @@ namespace AppServer
|
||||
DB.SetLastEmailTime(sslServer.getLastEmailTime());
|
||||
}
|
||||
|
||||
|
||||
DBsmsManager DBsms = new DBsmsManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
DBvehiclesManager dbvehs = new DBvehiclesManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
|
||||
|
||||
foreach (EmailtoSMS obj in EmailList)
|
||||
{
|
||||
String seqID = "0." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Millisecond.ToString();
|
||||
SM.Debug(new string[] {"-----START OK----",
|
||||
"From: " + obj.from,
|
||||
"ID: " + obj.id,
|
||||
"Text: " + obj.text});
|
||||
|
||||
SM.Debug(new string[] { "-----START OK----",
|
||||
"From: " + obj.from,
|
||||
"ID: " + obj.id,
|
||||
"Text: " + obj.text});
|
||||
try
|
||||
{
|
||||
// app server idx =0
|
||||
DBsmsManager DB = new DBsmsManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
|
||||
|
||||
//bigu code remove # from text and also replace "'"
|
||||
try
|
||||
{
|
||||
@ -2277,13 +2349,15 @@ namespace AppServer
|
||||
{
|
||||
SM.Debug("Error on converting email:" + ex.ToString());
|
||||
}
|
||||
|
||||
//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 (emailHT.Contains(obj.from))
|
||||
{
|
||||
SM.Debug("Email received <<" + obj.text + ">> from address: " + obj.from);
|
||||
|
||||
seqID = "1." + Utils.GetSecondsLocalFromDT(DateTime.Now).ToString() + DateTime.Now.Millisecond.ToString();
|
||||
string test = "#132#" + ((SW_Subscriber)emailHT[obj.from]).imei + "#" + obj.text + "#hyt#";
|
||||
String cmdok = "#" + seqID + test; Int32 tmp = cmdok.Length + 1; tmp += tmp.ToString().Length; cmdok = "#" + tmp.ToString() + cmdok;
|
||||
@ -2291,6 +2365,7 @@ namespace AppServer
|
||||
byte[] buf = enc.GetBytes(cmdok);
|
||||
//send to messagebus
|
||||
MainForm.udp.Send(buf, buf.Length);
|
||||
|
||||
SM.Debug("Email thread successfully sent data to message bus");
|
||||
}
|
||||
}
|
||||
@ -2305,26 +2380,36 @@ namespace AppServer
|
||||
obj.text = obj.text.Remove(140 - 3 - obj.from.Length) + " [" + obj.from + "]";
|
||||
else
|
||||
obj.text = obj.text + " [" + obj.from + "]";
|
||||
|
||||
//send SMS on message buss
|
||||
if (!obj.is_sierra)
|
||||
{
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition(dbvehs.getSCID(obj.id));
|
||||
|
||||
string msg = "#143#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + obj.id + "#" + obj.text + "#" + (DateTime.Now.GetSecondsLocalFromDT()) + "#";
|
||||
if (obj.is_group) msg = "#144#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + obj.id + "#" + obj.text + "#" + (DateTime.Now.GetSecondsLocalFromDT()) + "#";
|
||||
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + msg), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + msg).Length);
|
||||
|
||||
if (obj.is_group)
|
||||
|
||||
if (dbvehs != null)
|
||||
{
|
||||
Int32 oldgatewayID = 0;
|
||||
foreach (RadioGateway obj2 in RadioListIP)
|
||||
UnitSysPosition tmpX = dbvehs.getSystemPosition(dbvehs.getSCID(obj.id));
|
||||
|
||||
string cmd = $"{tmpX.Gw_id}.{tmpX.R_gw_id}.{obj.id}#{obj.text}#{DateTime.Now.GetSecondsLocalFromDT()}#";
|
||||
string code = (obj.is_group) ? "#144#" : "#143#" ;
|
||||
byte[] msg = Utils.Convert_text_For_multicast("#0.0" + code + cmd);
|
||||
|
||||
if (msg != null && msg.Length > 0)
|
||||
MainForm.udp.Send(msg, msg.Length);
|
||||
|
||||
if (obj.is_group)
|
||||
{
|
||||
if (oldgatewayID != obj2.Gw_id)
|
||||
Int32 oldgatewayID = 0;
|
||||
foreach (RadioGateway obj2 in RadioListIP)
|
||||
{
|
||||
oldgatewayID = (Int32)obj2.Gw_id;
|
||||
string msg2 = "#144#" + obj2.Gw_id + "." + obj2.Id + "." + obj.id + "#" + obj.text + "#" + (DateTime.Now.GetSecondsLocalFromDT()) + "#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#1." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Ticks.ToString() + msg2), SafeMobileLib.Utils.Convert_text_For_multicast("#1." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Ticks.ToString() + msg2).Length);
|
||||
if (oldgatewayID != obj2.Gw_id)
|
||||
{
|
||||
oldgatewayID = (Int32)obj2.Gw_id;
|
||||
cmd = $"#144#{obj2.Gw_id}.{obj2.Id}.{obj.id}#{obj.text}#{DateTime.Now.GetSecondsLocalFromDT()}#";
|
||||
byte[] msg2 = Utils.Convert_text_For_multicast("#1." + (DateTime.Now.GetSecondsLocalFromDT()) + DateTime.Now.Ticks.ToString() + cmd);
|
||||
|
||||
if( msg2 != null && msg2.Length > 0)
|
||||
MainForm.udp.Send(msg2, msg2.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2348,24 +2433,43 @@ namespace AppServer
|
||||
{
|
||||
if (Program.cfg.enableEmailService)
|
||||
{
|
||||
SM.Debug("Sending mail to " + mailAdr + " from radioId " + radioID.ToString());
|
||||
try
|
||||
if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
|
||||
{
|
||||
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
|
||||
@ -2378,20 +2482,46 @@ namespace AppServer
|
||||
//sms-> email Sierra Wireless
|
||||
private void sendMail_SW(string mailAdr, string mailBody)
|
||||
{
|
||||
SM.Debug("Sending mail to " + mailAdr);
|
||||
try
|
||||
if (Program.cfg.enableEmailService)
|
||||
{
|
||||
MailMessage message = new MailMessage();
|
||||
message.From = new MailAddress(Program.cfg.emailAddress);
|
||||
message.To.Add(mailAdr);
|
||||
message.Body = mailBody;
|
||||
message.IsBodyHtml = true;
|
||||
if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
|
||||
{
|
||||
|
||||
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 ACK back to GW
|
||||
string test = (backupDOne == true) ? "#61#1#" : "#61#0#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
string code = (backupDOne == true) ? "#61#1#" : "#61#0#";
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + code);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -2451,8 +2582,10 @@ namespace AppServer
|
||||
{
|
||||
//send emergency alarm to SD
|
||||
//send ACK back to GW
|
||||
string test = (restoreDOne == true) ? "#62#1#" : "#252#0#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
string code = (restoreDOne == true) ? "#62#1#" : "#252#0#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + code);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -215,8 +215,8 @@ namespace AppServer
|
||||
Thread.Sleep(2000);
|
||||
try
|
||||
{
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#"),
|
||||
Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#").Length);
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
// save all unhandled gps positions
|
||||
MainForm.DumpLocationQueueToFile();
|
||||
@ -240,8 +240,10 @@ namespace AppServer
|
||||
|
||||
Thread.Sleep(2000);
|
||||
try
|
||||
{
|
||||
MainForm.udp?.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#"), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#").Length);
|
||||
{
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#210#4#Application server stopped#");
|
||||
MainForm.udp?.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
// save all unhandled gps positions
|
||||
MainForm.DumpLocationQueueToFile();
|
||||
|
@ -14,5 +14,5 @@
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
@ -51,7 +51,7 @@ namespace AppServer
|
||||
String stringData = System.Text.Encoding.ASCII.GetString(data, 0, data.Length);
|
||||
String usefulData = stringData.Trim();
|
||||
Console.WriteLine("Data received:" + usefulData);
|
||||
String[] command = usefulData.Split('#');
|
||||
String[] command = usefulData.Split("#".ToCharArray());
|
||||
SDRegistration sdReg = null;
|
||||
String header = "";
|
||||
int digCommand;
|
||||
@ -107,9 +107,10 @@ namespace AppServer
|
||||
+ Program.cfg.msgBusIP.ToString() + ";" + Program.cfg.msgBusPort + ";" + databaseIP + ";"
|
||||
+ Program.cfg.DB_schema + ";" + Program.cfg.DB_user + ";" + Program.cfg.DB_passwd
|
||||
+ ";" + Program.cfg.DB_port + ";" + Program.cfg.VoicePort + ";"
|
||||
+ audibleAlerts.ToString() + ";" + MainForm.dbAccess.ToString() + ";";
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#"), Utils.Convert_text_For_multicast("#0.0#156#"
|
||||
+ command[1].Trim() + "#").Length);
|
||||
+ audibleAlerts.ToString() + ";" + MainForm.dbAccess.ToString() + ";";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#156#" + command[1].Trim() + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
|
||||
MainForm.RegistrationAnswer = false;
|
||||
Int32 countWait = 0; //maxim 30 = 3 seconds
|
||||
|
@ -171,8 +171,10 @@ namespace AppServer
|
||||
DBrec.addRecording(rec);
|
||||
|
||||
|
||||
test = $"#155#{rec.id}#{rec.hddLocation}#{rec.gwID}#{rec.radioGWID}#{rec.group_cpsId}#{rec.subs_imei}#{rec.startTime}#{rec.endTime}#{rec.typeSD}#{rec.calltype}#{rec.dispatcher_id}#";
|
||||
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length);
|
||||
test = $"#155#{rec.id}#{rec.hddLocation}#{rec.gwID}#{rec.radioGWID}#{rec.group_cpsId}#{rec.subs_imei}#{rec.startTime}#{rec.endTime}#{rec.typeSD}#{rec.calltype}#{rec.dispatcher_id}#";
|
||||
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0" + test);
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -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()
|
||||
{
|
||||
|
||||
@ -394,45 +428,78 @@ namespace MotoTrbo_GW
|
||||
"Update required...", MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
|
||||
|
||||
if (dr == DialogResult.Yes)
|
||||
{
|
||||
CheckForUpdate(true);
|
||||
Application.Exit();
|
||||
}
|
||||
else
|
||||
Application.Exit();
|
||||
|
||||
Application.Exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
//new code
|
||||
List <Gateway> listGW = new List<Gateway>();
|
||||
try
|
||||
{
|
||||
|
||||
if (!string.IsNullOrEmpty(DBServer))
|
||||
{
|
||||
listGW = getGWidFromDB(DBServer);
|
||||
}
|
||||
|
||||
|
||||
if (listGW.Count == 0)
|
||||
{
|
||||
DBServer = "127.0.0.1";
|
||||
listGW = getGWidFromDB(DBServer);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SafeMobileLib.Utils.WriteLine("Ex on find automat the gateway ID:" + ex.ToString());
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (listGW.Count == 0)
|
||||
{
|
||||
FeedbackRadMessageBox.ShowError("Gateway IP not present in DB\n\r Please go to Administrative module and register this GW with IP:!!!" + DBServer, "IP missing");
|
||||
|
||||
System.Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
GWID = ((Gateway)listGW[0]).Id;
|
||||
source = new IniConfigSource(Main.CFG_FILE);
|
||||
source.Configs["Gateway"].Set("id", GWID);
|
||||
// source.Configs["NAI"].Set("peerID", ((Gateway)listGW[0]).Peer_id);
|
||||
source.Save();
|
||||
|
||||
SafeMobileLib.Utils.WriteLine("Gateway ID is " + GWID, ConsoleColor.Cyan);
|
||||
|
||||
//SafeMobileLib.Utils.WriteLine("ID:" + GWID + " saved to config file.");
|
||||
btGWID.Text = GWID.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SafeMobileLib.Utils.WriteLine("DB error!!!");
|
||||
SafeMobileLib.Utils.WriteLine(ex.ToString());
|
||||
|
||||
FeedbackRadMessageBox.ShowError("DB error.\n\rPlease turn down the firewall or add an exception for the Datebase in the firewall and try again!!!\n\r DB ip:" + DBServer,
|
||||
"DB error");
|
||||
|
||||
|
||||
System.Environment.Exit(0);
|
||||
//System.Windows.Forms.Application.Exit();
|
||||
return;
|
||||
}
|
||||
//end of new code
|
||||
|
||||
|
||||
// Get Audio settings
|
||||
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);
|
||||
}
|
||||
|
||||
FetchAudioSettings();
|
||||
|
||||
|
||||
//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
|
||||
{
|
||||
@ -1274,7 +1257,7 @@ because base station {radioGwID} failed to send PTT", ConsoleColor.Red);
|
||||
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Main.ApplicationServer), registrationPort);
|
||||
client.Connect(serverEndPoint);
|
||||
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;
|
||||
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -77,6 +77,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetupProj", "SetupProj\Setu
|
||||
EndProject
|
||||
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup_SDRTetra", "Setup_SDRTetra\Setup_SDRTetra.vdproj", "{9FCD029D-6924-41FA-A59F-C79633FF6319}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateHelper", "UpdateHelper\UpdateHelper.csproj", "{316FC545-051D-47AE-BEFA-1E94AC6D5D21}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
SharedUI\SharedUI.projitems*{2292ade7-adac-40d0-866c-8a712f2137f7}*SharedItemsImports = 4
|
||||
@ -3195,6 +3197,90 @@ Global
|
||||
{9FCD029D-6924-41FA-A59F-C79633FF6319}.Repeater|x64.Build.0 = Release
|
||||
{9FCD029D-6924-41FA-A59F-C79633FF6319}.Repeater|x86.ActiveCfg = Release
|
||||
{9FCD029D-6924-41FA-A59F-C79633FF6319}.Repeater|x86.Build.0 = Release
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Kit2.0|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Kit2.0|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Kit2.0|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Kit2.0|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Kit2.0|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Kit2.0|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitExcera|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitExcera|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitExcera|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitExcera|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitExcera|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitExcera|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitHytera|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitHytera|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitHytera|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitHytera|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitHytera|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KitHytera|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINX|Any CPU.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINX|Any CPU.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINX|x64.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINX|x64.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINX|x86.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINX|x86.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINXB|Any CPU.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINXB|Any CPU.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINXB|x64.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINXB|x64.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINXB|x86.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.kitLINXB|x86.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittATLAS|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittATLAS|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittATLAS|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittATLAS|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittATLAS|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittATLAS|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittHARRIS|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittHARRIS|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittHARRIS|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittHARRIS|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittHARRIS|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittHARRIS|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittMotorola|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittMotorola|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittMotorola|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittMotorola|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittMotorola|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittMotorola|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittSimoco|Any CPU.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittSimoco|Any CPU.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittSimoco|x64.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittSimoco|x64.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittSimoco|x86.ActiveCfg = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.KittSimoco|x86.Build.0 = KitExcera|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LINX|Any CPU.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LINX|Any CPU.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LINX|x64.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LINX|x64.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LINX|x86.ActiveCfg = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LINX|x86.Build.0 = kitLINXB|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LISF|Any CPU.ActiveCfg = LISF|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LISF|Any CPU.Build.0 = LISF|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LISF|x64.ActiveCfg = LISF|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LISF|x64.Build.0 = LISF|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LISF|x86.ActiveCfg = LISF|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.LISF|x86.Build.0 = LISF|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Release|x64.Build.0 = Release|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Release|x86.Build.0 = Release|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Repeater|Any CPU.ActiveCfg = Repeater|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Repeater|Any CPU.Build.0 = Repeater|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Repeater|x64.ActiveCfg = Repeater|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Repeater|x64.Build.0 = Repeater|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Repeater|x86.ActiveCfg = Repeater|Any CPU
|
||||
{316FC545-051D-47AE-BEFA-1E94AC6D5D21}.Repeater|x86.Build.0 = Repeater|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -452,34 +452,36 @@ namespace SafeMobileLib
|
||||
|
||||
BatchHistoryData batchHistObj = null;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
|
||||
lat = Convert.ToDouble(dr["lat"]);
|
||||
lng = Convert.ToDouble(dr["lng"]);
|
||||
timegmt = Convert.ToInt32(dr["timegmt"]);
|
||||
|
||||
batchHistObj = new BatchHistoryData
|
||||
{
|
||||
batchHistObj = new BatchHistoryData
|
||||
{
|
||||
|
||||
Department = dr["department"].ToString(),
|
||||
Unit = dr["unit"].ToString(),
|
||||
Location = ((getAddress && dr["address"] != DBNull.Value) ? dr["address"].ToString() : "LAT:" + Math.Round(lat, 5).ToString() + " , LNG:" + Math.Round(lat, 5).ToString()),
|
||||
Speed = (isInMile) ? ((int)(Convert.ToInt32(dr["speed"]) * 0.621371192)).ToString() : Convert.ToInt32(dr["speed"]).ToString(),
|
||||
Lat = lat,
|
||||
Lng = lng,
|
||||
Address = dr["address"].ToString(),
|
||||
Address = string.Empty,
|
||||
Time = timegmt.TimeOfDayHHMMSSLocal(!is24hours),
|
||||
Date = timegmt.GetDTLocalFromSeconds().Date.ToShortDateString()
|
||||
|
||||
};
|
||||
|
||||
if (getAddress)
|
||||
{
|
||||
batchHistObj.Location = dr["address"].ToString();
|
||||
batchHistObj.Address = dr["address"].ToString();
|
||||
}
|
||||
else
|
||||
batchHistObj.Location = "LAT:" + Math.Round(lat, 5).ToString() + " , LNG:" + Math.Round(lat, 5).ToString();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ namespace SafeMobileLib
|
||||
Int32 sc_id = 0;
|
||||
Int32 job_status = 0;
|
||||
int specified_end_time = -1;
|
||||
string[] messageString = mess.Split('^');
|
||||
string[] messageString = mess.Split("^".ToCharArray());
|
||||
string text = messageString[0];
|
||||
string comment = messageString[1];
|
||||
string priority = messageString[2];
|
||||
|
@ -1018,7 +1018,7 @@ namespace SafeMobileLib
|
||||
vehResponse resp;
|
||||
NpgsqlCommand cmd;
|
||||
bool isDeleted;
|
||||
string[] idListArray = idlist.Replace("(", "").Replace(")", "").Split(',');
|
||||
string[] idListArray = idlist.Replace("(", "").Replace(")", "").Split(",".ToCharArray());
|
||||
isDeleted = isUnitDeleted(idListArray[0]);
|
||||
|
||||
NpgsqlTransaction transaction = null;
|
||||
|
@ -25,6 +25,8 @@ namespace SafeMobileLib
|
||||
private bool isSSL = true;
|
||||
private Int64 lastEmailTime = 0;
|
||||
private Int64 startEmailServiceTime = 0;
|
||||
public static Dictionary<string, int> blackList = new Dictionary<string, int>();
|
||||
public const int MAX_ATTEMPTS = 100;
|
||||
|
||||
// blank constructor in order to be used in Email Checking
|
||||
public EmailServerSSL()
|
||||
@ -334,7 +336,7 @@ namespace SafeMobileLib
|
||||
|
||||
if (ets.from.Contains("@"))
|
||||
{
|
||||
string temp = (ets.from.Split('@'))[0];
|
||||
string temp = (ets.from.Split("@".ToCharArray()))[0];
|
||||
|
||||
int i_id = 0;
|
||||
bool valid = Int32.TryParse(temp, out i_id);
|
||||
@ -378,11 +380,46 @@ namespace SafeMobileLib
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static void HandleBlacklist(string key)
|
||||
{
|
||||
// add key to backlist
|
||||
if (!blackList.ContainsKey(key))
|
||||
blackList.Add(key, MAX_ATTEMPTS);
|
||||
}
|
||||
|
||||
public static bool IsBlacklisted(string key)
|
||||
{
|
||||
|
||||
if (!blackList.ContainsKey(key))
|
||||
return false;
|
||||
|
||||
// avoid to connect to pop3 MAX_ATTEMPTS times => give another chance to try to connect to pop 3 when count = 0
|
||||
int count = blackList[key];
|
||||
if (count == 0)
|
||||
{
|
||||
blackList.Remove(key);
|
||||
return false;
|
||||
}
|
||||
|
||||
blackList[key] = count - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Connect to the Pop Server in order to be used to get the emails
|
||||
/// </summary>
|
||||
private void ConnectEmailPopServer()
|
||||
{
|
||||
if (IsBlacklisted(serverIP))
|
||||
{
|
||||
|
||||
Utils.WriteLine($"ConnectEmailPopServer : Could not conenct to the pop server '{serverIP}'. The pop server '{serverIP}' is in blacklist count = {blackList[serverIP]}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
ConnectAsync();
|
||||
@ -393,8 +430,17 @@ namespace SafeMobileLib
|
||||
|
||||
private void ConnectAsync()
|
||||
{
|
||||
if (popClient != null && popClient.Connected)
|
||||
popClient.Disconnect();
|
||||
try
|
||||
{
|
||||
|
||||
if (popClient != null && popClient.Connected)
|
||||
popClient.Disconnect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
|
||||
}
|
||||
|
||||
popClient = null;
|
||||
popClient = new Pop3Client();
|
||||
@ -412,18 +458,25 @@ namespace SafeMobileLib
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("PopServerNotFoundException -> " + ee.ToString());
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
HandleBlacklist(serverIP);
|
||||
|
||||
}
|
||||
catch (InvalidLoginException e)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("InvalidLoginException -> " + e.ToString());
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
HandleBlacklist(serverIP);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("ConnectEmailPopServer -> " + ex.ToString());
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
|
||||
HandleBlacklist(serverIP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,9 @@ namespace SafeMobileLib
|
||||
public void SendOnMsgBuss(string seqID, string test)
|
||||
{
|
||||
if (udpMulticast != null)
|
||||
{
|
||||
udpMulticast.Send(Utils.Convert_text_For_multicast("#" + seqID + test), Utils.Convert_text_For_multicast("#" + seqID + test).Length);
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#" + seqID + test);
|
||||
udpMulticast.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace SafeMobileLib.Helpers
|
||||
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(appServerIP), registrationPort);
|
||||
client.Connect(serverEndPoint);
|
||||
NetworkStream clientStream = client.GetStream();
|
||||
GatewayIP = (client.Client.LocalEndPoint.ToString().Split(':'))[0];
|
||||
GatewayIP = (client.Client.LocalEndPoint.ToString().Split(":".ToCharArray()))[0];
|
||||
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
byte[] buffer = encoding.GetBytes("200");
|
||||
|
@ -16,7 +16,7 @@ namespace SafeMobileLib
|
||||
string strInterface = "";
|
||||
try
|
||||
{
|
||||
string[] arrStr = IPstr.Split('.');
|
||||
string[] arrStr = IPstr.Split(".".ToCharArray());
|
||||
int lastPartOfIP = Convert.ToInt32(arrStr[3]);
|
||||
arrStr[3] = (lastPartOfIP + 1).ToString();
|
||||
strInterface = arrStr[0] + "." + arrStr[1] + "." + arrStr[2] + "." + arrStr[3];
|
||||
@ -34,7 +34,7 @@ namespace SafeMobileLib
|
||||
string strInterface = "";
|
||||
try
|
||||
{
|
||||
string[] arrStr = IPstr.Split('.');
|
||||
string[] arrStr = IPstr.Split(".".ToCharArray());
|
||||
int lastPartOfIP = Convert.ToInt32(arrStr[3]);
|
||||
arrStr[3] = (lastPartOfIP - 1).ToString();
|
||||
strInterface = arrStr[0] + "." + arrStr[1] + "." + arrStr[2] + "." + arrStr[3];
|
||||
@ -62,9 +62,9 @@ namespace SafeMobileLib
|
||||
System.Net.WebResponse resp = req.GetResponse();
|
||||
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
|
||||
string response = sr.ReadToEnd().Trim();
|
||||
string[] a = response.Split(':');
|
||||
string[] a = response.Split(":".ToCharArray());
|
||||
string a2 = a[1].Substring(1);
|
||||
string[] a3 = a2.Split('<');
|
||||
string[] a3 = a2.Split("<".ToCharArray());
|
||||
a4 = a3[0];
|
||||
if(a4 == "")
|
||||
a4 = new WebClient().DownloadString(@"http://icanhazip.com").Trim();
|
||||
|
@ -42,36 +42,28 @@ namespace SafeMobileLib
|
||||
recv = s.Receive(b);
|
||||
else
|
||||
break;//break if socket == null
|
||||
|
||||
if (recv == 0)
|
||||
continue;//continue if return nr bytes == 0
|
||||
|
||||
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
|
||||
byte[] decByte = Encrypted ? Encryption.Decrypt(tmp, EncryptionAlgorithm.Des64) : tmp;
|
||||
|
||||
// trigger event
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// trigger event
|
||||
if (OnNewDataReceived != null)
|
||||
{
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
|
||||
byte[] decByte = Encrypted ? Encryption.Decrypt(tmp, EncryptionAlgorithm.Des64) : tmp;
|
||||
|
||||
// trigger event
|
||||
OnNewDataReceived(mcastGroup, decByte, decByte.Length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (s == null)
|
||||
@ -108,27 +100,19 @@ namespace SafeMobileLib
|
||||
byte[] b = new byte[65507];
|
||||
Thread.Sleep(1);
|
||||
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];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
if (this.OnNewDataRecv != null)
|
||||
this.OnNewDataRecv(tmp, tmp.Length);
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
|
||||
if (OnNewDataReceived != null)
|
||||
{
|
||||
byte[] tmp = new byte[recv];
|
||||
for (int i = 0; i < recv; i++)
|
||||
{
|
||||
tmp[i] = b[i];
|
||||
}
|
||||
if (this.OnNewDataReceived != null)
|
||||
this.OnNewDataReceived(mcastGroup, tmp, tmp.Length);
|
||||
}
|
||||
if (this.OnNewDataRecv != null)
|
||||
this.OnNewDataRecv(tmp, tmp.Length);
|
||||
|
||||
if (this.OnNewDataReceived != null)
|
||||
this.OnNewDataReceived(mcastGroup, tmp, tmp.Length);
|
||||
|
||||
|
||||
if (s == null)
|
||||
{
|
||||
@ -217,16 +201,17 @@ namespace SafeMobileLib
|
||||
IPEndPoint ipep = new IPEndPoint(myIP, port);
|
||||
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
|
||||
s.Bind(ipep);
|
||||
|
||||
IPAddress ip = IPAddress.Parse(mcastGroup);
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, myIP));
|
||||
s.SetSocketOption(SocketOptionLevel.IP,
|
||||
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
listenThread = new Thread(new ThreadStart(Listen));
|
||||
listenThread.IsBackground = true;
|
||||
}
|
||||
|
||||
if (listenThread != null)
|
||||
listenThread.Start();
|
||||
|
||||
ret = true;
|
||||
|
||||
Utils.WriteLine($"++++++++++++++++++++++++++++++++++++++++++\nUdpMulticast bind on {mcastGroup}:{port} Ethernet: {myIP}\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
@ -243,12 +228,14 @@ namespace SafeMobileLib
|
||||
bool ret = false;
|
||||
working = true;
|
||||
useThreadPool = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
}
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port));
|
||||
@ -257,8 +244,7 @@ namespace SafeMobileLib
|
||||
s.Bind(ipep);
|
||||
IPAddress ip = IPAddress.Parse(mcastGroup);
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
|
||||
s.SetSocketOption(SocketOptionLevel.IP,
|
||||
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(Listen_pool));
|
||||
|
||||
@ -282,6 +268,7 @@ namespace SafeMobileLib
|
||||
{
|
||||
s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
}
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
Utils.WriteLine(String.Format("[### {0:H:mm:ss} ###] Port multi cast {1}", DateTime.Now, port));
|
||||
@ -290,13 +277,14 @@ namespace SafeMobileLib
|
||||
s.Bind(ipep);
|
||||
IPAddress ip = IPAddress.Parse(mcastGroup);
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
|
||||
s.SetSocketOption(SocketOptionLevel.IP,
|
||||
SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, int.Parse("1"));
|
||||
listenThread = new Thread(new ThreadStart(Listen_Decoded));
|
||||
listenThread.IsBackground = true;
|
||||
}
|
||||
|
||||
if (listenThread != null)
|
||||
listenThread.Start();
|
||||
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -441,8 +441,10 @@ namespace SafeMobileLib
|
||||
Int32 tmp = cmdok.Length + 1;
|
||||
tmp += tmp.ToString().Length;
|
||||
String TMPcmdok = "#" + tmp.ToString() + cmdok;
|
||||
if (tmp != TMPcmdok.Length) cmdok = "#" + TMPcmdok.Length + cmdok;
|
||||
else cmdok = TMPcmdok;
|
||||
if (tmp != TMPcmdok.Length)
|
||||
cmdok = "#" + TMPcmdok.Length + cmdok;
|
||||
else
|
||||
cmdok = TMPcmdok;
|
||||
|
||||
System.Text.Encoding enc = System.Text.Encoding.ASCII;
|
||||
byte[] buf = enc.GetBytes(cmdok);
|
||||
@ -1056,7 +1058,7 @@ namespace SafeMobileLib
|
||||
if (ret == "not_available")
|
||||
{
|
||||
string myIp = UdpMulticast.getPreferedIPAdress().ToString();
|
||||
string[] ip = myIp.Split('.');
|
||||
string[] ip = myIp.Split(".".ToCharArray());
|
||||
string baseIP = $"{ip[0]}.{ip[1]}.{ip[2]}";
|
||||
//4. scan lan range :41414/status
|
||||
for (int i = 1; i <= 255; i++)
|
||||
@ -1094,7 +1096,7 @@ namespace SafeMobileLib
|
||||
string rtpstart = o["data"]["ports"]["rtpstart"].ToString();
|
||||
string rtpend = o["data"]["ports"]["rtpend"].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;
|
||||
}
|
||||
catch { Utils.WriteLine("Error on parse server response!", ConsoleColor.Red); }
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -152,7 +152,7 @@ namespace MapGoogle
|
||||
Symbolx ret = new Symbolx();
|
||||
NextCount++;
|
||||
ret.ID = (byte)NextCount;
|
||||
String[] param = FileName.Split('\\');
|
||||
String[] param = FileName.Split("\\".ToCharArray());
|
||||
if (param.Length != 0)
|
||||
ret.Name = param[param.Length - 1];
|
||||
symbolsArray.Add(ret);
|
||||
@ -659,7 +659,7 @@ namespace MapGoogle
|
||||
if (MainForm2.MapType == MapTYPE.Google)
|
||||
{
|
||||
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,true," + "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2") + "," + Weight + "," + listS[1];
|
||||
parent.ListShapeCMD.Add(PolyCMD);
|
||||
|
@ -591,10 +591,10 @@ namespace Safedispatch_4_0
|
||||
foreach (RadTreeNode groupNode in treeViewUnits.Nodes)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
unitNode.Checked = (Array.IndexOf(splitHandled_by, unitNode.Tag.ToString()) > -1);
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -1151,7 +1151,7 @@ namespace Safedispatch_4_0
|
||||
{
|
||||
String tmpstr = url.Remove(0, url.IndexOf("points") + 7);
|
||||
//Console.WriteLine("TmpStr:" + tmpstr);
|
||||
String[] tmp = tmpstr.Split(',');
|
||||
String[] tmp = tmpstr.Split(",".ToCharArray());
|
||||
//begin
|
||||
|
||||
Int32 max = tmp.Length;
|
||||
@ -1204,7 +1204,7 @@ namespace Safedispatch_4_0
|
||||
/// <param name="mapResponse">String containing the response from the map</param>
|
||||
private void ParseLatAndLng(string mapResponse)
|
||||
{
|
||||
String[] tmp = mapResponse.Split(',');
|
||||
String[] tmp = mapResponse.Split(",".ToCharArray());
|
||||
Double lat = 0, lng = 0;
|
||||
string decimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
String tmpLat = tmp[0];
|
||||
|
@ -1015,7 +1015,7 @@ namespace Safedispatch_4_0
|
||||
else ckSpeedLimit.Checked = false;
|
||||
tbSpeed.Value = (((ZoneClass)((RadListDataItem)cbZoneEdit.SelectedItem).Value)).speed;
|
||||
String listOfUnits = (((ZoneClass)((RadListDataItem)cbZoneEdit.SelectedItem).Value)).unitids;
|
||||
String[] tmp = listOfUnits.Split(',');
|
||||
String[] tmp = listOfUnits.Split(",".ToCharArray());
|
||||
Hashtable tmpHashName = new Hashtable();
|
||||
if (tmp.Count() > 1)
|
||||
{
|
||||
|
@ -2103,7 +2103,7 @@ namespace Safedispatch_4_0
|
||||
}
|
||||
// Console.WriteLine("Update cmd:" + updatecomand);
|
||||
Thread.Sleep(1);
|
||||
String[] tmp = updatecomand.Split(',');
|
||||
String[] tmp = updatecomand.Split(",".ToCharArray());
|
||||
if (docLoad)
|
||||
{
|
||||
//SM.Debug("Oneunit"+MainForm2.oneunit);
|
||||
@ -2116,7 +2116,7 @@ namespace Safedispatch_4_0
|
||||
//SM.Debug("Value of displayname:" + MainForm2.Displaywithname);
|
||||
if (((MainForm2.Displaywithname) && (updatecomand.Contains("setDataset,"))) || (MainForm2.ForcePutLabelsONGoogle))
|
||||
{
|
||||
String[] datas = updatecomand.Split(',');
|
||||
String[] datas = updatecomand.Split(",".ToCharArray());
|
||||
if (datas.Length > 1)
|
||||
{
|
||||
//System.Threading.Thread.Sleep(100);
|
||||
|
@ -817,7 +817,7 @@ namespace Safedispatch_4_0
|
||||
IPictureMarkerSymbol bitmapPictureMarkerSymbolCls = new
|
||||
ESRI.ArcGIS.Display.PictureMarkerSymbolClass();
|
||||
//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";
|
||||
Image ArcgisImage = null;
|
||||
veh.IconID = veh.is_emergency ? 10000 + veh.IconID : veh.IconID % 10000;
|
||||
|
@ -510,7 +510,7 @@ namespace Safedispatch_4_0.Radio
|
||||
// #seqID#123#gatewayId.gatewayRadioId#result#dispatcherID#
|
||||
string cmd = "";
|
||||
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);
|
||||
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
|
||||
}
|
||||
@ -527,7 +527,7 @@ namespace Safedispatch_4_0.Radio
|
||||
// #seqID#122#gatewayId.gatewayRadioId#result#dispatcherID#
|
||||
string cmd = "";
|
||||
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);
|
||||
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
|
||||
}
|
||||
@ -553,7 +553,7 @@ namespace Safedispatch_4_0.Radio
|
||||
// Show event on System log
|
||||
// #seqID#123#gatewayId.gatewayRadioId#result#dispatcherID#
|
||||
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);
|
||||
this.Invoke((Action)(() => { parent.AddDataToSystemGrid(false, cmd); }));
|
||||
}
|
||||
@ -563,7 +563,7 @@ namespace Safedispatch_4_0.Radio
|
||||
string seqId = parent.GetCallRequestForSip(targetSipID);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -582,7 +582,7 @@ namespace Safedispatch_4_0.Radio
|
||||
// Show event on System log
|
||||
// #seqID#122#gatewayId.gatewayRadioId#result#dispatcherID#
|
||||
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);
|
||||
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)
|
||||
{
|
||||
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, 1, (int)callType, int.Parse(targetCallSipID), true);
|
||||
// Add info in system tab
|
||||
//#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)
|
||||
{
|
||||
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);
|
||||
// Show 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)
|
||||
{
|
||||
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, 3, (int)typeOfCall, int.Parse(targetCallSipID), true);
|
||||
// Show info in System Tab
|
||||
// Add info in system tab
|
||||
@ -1233,7 +1241,7 @@ namespace Safedispatch_4_0.Radio
|
||||
if (obj.group_cpsId == null)
|
||||
{
|
||||
GroupIDFromPath = obj.hddLocation;
|
||||
GroupIDFromSplit = GroupIDFromPath.Split('_');
|
||||
GroupIDFromSplit = GroupIDFromPath.Split("_".ToCharArray());
|
||||
userWhoWasCalled = GroupIDFromSplit[5];
|
||||
}
|
||||
else
|
||||
|
@ -775,7 +775,7 @@ namespace Safedispatch_4_0
|
||||
if (RepType == rep_type.JOB_TICKETING)
|
||||
{
|
||||
//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] != "")
|
||||
{
|
||||
|
@ -878,7 +878,7 @@ namespace Safedispatch_4_0
|
||||
//}
|
||||
|
||||
// find spaces to add a new line between them
|
||||
string[] split = DataString.Split(' ');
|
||||
string[] split = DataString.Split(" ".ToCharArray());
|
||||
if (split.Length == 4)
|
||||
DataString = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
|
||||
else if (split.Length == 3)
|
||||
@ -968,7 +968,7 @@ namespace Safedispatch_4_0
|
||||
//}
|
||||
|
||||
// find spaces to add a new line between them
|
||||
string[] split = DataString.Split(' ');
|
||||
string[] split = DataString.Split(" ".ToCharArray());
|
||||
if (split.Length == 4)
|
||||
DataString = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
|
||||
else if (split.Length == 3)
|
||||
@ -1590,7 +1590,7 @@ namespace Safedispatch_4_0
|
||||
if (SMSTreeView.SelectedNode == null)
|
||||
return;
|
||||
// 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))
|
||||
{
|
||||
@ -1627,11 +1627,11 @@ namespace Safedispatch_4_0
|
||||
}
|
||||
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]);
|
||||
else
|
||||
// update null text for quick send textbox
|
||||
rtbQuickText.NullText = String.Format(MainForm2.returnLNGString("sendquicksms"), SMSTreeView.SelectedNode.Text.Split('[')[0]);
|
||||
|
||||
string msg = (SMSTreeView.SelectedNode.Nodes.Count > 0) ? MainForm2.returnLNGString("sendquickgroupsms") : MainForm2.returnLNGString("sendquicksms");
|
||||
rtbQuickText.NullText = String.Format(msg, SMSTreeView.SelectedNode.Text.Split("[".ToCharArray())[0]);
|
||||
|
||||
|
||||
// display maximum number of characters
|
||||
rtbQuickText.MaxLength = SmsUtils.GetMaxNumberOfCharacters(MainForm2.radioType);
|
||||
if (MainForm2.vehicleHT.Contains(SMSTreeView.SelectedNode.Name))
|
||||
|
@ -627,7 +627,7 @@ namespace Safedispatch_4_0
|
||||
|
||||
public void UpdateExpiredTickets(string listOfExpiredTickets)
|
||||
{
|
||||
string[] expiredTickets = listOfExpiredTickets.Split(',');
|
||||
string[] expiredTickets = listOfExpiredTickets.Split(",".ToCharArray());
|
||||
try
|
||||
{
|
||||
foreach (string expiredTicket in expiredTickets)
|
||||
@ -1053,7 +1053,7 @@ namespace Safedispatch_4_0
|
||||
if (timeValue!= null && timeValue.Length > 0)
|
||||
{
|
||||
// find spaces to add a new line between them
|
||||
string[] split = timeValue.Split(' ');
|
||||
string[] split = timeValue.Split(" ".ToCharArray());
|
||||
if (split.Length == 4)
|
||||
cellElement.Text = String.Format("{0}\n{1} {2} {3}", split[0], split[1], split[2], split[3]);
|
||||
else if (split.Length == 3)
|
||||
@ -1079,7 +1079,7 @@ namespace Safedispatch_4_0
|
||||
{
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ namespace Dispatcher.maptab.UIClasses
|
||||
string key = $"{LiveTabLocation}_{tabName}";
|
||||
String[] loc = new string[0];
|
||||
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.Size size = loc.Length > 3 ? new System.Drawing.Size(int.Parse(loc[2]), int.Parse(loc[3])) : new System.Drawing.Size(800, 640);
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -263,19 +263,24 @@ namespace SipComponent
|
||||
}
|
||||
else
|
||||
_localIPaddress = localIPAddress;
|
||||
|
||||
_sipDomainPort = sipDomainPort;
|
||||
_sipClient = CreateSipClientClass(sipDomain, _sipDomainPort, _localIPaddress, localSipPort, userName, password, requestTimeout);
|
||||
_bufferMiliseconds = bufferMiliseconds;
|
||||
|
||||
// Registration Timer
|
||||
_registrationInterval = registrationInterval;
|
||||
_registrationData = new RegistrationData(userName, _registrationInterval + 2);
|
||||
|
||||
System.Timers.Timer registrationTimer = new System.Timers.Timer();
|
||||
// Set up the registration timer
|
||||
registrationTimer.Interval = _registrationInterval * 1000;
|
||||
registrationTimer.Elapsed += _registrationTimer_Elapsed;
|
||||
|
||||
_sipID_regTimer_regStatus_Dict.Add(userName,
|
||||
new Tuple<System.Timers.Timer, RegistrationStatus>(registrationTimer, RegistrationStatus.RegistrationNotStarted
|
||||
));
|
||||
|
||||
_IDsregisteredList.Add(userName);
|
||||
StartRegistrationTimer();
|
||||
|
||||
@ -304,6 +309,7 @@ namespace SipComponent
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
if (idToInvite == null)
|
||||
throw new ArgumentNullException("idToInvite");
|
||||
|
||||
lock (_lockerSipDialog)
|
||||
{
|
||||
if (!_IDsentInviteDict.ContainsKey(idToInvite) && !_IDreceivedInviteDict.ContainsKey(idToInvite)
|
||||
@ -324,6 +330,7 @@ namespace SipComponent
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
if (groupIDtoInvite == null)
|
||||
throw new ArgumentNullException("groupIDtoInvite");
|
||||
|
||||
// Check if registered to the group id
|
||||
lock (_lockerSipDialog)
|
||||
{
|
||||
@ -342,6 +349,7 @@ namespace SipComponent
|
||||
{
|
||||
if (_sipClassClosed)
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
|
||||
Task t = null;
|
||||
CancelInvite_private(idToCancel, out t);
|
||||
}
|
||||
@ -370,6 +378,7 @@ namespace SipComponent
|
||||
{
|
||||
return dialog.CallID == _IDsentInviteDict[idToCancel].CallID;
|
||||
});
|
||||
|
||||
if (d != null)
|
||||
{
|
||||
//Send Cancel Request
|
||||
@ -387,6 +396,7 @@ namespace SipComponent
|
||||
}
|
||||
}, d);
|
||||
}
|
||||
|
||||
// Remove from dict
|
||||
_IDsentInviteDict.Remove(idToCancel);
|
||||
_IDsCalledByMeList.Remove(idToCancel);
|
||||
@ -585,6 +595,7 @@ namespace SipComponent
|
||||
{
|
||||
if (_sipClassClosed)
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
|
||||
lock (_lockerSipDialog)
|
||||
{
|
||||
if (_IDdialogTuple.ContainsKey(idToSendVoice))
|
||||
@ -603,29 +614,29 @@ namespace SipComponent
|
||||
{
|
||||
if (_sipClassClosed)
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
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
|
||||
|
||||
if (idToRequestGps == null)
|
||||
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>
|
||||
@ -636,26 +647,26 @@ namespace SipComponent
|
||||
{
|
||||
if (_sipClassClosed)
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
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
|
||||
|
||||
if (linxID == null)
|
||||
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>
|
||||
@ -669,10 +680,12 @@ namespace SipComponent
|
||||
{
|
||||
if (_sipClassClosed)
|
||||
throw new ObjectDisposedException("SipClientClass");
|
||||
|
||||
if (idToSendSMS != null && text != null)
|
||||
{
|
||||
bool sendSipMessage = true;
|
||||
string unconfirmedSmsKey = null;
|
||||
|
||||
if (_smsConfirmationFromServer)
|
||||
{
|
||||
unconfirmedSmsKey = idToSendSMS + text.GetHashCode();
|
||||
@ -691,6 +704,7 @@ namespace SipComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sendSipMessage)
|
||||
{
|
||||
// Create a new thread on which:
|
||||
@ -743,15 +757,16 @@ namespace SipComponent
|
||||
throw new ArgumentNullException("text");
|
||||
}
|
||||
|
||||
private Message GenerateSipMessage(string destinationID, string senderID, string sipServer,
|
||||
int sipServerPort, string text)
|
||||
private Message GenerateSipMessage(string destinationID, string senderID, string sipServer, int sipServerPort, string text)
|
||||
{
|
||||
Message sipMessage = new Message();
|
||||
sipMessage.Uri = "sip:" + destinationID + "@" + sipServer + ":" + sipServerPort;
|
||||
sipMessage.From = new ContactInfo(string.Format("sip:{0}@{1}", senderID, sipServer));
|
||||
sipMessage.To = new ContactInfo(string.Format("sip:{0}@{1}", destinationID, sipServer));
|
||||
sipMessage.ContentType = "text/plain;charset=UTF-8";
|
||||
sipMessage.Body = text;
|
||||
Message sipMessage = new Message()
|
||||
{
|
||||
Uri = $"sip:{destinationID}@{sipServer}:{sipServerPort}",
|
||||
From = new ContactInfo($"sip:{senderID}@{sipServer}"),
|
||||
To = new ContactInfo($"sip:{destinationID}@{sipServer}"),
|
||||
ContentType = "text/plain;charset=UTF-8",
|
||||
Body = text
|
||||
};
|
||||
|
||||
return sipMessage;
|
||||
}
|
||||
@ -833,10 +848,12 @@ namespace SipComponent
|
||||
if (!_sipClassClosed)
|
||||
{
|
||||
_sipClassClosed = true;
|
||||
|
||||
// Send ARS OFF and disconnect from socket IO
|
||||
if (_sendArsOnOff)
|
||||
_socketIOClass.SendArs(new ArsInfo(false, "0", UserName));
|
||||
_socketIOClass.Disconect();
|
||||
_socketIOClass.Disconect();
|
||||
|
||||
//
|
||||
List<string> sipIDs = new List<string>();
|
||||
Task task = null;
|
||||
@ -892,6 +909,7 @@ namespace SipComponent
|
||||
// Stop sip class
|
||||
_sipClient.Disconnect();
|
||||
});
|
||||
|
||||
if (!async)
|
||||
t.Wait();
|
||||
}
|
||||
@ -911,6 +929,8 @@ namespace SipComponent
|
||||
zeroRegistrationData = new RegistrationData(id, 0, true);
|
||||
else
|
||||
zeroRegistrationData = new RegistrationData(id, 0);
|
||||
|
||||
|
||||
_sipID_regTimer_regStatus_Dict[id].Item1.Stop();
|
||||
SendSipRegister(zeroRegistrationData);
|
||||
}
|
||||
@ -1398,10 +1418,11 @@ namespace SipComponent
|
||||
string lastWord = source.Substring(source.LastIndexOf(' ') + 1);
|
||||
if (lastWord.Contains("delivered"))
|
||||
return true;
|
||||
else if (lastWord.Contains("failed"))
|
||||
|
||||
if (lastWord.Contains("failed"))
|
||||
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
|
||||
@ -1418,11 +1439,13 @@ namespace SipComponent
|
||||
// Extract ip and port where to send voice to simoco
|
||||
IPAddress ipToSendAudio = null;
|
||||
int portToSendAudio;
|
||||
|
||||
if (IPAddress.TryParse(receivedSDP.Connection.Address, out ipToSendAudio))
|
||||
{
|
||||
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
|
||||
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)
|
||||
{
|
||||
SipClient sipClient;
|
||||
|
||||
// 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);
|
||||
// Turn on logging
|
||||
//sipClient.Logger = new Logger(AppDomain.CurrentDomain.BaseDirectory + "\\sipLog.txt");
|
||||
@ -1590,6 +1613,7 @@ namespace SipComponent
|
||||
|
||||
int rtpPort = ReturnAvailablePort();
|
||||
SessionDescription sdp = CreateSDP(rtpPort);
|
||||
|
||||
Invite inv = new Invite();
|
||||
inv.Uri = "sip:" + idToCall + "@" + sipServerIP;
|
||||
inv.From = new ContactInfo("sip:" + sipID.ToString() + "@" + sipServerIP);
|
||||
@ -1650,20 +1674,17 @@ namespace SipComponent
|
||||
private void SendSipRegister(object registrationDataObj)
|
||||
{
|
||||
string sipServerIP = _sipClient.Domain;
|
||||
|
||||
RegistrationData regData = (RegistrationData)registrationDataObj;
|
||||
string sipIDfrom = _sipClient.Username;
|
||||
string sipIDto = regData.SipID;
|
||||
string sipIDto = regData.SipID;
|
||||
int expiresValue = regData.Expires;
|
||||
bool isUnregisterRequest = (expiresValue == 0);
|
||||
|
||||
Register reg = new Register();
|
||||
reg.Uri = "sip:" + sipServerIP;
|
||||
reg.From = new ContactInfo(
|
||||
sipIDfrom.ToString(),
|
||||
"sip:" + sipIDfrom + "@" + sipServerIP);
|
||||
reg.To = new ContactInfo(
|
||||
sipIDto.ToString(),
|
||||
"sip:" + sipIDto.ToString() + "@" + sipServerIP);
|
||||
reg.From = new ContactInfo( sipIDfrom.ToString(), $"sip:{sipIDfrom}@{sipServerIP}");
|
||||
reg.To = new ContactInfo( sipIDto.ToString(), $"sip:{sipIDto}@{sipServerIP}");
|
||||
reg.Contact = new Contact("sip:" + sipIDfrom.ToString() + "@" + _sipClient.LocalIPEndPoint.ToString());
|
||||
reg.Expires = expiresValue;
|
||||
|
||||
@ -1763,6 +1784,7 @@ namespace SipComponent
|
||||
{
|
||||
SendSipRegister(state);
|
||||
}, _registrationData);
|
||||
|
||||
// Start registration timer
|
||||
_sipID_regTimer_regStatus_Dict[UserName].Item1.Start();
|
||||
}
|
||||
@ -1807,10 +1829,12 @@ namespace SipComponent
|
||||
{
|
||||
rtpPort += 2;
|
||||
}
|
||||
|
||||
if (rtpPort < MaxRtpPortNumber)
|
||||
return rtpPort;
|
||||
else
|
||||
throw new SipClassException(
|
||||
|
||||
|
||||
throw new SipClassException(
|
||||
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;
|
||||
});
|
||||
if (inv != null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
return (inv != null);
|
||||
}
|
||||
|
||||
private bool IsPortAllreadyInUse(int portNumber)
|
||||
@ -1843,15 +1865,12 @@ namespace SipComponent
|
||||
public static bool ValidRtpPort(int rtpPort)
|
||||
{
|
||||
if (rtpPort < 1024 || rtpPort > 65534)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (rtpPort % 2 == 1)
|
||||
{
|
||||
|
||||
if (rtpPort % 2 == 1)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1870,11 +1889,6 @@ namespace SipComponent
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private bool IsInSameSubnet(IPAddress address2, IPAddress address, IPAddress subnetMask)
|
||||
{
|
||||
IPAddress network1 = GetNetworkAddress(address, subnetMask);
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -266,7 +266,7 @@ namespace SubscriberAndUserManager
|
||||
|
||||
public static Boolean TestIP(string IP)
|
||||
{
|
||||
String[] tmp = IP.Split('.');
|
||||
String[] tmp = IP.Split(".".ToCharArray());
|
||||
if (tmp.Length != 4) return false;
|
||||
Int32 number;
|
||||
bool result;
|
||||
@ -913,7 +913,7 @@ namespace SubscriberAndUserManager
|
||||
int result = clientStream.Read(message, 0, message.Length);
|
||||
Console.WriteLine("Received registration from server");
|
||||
String decodedString = encoding.GetString(message).Trim('\0');
|
||||
String[] options = decodedString.Split(';');
|
||||
String[] options = decodedString.Split(";".ToCharArray());
|
||||
Console.WriteLine("Option" + decodedString);
|
||||
|
||||
APP_SERVER_VERSION = options[options.Length - 1].Replace("valid-", "");
|
||||
|
@ -32,6 +32,6 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ namespace SubscriberAndUserManager
|
||||
private void EditRangeVehicles()
|
||||
{
|
||||
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]);
|
||||
|
||||
if (cbStatus.Text.Equals(MainForm.returnLNGString("active")) && isUnitDeleted)
|
||||
|
@ -835,19 +835,28 @@ namespace SubscriberAndUserManager
|
||||
}
|
||||
|
||||
private void SendBackupListRequest()
|
||||
{
|
||||
if(MainForm.udp != null)
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#53#1#"), Utils.Convert_text_For_multicast("#0.0#53#1#").Length);
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#53#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
private void SendBackupRequest()
|
||||
{
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#51#1#"), Utils.Convert_text_For_multicast("#0.0#51#1#").Length);
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#51#1#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
private void SendRestoreRequest(string filename)
|
||||
{
|
||||
{
|
||||
if (MainForm.udp != null)
|
||||
MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#"), Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#").Length);
|
||||
{
|
||||
byte[] dataToSend = Utils.Convert_text_For_multicast("#0.0#52#" + filename + "#");
|
||||
MainForm.udp.Send(dataToSend, dataToSend.Length);
|
||||
}
|
||||
}
|
||||
|
||||
delegate void UpdateList(string fileNames);
|
||||
@ -861,13 +870,15 @@ namespace SubscriberAndUserManager
|
||||
else
|
||||
{
|
||||
listBackups.Items.Clear();
|
||||
string[] fileNameArr = fileNames.Split(';');
|
||||
foreach (string fName in fileNameArr)
|
||||
string[] fileNameArr = fileNames.Split(";".ToCharArray());
|
||||
if (fileNameArr != null && fileNameArr.Length > 0)
|
||||
{
|
||||
if (fName != "")
|
||||
foreach (string fName in fileNameArr)
|
||||
{
|
||||
RadListDataItem r = new RadListDataItem(fName);
|
||||
listBackups.Items.Add(r);
|
||||
if (fName != "")
|
||||
{
|
||||
listBackups.Items.Add(new RadListDataItem(fName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -888,7 +899,7 @@ namespace SubscriberAndUserManager
|
||||
{
|
||||
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();
|
||||
foreach (string bk in backupList)
|
||||
listBackups.Items.Add(bk);
|
||||
@ -1439,7 +1450,7 @@ namespace SubscriberAndUserManager
|
||||
string rtpstart = o["data"]["ports"]["rtpstart"].ToString();
|
||||
string rtpend = o["data"]["ports"]["rtpend"].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;
|
||||
txNatIP.Value = publicIp;
|
||||
txUdpStart.Value = rtpstart;
|
||||
|
@ -852,7 +852,7 @@ namespace SubscriberAndUserManager
|
||||
if (alm.Speed != "")
|
||||
{
|
||||
chbSpeed.Checked = true;
|
||||
string[] arrSpeed = alm.Speed.Split('_');
|
||||
string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
|
||||
Int16 speed = 1;
|
||||
Int16.TryParse(arrSpeed[0], out speed);
|
||||
|
||||
@ -943,7 +943,7 @@ namespace SubscriberAndUserManager
|
||||
if (alm.Speed != "")
|
||||
{
|
||||
SpeedStat = 1;
|
||||
string[] arrSpeed = alm.Speed.Split('_');
|
||||
string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
|
||||
Speedvalue = arrSpeed[0];
|
||||
if (arrSpeed.Length == 2)
|
||||
{
|
||||
@ -980,7 +980,7 @@ namespace SubscriberAndUserManager
|
||||
if (((alm.Loneworker != "") && (LoneStat ==0))||((alm.Loneworker == "") && (LoneStat ==1))) LoneStat = 2;
|
||||
if (alm.Speed != "")
|
||||
{
|
||||
string[] arrSpeed = alm.Speed.Split('_');
|
||||
string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
|
||||
if (Speedvalue != arrSpeed[0])
|
||||
{
|
||||
Speedvalue = "0"; SpeedStat = 2;
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.1.0.10898")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
||||
|
15
UpdateHelper/4to5.sql
Normal file
15
UpdateHelper/4to5.sql
Normal file
@ -0,0 +1,15 @@
|
||||
CREATE TABLE public.user_radio (radio_id integer NOT NULL DEFAULT 0,user_id integer NOT NULL DEFAULT 0) WITH (OIDS=FALSE);
|
||||
ALTER TABLE public.user_radio OWNER TO postgres;
|
||||
CREATE TABLE public.reports(startdate integer NOT NULL DEFAULT 0, stopdate integer NOT NULL DEFAULT 0, unit_ids character varying(4096), geofence_id integer NOT NULL DEFAULT 0, type_stat integer NOT NULL DEFAULT 0, report_id integer NOT NULL DEFAULT 0, email character varying(255),idletime integer, idx serial NOT NULL) WITH (OIDS = FALSE);
|
||||
ALTER TABLE public.reports OWNER TO postgres;
|
||||
ALTER TABLE zonename ADD COLUMN useridx integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE place ADD COLUMN useridx integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE zonename ADD COLUMN alarmtype integer NOT NULL DEFAULT 3;
|
||||
ALTER TABLE zonename ADD COLUMN sentmsg boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE zonename ADD COLUMN msgbody character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN unitids character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN sentemail boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE zonename ADD COLUMN email character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN subj character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN body character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN imeilist character varying(255) NOT NULL DEFAULT '';
|
33
UpdateHelper/5to6.sql
Normal file
33
UpdateHelper/5to6.sql
Normal file
@ -0,0 +1,33 @@
|
||||
ALTER TABLE \"VoiceRecordings\" ADD COLUMN calltype integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE \"VoiceRecordings\" ADD COLUMN group_id integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE zonename ADD COLUMN sentmsg2 boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE zonename ADD COLUMN msgbody2 character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE speedalarm ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE speedalarm ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE telemetry_history ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE telemetry_history ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE emergalarm ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE emergalarm ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE reports ADD COLUMN latlng boolean NOT NULL DEFAULT false;
|
||||
UPDATE emergalarm SET address='no address' WHERE address = '';
|
||||
UPDATE telemetry_history SET address='no address' WHERE address = '';
|
||||
UPDATE speedalarm SET address='no address' WHERE address = '';
|
||||
ALTER TABLE vehicle ADD COLUMN gps_poor integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE vehicle ADD COLUMN gps_off integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE vehicle ADD COLUMN made_off integer NOT NULL DEFAULT 0;
|
||||
UPDATE vehicle SET gps_poor=\"GPS_reporting_interval\"*2, gps_off=\"GPS_reporting_interval\"*4, made_off=\"GPS_reporting_interval\"*10;
|
||||
UPDATE lastpos SET status=0;
|
||||
ALTER TABLE gateways ADD COLUMN peer_id integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE radio_gw DROP CONSTRAINT unique_radio_gw;
|
||||
ALTER TABLE sms ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE sms ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE sms ADD COLUMN address character varying(255) NOT NULL DEFAULT 'no address';
|
||||
INSERT INTO emailservice(id, \"user\", pass, enable) VALUES (2,'poll', 'poll', 0);
|
||||
ALTER TABLE zonename ADD COLUMN speed integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE emailservice ADD COLUMN pop_server text NOT NULL DEFAULT 'pop.gmail.com';
|
||||
ALTER TABLE emailservice ADD COLUMN pop_port integer NOT NULL DEFAULT 995;
|
||||
ALTER TABLE emailservice ADD COLUMN smtp_server text NOT NULL DEFAULT 'smtp.gmail.com';
|
||||
ALTER TABLE emailservice ADD COLUMN smtp_port integer NOT NULL DEFAULT 587;
|
||||
ALTER TABLE emailservice ADD COLUMN is_pop_ssl boolean NOT NULL DEFAULT true;
|
||||
ALTER TABLE emailservice ADD COLUMN is_smtp_ssl boolean NOT NULL DEFAULT true;
|
||||
ALTER TABLE emailservice ADD COLUMN last_email_time integer NOT NULL DEFAULT 0;
|
279
UpdateHelper/6to7.sql
Normal file
279
UpdateHelper/6to7.sql
Normal file
@ -0,0 +1,279 @@
|
||||
ALTER TABLE lastpos ADD COLUMN altitude double precision NOT NULL DEFAULT 0;
|
||||
DROP TABLE IF EXISTS jobtickets;
|
||||
CREATE TABLE jobtickets (ticket_id serial,name text,job_status integer,sc_id integer,comment text,dispatcher text,priority text,end_time_planned integer,creation_time integer,start_time integer,end_time integer,is_expired boolean DEFAULT false NOT NULL,deleted integer,share_with text,seq_id character varying(40),status integer DEFAULT 0 NOT NULL,sched_timegmt integer DEFAULT 0);
|
||||
ALTER TABLE public.jobtickets OWNER TO postgres;
|
||||
DROP TABLE IF EXISTS jobtickets_log;
|
||||
CREATE TABLE jobtickets_log ( id serial, ticket_id integer, modified_date integer,job_status integer, sc_id integer, comment text) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE jobtickets_log OWNER TO postgres;
|
||||
DROP TABLE IF EXISTS jobticketstatusesset;
|
||||
CREATE TABLE jobticketstatusesset ( status_id serial, status character varying(45), color character varying(45), sound_on integer, sound_file character varying(250), is_first_state integer, is_last_state integer, CONSTRAINT jobticketstatusesset_pkey PRIMARY KEY (status_id))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE jobticketstatusesset OWNER TO postgres;
|
||||
DROP TABLE IF EXISTS definejobticket;
|
||||
CREATE TABLE definejobticket ( name character varying(200) NOT NULL, text character varying(200) NOT NULL, comment character varying(200), priority character varying(200), expire_date integer, idx serial NOT NULL, CONSTRAINT definejobticket_pkey PRIMARY KEY (idx))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE definejobticket OWNER TO postgres;
|
||||
ALTER TABLE registration ADD COLUMN has_ticketing boolean NOT NULL DEFAULT false;
|
||||
DELETE FROM jobticketstatusesset;
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (1, 'Assigned', '3D8584', 0, '', 1, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (2, 'Accepted', '3D7171', 0, '', 0, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (3, 'In progress', '3D5B85', 0, '', 0, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (4, 'Completed', '5E853D', 0, '', 0, 1);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (5, 'Rejected', 'A93D47', 0, '', 0, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (6, 'Overdue', 'B29F3D', 0, '', 0, 0);
|
||||
ALTER TABLE definejobticket ADD COLUMN handled_by text;
|
||||
ALTER TABLE definejobticket ADD COLUMN schedule_date integer;
|
||||
ALTER TABLE definejobticket ADD COLUMN share_with text;
|
||||
DROP TABLE IF EXISTS sequences;
|
||||
CREATE TABLE sequences( name character varying(32) NOT NULL, value integer NOT NULL DEFAULT 0, idx serial NOT NULL, CONSTRAINT sequences_pkey PRIMARY KEY (idx))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE sequences OWNER TO postgres;
|
||||
INSERT INTO sequences(name, value) VALUES('jobticketing',1);
|
||||
DROP TABLE IF EXISTS icon_theme;
|
||||
CREATE TABLE icon_theme( id serial NOT NULL, \"name\" text, prefix text) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE icon_theme OWNER TO postgres;
|
||||
INSERT INTO icon_theme(id, \"name\", prefix)VALUES (1, 'Classic', 'classic'),(2, 'Pin', 'pin');
|
||||
DROP TABLE IF EXISTS car;
|
||||
CREATE TABLE car(\"name\" character varying(100) NOT NULL, id serial NOT NULL, pattern text, displayed_name text, CONSTRAINT car_pkey PRIMARY KEY (id))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE car OWNER TO postgres;
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('minibus', 102, 'minibus_01', 'Van 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Minicar', 103, 'minicar_01', 'MiniCar 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('people_08', 35, 'people_08', 'People 8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Minicar2', 104, 'minicar_02', 'MiniCar 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('police', 105, 'police_01', 'Police 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Police1', 106, 'police_02', 'Police 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('schoolbus', 107, 'school_bus_01', 'School Bus 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('taxi_02', 131, 'taxi_02', 'Taxi 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('schoolbus2', 108, 'school_bus_02', 'School Bus 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_01', 132, 'moto_01', 'Moto 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_02', 133, 'moto_02', 'Moto 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('TowTruckYellow', 110, 'tow_truck_01', 'Tow Truck');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('TractorUnitBlack', 111, 'tractor_unit', 'Tractor Unit');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_03', 134, 'moto_03', 'Moto 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_04', 135, 'moto_04', 'Moto 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Classic-Car-66', 92, 'classic_car_01', 'Classic Car 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck0', 112, 'truck_01', 'Truck 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('classycar', 93, 'classic_car_02', 'Classic Car 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peopleblue', 1, 'people_01', 'People 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplegreen', 2, 'people_02', 'People 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplegrey', 3, 'people_03', 'People 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplepink', 4, 'people_04', 'People 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplepurple', 5, 'people_05', 'People 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplered', 6, 'people_06', 'People 6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('army', 79, 'army_01', 'Army');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bigcar0', 80, 'car_01', 'Car 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bigcar1', 81, 'car_02', 'Car 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bigcar2', 82, 'car_03', 'Car 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_05', 136, 'moto_05', 'Moto 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bicycle_01', 137, 'bicycle_01', 'Bicycle');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car0', 87, 'car_04', 'Car 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car1', 88, 'car_05', 'Car 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car2', 89, 'car_06', 'Car 6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car3', 90, 'car_07', 'Car 7');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('CarGrey', 91, 'car_08', 'Car 8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('dodge', 94, 'dodge_01', 'Dodge');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('FireEscape', 95, 'firetruck_01', 'FireTruck 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck1', 113, 'truck_02', 'Truck 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('firefighters2', 96, 'firetruck_02', 'Fire Truck 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('ambulance_01', 36, 'ambulance_01', 'Ambulance 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('firetruck1', 97, 'firetruck_03', 'Fire Truck 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck2', 114, 'truck_03', 'Truck 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('firetruck2', 98, 'firetruck_04', 'Fire Truck 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Jeep', 99, 'jeep_01', 'Jeep');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('CabrioletRed', 86, 'cabriolet_01', 'Carbriolet');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck3', 115, 'truck_04', 'Truck 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Longhaul', 100, 'longhaul_01', 'Long Haul');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck4', 116, 'truck_05', 'Truck 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('LorryGreen', 101, 'lorry_01', 'Lorry');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('ambulance_02', 78, 'ambulance_02', 'Ambulance 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck5', 117, 'truck_06', 'Truck 6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck6', 118, 'truck_07', 'Truck 7');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('TruckYellow', 119, 'truck_08', 'Truck 8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('wagon', 120, 'wagon_01', 'Wagon');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bus', 83, 'tour_bus_01', 'Tour Bus 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bus0', 84, 'bus_01', 'Bus 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bus2', 85, 'bus_02', 'Bus 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_01', 121, 'number_01', '1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_02', 122, 'number_02', '2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_04', 124, 'number_04', '4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_03', 123, 'number_03', '3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_05', 125, 'number_05', '5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_06', 126, 'number_06', '6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_07', 127, 'number_07', '7');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_08', 128, 'number_08', '8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_09', 129, 'number_09', '9');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_10', 130, 'number_10', '10');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('taxi', 109, 'taxi_01', 'Taxi 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('people_07', 34, 'people_07', 'People 7');
|
||||
insert into \"userSettings\" (user_id, key, value) select userid, 'reportTime', '0' from users where userid not in (select user_id from \"userSettings\" where key = 'reportTime') order by userid;
|
||||
insert into \"userSettings\" (user_id, key, value) select userid, 'iconTheme', 'pin' from users where userid not in (select user_id from \"userSettings\" where key = 'iconTheme') order by userid;
|
||||
ALTER TABLE reports ADD COLUMN userid integer;
|
||||
UPDATE reports SET userid = (SELECT MAX(userid) FROM users);
|
||||
ALTER TABLE reports ADD COLUMN ticket_status character varying(250);
|
||||
ALTER TABLE reports ADD COLUMN ticket_date_type character varying(250);
|
||||
ALTER TABLE reports ADD COLUMN type text;
|
||||
ALTER TABLE reports ADD COLUMN day text;
|
||||
ALTER TABLE reports ADD COLUMN is_activated boolean;
|
||||
ALTER TABLE sms ADD COLUMN color character varying(7);
|
||||
ALTER TABLE sms ALTER COLUMN color SET STORAGE EXTENDED;
|
||||
DROP TABLE IF EXISTS placetype;
|
||||
CREATE TABLE placetype ( type_name character varying(100) NOT NULL,type_id integer NOT NULL,icon_name character varying(70));
|
||||
ALTER TABLE public.placetype OWNER TO postgres;
|
||||
CREATE SEQUENCE placetype_type_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;
|
||||
ALTER TABLE public.placetype_type_id_seq OWNER TO postgres;
|
||||
ALTER SEQUENCE placetype_type_id_seq OWNED BY placetype.type_id;
|
||||
SELECT pg_catalog.setval('placetype_type_id_seq', 156, true);
|
||||
ALTER TABLE place ADD COLUMN icon_size character varying(20);
|
||||
ALTER TABLE place ADD COLUMN color character varying(7);
|
||||
ALTER TABLE zonename ADD COLUMN fill_color character varying(7);
|
||||
ALTER TABLE zonename ADD COLUMN fill_opacity double precision;
|
||||
ALTER TABLE zonename ADD COLUMN border_color character varying(7);
|
||||
ALTER TABLE zonename ADD COLUMN border_opacity double precision;
|
||||
ALTER TABLE zonename ADD COLUMN border_width integer;
|
||||
ALTER TABLE placetype ALTER COLUMN type_id SET DEFAULT nextval('placetype_type_id_seq'::regclass);
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('calculator', 45, 'calculator.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('calendar', 46, 'calendar.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('camera', 47, 'camera.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cancel', 48, 'cancel.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('factory', 4, 'factory.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('airport', 1, 'airport.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cd', 49, 'cd.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hospital', 6, 'hospital.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bank', 2, 'bank.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('school', 15, 'school.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('supermarket', 17, 'supermarket.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shopping', 16, 'shopping.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('office', 18, 'office.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('post_office', 13, 'post_office.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('restaurant', 14, 'restaurant.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('home', 9, 'home.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('fire_department', 7, 'fire_department.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('repair_shop', 3, 'repair_shop.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('garage', 5, 'garage.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hotel', 10, 'hotel.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('gas_station', 8, 'gas_station.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('military_base', 11, 'military_base.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('police_station', 12, 'police_station.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('chair', 50, 'chair.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('check', 51, 'check.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cinema', 52, 'cinema.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('add', 20, 'add.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('coffee', 53, 'coffee.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('alert', 22, 'alert.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('anchor', 23, 'anchor.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('announce', 24, 'announce.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('antivirus', 25, 'antivirus.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_down', 26, 'arrow_down.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('compass', 54, 'compass.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_down_left', 27, 'arrow_down_left.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('computer', 55, 'computer.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_down_right', 28, 'arrow_down_right.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_left', 29, 'arrow_left.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('construction', 56, 'construction.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('repair_shop_2', 102, 'repair_shop_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('rip', 103, 'rip.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('roundabout', 104, 'roundabout.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('ruby', 105, 'ruby.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('save', 106, 'save.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_right', 30, 'arrow_right.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_up', 31, 'arrow_up.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_up_left', 32, 'arrow_up_left.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_up_right', 33, 'arrow_up_right.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('baggage', 34, 'baggage.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('banned', 35, 'banned.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('science', 107, 'science.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('search', 108, 'search.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('servers', 109, 'servers.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('settings', 110, 'settings.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_circle', 111, 'shape_circle.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_ellipse', 112, 'shape_ellipse.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_hexagon', 113, 'shape_hexagon.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_kite', 114, 'shape_kite.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_parallelogram', 115, 'shape_parallelogram.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('battery', 36, 'battery.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bicycle', 37, 'bicycle.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bluetooth', 38, 'bluetooth.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('book', 39, 'book.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bookmark', 40, 'bookmark.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('brush', 41, 'brush.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bug', 42, 'bug.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bussiness_card', 43, 'bussiness_card.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cake', 44, 'cake.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('credit_card', 57, 'credit_card.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cross', 58, 'cross.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('database', 59, 'database.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('directions', 60, 'directions.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('directions_2', 61, 'directions_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('doctor', 62, 'doctor.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('drill', 63, 'drill.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('elevator', 64, 'elevator.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('facebook', 65, 'facebook.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('fan', 66, 'fan.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('favorite', 67, 'favorite.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('flag', 68, 'flag.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('food', 69, 'food.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('gameboy', 70, 'gameboy.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_pentagon', 116, 'shape_pentagon.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_rhombus', 117, 'shape_rhombus.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_square', 118, 'shape_square.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_trapezoid', 119, 'shape_trapezoid.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_triangle', 120, 'shape_triangle.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pool_game', 98, 'pool_game.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('alarm', 21, 'alarm.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('games', 71, 'games.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('gift', 72, 'gift.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('glasses', 73, 'glasses.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('grid', 74, 'grid.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hairdresser', 75, 'hairdresser.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hammer', 76, 'hammer.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hardware', 77, 'hardware.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('headphones', 78, 'headphones.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hedge', 79, 'hedge.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('help', 80, 'help.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('help_2', 81, 'help_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('icecream', 82, 'icecream.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('info', 83, 'info.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('key', 84, 'key.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('map', 85, 'map.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('marker', 86, 'marker.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('microphone', 87, 'microphone.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('moon', 88, 'moon.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('newspaper', 89, 'newspaper.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('padlock_closed', 90, 'padlock_closed.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('padlock_open', 91, 'padlock_open.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('paintroller', 92, 'paintroller.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('park_bench', 93, 'park_bench.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('phone', 94, 'phone.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pill', 95, 'pill.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pinetree', 96, 'pinetree.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pollution', 97, 'pollution.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('print', 99, 'print.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('refreshment', 100, 'refreshment.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('remote_control', 101, 'remote_control.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stamp', 121, 'stamp.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('star', 122, 'star.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stop', 123, 'stop.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stop_2', 124, 'stop_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stopwatch', 125, 'stopwatch.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('store', 126, 'store.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('tag', 127, 'tag.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('tent', 128, 'tent.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('tie', 129, 'tie.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('time', 130, 'time.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight', 131, 'trafficlight.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight_green', 132, 'trafficlight_green.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight_red', 133, 'trafficlight_red.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight_yellow', 134, 'trafficlight_yellow.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trash', 135, 'trash.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trophy', 136, 'trophy.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('truck', 137, 'truck.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('typewritter', 138, 'typewritter.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('user', 139, 'user.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('users', 140, 'users.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('water', 141, 'water.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_cloud', 142, 'weather_cloud.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_clouds', 144, 'weather_clouds.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_rain', 145, 'weather_rain.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_sun', 146, 'weather_sun.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_snow', 147, 'weather_snow.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_thunder', 148, 'weather_thunder.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('wi_fi', 149, 'wi_fi.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_cloud_sun', 143, 'weather_cloud_sun.png');
|
||||
ALTER TABLE messages ADD COLUMN altitude double precision;
|
100
UpdateHelper/7toLatest7.sql
Normal file
100
UpdateHelper/7toLatest7.sql
Normal file
@ -0,0 +1,100 @@
|
||||
CREATE TABLE public.newicons (icontype integer NOT NULL DEFAULT 0, id integer NOT NULL DEFAULT 0, imagedata bytea);
|
||||
ALTER TABLE groups ADD COLUMN type integer;
|
||||
UPDATE groups SET type = 0;
|
||||
ALTER TABLE vehicle ADD COLUMN type integer;
|
||||
UPDATE vehicle SET type = 0;
|
||||
ALTER TABLE vehicle ADD COLUMN active boolean;
|
||||
UPDATE vehicle SET active = TRUE;
|
||||
ALTER TABLE radio_gw ADD COLUMN name character varying(30);
|
||||
UPDATE radio_gw SET name = 'unnamed' || \"ID\";
|
||||
ALTER TABLE radio_gw ADD COLUMN gw_type integer;
|
||||
UPDATE radio_gw SET gw_type = 0;
|
||||
ALTER TABLE groups ADD COLUMN r_gw_id integer;
|
||||
UPDATE groups SET r_gw_id = ( CASE WHEN ((select count(*) from radio_gw ) = 0) THEN 0 ELSE (select min(\"ID\") from radio_gw) END);
|
||||
update subs_gateway set gateway_id = (CASE WHEN ((select count(*) from radio_gw where \"ID\" = 1 and \"GW_ID\" = 1) = 0) THEN (select min(\"GW_ID\") from radio_gw) ELSE 1 END ), radio_gw_id = (CASE WHEN ((select count(*) from radio_gw where \"ID\" = 1 and \"GW_ID\" = 1) = 0) THEN (select min(\"ID\") from radio_gw) ELSE 1 END) where gateway_id = 1 and radio_gw_id = 1;
|
||||
CREATE TABLE subscriber_mobile( sc_id serial NOT NULL, phone_imei character varying(20), first_name character varying(50), last_name character varying(50), company character varying(30), os character varying(20), phone_type character varying(20), sip_pswd character varying(30), CONSTRAINT subscriber_mobile_pkey PRIMARY KEY (sc_id)) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE subscriber_mobile OWNER TO postgres;
|
||||
CREATE TABLE mobile_contacts(idx serial NOT NULL, sc_id integer NOT NULL, contact_id integer NOT NULL, contact_type character varying(30), contact_type_id integer) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE mobile_contacts OWNER TO postgres;
|
||||
ALTER TABLE sms ADD COLUMN user_id integer;
|
||||
ALTER TABLE sms ALTER COLUMN user_id SET STORAGE PLAIN;
|
||||
ALTER TABLE users ADD COLUMN backup_user_id integer default 0;
|
||||
ALTER TABLE users ALTER COLUMN backup_user_id SET STORAGE PLAIN;
|
||||
UPDATE users SET backup_user_id = -1;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_gps boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_voice boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_text boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_ticketing boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN email text;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN login text;
|
||||
ALTER TABLE users ADD COLUMN sip_id integer;
|
||||
ALTER TABLE users ALTER COLUMN sip_id SET STORAGE PLAIN;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN lone_worker boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN lone_worker_interval integer DEFAULT 0;
|
||||
ALTER TABLE emergalarm ADD COLUMN user_id integer;
|
||||
ALTER TABLE emergalarm ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE geozoneinout ADD COLUMN user_id integer;
|
||||
ALTER TABLE geozoneinout ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE speedalarm ADD COLUMN user_id integer;
|
||||
ALTER TABLE speedalarm ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE telemetry_history ADD COLUMN user_id integer;
|
||||
ALTER TABLE telemetry_history ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE emergalarm ADD COLUMN emergency_type integer;
|
||||
create table call_patch(idx serial not null, type integer, incoming text, outgoing text, userid integer);
|
||||
CREATE INDEX msg_sc_id_idx ON messages USING btree (sc_id);
|
||||
CREATE INDEX secv_idx ON messages USING btree (scevtime);
|
||||
CREATE INDEX speed_idx ON messages USING btree (speed);
|
||||
CREATE INDEX timegmt_idx ON messages USING btree (timegmt);
|
||||
CREATE TABLE users_group(idx serial not null, userid integer not null, grp_id integer not null);
|
||||
CREATE TABLE sip_manager(sip_id serial not null primary key, id integer not null, type integer not null);
|
||||
CREATE UNIQUE INDEX unique_idx ON sip_manager (id, type);
|
||||
ALTER SEQUENCE sip_manager_sip_id_seq RESTART WITH 10;
|
||||
insert into sip_manager(id, type) select userid, 0 from users where user_type <> 1;
|
||||
insert into sip_manager(id, type) select id, 1 from groups where type <> 0;
|
||||
insert into sip_manager(id, type) select sc_id, 2 from subscriber;
|
||||
insert into sip_manager(id, type) select \"ID\", 4 from radio_gw;
|
||||
ALTER TABLE users DROP COLUMN sip_id;
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'lanLinxServer','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'lanLinxServer');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'natLinxServer','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'natLinxServer');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'lanSipPort','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'lanSipPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'natSipPort','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'natSipPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'lanSigPort','41414' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'lanSigPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'natSigPort','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'natSigPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'rtpStart','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'rtpStart');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'rtpEnd','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'rtpEnd');
|
||||
INSERT INTO car(\"name\", id, pattern, displayed_name) VALUES ('linx_01', 138, 'linx_01', 'Linx 1'), ('linx_02', 139, 'linx_02', 'Linx 2');
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_man_down boolean DEFAULT false;
|
||||
ALTER TABLE gateways ADD COLUMN active boolean default false;
|
||||
UPDATE gateways SET active = true WHERE \"IP\" IN (SELECT ip FROM reg_gateway);
|
||||
DROP TABLE reg_gateway;
|
||||
ALTER TABLE subscriber_mobile RENAME lone_worker TO has_lone_worker;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_emergency boolean DEFAULT true;
|
||||
UPDATE subscriber_mobile SET lone_worker_interval = 1 WHERE lone_worker_interval = 0;
|
||||
ALTER TABLE subscriber_mobile ALTER COLUMN lone_worker_interval SET DEFAULT 1;
|
||||
ALTER TABLE sms ALTER COLUMN mess TYPE text;
|
||||
ALTER TABLE alarm ALTER COLUMN mess TYPE text;
|
||||
CREATE SEQUENCE radio_mobile_idx_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;
|
||||
CREATE TABLE public.radio_mobile(idx integer NOT NULL DEFAULT nextval('radio_mobile_idx_seq'::regclass), radio_grp_id integer NOT NULL, mobile_grp_id integer NOT NULL);
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'sampleRate','8000' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'sampleRate');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'bufferMilliseconds','32' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'bufferMilliseconds');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'bitDepth','16' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'bitDepth');
|
||||
alter table definesms add column user_id integer NOT NULL DEFAULT 0;
|
||||
CREATE TABLE msg(idx serial, message text NOT NULL, dest_id int NOT NULL, seq_id text, sched_timegmt integer DEFAULT 0, email text NOT NULL, CONSTRAINT msg_pkey PRIMARY KEY (idx));
|
||||
CREATE TABLE msg_details(idx serial, msg_id int NOT NULL, sip_id int, timegmt integer, lat double precision NOT NULL DEFAULT 0, lng double precision NOT NULL DEFAULT 0, speed double precision NOT NULL DEFAULT 0, altitude double precision NOT NULL DEFAULT 0, address character varying(255) NOT NULL DEFAULT 'no address'::character varying, is_sent boolean DEFAULT false, is_read boolean DEFAULT false, is_deleted boolean DEFAULT false, CONSTRAINT msg_det_pkey PRIMARY KEY (idx));
|
||||
ALTER TABLE msg_details ADD CONSTRAINT msg_fk FOREIGN KEY (msg_id) REFERENCES msg (idx) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE;
|
||||
ALTER TABLE msg_details ADD CONSTRAINT sip_manager_msg_det_fk FOREIGN KEY (sip_id) REFERENCES sip_manager (sip_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
ALTER TABLE msg ADD CONSTRAINT sip_manager_msg_fk FOREIGN KEY (dest_id) REFERENCES sip_manager (sip_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
CREATE INDEX msg_sip_id_idx ON msg_details USING btree (sip_id);
|
||||
CREATE INDEX msg_timegmt_idx ON msg_details USING btree (timegmt);
|
||||
ALTER TABLE msg_details ADD COLUMN msg_type integer not null default 0;
|
||||
ALTER TABLE messages ADD COLUMN tallysman_log_id integer;
|
||||
ALTER TABLE registration ADD COLUMN has_recordings boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE \"userSettings\" alter column key type text;
|
||||
CREATE INDEX idx_geozone_1 ON public.geozoneinout USING btree (sc_id, preview);
|
||||
CREATE INDEX idx_emergalarm ON public.emergalarm USING btree (sc_id, preview);
|
||||
CREATE INDEX idx_speedalarm ON public.speedalarm USING btree (sc_id, preview);
|
||||
CREATE INDEX idx_telemetryalarm ON public.telemetry_history USING btree (sc_id, ack, alarm);
|
||||
ALTER TABLE zonename ADD COLUMN \"callout\" BOOLEAN DEFAULT FALSE;
|
||||
ALTER TABLE zonename ADD COLUMN \"callout_severity\" int DEFAULT 3;
|
||||
ALTER TABLE place ADD COLUMN \"callout\" BOOLEAN DEFAULT FALSE;
|
||||
ALTER TABLE place ADD COLUMN \"callout_severity\" int DEFAULT 3;
|
56
UpdateHelper/App.config
Normal file
56
UpdateHelper/App.config
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<appSettings>
|
||||
<add key="pg_path" value="C:\Program Files (x86)\SafeMobile\postgresql\pgsql\bin\" />
|
||||
<add key="cmd_sleep" value="10" />
|
||||
<add key="db_ip" value="10" />
|
||||
<add key="hostname" value="127.0.0.1" />
|
||||
<add key="username" value="postgres" />
|
||||
<add key="dbname" value="safedispatchdb" />
|
||||
<add key="port" value="5432" />
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
<providers>
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
|
||||
<providers>
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
|
||||
</providers>
|
||||
</roleManager>
|
||||
</system.web>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="CommandLine" publicKeyToken="de6f01bd326f8c32" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.9.71.2" newVersion="1.9.71.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
696
UpdateHelper/CreateMissingForeignKeys.sql
Normal file
696
UpdateHelper/CreateMissingForeignKeys.sql
Normal file
@ -0,0 +1,696 @@
|
||||
CREATE OR REPLACE FUNCTION public.CreateMissingForeignKeys()
|
||||
RETURNS void AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
|
||||
|
||||
--===================
|
||||
--VoiceRecordings
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'VoiceRecordings' and constraint_type = 'FOREIGN KEY' and constraint_name = 'voice_recordings_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'VoiceRecordings' and column_name = 'subscriber_id') then
|
||||
|
||||
ALTER TABLE public."VoiceRecordings"
|
||||
ADD CONSTRAINT voice_recordings_subscriber_fk FOREIGN KEY (subscriber_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : voice_recordings_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key voice_recordings_subscriber_fk already exists between tables (VoiceRecordings, subscriber) !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'VoiceRecordings' and constraint_type = 'FOREIGN KEY' and constraint_name = 'voice_recordings_gateway_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'VoiceRecordings' and column_name = 'gw_id') then
|
||||
|
||||
ALTER TABLE public."VoiceRecordings"
|
||||
ADD CONSTRAINT voice_recordings_gateway_fk FOREIGN KEY (gw_id)
|
||||
REFERENCES public.gateways ("ID") MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : voice_recordings_gateway_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key voice_recordings_gateway_fk already exists between tables (VoiceRecordings, gateways) !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'VoiceRecordings' and constraint_type = 'FOREIGN KEY' and constraint_name = 'voice_recordings_groups_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'VoiceRecordings' and column_name = 'group_id') then
|
||||
|
||||
ALTER TABLE public."VoiceRecordings"
|
||||
ADD CONSTRAINT voice_recordings_groups_fk FOREIGN KEY (group_id)
|
||||
REFERENCES public.groups (id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : voice_recordings_groups_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key voice_recordings_groups_fk already exists between tables (VoiceRecordings, groups) !';
|
||||
|
||||
end if;
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'VoiceRecordings' and constraint_type = 'FOREIGN KEY' and constraint_name = 'voice_recordings_dispatchers_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'VoiceRecordings' and column_name = 'dispatcher_id') then
|
||||
|
||||
ALTER TABLE public."VoiceRecordings"
|
||||
ADD CONSTRAINT voice_recordings_dispatchers_fk FOREIGN KEY (dispatcher_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : voice_recordings_dispatchers_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key voice_recordings_dispatchers_fk already exists between tables (VoiceRecordings, users) !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--alarm
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'alarm' and constraint_type = 'FOREIGN KEY' and constraint_name = 'alarm_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'alarm' and column_name = 'sc_id') then
|
||||
|
||||
|
||||
ALTER TABLE public.alarm
|
||||
ADD CONSTRAINT alarm_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : alarm_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key alarm_subscriber_fk exists between tables (alarm, subscriber) !';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--call_patch
|
||||
--===================
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'call_patch' and constraint_type = 'FOREIGN KEY' and constraint_name = 'call_patch_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'call_patch' and column_name = 'userid') then
|
||||
|
||||
ALTER TABLE public.call_patch
|
||||
ADD CONSTRAINT call_patch_user_fk FOREIGN KEY (userid)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : call_patch_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key call_patch_user_fk exists between tables (call_patch, user) !';
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--definesms
|
||||
--===================
|
||||
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'definesms' and constraint_type = 'FOREIGN KEY' and constraint_name = 'definesms_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'definesms' and column_name = 'user_id') then
|
||||
|
||||
if exists (select * from public.definesms where user_id = 0) then
|
||||
UPDATE public.definesms SET user_id = 1
|
||||
WHERE user_id = 0;
|
||||
end if;
|
||||
|
||||
ALTER TABLE public.definesms
|
||||
ADD CONSTRAINT definesms_user_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : definesms_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key definesms_user_fk exists between tables (definesms, user) !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--emergalarm
|
||||
--===================
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'emergalarm' and constraint_type = 'FOREIGN KEY' and constraint_name = 'emergalarm_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'emergalarm' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.emergalarm
|
||||
ADD CONSTRAINT emergalarm_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : emergalarm_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key emergalarm_subscriber_fk exists between tables (emergalarm, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'emergalarm' and constraint_type = 'FOREIGN KEY' and constraint_name = 'emergalarm_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'emergalarm' and column_name = 'user_id') then
|
||||
|
||||
ALTER TABLE public.emergalarm
|
||||
ADD CONSTRAINT emergalarm_user_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : emergalarm_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key emergalarm_user_fk exists between tables (emergalarm, user) !';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--emergdi
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'emergdi' and constraint_type = 'FOREIGN KEY' and constraint_name = 'emergdi_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'emergdi' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.emergdi
|
||||
ADD CONSTRAINT emergdi_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : emergdi_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key emergdi_subscriber_fk exists between tables (emergdi, subscriber) !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--geozoneinout
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'geozoneinout' and constraint_type = 'FOREIGN KEY' and constraint_name = 'geozoneinout_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'geozoneinout' and column_name = 'user_id') then
|
||||
|
||||
ALTER TABLE public.geozoneinout
|
||||
ADD CONSTRAINT geozoneinout_user_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : geozoneinout_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key geozoneinout_user_fk exists between tables (geozoneinout, user) !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'geozoneinout' and constraint_type = 'FOREIGN KEY' and constraint_name = 'geozoneinout_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'geozoneinout' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.geozoneinout
|
||||
ADD CONSTRAINT geozoneinout_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : geozoneinout_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key geozoneinout_subscriber_fk exists between tables (geozoneinout, subscriber) !';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--groups
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'groups' and constraint_type = 'FOREIGN KEY' and constraint_name = 'groups_radio_gw_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'groups' and column_name = 'r_gw_id') then
|
||||
|
||||
ALTER TABLE public.groups
|
||||
ADD CONSTRAINT groups_radio_gw_fk FOREIGN KEY (r_gw_id)
|
||||
REFERENCES public.radio_gw ("ID") MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : groups_radio_gw_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key groups_radio_gw_fk exists between tables (groups, radio_gw)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--jobtickets
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'jobtickets' and constraint_type = 'FOREIGN KEY' and constraint_name = 'jobtickets_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'jobtickets' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.jobtickets
|
||||
ADD CONSTRAINT jobtickets_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : jobtickets_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key jobtickets_subscriber_fk exists between tables (jobtickets, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--jobtickets_log
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'jobtickets_log' and constraint_type = 'FOREIGN KEY' and constraint_name = 'jobtickets_log_jobtickets_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'jobtickets_log' and column_name = 'ticket_id') then
|
||||
|
||||
ALTER TABLE public.jobtickets_log
|
||||
ADD CONSTRAINT jobtickets_log_jobtickets_fk FOREIGN KEY (ticket_id)
|
||||
REFERENCES public.jobtickets (ticket_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : jobtickets_log_jobtickets_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key jobtickets_log_jobtickets_fk exists between tables (jobtickets_log, jobtickets)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'jobtickets_log' and constraint_type = 'FOREIGN KEY' and constraint_name = 'jobtickets_log_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'jobtickets_log' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.jobtickets_log
|
||||
ADD CONSTRAINT jobtickets_log_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : jobtickets_log_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key jobtickets_log_subscriber_fk exists between tables (jobtickets_log, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--messages
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'messages' and constraint_type = 'FOREIGN KEY' and constraint_name = 'messages_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'messages' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.messages
|
||||
ADD CONSTRAINT messages_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : messages_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key messages_subscriber_fk exists between tables (messages, subscriber)!';
|
||||
|
||||
end if;
|
||||
--===================
|
||||
--mobile_contacts
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'mobile_contacts' and constraint_type = 'FOREIGN KEY' and constraint_name = 'mobile_contacts_subscriber_dest_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'mobile_contacts' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.mobile_contacts
|
||||
ADD CONSTRAINT mobile_contacts_subscriber_dest_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : mobile_contacts_subscriber_dest_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key mobile_contacts_subscriber_dest_fk exists between tables (mobile_contacts, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--passenger
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'passenger' and constraint_type = 'FOREIGN KEY' and constraint_name = 'passenger_subscriber_dest_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'passenger' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.passenger
|
||||
ADD CONSTRAINT passenger_subscriber_dest_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : passenger_subscriber_dest_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key passenger_subscriber_dest_fk exists between tables (passenger, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--sms
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'sms' and constraint_type = 'FOREIGN KEY' and constraint_name = 'sms_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'sms' and column_name = 'user_id') then
|
||||
ALTER TABLE public.sms
|
||||
ADD CONSTRAINT sms_user_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : sms_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key sms_user_fk exists between tables (sms, user)!';
|
||||
|
||||
end if;
|
||||
|
||||
--if NOT exists (select * from information_schema.table_constraints where table_name = 'sms' and constraint_type = 'FOREIGN KEY' and constraint_name = 'sms_subscriber_source_fk')
|
||||
-- and exists (select * from information_schema.columns where table_name = 'sms' and column_name = 'sc_id_sour') then
|
||||
--
|
||||
--ALTER TABLE public.sms
|
||||
-- ADD CONSTRAINT sms_subscriber_source_fk FOREIGN KEY (sc_id_sour)
|
||||
-- REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
-- ON DELETE CASCADE;
|
||||
--
|
||||
-- RAISE NOTICE '%', 'Created foreign key : sms_subscriber_source_fk !';
|
||||
--else
|
||||
-- RAISE NOTICE '%', 'Foreign key sms_subscriber_source_fk exists between tables (sms, subscriber)!';
|
||||
--
|
||||
--end if;
|
||||
--
|
||||
--if NOT exists (select * from information_schema.table_constraints where table_name = 'sms' and constraint_type = 'FOREIGN KEY' and constraint_name = 'sms_subscriber_dest_fk')
|
||||
-- and exists (select * from information_schema.columns where table_name = 'sms' and column_name = 'sc_id_dest') then
|
||||
--ALTER TABLE public.sms
|
||||
-- ADD CONSTRAINT sms_subscriber_dest_fk FOREIGN KEY (sc_id_dest)
|
||||
-- REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
-- ON DELETE CASCADE;
|
||||
--
|
||||
-- RAISE NOTICE '%', 'Created foreign key : sms_subscriber_dest_fk !';
|
||||
--else
|
||||
-- RAISE NOTICE '%', 'Foreign key sms_subscriber_dest_fk exists between tables (sms, subscriber)!';
|
||||
--
|
||||
--end if;
|
||||
|
||||
|
||||
|
||||
--===================
|
||||
--soundcards
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'soundcards' and constraint_type = 'FOREIGN KEY' and constraint_name = 'soundcards_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'soundcards' and column_name = 'user_id') then
|
||||
|
||||
ALTER TABLE public.soundcards
|
||||
ADD CONSTRAINT soundcards_user_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : soundcards_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key soundcards_user_fk exists between tables (soundcards, user)!';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--speedalarm
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'speedalarm' and constraint_type = 'FOREIGN KEY' and constraint_name = 'speedalarm_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'speedalarm' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.speedalarm
|
||||
ADD CONSTRAINT speedalarm_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : speedalarm_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key speedalarm_subscriber_fk exists between tables (speedalarm, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'speedalarm' and constraint_type = 'FOREIGN KEY' and constraint_name = 'speedalarm_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'speedalarm' and column_name = 'user_id') then
|
||||
|
||||
ALTER TABLE public.speedalarm
|
||||
ADD CONSTRAINT speedalarm_user_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : speedalarm_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key speedalarm_user_fk exists between tables (speedalarm, user)!';
|
||||
|
||||
end if;
|
||||
|
||||
--===================
|
||||
--subs_gateway
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'subs_gateway' and constraint_type = 'FOREIGN KEY' and constraint_name = 'subs_gateway_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'subs_gateway' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.subs_gateway
|
||||
ADD CONSTRAINT subs_gateway_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : subs_gateway_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key subs_gateway_subscriber_fk exists between tables (subs_gateway, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'subs_gateway' and constraint_type = 'FOREIGN KEY' and constraint_name = 'subs_gateway_radio_gw_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'subs_gateway' and column_name = 'radio_gw_id') then
|
||||
|
||||
ALTER TABLE public.subs_gateway
|
||||
ADD CONSTRAINT subs_gateway_radio_gw_fk FOREIGN KEY (radio_gw_id)
|
||||
REFERENCES public.radio_gw ("ID") MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : subs_gateway_radio_gw_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key subs_gateway_radio_gw_fk exists between tables (subs_gateway, radio_gw)!';
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'subs_gateway' and constraint_type = 'FOREIGN KEY' and constraint_name = 'subs_gateway_gateways_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'subs_gateway' and column_name = 'gateway_id') then
|
||||
|
||||
ALTER TABLE public.subs_gateway
|
||||
ADD CONSTRAINT subs_gateway_gateways_fk FOREIGN KEY (gateway_id)
|
||||
REFERENCES public.gateways ("ID") MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : subs_gateway_gateways_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key subs_gateway_gateways_fk exists between tables (subs_gateway, gateways)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--===================
|
||||
--subscriber_history
|
||||
--===================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'subscriber_history' and constraint_type = 'FOREIGN KEY' and constraint_name = 'subscriber_history_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'subscriber_history' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.subscriber_history
|
||||
ADD CONSTRAINT subscriber_history_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : subscriber_history_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key subscriber_history_subscriber_fk exists between tables (subscriber_history, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'subscriber_history' and constraint_type = 'FOREIGN KEY' and constraint_name = 'subscriber_history_vehicle_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'subscriber_history' and column_name = 'veh_id') then
|
||||
|
||||
ALTER TABLE public.subscriber_history
|
||||
ADD CONSTRAINT subscriber_history_vehicle_fk FOREIGN KEY (veh_id)
|
||||
REFERENCES public.vehicle (id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : subscriber_history_vehicle_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key subscriber_history_vehicle_fk exists between tables (subscriber_history, vehicle)!';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
--telemetry_pos
|
||||
--================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'telemetry_pos' and constraint_type = 'FOREIGN KEY' and constraint_name = 'telemetry_pos_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'telemetry_pos' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.telemetry_pos
|
||||
ADD CONSTRAINT telemetry_pos_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : telemetry_pos_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key telemetry_pos_subscriber_fk exists between tables (telemetry_pos, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- users_radio
|
||||
--================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'user_radio' and constraint_type = 'FOREIGN KEY' and constraint_name = 'user_radio_users_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'user_radio' and column_name = 'user_id') then
|
||||
|
||||
ALTER TABLE public.user_radio
|
||||
ADD CONSTRAINT user_radio_users_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : users_radio_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key users_radio_user_fk exists between tables (user_radio, users)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'user_radio' and constraint_type = 'FOREIGN KEY' and constraint_name = 'user_radio_radio_gw_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'user_radio' and column_name = 'radio_id') then
|
||||
|
||||
ALTER TABLE public.user_radio
|
||||
ADD CONSTRAINT user_radio_radio_gw_fk FOREIGN KEY (radio_id)
|
||||
REFERENCES public.radio_gw ("ID") MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : user_radio_radio_gw_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key user_radio_radio_gw_fk exists between tables (user_radio, radio_gw)!';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- users_group
|
||||
--================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'users_group' and constraint_type = 'FOREIGN KEY' and constraint_name = 'users_group_user_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'users_group' and column_name = 'userid') then
|
||||
|
||||
ALTER TABLE public.users_group
|
||||
ADD CONSTRAINT users_group_user_fk FOREIGN KEY (userid)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : users_group_user_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key users_group_user_fk exists between tables (users_group, users)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'users_group' and constraint_type = 'FOREIGN KEY' and constraint_name = 'users_group_groups_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'users_group' and column_name = 'grp_id') then
|
||||
|
||||
ALTER TABLE public.users_group
|
||||
ADD CONSTRAINT users_group_groups_fk FOREIGN KEY (grp_id)
|
||||
REFERENCES public.groups (id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : users_group_groups_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key users_group_groups_fk exists between tables (users_group, groups)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- vehicle_group
|
||||
--================
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'vehicle_group' and constraint_type = 'FOREIGN KEY' and constraint_name = 'vehicle_group_subscriber_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'vehicle_group' and column_name = 'sc_id') then
|
||||
|
||||
ALTER TABLE public.vehicle_group
|
||||
ADD CONSTRAINT vehicle_group_subscriber_fk FOREIGN KEY (sc_id)
|
||||
REFERENCES public.subscriber (sc_id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : vehicle_group_subscriber_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key vehicle_group_subscriber_fk exists between tables (vehicle_group, subscriber)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'vehicle_group' and constraint_type = 'FOREIGN KEY' and constraint_name = 'vehicle_group_groups_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'vehicle_group' and column_name = 'grp_ip') then
|
||||
|
||||
ALTER TABLE public.vehicle_group
|
||||
ADD CONSTRAINT vehicle_group_groups_fk FOREIGN KEY (grp_ip)
|
||||
REFERENCES public.groups (id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : vehicle_group_groups_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key vehicle_group_groups_fk exists between tables (vehicle_group, groups)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- vehicle_user
|
||||
--================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'vehicle_user' and constraint_type = 'FOREIGN KEY' and constraint_name = 'vehicle_user_users_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'vehicle_user' and column_name = 'user_id') then
|
||||
|
||||
ALTER TABLE public.vehicle_user
|
||||
ADD CONSTRAINT vehicle_user_users_fk FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (userid) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : vehicle_user_users_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key vehicle_user_users_fk exists between tables (vehicle_group, users)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'vehicle_user' and constraint_type = 'FOREIGN KEY' and constraint_name = 'vehicle_user_vehicule_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'vehicle_user' and column_name = 'veh_id') then
|
||||
|
||||
ALTER TABLE public.vehicle_user
|
||||
ADD CONSTRAINT vehicle_user_vehicule_fk FOREIGN KEY (veh_id)
|
||||
REFERENCES public.vehicle (id) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : vehicle_user_vehicule_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key vehicle_user_vehicule_fk exists between tables (vehicle_group, vehicle)!';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- zonepoints
|
||||
--================
|
||||
|
||||
if NOT exists (select * from information_schema.table_constraints where table_name = 'zonepoints' and constraint_type = 'FOREIGN KEY' and constraint_name = 'zonepoints_zone_fk')
|
||||
and exists (select * from information_schema.columns where table_name = 'zonepoints' and column_name = 'zone_id') then
|
||||
|
||||
ALTER TABLE public.zonepoints
|
||||
ADD CONSTRAINT zonepoints_zone_fk FOREIGN KEY (zone_id)
|
||||
REFERENCES public.zonename (idx) MATCH SIMPLE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
RAISE NOTICE '%', 'Created foreign key : zonepoints_zone_fk !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Foreign key zonepoints_zone_fk exists between tables (zonepoints, zonename)!';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
END;
|
||||
$BODY$
|
||||
LANGUAGE plpgsql VOLATILE
|
333
UpdateHelper/CreateMissingIndexes.sql
Normal file
333
UpdateHelper/CreateMissingIndexes.sql
Normal file
@ -0,0 +1,333 @@
|
||||
CREATE OR REPLACE FUNCTION public.CreateMissingIndexes()
|
||||
RETURNS void AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
|
||||
|
||||
--================
|
||||
-- VoiceRecordings
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'VoiceRecordings' and schemaname = 'public' and indexname = 'voicerecordings_time_start_idx' ) then
|
||||
CREATE INDEX voicerecordings_time_start_idx ON public."VoiceRecordings" USING btree (time_start);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''voicerecordings_time_start_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''voicerecordings_time_start_idx'' already exists for table_name = ''VoiceRecordings'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
--================
|
||||
-- car
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'car' and schemaname = 'public' and indexname = 'car_name_idx' ) then
|
||||
CREATE INDEX car_name_idx ON public.car USING btree (name);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''car_name_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''car_name_idx'' already exists for table_name = ''car'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- geozoneinout
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'geozoneinout' and schemaname = 'public' and indexname = 'geozoneinout_sc_id_timegmt_idx' ) then
|
||||
CREATE INDEX geozoneinout_sc_id_timegmt_idx ON public.geozoneinout USING btree (sc_id, timegmt);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''geozoneinout_sc_id_timegmt_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''geozoneinout_sc_id_timegmt_idx'' already exists for table_name = ''geozoneinout'' !';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- groups
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'groups' and schemaname = 'public' and indexname = 'groups_name_idx' ) then
|
||||
CREATE INDEX groups_name_idx ON public.groups USING btree (name);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''groups_name_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''groups_name_idx'' already exists for table_name = ''groups'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- passenger
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'passenger' and schemaname = 'public' and indexname = 'passenger_name_idx' ) then
|
||||
CREATE INDEX passenger_name_idx ON public.passenger USING btree (name);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''passenger_name_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''passenger_name_idx'' already exists for table_name = ''passenger'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- placetype
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'placetype' and schemaname = 'public' and indexname = 'placetype_type_name_idx' ) then
|
||||
CREATE INDEX placetype_type_name_idx ON public.placetype USING btree (type_name);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''placetype_type_name_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''placetype_type_name_idx'' already exists for table_name = ''placetype'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- radio_gw
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'radio_gw' and schemaname = 'public' and indexname = 'radio_gw_name_idx' ) then
|
||||
CREATE INDEX radio_gw_name_idx ON public.radio_gw USING btree (name);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''radio_gw_name_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''radio_gw_name_idx'' already exists for table_name = ''radio_gw'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'radio_gw' and schemaname = 'public' and indexname = 'radio_gw_type_idx' ) then
|
||||
CREATE INDEX radio_gw_type_idx ON public.radio_gw USING btree (gw_type);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''radio_gw_type_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''radio_gw_type_idx'' already exists for table_name = ''radio_gw'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- sms
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'sms' and schemaname = 'public' and indexname = 'sms_timegmt_idx' ) then
|
||||
CREATE INDEX sms_timegmt_idx ON public.sms USING btree (timegmt);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''sms_timegmt_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''sms_timegmt_idx'' already exists for table_name = ''sms'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
--================
|
||||
-- subscriber
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'subscriber' and schemaname = 'public' and indexname = 'subscriber_imei_idx' ) then
|
||||
CREATE INDEX subscriber_imei_idx ON public.subscriber USING btree (imei);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''subscriber_imei_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''subscriber_imei_idx'' already exists for table_name = ''subscriber'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- subscriber_alarm
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'subscriber_alarm' and schemaname = 'public' and indexname = 'subscriber_alarm_sc_id_idx' ) then
|
||||
CREATE INDEX subscriber_alarm_sc_id_idx ON public.subscriber_alarm USING btree (sc_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''subscriber_alarm_sc_id_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''subscriber_alarm_sc_id_idx'' already exists for table_name = ''subscriber_alarm'' !';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- subscriber_stun
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'subscriber_stun' and schemaname = 'public' and indexname = 'subscriber_stun_sc_id_idx' ) then
|
||||
CREATE INDEX subscriber_stun_sc_id_idx ON public.subscriber_stun USING btree (sc_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''subscriber_stun_sc_id_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''subscriber_stun_sc_id_idx'' already exists for table_name = ''subscriber_stun'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- telemetry
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'telemetry' and schemaname = 'public' and indexname = 'telemetry_alarm_idx' ) then
|
||||
CREATE INDEX telemetry_alarm_idx ON public.telemetry USING btree (alarm);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''telemetry_alarm_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''telemetry_alarm_idx'' already exists for table_name = ''telemetry'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'telemetry' and schemaname = 'public' and indexname = 'telemetry_name_idx' ) then
|
||||
CREATE INDEX telemetry_name_idx ON public.telemetry USING btree (name);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''telemetry_name_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''telemetry_name_idx'' already exists for table_name = ''telemetry'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'telemetry' and schemaname = 'public' and indexname = 'telemetry_sc_id_idx' ) then
|
||||
CREATE INDEX telemetry_sc_id_idx ON public.telemetry USING btree (sc_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''telemetry_sc_id_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''telemetry_sc_id_idx'' already exists for table_name = ''telemetry'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'telemetry' and schemaname = 'public' and indexname = 'telemetry_sc_id__digital_nr_idx' ) then
|
||||
CREATE INDEX telemetry_sc_id__digital_nr_idx ON public.telemetry USING btree (sc_id, digital_nr);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''telemetry_sc_id__digital_nr_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''telemetry_sc_id__digital_nr_idx'' already exists for table_name = ''telemetry'' !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--====================
|
||||
-- telemetry history
|
||||
--====================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'telemetry_history' and schemaname = 'public' and indexname = 'telemetry_history_sc_id_idx' ) then
|
||||
CREATE INDEX telemetry_history_sc_id_idx ON public.telemetry_history USING btree (sc_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''telemetry_history_sc_id_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''telemetry_history_sc_id_idx'' already exists for table_name = ''telemetry_history'' !';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- user_radio
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'user_radio' and schemaname = 'public' and indexname = 'user_radio_userid_idx' ) then
|
||||
CREATE INDEX user_radio_userid_idx ON public.user_radio USING btree (user_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''user_radio_userid_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''user_radio_userid_idx'' already exists for table_name = ''user_radio'' !';
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'user_radio' and schemaname = 'public' and indexname = 'user_radio_radioid_idx' ) then
|
||||
CREATE INDEX user_radio_radioid_idx ON public.user_radio USING btree (radio_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''user_radio_radioid_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''user_radio_radioid_idx'' already exists for table_name = ''user_radio'' !';
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
--================
|
||||
-- users
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'users' and schemaname = 'public' and indexname = 'user_login_idx' ) then
|
||||
CREATE INDEX user_login_idx ON public.users USING btree (login);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''user_login_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''user_login_idx'' already exists for table_name = ''users'' !';
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'users' and schemaname = 'public' and indexname = 'user_usertype_idx' ) then
|
||||
CREATE INDEX user_usertype_idx ON public.users USING btree (user_type);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''user_usertype_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''user_usertype_idx'' already exists for table_name = ''users'' !';
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- userSettings
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'userSettings' and schemaname = 'public' and indexname = 'usersettings_userid_idx' ) then
|
||||
CREATE INDEX usersettings_userid_idx ON public."userSettings" USING btree (user_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''usersettings_userid_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''usersettings_userid_idx'' already exists for table_name = ''userSettings'' !';
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'userSettings' and schemaname = 'public' and indexname = 'usersettings_key_idx' ) then
|
||||
CREATE INDEX usersettings_key_idx ON public."userSettings" USING btree (key);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''usersettings_key_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''usersettings_key_idx'' already exists for table_name = ''userSettings'' !';
|
||||
end if;
|
||||
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'userSettings' and schemaname = 'public' and indexname = 'usersettings_userid_key_idx' ) then
|
||||
CREATE INDEX usersettings_userid_key_idx ON public."userSettings" USING btree (user_id, key);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''usersettings_userid_key_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''usersettings_userid_key_idx'' already exists for table_name = ''userSettings'' !';
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- vehicle_group
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'vehicle_group' and schemaname = 'public' and indexname = 'vehicle_group_sc_id_grp_ip_idx' ) then
|
||||
CREATE INDEX vehicle_group_sc_id_grp_ip_idx ON public.vehicle_group USING btree (sc_id, grp_ip);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''vehicle_group_sc_id_grp_ip_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''vehicle_group_sc_id_grp_ip_idx'' already exists for table_name = ''vehicle_group'' !';
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- zonepoints
|
||||
--================
|
||||
|
||||
if not exists ( SELECT * FROM pg_indexes WHERE tablename = 'zonepoints' and schemaname = 'public' and indexname = 'zonepoints_zoneid_idx' ) then
|
||||
CREATE INDEX zonepoints_zoneid_idx ON public.zonepoints USING btree (zone_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created index : ''zonepoints_zoneid_idx'' !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Index ''zonepoints_zoneid_idx'' already exists for table_name = ''zonepoints'' !';
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
END;
|
||||
$BODY$
|
||||
LANGUAGE plpgsql VOLATILE
|
275
UpdateHelper/CreateMissingPrimaryKeys.sql
Normal file
275
UpdateHelper/CreateMissingPrimaryKeys.sql
Normal file
@ -0,0 +1,275 @@
|
||||
CREATE OR REPLACE FUNCTION CreateMissingPrimaryKeys()
|
||||
RETURNS void
|
||||
LANGUAGE 'plpgsql'
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
|
||||
--============
|
||||
--call_patch
|
||||
--============
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'call_patch' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.call_patch
|
||||
ADD CONSTRAINT call_patch_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : call_patch_pkey!';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = call_patch!';
|
||||
end if;
|
||||
|
||||
--============
|
||||
--emailservice ( duplicate row )
|
||||
--============
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'emailservice' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.emailservice
|
||||
ADD CONSTRAINT emailservice_pkey PRIMARY KEY(id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : emailservice_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = emailservice !';
|
||||
end if;
|
||||
|
||||
--============
|
||||
--emergdi
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'emergdi' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.emergdi
|
||||
ADD CONSTRAINT emergdi_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : emergdi_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = emergdi !';
|
||||
end if;
|
||||
|
||||
--========
|
||||
--groups
|
||||
--========
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'groups' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.groups
|
||||
ADD CONSTRAINT groups_pkey PRIMARY KEY(id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : groups_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = groups !';
|
||||
|
||||
end if;
|
||||
|
||||
--============
|
||||
-- icon_theme
|
||||
--============
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'icon_theme' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.icon_theme
|
||||
ADD CONSTRAINT icon_theme_pkey PRIMARY KEY(id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : icon_theme_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = icon_theme !';
|
||||
end if;
|
||||
|
||||
--============
|
||||
-- jobtickets
|
||||
--============
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'jobtickets' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.jobtickets
|
||||
ADD CONSTRAINT jobtickets_pkey PRIMARY KEY(ticket_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : jobtickets_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = jobtickets !';
|
||||
end if;
|
||||
|
||||
|
||||
--================
|
||||
-- jobtickets_log
|
||||
--================
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'jobtickets_log' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.jobtickets_log
|
||||
ADD CONSTRAINT jobtickets_log_pkey PRIMARY KEY(id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : jobtickets_log_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = jobtickets_log !';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- mobile_contacts
|
||||
--================
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'mobile_contacts' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.mobile_contacts
|
||||
ADD CONSTRAINT mobile_contacts_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : mobile_contacts_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = mobile_contacts !';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- placetype
|
||||
--================
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'placetype' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.placetype
|
||||
ADD CONSTRAINT placetype_pkey PRIMARY KEY(type_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : placetype_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = placetype !';
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- radio_mobile
|
||||
--================
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'radio_mobile' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.radio_mobile
|
||||
ADD CONSTRAINT radio_mobile_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : radio_mobile_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = radio_mobile !';
|
||||
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- reports
|
||||
--================
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'reports' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.reports
|
||||
ADD CONSTRAINT reports_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : reports_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = reports !';
|
||||
|
||||
end if;
|
||||
|
||||
--================
|
||||
-- sd_list
|
||||
--================
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'sd_list' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.sd_list
|
||||
ADD CONSTRAINT sd_list_pkey PRIMARY KEY(sd_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : sd_list_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = sd_list !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
--============
|
||||
-- users_group
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'users_group' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.users_group
|
||||
ADD CONSTRAINT users_group_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : users_group_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = users_group !';
|
||||
|
||||
|
||||
end if;
|
||||
|
||||
--============
|
||||
-- user_radio
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'user_radio' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.user_radio
|
||||
ADD CONSTRAINT user_radio_pkey PRIMARY KEY(radio_id, user_id);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : user_radio_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = user_radio !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--============
|
||||
-- vehicle_group
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'vehicle_group' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.vehicle_group
|
||||
ADD CONSTRAINT vehicle_group_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : vehicle_group_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = vehicle_group !';
|
||||
|
||||
|
||||
end if;
|
||||
|
||||
--============
|
||||
-- vehicle_user
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'vehicle_user' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.vehicle_user
|
||||
ADD CONSTRAINT vehicle_user_pkey PRIMARY KEY(veh_id, user_id);
|
||||
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : vehicle_user_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = vehicle_user !';
|
||||
end if;
|
||||
|
||||
--============
|
||||
-- zonenames
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'zonename' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.zonename
|
||||
ADD CONSTRAINT zonename_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : zonename_pkey !';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = zonename !';
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--============
|
||||
-- zonepoints
|
||||
--============
|
||||
|
||||
if NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'zonepoints' and constraint_type = 'PRIMARY KEY') then
|
||||
|
||||
ALTER TABLE public.zonepoints
|
||||
ADD CONSTRAINT zonepoints_pkey PRIMARY KEY(idx);
|
||||
|
||||
RAISE NOTICE '%', 'Created primary key : zonepoints_pkey!';
|
||||
else
|
||||
RAISE NOTICE '%', 'Primary key already exists for table_name = zonepoints !';
|
||||
|
||||
end if;
|
||||
|
||||
END;
|
||||
$$;
|
121
UpdateHelper/NewFields.sql
Normal file
121
UpdateHelper/NewFields.sql
Normal file
@ -0,0 +1,121 @@
|
||||
CREATE OR REPLACE FUNCTION public.AddNewFields()
|
||||
RETURNS void
|
||||
LANGUAGE 'plpgsql'
|
||||
AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'radio_gw' AND column_name = 'deleted') THEN
|
||||
ALTER TABLE public.radio_gw ADD COLUMN deleted boolean NOT NULL DEFAULT false;
|
||||
|
||||
RAISE NOTICE '%', 'ADD COLUMN : deleted in table radio_gw !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'COLUMN deleted already exists in table radio_gw !';
|
||||
|
||||
END IF;
|
||||
|
||||
|
||||
|
||||
IF EXISTS ( SELECT * FROM pg_constraint WHERE conname = 'uniqueKey_radio_gw' ) THEN
|
||||
ALTER TABLE public.radio_gw DROP CONSTRAINT "uniqueKey_radio_gw";
|
||||
|
||||
RAISE NOTICE '%', 'DROP CONSTRAINT uniqueKey_radio_gw in table radio_gw !';
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS ( SELECT * FROM pg_indexes WHERE tablename = 'radio_gw' and schemaname = 'public' and indexname = 'uniqueKey_radio_gw' ) THEN
|
||||
CREATE UNIQUE INDEX "uniqueKey_radio_gw" ON radio_gw ("IP", "GW_ID", deleted) WHERE deleted = false;
|
||||
|
||||
RAISE NOTICE '%', 'CREATE UNIQUE INDEX uniqueKey_radio_gw in table radio_gw !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'UNIQUE INDEX uniqueKey_radio_gw already exists in table radio_gw !';
|
||||
|
||||
END IF;
|
||||
|
||||
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'gateways' AND column_name='deleted') THEN
|
||||
ALTER TABLE public.gateways ADD COLUMN deleted boolean NOT NULL DEFAULT false;
|
||||
|
||||
RAISE NOTICE '%', 'ADD COLUMN : deleted in table gateways !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'COLUMN deleted already exists in table gateways !';
|
||||
END IF;
|
||||
|
||||
|
||||
IF EXISTS ( SELECT * FROM pg_constraint WHERE conname = 'uniqueKey_gateways' ) THEN
|
||||
ALTER TABLE public.gateways DROP CONSTRAINT "uniqueKey_gateways";
|
||||
|
||||
RAISE NOTICE '%', 'DROP CONSTRAINT uniqueKey_gateways in table gateways !';
|
||||
END IF ;
|
||||
|
||||
IF NOT EXISTS ( SELECT * FROM pg_indexes WHERE tablename = 'gateways' and schemaname = 'public' and indexname = 'uniqueKey_gateways' ) THEN
|
||||
CREATE UNIQUE INDEX "uniqueKey_gateways" ON gateways ("IP", deleted) WHERE deleted = false ;
|
||||
|
||||
RAISE NOTICE '%', 'CREATE UNIQUE INDEX uniqueKey_gateways in table gateways !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'UNIQUE INDEX uniqueKey_gateways already exists in table gateways !';
|
||||
|
||||
END IF;
|
||||
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'subs_gateway' AND column_name = 'id') THEN
|
||||
CREATE SEQUENCE IF NOT EXISTS subs_gateway_seq;
|
||||
|
||||
ALTER TABLE public.subs_gateway ADD COLUMN id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('subs_gateway_seq'::regclass) ;
|
||||
|
||||
RAISE NOTICE '%', 'ADD COLUMN : id in table subs_gateway and set it as primary key!';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'COLUMN id already exists in table subs_gateway !';
|
||||
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'subs_gateway' AND column_name = 'gateway_id' AND is_nullable = 'NO') THEN
|
||||
ALTER TABLE public.subs_gateway ALTER COLUMN gateway_id DROP NOT NULL;
|
||||
|
||||
RAISE NOTICE '%', 'DROP NOT NULL attribute FOR COLUMN : gateway_id in the table subs_gateway !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'The attribute NULL already exists for the column : gateway_id in the table subs_gateway !';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'subs_gateway' AND column_name = 'radio_gw_id' AND is_nullable = 'NO') THEN
|
||||
ALTER TABLE public.subs_gateway ALTER COLUMN radio_gw_id DROP NOT NULL;
|
||||
|
||||
RAISE NOTICE '%', 'DROP NOT NULL attribute FOR COLUMN : radio_gw_id in the table subs_gateway !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'The attribute NULL already exists for the column : radio_gw_id in the table subs_gateway !';
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'VoiceRecordings' AND column_name = 'dispatcher_id') THEN
|
||||
ALTER TABLE public."VoiceRecordings" ADD COLUMN dispatcher_id integer NULL;
|
||||
|
||||
RAISE NOTICE '%', 'ADD COLUMN : dispatcher_id in table VoiceRecordings !';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'VoiceRecordings' AND column_name = 'subscriber_id' AND is_nullable = 'NO') THEN
|
||||
ALTER TABLE public."VoiceRecordings" ALTER COLUMN subscriber_id DROP NOT NULL;
|
||||
|
||||
RAISE NOTICE '%', 'DROP NOT NULL attribute FOR COLUMN : subscriber_id in the table VoiceRecordings !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'The attribute NULL already exists for the column : subscriber_id in the table VoiceRecordings !';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'VoiceRecordings' AND column_name = 'group_id' AND is_nullable = 'NO') THEN
|
||||
ALTER TABLE public."VoiceRecordings" ALTER COLUMN group_id DROP NOT NULL;
|
||||
|
||||
RAISE NOTICE '%', 'DROP NOT NULL attribute FOR COLUMN : group_id in the table VoiceRecordings !';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'The attribute NULL already exists for the column : group_id in the table VoiceRecordings !';
|
||||
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_name = 'vehicle' AND column_name = 'is_deleted' AND is_nullable = 'NO') THEN
|
||||
ALTER TABLE vehicle ADD COLUMN is_deleted BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
RAISE NOTICE '%', 'ADD COLUMN : is_deleted in table vehicle and set it to FALSE!';
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'COLUMN is_deleted already exists in table vehicle !';
|
||||
|
||||
END IF;
|
||||
|
||||
END;
|
||||
$BODY$;
|
218
UpdateHelper/Program.cs
Normal file
218
UpdateHelper/Program.cs
Normal file
@ -0,0 +1,218 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UpdateHelper
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#region filename argument
|
||||
var sql_path = "";
|
||||
|
||||
try
|
||||
{
|
||||
switch(args[0])
|
||||
{
|
||||
case "-f":
|
||||
case "-w":
|
||||
sql_path = AppDomain.CurrentDomain.BaseDirectory + args[1];
|
||||
break;
|
||||
case "-h":
|
||||
case "--help":
|
||||
WriteLine("-w <SQL Func filename>", ConsoleColor.Yellow); // run whole file
|
||||
WriteLine("-f <SQL Query filename>", ConsoleColor.Yellow); // run line by line
|
||||
WriteLine("-h help", ConsoleColor.Yellow);
|
||||
WriteLine("--help help", ConsoleColor.Yellow);
|
||||
WriteLine("NOTE: If you wish to set the pgsql password, please execute: SET PGPASSWORD=<PGPASSWORD STRING>", ConsoleColor.Cyan);
|
||||
Console.WriteLine("\nPress any key to exit...");
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
WriteLine("Invalid argument exception", ConsoleColor.Red);
|
||||
Console.WriteLine("\nPress any key to exit...");
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region readfile & config
|
||||
string pg_path = ConfigurationManager.AppSettings["pg_path"];
|
||||
if (!pg_path.EndsWith("\\"))
|
||||
pg_path += "\\";
|
||||
|
||||
string hostname = ConfigurationManager.AppSettings["hostname"];
|
||||
string username = ConfigurationManager.AppSettings["username"];
|
||||
string dbname = ConfigurationManager.AppSettings["dbname"];
|
||||
string port = ConfigurationManager.AppSettings["port"];
|
||||
string PGPASSWORD = ConfigurationManager.AppSettings["PGPASSWORD"];
|
||||
int cntOK = 0, cntKO = 0, cntWarning = 0, total = 0, cmd_sleep = 100;
|
||||
int.TryParse(ConfigurationManager.AppSettings["cmd_sleep"], out cmd_sleep);
|
||||
if(!File.Exists(sql_path))
|
||||
{
|
||||
WriteLine("Invalid sql_path", ConsoleColor.Red);
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
if (!File.Exists(pg_path + "psql.exe"))
|
||||
{
|
||||
WriteLine("Invalid pg_path", ConsoleColor.Red);
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
string arguments = string.Empty;
|
||||
|
||||
if (args[0] == "-w")
|
||||
{
|
||||
arguments = string.Format("-h {0} -U {1} -d {2} -p {3} -w -f \"{4}\" ", hostname, username, dbname, port, sql_path);
|
||||
RunFile(pg_path, arguments);
|
||||
|
||||
Console.WriteLine(pg_path + "psql.exe " + arguments);
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0] == "-f")
|
||||
{
|
||||
var reader = File.ReadLines(sql_path);
|
||||
StringBuilder fileOK = new StringBuilder();
|
||||
StringBuilder fileKO = new StringBuilder();
|
||||
StringBuilder fileWarning = new StringBuilder();
|
||||
StreamWriter swOK = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Succes.txt", false);
|
||||
StreamWriter swKO = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Failed.txt", false);
|
||||
StreamWriter swWarning = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Warning.txt", false);
|
||||
|
||||
|
||||
Process p = new Process();
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
arguments = string.Empty;
|
||||
|
||||
#region execute commands
|
||||
foreach (string line in reader)
|
||||
{
|
||||
if (!line.StartsWith("--"))
|
||||
{
|
||||
total++;
|
||||
|
||||
arguments = string.Format("-h {0} -U {1} -d {2} -p {3} -c \"{4}\" -w", hostname, username, dbname, port, line);
|
||||
p.StartInfo = RunQuery(startInfo, pg_path, arguments);
|
||||
|
||||
p.Start();
|
||||
|
||||
// add statistics
|
||||
string output = p.StandardOutput.ReadToEnd();
|
||||
string error = p.StandardError.ReadToEnd();
|
||||
if (output == "")
|
||||
{
|
||||
if (error.Contains("already"))
|
||||
{
|
||||
WriteLine(line, ConsoleColor.Yellow);
|
||||
WriteLine(error.Trim(), ConsoleColor.White);
|
||||
fileWarning.AppendLine(line);
|
||||
cntWarning++;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(line, ConsoleColor.Red);
|
||||
WriteLine(error, ConsoleColor.White);
|
||||
fileKO.AppendLine(line);
|
||||
cntKO++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(line, ConsoleColor.Green);
|
||||
fileOK.AppendLine(line);
|
||||
cntOK++;
|
||||
}
|
||||
Thread.Sleep(cmd_sleep);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region statistics
|
||||
WriteLine("-------------------------", ConsoleColor.Cyan);
|
||||
WriteLine("| Finish |", ConsoleColor.Cyan);
|
||||
WriteLine("-------------------------", ConsoleColor.Cyan);
|
||||
WriteLine(string.Format("| Total | {0,10}|", total), ConsoleColor.Cyan);
|
||||
WriteLine(string.Format("| Succes | {0,10}|", cntOK), ConsoleColor.Cyan);
|
||||
WriteLine(string.Format("| Warning | {0,10}|", cntWarning), ConsoleColor.Cyan);
|
||||
WriteLine(string.Format("| Failed | {0,10}|", cntKO), ConsoleColor.Cyan);
|
||||
WriteLine("-------------------------", ConsoleColor.Cyan);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region write streams
|
||||
swOK.Write(fileOK.ToString());
|
||||
swOK.Close();
|
||||
swKO.Write(fileKO.ToString());
|
||||
swKO.Close();
|
||||
swWarning.Write(fileWarning.ToString());
|
||||
swWarning.Close();
|
||||
#endregion
|
||||
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void RunFile(string path, string arguments)
|
||||
{
|
||||
Process p = new Process();
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
|
||||
p.StartInfo = RunQuery(startInfo, path, arguments);
|
||||
|
||||
p.Start();
|
||||
|
||||
string output = p.StandardOutput.ReadToEnd();
|
||||
string error = p.StandardError.ReadToEnd();
|
||||
|
||||
Console.WriteLine(output);
|
||||
Console.WriteLine(error);
|
||||
|
||||
}
|
||||
|
||||
static ProcessStartInfo RunQuery(ProcessStartInfo startInfo, string path, string arguments)
|
||||
{
|
||||
|
||||
startInfo.FileName = path + "psql.exe";
|
||||
startInfo.Arguments = arguments;
|
||||
startInfo.Verb = "runas";
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.RedirectStandardError = true;
|
||||
|
||||
return startInfo;
|
||||
}
|
||||
|
||||
|
||||
static void WriteLine(string str, ConsoleColor color)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.Write(String.Format("[### {0:H:mm:ss} ###] ", DateTime.Now));
|
||||
Console.ForegroundColor = color;
|
||||
Console.Write(String.Format("{0}\n", str));
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
}
|
||||
}
|
36
UpdateHelper/Properties/AssemblyInfo.cs
Normal file
36
UpdateHelper/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UpdateHelper")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UpdateHelper")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5e9a06be-0b35-444f-8f1d-714e6f12d8ee")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("8.2.0.10898")]
|
||||
[assembly: AssemblyFileVersion("8.2.0.10898")]
|
278
UpdateHelper/RemoveRecordsWithoutRelatedData.sql
Normal file
278
UpdateHelper/RemoveRecordsWithoutRelatedData.sql
Normal file
@ -0,0 +1,278 @@
|
||||
|
||||
-- in order to add foreign keys is mandatory to have right values for related data.
|
||||
-- so we should remove the records without related data
|
||||
|
||||
CREATE OR REPLACE FUNCTION RemoveRecordsWithoutRelatedData()
|
||||
RETURNS void
|
||||
LANGUAGE 'plpgsql'
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
|
||||
|
||||
|
||||
if ( (select count(*) from emailservice where id = 2) > 1 ) then
|
||||
delete from public.emailservice where id = 2;
|
||||
|
||||
INSERT INTO public.emailservice(
|
||||
id, "user", pass, enable, pop_server, pop_port, smtp_server, smtp_port, is_pop_ssl, is_smtp_ssl, last_email_time)
|
||||
VALUES (2, 'poll', 'poll', 0, 'pop.gmail.com', 995, 'smtp.gmail.com', 587, true, true, 0);
|
||||
|
||||
end if;
|
||||
|
||||
|
||||
--=============================================
|
||||
-- insert a dummy user if it doesn't exist
|
||||
--=============================================
|
||||
if not exists ( select * from public.users where userid = 0) then
|
||||
INSERT INTO users(userid, firstname, lastname, login, password, user_type, ison,backup_user_id) VALUES (0, 'anything', 'anything', 'anything', 'anything', 100, 0, -1 );
|
||||
end if;
|
||||
|
||||
--=============================================
|
||||
-- insert a dummy suscriber if it doesn't exist
|
||||
--=============================================
|
||||
if not exists ( select * from subscriber where sc_id = 0 ) then
|
||||
insert into subscriber (sc_id, imei) values ( 0, '0');
|
||||
end if;
|
||||
|
||||
--==========================================================
|
||||
-- replace the invalid user ids to the id of the dummy user
|
||||
--==========================================================
|
||||
if exists ( select * from public.sms where user_id < 0) then
|
||||
update sms set user_id = 0 where user_id = -1;
|
||||
end if;
|
||||
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the emergalarm records
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
delete from public.emergalarm
|
||||
where sc_id in ( select distinct sc_id from public.emergalarm
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
)
|
||||
or user_id in ( select distinct user_id from public.emergalarm
|
||||
except
|
||||
select userid from public.users
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the groups
|
||||
-- whose radio_gw doesn't exists any more
|
||||
--========================================
|
||||
|
||||
delete from public.groups
|
||||
where r_gw_id in ( select distinct r_gw_id from public.groups
|
||||
except
|
||||
select "ID" from public.radio_gw
|
||||
);
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the passenger
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
|
||||
delete from public.passenger
|
||||
where sc_id in ( select distinct sc_id from public.passenger
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the subs_gateway
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
|
||||
delete from public.subs_gateway
|
||||
where gateway_id in ( select distinct gateway_id from public.subs_gateway
|
||||
except
|
||||
select "ID" from public.gateways
|
||||
)
|
||||
or radio_gw_id in ( select distinct radio_gw_id from public.subs_gateway
|
||||
except
|
||||
select "ID" from public.radio_gw
|
||||
)
|
||||
or sc_id in ( select distinct sc_id from public.subs_gateway
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
--========================================
|
||||
-- remove the speedalarm records
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
delete from public.speedalarm
|
||||
where sc_id in ( select distinct sc_id from public.speedalarm
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
)
|
||||
or user_id in ( select distinct user_id from public.speedalarm
|
||||
except
|
||||
select userid from public.users
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the soundcard records
|
||||
-- whose user doesn't exists any more
|
||||
--========================================
|
||||
delete from public.soundcards
|
||||
where user_id in ( select distinct user_id from public.soundcards
|
||||
except
|
||||
select userid from public.users
|
||||
);
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the emergdi records
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
delete from public.emergdi
|
||||
where sc_id in ( select distinct sc_id from public.emergdi
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the sms records
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
delete from public.sms
|
||||
where sc_id_sour in ( select distinct sc_id_sour from public.sms
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
)
|
||||
or sc_id_dest in ( select distinct sc_id_dest from public.sms
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the messages records
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
delete from public.messages
|
||||
where sc_id in ( select distinct sc_id from public.messages
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the geozoneinout records
|
||||
-- whose subscriber doesn't exists any more
|
||||
--========================================
|
||||
delete from public.geozoneinout
|
||||
where sc_id in ( select distinct sc_id from public.geozoneinout
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the subscriber_history records
|
||||
-- whose subscriber/ vehicle doesn't exists any more
|
||||
--========================================
|
||||
delete from public.subscriber_history
|
||||
where sc_id in ( select distinct sc_id from public.subscriber_history
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
)
|
||||
or veh_id in ( select distinct veh_id from public.subscriber_history
|
||||
except
|
||||
select id from public.vehicle
|
||||
);
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the user_radio records
|
||||
-- whose user_id / radio_id doesn't exists any more
|
||||
--========================================
|
||||
|
||||
delete from public.user_radio
|
||||
where user_id in ( select distinct user_id from public.user_radio
|
||||
except
|
||||
select userid from public.users
|
||||
)
|
||||
or radio_id in ( select distinct radio_id from public.user_radio
|
||||
except
|
||||
select "ID" from public.radio_gw
|
||||
);
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the user_group records
|
||||
-- whose user doesn't exists any more
|
||||
--========================================
|
||||
delete from public.users_group
|
||||
where userid in ( select distinct userid from public.users_group
|
||||
except
|
||||
select userid from public.users
|
||||
)
|
||||
or grp_id in ( select distinct grp_id from public.users_group
|
||||
except
|
||||
select id from public.groups
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the vehicle_group
|
||||
-- whose group_id doesn't exists any more
|
||||
--========================================
|
||||
delete from public.vehicle_group
|
||||
where grp_ip in ( select distinct grp_ip from public.vehicle_group
|
||||
except
|
||||
select id from groups
|
||||
)
|
||||
or sc_id in ( select distinct sc_id from public.vehicle_group
|
||||
except
|
||||
select sc_id from public.subscriber
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove the vehicle_user
|
||||
-- whose user_id doesn't exists any more
|
||||
--========================================
|
||||
delete from public.vehicle_user
|
||||
where user_id in ( select distinct user_id from public.vehicle_user
|
||||
except
|
||||
select userid from users
|
||||
)
|
||||
or veh_id in ( select distinct veh_id from public.vehicle_user
|
||||
except
|
||||
select id from public.vehicle
|
||||
);
|
||||
|
||||
|
||||
--========================================
|
||||
-- remove the zonepoints records
|
||||
-- whose zone_id doesn't exists any more
|
||||
--========================================
|
||||
delete from public.zonepoints
|
||||
where zone_id in ( select distinct zone_id from public.zonepoints
|
||||
except
|
||||
select idx from public.zonename
|
||||
);
|
||||
|
||||
--========================================
|
||||
-- remove sc_id=0 from all records
|
||||
--========================================
|
||||
delete from public.subscriber_stun
|
||||
where sc_id = 0;
|
||||
delete from public.subscriber_alarm
|
||||
where sc_id = 0;
|
||||
delete from public.emergdi
|
||||
where sc_id = 0;
|
||||
delete from public.messages
|
||||
where sc_id = 0;
|
||||
delete from public.subs_gateway
|
||||
where sc_id = 0;
|
||||
delete from public.subscriber
|
||||
where sc_id = 0;
|
||||
|
||||
|
||||
END;
|
||||
$$
|
||||
|
5
UpdateHelper/RunAllMissingFiles.sql
Normal file
5
UpdateHelper/RunAllMissingFiles.sql
Normal file
@ -0,0 +1,5 @@
|
||||
SELECT AddNewFields();
|
||||
SELECT RemoveRecordsWithoutRelatedData();
|
||||
SELECT CreateMissingPrimaryKeys();
|
||||
SELECT CreateMissingForeignKeys();
|
||||
SELECT CreateMissingIndexes();
|
3
UpdateHelper/RunMessagesPartitioning.bat
Normal file
3
UpdateHelper/RunMessagesPartitioning.bat
Normal file
@ -0,0 +1,3 @@
|
||||
UpdateHelper.exe -w generate_partitioning_of_an_existing_table_by_date_unix_time.sql
|
||||
UpdateHelper.exe -w get_query_partitioning_of_an_existing_table_by_date_unix_time.sql
|
||||
UpdateHelper.exe -f call_messsages_partitioning.sql
|
202
UpdateHelper/UpdateHelper.csproj
Normal file
202
UpdateHelper/UpdateHelper.csproj
Normal file
@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{316FC545-051D-47AE-BEFA-1E94AC6D5D21}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>UpdateHelper</RootNamespace>
|
||||
<AssemblyName>UpdateHelper</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'kitLINXB|AnyCPU'">
|
||||
<OutputPath>bin\kitLINXB\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'KitExcera|AnyCPU'">
|
||||
<OutputPath>bin\KitExcera\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'LISF|AnyCPU'">
|
||||
<OutputPath>bin\LISF\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Repeater|AnyCPU'">
|
||||
<OutputPath>bin\Repeater\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="functions.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="prebuild.sh" />
|
||||
<None Include="RunMessagesPartitioning.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="4to5.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="5to6.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="6to7.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="7toLatest7.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="call_messages_partitioning.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="CreateMissingForeignKeys.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="CreateMissingIndexes.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="CreateMissingPrimaryKeys.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="generate_partitioning_of_an_existing_table_by_date_unix_time.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="get_query_partitioning_of_an_existing_table_by_date_unix_time.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="NewFields.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="RemoveRecordsWithoutRelatedData.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="RunAllMissingFiles.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="sql.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SafeMobileLIB_DLL\safemobilelib.csproj">
|
||||
<Project>{f7a15710-ee5c-4374-b9c7-aed367e36f16}</Project>
|
||||
<Name>safemobilelib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>$(ProjectDir)prebuild.sh</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
1
UpdateHelper/call_messages_partitioning.sql
Normal file
1
UpdateHelper/call_messages_partitioning.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT generate_partitioning_of_an_existing_table_by_date_unix_time( 'messages', 'timegmt', 2020, 2035, 'half-yearly', false);
|
6
UpdateHelper/functions.bat
Normal file
6
UpdateHelper/functions.bat
Normal file
@ -0,0 +1,6 @@
|
||||
UpdateHelper.exe -w NewFields.sql
|
||||
UpdateHelper.exe -w RemoveRecordsWithoutRelatedData.sql
|
||||
UpdateHelper.exe -w CreateMissingPrimaryKeys.sql
|
||||
UpdateHelper.exe -w CreateMissingForeignKeys.sql
|
||||
UpdateHelper.exe -w CreateMissingIndexes.sql
|
||||
UpdateHelper.exe -f RunAllMissingFiles.sql
|
@ -0,0 +1,252 @@
|
||||
DROP FUNCTION IF EXISTS public.generate_partitioning_of_an_existing_table_by_date_unix_time(text, text, integer, integer, text, boolean);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.generate_partitioning_of_an_existing_table_by_date_unix_time(
|
||||
tablename text,
|
||||
columnname text,
|
||||
start_year integer,
|
||||
end_year integer,
|
||||
step text,
|
||||
droptable boolean DEFAULT false)
|
||||
RETURNS void
|
||||
LANGUAGE 'plpgsql'
|
||||
|
||||
VOLATILE PARALLEL UNSAFE
|
||||
AS $BODY$
|
||||
declare old_tablename TEXT;
|
||||
new_tablename TEXT;
|
||||
partition_tablename TEXT;
|
||||
start_interval TEXT;
|
||||
end_interval TEXT;
|
||||
interations INTEGER;
|
||||
i INTEGER;
|
||||
sql_str TEXT = '';
|
||||
receive_constraints TEXT;
|
||||
receive_triggers TEXT;
|
||||
toBeDeleted_constraints TEXT;
|
||||
lastvalue INTEGER;
|
||||
exists_sequence TEXT;
|
||||
tmp_sql VARCHAR;
|
||||
renamed_indexes TEXT;
|
||||
renamed_constraints TEXT;
|
||||
toBeCreated_indexes TEXT;
|
||||
start_unix_time TEXT;
|
||||
end_unix_time TEXT;
|
||||
primary_key TEXT;
|
||||
sequence_id TEXT;
|
||||
|
||||
BEGIN
|
||||
|
||||
IF start_year > end_year THEN
|
||||
RAISE NOTICE '%', 'start_year > end_year';
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
primary_key := '"posID"';
|
||||
sequence_id := '_posID_seq';
|
||||
|
||||
new_tablename := 'new_' || tablename;
|
||||
sql_str := format('-- create a new table having the same structure with specified table ' || CHR(13) ||
|
||||
'CREATE TABLE ' || new_tablename || '(LIKE ' || tablename || ' INCLUDING DEFAULTS INCLUDING CONSTRAINTS) PARTITION BY RANGE(' || columnname || ');' || CHR(13) || CHR(13) ||
|
||||
'-- create partiton for all other records that dont match with the partition condition' || CHR(13) ||
|
||||
'CREATE TABLE ' || tablename || '_default PARTITION OF ' || new_tablename || ' DEFAULT; ') || CHR(13);
|
||||
|
||||
|
||||
sql_str := sql_str || CHR(13) || get_query_partitioning_of_an_existing_table_by_date_unix_time(tablename , new_tablename, start_year, end_year, step);
|
||||
|
||||
sql_str := sql_str || CHR(13) ||
|
||||
'-- copy data into the new table ' || CHR(13) ||
|
||||
'INSERT INTO ' || new_tablename || '(SELECT * FROM ' || tablename || '); ' || CHR(13) ;
|
||||
|
||||
|
||||
RAISE NOTICE '%', sql_str;
|
||||
|
||||
-- execute the query
|
||||
EXECUTE sql_str;
|
||||
|
||||
--===========================================================
|
||||
-- build the commands to rename the indexes
|
||||
--===========================================================
|
||||
|
||||
old_tablename := tablename;
|
||||
|
||||
SELECT string_agg( 'ALTER INDEX IF EXISTS "' || indexname || '" RENAME TO "old_' || indexname || '";' , CHR(13)) INTO renamed_indexes
|
||||
FROM pg_indexes pg
|
||||
WHERE pg.tablename = old_tablename
|
||||
AND indexname NOT LIKE '%pkey%';
|
||||
|
||||
SELECT string_agg( CASE WHEN contype = 'p' THEN -- primary key
|
||||
'ALTER INDEX IF EXISTS "' || conname || '" RENAME TO "old_' || conname || '";'
|
||||
ELSE
|
||||
'ALTER TABLE ' || old_tablename || ' RENAME CONSTRAINT "' || conname || '" TO "old_' || conname || '";'
|
||||
END
|
||||
, CHR(13)) INTO renamed_constraints
|
||||
|
||||
FROM pg_catalog.pg_constraint con
|
||||
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
||||
WHERE rel.relname = old_tablename;
|
||||
|
||||
--======================================================================
|
||||
-- build the commands to recreate the indexes on the partitioned table
|
||||
--======================================================================
|
||||
|
||||
SELECT string_agg( indexdef || ';' , CHR(13)) INTO toBeCreated_indexes
|
||||
FROM pg_indexes pg
|
||||
WHERE pg.tablename = old_tablename
|
||||
AND indexname NOT LIKE '%pkey%'
|
||||
AND indexname NOT LIKE '%' || primary_key || '%'
|
||||
AND indexdef NOT LIKE '%UNIQUE%';
|
||||
|
||||
|
||||
|
||||
--===========================================================
|
||||
-- save the foreign key into receive_constraints variable
|
||||
--===========================================================
|
||||
SELECT string_agg(command , CHR(13) ) INTO receive_constraints
|
||||
FROM ( SELECT format('ALTER TABLE IF EXISTS "%s" ADD CONSTRAINT "%s" FOREIGN KEY ("%s") REFERENCES "%s"("%s");',
|
||||
tablename,
|
||||
tc.constraint_name,
|
||||
string_agg(distinct kcu.column_name, ','),
|
||||
ccu.table_name,
|
||||
string_agg(distinct ccu.column_name, ',')) command
|
||||
FROM information_schema.table_constraints AS tc
|
||||
JOIN information_schema.key_column_usage AS kcu
|
||||
ON tc.constraint_name = kcu.constraint_name
|
||||
JOIN information_schema.constraint_column_usage AS ccu
|
||||
ON ccu.constraint_name = tc.constraint_name
|
||||
WHERE constraint_type = 'FOREIGN KEY'
|
||||
AND tc.table_name = tablename
|
||||
GROUP BY tc.constraint_name, tc.table_name, ccu.table_name
|
||||
)x;
|
||||
|
||||
--===========================================================
|
||||
-- save the triggers into receive_triggers variable
|
||||
--===========================================================
|
||||
SELECT string_agg(command , CHR(13) ) INTO receive_triggers
|
||||
FROM ( SELECT format( 'CREATE TRIGGER %s %s %s ON "%s" FOR EACH ROW %s ;',
|
||||
t1.trigger_name
|
||||
,t1.action_timing
|
||||
,t2.event_manipulation
|
||||
,t1.event_object_table
|
||||
,t1.action_statement ) as command
|
||||
|
||||
FROM ( SELECT DISTINCT
|
||||
trigger_name
|
||||
,action_timing
|
||||
,event_object_table
|
||||
,action_statement
|
||||
FROM information_schema.triggers
|
||||
WHERE event_object_table = tablename
|
||||
) t1
|
||||
INNER JOIN (SELECT trigger_name, string_agg(event_manipulation, ' OR ') as event_manipulation
|
||||
FROM information_schema.triggers
|
||||
WHERE event_object_table = tablename
|
||||
GROUP BY trigger_name
|
||||
) t2 ON t1.trigger_name = t2.trigger_name
|
||||
)x;
|
||||
|
||||
|
||||
--===================================================================================================================
|
||||
-- save the constraints which refereces the specified tablename into toBeDeleted_constraints variable
|
||||
--===================================================================================================================
|
||||
SELECT string_agg( 'ALTER TABLE IF EXISTS "' || foreign_table || '" DROP CONSTRAINT IF EXISTS "' || constraint_name || '";' , CHR(13) ) INTO toBeDeleted_constraints
|
||||
FROM (
|
||||
select kcu.table_name as foreign_table,
|
||||
'>-' as rel,
|
||||
rel_tco.table_schema || '.' || rel_tco.table_name as primary_table,
|
||||
string_agg(kcu.column_name, ', ') as fk_columns,
|
||||
kcu.constraint_name
|
||||
from information_schema.table_constraints tco
|
||||
join information_schema.key_column_usage kcu
|
||||
on tco.constraint_schema = kcu.constraint_schema
|
||||
and tco.constraint_name = kcu.constraint_name
|
||||
join information_schema.referential_constraints rco
|
||||
on tco.constraint_schema = rco.constraint_schema
|
||||
and tco.constraint_name = rco.constraint_name
|
||||
join information_schema.table_constraints rel_tco
|
||||
on rco.unique_constraint_schema = rel_tco.constraint_schema
|
||||
and rco.unique_constraint_name = rel_tco.constraint_name
|
||||
where tco.constraint_type = 'FOREIGN KEY'
|
||||
and rel_tco.table_name = tablename
|
||||
group by kcu.table_schema,
|
||||
kcu.table_name,
|
||||
rel_tco.table_name,
|
||||
rel_tco.table_schema,
|
||||
kcu.constraint_name
|
||||
)x;
|
||||
|
||||
tmp_sql = ' SELECT ''exists'' FROM pg_class WHERE relname = ''' || tablename || sequence_id || ''';';
|
||||
EXECUTE tmp_sql INTO exists_sequence;
|
||||
|
||||
--RAISE NOTICE '%', COALESCE( exists_sequence, 'not exists');
|
||||
IF exists_sequence = 'exists' THEN
|
||||
EXECUTE format(' SELECT last_value FROM "%s";', tablename || sequence_id) INTO lastvalue;
|
||||
END IF;
|
||||
|
||||
|
||||
|
||||
IF ( dropTable ) THEN
|
||||
|
||||
sql_str := '--====== dropTable = true ======-- ' || CHR(13) || CHR(13) ||
|
||||
'-- drop old table with cascade ' || CHR(13) ||
|
||||
'DROP TABLE IF EXISTS ' || tablename || ' CASCADE; ' || CHR(13) ||
|
||||
|
||||
'-- rename the new table to old table ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || new_tablename || ' RENAME TO ' || tablename || ';' || CHR(13) ||
|
||||
|
||||
'-- create primary key ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || tablename || ' ADD CONSTRAINT ' || tablename || '_pkey PRIMARY KEY (' || primary_key || ',' || columnname || ');' || CHR(13) ||
|
||||
|
||||
'-- create sequence ' || CHR(13) ||
|
||||
'CREATE SEQUENCE IF NOT EXISTS "' || tablename || sequence_id || '" INCREMENT 1 START ' || COALESCE(lastvalue,0) + 1 || ';' || CHR(13) ||
|
||||
|
||||
'-- set id to be taken from sequence ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || tablename || ' ALTER COLUMN ' || primary_key || ' SET DEFAULT nextval(''"' || tablename || sequence_id || '"'');' || CHR(13);
|
||||
|
||||
|
||||
ELSE
|
||||
|
||||
sql_str := COALESCE( renamed_constraints, '') || CHR(13) ||
|
||||
COALESCE( renamed_indexes, '') || CHR(13);
|
||||
EXECUTE sql_str;
|
||||
|
||||
sql_str := '--====== dropTable = false ( rename table )======-- ' || CHR(13) || CHR(13) ||
|
||||
|
||||
'-- rename the current table to *_old ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || tablename || ' RENAME TO ' || tablename || '_old; ' || CHR(13) ||
|
||||
|
||||
'-- rename the new table ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || new_tablename || ' RENAME TO ' || tablename || ';' || CHR(13) ||
|
||||
|
||||
'-- create primary key ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || tablename || ' ADD CONSTRAINT ' || tablename || '_pkey PRIMARY KEY (' || primary_key || ',' || columnname || ');' || CHR(13) ||
|
||||
|
||||
'-- rename existing sequence as old ' || CHR(13) ||
|
||||
'ALTER SEQUENCE IF EXISTS "' || tablename || sequence_id || '" RENAME TO "' || tablename || '_old' || sequence_id || '";' || CHR(13) ||
|
||||
|
||||
'-- create sequence ' || CHR(13) ||
|
||||
'CREATE SEQUENCE IF NOT EXISTS "' || tablename || sequence_id || '" INCREMENT 1 START ' || COALESCE(lastvalue,0) + 1 || ';' || CHR(13) ||
|
||||
|
||||
'-- set id to be taken from sequence ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || tablename || '_old' || ' ALTER COLUMN ' || primary_key || ' SET DEFAULT nextval(''"' || tablename || '_old' || sequence_id || '"'');' || CHR(13) ||
|
||||
|
||||
'-- set id to be taken from sequence ' || CHR(13) ||
|
||||
'ALTER TABLE IF EXISTS ' || tablename || ' ALTER COLUMN ' || primary_key || ' SET DEFAULT nextval(''"' || tablename || sequence_id || '"'');' || CHR(13);
|
||||
|
||||
END IF;
|
||||
|
||||
sql_str := sql_str || COALESCE(toBeDeleted_constraints, '') || CHR(13) || COALESCE(receive_constraints, '') || CHR(13) || CHR(13) || COALESCE(receive_triggers, '');
|
||||
|
||||
|
||||
RAISE NOTICE '%', sql_str;
|
||||
|
||||
-- execute the query
|
||||
EXECUTE sql_str;
|
||||
|
||||
|
||||
sql_str := COALESCE(toBeCreated_indexes, '');
|
||||
|
||||
RAISE NOTICE '%', sql_str;
|
||||
EXECUTE sql_str;
|
||||
|
||||
END;
|
||||
$BODY$;
|
@ -0,0 +1,130 @@
|
||||
DROP FUNCTION IF EXISTS public.get_query_partitioning_of_an_existing_table_by_date_unix_time(text, text, integer, integer, text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.get_query_partitioning_of_an_existing_table_by_date_unix_time(
|
||||
old_tablename text,
|
||||
new_tablename text,
|
||||
start_year integer,
|
||||
end_year integer,
|
||||
step text)
|
||||
RETURNS character varying
|
||||
LANGUAGE 'plpgsql'
|
||||
|
||||
VOLATILE PARALLEL UNSAFE
|
||||
AS $BODY$
|
||||
DECLARE partition_tablename TEXT;
|
||||
start_interval TEXT;
|
||||
end_interval TEXT;
|
||||
i INTEGER;
|
||||
sql_str TEXT;
|
||||
start_unix_time TEXT;
|
||||
end_unix_time TEXT;
|
||||
|
||||
BEGIN
|
||||
|
||||
IF start_year > end_year THEN
|
||||
RAISE NOTICE '%', 'start_year > end_year';
|
||||
RETURN '';
|
||||
END IF;
|
||||
|
||||
|
||||
WHILE start_year <= end_year LOOP -- loop through years
|
||||
|
||||
-- set the initial month
|
||||
CASE step
|
||||
WHEN 'monthly' THEN i:= 1;
|
||||
WHEN 'quaterly' THEN i:= 3;
|
||||
WHEN 'half-yearly' THEN i:= 6;
|
||||
WHEN 'yearly' THEN i:= 12;
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'Invalid step parameter. Valid values are : monthly, quaterly, half-yearly, yearly';
|
||||
EXIT;
|
||||
END CASE;
|
||||
|
||||
|
||||
WHILE i <= 12 LOOP -- loop through month
|
||||
|
||||
partition_tablename := '';
|
||||
|
||||
CASE step
|
||||
WHEN 'monthly' THEN
|
||||
|
||||
partition_tablename := old_tablename || '_' || lpad(i::text, 2, '0') || '_' || start_year::text;
|
||||
start_interval = start_year::text || '-' || lpad(i::text, 2, '0') || '-01';
|
||||
end_interval = (date_trunc('month', start_interval::date) + interval '1 months')::date;
|
||||
i := i + 1;
|
||||
|
||||
start_unix_time = extract(epoch from (start_interval)::timestamp);
|
||||
end_unix_time = extract(epoch from (end_interval::date - Interval'1 sec')::timestamp);
|
||||
|
||||
|
||||
WHEN 'quaterly' THEN
|
||||
|
||||
IF (i % 3 = 0) THEN
|
||||
partition_tablename := old_tablename || '_Q' || i/3 || '_' || start_year::text;
|
||||
start_interval = start_year::text || '-' || case i/3
|
||||
when 1 then '01-01'
|
||||
when 2 then '04-01'
|
||||
when 3 then '07-01'
|
||||
when 4 then '10-01'
|
||||
end;
|
||||
|
||||
end_interval = (date_trunc('quarter', start_interval::date) + interval '3 months')::date;
|
||||
i := i + 3;
|
||||
|
||||
start_unix_time = extract(epoch from (start_interval)::timestamp);
|
||||
end_unix_time = extract(epoch from (end_interval::date - Interval'1 sec')::timestamp);
|
||||
END IF;
|
||||
|
||||
|
||||
WHEN 'half-yearly' THEN
|
||||
|
||||
IF (i % 6 = 0) THEN
|
||||
partition_tablename := old_tablename || '_S' || i/6 || '_' || start_year::text;
|
||||
start_interval = start_year::text || case i/6 when 1 then '-01-01' else '-07-01' end ;
|
||||
end_interval = (start_interval::date + interval '6 months')::date;
|
||||
|
||||
i := i + 6;
|
||||
|
||||
start_unix_time = extract(epoch from (start_interval)::timestamp);
|
||||
end_unix_time = extract(epoch from (end_interval::date - Interval'1 sec')::timestamp);
|
||||
END IF;
|
||||
|
||||
WHEN 'yearly' THEN
|
||||
|
||||
IF (i % 12 = 0) THEN
|
||||
partition_tablename := old_tablename || '_' || start_year::text;
|
||||
start_interval = start_year::text || '-01-01';
|
||||
end_interval = (date_trunc('year', start_interval::date) + interval '1 year')::date;
|
||||
|
||||
i := i + 12;
|
||||
|
||||
start_unix_time = extract(epoch from (start_interval)::timestamp);
|
||||
end_unix_time = extract(epoch from (end_interval::date - Interval'1 sec')::timestamp);
|
||||
END IF;
|
||||
ELSE
|
||||
RAISE NOTICE '%', 'Invalid step parameter. Valid values are : monthly, quaterly, half-yearly, yearly';
|
||||
EXIT;
|
||||
END CASE;
|
||||
|
||||
|
||||
|
||||
IF ( partition_tablename <> '') THEN
|
||||
sql_str := COALESCE(sql_str, '') || CHR(13) || 'CREATE TABLE ' || partition_tablename || ' PARTITION OF ' || new_tablename ||
|
||||
' FOR VALUES FROM (' || start_unix_time || ') TO (' || end_unix_time || ');';
|
||||
END IF;
|
||||
|
||||
END LOOP;
|
||||
|
||||
start_year := start_year + 1;
|
||||
sql_str := COALESCE(sql_str, '') || CHR(13);
|
||||
|
||||
|
||||
END LOOP;
|
||||
|
||||
--RAISE NOTICE '%', sql_str;
|
||||
|
||||
RETURN COALESCE(sql_str, '');
|
||||
|
||||
END;
|
||||
$BODY$;
|
||||
|
39
UpdateHelper/prebuild.sh
Normal file
39
UpdateHelper/prebuild.sh
Normal file
@ -0,0 +1,39 @@
|
||||
#/!bin/bash
|
||||
|
||||
echo .................
|
||||
echo . Prebuild step $(pwd)
|
||||
echo .................
|
||||
|
||||
|
||||
version=$(git describe)
|
||||
|
||||
# (
|
||||
# echo namespace SafeDispatch-git
|
||||
# echo {
|
||||
# echo public class VersionInfo
|
||||
# echo {
|
||||
# echo public string Version{ get; set; } = "%VersionGIT%";
|
||||
# echo }
|
||||
# echo }
|
||||
# )> "$(ProjectDir)\Properties\VersionInfo.cs"
|
||||
|
||||
|
||||
|
||||
[ -f ../../../Properties/VersionInfo.cs ] && rm ../../../Properties/VersionInfo.cs
|
||||
cat > ../../../Properties/VersionInfo.cs << ENDOFFILE
|
||||
|
||||
// Generated on $(date) by prebuild script
|
||||
namespace SafeDispatch-git
|
||||
{
|
||||
public class VersionInfo
|
||||
{
|
||||
public string Version{ get; set; } = "$version";
|
||||
}
|
||||
}
|
||||
|
||||
ENDOFFILE
|
||||
|
||||
echo Generated 'Properties/VersionInfo.cs' with the content below:
|
||||
cat ../../../Properties/VersionInfo.cs
|
||||
echo ............................
|
||||
#read -p 'Press Enter to continue...' var
|
451
UpdateHelper/sql.sql
Normal file
451
UpdateHelper/sql.sql
Normal file
@ -0,0 +1,451 @@
|
||||
---
|
||||
-- Below is v4 to v5
|
||||
---
|
||||
CREATE TABLE public.user_radio (radio_id integer NOT NULL DEFAULT 0,user_id integer NOT NULL DEFAULT 0) WITH (OIDS=FALSE);
|
||||
ALTER TABLE public.user_radio OWNER TO postgres;
|
||||
CREATE TABLE public.reports(startdate integer NOT NULL DEFAULT 0, stopdate integer NOT NULL DEFAULT 0, unit_ids character varying(4096), geofence_id integer NOT NULL DEFAULT 0, type_stat integer NOT NULL DEFAULT 0, report_id integer NOT NULL DEFAULT 0, email character varying(255),idletime integer, idx serial NOT NULL) WITH (OIDS = FALSE);
|
||||
ALTER TABLE public.reports OWNER TO postgres;
|
||||
ALTER TABLE zonename ADD COLUMN useridx integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE place ADD COLUMN useridx integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE zonename ADD COLUMN alarmtype integer NOT NULL DEFAULT 3;
|
||||
ALTER TABLE zonename ADD COLUMN sentmsg boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE zonename ADD COLUMN msgbody character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN unitids character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN sentemail boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE zonename ADD COLUMN email character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN subj character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN body character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE zonename ADD COLUMN imeilist character varying(255) NOT NULL DEFAULT '';
|
||||
---
|
||||
-- Below is v5 to v6
|
||||
---
|
||||
ALTER TABLE \"VoiceRecordings\" ADD COLUMN calltype integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE \"VoiceRecordings\" ADD COLUMN group_id integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE zonename ADD COLUMN sentmsg2 boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE zonename ADD COLUMN msgbody2 character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE speedalarm ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE speedalarm ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE telemetry_history ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE telemetry_history ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE emergalarm ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE emergalarm ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE reports ADD COLUMN latlng boolean NOT NULL DEFAULT false;
|
||||
UPDATE emergalarm SET address='no address' WHERE address = '';
|
||||
UPDATE telemetry_history SET address='no address' WHERE address = '';
|
||||
UPDATE speedalarm SET address='no address' WHERE address = '';
|
||||
ALTER TABLE vehicle ADD COLUMN gps_poor integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE vehicle ADD COLUMN gps_off integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE vehicle ADD COLUMN made_off integer NOT NULL DEFAULT 0;
|
||||
UPDATE vehicle SET gps_poor=\"GPS_reporting_interval\"*2, gps_off=\"GPS_reporting_interval\"*4, made_off=\"GPS_reporting_interval\"*10;
|
||||
UPDATE lastpos SET status=0;
|
||||
---
|
||||
-- Below is v6 with for recordings.
|
||||
---
|
||||
ALTER TABLE gateways ADD COLUMN peer_id integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE radio_gw DROP CONSTRAINT unique_radio_gw;
|
||||
ALTER TABLE sms ADD COLUMN lat double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE sms ADD COLUMN lng double precision NOT NULL DEFAULT 0;
|
||||
ALTER TABLE sms ADD COLUMN address character varying(255) NOT NULL DEFAULT 'no address';
|
||||
INSERT INTO emailservice(id, \"user\", pass, enable) VALUES (2,'poll', 'poll', 0);
|
||||
ALTER TABLE zonename ADD COLUMN speed integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE emailservice ADD COLUMN pop_server text NOT NULL DEFAULT 'pop.gmail.com';
|
||||
ALTER TABLE emailservice ADD COLUMN pop_port integer NOT NULL DEFAULT 995;
|
||||
ALTER TABLE emailservice ADD COLUMN smtp_server text NOT NULL DEFAULT 'smtp.gmail.com';
|
||||
ALTER TABLE emailservice ADD COLUMN smtp_port integer NOT NULL DEFAULT 587;
|
||||
ALTER TABLE emailservice ADD COLUMN is_pop_ssl boolean NOT NULL DEFAULT true;
|
||||
ALTER TABLE emailservice ADD COLUMN is_smtp_ssl boolean NOT NULL DEFAULT true;
|
||||
ALTER TABLE emailservice ADD COLUMN last_email_time integer NOT NULL DEFAULT 0;
|
||||
---
|
||||
-- Below is v6 to v7
|
||||
---
|
||||
ALTER TABLE lastpos ADD COLUMN altitude double precision NOT NULL DEFAULT 0;
|
||||
DROP TABLE IF EXISTS jobtickets;
|
||||
CREATE TABLE jobtickets (ticket_id serial,name text,job_status integer,sc_id integer,comment text,dispatcher text,priority text,end_time_planned integer,creation_time integer,start_time integer,end_time integer,is_expired boolean DEFAULT false NOT NULL,deleted integer,share_with text,seq_id character varying(40),status integer DEFAULT 0 NOT NULL,sched_timegmt integer DEFAULT 0);
|
||||
ALTER TABLE public.jobtickets OWNER TO postgres;
|
||||
DROP TABLE IF EXISTS jobtickets_log;
|
||||
CREATE TABLE jobtickets_log ( id serial, ticket_id integer, modified_date integer,job_status integer, sc_id integer, comment text) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE jobtickets_log OWNER TO postgres;
|
||||
DROP TABLE IF EXISTS jobticketstatusesset;
|
||||
CREATE TABLE jobticketstatusesset ( status_id serial, status character varying(45), color character varying(45), sound_on integer, sound_file character varying(250), is_first_state integer, is_last_state integer, CONSTRAINT jobticketstatusesset_pkey PRIMARY KEY (status_id))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE jobticketstatusesset OWNER TO postgres;
|
||||
DROP TABLE IF EXISTS definejobticket;
|
||||
CREATE TABLE definejobticket ( name character varying(200) NOT NULL, text character varying(200) NOT NULL, comment character varying(200), priority character varying(200), expire_date integer, idx serial NOT NULL, CONSTRAINT definejobticket_pkey PRIMARY KEY (idx))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE definejobticket OWNER TO postgres;
|
||||
ALTER TABLE registration ADD COLUMN has_ticketing boolean NOT NULL DEFAULT false;
|
||||
DELETE FROM jobticketstatusesset;
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (1, 'Assigned', '3D8584', 0, '', 1, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (2, 'Accepted', '3D7171', 0, '', 0, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (3, 'In progress', '3D5B85', 0, '', 0, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (4, 'Completed', '5E853D', 0, '', 0, 1);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (5, 'Rejected', 'A93D47', 0, '', 0, 0);
|
||||
INSERT INTO jobticketstatusesset (status_id, status, color, sound_on, sound_file, is_first_state, is_last_state) VALUES (6, 'Overdue', 'B29F3D', 0, '', 0, 0);
|
||||
ALTER TABLE definejobticket ADD COLUMN handled_by text;
|
||||
ALTER TABLE definejobticket ADD COLUMN schedule_date integer;
|
||||
ALTER TABLE definejobticket ADD COLUMN share_with text;
|
||||
DROP TABLE IF EXISTS sequences;
|
||||
CREATE TABLE sequences( name character varying(32) NOT NULL, value integer NOT NULL DEFAULT 0, idx serial NOT NULL, CONSTRAINT sequences_pkey PRIMARY KEY (idx))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE sequences OWNER TO postgres;
|
||||
INSERT INTO sequences(name, value) VALUES('jobticketing',1);
|
||||
DROP TABLE IF EXISTS icon_theme;
|
||||
CREATE TABLE icon_theme( id serial NOT NULL, \"name\" text, prefix text) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE icon_theme OWNER TO postgres;
|
||||
INSERT INTO icon_theme(id, \"name\", prefix)VALUES (1, 'Classic', 'classic'),(2, 'Pin', 'pin');
|
||||
DROP TABLE IF EXISTS car;
|
||||
CREATE TABLE car(\"name\" character varying(100) NOT NULL, id serial NOT NULL, pattern text, displayed_name text, CONSTRAINT car_pkey PRIMARY KEY (id))WITH ( OIDS=FALSE);
|
||||
ALTER TABLE car OWNER TO postgres;
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('minibus', 102, 'minibus_01', 'Van 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Minicar', 103, 'minicar_01', 'MiniCar 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('people_08', 35, 'people_08', 'People 8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Minicar2', 104, 'minicar_02', 'MiniCar 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('police', 105, 'police_01', 'Police 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Police1', 106, 'police_02', 'Police 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('schoolbus', 107, 'school_bus_01', 'School Bus 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('taxi_02', 131, 'taxi_02', 'Taxi 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('schoolbus2', 108, 'school_bus_02', 'School Bus 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_01', 132, 'moto_01', 'Moto 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_02', 133, 'moto_02', 'Moto 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('TowTruckYellow', 110, 'tow_truck_01', 'Tow Truck');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('TractorUnitBlack', 111, 'tractor_unit', 'Tractor Unit');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_03', 134, 'moto_03', 'Moto 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_04', 135, 'moto_04', 'Moto 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Classic-Car-66', 92, 'classic_car_01', 'Classic Car 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck0', 112, 'truck_01', 'Truck 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('classycar', 93, 'classic_car_02', 'Classic Car 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peopleblue', 1, 'people_01', 'People 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplegreen', 2, 'people_02', 'People 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplegrey', 3, 'people_03', 'People 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplepink', 4, 'people_04', 'People 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplepurple', 5, 'people_05', 'People 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('peoplered', 6, 'people_06', 'People 6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('army', 79, 'army_01', 'Army');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bigcar0', 80, 'car_01', 'Car 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bigcar1', 81, 'car_02', 'Car 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bigcar2', 82, 'car_03', 'Car 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('moto_05', 136, 'moto_05', 'Moto 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bicycle_01', 137, 'bicycle_01', 'Bicycle');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car0', 87, 'car_04', 'Car 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car1', 88, 'car_05', 'Car 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car2', 89, 'car_06', 'Car 6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('car3', 90, 'car_07', 'Car 7');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('CarGrey', 91, 'car_08', 'Car 8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('dodge', 94, 'dodge_01', 'Dodge');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('FireEscape', 95, 'firetruck_01', 'FireTruck 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck1', 113, 'truck_02', 'Truck 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('firefighters2', 96, 'firetruck_02', 'Fire Truck 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('ambulance_01', 36, 'ambulance_01', 'Ambulance 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('firetruck1', 97, 'firetruck_03', 'Fire Truck 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck2', 114, 'truck_03', 'Truck 3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('firetruck2', 98, 'firetruck_04', 'Fire Truck 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Jeep', 99, 'jeep_01', 'Jeep');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('CabrioletRed', 86, 'cabriolet_01', 'Carbriolet');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck3', 115, 'truck_04', 'Truck 4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('Longhaul', 100, 'longhaul_01', 'Long Haul');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck4', 116, 'truck_05', 'Truck 5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('LorryGreen', 101, 'lorry_01', 'Lorry');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('ambulance_02', 78, 'ambulance_02', 'Ambulance 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck5', 117, 'truck_06', 'Truck 6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('truck6', 118, 'truck_07', 'Truck 7');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('TruckYellow', 119, 'truck_08', 'Truck 8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('wagon', 120, 'wagon_01', 'Wagon');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bus', 83, 'tour_bus_01', 'Tour Bus 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bus0', 84, 'bus_01', 'Bus 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('bus2', 85, 'bus_02', 'Bus 2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_01', 121, 'number_01', '1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_02', 122, 'number_02', '2');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_04', 124, 'number_04', '4');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_03', 123, 'number_03', '3');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_05', 125, 'number_05', '5');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_06', 126, 'number_06', '6');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_07', 127, 'number_07', '7');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_08', 128, 'number_08', '8');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_09', 129, 'number_09', '9');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('number_10', 130, 'number_10', '10');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('taxi', 109, 'taxi_01', 'Taxi 1');
|
||||
INSERT INTO car (name, id, pattern, displayed_name) VALUES ('people_07', 34, 'people_07', 'People 7');
|
||||
insert into \"userSettings\" (user_id, key, value) select userid, 'reportTime', '0' from users where userid not in (select user_id from \"userSettings\" where key = 'reportTime') order by userid;
|
||||
insert into \"userSettings\" (user_id, key, value) select userid, 'iconTheme', 'pin' from users where userid not in (select user_id from \"userSettings\" where key = 'iconTheme') order by userid;
|
||||
ALTER TABLE reports ADD COLUMN userid integer;
|
||||
UPDATE reports SET userid = (SELECT MAX(userid) FROM users);
|
||||
ALTER TABLE reports ADD COLUMN ticket_status character varying(250);
|
||||
ALTER TABLE reports ADD COLUMN ticket_date_type character varying(250);
|
||||
ALTER TABLE reports ADD COLUMN type text;
|
||||
ALTER TABLE reports ADD COLUMN day text;
|
||||
ALTER TABLE reports ADD COLUMN is_activated boolean;
|
||||
ALTER TABLE sms ADD COLUMN color character varying(7);
|
||||
ALTER TABLE sms ALTER COLUMN color SET STORAGE EXTENDED;
|
||||
DROP TABLE IF EXISTS placetype;
|
||||
CREATE TABLE placetype ( type_name character varying(100) NOT NULL,type_id integer NOT NULL,icon_name character varying(70));
|
||||
ALTER TABLE public.placetype OWNER TO postgres;
|
||||
CREATE SEQUENCE placetype_type_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;
|
||||
ALTER TABLE public.placetype_type_id_seq OWNER TO postgres;
|
||||
ALTER SEQUENCE placetype_type_id_seq OWNED BY placetype.type_id;
|
||||
SELECT pg_catalog.setval('placetype_type_id_seq', 156, true);
|
||||
ALTER TABLE place ADD COLUMN icon_size character varying(20);
|
||||
ALTER TABLE place ADD COLUMN color character varying(7);
|
||||
ALTER TABLE zonename ADD COLUMN fill_color character varying(7);
|
||||
ALTER TABLE zonename ADD COLUMN fill_opacity double precision;
|
||||
ALTER TABLE zonename ADD COLUMN border_color character varying(7);
|
||||
ALTER TABLE zonename ADD COLUMN border_opacity double precision;
|
||||
ALTER TABLE zonename ADD COLUMN border_width integer;
|
||||
ALTER TABLE placetype ALTER COLUMN type_id SET DEFAULT nextval('placetype_type_id_seq'::regclass);
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('calculator', 45, 'calculator.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('calendar', 46, 'calendar.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('camera', 47, 'camera.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cancel', 48, 'cancel.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('factory', 4, 'factory.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('airport', 1, 'airport.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cd', 49, 'cd.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hospital', 6, 'hospital.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bank', 2, 'bank.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('school', 15, 'school.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('supermarket', 17, 'supermarket.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shopping', 16, 'shopping.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('office', 18, 'office.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('post_office', 13, 'post_office.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('restaurant', 14, 'restaurant.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('home', 9, 'home.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('fire_department', 7, 'fire_department.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('repair_shop', 3, 'repair_shop.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('garage', 5, 'garage.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hotel', 10, 'hotel.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('gas_station', 8, 'gas_station.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('military_base', 11, 'military_base.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('police_station', 12, 'police_station.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('chair', 50, 'chair.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('check', 51, 'check.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cinema', 52, 'cinema.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('add', 20, 'add.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('coffee', 53, 'coffee.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('alert', 22, 'alert.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('anchor', 23, 'anchor.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('announce', 24, 'announce.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('antivirus', 25, 'antivirus.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_down', 26, 'arrow_down.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('compass', 54, 'compass.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_down_left', 27, 'arrow_down_left.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('computer', 55, 'computer.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_down_right', 28, 'arrow_down_right.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_left', 29, 'arrow_left.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('construction', 56, 'construction.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('repair_shop_2', 102, 'repair_shop_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('rip', 103, 'rip.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('roundabout', 104, 'roundabout.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('ruby', 105, 'ruby.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('save', 106, 'save.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_right', 30, 'arrow_right.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_up', 31, 'arrow_up.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_up_left', 32, 'arrow_up_left.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('arrow_up_right', 33, 'arrow_up_right.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('baggage', 34, 'baggage.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('banned', 35, 'banned.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('science', 107, 'science.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('search', 108, 'search.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('servers', 109, 'servers.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('settings', 110, 'settings.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_circle', 111, 'shape_circle.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_ellipse', 112, 'shape_ellipse.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_hexagon', 113, 'shape_hexagon.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_kite', 114, 'shape_kite.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_parallelogram', 115, 'shape_parallelogram.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('battery', 36, 'battery.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bicycle', 37, 'bicycle.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bluetooth', 38, 'bluetooth.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('book', 39, 'book.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bookmark', 40, 'bookmark.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('brush', 41, 'brush.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bug', 42, 'bug.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('bussiness_card', 43, 'bussiness_card.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cake', 44, 'cake.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('credit_card', 57, 'credit_card.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('cross', 58, 'cross.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('database', 59, 'database.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('directions', 60, 'directions.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('directions_2', 61, 'directions_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('doctor', 62, 'doctor.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('drill', 63, 'drill.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('elevator', 64, 'elevator.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('facebook', 65, 'facebook.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('fan', 66, 'fan.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('favorite', 67, 'favorite.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('flag', 68, 'flag.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('food', 69, 'food.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('gameboy', 70, 'gameboy.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_pentagon', 116, 'shape_pentagon.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_rhombus', 117, 'shape_rhombus.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_square', 118, 'shape_square.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_trapezoid', 119, 'shape_trapezoid.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('shape_triangle', 120, 'shape_triangle.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pool_game', 98, 'pool_game.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('alarm', 21, 'alarm.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('games', 71, 'games.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('gift', 72, 'gift.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('glasses', 73, 'glasses.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('grid', 74, 'grid.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hairdresser', 75, 'hairdresser.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hammer', 76, 'hammer.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hardware', 77, 'hardware.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('headphones', 78, 'headphones.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('hedge', 79, 'hedge.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('help', 80, 'help.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('help_2', 81, 'help_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('icecream', 82, 'icecream.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('info', 83, 'info.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('key', 84, 'key.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('map', 85, 'map.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('marker', 86, 'marker.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('microphone', 87, 'microphone.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('moon', 88, 'moon.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('newspaper', 89, 'newspaper.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('padlock_closed', 90, 'padlock_closed.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('padlock_open', 91, 'padlock_open.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('paintroller', 92, 'paintroller.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('park_bench', 93, 'park_bench.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('phone', 94, 'phone.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pill', 95, 'pill.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pinetree', 96, 'pinetree.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('pollution', 97, 'pollution.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('print', 99, 'print.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('refreshment', 100, 'refreshment.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('remote_control', 101, 'remote_control.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stamp', 121, 'stamp.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('star', 122, 'star.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stop', 123, 'stop.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stop_2', 124, 'stop_2.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('stopwatch', 125, 'stopwatch.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('store', 126, 'store.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('tag', 127, 'tag.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('tent', 128, 'tent.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('tie', 129, 'tie.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('time', 130, 'time.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight', 131, 'trafficlight.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight_green', 132, 'trafficlight_green.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight_red', 133, 'trafficlight_red.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trafficlight_yellow', 134, 'trafficlight_yellow.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trash', 135, 'trash.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('trophy', 136, 'trophy.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('truck', 137, 'truck.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('typewritter', 138, 'typewritter.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('user', 139, 'user.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('users', 140, 'users.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('water', 141, 'water.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_cloud', 142, 'weather_cloud.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_clouds', 144, 'weather_clouds.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_rain', 145, 'weather_rain.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_sun', 146, 'weather_sun.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_snow', 147, 'weather_snow.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_thunder', 148, 'weather_thunder.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('wi_fi', 149, 'wi_fi.png');
|
||||
INSERT INTO placetype (type_name, type_id, icon_name) VALUES ('weather_cloud_sun', 143, 'weather_cloud_sun.png');
|
||||
ALTER TABLE messages ADD COLUMN altitude double precision;
|
||||
---
|
||||
-- Below if v7 to LINX
|
||||
---
|
||||
CREATE TABLE public.newicons (icontype integer NOT NULL DEFAULT 0, id integer NOT NULL DEFAULT 0, imagedata bytea);
|
||||
ALTER TABLE groups ADD COLUMN type integer;
|
||||
UPDATE groups SET type = 0;
|
||||
ALTER TABLE vehicle ADD COLUMN type integer;
|
||||
UPDATE vehicle SET type = 0;
|
||||
ALTER TABLE vehicle ADD COLUMN active boolean;
|
||||
UPDATE vehicle SET active = TRUE;
|
||||
ALTER TABLE radio_gw ADD COLUMN name character varying(30);
|
||||
UPDATE radio_gw SET name = 'unnamed' || \"ID\";
|
||||
ALTER TABLE radio_gw ADD COLUMN gw_type integer;
|
||||
UPDATE radio_gw SET gw_type = 0;
|
||||
ALTER TABLE groups ADD COLUMN r_gw_id integer;
|
||||
UPDATE groups SET r_gw_id = ( CASE WHEN ((select count(*) from radio_gw ) = 0) THEN 0 ELSE (select min(\"ID\") from radio_gw) END);
|
||||
update subs_gateway set gateway_id = (CASE WHEN ((select count(*) from radio_gw where \"ID\" = 1 and \"GW_ID\" = 1) = 0) THEN (select min(\"GW_ID\") from radio_gw) ELSE 1 END ), radio_gw_id = (CASE WHEN ((select count(*) from radio_gw where \"ID\" = 1 and \"GW_ID\" = 1) = 0) THEN (select min(\"ID\") from radio_gw) ELSE 1 END) where gateway_id = 1 and radio_gw_id = 1;
|
||||
CREATE TABLE subscriber_mobile( sc_id serial NOT NULL, phone_imei character varying(20), first_name character varying(50), last_name character varying(50), company character varying(30), os character varying(20), phone_type character varying(20), sip_pswd character varying(30), CONSTRAINT subscriber_mobile_pkey PRIMARY KEY (sc_id)) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE subscriber_mobile OWNER TO postgres;
|
||||
CREATE TABLE mobile_contacts(idx serial NOT NULL, sc_id integer NOT NULL, contact_id integer NOT NULL, contact_type character varying(30), contact_type_id integer) WITH ( OIDS=FALSE);
|
||||
ALTER TABLE mobile_contacts OWNER TO postgres;
|
||||
ALTER TABLE sms ADD COLUMN user_id integer;
|
||||
ALTER TABLE sms ALTER COLUMN user_id SET STORAGE PLAIN;
|
||||
ALTER TABLE users ADD COLUMN backup_user_id integer default 0;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_gps boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_voice boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_text boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_ticketing boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN email text;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN login text;
|
||||
ALTER TABLE users ADD COLUMN sip_id integer;
|
||||
ALTER TABLE users ALTER COLUMN sip_id SET STORAGE PLAIN;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN lone_worker boolean DEFAULT false;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN lone_worker_interval integer DEFAULT 0;
|
||||
ALTER TABLE emergalarm ADD COLUMN user_id integer;
|
||||
ALTER TABLE emergalarm ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE geozoneinout ADD COLUMN user_id integer;
|
||||
ALTER TABLE geozoneinout ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE speedalarm ADD COLUMN user_id integer;
|
||||
ALTER TABLE speedalarm ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE telemetry_history ADD COLUMN user_id integer;
|
||||
ALTER TABLE telemetry_history ADD COLUMN timegmt_ack integer;
|
||||
ALTER TABLE emergalarm ADD COLUMN emergency_type integer;
|
||||
create table call_patch(idx serial not null, type integer, incoming text, outgoing text, userid integer);
|
||||
CREATE INDEX msg_sc_id_idx ON messages USING btree (sc_id);
|
||||
CREATE INDEX secv_idx ON messages USING btree (scevtime);
|
||||
CREATE INDEX speed_idx ON messages USING btree (speed);
|
||||
CREATE INDEX timegmt_idx ON messages USING btree (timegmt);
|
||||
CREATE TABLE users_group(idx serial not null, userid integer not null, grp_id integer not null);
|
||||
CREATE TABLE sip_manager(sip_id serial not null primary key, id integer not null, type integer not null);
|
||||
CREATE UNIQUE INDEX unique_idx ON sip_manager (id, type);
|
||||
ALTER SEQUENCE sip_manager_sip_id_seq RESTART WITH 10;
|
||||
insert into sip_manager(id, type) select userid, 0 from users where user_type <> 1;
|
||||
insert into sip_manager(id, type) select id, 1 from groups where type <> 0;
|
||||
insert into sip_manager(id, type) select sc_id, 2 from subscriber;
|
||||
insert into sip_manager(id, type) select \"ID\", 4 from radio_gw;
|
||||
ALTER TABLE users DROP COLUMN sip_id;
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'lanLinxServer','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'lanLinxServer');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'natLinxServer','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'natLinxServer');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'lanSipPort','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'lanSipPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'natSipPort','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'natSipPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'lanSigPort','41414' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'lanSigPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'natSigPort','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'natSigPort');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'rtpStart','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'rtpStart');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'rtpEnd','' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'rtpEnd');
|
||||
INSERT INTO car(\"name\", id, pattern, displayed_name) VALUES ('linx_01', 138, 'linx_01', 'Linx 1'), ('linx_02', 139, 'linx_02', 'Linx 2');
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_man_down boolean DEFAULT false;
|
||||
ALTER TABLE gateways ADD COLUMN active boolean default false;
|
||||
UPDATE gateways SET active = true WHERE \"IP\" IN (SELECT ip FROM reg_gateway);
|
||||
DROP TABLE reg_gateway;
|
||||
ALTER TABLE subscriber_mobile RENAME lone_worker TO has_lone_worker;
|
||||
ALTER TABLE subscriber_mobile ADD COLUMN has_emergency boolean DEFAULT true;
|
||||
UPDATE subscriber_mobile SET lone_worker_interval = 1 WHERE lone_worker_interval = 0;
|
||||
ALTER TABLE subscriber_mobile ALTER COLUMN lone_worker_interval SET DEFAULT 1;
|
||||
ALTER TABLE sms ALTER COLUMN mess TYPE text;
|
||||
ALTER TABLE alarm ALTER COLUMN mess TYPE text;
|
||||
CREATE SEQUENCE radio_mobile_idx_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;
|
||||
CREATE TABLE public.radio_mobile(idx integer NOT NULL DEFAULT nextval('radio_mobile_idx_seq'::regclass), radio_grp_id integer NOT NULL, mobile_grp_id integer NOT NULL);
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'sampleRate','8000' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'sampleRate');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'bufferMilliseconds','32' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'bufferMilliseconds');
|
||||
insert into \"userSettings\" (user_id, key, value) SELECT 0,'bitDepth','16' where not exists (select * from \"userSettings\" where user_id = 0 and key = 'bitDepth');
|
||||
alter table definesms add column user_id integer NOT NULL DEFAULT 0;
|
||||
CREATE TABLE msg(idx serial, message text NOT NULL, dest_id int NOT NULL, seq_id text, sched_timegmt integer DEFAULT 0, email text NOT NULL, CONSTRAINT msg_pkey PRIMARY KEY (idx));
|
||||
CREATE TABLE msg_details(idx serial, msg_id int NOT NULL, sip_id int, timegmt integer, lat double precision NOT NULL DEFAULT 0, lng double precision NOT NULL DEFAULT 0, speed double precision NOT NULL DEFAULT 0, altitude double precision NOT NULL DEFAULT 0, address character varying(255) NOT NULL DEFAULT 'no address'::character varying, is_sent boolean DEFAULT false, is_read boolean DEFAULT false, is_deleted boolean DEFAULT false, CONSTRAINT msg_det_pkey PRIMARY KEY (idx));
|
||||
ALTER TABLE msg_details ADD CONSTRAINT msg_fk FOREIGN KEY (msg_id) REFERENCES msg (idx) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE;
|
||||
ALTER TABLE msg_details ADD CONSTRAINT sip_manager_msg_det_fk FOREIGN KEY (sip_id) REFERENCES sip_manager (sip_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
ALTER TABLE msg ADD CONSTRAINT sip_manager_msg_fk FOREIGN KEY (dest_id) REFERENCES sip_manager (sip_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
CREATE INDEX msg_sip_id_idx ON msg_details USING btree (sip_id);
|
||||
CREATE INDEX msg_timegmt_idx ON msg_details USING btree (timegmt);
|
||||
ALTER TABLE msg_details ADD COLUMN msg_type integer not null default 0;
|
||||
ALTER TABLE messages ADD COLUMN tallysman_log_id integer;
|
||||
ALTER TABLE registration ADD COLUMN has_recordings boolean NOT NULL DEFAULT false;
|
||||
ALTER TABLE \"userSettings\" alter column key type text;
|
||||
|
||||
---
|
||||
-- Fix long context menu when to many alerts
|
||||
---
|
||||
|
||||
CREATE INDEX idx_geozone_1 ON public.geozoneinout USING btree (sc_id, preview);
|
||||
CREATE INDEX idx_emergalarm ON public.emergalarm USING btree (sc_id, preview);
|
||||
CREATE INDEX idx_speedalarm ON public.speedalarm USING btree (sc_id, preview);
|
||||
CREATE INDEX idx_telemetryalarm ON public.telemetry_history USING btree (sc_id, ack, alarm);
|
||||
|
||||
---
|
||||
-- Callout for TetraSDR
|
||||
---
|
||||
|
||||
ALTER TABLE zonename ADD COLUMN \"callout\" BOOLEAN DEFAULT FALSE;
|
||||
ALTER TABLE zonename ADD COLUMN \"callout_severity\" int DEFAULT 3;
|
||||
ALTER TABLE place ADD COLUMN \"callout\" BOOLEAN DEFAULT FALSE;
|
||||
ALTER TABLE place ADD COLUMN \"callout_severity\" int DEFAULT 3;
|
||||
|
Loading…
Reference in New Issue
Block a user