Merge pull request 'refactor code' (#5) from refactor_code into master

Reviewed-on: #5
This commit is contained in:
Laurențiu Constantin 2024-06-07 13:35:46 +00:00
commit 61fa677598
23 changed files with 158 additions and 129 deletions

View File

@ -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

View File

@ -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;

View File

@ -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];

View File

@ -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;

View File

@ -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);

View File

@ -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");

View File

@ -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();

View File

@ -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); }

View File

@ -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);

View File

@ -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);

View File

@ -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];

View File

@ -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)
{

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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] != "")
{

View File

@ -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))

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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-", "");

View File

@ -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)

View File

@ -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;

View File

@ -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;