From e1c315402fb3b27de7797c86146a9dcc05287923 Mon Sep 17 00:00:00 2001 From: Laurentiu Date: Fri, 7 Jun 2024 16:20:57 +0300 Subject: [PATCH] refactor code --- AppServer/LocationThread.cs | 157 ++++++++++-------- AppServer/RegistrationThread.cs | 2 +- .../DBmanagers/DBTicketingManager.cs | 2 +- .../DBmanagers/DBvehiclesManager.cs | 2 +- SafeMobileLIB_DLL/EmailServerSSL.cs | 2 +- .../Helpers/RegistrationHelper.cs | 2 +- SafeMobileLIB_DLL/IP_Helpers.cs | 8 +- SafeMobileLIB_DLL/Utils.cs | 4 +- Safedispatch_4_0/MapGoogle.cs | 4 +- Safedispatch_4_0/NewJobTicketingForm.cs | 6 +- Safedispatch_4_0/maptab/LandZoneCfg.cs | 4 +- Safedispatch_4_0/maptab/LandZoneCfgGIS.cs | 2 +- Safedispatch_4_0/maptab/LiveTab.cs | 4 +- Safedispatch_4_0/maptab/LiveTabGIS.cs | 2 +- Safedispatch_4_0/maptab/Radio/RadioTab.cs | 32 ++-- .../maptab/Reports/ReportsControl.cs | 2 +- Safedispatch_4_0/maptab/SMSuserControl.cs | 16 +- .../maptab/TicketingUserControl.cs | 6 +- .../maptab/UIClasses/VisualSettings.cs | 2 +- SubscriberAndUserManager/MainForm.cs | 4 +- SubscriberAndUserManager/VehiclesForm.cs | 2 +- SubscriberAndUserManager/controlSettings.cs | 16 +- SubscriberAndUserManager/controlSystem.cs | 6 +- 23 files changed, 158 insertions(+), 129 deletions(-) diff --git a/AppServer/LocationThread.cs b/AppServer/LocationThread.cs index a56f0f3..6e51c4e 100644 --- a/AppServer/LocationThread.cs +++ b/AppServer/LocationThread.cs @@ -256,7 +256,7 @@ 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; @@ -407,36 +407,45 @@ namespace AppServer private void sendMailGeo(string mes, String subj, string mailAdr) { - try + + if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr)) { - 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) + try { - Boolean skipeFirst = true; - foreach (String obj in address) + 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) { - if (skipeFirst) - { skipeFirst = false; } - else - message.To.Add(new MailAddress(obj)); + 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) + { + Console.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) + else { - Console.WriteLine("Exception in sendMailGeo: ", ex.ToString()); + Utils.WriteLine("Email Server not Set", ConsoleColor.Cyan); } + } private void sendAlarmMail(string title, string mes, string mailAdr) { - if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(mailAdr)) + if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr)) { try { @@ -505,18 +514,19 @@ namespace AppServer 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"); - - string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph"; - string message = "Zone alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp - + $". Unit speed {speed_km_or_mph} at time:" + Utils.UnixTimeStampToDateTime(time).ToLocalTime() + " [" + cell.lat + " , " + cell.lng + "]"; - - string title = "Zone alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name; - if (mailAdr != "") + // send Alert by email if the emailServer is configured + if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr)) { + + string veh_name = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name; + string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph"; + string message = $"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(() => { sendAlarmMail(title, message, mailAdr); @@ -533,6 +543,7 @@ namespace AppServer 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); } + String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString(); ///send SMS UnitSysPosition tmpX = null; @@ -559,7 +570,7 @@ namespace AppServer 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); + 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)}]"); } @@ -586,8 +597,8 @@ namespace AppServer 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(() => { @@ -607,30 +618,38 @@ 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); - - string speed_km_or_mph = obj2.speedUnit.Equals("k") ? $"{speed} km/h" : $"{speedMiles} mph"; - string message = "Landmark alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " " + tmpresp - + $". Unit speed {speed_km_or_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 != "") + 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 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(() => { 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); } + //send CallOut if(obj2.callout && tmpresp.ToString().Contains("IN ")) { @@ -667,47 +686,47 @@ 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 speedMiles = (int)Math.Round(speed * 0.621371192); - - - uint time = DateTo70Format(cell.location_time); - string speed4send = speed.ToString() + "_" + speedUnits; - int treshold = (int)Convert.ToDouble(speedTreshold); if (speedUnits == "m") treshold = (int)(treshold * 1.609); - if (speedUnits != "m") + int speed = (int)Convert.ToDouble(cell.spd); + if (speed >= treshold) { - if (speed >= treshold) + uint time = DateTo70Format(cell.location_time); + // insert alert into database + DBalarm.Insert_Speed_Alarm(radioID, time, speed, cell.lat, cell.lng); + + + //send Alert by email if EmailServer si configured + if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(mailAdr)) { - Utils.WriteLine("Speed alarm detected!"); - DBalarm.Insert_Speed_Alarm(radioID, time, speed,cell.lat,cell.lng); - Utils.WriteLine("Done inserting speed alarm!"); - + int speedMiles = (int)Math.Round(speed * 0.621371192); + string veh_name = ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name; string speed_km_or_mph = (speedUnits != "m") ? $"{speed} km/h" : $"{speedMiles} mph"; - string message = "Speed alarm for " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name - + $". Unit speed {speed_km_or_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 != "") - { - Task.Factory.StartNew(() => - { - sendAlarmMail(title, message, mailAdr); - }); - } + 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}"; - if (sendOnMsgBus) + + 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); - } + 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(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); } } + } #endregion diff --git a/AppServer/RegistrationThread.cs b/AppServer/RegistrationThread.cs index 9bdb83c..58bb322 100644 --- a/AppServer/RegistrationThread.cs +++ b/AppServer/RegistrationThread.cs @@ -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; diff --git a/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs index 95bbea3..cfa9774 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs @@ -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]; diff --git a/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs index f3c599b..2a3f665 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs @@ -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; diff --git a/SafeMobileLIB_DLL/EmailServerSSL.cs b/SafeMobileLIB_DLL/EmailServerSSL.cs index 4fa6b42..7882feb 100644 --- a/SafeMobileLIB_DLL/EmailServerSSL.cs +++ b/SafeMobileLIB_DLL/EmailServerSSL.cs @@ -334,7 +334,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); diff --git a/SafeMobileLIB_DLL/Helpers/RegistrationHelper.cs b/SafeMobileLIB_DLL/Helpers/RegistrationHelper.cs index f2e8d68..58fc514 100644 --- a/SafeMobileLIB_DLL/Helpers/RegistrationHelper.cs +++ b/SafeMobileLIB_DLL/Helpers/RegistrationHelper.cs @@ -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"); diff --git a/SafeMobileLIB_DLL/IP_Helpers.cs b/SafeMobileLIB_DLL/IP_Helpers.cs index 246a5f9..0fd6434 100644 --- a/SafeMobileLIB_DLL/IP_Helpers.cs +++ b/SafeMobileLIB_DLL/IP_Helpers.cs @@ -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(); diff --git a/SafeMobileLIB_DLL/Utils.cs b/SafeMobileLIB_DLL/Utils.cs index 74ebce1..65e6c42 100644 --- a/SafeMobileLIB_DLL/Utils.cs +++ b/SafeMobileLIB_DLL/Utils.cs @@ -1056,7 +1056,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 +1094,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); } diff --git a/Safedispatch_4_0/MapGoogle.cs b/Safedispatch_4_0/MapGoogle.cs index 29698a5..ee25cbd 100644 --- a/Safedispatch_4_0/MapGoogle.cs +++ b/Safedispatch_4_0/MapGoogle.cs @@ -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); diff --git a/Safedispatch_4_0/NewJobTicketingForm.cs b/Safedispatch_4_0/NewJobTicketingForm.cs index 5f14569..6084d30 100644 --- a/Safedispatch_4_0/NewJobTicketingForm.cs +++ b/Safedispatch_4_0/NewJobTicketingForm.cs @@ -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); diff --git a/Safedispatch_4_0/maptab/LandZoneCfg.cs b/Safedispatch_4_0/maptab/LandZoneCfg.cs index d37b6c5..78c6b61 100644 --- a/Safedispatch_4_0/maptab/LandZoneCfg.cs +++ b/Safedispatch_4_0/maptab/LandZoneCfg.cs @@ -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 /// String containing the response from the map 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]; diff --git a/Safedispatch_4_0/maptab/LandZoneCfgGIS.cs b/Safedispatch_4_0/maptab/LandZoneCfgGIS.cs index 8b2affc..35847e4 100644 --- a/Safedispatch_4_0/maptab/LandZoneCfgGIS.cs +++ b/Safedispatch_4_0/maptab/LandZoneCfgGIS.cs @@ -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) { diff --git a/Safedispatch_4_0/maptab/LiveTab.cs b/Safedispatch_4_0/maptab/LiveTab.cs index ebd0013..913cb73 100644 --- a/Safedispatch_4_0/maptab/LiveTab.cs +++ b/Safedispatch_4_0/maptab/LiveTab.cs @@ -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); diff --git a/Safedispatch_4_0/maptab/LiveTabGIS.cs b/Safedispatch_4_0/maptab/LiveTabGIS.cs index 97690e7..febe08c 100644 --- a/Safedispatch_4_0/maptab/LiveTabGIS.cs +++ b/Safedispatch_4_0/maptab/LiveTabGIS.cs @@ -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; diff --git a/Safedispatch_4_0/maptab/Radio/RadioTab.cs b/Safedispatch_4_0/maptab/Radio/RadioTab.cs index 0935cf3..15019cb 100644 --- a/Safedispatch_4_0/maptab/Radio/RadioTab.cs +++ b/Safedispatch_4_0/maptab/Radio/RadioTab.cs @@ -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 diff --git a/Safedispatch_4_0/maptab/Reports/ReportsControl.cs b/Safedispatch_4_0/maptab/Reports/ReportsControl.cs index 850fef5..2573acc 100644 --- a/Safedispatch_4_0/maptab/Reports/ReportsControl.cs +++ b/Safedispatch_4_0/maptab/Reports/ReportsControl.cs @@ -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] != "") { diff --git a/Safedispatch_4_0/maptab/SMSuserControl.cs b/Safedispatch_4_0/maptab/SMSuserControl.cs index 2c23c37..fbc4504 100644 --- a/Safedispatch_4_0/maptab/SMSuserControl.cs +++ b/Safedispatch_4_0/maptab/SMSuserControl.cs @@ -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)) diff --git a/Safedispatch_4_0/maptab/TicketingUserControl.cs b/Safedispatch_4_0/maptab/TicketingUserControl.cs index 733a7fd..d5f81c5 100644 --- a/Safedispatch_4_0/maptab/TicketingUserControl.cs +++ b/Safedispatch_4_0/maptab/TicketingUserControl.cs @@ -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; } } diff --git a/Safedispatch_4_0/maptab/UIClasses/VisualSettings.cs b/Safedispatch_4_0/maptab/UIClasses/VisualSettings.cs index 6f6dc8b..629b0e7 100644 --- a/Safedispatch_4_0/maptab/UIClasses/VisualSettings.cs +++ b/Safedispatch_4_0/maptab/UIClasses/VisualSettings.cs @@ -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); diff --git a/SubscriberAndUserManager/MainForm.cs b/SubscriberAndUserManager/MainForm.cs index ff5cda0..5fd3f71 100644 --- a/SubscriberAndUserManager/MainForm.cs +++ b/SubscriberAndUserManager/MainForm.cs @@ -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-", ""); diff --git a/SubscriberAndUserManager/VehiclesForm.cs b/SubscriberAndUserManager/VehiclesForm.cs index e7a6d9d..60832e1 100644 --- a/SubscriberAndUserManager/VehiclesForm.cs +++ b/SubscriberAndUserManager/VehiclesForm.cs @@ -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) diff --git a/SubscriberAndUserManager/controlSettings.cs b/SubscriberAndUserManager/controlSettings.cs index 4c05585..f13347e 100644 --- a/SubscriberAndUserManager/controlSettings.cs +++ b/SubscriberAndUserManager/controlSettings.cs @@ -861,13 +861,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 +890,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 +1441,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; diff --git a/SubscriberAndUserManager/controlSystem.cs b/SubscriberAndUserManager/controlSystem.cs index e14e29a..7a28782 100644 --- a/SubscriberAndUserManager/controlSystem.cs +++ b/SubscriberAndUserManager/controlSystem.cs @@ -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; -- 2.37.1