From 69f34e84ba48bd1d3246d0a308514af8024191a7 Mon Sep 17 00:00:00 2001 From: Laurentiu Date: Wed, 5 Jun 2024 14:00:51 +0300 Subject: [PATCH 1/4] Batch_Historical_Group_Report and refactor the code --- AppServer/MainForm.cs | 95 +- AppServer/MulticastListener.cs | 22 +- Dongle RegLib/RegLib.cs | 349 ++-- ReportsLibrary/Properties/AssemblyInfo.cs | 4 +- ReportsLibrary/Reports/ClassForReports.cs | 484 +++-- ReportsLibrary/ReportsLibrary.csproj | 10 + .../DBmanagers/DBRadioTypeManager.cs | 10 +- .../DBmanagers/DBReportingManager.cs | 665 ++++-- .../DBmanagers/DBTicketingManager.cs | 56 +- .../DBmanagers/DBalarmManager.cs | 147 +- SafeMobileLIB_DLL/DBmanagers/DBmanager.cs | 20 +- .../DBmanagers/DBregistrationManager.cs | 57 +- .../DBmanagers/DBsettingsManager.cs | 4 +- SafeMobileLIB_DLL/DBmanagers/DBsmsManager.cs | 35 +- .../DBmanagers/DBsubsOperationManager.cs | 28 +- .../DBmanagers/DBtelemetryManager.cs | 8 +- SafeMobileLIB_DLL/DBmanagers/DBuserManager.cs | 44 +- .../DBmanagers/DBvehiclesManager.cs | 17 +- SafeMobileLIB_DLL/ReportsClass.cs | 28 +- SafeMobileLIB_DLL/StaticMembers.cs | 1 + SafeMobileLIB_DLL/Utils.cs | 126 ++ Safedispatch_4_0/ClassDef.cs | 6 +- Safedispatch_4_0/Language/myRes.Designer.cs | 81 + Safedispatch_4_0/Language/myRes.resx | 27 + Safedispatch_4_0/Login.cs | 10 +- Safedispatch_4_0/MainForm2.Designer.cs | 39 +- Safedispatch_4_0/MainForm2.cs | 1811 +++++++++-------- Safedispatch_4_0/ReverseGeocodingModule.cs | 15 +- Safedispatch_4_0/SMdb_accessMS.cs | 960 ++++----- Safedispatch_4_0/config.ini | 2 +- Safedispatch_4_0/maptab/HistoryTab.cs | 437 ++-- .../maptab/HistoryTab.designer.cs | 883 ++++---- Safedispatch_4_0/maptab/HistoryTab.resx | 2 +- .../maptab/ReportCont.Designer.cs | 77 +- Safedispatch_4_0/maptab/ReportCont.cs | 88 +- .../maptab/Reports/ReportsControl.Designer.cs | 110 +- .../maptab/Reports/ReportsControl.cs | 1358 +++++++----- SubscriberAndUserManager/MainForm.cs | 14 +- .../VehiclesForm.Designer.cs | 1 + .../controlRegistration.cs | 23 +- 40 files changed, 4523 insertions(+), 3631 deletions(-) diff --git a/AppServer/MainForm.cs b/AppServer/MainForm.cs index 5455245..e3db6a6 100644 --- a/AppServer/MainForm.cs +++ b/AppServer/MainForm.cs @@ -402,6 +402,34 @@ namespace AppServer } + + private string get_radio_type() + { + string radio_type = string.Empty; + + // if radio_type isn't saved in db => check folder's name + System.IO.DirectoryInfo myDirectory = new DirectoryInfo(Environment.CurrentDirectory); + // get parent directory + string parentDirectory = myDirectory.Parent.FullName; + DirectoryInfo dInfo = new DirectoryInfo(parentDirectory); + DirectoryInfo[] subdirs = dInfo.GetDirectories(); + foreach (DirectoryInfo folder in subdirs) + { + if (folder.Name == "Gateway") { radio_type = ((int)RADIOTYPE.MOTO).ToString(); break; } + else if (folder.Name == "Hytera") { radio_type = ((int)RADIOTYPE.HYT).ToString(); break; } + else if (folder.Name == "Momentum") { radio_type = ((int)RADIOTYPE.HARRIS).ToString(); break; } + else if (folder.Name == "Astro") { radio_type = ((int)RADIOTYPE.ATLAS).ToString(); break; } + else if (folder.Name == "Tetra") { radio_type = ((int)RADIOTYPE.TETRA).ToString(); break; } + else if (folder.Name == "Connect Plus") { radio_type = ((int)RADIOTYPE.CONECTPLUS).ToString(); break; } + else if (folder.Name == "Repeater_Gateway") { radio_type = ((int)RADIOTYPE.REPEATER_TRBO).ToString(); break; } + else if (folder.Name == "SMC_Gateway") { radio_type = ((int)RADIOTYPE.MOTO).ToString(); break; } + else if (folder.Name == "Simoco") { radio_type = ((int)RADIOTYPE.SIMOCO).ToString(); break; } + else if (folder.Name == "Sepura3T_SDR") { radio_type = ((int)RADIOTYPE.LISF).ToString(); break; } + } + + return radio_type; + } + /// /// Update the UI licenses circular controllers. This will read the dongle licenses /// and the ones from the DB and the display them in the UI. @@ -409,40 +437,26 @@ namespace AppServer private void UpdateLicensesUI() { Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; - String[] appname = this.Text.Split(' '); + String[] appname = this.Text.Split(" ".ToCharArray()); this.Text = appname[0] + " " + v.ToString(); lbVersion.Text = "Version " + v.ToString(); + //check radio type from database to set job ticketing to visible if (Program.cfg == null) return; + radioTypeManager = new DBRadioTypeManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); dbSettings = new DBsettingsManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); string radio_type = radioTypeManager.getRadioType(); if(radio_type == "") { - // if radio_type isn't saved in db => check folder's name - System.IO.DirectoryInfo myDirectory = new DirectoryInfo(Environment.CurrentDirectory); - // get parent directory - string parentDirectory = myDirectory.Parent.FullName; - DirectoryInfo dInfo = new DirectoryInfo(parentDirectory); - DirectoryInfo[] subdirs = dInfo.GetDirectories(); - foreach(DirectoryInfo folder in subdirs) - { - if (folder.Name == "Gateway") { radio_type = ((int)RADIOTYPE.MOTO).ToString(); break; } - else if (folder.Name == "Hytera") { radio_type = ((int)RADIOTYPE.HYT).ToString(); break; } - else if (folder.Name == "Momentum") { radio_type = ((int)RADIOTYPE.HARRIS).ToString(); break; } - else if (folder.Name == "Astro") { radio_type = ((int)RADIOTYPE.ATLAS).ToString(); break; } - else if (folder.Name == "Tetra") { radio_type = ((int)RADIOTYPE.TETRA).ToString(); break; } - else if (folder.Name == "Connect Plus") { radio_type = ((int)RADIOTYPE.CONECTPLUS).ToString(); break; } - else if (folder.Name == "Repeater_Gateway") { radio_type = ((int)RADIOTYPE.REPEATER_TRBO).ToString(); break; } - else if (folder.Name == "SMC_Gateway") { radio_type = ((int)RADIOTYPE.MOTO).ToString(); break; } - else if (folder.Name == "Simoco") { radio_type = ((int)RADIOTYPE.SIMOCO).ToString(); break; } - else if (folder.Name == "Sepura3T_SDR") { radio_type = ((int)RADIOTYPE.LISF).ToString(); break; } - } + + radio_type = get_radio_type(); //save radiotype in db radioTypeManager.setRadioType(radio_type); } + if (radio_type != "") RadioType = (RADIOTYPE)Enum.Parse(typeof(RADIOTYPE), radio_type); @@ -451,31 +465,18 @@ namespace AppServer = (RadioType == RADIOTYPE.MOTO || RadioType == RADIOTYPE.REPEATER_TRBO || RadioType == RADIOTYPE.HYT || RadioType == RADIOTYPE.HARRIS); - circularSDM.Visible = pbSDM.Visible = labelSDM.Visible = lbLicSDM.Visible = (RadioType == RADIOTYPE.SIMOCO); + circularSDM.Visible = pbSDM.Visible = labelSDM.Visible = lbLicSDM.Visible = (RadioType == RADIOTYPE.SIMOCO); + // change logo icon depending on the system type - if (RadioType == RADIOTYPE.SIMOCO) - { - pbLogo.Image = AppServer.Properties.Resources.simoco; - } - else - { - pbLogo.Image = AppServer.Properties.Resources.safemobile; - } + pbLogo.Image = (RadioType == RADIOTYPE.SIMOCO) ? AppServer.Properties.Resources.simoco : + AppServer.Properties.Resources.safemobile; if (error) { if (regLib.demoMode) { - if (regLib.remainingTime() == 1) - { - lbRegistrationStatus.Text = "Demo invalidated, please contact " + Program.COMPANY; - lbRegistrationStatus.ForeColor = Color.DarkRed; - } - else - { - lbRegistrationStatus.Text = "Demo registration expired"; - lbRegistrationStatus.ForeColor = Color.DarkRed; - } + lbRegistrationStatus.Text = (regLib.remainingTime() == 1) ? "Demo invalidated, please contact " + Program.COMPANY : "Demo registration expired"; ; + lbRegistrationStatus.ForeColor = Color.DarkRed; } } else @@ -486,9 +487,11 @@ namespace AppServer lbRegistrationStatus.Text = "trial ends in " + (regLib.remainingTime() / 86400).ToString() + " days "; lbRegistrationStatus.ForeColor = Color.Yellow; } + regManager = new DBregistrationManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); vehManager = new DBvehiclesManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); dbsub = new DBsubsOperationManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); + uint gpsCount = regManager.getGPSCount(); uint smsCount = regManager.getSMSCount(); uint reportsCount = regManager.getReportsCount(); @@ -644,6 +647,7 @@ namespace AppServer regManager.resetSafeDispatchRegistrations(); lbRegistrationRemaining.Text = "Database licenses reset"; } + if(gatewaysCount > regLib.gatewayCount()) regManager.removeAllGatewayRegistrations(); @@ -997,6 +1001,7 @@ namespace AppServer try { DB.InitConnection(); + DB.CloseConnection(); } catch (Exception ex) { @@ -1196,15 +1201,19 @@ namespace AppServer private void BroadcastWebSocketStatusOnMessageBus(object source, ElapsedEventArgs e) { - string message; //$"#0.0#{failoverStatusToMessBuss}#{configHelper.PCIp}#{msg}#{master}#"; + //string message; //$"#0.0#{failoverStatusToMessBuss}#{configHelper.PCIp}#{msg}#{master}#"; - string status = WebsocketThread.Instance.getClient().IsRunning ? "online" : "offline"; + string status = "offline"; + IWebsocketClient iWebsocketClient = WebsocketThread.Instance.getClient(); + if( iWebsocketClient != null) + status = iWebsocketClient.IsRunning ? "online" : "offline"; - message = $"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#{status}#"; + string message = $"#0.0#{Utils.enumConvertToString(MessageBusCmds.WebsocketStatusToMsgBus)}#{status}#"; byte[] dataToSend = Utils.Convert_text_For_multicast(message); - udp.Send(dataToSend, dataToSend.Length); + if(dataToSend != null && dataToSend.Length > 0) + udp.Send(dataToSend, dataToSend.Length); } diff --git a/AppServer/MulticastListener.cs b/AppServer/MulticastListener.cs index 871a8f8..cd1b174 100644 --- a/AppServer/MulticastListener.cs +++ b/AppServer/MulticastListener.cs @@ -1721,6 +1721,7 @@ namespace AppServer UserList.Add(obj.Id, obj.UserName); } + // gateways GatewayListTMP = dbgate.getAllGateways(); GatewayList.Clear(); foreach (Gateway obj in GatewayListTMP) @@ -1732,6 +1733,7 @@ namespace AppServer GatewayList.Add(obj.Id, (obj.Peer_id > 0)); } + // vehicles VehicleListTMP = dbveh.getAllVehicles(); VehicleList.Clear(); foreach (Vehicles obj in VehicleListTMP) @@ -2003,20 +2005,22 @@ namespace AppServer { Vehicle_Data vehicle_Data = (Vehicle_Data)VehListTMP[obj]; + + // populate Zone list ArrayList tmparr = new ArrayList(); foreach (ZoneClass obj2 in ZoneListTMP) { - ZoneClass tmp = new ZoneClass(obj2, obj2.id, obj2.arrSc_id); - tmparr.Add(tmp); + tmparr.Add(new ZoneClass(obj2, obj2.id, obj2.arrSc_id)); } vehicle_Data.zonelist = tmparr; + // populate Landmark list ArrayList tmparr2 = new ArrayList(); foreach (LandMark obj2 in LandListTMP) { - LandMark tmp = new LandMark(obj2.name, obj2.lat, obj2.lng, obj2.land_id, obj2.useridx, obj2.callout, obj2.calloutSeverity); - tmparr2.Add(tmp); + tmparr2.Add(new LandMark(obj2.name, obj2.lat, obj2.lng, obj2.land_id, obj2.useridx, obj2.callout, obj2.calloutSeverity)); + } vehicle_Data.landlist = tmparr2; } @@ -2038,11 +2042,9 @@ namespace AppServer MainForm.VehList.Clear(); // move from TMP used List - foreach (ZoneClass obj in ZoneListTMP) - ZoneList.Add(obj); + ZoneList.AddRange(ZoneListTMP); + LandList.AddRange(LandListTMP); - foreach (LandMark obj in LandListTMP) - LandList.Add(obj); foreach (String obj in VehListTMP.Keys) { @@ -2110,8 +2112,8 @@ namespace AppServer { try { - DB = new DBmanager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); - DB.InitConnection(); + //DB = new DBmanager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); + //DB.InitConnection(); //load vehs for stolen test dbvehs = new DBvehiclesManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); dbsubsoperManage = new DBsubsOperationManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port); diff --git a/Dongle RegLib/RegLib.cs b/Dongle RegLib/RegLib.cs index 42b125e..f2b0369 100644 --- a/Dongle RegLib/RegLib.cs +++ b/Dongle RegLib/RegLib.cs @@ -247,18 +247,11 @@ namespace RegLibDLL return true; #else int ret = SDX_Find(); - if (ret > 1) - { + if (ret >= 1) return true; - } - else if (ret == 1) - { - return true; - } - else - { - return false; - } + + return false; + #endif } @@ -269,9 +262,8 @@ namespace RegLibDLL #else int ret = SDX_Open(1, uid, ref hid); if (ret < 0) - { return false; - } + handle = ret; return true; #endif @@ -282,9 +274,8 @@ namespace RegLibDLL Byte[] retbuff = new byte[512]; int ret = SDX_Read(handle, blockNumber, retbuff); if (ret < 0) - { return ""; - } + String sReturn = System.Text.ASCIIEncoding.ASCII.GetString(retbuff); return sReturn; } @@ -293,9 +284,8 @@ namespace RegLibDLL { int ret = SDX_Write(handle, blockIndex, dataToWrite); if (ret < 0) - { return -1; - } + return 0; } private String DecryptString(string Message, string Passphrase) @@ -356,13 +346,11 @@ namespace RegLibDLL return true; #else if (existsDongle) - { return true; - } - else - { - return false; - } + + + return false; + #endif } @@ -376,13 +364,10 @@ namespace RegLibDLL return true; #else if (validDongle) - { return true; - } - else - { - return false; - } + + return false; + #endif } @@ -397,10 +382,8 @@ namespace RegLibDLL Int32 length = Convert.ToInt32(decodedMessage.Substring(10, 3)); return decodedMessage.Substring(13, length); } - else - { - return null; - } + + return null; } /// @@ -414,10 +397,8 @@ namespace RegLibDLL Int32 length = Convert.ToInt32(decodedMessage.Substring(35, 3)); return decodedMessage.Substring(38, length); } - else - { - return null; - } + + return null; } /// @@ -431,10 +412,8 @@ namespace RegLibDLL Int32 length = Convert.ToInt32(decodedMessage.Substring(85, 3)); return decodedMessage.Substring(88, length); } - else - { - return null; - } + + return null; } /// @@ -448,10 +427,9 @@ namespace RegLibDLL Int32 length = Convert.ToInt32(decodedMessage.Substring(195, 3)); return decodedMessage.Substring(198, length); } - else - { - return null; - } + + return null; + } /// @@ -464,17 +442,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[zonesIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -488,17 +462,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[gpsIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -512,17 +482,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[smsIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -536,17 +502,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[jobTicketingIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -560,17 +522,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[recordingsIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -581,17 +539,13 @@ namespace RegLibDLL public int voiceCount() { if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[voiceIndex]); - } - else - { - return 0; - } + + return 0; + } /// @@ -601,17 +555,14 @@ namespace RegLibDLL public int audibleAlertsCount() { if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[audibleAlertsIndex]); - } - else - { - return 0; - } + + + return 0; + } /// @@ -621,17 +572,14 @@ namespace RegLibDLL public int dbAccessCount() { if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[dbAccessIndex]); - } - else - { - return 0; - } + + + return 0; + } /// @@ -644,17 +592,14 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + + if (validDongle) - { return ((int)decodedMessage[emailGatewayIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -668,13 +613,13 @@ namespace RegLibDLL return 45; #else if (demoMode) - { return 12; //10 - } + + if (oldDongle) - { return 12; //10 - } + + int numberOfUnits = 0; if (validDongle) { @@ -687,10 +632,9 @@ namespace RegLibDLL } else return numberOfUnits; } - else - { - return 0; - } + + return 0; + #endif } @@ -704,17 +648,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[reportsIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -728,17 +668,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[telemetryIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -752,17 +688,13 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[mapType1Index]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -776,17 +708,14 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + if (validDongle) - { return ((int)decodedMessage[mapType2Index]); - } - else - { - return 0; - } + + + return 0; + #endif } @@ -800,17 +729,15 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + + if (validDongle) - { return ((int)decodedMessage[mapType3Index]); - } - else - { - return 0; - } + + + return 0; + #endif } @@ -824,17 +751,15 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + + if (validDongle) - { return ((int)decodedMessage[mapType4Index]); - } - else - { - return 0; - } + + + return 0; + #endif } @@ -848,17 +773,14 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } + + if (validDongle) - { return ((int)decodedMessage[safeDispatchIndex]); - } - else - { - return 0; - } + + + return 0; #endif } @@ -872,24 +794,14 @@ namespace RegLibDLL return true; #else if (demoMode) - { return true; - } + + if (validDongle) - { - if (decodedMessage[342].CompareTo('y') == 0) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } + return (decodedMessage[342].CompareTo('y') == 0); + + return false; + #endif } @@ -903,9 +815,7 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } /*if (enabledGateway()) { oldDongle = true; @@ -913,13 +823,11 @@ namespace RegLibDLL } oldDongle = false;*/ if (validDongle) - { return ((int)decodedMessage[gatewayIndex]); - } - else - { - return 0; - } + + + return 0; + #endif } @@ -933,9 +841,7 @@ namespace RegLibDLL return 2; #else if (demoMode) - { return 1; - } /*if (enabledGateway()) { oldDongle = true; @@ -943,13 +849,10 @@ namespace RegLibDLL } oldDongle = false;*/ if (validDongle) - { return ((int)decodedMessage[SDMobileIndex]); - } - else - { - return 0; - } + + return 0; + #endif } @@ -963,26 +866,18 @@ namespace RegLibDLL return true; #else if (demoMode) - { return true; - } + if (validDongle) { Int32 length = Convert.ToInt32(decodedMessage.Substring(320, 3)); String HID_READ = decodedMessage.Substring(323, length); - if (HID_READ.CompareTo(hid.ToString()) == 0) - { - return true; - } - else - { - return false; - } - } - else - { - return false; + return (HID_READ.CompareTo(hid.ToString()) == 0); + } + + return false; + #endif } diff --git a/ReportsLibrary/Properties/AssemblyInfo.cs b/ReportsLibrary/Properties/AssemblyInfo.cs index 40c2a25..cec11b9 100644 --- a/ReportsLibrary/Properties/AssemblyInfo.cs +++ b/ReportsLibrary/Properties/AssemblyInfo.cs @@ -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.0.0.10885")] -[assembly: AssemblyFileVersion("8.0.0.10885")] +[assembly: AssemblyVersion("8.1.0.10898")] +[assembly: AssemblyFileVersion("8.1.0.10898")] diff --git a/ReportsLibrary/Reports/ClassForReports.cs b/ReportsLibrary/Reports/ClassForReports.cs index 520059e..2ba65c2 100644 --- a/ReportsLibrary/Reports/ClassForReports.cs +++ b/ReportsLibrary/Reports/ClassForReports.cs @@ -180,9 +180,10 @@ namespace ReportsLibrary tmpData = new EndOfDayData(); RowNumber++; tmpData.Trip = Convert.ToString(RowNumber); - //tmpData.StartTime = (new ConvertDT().GetDTLocalFromSeconds(obj3.stop)).ToString(); - if (StaticMembers.is24hours) tmpData.StartTime = ((obj3.stop).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy HH:mm:ss"); - else tmpData.StartTime = ((obj3.stop).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy hh:mm:ss tt"); + + string dateTimeFormat = StaticMembers.is24hours ? "MM/dd/yyyy HH:mm:ss" : "MM/dd/yyyy hh:mm:ss tt"; + tmpData.StartTime = ((obj3.stop).GetDTLocalFromSeconds()).ToString(dateTimeFormat); + timeforStartCalc = obj3.stop; if (!StaticMembers.LATLNGforDinamicReports) @@ -213,10 +214,10 @@ namespace ReportsLibrary tmpData = new EndOfDayData(); RowNumber++; tmpData.Trip = Convert.ToString(RowNumber); - //tmpData.StartTime = (new ConvertDT().GetDTLocalFromSeconds(lastStopTimeStop)).ToString(); + - if (StaticMembers.is24hours) tmpData.StartTime = ((lastStopTimeStop).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy HH:mm:ss"); - else tmpData.StartTime = ((lastStopTimeStop).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy hh:mm:ss tt"); + string dateTimeFormat = StaticMembers.is24hours ? "MM/dd/yyyy HH:mm:ss" : "MM/dd/yyyy hh:mm:ss tt"; + tmpData.StartTime = ((lastStopTimeStop).GetDTLocalFromSeconds()).ToString(dateTimeFormat); timeforStartCalc = lastStopTimeStop; tmpData.StartAddress = lastStopNameStop; @@ -226,26 +227,35 @@ namespace ReportsLibrary { totaltime += (obj3.start - timeforStartCalc); tmpData.StopTime = ((obj3.start).GetDTLocalFromSeconds()).ToString(); + if (!StaticMembers.LATLNGforDinamicReports) { if ((StaticMembers.MapType == MapTYPE.Google) || (StaticMembers.MapType == MapTYPE.ArcGis)) tmpData.StopAddress = StaticMembers.IdReportHS[obj3.name].ToString(); } - else tmpData.StopAddress = "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString(); + else + tmpData.StopAddress = "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString(); + difidx = (Double)DriveList[count3]; total += difidx; - if (StaticMembers.isInMile) tmpData.Distance = (Math.Round(((difidx * 0.621371192) * 1000)) / 1000).ToString(); - else tmpData.Distance = difidx.ToString(); - if (tmpData != null) Ret.Add(tmpData); + if (StaticMembers.isInMile) + tmpData.Distance = (Math.Round(((difidx * 0.621371192) * 1000)) / 1000).ToString(); + else + tmpData.Distance = difidx.ToString(); + + if (tmpData != null) + Ret.Add(tmpData); } lastStopIsStop = true; lastStopTimeStop = obj3.stop; + if (!StaticMembers.LATLNGforDinamicReports) { if ((StaticMembers.MapType == MapTYPE.Google) || (StaticMembers.MapType == MapTYPE.ArcGis)) lastStopNameStop = StaticMembers.IdReportHS[obj3.name].ToString(); } - else lastStopNameStop = "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString(); + else + lastStopNameStop = "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString(); } catch (Exception ex) { @@ -264,8 +274,12 @@ namespace ReportsLibrary tmpData.StartAddress = String.Format("{0:00}", (int)(totaltime / 3600)) + ":" + String.Format("{0:00}", ((int)(((int)(totaltime % 3600)) / 60))) + ":" + String.Format("{0:00}", ((int)(totaltime % 60))); tmpData.StopTime = ""; tmpData.StopAddress = "Total distance:"; - if (StaticMembers.isInMile) tmpData.Distance = (Math.Round(((total * 0.621371192) * 1000)) / 1000).ToString(); - else tmpData.Distance = total.ToString(); + + if (StaticMembers.isInMile) + tmpData.Distance = (Math.Round(((total * 0.621371192) * 1000)) / 1000).ToString(); + else + tmpData.Distance = total.ToString(); + Ret.Add(tmpData); } @@ -289,149 +303,181 @@ namespace ReportsLibrary [DataObjectMethod(DataObjectMethodType.Select)] public List GetALL() { - if (!StaticMembers.IsHistroyNotStop) // aici prelucrez date cand e raport de stop sau IDLE + + if (StaticMembers.IsHistroyNotStop) + return StaticMembers.HistDataReport; + + + //if (!StaticMembers.IsHistroyNotStop) // aici prelucrez date cand e raport de stop sau IDLE + + CalcStops calcStop = new CalcStops(true);//mapControl + calcStop.get_position(StaticMembers.PositionList); + + try + { + if (!StaticMembers.IsIdle) + { + calcStop.calculate_zone(); + calcStop.calc_zone_with_delta2(); + calcStop.create_stop_list(); + } + else + { + calcStop.create_stop_list_EON(StaticMembers.IDLETime); + } + } + catch (Exception ex) + { + SM.Debug("Database connection failed:" + ex.ToString()); + } + + if (StaticMembers.StartStop) + { + calcStop.StartStopCalc(); + calcStop.StartStopCalcPosition(); + } + + ArrayList numbers = new ArrayList(); + ReverseGeocoding volltmpGo = new ReverseGeocoding(ReverseGeoOSM); + + //calcul addressa Google + if (!StaticMembers.LATLNGforDinamicReports) { - CalcStops calcStop = new CalcStops(true);//mapControl - calcStop.get_position(StaticMembers.PositionList); try { - if (!StaticMembers.IsIdle) + if ((StaticMembers.MapType == MapTYPE.ArcGis) || (StaticMembers.MapType == MapTYPE.Google)) { - calcStop.calculate_zone(); - calcStop.calc_zone_with_delta2(); - calcStop.create_stop_list(); - } - else - { - calcStop.create_stop_list_EON(StaticMembers.IDLETime); + foreach (Stops obj3 in calcStop.StopsList) + { + StaticMembers.AddrGISQueue.Enqueue(new AddrAndID(Convert.ToInt32(obj3.name), obj3.lat, obj3.lng)); + if (StaticMembers.ShowCoordinates) + StaticMembers.IdReportHS.Add(obj3.name, "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString()); + else + StaticMembers.IdReportHS.Add(obj3.name, obj3.address != "" ? obj3.address : volltmpGo.getAddressLATLNG(obj3.lat, obj3.lng)); + } + + if (!StaticMembers.ShowCoordinates) + { + bool retrynew = true; + int cntmax = 0; + foreach (String obj in StaticMembers.IdReportHS.Keys) + numbers.Add(obj); + + while (retrynew) + { + cntmax++; + retrynew = false; + + foreach (String obj in numbers) + { + if ((String)StaticMembers.IdReportHS[obj] == "no address") + { + SM.Debug("Sta 180 msec"); + Thread.Sleep(180); + retrynew = true; + } + } + + if (cntmax > 10) + retrynew = false; + } + } } } catch (Exception ex) { - SM.Debug("Database connection failed:" + ex.ToString()); + SM.Debug("Erorr on compute adress for report:" + ex.ToString()); } + } - if (StaticMembers.StartStop) - { - calcStop.StartStopCalc(); - calcStop.StartStopCalcPosition(); - } - ArrayList numbers = new ArrayList(); - ReverseGeocoding volltmpGo = new ReverseGeocoding(ReverseGeoOSM); - //calcul addressa Google - if (!StaticMembers.LATLNGforDinamicReports) + int countStops = -1; + long stoptime, starttime; + StopData tmpData = null; + Int32 RowNumber = 0; + + var list = new List(); + + foreach (Stops obj3 in calcStop.StopsList) + { + countStops++; + if (obj3.type == car_state_e.CAR_STOP) { + // Populate StopData object + tmpData = new StopData(); try { - if ((StaticMembers.MapType == MapTYPE.ArcGis) || (StaticMembers.MapType == MapTYPE.Google)) - { - foreach (Stops obj3 in calcStop.StopsList) - { - StaticMembers.AddrGISQueue.Enqueue(new AddrAndID(Convert.ToInt32(obj3.name), obj3.lat, obj3.lng)); - if (StaticMembers.ShowCoordinates) - StaticMembers.IdReportHS.Add(obj3.name, "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString()); - else - StaticMembers.IdReportHS.Add(obj3.name, obj3.address != "" ? obj3.address : volltmpGo.getAddressLATLNG(obj3.lat, obj3.lng)); - } - if (!StaticMembers.ShowCoordinates) - { - bool retrynew = true; - int cntmax = 0; - foreach (String obj in StaticMembers.IdReportHS.Keys) - numbers.Add(obj); + RowNumber++; - while (retrynew) - { - cntmax++; - retrynew = false; - foreach (String obj in numbers) - { - if ((String)StaticMembers.IdReportHS[obj] == "no address") - { - SM.Debug("Sta 180 msec"); - Thread.Sleep(180); - retrynew = true; - } - } - if (cntmax > 10) retrynew = false; - } - } + tmpData.Data = ((obj3.start).GetDTLocalFromSeconds()).Date.ToShortDateString(); + tmpData.Time = ((Int32)obj3.start).TimeOfDayHHMMLocal(!StaticMembers.is24hours); + + // get location + if (!StaticMembers.LATLNGforDinamicReports) + { + if ((StaticMembers.MapType == MapTYPE.Google) || (StaticMembers.MapType == MapTYPE.ArcGis)) + tmpData.Location = StaticMembers.IdReportHS[obj3.name].ToString(); } + else + tmpData.Location = "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString(); + + + // calculate duration + stoptime = obj3.stop; + starttime = obj3.start; + if (countStops < (calcStop.StopsList.Count - 1)) + { + if (((Stops)(calcStop.StopsList[countStops + 1])).type == car_state_e.CAR_START) + stoptime = ((Stops)(calcStop.StopsList[countStops + 1])).stop; + } + + + tmpData.Duration = FormatDuration(starttime, stoptime); } catch (Exception ex) { - SM.Debug("Erorr on compute adress for report:" + ex.ToString()); + SM.Debug("EX:" + ex.ToString()); } + + // add to list + list.Add(tmpData); } - - int countStops = -1; - long stoptime, starttime; - StopData tmpData = null; - Int32 RowNumber = 0; - var Ret = new List(); - Int64 diffTime; - foreach (Stops obj3 in calcStop.StopsList) - { - countStops++; - if (obj3.type == car_state_e.CAR_STOP) - { - tmpData = new StopData(); - try - { - RowNumber++; - tmpData.Data = ((obj3.start).GetDTLocalFromSeconds()).Date.ToShortDateString(); - tmpData.Time = ((Int32)obj3.start).TimeOfDayHHMMLocal(!StaticMembers.is24hours); - if (!StaticMembers.LATLNGforDinamicReports) - { - if ((StaticMembers.MapType == MapTYPE.Google) || (StaticMembers.MapType == MapTYPE.ArcGis)) - tmpData.Location = StaticMembers.IdReportHS[obj3.name].ToString(); - } - else tmpData.Location = "LAT:" + Math.Round(obj3.lat, 5).ToString() + " , LNG:" + Math.Round(obj3.lng, 5).ToString(); - stoptime = obj3.stop; - starttime = obj3.start; - if (countStops < (calcStop.StopsList.Count - 1)) - { - if (((Stops)(calcStop.StopsList[countStops + 1])).type == car_state_e.CAR_START) - stoptime = ((Stops)(calcStop.StopsList[countStops + 1])).stop; - } - - diffTime = stoptime - starttime; - Int32 Hour = (Int32)(diffTime / 3600); - Int32 Minute = (Int32)((diffTime - Hour * 3600) / 60); - String toReturn = ""; - if (Hour >= 10) - toReturn = toReturn + Hour.ToString() + ":"; - else - toReturn = toReturn + "0" + Hour.ToString() + ":"; - - if (Minute >= 10) - toReturn = toReturn + Minute.ToString(); - else - toReturn = toReturn + "0" + Minute.ToString(); - tmpData.Duration = toReturn; - } - catch (Exception ex) - { - SM.Debug("EX:" + ex.ToString()); - } - Ret.Add(tmpData); - } - } - - //de la google address - if ((StaticMembers.MapType == MapTYPE.Google) || (StaticMembers.MapType == MapTYPE.ArcGis)) - { - foreach (String obj in numbers) - StaticMembers.IdReportHS.Remove(obj); - numbers.Clear(); - } - return Ret; } - else // aici prelucrez date cand e raport de history + + //de la google address + if ((StaticMembers.MapType == MapTYPE.Google) || (StaticMembers.MapType == MapTYPE.ArcGis)) { - return StaticMembers.HistDataReport; + foreach (String obj in numbers) + StaticMembers.IdReportHS.Remove(obj); + + numbers.Clear(); } + return list; + + } + + + private string FormatDuration(long starttime, long stoptime) + { + + Int64 diffTime = stoptime - starttime; + Int32 Hour = (Int32)(diffTime / 3600); + Int32 Minute = (Int32)((diffTime - Hour * 3600) / 60); + + return Hour.ToString("D2") + ":" + Minute.ToString("D2"); + + } + } + + [DataObject] + public class BatchHistoryDataObj + { + [DataObjectMethod(DataObjectMethodType.Select)] + public List GetALL() + { + return StaticMembers.BatchHistoryReport; + } + } [DataObject] @@ -440,9 +486,7 @@ namespace ReportsLibrary [DataObjectMethod(DataObjectMethodType.Select)] public List GetALL() { - Double distance = .001f; - Double AllDistance = .001f; - var Ret = new List(); + var fleetDataList = new List(); if (!StaticMembers.IsSMSLocationNotFleet) { @@ -468,91 +512,112 @@ namespace ReportsLibrary calcStop.StartStopCalcPosition(); } - //distance - AllDistance = 0; - Boolean first = true; - distance = 0; - Int32 timeStart = 0, timeStop = 0, oldStop = 0; - if (calcStop.StopsList.Count > 1) - { - Stops prevObj = null; - foreach (Stops obj in calcStop.StopsList) - { - if (prevObj != null) - { - if (!((prevObj.type == car_state_e.CAR_STOP) && (obj.type == car_state_e.CAR_START))) - { - AllDistance += distance; - - if (first) - { - timeStart = prevObj.stop; - first = false; - } - else timeStart = oldStop; - timeStop = obj.start; - oldStop = obj.stop; - AllDistance += calcStop.calcDistance(timeStart, timeStop); - //DriveList.Add(distance); - } - else { first = true; } - } - prevObj = obj; - } - } - - int startnr = 0; - Stops prevStopObj = null; - foreach (Stops obj in calcStop.StopsList) - { - if (obj.type == car_state_e.CAR_START) - startnr++; - - if (prevStopObj != null) - if ((prevStopObj.type == car_state_e.CAR_STOP) && (obj.type == car_state_e.CAR_STOP)) - startnr++; - prevStopObj = obj; - } + // populate FleetData FleetData tmpData = new FleetData(); tmpData.Name = veh.Name; - if (StaticMembers.isInMile) tmpData.Distance = (Math.Round(((AllDistance * 0.621371192) * 1000)) / 1000).ToString(); - else tmpData.Distance = AllDistance.ToString(); - if ((calcStop.StopsList.Count == 0) || (calcStop.StopsList.Count == 1)) tmpData.Trips = "0"; - else tmpData.Trips = startnr.ToString(); + tmpData.Distance = calculatetDistance(calcStop); + + tmpData.Trips = "0"; + if (calcStop.StopsList.Count > 1) + tmpData.Trips = calculateTrips(calcStop); + tmpData.Start = ""; tmpData.Stop = ""; + + if ((calcStop.StopsList.Count != 0) && (calcStop.StopsList.Count != 1)) { - if (StaticMembers.is24hours) - { - tmpData.Start = ((((Stops)(calcStop.StopsList[0])).stop).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy HH:mm:ss"); - tmpData.Stop = ((((Stops)(calcStop.StopsList[calcStop.StopsList.Count - 1])).start).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy HH:mm:ss"); - } - else - { - tmpData.Start = ((((Stops)(calcStop.StopsList[0])).stop).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy hh:mm:ss tt"); - tmpData.Stop = ((((Stops)(calcStop.StopsList[calcStop.StopsList.Count - 1])).start).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy hh:mm:ss tt"); - } + string formatDate = StaticMembers.is24hours ? "MM/dd/yyyy HH:mm:ss" : "MM/dd/yyyy HH:mm:ss tt"; + tmpData.Start = ((((Stops)(calcStop.StopsList[0])).stop).GetDTLocalFromSeconds()).ToString(formatDate); + tmpData.Stop = ((((Stops)(calcStop.StopsList[calcStop.StopsList.Count - 1])).start).GetDTLocalFromSeconds()).ToString(formatDate); + } - Ret.Add(tmpData); + + // add to list + fleetDataList.Add(tmpData); } } else { foreach (SMS_Location sms_obj in StaticMembers.SMSLocList) { - FleetData tmpData = new FleetData(); - tmpData.Name = sms_obj.Name; - tmpData.Start = sms_obj.Data; - tmpData.Stop = sms_obj.Address; - tmpData.Trips = sms_obj.Time; - tmpData.Distance = sms_obj.Text_mess; - Ret.Add(tmpData); + + fleetDataList.Add( new FleetData() + { + Name = sms_obj.Name, + Start = sms_obj.Data, + Stop = sms_obj.Address, + Trips = sms_obj.Time, + Distance = sms_obj.Text_mess + }); } } - return Ret; + return fleetDataList; + } + + + private string calculateTrips(CalcStops calcStop) + { + int startnr = 0; + Stops prevStopObj = null; + foreach (Stops obj in calcStop.StopsList) + { + if (obj.type == car_state_e.CAR_START) + startnr++; + + if (prevStopObj != null) + if ((prevStopObj.type == car_state_e.CAR_STOP) && (obj.type == car_state_e.CAR_STOP)) + startnr++; + + prevStopObj = obj; + } + + return startnr.ToString(); + } + + private string calculatetDistance(CalcStops calcStop) + { + Double AllDistance = 0; + Boolean first = true; + Double distance = 0; + Int32 timeStart = 0, timeStop = 0, oldStop = 0; + if (calcStop.StopsList.Count > 1) + { + Stops prevObj = null; + foreach (Stops obj in calcStop.StopsList) + { + if (prevObj != null) + { + if (!((prevObj.type == car_state_e.CAR_STOP) && (obj.type == car_state_e.CAR_START))) + { + AllDistance += distance; + + if (first) + { + timeStart = prevObj.stop; + first = false; + } + else + timeStart = oldStop; + + timeStop = obj.start; + oldStop = obj.stop; + AllDistance += calcStop.calcDistance(timeStart, timeStop); + //DriveList.Add(distance); + } + else { first = true; } + } + prevObj = obj; + } + } + + if (StaticMembers.isInMile) + return (Math.Round(((AllDistance * 0.621371192) * 1000)) / 1000).ToString(); + + return AllDistance.ToString(); + } } @@ -569,9 +634,8 @@ namespace ReportsLibrary if (StaticMembers.ReportType == rep_type.SPEED) { int[,] array2D = new int[,] { { 20, 50 }, { 50, 70 }, { 70, 90 }, { 90, 400 } }; - var list = new List(); - foreach (SpeedData sd in StaticMembers.SpeedingList) - list.Add(sd.Speed); + var list = StaticMembers.SpeedingList.Select(x => x.Speed); + for (int i = 0; i < array2D.GetLength(0); i++) { var result = list.Select(int.Parse).Count(r => r >= array2D[i, 0] && r < array2D[i, 1]); @@ -582,6 +646,7 @@ namespace ReportsLibrary } } } + if (StaticMembers.ReportType == rep_type.JOB_TICKETING) { var query = StaticMembers.SpeedingList.GroupBy(n => n.Time, @@ -596,6 +661,7 @@ namespace ReportsLibrary } } } + return ChartDataList; } @@ -617,12 +683,12 @@ namespace ReportsLibrary ChartDataList.Add(cd); } } + if (StaticMembers.ReportType == rep_type.HIST) { int[,] array2D = new int[,] { { 0, 40 }, { 40, 70 }, { 70, 90 }, { 90, 400 } }; - var list = new List(); - foreach (StopData sd in StaticMembers.HistDataReport) - list.Add(sd.Duration); + var list = StaticMembers.HistDataReport.Select(x => x.Duration); + for (int i = 0; i < array2D.GetLength(0); i++) { var result = list.Select(int.Parse).Count(r => r >= array2D[i, 0] && r < array2D[i, 1]); diff --git a/ReportsLibrary/ReportsLibrary.csproj b/ReportsLibrary/ReportsLibrary.csproj index 600a1bc..97eac69 100644 --- a/ReportsLibrary/ReportsLibrary.csproj +++ b/ReportsLibrary/ReportsLibrary.csproj @@ -77,6 +77,12 @@ + + Component + + + BatchHistoryReport.cs + @@ -1144,6 +1150,9 @@ + + BatchHistoryReport.cs + EndOfDay.cs Designer @@ -1170,6 +1179,7 @@ + diff --git a/SafeMobileLIB_DLL/DBmanagers/DBRadioTypeManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBRadioTypeManager.cs index 154495a..1ef92bf 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBRadioTypeManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBRadioTypeManager.cs @@ -28,7 +28,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = "select count(value) from \"userSettings\" where key=\'radiotype\'"; + string command = "SELECT COUNT(value) FROM \"userSettings\" WHERE key=\'radiotype\'"; object result = null; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) @@ -82,13 +82,7 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - resp = reader.GetValue(0).ToString(); - } - } + resp = cmd.ExecuteScalar().ToString(); } } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBReportingManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBReportingManager.cs index 6b80344..59a6aab 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBReportingManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBReportingManager.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.Text; using Npgsql; @@ -18,9 +19,9 @@ namespace SafeMobileLib public List get_ALLAlarm(String glwhere, Boolean is24hours, Boolean isInMile, Boolean DayFirst, Hashtable VehIDHash, Hashtable ZoneIDHash, Hashtable LandIDHash, Hashtable vehicleHT, string milesh, string kmh) { - + int sc_id = 0, timeGMT = 0, zone_id = 0, speed = 0, telemetry_id = 0, action = 0, type = 0; String tmpglwhere = glwhere; - String TimeVal = ""; + List HistDataReport = new List(); try @@ -39,21 +40,25 @@ namespace SafeMobileLib { using (NpgsqlDataReader dr = cmd.ExecuteReader()) { + while (dr.Read()) { - TimeVal = dr.GetInt32(1).GetRegionalFormat(is24hours, DayFirst); - var tmp = new StopData - { - Location = TimeVal, - Duration = "", - Time = "Emergency", - Data = (VehIDHash[dr.GetInt32(0)] != null) ? (String)VehIDHash[dr.GetInt32(0)] : "", - timeGMT = dr.GetInt32(1) - }; + sc_id = Convert.ToInt32(dr["sc_id"]); - if (tmp.Data != "") - HistDataReport.Add(tmp); + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") + { + timeGMT = Convert.ToInt32(dr["timeGMT"]); + + HistDataReport.Add(new StopData + { + Location = timeGMT.GetRegionalFormat(is24hours, DayFirst), + Duration = "", + Time = "Emergency", + Data = (String)VehIDHash[sc_id], + timeGMT = timeGMT + }); + } } } } @@ -68,32 +73,41 @@ namespace SafeMobileLib { while (dr.Read()) { - string descStr = ((uint)dr.GetInt32(2) == 1) ? "OUT " : "IN "; + + sc_id = Convert.ToInt32(dr["sc_id"]); - if (dr.GetInt32(4) == 1) + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") { - if (ZoneIDHash[dr.GetInt32(1)] != null) - descStr = descStr + ((ZoneClass)ZoneIDHash[dr.GetInt32(1)]).Name; + timeGMT = Convert.ToInt32(dr["timeGMT"]); + zone_id = Convert.ToInt32(dr["zone_id"]); + action = Convert.ToInt32(dr["action"]); + type = Convert.ToInt32(dr["type"]); + + string descStr = ((uint)action == 1) ? "OUT " : "IN "; + + + if (type == 1) + { + if (ZoneIDHash[zone_id] != null) + descStr = descStr + ((ZoneClass)ZoneIDHash[zone_id]).Name; + } + else + { + if (LandIDHash[zone_id] != null) + descStr = descStr + ((String)LandIDHash[zone_id]); + } + + + HistDataReport.Add(new StopData + { + Location = timeGMT.GetRegionalFormat(is24hours, DayFirst), + Duration = descStr, + Time = "Geo-Fence", + Data = (String)VehIDHash[sc_id], + timeGMT = timeGMT + }); } - else - { - if (LandIDHash[dr.GetInt32(1)] != null) - descStr = descStr + ((String)LandIDHash[dr.GetInt32(1)]); - } - - TimeVal = dr.GetInt32(3).GetRegionalFormat(is24hours, DayFirst); - var tmp = new StopData - { - Location = TimeVal, - Duration = descStr, - Time = "Geo-Fence", - Data = (VehIDHash[dr.GetInt32(0)] != null) ? (String)VehIDHash[dr.GetInt32(0)] : "", - timeGMT = dr.GetInt32(3) - }; - - if (tmp.Data != "") - HistDataReport.Add(tmp); } } } @@ -106,17 +120,24 @@ namespace SafeMobileLib { while (dr.Read()) { - TimeVal = dr.GetInt32(0).GetRegionalFormat(is24hours, DayFirst); - var tmp = new StopData + sc_id = Convert.ToInt32(dr["sc_id"]); + + + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") { - Location = TimeVal, - Duration = (isInMile) ? ((int)(dr.GetInt32(2) * 0.621371192)).ToString() + " " + milesh : dr.GetInt32(2).ToString() + " " + kmh, - Time = "Speeding", - Data = (VehIDHash[dr.GetInt32(1)] != null) ? (String)VehIDHash[dr.GetInt32(1)] : "", - timeGMT = dr.GetInt32(0) - }; - if (tmp.Data != "") - HistDataReport.Add(tmp); + timeGMT = Convert.ToInt32(dr["timeGMT"]); + speed = Convert.ToInt32(dr["speed"]); + + + HistDataReport.Add(new StopData + { + Location = timeGMT.GetRegionalFormat(is24hours, DayFirst), + Duration = (isInMile) ? ((int)(speed * 0.621371192)).ToString() + " " + milesh : speed.ToString() + " " + kmh, + Time = "Speeding", + Data = (String)VehIDHash[sc_id], + timeGMT = timeGMT + }); + } } } } @@ -130,29 +151,31 @@ namespace SafeMobileLib { using (NpgsqlDataReader dr = cmd.ExecuteReader()) { + while (dr.Read()) { - String actionName = ""; - if (VehIDHash[dr.GetInt32(0)] != null) + + sc_id = Convert.ToInt32(dr["sc_id"]); + + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") { - foreach (TelemetryObj obj in ((VehicleForReports)vehicleHT[(String)VehIDHash[dr.GetInt32(0)]]).telemList) - if (obj.Id == dr.GetInt32(2)) { actionName = obj.Name; break; } + + telemetry_id = Convert.ToInt32(dr["telemetry_id"]); + timeGMT = Convert.ToInt32(dr["timeGMT"]); + + // get action name + var list = ((VehicleForReports)vehicleHT[(String)VehIDHash[sc_id]]).telemList; + string actionName = list.Where(x => x.Id == telemetry_id).Select(x => x.Name).FirstOrDefault(); + + HistDataReport.Add(new StopData + { + Location = timeGMT.GetRegionalFormat(is24hours, DayFirst), + Duration = actionName, + Time = "Telemetry", + Data = (String)VehIDHash[sc_id], + timeGMT = timeGMT + }); } - - TimeVal = dr.GetInt32(1).GetRegionalFormat(is24hours, DayFirst); - - - var tmp = new StopData - { - Location = TimeVal, - Duration = actionName, - Time = "Telemetry", - Data = (VehIDHash[dr.GetInt32(0)] != null) ? (String)VehIDHash[dr.GetInt32(0)] : "", - timeGMT = dr.GetInt32(1) - }; - - if (tmp.Data != "") - HistDataReport.Add(tmp); } } } @@ -176,6 +199,7 @@ namespace SafeMobileLib { List SpeedingList = new List(); Int32 count50000 = 0; + Int32 sc_id = 0; try { @@ -195,23 +219,27 @@ namespace SafeMobileLib { count50000++; - var tmp = new SpeedData + sc_id = Convert.ToInt32(dr["sc_id"]); + + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") { - Name = (VehIDHash[dr.GetInt32(1)] != null) ? (String)VehIDHash[dr.GetInt32(1)] : "", - Speed = (isInMile) ? ((int)(dr.GetInt32(2) * 0.621371192)).ToString() : dr.GetInt32(2).ToString(), - Time = dr.GetInt32(0).TimeOfDayHHMMLocal(!is24hours), - Data = dr.GetInt32(0).GetDTLocalFromSeconds().Date.ToShortDateString(), - Address = dr.GetString(3), - sc_id = dr.GetInt32(1), - timeGMT = dr.GetInt32(0), - lat = (dr.IsDBNull(4) ? 0 : dr.GetDouble(4)), - lng = (dr.IsDBNull(5) ? 0 : dr.GetDouble(5)) - }; + + SpeedingList.Add(new SpeedData + { + Name = (String)VehIDHash[sc_id], + Speed = (isInMile) ? ((int)(dr.GetInt32(2) * 0.621371192)).ToString() : dr.GetInt32(2).ToString(), + Time = dr.GetInt32(0).TimeOfDayHHMMLocal(!is24hours), + Data = dr.GetInt32(0).GetDTLocalFromSeconds().Date.ToShortDateString(), + Address = dr.GetString(3), + sc_id = sc_id, + timeGMT = dr.GetInt32(0), + lat = (dr.IsDBNull(4) ? 0 : dr.GetDouble(4)), + lng = (dr.IsDBNull(5) ? 0 : dr.GetDouble(5)) + }); - if (tmp.Name != "") - SpeedingList.Add(tmp); - - if (count50000 > 50000) break; + if (count50000 > 50000) + break; + } } } } @@ -231,11 +259,13 @@ namespace SafeMobileLib List LandList = new List(); String newglwhere = glwhere; String ToAdd = " type=2 "; + if (typ == rep_type.GEOFENC) ToAdd = " type=1 "; if (newglwhere.Length > 1) newglwhere = newglwhere + " and " + ToAdd; - else newglwhere = " where " + ToAdd; + else + newglwhere = " where " + ToAdd; try { @@ -249,34 +279,41 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { + + int sc_id = 0, zone_id = 0; + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { - LandData tmp = new LandData(); - if (VehIDHash[dr.GetInt32(0)] != null) - tmp.Name = (String)VehIDHash[dr.GetInt32(0)]; - else tmp.Name = ""; + sc_id = Convert.ToInt32(dr["sc_id"]); + zone_id = Convert.ToInt32(dr["zone_id"]); - tmp.LandType = ((uint)dr.GetInt32(2) == 1) ? "OUT" : "IN"; - tmp.Time = dr.GetInt32(3).GetRegionalFormat(is24hours, DayFirst); - tmp.LandName = dr.GetInt32(0).TimeOfDayHHMMLocal(); - - if (typ == rep_type.GEOFENC) + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") { - if (ZoneIDHash[dr.GetInt32(1)] != null) - tmp.LandName = ((ZoneClass)ZoneIDHash[dr.GetInt32(1)]).Name; - } - else - { - SM.Debug("LandID" + dr.GetInt32(1)); - if (LandIDHash[dr.GetInt32(1)] != null) - tmp.LandName = (String)LandIDHash[dr.GetInt32(1)]; - } - if (tmp.Name != "") + + LandData tmp = new LandData(); + + tmp.Name = (String)VehIDHash[sc_id]; + tmp.LandType = Convert.ToInt32(dr["action"]) == 1 ? "OUT" : "IN"; + tmp.Time = Convert.ToInt32(dr["timeGMT"]).GetRegionalFormat(is24hours, DayFirst); + tmp.LandName = sc_id.TimeOfDayHHMMLocal(); + + if (typ == rep_type.GEOFENC) + { + if (ZoneIDHash[zone_id] != null) + tmp.LandName = ((ZoneClass)ZoneIDHash[zone_id]).Name; + } + else + { + if (LandIDHash[zone_id] != null) + tmp.LandName = (String)LandIDHash[zone_id]; + } + LandList.Add(tmp); + } } } } @@ -293,8 +330,9 @@ namespace SafeMobileLib public List get_log_view_all(String glwhere, Boolean is24hours, Boolean DayFirst, Hashtable VehIMEIHash) { String tmpname = ""; - String TimeVal = ""; string Stat = ""; + string imei = ""; + int timeGMT = 0; List ONOFFList = new List(); try @@ -312,35 +350,31 @@ namespace SafeMobileLib NpgsqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { - if (VehIMEIHash[dr.GetString(0)] != null) tmpname = (VehIMEIHash[dr.GetString(0)] as String); - else tmpname = ""; + + imei = dr["imei"].ToString(); + timeGMT = Convert.ToInt32(dr["timeGMT"]); + + tmpname = ""; + if (VehIMEIHash[imei] != null) + tmpname = (VehIMEIHash[imei] as String); if (tmpname != "") { - TimeVal = dr.GetInt32(1).GetRegionalFormat(is24hours, DayFirst); switch (dr.GetInt32(2)) { - case 0: - Stat = "OFF"; - break; - case 1: - Stat = "ON"; - break; - case 9: - Stat = "MADE OFF"; - break; - case 10: - Stat = "MADE ON"; - break; + case 0: Stat = "OFF"; break; + case 1: Stat = "ON"; break; + case 9: Stat = "MADE OFF"; break; + case 10: Stat = "MADE ON"; break; } - var tmp = new ONOFFData - { - Name = tmpname, - Time = TimeVal, - Status = Stat - }; - ONOFFList.Add(tmp); + + ONOFFList.Add( new ONOFFData + { + Name = tmpname, + Time = timeGMT.GetRegionalFormat(is24hours, DayFirst), + Status = Stat + }); } } } @@ -357,6 +391,8 @@ namespace SafeMobileLib public List get_EMERG(String glwhere, Boolean is24hours, Hashtable VehIDHash) { List ONOFFList = new List(); + int timeGMT = 0, sc_id = 0; + try { using (NpgsqlConnection connection = new NpgsqlConnection()) @@ -370,21 +406,30 @@ namespace SafeMobileLib { using (NpgsqlDataReader dr = cmd.ExecuteReader()) { + + string formatDateTime = is24hours ? "MM/dd/yyyy HH:mm:ss" : "MM/dd/yyyy hh:mm:ss tt"; + while (dr.Read()) { - var tmp = new ONOFFData - { - Name = (VehIDHash[dr.GetInt32(1)] != null) ? (String)VehIDHash[dr.GetInt32(1)] : "", - Time = (is24hours) ? (dr.GetInt32(0).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy HH:mm:ss") : (dr.GetInt32(0).GetDTLocalFromSeconds()).ToString("MM/dd/yyyy hh:mm:ss tt"), - Status = dr.GetString(2), - sc_id = dr.GetInt32(1), - lat = dr.GetDouble(3), - lng = dr.GetDouble(4), - timeGMT = dr.GetInt32(0) - }; + sc_id = Convert.ToInt32(dr["sc_id"]); - if (tmp.Name != "") - ONOFFList.Add(tmp); + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") + { + + timeGMT = Convert.ToInt32(dr["timegmt"]); + + ONOFFList.Add( new ONOFFData + { + Name = (String)VehIDHash[sc_id], + Time = timeGMT.GetDTLocalFromSeconds().ToString(formatDateTime), + Status = dr["address"].ToString(), + sc_id = sc_id, + lat = Convert.ToDouble(dr["lat"]), + lng = Convert.ToDouble(dr["lng"]), + timeGMT = timeGMT + }); + + } } } } @@ -398,6 +443,179 @@ namespace SafeMobileLib return ONOFFList; } + + + private BatchHistoryData GetData(NpgsqlDataReader dr, bool isInMile, bool is24hours, bool getAddress = false) + { + int timegmt = 0; + double lat = 0, lng = 0; + + BatchHistoryData batchHistObj = null; + + + + try + { + + + + lat = Convert.ToDouble(dr["lat"]); + lng = Convert.ToDouble(dr["lng"]); + timegmt = Convert.ToInt32(dr["timegmt"]); + + 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(), + Time = timegmt.TimeOfDayHHMMSSLocal(!is24hours), + Date = timegmt.GetDTLocalFromSeconds().Date.ToShortDateString() + + }; + + + + } + catch (Exception ex) + { + Console.WriteLine(ex.Message, ConsoleColor.Red); + } + + return batchHistObj; + + } + + + + private string FormatCommandBatchHistory(string sc_ids, int startdate, int enddate, bool isInMile, bool is24hours, int limit = Int32.MaxValue, bool getAddress = false, bool getOnlyValidPositions = false) + { + string address = ""; + string join_getiing_address = ""; + string onlyValidPositions = ""; + + if (getAddress) + { + address = ",a.address"; + join_getiing_address = "LEFT JOIN address a ON a.lat = ROUND(z.lat::numeric, 4) AND a.lng = ROUND(z.lng::numeric, 4) "; + } + + if (getOnlyValidPositions) + { + onlyValidPositions = " AND m.lat <> 0.0 AND m.lng <> 0.0 "; + } + + + string command = $" SELECT x.grp_name as department, x.veh_name as unit, z.lat, z.lng, z.timegmt, z.speed {address} " + + " FROM " + + " (SELECT m.sc_id, m.timegmt, m.lat, m.lng, m.speed " + + " FROM messages m " + + $" WHERE m.timegmt BETWEEN {startdate} AND {enddate} " + + $" {onlyValidPositions}" + + $" AND m.sc_id IN ({sc_ids}) { (limit != Int32.MaxValue ? $"LIMIT {limit}" : "")} " + + " )z " + + " INNER JOIN " + + " ( " + + " SELECT sh.sc_id, v.name as veh_name, g.name as grp_name " + + $" FROM (SELECT * FROM subscriber_history WHERE sc_id IN ({sc_ids})) sh " + + " INNER JOIN vehicle v ON v.id = sh.veh_id " + + " INNER JOIN vehicle_group vg ON sh.sc_id = vg.sc_id " + + " INNER JOIN groups g ON vg.grp_ip = g.id " + + " ) x ON z.sc_id = x.sc_id " + + $"{join_getiing_address}" + + " ORDER BY x.grp_name, x.veh_name, z.timegmt "; + + return command; + } + + public List getBatchHistory(string sc_ids, int startdate, int enddate , bool isInMile, bool is24hours, int limit = Int32.MaxValue, bool getAddress = false, bool getOnlyValidPositions = false) + { + var list = new List(); + + using (NpgsqlConnection connection = new NpgsqlConnection()) + { + + connection.ConnectionString = getConnectionString(); + connection.Open(); + + string command = FormatCommandBatchHistory(sc_ids, startdate, enddate, isInMile, is24hours, limit, getAddress, getOnlyValidPositions); + + + + using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) + { + + + cmd.CommandTimeout = 1200; + + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + + while (dr.Read()) + { + + BatchHistoryData data = GetData(dr, isInMile, is24hours, getAddress); + list.Add(data); + } + } + } + } + + return list; + + } + + public void saveBatchHistoryToCsv(string filePath, List excludeColumns, string sc_ids, int startdate, int enddate, bool isInMile, bool is24hours, int limit = Int32.MaxValue, bool getAddress = false, bool getOnlyValidPositions = false) + { + using (NpgsqlConnection connection = new NpgsqlConnection()) + { + + connection.ConnectionString = getConnectionString(); + connection.Open(); + + string command = FormatCommandBatchHistory(sc_ids, startdate, enddate, isInMile, is24hours, limit, getAddress, getOnlyValidPositions); + using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) + { + + + cmd.CommandTimeout = 1200; + + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + // Being a huge report we get record by record and save them into file (without keep them). + using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filePath, false)) + { + + //================ + // write header + //================ + Utils.HeaderToCsv(sw, excludeColumns); + + while (dr.Read()) + { + + + //================ + // write rows + //================ + + BatchHistoryData data = GetData(dr, isInMile, is24hours, getAddress); + Utils.RowToCsv(sw, data, excludeColumns); + + } + } + } + } + + } + } + + + public List get_History(String glwhere, Boolean compAddress, Boolean forceLATLNG, Boolean is24hours, Boolean isInMile, ref int cntaddr, ref Queue AddrGISQueue, ref Hashtable IdReportHS) { List HistDataReport = new List(); @@ -406,25 +624,33 @@ namespace SafeMobileLib { using (NpgsqlConnection connection = new NpgsqlConnection()) { - + connection.ConnectionString = getConnectionString(); connection.Open(); string command = "SELECT timeGMT,address,speed,lat,lng,scevtime, sc_id, W.name, W.driver_id FROM messages " + - $" INNER JOIN vehicle W on sc_id = W.id {glwhere} ORDER BY timeGMT DESC"; + $" INNER JOIN vehicle W on sc_id = W.id {glwhere} ORDER BY timeGMT DESC"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { + cmd.CommandTimeout = 1200; + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { + + double lat = Convert.ToDouble(dr["lat"]); + double lng = Convert.ToDouble(dr["lng"]); + String Address = ""; - latlng = "LAT:" + Math.Round(dr.GetDouble(3), 5).ToString() + " , LNG:" + Math.Round(dr.GetDouble(4), 5).ToString(); + latlng = "LAT:" + Math.Round(lat, 5).ToString() + " , LNG:" + Math.Round(lat, 5).ToString(); if (!forceLATLNG) { - if (!dr.IsDBNull(1)) Address = dr.GetString(1); - if ((dr.GetDouble(3) == 0) || (dr.GetDouble(4) == 0)) Address = "NO GPS FIX"; + if (!dr.IsDBNull(1)) + Address = dr["address"].ToString(); + if ((lat == 0.0) || (lng == 0.0)) + Address = "NO GPS FIX"; else if ((Address == "") || (Address == " ")) { @@ -432,24 +658,26 @@ namespace SafeMobileLib { cntaddr++; IdReportHS[cntaddr.ToString()] = string.Format("no address ({0})", latlng); - AddrGISQueue.Enqueue(new AddrAndID(cntaddr, dr.GetDouble(3), dr.GetDouble(4))); + AddrGISQueue.Enqueue(new AddrAndID(cntaddr, lat, lng)); Address = cntaddr.ToString(); } else Address = latlng; } } - else Address = "LAT:" + Math.Round(dr.GetDouble(3), 5).ToString() + " , LNG:" + Math.Round(dr.GetDouble(4), 5).ToString(); - var tmp = new StopData - { - Location = Address, - Duration = (isInMile) ? ((int)(dr.GetInt32(2) * 0.621371192)).ToString() : dr.GetInt32(2).ToString(), - Time = dr.GetInt32(0).TimeOfDayHHMMSSLocal(!is24hours), - Data = (dr.GetInt32(0).GetDTLocalFromSeconds()).Date.ToShortDateString(), - unit_sc_id = dr.GetInt32(6), - unit_name = dr.GetString(7), - unique_id = dr.GetDouble(5) - }; - HistDataReport.Add(tmp); + else + Address = latlng; + + + HistDataReport.Add(new StopData + { + Location = Address, + Duration = (isInMile) ? ((int)(Convert.ToInt32(dr["speed"]) * 0.621371192)).ToString() : Convert.ToInt32(dr["speed"]).ToString(), + Time = Convert.ToInt32(dr["timeGMT"]).TimeOfDayHHMMSSLocal(!is24hours), + Data = (Convert.ToInt32(dr["timeGMT"]).GetDTLocalFromSeconds()).Date.ToShortDateString(), + unit_sc_id = Convert.ToInt32(dr["sc_id"]), + unit_name = dr["name"].ToString(), + unique_id = Convert.ToDouble(dr["scevtime"]) + }); } } } @@ -464,6 +692,7 @@ namespace SafeMobileLib return HistDataReport; } + public List get_TelemHist_alarm_event(String glwhere, Hashtable VehIDHash, Hashtable vehicleHT) { List SpeedingList = new List(); @@ -481,33 +710,38 @@ namespace SafeMobileLib { using (NpgsqlDataReader dr = cmd.ExecuteReader()) { + + int timeGMT = 0, sc_id = 0, telemetry_id = 0; + while (dr.Read()) { - String actionName = ""; - if (VehIDHash[dr.GetInt32(1)] != null) - { - foreach (TelemetryObj obj in ((VehicleForReports)vehicleHT[(String)VehIDHash[dr.GetInt32(1)]]).telemList) - if (obj.Id == dr.GetInt32(2)) - { - actionName = obj.Name; - break; - } - } - var tmp = new SpeedData - { - Name = (VehIDHash[dr.GetInt32(1)] != null) ? (String)VehIDHash[dr.GetInt32(1)] : "", - Speed = actionName, - Time = dr.GetInt32(0).TimeOfDayHHMMSSLocal(false), - Data = (dr.GetInt32(0).GetDTLocalFromSeconds()).Date.ToShortDateString(), - Address = dr.GetString(3), - sc_id = dr.GetInt32(1), - timeGMT = dr.GetInt32(0), - lat = dr.GetDouble(4), - lng = dr.GetDouble(5) - }; - if (tmp.Name != "") - SpeedingList.Add(tmp); + sc_id = Convert.ToInt32(dr["sc_id"]); + + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") + { + + timeGMT = Convert.ToInt32(dr["timegmt"]); + telemetry_id = Convert.ToInt32(dr["telemetry_id"]); + + // get action name + var list = ((VehicleForReports)vehicleHT[(String)VehIDHash[sc_id]]).telemList; + string actionName = list.Where(x => x.Id == telemetry_id).Select(x => x.Name).FirstOrDefault(); + + + SpeedingList.Add(new SpeedData + { + Name = (String)VehIDHash[sc_id], + Speed = actionName, + Time = timeGMT.TimeOfDayHHMMSSLocal(false), + Data = (timeGMT.GetDTLocalFromSeconds()).Date.ToShortDateString(), + Address = dr["address"].ToString(), + sc_id = sc_id, + timeGMT = timeGMT, + lat = Convert.ToDouble(dr["lat"]), + lng = Convert.ToDouble(dr["lng"]) + }); + } } } } @@ -539,22 +773,32 @@ namespace SafeMobileLib { using (NpgsqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { + + int sc_id = 0, timeGMT = 0; + while (dr.Read()) { - var tmp = new SMS_Location + sc_id = Convert.ToInt32(dr["sc_id_sour"]); + + + if (VehIDHash.ContainsKey(sc_id) && (String)VehIDHash[sc_id] != "") { - Name = (VehIDHash[dr.GetInt32(1)] != null) ? (String)VehIDHash[dr.GetInt32(1)] : "", - Text_mess = dr.GetString(2), - Time = dr.GetInt32(0).TimeOfDayHHMMLocal(!is24hours), - Data = (dr.GetInt32(0).GetDTLocalFromSeconds()).Date.ToShortDateString(), - Address = dr.GetString(3), - sc_id = dr.GetInt32(1), - timeGMT = dr.GetInt32(0), - lat = dr.GetDouble(4), - lng = dr.GetDouble(5) - }; - if (tmp.Name != "") - SMSLocList.Add(tmp); + + timeGMT = Convert.ToInt32(dr["timeGMT"]); + + SMSLocList.Add(new SMS_Location + { + Name = (String)VehIDHash[sc_id], + Text_mess = dr["mess"].ToString(), + Time = timeGMT.TimeOfDayHHMMLocal(!is24hours), + Data = (timeGMT.GetDTLocalFromSeconds()).Date.ToShortDateString(), + Address = dr["address"].ToString(), + sc_id = sc_id, + timeGMT = timeGMT, + lat = Convert.ToDouble(dr["lat"]), + lng = Convert.ToDouble(dr["lng"]) + }); + } } } } @@ -603,12 +847,13 @@ namespace SafeMobileLib { var tmp = new SpeedData { - Name = dr.GetString(0), - Speed = dr.GetInt32(1).ToString(), - Time = dr.GetString(2), - Data = (dr.GetValue(3).ToString() == "") ? "" : dr.GetInt32(3).GetDTLocalFromSeconds().Date.ToShortDateString(), - Address = (dr.GetValue(4).ToString() == "") ? "" : dr.GetInt32(4).GetDTLocalFromSeconds().Date.ToShortDateString(), + Name = dr["name"].ToString(), + Speed = dr["ticket_id"].ToString(), + Time = dr["status"].ToString(), + Data = (dr["start_time"].ToString() == "") ? "" : Convert.ToInt32(dr["start_time"]).GetDTLocalFromSeconds().Date.ToShortDateString(), + Address = (dr["end_time"].ToString() == "") ? "" : Convert.ToInt32(dr["end_time"]).GetDTLocalFromSeconds().Date.ToShortDateString(), }; + if (tmp.Name != "") SpeedingList.Add(tmp); } @@ -650,18 +895,19 @@ namespace SafeMobileLib while (dr.Read()) { int seconds = 0; - string value = dr.GetString(1); + string value = dr["value"].ToString(); Int32.TryParse(value, out seconds); DateTime DT = DateTime.Today.AddSeconds(seconds); - var tmp = new UserReportTime - { - UserID = dr.GetInt32(0), - UserName = dr.GetString(2), - HH = DT.Hour, - MM = DT.Minute, - ReportExecuted = false - }; - UserReportTimeList.Add(tmp); + + + UserReportTimeList.Add(new UserReportTime + { + UserID = Convert.ToInt32(dr["user_id"]), + UserName = dr["login"].ToString(), + HH = DT.Hour, + MM = DT.Minute, + ReportExecuted = false + }); } } } @@ -700,10 +946,15 @@ namespace SafeMobileLib { while (dr.Read()) { - string address = dr.IsDBNull(1) ? "" : dr.GetString(1); - if ((dr.GetDouble(2) != 0) && (dr.GetDouble(3) != 0)) - ret.Add(new PositionData(dr.GetDouble(2), dr.GetDouble(3), address, dr.GetInt32(0), car_state_e.CAR_RUNNING, dr.GetInt32(5))); + double lat = Convert.ToDouble(dr["lat"]); + double lng = Convert.ToDouble(dr["lng"]); + string address = dr.IsDBNull(1) ? "" : dr["address"].ToString(); + int speed = Convert.ToInt32(dr["speed"]); + int timeGMT = Convert.ToInt32(dr["timeGMT"]); + + if (lat != 0 && lng != 0) + ret.Add(new PositionData(lat, lng, address, timeGMT, car_state_e.CAR_RUNNING, speed)); } } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs index c78b268..95bbea3 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBTicketingManager.cs @@ -35,14 +35,8 @@ namespace SafeMobileLib string command = "SELECT value FROM sequences where name = 'jobticketing'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader Reader = cmd.ExecuteReader()) - { - while (Reader.Read()) - { - ticket_id = Convert.ToInt32(Reader.GetValue(0).ToString()); - } - } + ticket_id = Convert.ToInt32(cmd.ExecuteScalar()); } if (ticket_id == -1) @@ -100,26 +94,13 @@ namespace SafeMobileLib string command = $"SELECT sc_id FROM subscriber WHERE imei='{imei}'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } command = "SELECT status_id from jobticketstatusesset where is_first_state = 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - job_status = dr.GetInt32(0); - } - } + job_status = Convert.ToInt32(cmd.ExecuteScalar()); } @@ -210,7 +191,7 @@ namespace SafeMobileLib public sqlResponse insert_ticket_response(String imei, string mess) { sqlResponse resp = sqlResponse.SQLerror; - InitConnection(); + //InitConnection(); Int32 status_id = 0; Int32 sc_id = 0; @@ -226,15 +207,9 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT sc_id from subscriber where imei='{imei}'", connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT sc_id from subscriber where imei='{imei}' LIMIT 1", connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } @@ -1049,7 +1024,7 @@ namespace SafeMobileLib public TicketResponse deleteTicketingStatus(string ticketStatus) { //TODO before delete ticket status check job ticketing transactions - InitConnection(); + //InitConnection(); TicketResponse resp; Int32 status_id = -1; @@ -1066,14 +1041,9 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader Reader = cmd.ExecuteReader()) - { - while (Reader.Read()) - { - status_id = Reader.GetInt32(0); - } - } + status_id = Convert.ToInt32(cmd.ExecuteScalar()); } + if (status_id > -1) { command = "SELECT COUNT(job_status) FROM jobtickets WHERE job_status =\'" + status_id + "\'"; @@ -1176,13 +1146,7 @@ namespace SafeMobileLib string command = "SELECT status_id FROM jobticketstatusesset WHERE status=\'" + ticketStatus + "\'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader Reader = cmd.ExecuteReader()) - { - while (Reader.Read()) - { - status_id = Convert.ToInt32(Reader.GetValue(0).ToString()); - } - } + status_id = Convert.ToInt32(cmd.ExecuteScalar()); } } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBalarmManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBalarmManager.cs index 4257a1f..47dc26f 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBalarmManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBalarmManager.cs @@ -33,14 +33,7 @@ namespace SafeMobileLib string command = "SELECT sc_id from subscriber where imei='" + radioID.ToString() + "'"; using (cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - dr.Close(); - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } command = " SELECT id, emergency, landmark, \"zone\" ,loneworker,speed,email,empopup,emsound,geopopup,geosound,speedpopup,speedsound,telempopup,telemsound FROM subscriber_alarm " + @@ -53,7 +46,6 @@ namespace SafeMobileLib { alarmRet = new Alarm(Reader.GetInt32(0), sc_id, Reader.GetString(1), Reader.GetString(2), Reader.GetString(3), Reader.GetString(4), Reader.GetString(5), Reader.GetString(6), Reader.GetBoolean(7), Reader.GetBoolean(8), Reader.GetBoolean(9), Reader.GetBoolean(10), Reader.GetBoolean(11), Reader.GetBoolean(12), Reader.GetBoolean(13), Reader.GetBoolean(14)); } - Reader.Close(); } } } @@ -81,24 +73,18 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = "SELECT imei,status FROM lastpos"; - using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT imei,status FROM lastpos", connection)) { using (NpgsqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { - try - { - ret.Add(reader.GetString(0), reader.GetInt32(1)); - } - catch (Exception ex) - { - Console.WriteLine("Error on add to hash SystemPosition:" + ex.ToString()); - } + + string imei = (reader["imei"] != DBNull.Value) ? reader["imei"].ToString() : ""; + if (imei != "" && ret.ContainsKey(imei)) + ret.Add(imei, reader.GetInt32(1)); } - reader.Close(); } } } @@ -137,7 +123,6 @@ namespace SafeMobileLib { alarmRet = new Alarm(Reader.GetInt32(0), sc_id, Reader.GetString(1), Reader.GetString(2), Reader.GetString(3), Reader.GetString(4), Reader.GetString(5), Reader.GetString(6), Reader.GetBoolean(7), Reader.GetBoolean(8), Reader.GetBoolean(9), Reader.GetBoolean(10), Reader.GetBoolean(11), Reader.GetBoolean(12), Reader.GetBoolean(13), Reader.GetBoolean(14)); } - Reader.Close(); } } } @@ -208,17 +193,10 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT sc_id from subscriber where imei='{radioID}'"; + string command = $"SELECT sc_id FROM subscriber where imei='{radioID}' LIMIT 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - sc_id = reader.GetInt32(0); - } - reader.Close(); - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } @@ -258,17 +236,10 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT sc_id from subscriber where imei='{radioID}'"; + string command = $"SELECT sc_id from subscriber where imei='{radioID}' LIMIT 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - sc_id = reader.GetInt32(0); - } - reader.Close(); - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } int i = 0; @@ -310,56 +281,30 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT sc_id from subscriber where imei='{radioID}'"; + string command = $"SELECT sc_id FROM subscriber WHERE imei='{radioID}' LIMIT 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - sc_id = reader.GetInt32(0); - } - reader.Close(); - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); + } - command = "SELECT idx from place where name='Landmark1'"; + command = "SELECT idx FROM place WHERE name='Landmark1'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - idxL1 = reader.GetInt32(0); - } - reader.Close(); - } + idxL1 = Convert.ToInt32(cmd.ExecuteScalar()); } - command = "SELECT idx from place where name='Landmark2'"; + command = "SELECT idx FROM place WHERE name='Landmark2'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - idxL2 = reader.GetInt32(0); - } - reader.Close(); - } + idxL2 = Convert.ToInt32(cmd.ExecuteScalar()); } - command = "SELECT idx from zonename where name='testZone1'"; + command = "SELECT idx FROM zonename WHERE name='testZone1'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - idxGeo = reader.GetInt32(0); - } - reader.Close(); - } + + idxGeo = Convert.ToInt32(cmd.ExecuteScalar()); } // get ID for landmark1,2 and zone1 @@ -534,18 +479,11 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT sc_id FROM subscriber WHERE imei='{radioID}'"; + string command = $"SELECT sc_id FROM subscriber WHERE imei='{radioID}' LIMIT 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - sc_id = reader.GetInt32(0); - } - reader.Close(); - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } command = $"DELETE FROM \"subscriber_alarm\" WHERE sc_id = {sc_id} "; @@ -621,17 +559,10 @@ namespace SafeMobileLib connection.Open(); //get sc_id from imei/radioID - string command = $"SELECT sc_id FROM subscriber WHERE imei='{radioID}'"; + string command = $"SELECT sc_id FROM subscriber WHERE imei='{radioID}' LIMIT 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - p_sc_id = reader.GetInt32(0); - } - reader.Close(); - } + p_sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } string emergTime = DateTime.Now.ToUniversalTime().DateTo70Format() + ""; @@ -682,14 +613,7 @@ namespace SafeMobileLib string command = $"SELECT sc_id FROM subscriber WHERE imei='{radioID}'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, conn)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - p_sc_id = dr.GetInt32(0); - } - dr.Close(); - } + p_sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } command = "INSERT INTO speedalarm (sc_id,timeGMT,speed,preview,address,lat,lng) " + @@ -712,7 +636,7 @@ namespace SafeMobileLib { Utils.WriteLine(o.ToString(), ConsoleColor.Red); } - conn.Close(); + } } catch (Exception ex) @@ -753,7 +677,7 @@ namespace SafeMobileLib } resp = sqlResponse.done; - conn.Close(); + } } catch (Exception ex) @@ -784,7 +708,7 @@ namespace SafeMobileLib } String idx = string.Empty; - query = "SELECT max(idx) from zonename"; + query = "SELECT MAX(idx) FROM zonename"; using (NpgsqlCommand cmd = new NpgsqlCommand(query, connection)) { idx = ((Int32)cmd.ExecuteScalar()).ToString(); @@ -833,17 +757,10 @@ namespace SafeMobileLib connection.Open(); - string command = $"select sc_id from subscriber where imei='{imei}'"; + string command = $"SELECT sc_id FROM subscriber where imei='{imei}' LIMIT 1"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - dr.Close(); - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } @@ -1006,7 +923,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = "SELECT name,lat,lng,idx, useridx, callout, callout_severity from PLACE ORDER BY name"; + string command = "SELECT name,lat,lng,idx, useridx, callout, callout_severity FROM place ORDER BY name"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { @@ -1047,7 +964,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT count(sc_id) FROM emergalarm WHERE preview = 0 and sc_id = {sc_id} "; + string command = $"SELECT COUNT(sc_id) FROM emergalarm WHERE preview = 0 and sc_id = {sc_id} "; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { diff --git a/SafeMobileLIB_DLL/DBmanagers/DBmanager.cs b/SafeMobileLIB_DLL/DBmanagers/DBmanager.cs index eea3ac2..5cac97c 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBmanager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBmanager.cs @@ -143,25 +143,7 @@ namespace SafeMobileLib } - public void InitConnectionHistoryReport() - { - - cn = new NpgsqlConnection(); - cn.ConnectionString = getConnectionString(); - try - { - if (cn != null && cn.State == System.Data.ConnectionState.Closed) - cn.Open(); - } - catch (Exception o) - { - if (cn != null) - { - cn.Close(); - } - throw new ArgumentException(o.Message.ToString()); - } - } + public void CloseConnection() { diff --git a/SafeMobileLIB_DLL/DBmanagers/DBregistrationManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBregistrationManager.cs index 5625f9c..644a6fa 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBregistrationManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBregistrationManager.cs @@ -92,30 +92,10 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - String query = "UPDATE registration SET has_gps = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_sms = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_ticketing = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_reports = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_voice = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_recordings = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_zones = false WHERE true"; - cmd = new NpgsqlCommand(query, connection); - cmd.ExecuteNonQuery(); - query = "UPDATE registration SET has_telemetry = false WHERE true"; + String query = "UPDATE registration SET has_gps = false, has_sms = false, has_ticketing = false, has_reports = false, has_voice = false, has_recordings = false, has_zones = false, has_telemetry = false "; cmd = new NpgsqlCommand(query, connection); cmd.ExecuteNonQuery(); + } } catch (Exception e) @@ -197,25 +177,25 @@ namespace SafeMobileLib public uint getReportsCount() { - string command = "SELECT count (has_reports) FROM registration WHERE has_reports=true"; + string command = "SELECT count (has_reports) FROM registration WHERE has_reports = true"; return (uint)GetInt32Result(command); } public uint getVoiceCount() { - string command = "SELECT COUNT (has_voice) FROM registration WHERE has_voice=true"; + string command = "SELECT COUNT (has_voice) FROM registration WHERE has_voice = true"; return (uint)GetInt32Result(command); } public uint getZonesCount() { - string command = "SELECT COUNT (has_zones) FROM registration WHERE has_zones=true"; + string command = "SELECT COUNT (has_zones) FROM registration WHERE has_zones = true"; return (uint)GetInt32Result(command); } public uint getTelemetryCount() { - string command = "SELECT COUNT (has_telemetry) FROM registration WHERE has_telemetry=true"; + string command = "SELECT COUNT (has_telemetry) FROM registration WHERE has_telemetry = true"; return (uint)GetInt32Result(command); } @@ -268,19 +248,19 @@ namespace SafeMobileLib while (reader.Read()) { SDRegistration reg = new SDRegistration(); - reg.ip = reader.GetValue(0).ToString(); - reg.gps = (Boolean)reader.GetValue(1); - reg.sms = (Boolean)reader.GetValue(2); - reg.ticketing = (Boolean)reader.GetValue(3); - reg.reports = (Boolean)reader.GetValue(4); - reg.voice = (Boolean)reader.GetValue(5); - reg.recordings = (Boolean)reader.GetValue(6); - reg.zones = (Boolean)reader.GetValue(7); - reg.telemetry = (Boolean)reader.GetValue(8); - Int16 mType = Int16.Parse(reader.GetValue(9).ToString()); - reg.map_type = mType; + reg.ip = reader["ip"].ToString(); + reg.gps = Convert.ToBoolean(reader["has_gps"]); + reg.sms = Convert.ToBoolean(reader["has_sms"]); + reg.ticketing = Convert.ToBoolean(reader["has_ticketing"]); + reg.reports = Convert.ToBoolean(reader["has_reports"]); + reg.voice = Convert.ToBoolean(reader["has_voice"]); + reg.recordings = Convert.ToBoolean(reader["has_recordings"]); + reg.zones = Convert.ToBoolean(reader["has_zones"]); + reg.telemetry = Convert.ToBoolean(reader["has_telemetry"]); + reg.map_type = Convert.ToInt16(reader["map_type"]); + reg.MapTypeS = "None"; - switch (mType) + switch (reg.map_type) { case 1: reg.MapTypeS = "Google"; @@ -295,6 +275,7 @@ namespace SafeMobileLib reg.MapTypeS = "ArcGIS"; break; } + safeDispatches.Add(reg); } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBsettingsManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBsettingsManager.cs index 2fa0879..398745a 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBsettingsManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBsettingsManager.cs @@ -206,7 +206,9 @@ namespace SafeMobileLib { string key = Reader.GetValue(0).ToString(); string value = Reader.GetValue(1).ToString(); - resp.Add(key, value); + + if (!resp.ContainsKey(key)) + resp.Add(key, value); } } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBsmsManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBsmsManager.cs index 95481fa..86a2be0 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBsmsManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBsmsManager.cs @@ -32,13 +32,7 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - sc_id = reader.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } @@ -74,16 +68,10 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = "SELECT sc_id from subscriber where imei='" + imei + "'"; + string command = $"SELECT sc_id from subscriber where imei='{imei}'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } command = "INSERT INTO sms (timeGMT,sc_id_sour,sc_id_dest,mess,status, email, seq_id) " + @@ -135,13 +123,7 @@ namespace SafeMobileLib string command = $"SELECT sc_id from subscriber where imei = '{imei}'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } @@ -468,14 +450,7 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - status = reader.GetInt32(0); - } - } - + status = Convert.ToInt32(cmd.ExecuteScalar()); } return (status == 2); diff --git a/SafeMobileLIB_DLL/DBmanagers/DBsubsOperationManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBsubsOperationManager.cs index 1cda155..db72600 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBsubsOperationManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBsubsOperationManager.cs @@ -54,7 +54,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - command = String.Format("UPDATE lastpos SET status ={0} where imei='{1}'", status, p_IMEI); + command = String.Format("UPDATE lastpos SET status = {0} where imei = '{1}'", status, p_IMEI); using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { cmd.ExecuteNonQuery(); @@ -239,13 +239,7 @@ namespace SafeMobileLib //get sc_id from imei/radioID using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } } @@ -260,14 +254,8 @@ namespace SafeMobileLib string command = $"SELECT status from subscriber_stun where sc_id={sc_id}"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - respStatus = dr.GetInt32(0); - } - } + respStatus = Convert.ToInt32(cmd.ExecuteScalar()); } } @@ -321,17 +309,11 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT sc_id from subscriber where imei='{radioID}'"; + string command = $"SELECT sc_id from subscriber where imei = '{radioID}'"; //get sc_id from imei/radioID using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { - using (NpgsqlDataReader dr = cmd.ExecuteReader()) - { - while (dr.Read()) - { - sc_id = dr.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBtelemetryManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBtelemetryManager.cs index 4e5cd59..e1a58c3 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBtelemetryManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBtelemetryManager.cs @@ -550,13 +550,7 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT sc_id FROM subscriber where imei='" + radioID + "'", connection)) { - using (NpgsqlDataReader Reader = cmd.ExecuteReader()) - { - while (Reader.Read()) - { - sc_id = Reader.GetInt32(0); - } - } + sc_id = Convert.ToInt32(cmd.ExecuteScalar()); } } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBuserManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBuserManager.cs index e5a6dc3..ecf1005 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBuserManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBuserManager.cs @@ -140,7 +140,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT COUNT(*) FROM zonename WHERE useridx=" + userID, connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT COUNT(*) FROM zonename WHERE useridx = {userID}", connection)) { resp = Convert.ToInt32((object)cmd.ExecuteScalar()); } @@ -167,7 +167,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT COUNT(*) FROM place WHERE useridx=" + userID, connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT COUNT(*) FROM place WHERE useridx = {userID}", connection)) { resp = Convert.ToInt32((object)cmd.ExecuteScalar()); } @@ -195,12 +195,12 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE zonename SET useridx={newUserID} WHERE useridx=" + userID, connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE zonename SET useridx = {newUserID} WHERE useridx = {userID}", connection)) { cmd.ExecuteNonQuery(); } - using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE place SET useridx={newUserID} WHERE useridx=" + userID, connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE place SET useridx = {newUserID} WHERE useridx = {userID}", connection)) { cmd.ExecuteNonQuery(); } @@ -284,8 +284,8 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = "SELECT firstName, lastName, login, password, userId, user_type, backup_user_id " + - " FROM users where userid <> 0 ORDER by login"; + string command = " SELECT firstName, lastName, login, password, userId, user_type, backup_user_id " + + " FROM users where userid <> 0 ORDER BY login"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { using (NpgsqlDataReader Reader = cmd.ExecuteReader()) @@ -309,6 +309,7 @@ namespace SafeMobileLib { uType = USERTYPE.LiteDispatcher; } + User usr = new User() { UType = uType, @@ -319,6 +320,7 @@ namespace SafeMobileLib Id = Convert.ToInt32(Reader.GetValue(4)), BackupUserId = Convert.ToInt32(Reader.GetValue(6)) }; + userList.Add(usr); } } @@ -351,7 +353,7 @@ namespace SafeMobileLib connection.Open(); string command = "SELECT u.userid, us.value FROM users u join \"userSettings\" us on us.user_id = u.userid " + - " WHERE key = 'startUnits'"; + " WHERE key = 'startUnits'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { @@ -390,7 +392,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = "SELECT login FROM users where userid <> 0 ORDER by user_type"; + string command = "SELECT login FROM users where userid <> 0 ORDER by user_type"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { using (NpgsqlDataReader reader = cmd.ExecuteReader()) @@ -477,7 +479,7 @@ namespace SafeMobileLib connection.Open(); string command = $"SELECT firstName, lastName, login, password, userId, user_type" - + $" FROM users u where user_type != 1 and login = '{userName}' and password='{password}'"; + + $" FROM users u where user_type != 1 and login = '{userName}' and password='{password}'"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { @@ -619,13 +621,7 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT userid FROM users WHERE \"login\"='{userLoginName}'", connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - userid = reader.GetInt32(0); - } - } + userid = Convert.ToInt32(cmd.ExecuteScalar()); } } @@ -655,13 +651,7 @@ namespace SafeMobileLib using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT \"password\" FROM users WHERE \"login\"='administrator'", connection)) { - using (NpgsqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - pass = reader.GetString(0); - } - } + pass = cmd.ExecuteScalar().ToString(); } } } @@ -756,7 +746,7 @@ namespace SafeMobileLib connection.Open(); Int32 temp = 0; - using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT ison FROM users WHERE userid={UserIdx}", connection)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT ison FROM users WHERE userid = {UserIdx}", connection)) { temp = Convert.ToInt32((object)cmd.ExecuteScalar()); } @@ -783,8 +773,8 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"update users set ison={(state == true ? 1 : 0)} " + - " where userid=(select id from sip_manager where sip_id = {sipID} and type = 0) "; + string command = $"UPDATE users SET ison={(state == true ? 1 : 0)} " + + " WHERE userid = (SELECT id FROM sip_manager WHERE sip_id = {sipID} AND type = 0) "; NpgsqlCommand cmd = new NpgsqlCommand(command, connection); { cmd.ExecuteNonQuery(); @@ -809,7 +799,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - NpgsqlCommand cmd = new NpgsqlCommand($"update users set ison={(state == true ? 1 : 0)} where userid={UserIdx}", connection); + NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE users SET ison = {(state == true ? 1 : 0)} WHERE userid={UserIdx}", connection); cmd.ExecuteNonQuery(); } } diff --git a/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs b/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs index 337ff51..f3c599b 100644 --- a/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs +++ b/SafeMobileLIB_DLL/DBmanagers/DBvehiclesManager.cs @@ -1201,17 +1201,8 @@ namespace SafeMobileLib { ArrayList toreturn = new ArrayList(); - StringBuilder buffer = new StringBuilder(4096); + string buffer = string.Join(",", hash.Keys); - - - foreach (Int32 obj in hash.Keys) - { - buffer.AppendFormat("'{0}',", obj); - } - - if (buffer.Length > 0) - buffer = buffer.Replace(",", "", buffer.Length - 1, 1); try { @@ -1221,7 +1212,7 @@ namespace SafeMobileLib connection.ConnectionString = getConnectionString(); connection.Open(); - string command = $"SELECT sc_id FROM subscriber WHERE imei in ( {buffer.ToString() } )"; + string command = $"SELECT sc_id FROM subscriber WHERE imei in ( {buffer} )"; using (NpgsqlCommand cmd = new NpgsqlCommand(command, connection)) { @@ -2139,7 +2130,8 @@ namespace SafeMobileLib int gateway_id = Convert.ToInt32(reader["gateway_id"]); int radio_gw_id = Convert.ToInt32(reader["radio_gw_id"]); - ret.Add(sc_id, new UnitSysPosition(gateway_id, radio_gw_id)); + if(!ret.ContainsKey(sc_id)) + ret.Add(sc_id, new UnitSysPosition(gateway_id, radio_gw_id)); } reader.Close(); @@ -2330,6 +2322,7 @@ namespace SafeMobileLib cmd.ExecuteNonQuery(); result = totalUnits; } + cmd = new NpgsqlCommand("SELECT COUNT(id) FROM vehicle v WHERE is_deleted = FALSE", connection); int.TryParse(cmd.ExecuteScalar().ToString(), out totaldbunits); diff --git a/SafeMobileLIB_DLL/ReportsClass.cs b/SafeMobileLIB_DLL/ReportsClass.cs index f22bdef..eb11e0e 100644 --- a/SafeMobileLIB_DLL/ReportsClass.cs +++ b/SafeMobileLIB_DLL/ReportsClass.cs @@ -8,6 +8,14 @@ using System.Text; namespace SafeMobileLib { + + public interface ILocationAddress + { + Double Lat { get; set; } + Double Lng { get; set; } + String Address { get; set; } + } + public enum MapTYPE { Google = 1, @@ -53,7 +61,8 @@ namespace SafeMobileLib HIST, ALLALARM, SMS_LOCATION, - JOB_TICKETING + JOB_TICKETING, + BATCH_HIST }; public enum car_state_e @@ -64,7 +73,7 @@ namespace SafeMobileLib CAR_HW }; - public class PositionData + public class PositionData : ILocationAddress { public Int32 ReportingInterval { get; set; } public Double Lat { get; set; } @@ -150,7 +159,20 @@ namespace SafeMobileLib public String Stop { get; set; } } - public class ChartData + public class BatchHistoryData : ILocationAddress + { + public String Department { get; set; } + public String Unit { get; set; } + public String Date { get; set; } + public String Time { get; set; } + public String Location { get; set; } + public String Address { get; set; } + public Double Lat { get; set; } + public Double Lng { get; set; } + public String Speed { get; set; } + } + + public class ChartData { public String Type { get; set; } public int Value { get; set; } diff --git a/SafeMobileLIB_DLL/StaticMembers.cs b/SafeMobileLIB_DLL/StaticMembers.cs index 018627f..56bb47c 100644 --- a/SafeMobileLIB_DLL/StaticMembers.cs +++ b/SafeMobileLIB_DLL/StaticMembers.cs @@ -27,6 +27,7 @@ namespace SafeMobileLib public static List SpeedingList; public static List LandList; public static List HistDataReport; + public static List BatchHistoryReport; public static List UsersList; public static List SMSLocList; public static Boolean IsIdle = false; diff --git a/SafeMobileLIB_DLL/Utils.cs b/SafeMobileLIB_DLL/Utils.cs index 99dc52b..74ebce1 100644 --- a/SafeMobileLIB_DLL/Utils.cs +++ b/SafeMobileLIB_DLL/Utils.cs @@ -18,6 +18,9 @@ using System.Net.Sockets; using System.Management.Automation.Runspaces; using System.Collections.ObjectModel; using System.Management.Automation; +using System.Data; +using System.ComponentModel; +using System.IO; namespace SafeMobileLib { @@ -1250,6 +1253,129 @@ namespace SafeMobileLib string Text = Convert.ToInt32(e).ToString(); return Text; } + + + public static DataTable ToEmptyDataTable() + { + DataTable table = new DataTable(); + + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T)); + + for (int i = 0; i < props.Count; i++) + { + PropertyDescriptor prop = props[i]; + table.Columns.Add(prop.Name, prop.PropertyType); + } + + return table; + + } + + + + public static void HeaderToCsv(StreamWriter sw, List excludeColumns) + { + char separator = ','; + char replacer = ';'; + + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T)); + + for (int i = 0; i < props.Count; i++) + { + if (excludeColumns.Contains(props[i].Name)) + continue; + + PropertyDescriptor prop = props[i]; + + sw.Write(prop.Name.Replace(separator, replacer)); + if (i < props.Count - 1) + sw.Write(separator); + + } + sw.Write(Environment.NewLine); + } + + public static void RowToCsv(StreamWriter sw, T obj, List excludeColumns) + { + char separator = ','; + char replacer = ';'; + + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T)); + + for (int i = 0; i < props.Count; i++) + { + + if (excludeColumns.Contains(props[i].Name)) + continue; + + String value = props[i].GetValue(obj).ToString(); + sw.Write(value.Replace(separator, replacer)); + + if (i < props.Count - 1) + sw.Write(separator); + } + sw.Write(Environment.NewLine); + } + + + public static void DataTable_HeaderToCsvFile(System.IO.StreamWriter sw, DataTable dt) + { + char separator = ','; + char replacer = ';'; + + int columnCount = dt.Columns.Count; + for (int i = 0; i < columnCount; i++) + { + sw.Write(dt.Columns[i].ToString().Replace(separator, replacer)); + if (i < columnCount - 1) + sw.Write(separator); + } + sw.Write(Environment.NewLine); + } + + public static void DataTable_RowToCsvFile(System.IO.StreamWriter sw, DataRow dr) + { + char separator = ','; + char replacer = ';'; + + int columnCount = dr.Table.Columns.Count; + + for (int i = 0; i < columnCount; i++) + { + if (!Convert.IsDBNull(dr[i])) + sw.Write(dr[i].ToString().Replace(separator, replacer)); + + if (i < columnCount - 1) + sw.Write(separator); + } + + sw.Write(Environment.NewLine); + } + + public static void DataTableToCsvFile(DataTable dataTable, string filePath, bool includeHeaders = true) + { + using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filePath, false)) + { + + //================ + // write header + //================ + if (includeHeaders) + { + DataTable_HeaderToCsvFile(sw, dataTable); + } + + //================ + // write rows + //================ + foreach (DataRow dr in dataTable.Rows) + { + DataTable_RowToCsvFile(sw, dr); + } + } + + } + } public class Hyt_cmdMsg diff --git a/Safedispatch_4_0/ClassDef.cs b/Safedispatch_4_0/ClassDef.cs index 9ff597c..34882fe 100644 --- a/Safedispatch_4_0/ClassDef.cs +++ b/Safedispatch_4_0/ClassDef.cs @@ -126,7 +126,8 @@ namespace Safedispatch_4_0 REPORTS, SYSTEM, HELP, - RADIO + RADIO, + BATCH_HIST }; //public enum StartItems @@ -209,6 +210,7 @@ namespace Safedispatch_4_0 public static readonly Tabs SYSTEM = new Tabs(9, "SYSTEM"); public static readonly Tabs ALERTS = new Tabs(10, "ALERTS"); public static readonly Tabs RADIO = new Tabs(11, "RADIO"); + public static readonly Tabs BATCH_HISTORY = new Tabs(12, "BATCH HISTORY"); private Tabs(int value, String name) { @@ -1027,6 +1029,7 @@ namespace Safedispatch_4_0 { public ToolWindow toolwind; public HistoryTab histtab = null; + public HistTabWind(ToolWindow _toolwind, HistoryTab _livetab) { @@ -1036,6 +1039,7 @@ namespace Safedispatch_4_0 } + public class Commands { public Commands(Int32 _type, String _imei, Int32 _time, Double _lat, Double _lng, Int32 _speed, Int32 _di, Double _alt) diff --git a/Safedispatch_4_0/Language/myRes.Designer.cs b/Safedispatch_4_0/Language/myRes.Designer.cs index 00792bc..a6983bb 100644 --- a/Safedispatch_4_0/Language/myRes.Designer.cs +++ b/Safedispatch_4_0/Language/myRes.Designer.cs @@ -438,6 +438,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Batch History Report. + /// + internal static string BatchHistoryRep { + get { + return ResourceManager.GetString("BatchHistoryRep", resourceCulture); + } + } + /// /// Looks up a localized string similar to Border color. /// @@ -501,6 +510,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Generate Report In Csv. + /// + internal static string btShowReportInCsv { + get { + return ResourceManager.GetString("btShowReportInCsv", resourceCulture); + } + } + /// /// Looks up a localized string similar to Busy. /// @@ -1014,6 +1032,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Date. + /// + internal static string Date { + get { + return ResourceManager.GetString("Date", resourceCulture); + } + } + /// /// Looks up a localized string similar to Stop Date. /// @@ -1113,6 +1140,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Department. + /// + internal static string Department { + get { + return ResourceManager.GetString("Department", resourceCulture); + } + } + /// /// Looks up a localized string similar to Details. /// @@ -3012,6 +3048,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to In Progress. + /// + internal static string InProgress { + get { + return ResourceManager.GetString("InProgress", resourceCulture); + } + } + /// /// Looks up a localized string similar to InterConnected Subscribers. /// @@ -5124,6 +5169,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Batch History Report. + /// + internal static string r_BatchHistoryReport { + get { + return ResourceManager.GetString("r_BatchHistoryReport", resourceCulture); + } + } + /// /// Looks up a localized string similar to Emergency Alarm Report. /// @@ -6681,6 +6735,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Speed. + /// + internal static string Speed { + get { + return ResourceManager.GetString("Speed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Speed Alarm Report. /// @@ -7024,6 +7087,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Batch history. + /// + internal static string tabBatchHist { + get { + return ResourceManager.GetString("tabBatchHist", resourceCulture); + } + } + /// /// Looks up a localized string similar to Geo-Fences. /// @@ -7429,6 +7501,15 @@ namespace Dispatcher.Language { } } + /// + /// Looks up a localized string similar to Time. + /// + internal static string Time { + get { + return ResourceManager.GetString("Time", resourceCulture); + } + } + /// /// Looks up a localized string similar to Time filter. /// diff --git a/Safedispatch_4_0/Language/myRes.resx b/Safedispatch_4_0/Language/myRes.resx index 0be58a6..67c43a4 100644 --- a/Safedispatch_4_0/Language/myRes.resx +++ b/Safedispatch_4_0/Language/myRes.resx @@ -2995,4 +2995,31 @@ Does not apply to the below send message and email options. Successfully SDR service test Failover service + + Batch history + + + Batch History Report + + + Batch History Report + + + Date + + + Department + + + Speed + + + Time + + + Generate Report In Csv + + + In Progress + \ No newline at end of file diff --git a/Safedispatch_4_0/Login.cs b/Safedispatch_4_0/Login.cs index 01fde9d..1f1ea98 100644 --- a/Safedispatch_4_0/Login.cs +++ b/Safedispatch_4_0/Login.cs @@ -441,13 +441,17 @@ namespace Safedispatch_4_0 client = new TcpClient(); IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(MainForm2.cfg.APPLICATION_SERVER_IP), MainForm2.cfg.RegsPort); client.Connect(serverEndPoint); - YourIPaddress = (client.Client.LocalEndPoint.ToString().Split(':'))[0]; + + YourIPaddress = (client.Client.LocalEndPoint.ToString().Split(":".ToCharArray()))[0]; IPaddress = MainForm2.cfg.LocalIP.Length > 3 ? MainForm2.cfg.LocalIP : YourIPaddress; + NetworkStream clientStream = client.GetStream(); - System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); + + UTF8Encoding encoding = new UTF8Encoding(); byte[] buffer = encoding.GetBytes("100"); clientStream.Write(buffer, 0, buffer.Length); SM.Debug("Sent registration request to server, waiting..."); + byte[] message = new byte[256]; clientStream.ReadTimeout = 7000; int result = clientStream.Read(message, 0, message.Length); @@ -457,9 +461,11 @@ namespace Safedispatch_4_0 { client.Close(); Thread.Sleep(100); + client = new TcpClient(); client.Connect(serverEndPoint); buffer = encoding.GetBytes("1000#" + MainForm2.uniqueID + "#"); + NetworkStream clientStream2 = client.GetStream(); clientStream2.Write(buffer, 0, buffer.Length); byte[] message2 = new byte[256]; diff --git a/Safedispatch_4_0/MainForm2.Designer.cs b/Safedispatch_4_0/MainForm2.Designer.cs index b885357..9a9b676 100644 --- a/Safedispatch_4_0/MainForm2.Designer.cs +++ b/Safedispatch_4_0/MainForm2.Designer.cs @@ -187,7 +187,7 @@ namespace Safedispatch_4_0 // // radDock1 // - this.radDock1.ActiveWindow = this.tabSystem; + this.radDock1.ActiveWindow = this.tabGeo; this.radDock1.BackColor = System.Drawing.Color.Transparent; this.radDock1.CausesValidation = false; this.radDock1.Controls.Add(this.documentContainer1); @@ -521,7 +521,7 @@ namespace Safedispatch_4_0 this.rcbDropDropDownUnitEvent.Location = new System.Drawing.Point(13, 157); this.rcbDropDropDownUnitEvent.Name = "rcbDropDropDownUnitEvent"; this.rcbDropDropDownUnitEvent.NullText = "Display all"; - this.rcbDropDropDownUnitEvent.Size = new System.Drawing.Size(260, 20); + this.rcbDropDropDownUnitEvent.Size = new System.Drawing.Size(260, 21); this.rcbDropDropDownUnitEvent.TabIndex = 66; this.rcbDropDropDownUnitEvent.ThemeName = "Office2013Light"; this.rcbDropDropDownUnitEvent.ItemCheckedChanged += new Telerik.WinControls.UI.RadCheckedListDataItemEventHandler(this.rcbDropDropDownUnitEvent_ItemCheckedChanged); @@ -545,7 +545,7 @@ namespace Safedispatch_4_0 this.rdpEndTime.MaxDate = new System.DateTime(2030, 12, 31, 0, 0, 0, 0); this.rdpEndTime.Name = "rdpEndTime"; this.rdpEndTime.NullText = "Display all"; - this.rdpEndTime.Size = new System.Drawing.Size(232, 20); + this.rdpEndTime.Size = new System.Drawing.Size(232, 21); this.rdpEndTime.TabIndex = 65; this.rdpEndTime.TabStop = false; this.rdpEndTime.ThemeName = "Office2013Light"; @@ -561,7 +561,7 @@ namespace Safedispatch_4_0 this.rdpStartTime.MinDate = new System.DateTime(2015, 1, 1, 0, 0, 0, 0); this.rdpStartTime.Name = "rdpStartTime"; this.rdpStartTime.NullText = "Display all"; - this.rdpStartTime.Size = new System.Drawing.Size(233, 20); + this.rdpStartTime.Size = new System.Drawing.Size(233, 21); this.rdpStartTime.TabIndex = 64; this.rdpStartTime.TabStop = false; this.rdpStartTime.Text = "Thu, 01/01/2015, 00:00"; @@ -604,7 +604,7 @@ namespace Safedispatch_4_0 this.rcbDropDownEventType.Location = new System.Drawing.Point(13, 15); this.rcbDropDownEventType.Name = "rcbDropDownEventType"; this.rcbDropDownEventType.NullText = "Display all"; - this.rcbDropDownEventType.Size = new System.Drawing.Size(260, 20); + this.rcbDropDownEventType.Size = new System.Drawing.Size(260, 21); this.rcbDropDownEventType.TabIndex = 60; this.rcbDropDownEventType.ThemeName = "Office2013Light"; this.rcbDropDownEventType.ItemCheckedChanged += new Telerik.WinControls.UI.RadCheckedListDataItemEventHandler(this.rcbDropDownEventType_ItemCheckedChanged); @@ -752,7 +752,7 @@ namespace Safedispatch_4_0 this.pbFilterDirection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.pbFilterDirection.Cursor = System.Windows.Forms.Cursors.Hand; this.pbFilterDirection.Image = global::Dispatcher.Properties.Resources.s_filter_direction_grey; - this.pbFilterDirection.Location = new System.Drawing.Point(565, -1); + this.pbFilterDirection.Location = new System.Drawing.Point(557, -1); this.pbFilterDirection.Name = "pbFilterDirection"; this.pbFilterDirection.Size = new System.Drawing.Size(24, 24); this.pbFilterDirection.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -768,7 +768,7 @@ namespace Safedispatch_4_0 this.pbFilterType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.pbFilterType.Cursor = System.Windows.Forms.Cursors.Hand; this.pbFilterType.Image = global::Dispatcher.Properties.Resources.s_filter_type_grey; - this.pbFilterType.Location = new System.Drawing.Point(595, -1); + this.pbFilterType.Location = new System.Drawing.Point(587, -1); this.pbFilterType.Name = "pbFilterType"; this.pbFilterType.Size = new System.Drawing.Size(24, 24); this.pbFilterType.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -784,7 +784,7 @@ namespace Safedispatch_4_0 this.pbFilterUnit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.pbFilterUnit.Cursor = System.Windows.Forms.Cursors.Hand; this.pbFilterUnit.Image = global::Dispatcher.Properties.Resources.s_filter_user_grey; - this.pbFilterUnit.Location = new System.Drawing.Point(624, -1); + this.pbFilterUnit.Location = new System.Drawing.Point(616, -1); this.pbFilterUnit.Name = "pbFilterUnit"; this.pbFilterUnit.Size = new System.Drawing.Size(24, 24); this.pbFilterUnit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -1023,7 +1023,7 @@ namespace Safedispatch_4_0 // // this.documentTabStrip1.RootElement.MinSize = new System.Drawing.Size(0, 0); - this.documentTabStrip1.SelectedIndex = 9; + this.documentTabStrip1.SelectedIndex = 1; this.documentTabStrip1.Size = new System.Drawing.Size(1017, 581); this.documentTabStrip1.TabIndex = 0; this.documentTabStrip1.TabStop = false; @@ -1057,10 +1057,10 @@ namespace Safedispatch_4_0 // this.tabGeo.Caption = null; this.tabGeo.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.tabGeo.Location = new System.Drawing.Point(5, 33); + this.tabGeo.Location = new System.Drawing.Point(5, 32); this.tabGeo.Name = "tabGeo"; this.tabGeo.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.tabGeo.Size = new System.Drawing.Size(1007, 543); + this.tabGeo.Size = new System.Drawing.Size(1007, 544); this.tabGeo.Tag = "GEOFENCE"; this.tabGeo.Text = "Geo-Fences and Landmarks"; this.tabGeo.ToolTipText = "Geofence"; @@ -1071,14 +1071,15 @@ namespace Safedispatch_4_0 // this.tabHistory.Caption = null; this.tabHistory.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.tabHistory.Location = new System.Drawing.Point(5, 33); + this.tabHistory.Location = new System.Drawing.Point(5, 32); this.tabHistory.Name = "tabHistory"; this.tabHistory.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.tabHistory.Size = new System.Drawing.Size(1007, 543); + this.tabHistory.Size = new System.Drawing.Size(1007, 544); this.tabHistory.Tag = "HISTORY"; this.tabHistory.Text = "History"; this.tabHistory.Enter += new System.EventHandler(this.tabHistory_Enter); this.tabHistory.Leave += new System.EventHandler(this.tabHistory_Leave); + // // tabSMS // @@ -1100,10 +1101,10 @@ namespace Safedispatch_4_0 // this.tabTicketing.Caption = null; this.tabTicketing.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.tabTicketing.Location = new System.Drawing.Point(5, 33); + this.tabTicketing.Location = new System.Drawing.Point(5, 32); this.tabTicketing.Name = "tabTicketing"; this.tabTicketing.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.TabbedDocument; - this.tabTicketing.Size = new System.Drawing.Size(1007, 543); + this.tabTicketing.Size = new System.Drawing.Size(1007, 544); this.tabTicketing.Tag = "TICKETING"; this.tabTicketing.Text = "Job Ticketing"; this.tabTicketing.Enter += new System.EventHandler(this.tabTicketing_Enter); @@ -1114,10 +1115,10 @@ namespace Safedispatch_4_0 this.tabReport.Caption = null; this.tabReport.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.tabReport.ForeColor = System.Drawing.Color.Black; - this.tabReport.Location = new System.Drawing.Point(5, 33); + this.tabReport.Location = new System.Drawing.Point(5, 32); this.tabReport.Name = "tabReport"; this.tabReport.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.tabReport.Size = new System.Drawing.Size(1007, 543); + this.tabReport.Size = new System.Drawing.Size(1007, 544); this.tabReport.Tag = "REPORTS"; this.tabReport.Text = "Reports"; this.tabReport.Enter += new System.EventHandler(this.tabReport_Enter); @@ -1139,11 +1140,11 @@ namespace Safedispatch_4_0 // this.tabNewRadio.Caption = null; this.tabNewRadio.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.tabNewRadio.Location = new System.Drawing.Point(5, 33); + this.tabNewRadio.Location = new System.Drawing.Point(5, 32); this.tabNewRadio.Margin = new System.Windows.Forms.Padding(0); this.tabNewRadio.Name = "tabNewRadio"; this.tabNewRadio.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Floating; - this.tabNewRadio.Size = new System.Drawing.Size(1007, 543); + this.tabNewRadio.Size = new System.Drawing.Size(1007, 544); this.tabNewRadio.Tag = "RADIO"; this.tabNewRadio.Text = "Radio"; this.tabNewRadio.Enter += new System.EventHandler(this.tabNewRadio_Enter); diff --git a/Safedispatch_4_0/MainForm2.cs b/Safedispatch_4_0/MainForm2.cs index 302c096..0cf4f65 100644 --- a/Safedispatch_4_0/MainForm2.cs +++ b/Safedispatch_4_0/MainForm2.cs @@ -34,6 +34,8 @@ using System.Text; using Telerik.WinControls.Layouts; using Telerik.WinControls.Enumerations; +using resources = Dispatcher.Properties.Resources; + namespace Safedispatch_4_0 { public partial class MainForm2 : Telerik.WinControls.UI.RadForm @@ -487,10 +489,12 @@ namespace Safedispatch_4_0 tabReport.Text = returnLNGString("tabRep"); tabVoice.Text = returnLNGString("tabVoice"); tabNewRadio.Text = returnLNGString("radio"); + if (radioType == RADIOTYPE.LINX || radioType == RADIOTYPE.LINXB) tabNewRadio.Text = returnLNGString("voice"); if (radioType == RADIOTYPE.REPEATER_TRBO) tabVoice.Text = returnLNGString("tabrec"); + tabSMS.Text = returnLNGString("tabSMS"); tabAlerts.Text = returnLNGString("tabAlerts"); tabTicketing.Text = returnLNGString("tabTicketing"); @@ -504,6 +508,7 @@ namespace Safedispatch_4_0 SystemGridView.Columns["SysEventMsg"].HeaderText = returnLNGString("eventype"); SystemGridView.Columns["HumanMsg"].HeaderText = returnLNGString("eventMessage"); SystemGridView.Columns["timecmd"].HeaderText = returnLNGString("datetimefil"); + documentWindow3.Text = returnLNGString("filters"); rcbAutoRefresh.Text = returnLNGString("enableautorefreshgrid"); btForceRefresh.Text = MainForm2.returnLNGString("forceRefresh"); @@ -528,12 +533,14 @@ namespace Safedispatch_4_0 iconThemeType = IconTheme.GetIconType(HashVal["iconTheme"].ToString()); SafeMobileLib.Utils.WriteLine("IconType is: " + HashVal["iconTheme"].ToString(), ConsoleColor.Yellow); } + //get Separator string decimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; // if (MainForm2.culture.Name.StartsWith("en")) DayFirst = false; Console.WriteLine("PC culture: " + System.Globalization.CultureInfo.CurrentCulture.Name); if (System.Globalization.CultureInfo.CurrentCulture.Name.StartsWith("en")) DayFirst = false; else DayFirst = true; + String tmpLat = (String)HashVal["startLar"]; String tmpLng = (String)HashVal["startLng"]; if ((decimalSeparator == ",") && (tmpLat.Contains("."))) @@ -546,6 +553,7 @@ namespace Safedispatch_4_0 tmpLat = tmpLat.Replace(",", "."); tmpLng = tmpLng.Replace(",", "."); } + try { LatStart = Convert.ToDouble(tmpLat); @@ -572,6 +580,7 @@ namespace Safedispatch_4_0 LngStart = -88.02413; SM.Debug("Error load LAT, LNG Start force default LatStart = 42.060647,LngStart = -88.024134"); } + try { ZoomStart = Convert.ToInt32(Convert.ToDecimal(HashVal["startZoom"])); @@ -583,6 +592,7 @@ namespace Safedispatch_4_0 SM.Debug("Error load Zoom Start force default ZoomStart = 2"); } isInMile = StaticMembers.isInMile = (((String)HashVal["startUnits"]) == "0") ? false : true; + try { if (((String)HashVal["startAddress"]) == "0") is24hours = false; @@ -612,10 +622,8 @@ namespace Safedispatch_4_0 String tmpVal = HashVal["liveMultiColor"].ToString().ToUpper(); if ((tmpVal.CompareTo("TRUE") == 0) || (tmpVal.CompareTo("FALSE") == 0)) { - if (Convert.ToBoolean(HashVal["liveMultiColor"]) == true) - MainForm2.iconType = IconType.ARROWS; - else - MainForm2.iconType = IconType.ICONS; + MainForm2.iconType = Convert.ToBoolean(HashVal["liveMultiColor"]) == true ? IconType.ARROWS : IconType.ICONS; + } else { @@ -623,6 +631,7 @@ namespace Safedispatch_4_0 else if (((String)HashVal["liveMultiColor"]).CompareTo("1") == 0) MainForm2.iconType = IconType.ARROWS; else MainForm2.iconType = IconType.EMERG; } + if (isInMile) Measure = " " + milesh; else Measure = " " + kmh; } @@ -669,13 +678,8 @@ namespace Safedispatch_4_0 continue; List listRadgw = DBgw.gelAllRadioGateways_forUser(rad.Id, MainForm2.userIDX); - foreach (RadioGateway radgw in listRadgw) - { - if (radgw.Gw_voice == 1) - { - MainForm2.myGatewaylist.Add(radgw); - } - } + MainForm2.myGatewaylist.AddRange(listRadgw.Where(x => x.Gw_voice == 1).ToList()); + } } @@ -742,9 +746,10 @@ namespace Safedispatch_4_0 if (SMSDecide) hasSMS = true; - - //foreach (VehandID obj in vehandIDList) - for (int i=0;i vehnames Ex:" + ex.ToString()); } + + //==================================== ///get telemetry info for each vehicle + //==================================== try { + string veh_name = ""; + DBtelemetryManager tmptel = new DBtelemetryManager(ServerDBip, Schema, UserDB, PassDB, PortDB); List ListAllTelem = tmptel.getAllTelemetryObjsAll(); Utils.WriteLine("TelemALL count:" + ListAllTelem.Count); List ListPosTelem = tmptel.GetTelemetryPOSAll(); Utils.WriteLine("telemPOS count:" + ListPosTelem.Count); + foreach (TelemetryObj obj in ListAllTelem) { - if (VehIDHash[obj.Sc_Id] != null) + veh_name = (String)VehIDHash[obj.Sc_Id]; + + if (!string.IsNullOrEmpty(veh_name)) { - ((Vehicle)vehicleHT[VehIDHash[obj.Sc_Id]]).telemList.Add(obj); - ((VehicleForReports)StaticMembers.vehicleHT[VehIDHash[obj.Sc_Id]]).telemList.Add(obj); + ((Vehicle)vehicleHT[veh_name]).telemList.Add(obj); + ((VehicleForReports)StaticMembers.vehicleHT[veh_name]).telemList.Add(obj); } } foreach (TelemetryPOS obj in ListPosTelem) { - if (VehIDHash[obj.Sc_id] != null) + veh_name = (String)VehIDHash[obj.Sc_id]; + + if (!string.IsNullOrEmpty(veh_name)) { - ((Vehicle)vehicleHT[VehIDHash[obj.Sc_id]]).telemPos = obj; - ((VehicleForReports)StaticMembers.vehicleHT[VehIDHash[obj.Sc_id]]).telemPos = obj; + ((Vehicle)vehicleHT[veh_name]).telemPos = obj; + ((VehicleForReports)StaticMembers.vehicleHT[veh_name]).telemPos = obj; } } @@ -944,12 +976,15 @@ namespace Safedispatch_4_0 Utils.WriteLine("lastpos <> vehnames EX:" + ex.ToString()); } + //=========================== //job ticketing statuses + //=========================== try { DBTicketingManager DBT = new DBTicketingManager(cfg.DB_IP, cfg.DB_schema, cfg.DB_user, cfg.DB_passwd, cfg.DB_port); List ticketStatuses = DBT.getAllTicketStatuses(); Utils.WriteLine("Job ticketing statuses count:" + ticketStatuses.Count); + foreach (TicketingStatus obj in ticketStatuses) // add ticket to hash { @@ -1150,10 +1185,15 @@ namespace Safedispatch_4_0 foreach (SMposition obj in currentPositions) { - if ((Vehicle)vehicleHT[obj.m_vehName] != null) + + //==================================================== + Vehicle vehicle = vehicleHT[obj.m_vehName] as Vehicle; + //==================================================== + + if (vehicle != null) { //SM.Debug("Compare Time1: " + obj.m_time + " " + ((Vehicle)vehicleHT[obj.m_vehName]).lastTime + " NAME: " + obj.m_vehName); - if (obj.m_time >= ((Vehicle)vehicleHT[obj.m_vehName]).lastActivityTime) + if (obj.m_time >= vehicle.lastActivityTime) { foreach (LiveTabWind objw in LiveTabs.Values) { @@ -1163,68 +1203,77 @@ namespace Safedispatch_4_0 else if (MapType == MapTYPE.ArcGis) tabNameSel = objw.livetabgis.tabName; - ((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).vehCompute = false; - if (((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).isActive) + //================================================================ + MapElement mapElement = vehicle.MapsHT[tabNameSel] as MapElement; + //================================================================ + + mapElement.vehCompute = false; + if (mapElement.isActive) { //SM.Debug("Compare PArt2: " + ((Vehicle)vehicleHT[obj.m_vehName]).lastTime + " < " + (timenowsec - (Livelastmin * 60)) + " NAME: " + obj.m_vehName); //vehCompute = true; if (HideInactiveUnitsCheck) - if (((Vehicle)vehicleHT[obj.m_vehName]).lastActivityTime < (timenowsec - (Livelastmin * 30))) + if (vehicle.lastActivityTime < (timenowsec - (Livelastmin * 30))) { SM.Debug("Deactivate Pushpin from compute"); - ((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).DeactivatePushpin(); + mapElement.DeactivatePushpin(); //vehCompute = true; if (MapType == MapTYPE.Google) { objw.livetab.deleteDsetcomand += "," + obj.m_vehName; - ((Vehicle)vehicleHT[obj.m_vehName]).RemoveFromMap = true; + vehicle.RemoveFromMap = true; } } - else { ((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).vehCompute = true; } - else { ((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).vehCompute = true; } + else { mapElement.vehCompute = true; } + else { mapElement.vehCompute = true; } } else { if (HideInactiveUnitsCheck) - if ((((Vehicle)vehicleHT[obj.m_vehName]).lastActivityTime > (timenowsec - (Livelastmin * 30))) - && (((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).itemCheck)) + if ((vehicle.lastActivityTime > (timenowsec - (Livelastmin * 30))) + && (mapElement.itemCheck)) { - ((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).ActivatePushPin(); - ((MapElement)(((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel])).vehCompute = true; + mapElement.ActivatePushPin(); + mapElement.vehCompute = true; } } } - ((Vehicle)vehicleHT[obj.m_vehName]).SetLAT(obj.m_lat); - ((Vehicle)vehicleHT[obj.m_vehName]).SetLNG(obj.m_lng); - ((Vehicle)vehicleHT[obj.m_vehName]).SetALT(obj.m_alt); - ((Vehicle)vehicleHT[obj.m_vehName]).SetTime(obj.m_time); + vehicle.SetLAT(obj.m_lat); + vehicle.SetLNG(obj.m_lng); + vehicle.SetALT(obj.m_alt); + vehicle.SetTime(obj.m_time); // update the last Valid GPS Time if ((Math.Round(obj.m_lat) != 0) || (Math.Round(obj.m_lng) != 0)) - ((Vehicle)vehicleHT[obj.m_vehName]).SetValidGPSTime(obj.m_time); + vehicle.SetValidGPSTime(obj.m_time); - ((Vehicle)vehicleHT[obj.m_vehName]).SetSpeed(obj.m_speed); - ((Vehicle)vehicleHT[obj.m_vehName]).SetDI(obj.m_di); - ((Vehicle)vehicleHT[obj.m_vehName]).SetDO(obj.m_do); + vehicle.SetSpeed(obj.m_speed); + vehicle.SetDI(obj.m_di); + vehicle.SetDO(obj.m_do); foreach (LiveTabWind objw in LiveTabs.Values) { String tabNameSel = ""; - if (MapType == MapTYPE.Google) tabNameSel = objw.livetab.tabName; + if (MapType == MapTYPE.Google) tabNameSel = objw.livetab.tabName; else if (MapType == MapTYPE.ArcGis) tabNameSel = objw.livetabgis.tabName; - if ((System.Math.Round(obj.m_lat) == 0) && (System.Math.Round(obj.m_lng) == 0)) ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).vehCompute = false; - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).vehCompute) + + //================================================================ + MapElement mapElement = vehicle.MapsHT[tabNameSel] as MapElement; + //================================================================ + + if ((System.Math.Round(obj.m_lat) == 0) && (System.Math.Round(obj.m_lng) == 0)) mapElement.vehCompute = false; + if (mapElement.vehCompute) { - bool newLalLong = ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).SetLastLocation(); + bool newLalLong = mapElement.SetLastLocation(); #region NEW POSITION RECEIVED if (newLalLong) { try { - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).SetLastPushpin(); - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).ActivatePushPin(); + mapElement.SetLastPushpin(); + mapElement.ActivatePushPin(); } catch (Exception ex) { @@ -1234,15 +1283,15 @@ namespace Safedispatch_4_0 if (MapType == MapTYPE.Google) { //Google choice - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp != null) + if (mapElement.pp != null) { - AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, ((Vehicle)vehicleHT[obj.m_vehName]).LAT, ((Vehicle)vehicleHT[obj.m_vehName]).LNG)); - ((Vehicle)vehicleHT[obj.m_vehName]).SetLastAddress(msgRetAddr); - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note += "
" + FixComma(((Vehicle)vehicleHT[obj.m_vehName]).lastAddress); + AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, vehicle.LAT, vehicle.LNG)); + vehicle.SetLastAddress(msgRetAddr); + mapElement.pp.Note += "
" + FixComma(vehicle.lastAddress); } - DateTime positionTime = (((Vehicle)vehicleHT[obj.m_vehName]).lastValidPositionTime.ConvertGMTToLocal()).GetDTFromSeconds(); + DateTime positionTime = (vehicle.lastValidPositionTime.ConvertGMTToLocal()).GetDTFromSeconds(); // change scheduled value to future position to be displayed in the grid string timeAgo = LiveGridCellElement.GetDateTimeAgo(positionTime); @@ -1257,14 +1306,14 @@ namespace Safedispatch_4_0 time = String.Format("{0, 17} [{1:MM/dd/yyyy HH:mm:ss}]", time, positionTime); - string iconName = ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.GetSymbName(); + string iconName = mapElement.pp.GetSymbName(); if (((Vehicle)vehicleHT[obj.m_vehName]).is_emergency) { iconName = iconName.Replace(".png", "_FF79A6_l.png"); // check and create emergency icon - CheckCreateEmergencyIcon(((Vehicle)vehicleHT[obj.m_vehName]).IconID); + CheckCreateEmergencyIcon(vehicle.IconID); } @@ -1273,98 +1322,99 @@ namespace Safedispatch_4_0 + FixDoubleLAT(obj.m_lat.ToString()) + "," + FixDoubleLNG(obj.m_lng.ToString()) + "," + positionTime.ToString("yyyy-MM-dd HH:mm:ss") + "," - + ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Name + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).GetSpeed() + (MainForm2.isInMile ? "mph" : "kph") + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).GetAlt() + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).GetLastAddress().Replace(',', ' ') + "," - //+ ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.GetSymbName() + "," + + mapElement.pp.Name + "," + + vehicle.GetSpeed() + (MainForm2.isInMile ? "mph" : "kph") + "," + + vehicle.GetAlt() + "," + + vehicle.GetLastAddress().Replace(',', ' ') + "," + //+ mapElement.pp.GetSymbName() + "," + iconName + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).has_voice + "," + ((Vehicle)vehicleHT[obj.m_vehName]).has_text + "," + ((Vehicle)vehicleHT[obj.m_vehName]).inCall; + + vehicle.has_voice + "," + vehicle.has_text + "," + vehicle.inCall; //+ ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note + "," if ((NoteAddr[obj.m_vehName] == null)) - NoteAddr.Add(obj.m_vehName, ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note); + NoteAddr.Add(obj.m_vehName, mapElement.pp.Note); else - NoteAddr[obj.m_vehName] = ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note; + NoteAddr[obj.m_vehName] = mapElement.pp.Note; } else if (MapType == MapTYPE.ArcGis) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).GISID != -1) - AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, ((Vehicle)vehicleHT[obj.m_vehName]).LAT, ((Vehicle)vehicleHT[obj.m_vehName]).LNG)); + if (mapElement.GISID != -1) + AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, vehicle.LAT, vehicle.LNG)); } } #endregion else { - if (((Vehicle)vehicleHT[obj.m_vehName]).lastAddress.CompareTo("") == 0) + if (vehicle.lastAddress.CompareTo("") == 0) { if (MapType == MapTYPE.Google) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp != null) - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note = langSpeed + " " - + Convert.ToString(((Vehicle)vehicleHT[obj.m_vehName]).GetSpeed()) + Measure + " " - + langTime + " " + ((Vehicle)vehicleHT[obj.m_vehName]).lastActivityTime.TimeOfDayHHMMLocal(); + if (mapElement.pp != null) + mapElement.pp.Note = langSpeed + " " + + Convert.ToString(vehicle.GetSpeed()) + Measure + " " + + langTime + " " + vehicle.lastActivityTime.TimeOfDayHHMMLocal(); } else if (MapType == MapTYPE.ArcGis) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).GISID != -1) - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).UpdateLabelCMD(false); + if (mapElement.GISID != -1) + mapElement.UpdateLabelCMD(false); } } else if (MapType == MapTYPE.Google) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp != null) - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note = langSpeed + " " - + Convert.ToString(((Vehicle)vehicleHT[obj.m_vehName]).GetSpeed()) + Measure + " " - + langTime + " " + ((Vehicle)vehicleHT[obj.m_vehName]).lastActivityTime.TimeOfDayHHMMLocal() - + "
" + ((Vehicle)vehicleHT[obj.m_vehName]).lastAddress.Replace(',', ' '); + if (mapElement.pp != null) + mapElement.pp.Note = langSpeed + " " + + Convert.ToString(vehicle.GetSpeed()) + Measure + " " + + langTime + " " + vehicle.lastActivityTime.TimeOfDayHHMMLocal() + + "
" + vehicle.lastAddress.Replace(',', ' '); } else if (MapType == MapTYPE.ArcGis) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).GISID != -1) - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).UpdateLabelCMD(true); + if (mapElement.GISID != -1) + mapElement.UpdateLabelCMD(true); } } //cand dau check si nu aret address ala lastpos - if ((((Vehicle)vehicleHT[obj.m_vehName]).lastAddress.CompareTo("") == 0) || (((Vehicle)vehicleHT[obj.m_vehName]).lastAddress.CompareTo(" ") == 0)) + if ((((Vehicle)vehicleHT[obj.m_vehName]).lastAddress.CompareTo("") == 0) || (vehicle.lastAddress.CompareTo(" ") == 0)) { if (MapType == MapTYPE.Google) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp != null) + if (mapElement.pp != null) { //google choice - AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, ((Vehicle)vehicleHT[obj.m_vehName]).LAT, ((Vehicle)vehicleHT[obj.m_vehName]).LNG)); - ((Vehicle)vehicleHT[obj.m_vehName]).SetLastAddress(msgRetAddr); - ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note += "
" + FixComma(((Vehicle)vehicleHT[obj.m_vehName]).lastAddress); + AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, vehicle.LAT, vehicle.LNG)); + vehicle.SetLastAddress(msgRetAddr); + mapElement.pp.Note += "
" + FixComma(vehicle.lastAddress); //} } } else if (MapType == MapTYPE.ArcGis) { - if (((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).GISID != -1) - AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, ((Vehicle)vehicleHT[obj.m_vehName]).LAT, ((Vehicle)vehicleHT[obj.m_vehName]).LNG)); + if (mapElement.GISID != -1) + AddrGISQueue.Enqueue(new AddrAndID(obj.m_vehName, vehicle.LAT, vehicle.LNG)); } } + if (MapType == MapTYPE.Google) { if (NoteAddr[obj.m_vehName] != null) - if (((String)NoteAddr[obj.m_vehName]) != ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Note) + if (((String)NoteAddr[obj.m_vehName]) != mapElement.pp.Note) { - DateTime positionTime = ((Vehicle)vehicleHT[obj.m_vehName]).lastValidPositionTime.ConvertGMTToLocal().GetDTFromSeconds(); + DateTime positionTime = vehicle.lastValidPositionTime.ConvertGMTToLocal().GetDTFromSeconds(); - string iconName = ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.GetSymbName(); + string iconName = mapElement.pp.GetSymbName(); - if (((Vehicle)vehicleHT[obj.m_vehName]).is_emergency) + if (vehicle.is_emergency) { iconName = iconName.Replace(".png", "_FF79A6_l.png"); // check and create emergency icon - CheckCreateEmergencyIcon(((Vehicle)vehicleHT[obj.m_vehName]).IconID); + CheckCreateEmergencyIcon(vehicle.IconID); } @@ -1372,11 +1422,13 @@ namespace Safedispatch_4_0 #region mapCallTimeout int mapCallTimeout = 3; ((Vehicle)MainForm2.vehicleHT[obj.m_vehName]).CheckPositionInSystem(); - string GatewayAndRadioID = ((Vehicle)MainForm2.vehicleHT[obj.m_vehName]).GwandRadioID; + string GatewayAndRadioID = vehicle.GwandRadioID; int gwType = (int)GatewayType.Unknown; + if (MainForm2.radioGwHT[GatewayAndRadioID] != null) { - if (((RadioGateway)MainForm2.radioGwHT[GatewayAndRadioID]).Type == (int)GatewayType.Broadband || ((RadioGateway)MainForm2.radioGwHT[GatewayAndRadioID]).Type == (int)GatewayType.Tier3Radio) + if (((RadioGateway)MainForm2.radioGwHT[GatewayAndRadioID]).Type == (int)GatewayType.Broadband || + ((RadioGateway)MainForm2.radioGwHT[GatewayAndRadioID]).Type == (int)GatewayType.Tier3Radio) { mapCallTimeout = MainForm2.MapCallTimeout; } @@ -1386,18 +1438,18 @@ namespace Safedispatch_4_0 #endregion bool hasVoice = documentTabStrip1.Controls.Contains(tabVoice) || documentTabStrip1.Controls.Contains(tabNewRadio); - bool hasText = documentTabStrip1.Controls.Contains(tabSMS); + bool hasText = documentTabStrip1.Controls.Contains(tabSMS); // set the command which will contains the points icon, name, speed, lat, lng, altitude, address objw.livetab.updatecomand = objw.livetab.updatecomand + "," + FixDoubleLAT(obj.m_lat.ToString()) + "," + FixDoubleLNG(obj.m_lng.ToString()) + "," + positionTime.ToString("yyyy-MM-dd HH:mm:ss") + "," - + ((MapElement)((Vehicle)vehicleHT[obj.m_vehName]).MapsHT[tabNameSel]).pp.Name + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).GetSpeed() + (MainForm2.isInMile ? "mph" : "kph") + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).GetAlt() + "," - + ((Vehicle)vehicleHT[obj.m_vehName]).GetLastAddress().Replace(',', ' ') + "," - + iconName + "," + (hasVoice ? mapCallTimeout : 0) + "," + (hasText ? smsLength : 0) + "," + ((Vehicle)vehicleHT[obj.m_vehName]).inCall; + + mapElement.pp.Name + "," + + vehicle.GetSpeed() + (MainForm2.isInMile ? "mph" : "kph") + "," + + vehicle.GetAlt() + "," + + vehicle.GetLastAddress().Replace(',', ' ') + "," + + iconName + "," + (hasVoice ? mapCallTimeout : 0) + "," + (hasText ? smsLength : 0) + "," + vehicle.inCall; } @@ -1424,47 +1476,13 @@ namespace Safedispatch_4_0 public static Int32 getMapPointZoom() { - Int32 toreturn = 32000; - switch (MainForm2.ZoomStart) - { - case 0: - toreturn = 1; - break; - case 1: - toreturn = 3; - break; - case 2: - toreturn = 8; - break; - case 3: - toreturn = 24; - break; - case 4: - toreturn = 70; - break; - case 5: - toreturn = 200; - break; - case 6: - toreturn = 580; - break; - case 7: - toreturn = 1700; - break; - case 8: - toreturn = 5000; - break; - case 9: - toreturn = 10000; - break; - case 10: - toreturn = 32000; - break; - default: - toreturn = 32000; - break; - } - return toreturn; + Int32[] toreturn = { 1, 2, 8, 24, 70, 200, 580, 1700, 5000, 10000, 32000 }; + + if ( MainForm2.ZoomStart >=0 && MainForm2.ZoomStart <= 10) + return toreturn[MainForm2.ZoomStart]; + + return 32000; + } #endregion @@ -1520,6 +1538,7 @@ namespace Safedispatch_4_0 } cntlive++; break; + case track_type.HIST: if (MapType == MapTYPE.Google) { @@ -1542,6 +1561,7 @@ namespace Safedispatch_4_0 } cntlive++; break; + case track_type.LANDZONE: if (MapType == MapTYPE.Google) { @@ -1561,6 +1581,7 @@ namespace Safedispatch_4_0 } cntlive++; break; + case track_type.SMS: SMSControl = new SMSuserControl(this); SMSControl.Visible = true; @@ -1568,6 +1589,7 @@ namespace Safedispatch_4_0 SMSControl.Location = new System.Drawing.Point(0, 0); toolwin.Controls.Add(SMSControl); break; + case track_type.TICKETING: TicketingControl = new TicketingUserControl(this); TicketingControl.Visible = true; @@ -1575,6 +1597,7 @@ namespace Safedispatch_4_0 TicketingControl.Location = new System.Drawing.Point(0, 0); toolwin.Controls.Add(TicketingControl); break; + case track_type.RADIO: try { @@ -1591,6 +1614,7 @@ namespace Safedispatch_4_0 SM.Debug("Erorr create radio:" + ex.ToString()); } break; + case track_type.REPORTS: RepControl = new ReportCont(); RepControl.Visible = true; @@ -1598,6 +1622,7 @@ namespace Safedispatch_4_0 RepControl.Location = new System.Drawing.Point(0, 0); toolwin.Controls.Add(RepControl); break; + case track_type.TELEM: if (MapType == MapTYPE.Google) { @@ -1665,13 +1690,14 @@ namespace Safedispatch_4_0 while (line != default(string)) { - string[] tempArr = line.Split('#'); + string[] tempArr = line.Split("#".ToCharArray()); if (tempArr.Length > 4 && tempArr[3].Equals("153")) { string radioID = tempArr[4]; Status_for_tab status = (Status_for_tab)Convert.ToInt32(tempArr[5]); String nameveh = VehIMEIHash[radioID].ToString(); + int sc_id = ((Vehicle)vehicleHT[nameveh]).sc_id; if (VehIDHash[sc_id] != null) @@ -1721,7 +1747,7 @@ namespace Safedispatch_4_0 while (line != default(string)) { - string[] tempArr = line.Split('#'); + string[] tempArr = line.Split("#".ToCharArray()); if (tempArr.Length > 4 && (tempArr[3].Equals("131") || tempArr[3].Equals("231"))) { @@ -1759,29 +1785,34 @@ namespace Safedispatch_4_0 String nameveh = VehIMEIHash[radioID].ToString(); + + //================================================== + Vehicle vehicle = (Vehicle)vehicleHT[nameveh]; + //================================================== + //UpdateStatusLive(nameveh); - int sc_id = ((Vehicle)vehicleHT[nameveh]).sc_id; + int sc_id = vehicle.sc_id; - ((Vehicle)vehicleHT[nameveh]).SetSpeed((byte)tmpCOM.speed); + vehicle.SetSpeed((byte)tmpCOM.speed); if (tmpCOM.lat != 0 || tmpCOM.lng != 0) { - ((Vehicle)vehicleHT[nameveh]).SetLAT(tmpCOM.lat); - ((Vehicle)vehicleHT[nameveh]).SetLNG(tmpCOM.lng); + vehicle.SetLAT(tmpCOM.lat); + vehicle.SetLNG(tmpCOM.lng); } - ((Vehicle)vehicleHT[nameveh]).SetALT(tmpCOM.alt); - ((Vehicle)vehicleHT[nameveh]).SetDI((byte)tmpCOM.di); - ((Vehicle)vehicleHT[nameveh]).SetTime(tmpCOM.time); + vehicle.SetALT(tmpCOM.alt); + vehicle.SetDI((byte)tmpCOM.di); + vehicle.SetTime(tmpCOM.time); //((Vehicle)vehicleHT[nameveh]).StartTimer(); if ((Math.Round(tmpCOM.lat) != 0) || (Math.Round(tmpCOM.lng) != 0)) { // update the last Valid GPS Time - ((Vehicle)vehicleHT[nameveh]).SetValidGPSTime(tmpCOM.time); + vehicle.SetValidGPSTime(tmpCOM.time); - ((Vehicle)vehicleHT[nameveh]).needAddress = true; + vehicle.needAddress = true; AddrGISQueue.Enqueue(new AddrAndID(nameveh, tmpCOM.lat, tmpCOM.lng)); if (MapType == MapTYPE.Google) { @@ -1804,33 +1835,38 @@ namespace Safedispatch_4_0 { foreach (String name in ((Vehicle)vehicleHT[nameveh]).MapsHT.Keys) { - if (((HideInactiveUnitsCheck) && ((MapElement)((Vehicle)vehicleHT[nameveh]).MapsHT[name]).itemCheck) || - (emergOnlyCheck && ((Vehicle)vehicleHT[nameveh]).actual_status == Status_for_tab.EMERG)) + + //================================================================ + MapElement mapElement = vehicle.MapsHT[name] as MapElement; + //================================================================ + + if (((HideInactiveUnitsCheck) && mapElement.itemCheck) || + (emergOnlyCheck && vehicle.actual_status == Status_for_tab.EMERG)) { - ((MapElement)((Vehicle)MainForm2.vehicleHT[nameveh]).MapsHT[name]).isActive = true; + mapElement.isActive = true; } // update the location - if ((Math.Round(((Vehicle)vehicleHT[nameveh]).LAT) != 0) && (Math.Round(((Vehicle)vehicleHT[nameveh]).LNG) != 0)) + if (Math.Round(vehicle.LAT) != 0 && Math.Round(vehicle.LNG) != 0) { - ((MapElement)((Vehicle)vehicleHT[nameveh]).MapsHT[name]).SetLastLocation(); + mapElement.SetLastLocation(); } - if (((MapElement)((Vehicle)vehicleHT[nameveh]).MapsHT[name]).isActive) + if (mapElement.isActive) { - if ((Math.Round(((Vehicle)vehicleHT[nameveh]).LAT) != 0) && (Math.Round(((Vehicle)vehicleHT[nameveh]).LNG) != 0)) + if (Math.Round(vehicle.LAT) != 0 && Math.Round(vehicle.LNG) != 0) { - ((MapElement)((Vehicle)vehicleHT[nameveh]).MapsHT[name]).SetLastPushpin(); + mapElement.SetLastPushpin(); Utils.WriteLine("ActivatePushPin on ProgressChanged"); - ((MapElement)((Vehicle)vehicleHT[nameveh]).MapsHT[name]).ActivatePushPin(); + mapElement.ActivatePushPin(); } - if ((MainForm2.POLLunit == nameveh) && ((((Vehicle)vehicleHT[nameveh]).LAT != 0) && (((Vehicle)vehicleHT[nameveh]).LNG != 0))) + if ((MainForm2.POLLunit == nameveh) && (vehicle.LAT != 0 && vehicle.LNG != 0)) { MovePOLL = true; if (MapType == MapTYPE.ArcGis) - ((MapElement)((Vehicle)vehicleHT[nameveh]).MapsHT[name]).AxMapGIS.Extent + mapElement.AxMapGIS.Extent = MainForm2.ZoomTo(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG, ((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT, ((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG, ((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT); Thread.Sleep(1); @@ -1857,12 +1893,12 @@ namespace Safedispatch_4_0 //SafeMobileLib.Utils.WriteLine("UPDATE FROM POSITION ", ConsoleColor.Yellow); bool isFirstPositionForUnit = false; - if (((Vehicle)vehicleHT[nameveh]).lastLocLAT == 0.1 && ((Vehicle)vehicleHT[nameveh]).lastLocLNG == 0.1) + if (vehicle.lastLocLAT == 0.1 && vehicle.lastLocLNG == 0.1) isFirstPositionForUnit = true; - if ((((Vehicle)vehicleHT[nameveh]).LAT != 0) && (((Vehicle)vehicleHT[nameveh]).LNG != 0)) + if (vehicle.LAT != 0 && vehicle.LNG != 0) { - ((Vehicle)vehicleHT[nameveh]).first_live_gps = true; + vehicle.first_live_gps = true; obj.livetab.onGPSPositionReceivedHandler(nameveh, isFirstPositionForUnit); } } @@ -1875,7 +1911,7 @@ namespace Safedispatch_4_0 this.Invoke((MethodInvoker)delegate () { SMSDesktopAlert.FixedSize = new System.Drawing.Size(329, 120); - SMSDesktopAlert.ContentImage = global::Dispatcher.Properties.Resources.alert_gps; + SMSDesktopAlert.ContentImage = resources.alert_gps; html_message = "" + returnLNGString("RecLoc") + ": " + nameveh + " "; SMSDesktopAlert.ContentText = "" + html_message + ""; // mesajul din interior editat cu html title = returnLNGString("pollResp"); @@ -1924,7 +1960,7 @@ namespace Safedispatch_4_0 SystemMessQueue.PostItem(new SystemLog(false, str.Trim())); //find seqID in parse - String[] tmp = str.Split('#'); + String[] tmp = str.Split("#".ToCharArray()); String Station = ""; String GwPlusRadio = ""; Boolean findstation = false; @@ -1990,7 +2026,7 @@ namespace Safedispatch_4_0 case "201": if (Convert.ToInt32(tmp[4]) == userIDX) { - String[] tmpStr = tmp[2].ToString().Split('.'); + String[] tmpStr = tmp[2].ToString().Split(".".ToCharArray()); if (VoiceTabStarted) { RadioTab.PersonalIP = String.Format("224.20.{0}.1", tmpStr[0]); @@ -2006,25 +2042,25 @@ namespace Safedispatch_4_0 { RadioTabControl.StartCallPatch("Dispatcher", "Dispatcher." + tmpStr[0], tmpStr[0].ToString()); } - String[] tmpIP = tmp[5].ToString().Split('.'); + String[] tmpIP = tmp[5].ToString().Split(".".ToCharArray()); SaveValue(tmptime, Convert.ToInt32(tmpIP[2]), Convert.ToInt32(tmp[3])); RadioTabControl.WatchList.Add(seqID); Listcmd.Add(seqID, tmptime); - Send_UDP_cmd_sent_withOutID("#" + tmp[2] + "#221#0#1#"); + Send_UDP_cmd_sent_withOutID($"#{tmp[2]}#221#0#1#"); } } break; case "211": if (Convert.ToInt32(tmp[4]) == userIDX) { - String[] tmpStr = tmp[2].ToString().Split('.'); + String[] tmpStr = tmp[2].ToString().Split(".".ToCharArray()); if (VoiceTabStarted) { RadioTab.PersonalIP = String.Format("224.20.{0}.1", tmpStr[0]); cmdcnt++; seqID = MainForm2.userIDX + "." + cmdcnt; TimerAndResp tmptime = new TimerAndResp(null, false); - String[] tmpIP = tmp[5].ToString().Split('.'); + String[] tmpIP = tmp[5].ToString().Split(".".ToCharArray()); SaveValue(tmptime, Convert.ToInt32(tmpIP[2]), Convert.ToInt32(tmp[3])); RadioTabControl.WatchList.Add(seqID); Listcmd.Add(seqID, tmptime); @@ -2052,12 +2088,15 @@ namespace Safedispatch_4_0 case "125": if (tmp[2] == "0.0" && tmp.Length == 9) // Don't process 125 commands sent by the SD for recordings (for EXCERA or LINX) { - Utils.WriteLine("tmp[4].Split('.')[0] = " + tmp[4].Split('.')[0] + "\r\n" + - "tmp[4].Split('.')[1] = " + tmp[4].Split('.')[1] + "\r\n" + - "tmp[4].Split('.')[2] = " + tmp[4].Split('.')[2] + "\r\n" + + string[] tmp4Arr = tmp[4].Split(".".ToCharArray()); + + Utils.WriteLine("tmp[4].Split('.')[0] = " + tmp4Arr[0] + "\r\n" + + "tmp[4].Split('.')[1] = " + tmp4Arr[1] + "\r\n" + + "tmp[4].Split('.')[2] = " + tmp4Arr[2] + "\r\n" + "int.Parse(tmp[5]) = " + tmp[5] + "\r\n" + "int.Parse(tmp[6]) = " + tmp[6] + "\r\n" + "tmp[7] = " + tmp[7]); + Utils.WriteLine("RECEIVED " + tmp[3] + " | " + int.Parse(tmp[5])); try { @@ -2091,7 +2130,7 @@ namespace Safedispatch_4_0 case "155": //test = "#155#" + rec.id.ToString() + "#" + rec.hddLocation + "#" + rec.gwID + "#" + rec.radioGWID + "#" + rec.Group_ID + "#" + rec.subID.ToString() + "#" + rec.startTime + "#" + rec.endTime + "#" + rec.typeSD + "#" + rec.calltype + "#"; Utils.WriteLine("tmp " + tmp[6] + " | " + tmp[7]); - GwPlusRadio = tmp[6] + '.' + tmp[7]; + GwPlusRadio = $"{tmp[6]}.{tmp[7]}"; RadioTab.responseGW = GwPlusRadio; int callType = -1; Int32.TryParse(tmp[13], out callType); @@ -2180,14 +2219,10 @@ namespace Safedispatch_4_0 } else { - if (strData == "ON") - { - CmdList.Enqueue(new Commands(Convert.ToInt32(tmp[3]), tmp[4], true)); - } - else - { - CmdList.Enqueue(new Commands(Convert.ToInt32(tmp[3]), tmp[4], false)); - } + + bool isArsOn = (strData == "ON"); + CmdList.Enqueue(new Commands(Convert.ToInt32(tmp[3]), tmp[4], isArsOn)); + } } catch (Exception ex) @@ -2319,9 +2354,9 @@ namespace Safedispatch_4_0 // RESPONSE FROM TERMINATNG REQUESTS // Get gwPlusRadio GwPlusRadio = tmp[4]; - string[] parts = GwPlusRadio.Split('.'); + string[] parts = GwPlusRadio.Split(".".ToCharArray()); if (parts.Length > 2) - GwPlusRadio = parts[0] + "." + parts[1]; + GwPlusRadio = $"{parts[0]}.{parts[1]}"; // gateway is not in ptt if (radioGwHT.ContainsKey(GwPlusRadio)) @@ -2345,7 +2380,7 @@ namespace Safedispatch_4_0 { try { - String usermess = tmp[2].Split('.')[0]; + String usermess = tmp[2].Split(".".ToCharArray())[0]; if ((tmp[2] == "0.0") || (Convert.ToInt32(usermess) == userIDX)) { findstation = false; @@ -2396,6 +2431,7 @@ namespace Safedispatch_4_0 string radioGWip = tmp[5]; int radioID0 = Convert.ToInt32(tmp[6]); int radioGateID = 0; + foreach (GatewayIDandIP obj in RadioListIP) { if ((obj.IP == radioGWip) && (obj.GWID == gwID0)) @@ -2450,7 +2486,8 @@ namespace Safedispatch_4_0 if (MapType == MapTYPE.Google) obj.livetab.OnUnitStolenChanged(unitName, isStolen); //obj.livetab.UpdateVehList(name, true); - else if (MapType == MapTYPE.ArcGis) obj.livetabgis.OnUnitStolenChanged(unitName, isStolen); + else if (MapType == MapTYPE.ArcGis) + obj.livetabgis.OnUnitStolenChanged(unitName, isStolen); } }); } @@ -2558,7 +2595,7 @@ namespace Safedispatch_4_0 case "238": try { - string IMEI = tmp[4].Split('.')[2]; + string IMEI = tmp[4].Split(".".ToCharArray())[2]; string unitName = (string)VehIMEIHash[IMEI]; Thread.Sleep(30); @@ -2595,6 +2632,7 @@ namespace Safedispatch_4_0 { obj.livetab.onEmergencyStateChangedHandler(veh, false); } + if (MapType == MapTYPE.ArcGis) { obj.livetabgis.onEmergencyStateChangedHandler(veh, false); @@ -2678,8 +2716,13 @@ namespace Safedispatch_4_0 case "172": if (tmp[2] == "0.0") { - Station = tmp[4].Split('.')[2]; - GwPlusRadio = tmp[4].Split('.')[0] + '.' + tmp[4].Split('.')[1]; + + string[] tmp4Arr = tmp[4].Split(".".ToCharArray()); + if (tmp4Arr == null) + break; + + Station = tmp4Arr[2]; + GwPlusRadio = $"{tmp4Arr[0]}.{tmp4Arr[1]}"; findstation = false; if (MainForm2.VoiceTabStarted) { @@ -2735,12 +2778,13 @@ namespace Safedispatch_4_0 { if (tmp[6] == null) break; + bool status = tmp[6] == "ON" ? true : false; if (OnRadioGatewayStatusChanged != null) OnRadioGatewayStatusChanged(tmp[4] + "." + tmp[5], status); this.Invoke((MethodInvoker)delegate { - SMSDesktopAlert.ContentImage = status ? global::Dispatcher.Properties.Resources.green_status : global::Dispatcher.Properties.Resources.red_status; + SMSDesktopAlert.ContentImage = status ? resources.green_status : resources.red_status; SMSDesktopAlert.ContentText = string.Format(returnLNGString("gwStatusHTML"), tmp[7], tmp[6]); SMSDesktopAlert.CaptionText = returnLNGString("gwStatus"); ; SMSDesktopAlert.Show(); @@ -2897,7 +2941,7 @@ namespace Safedispatch_4_0 DockLayoutPanel dockPanel = new DockLayoutPanel(); LightVisualElement imageElement = new LightVisualElement(); - imageElement.Image = global::Dispatcher.Properties.Resources.red_status; + imageElement.Image = resources.red_status; LightVisualElement textElement = new LightVisualElement(); textElement.TextAlignment = ContentAlignment.MiddleLeft; @@ -2921,7 +2965,7 @@ namespace Safedispatch_4_0 FailoverDesktopAlert.CaptionText = captionText; FailoverDesktopAlert.ContentText = text; - FailoverDesktopAlert.ContentImage = global::Dispatcher.Properties.Resources.red_status; + FailoverDesktopAlert.ContentImage = resources.red_status; FailoverDesktopAlert.Show(); } @@ -3050,11 +3094,13 @@ namespace Safedispatch_4_0 { if (radioGwHT.ContainsKey(gwPlusRadio)) { - ((RadioGateway)(radioGwHT[gwPlusRadio])).State1 = RadioState.TX; - ((RadioGateway)(radioGwHT[gwPlusRadio])).InPTT = true; + RadioGateway radioGateway = (RadioGateway)radioGwHT[gwPlusRadio]; + + radioGateway.State1 = RadioState.TX; + radioGateway.InPTT = true; // notify the radio tab that something changed - RadioTabControl?.OnRadioGatewayStateChanged((RadioGateway)(radioGwHT[gwPlusRadio]), RadioState.TX); + RadioTabControl?.OnRadioGatewayStateChanged(radioGateway, RadioState.TX); } } } @@ -3195,11 +3241,14 @@ namespace Safedispatch_4_0 { try { - foreach (TelemetryObj obj in ((Vehicle)MainForm2.vehicleHT[name]).telemList) + + Vehicle vehicle = (Vehicle)MainForm2.vehicleHT[name]; + + foreach (TelemetryObj obj in vehicle.telemList) if (obj.Name == GPIOName) { - ((Vehicle)MainForm2.vehicleHT[name]).CheckPositionInSystem(); - String Totrans = "#0.0#133#" + ((Vehicle)MainForm2.vehicleHT[name]).GwandRadioID + "." + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#" + obj.DigitalNr + "." + type + "#"; + vehicle.CheckPositionInSystem(); + String Totrans = "#0.0#133#" + vehicle.GwandRadioID + "." + vehicle.IMEI + "#" + obj.DigitalNr + "." + type + "#"; Send_UDP_cmd_sent_withOutID(Totrans); break; } @@ -3221,41 +3270,41 @@ namespace Safedispatch_4_0 { try { + + Vehicle vehicle = (Vehicle)MainForm2.vehicleHT[name]; + String Totrans = ""; switch (Status) { case CMDTYPE.EnableCMD: case CMDTYPE.DisableCMD: - ((Vehicle)MainForm2.vehicleHT[name]).CheckPositionInSystem(); - Totrans = "#" + (Int32)API.RADIO_ENABLE_DISABLE_REQ + "#" + ((Vehicle)MainForm2.vehicleHT[name]).GwandRadioID + "." + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#"; - Totrans += ((int)Status).ToString() + "#"; + vehicle.CheckPositionInSystem(); + Totrans = $"#{(Int32)API.RADIO_ENABLE_DISABLE_REQ}#{vehicle.GwandRadioID}.{vehicle.IMEI}#{(int)Status}#"; break; case CMDTYPE.POLLGPSCMD: - ((Vehicle)MainForm2.vehicleHT[name]).CheckPositionInSystem(); + vehicle.CheckPositionInSystem(); //Totrans = "#" + (Int32)API.POLL_GPS_REQ + "#" + ((Vehicle)MainForm2.vehicleHT[name]).GwandRadioID + "." + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#"; // Add dispatcher (user) id to the poll gps request - Totrans = "#" + (Int32)API.POLL_GPS_REQ + "#" + ((Vehicle)MainForm2.vehicleHT[name]).GwandRadioID + "." + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#" + - userIDX + "#"; + Totrans = $"#{(Int32)API.POLL_GPS_REQ}#{vehicle.GwandRadioID}.{vehicle.IMEI}#{userIDX}#"; break; case CMDTYPE.StolenONCMD: - //Console.WriteLine("Stolen ON SEND"); - Totrans = "#" + (Int32)API.STOLEN_REQ + "#" + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#1#"; - ((Vehicle)MainForm2.vehicleHT[name]).is_stolen = true; + + Totrans = $"#{(Int32)API.STOLEN_REQ}#{vehicle.IMEI}#1#"; + vehicle.is_stolen = true; break; case CMDTYPE.StolenOFFCMD: - //Console.WriteLine("UnStolen ON SEND (Stolen OFF)"); - Totrans = "#" + (Int32)API.STOLEN_REQ + "#" + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#0#"; - ((Vehicle)MainForm2.vehicleHT[name]).is_stolen = false; + + Totrans = $"#{(Int32)API.STOLEN_REQ}#{vehicle.IMEI}#0#"; + vehicle.is_stolen = false; break; // CHECK THE SATUS OF ON UNIT case CMDTYPE.POLLARSCMD: ((Vehicle)MainForm2.vehicleHT[name]).CheckPositionInSystem(); - Totrans = "#" + (Int32)API.POLL_ARS_REQ + "#" + ((Vehicle)MainForm2.vehicleHT[name]).GwandRadioID + "." + ((Vehicle)MainForm2.vehicleHT[name]).IMEI + "#" + - userIDX + "#"; + Totrans = $"#{(Int32)API.POLL_ARS_REQ}#{vehicle.GwandRadioID}.{vehicle.IMEI}#{userIDX}#"; break; } @@ -3300,12 +3349,13 @@ namespace Safedispatch_4_0 public static SDRegistration verifyReg(byte[] message) { SDRegistration toReturn = new SDRegistration(); - System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); + + UTF8Encoding encoding = new UTF8Encoding(); SM.Debug("Received registration from server"); String decodedString = encoding.GetString(message); Console.WriteLine("Result string:" + decodedString); - String[] options = decodedString.Split(';'); + String[] options = decodedString.Split(";".ToCharArray()); //option[19] = audible alerts ; option[20] = db access; if(options[19] != null) hasAudibleAlerts = (options[19].Equals("1") ? true : false); @@ -3327,6 +3377,7 @@ namespace Safedispatch_4_0 { APP_SERVER_VERSION = options[1].Replace("valid-", ""); toReturn.ip = "valid"; + int i = 2; toReturn.gps = Boolean.Parse(options[i++]); toReturn.sms = Boolean.Parse(options[i++]); @@ -3363,7 +3414,7 @@ namespace Safedispatch_4_0 case 230: volARSStat = Convert.ToBoolean(e.UserState as String); SMSDesktopAlert.FixedSize = new System.Drawing.Size(329, 120); - SMSDesktopAlert.ContentImage = global::Dispatcher.Properties.Resources.alert_gps; + SMSDesktopAlert.ContentImage = resources.alert_gps; if (volARSStat) html_status = "

" + returnLNGString("statON") + "
"; else html_status = "

" + returnLNGString("statOFF") + "
"; @@ -3434,7 +3485,7 @@ namespace Safedispatch_4_0 int result = clientStream.Read(message, 0, message.Length); SM.Debug("Received registration from server"); String decodedString = encoding.GetString(message); - String[] options = decodedString.Split(';'); + String[] options = decodedString.Split(";".ToCharArray()); if (options[0].Equals("101")) { DecisionDown = false; @@ -3481,7 +3532,7 @@ namespace Safedispatch_4_0 int result = clientStream.Read(message, 0, message.Length); SM.Debug("Received registration from server"); String decodedString = encoding.GetString(message); - String[] options = decodedString.Split(';'); + String[] options = decodedString.Split(";".ToCharArray()); if (options[0].Equals("101")) { DecisionDown = false; @@ -3596,7 +3647,7 @@ namespace Safedispatch_4_0 tabTicketing.Text = String.Format("{0} ({1})", returnLNGString("tabTicketing"), TicketingNrinTab.ToString()); - //SMSDesktopAlert.ContentImage = global::Dispatcher.Properties.Resources.ticket; + //SMSDesktopAlert.ContentImage = resources.ticket; String html_from = "" + ((MainForm2.radioType != RADIOTYPE.MOTO) ? "
" : "") + "From:
" + (e.UserState as messBody).name + "

"; html_message = "Ticket id: " + ticket_id + " Status: " + status + ""; //"" + (e.UserState as messBody).body +" "; @@ -3718,7 +3769,7 @@ namespace Safedispatch_4_0 private void DisplayDesktopAlertForAppServer(String title, String message, bool isError) { SMSDesktopAlert.FixedSize = new System.Drawing.Size(329, 120); - SMSDesktopAlert.ContentImage = isError ? global::Dispatcher.Properties.Resources.alert_error : global::Dispatcher.Properties.Resources.outboxNewGE; + SMSDesktopAlert.ContentImage = isError ? resources.alert_error : resources.outboxNewGE; html_message = "" + message + " "; SMSDesktopAlert.ContentText = "" + html_message + ""; // mesajul din interior editat cu html @@ -3777,7 +3828,7 @@ namespace Safedispatch_4_0 try { System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(); - myPlayer.Stream = Dispatcher.Properties.Resources.new_sms; + myPlayer.Stream = resources.new_sms; myPlayer.Play(); } catch (Exception ex) @@ -3796,7 +3847,7 @@ namespace Safedispatch_4_0 // SMSControl?.updateOnlytree(volsc_id, (String)VehIDHash[volsc_id]); if (!SMSuserControl.isSMSLoaded) nrOfUnreadMessages++; tabSMS.Text = String.Format("{0} ({1})", returnLNGString("tabSMS"), nrOfUnreadMessages); - SMSDesktopAlert.ContentImage = global::Dispatcher.Properties.Resources.alert_message; + SMSDesktopAlert.ContentImage = resources.alert_message; String html_from = "" + ((MainForm2.radioType != RADIOTYPE.MOTO) ? "
" : "") + "From:
" + (e.UserState as messBody).name + "

"; html_message = "Message: " + (e.UserState as messBody).body + ""; //"" + (e.UserState as messBody).body +" "; @@ -3820,6 +3871,10 @@ namespace Safedispatch_4_0 tmpCOM = (Commands)CmdList.Dequeue(); if (tmpCOM.type != 210 && tmpCOM.type != 251) nameveh = VehIMEIHash[tmpCOM.imei].ToString(); + + + Vehicle vehicle = (Vehicle)MainForm2.vehicleHT[nameveh]; + switch (tmpCOM.type) { case 231: @@ -3827,29 +3882,29 @@ namespace Safedispatch_4_0 break; case 230: - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 230, tmpCOM.ARSon.ToString()); + worker.ReportProgress(vehicle.sc_id * 1000 + 230, tmpCOM.ARSon.ToString()); break; case 130: if (tmpCOM.ARSon) ; else - ((Vehicle)vehicleHT[nameveh]).SetARSOFF(); - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 130); + vehicle.SetARSOFF(); + worker.ReportProgress(vehicle.sc_id * 1000 + 130); //else worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 230); break; case 153: - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 153, tmpCOM.di.ToString()); + worker.ReportProgress(vehicle.sc_id * 1000 + 153, tmpCOM.di.ToString()); break; case 132: messtmp = new messBody(tmpCOM.messages, nameveh); - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 132, messtmp); + worker.ReportProgress(vehicle.sc_id * 1000 + 132, messtmp); break; case 138: - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 138); + worker.ReportProgress(vehicle.sc_id * 1000 + 138); break; case 251: //in tmpCom.IMEI you have the list of id split with coma - string[] ticketExpiredList = tmpCOM.imei.Split(','); + string[] ticketExpiredList = tmpCOM.imei.Split(",".ToCharArray()); string list_of_my_tickets = ""; foreach (string ticketExpired in ticketExpiredList) { @@ -3863,32 +3918,36 @@ namespace Safedispatch_4_0 case 136: case 137: case 140: - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + tmpCOM.type, tmpCOM.zone); + worker.ReportProgress(vehicle.sc_id * 1000 + tmpCOM.type, tmpCOM.zone); break; case 210: worker.ReportProgress(Convert.ToInt32(tmpCOM.imei) * 1000 + tmpCOM.type, tmpCOM.zone); break; case 250: nameveh = VehIMEIHash[tmpCOM.imei].ToString(); - if (tmpCOM.ARSon) ((Vehicle)vehicleHT[nameveh]).RadioEnabled = true; - else ((Vehicle)vehicleHT[nameveh]).RadioEnabled = false; - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + 250); + + ((Vehicle)MainForm2.vehicleHT[nameveh]).RadioEnabled = tmpCOM.ARSon; + + worker.ReportProgress(((Vehicle)MainForm2.vehicleHT[nameveh]).sc_id * 1000 + 250); break; case 233: - if (((Vehicle)MainForm2.vehicleHT[nameveh]).telemList.Count != 0) + if (vehicle.telemList.Count != 0) { - if (((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos != null) + if (vehicle.telemPos != null) { if ((MainForm2.radioType == RADIOTYPE.MOTO) || (MainForm2.radioType == RADIOTYPE.REPEATER_TRBO)) { - if (tmpCOM.diNew) ((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos.ByteValue = tmpCOM.di; - else ((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos.ByteValue = ((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos.ByteValue | tmpCOM.di; + if (tmpCOM.diNew) + vehicle.telemPos.ByteValue = tmpCOM.di; + else + vehicle.telemPos.ByteValue |= tmpCOM.di; } else { - ((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos.ByteValue = tmpCOM.di; + vehicle.telemPos.ByteValue = tmpCOM.di; } - ((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos.TimeGMT = ((DateTime.Now.GetSecondsFromDT().ConvertLocalToGMT())); + + vehicle.telemPos.TimeGMT = ((DateTime.Now.GetSecondsFromDT().ConvertLocalToGMT())); } else { @@ -3896,7 +3955,7 @@ namespace Safedispatch_4_0 try { //Console.WriteLine("DI este" + tmpCOM.di); - ((Vehicle)MainForm2.vehicleHT[nameveh]).telemPos = new TelemetryPOS(0, ((Vehicle)MainForm2.vehicleHT[nameveh]).IMEI, ((DateTime.Now.GetSecondsFromDT().ConvertLocalToGMT())), tmpCOM.di); + vehicle.telemPos = new TelemetryPOS(0, vehicle.IMEI, ((DateTime.Now.GetSecondsFromDT().ConvertLocalToGMT())), tmpCOM.di); } catch (Exception ex) { @@ -3904,7 +3963,7 @@ namespace Safedispatch_4_0 } } } - worker.ReportProgress(((Vehicle)vehicleHT[nameveh]).sc_id * 1000 + tmpCOM.type); + worker.ReportProgress(vehicle.sc_id * 1000 + tmpCOM.type); break; } } @@ -4143,14 +4202,18 @@ namespace Safedispatch_4_0 Boolean SpecialEmerg = false; Boolean isAlarmSilence = !(DateTime.Now.CompareTo(alertSilenceEndTime) > 0); - if ((type != rep_type.IDLE) && (Name != null) && (((Vehicle)vehicleHT[Name]) != null)) + //==================================================== + Vehicle vehicle = vehicleHT[Name] as Vehicle; + //==================================================== + + if (type != rep_type.IDLE && Name != null && vehicle != null) { switch (type) { case rep_type.EMERG://emergon //Console.WriteLine("PAS2"); //AlarmName.Text = returnLNGString("emergon") + " " + Name + Detail; - if (((Vehicle)vehicleHT[Name]).AlarmSound.EMpopup) + if (vehicle.AlarmSound.EMpopup) { alarmOK = true; if (selectedTabType == track_type.LIVE) @@ -4160,40 +4223,53 @@ namespace Safedispatch_4_0 UpdateStatusLive(Name); - ((Vehicle)vehicleHT[Name]).is_emergency = true; + vehicle.is_emergency = true; //Console.WriteLine("PAS3"); AlarmCountNotAck++; if (!withoutsound) { //if the unit has sound - if (((Vehicle)vehicleHT[Name]).AlarmSound.EMsound && !isAlarmSilence) + if (vehicle.AlarmSound.EMsound && !isAlarmSilence) { - myPlayer.Stream = Dispatcher.Properties.Resources.panic; + myPlayer.Stream = resources.panic; myPlayer.Play(); } } + if (MapType == MapTYPE.ArcGis && ON) { foreach (LiveTabWind obj in LiveTabs.Values) - obj.livetabgis.onEmergencyStateChangedHandler((Vehicle)vehicleHT[Name], true); + obj.livetabgis.onEmergencyStateChangedHandler(vehicle, true); } + //put unit in center of the screen - foreach (String nameMap in ((Vehicle)vehicleHT[Name]).MapsHT.Keys) + foreach (String nameMap in vehicle.MapsHT.Keys) { + + //=============================================================================== + MapElement mapElement = ((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]); + //=============================================================================== + //need to force udpdate //Console.WriteLine("PAS4"); - if (!((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).isActive) + if (!mapElement.isActive) { //Console.WriteLine("PAS5"); - if ((Math.Round(((Vehicle)vehicleHT[Name]).LAT) != 0) && (Math.Round(((Vehicle)vehicleHT[Name]).LNG) != 0)) + if (Math.Round(vehicle.LAT) != 0 && Math.Round(vehicle.LNG) != 0) { - ((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).SetLastLocation(); - ((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).SetLastPushpin(); - ((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).ActivatePushPin(); + mapElement.SetLastLocation(); + mapElement.SetLastPushpin(); + mapElement.ActivatePushPin(); + if (MapType == MapTYPE.Google) { - try { if (SendDataToMapHASH[Name] == null) SendDataToMapHASH.Add(Name, 0); } - catch(Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } + try { + if (SendDataToMapHASH[Name] == null) + SendDataToMapHASH.Add(Name, 0); } + + catch(Exception ex) + { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } + SendDataToMapQUE.PostItem(Name); } } @@ -4216,32 +4292,30 @@ namespace Safedispatch_4_0 } } } + if (MapType == MapTYPE.ArcGis) - ((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).AxMapGIS.Extent - = MainForm2.ZoomTo(((Vehicle)MainForm2.vehicleHT[Name]).LNG, ((Vehicle)MainForm2.vehicleHT[Name]).LAT, - ((Vehicle)MainForm2.vehicleHT[Name]).LNG, ((Vehicle)MainForm2.vehicleHT[Name]).LAT); + mapElement.AxMapGIS.Extent = MainForm2.ZoomTo(vehicle.LNG, vehicle.LAT,vehicle.LNG, vehicle.LAT); else { foreach (LiveTabWind obj in LiveTabs.Values) { - if ((Math.Round(((Vehicle)MainForm2.vehicleHT[Name]).LNG) != 0) && (Math.Round(((Vehicle)MainForm2.vehicleHT[Name]).LAT) != 0)) + if ((Math.Round(vehicle.LNG) != 0 && Math.Round(vehicle.LAT) != 0)) { //((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).UpdateSymbol(); RemoveIconsFromMap(); obj.livetab.mapControl.mapGoogles.ExecuteScript("window.GWTcallback('centerzoom," - + MainForm2.FixDoubleLAT(((Vehicle)MainForm2.vehicleHT[Name]).LAT.ToString()) + "," - + MainForm2.FixDoubleLNG(((Vehicle)MainForm2.vehicleHT[Name]).LNG.ToString()) + ",15');"); + + MainForm2.FixDoubleLAT(vehicle.LAT.ToString()) + "," + + MainForm2.FixDoubleLNG(vehicle.LNG.ToString()) + ",15');"); } - else if ((Math.Round(((Vehicle)MainForm2.vehicleHT[Name]).lastLocLNG) != 0) - && (Math.Round(((Vehicle)MainForm2.vehicleHT[Name]).lastLocLAT) != 0)) + else if (Math.Round(vehicle.lastLocLNG) != 0 && Math.Round(vehicle.lastLocLAT) != 0) { //((MapElement)((Vehicle)vehicleHT[Name]).MapsHT[nameMap]).UpdateSymbol(); RemoveIconsFromMap(); obj.livetab.mapControl.mapGoogles.ExecuteScript("window.GWTcallback('centerzoom," - + MainForm2.FixDoubleLAT(((Vehicle)MainForm2.vehicleHT[Name]).lastLocLAT.ToString()) - + "," + MainForm2.FixDoubleLNG(((Vehicle)MainForm2.vehicleHT[Name]).lastLocLNG.ToString()) + ",15');"); + + MainForm2.FixDoubleLAT(vehicle.lastLocLAT.ToString()) + + "," + MainForm2.FixDoubleLNG(vehicle.lastLocLNG.ToString()) + ",15');"); } @@ -4258,6 +4332,7 @@ namespace Safedispatch_4_0 { obj.livetab.onEmergencyStateChangedHandler(veh, true); } + //if(MapType == MapTYPE.ArcGis) // obj.livetabgis.onEmergencyStateChangedHandler(veh, true); } @@ -4276,49 +4351,52 @@ namespace Safedispatch_4_0 //if the unit has sound if (((Vehicle)vehicleHT[Name]).AlarmSound.SPEEDsound && !isAlarmSilence) { - myPlayer.Stream = Dispatcher.Properties.Resources.speeding; + myPlayer.Stream = resources.speeding; myPlayer.Play(); } } break; + case rep_type.GEOFENC: //AlarmName.Text = Name + " " + Detail; - if (((Vehicle)vehicleHT[Name]).AlarmSound.GEOpopup) alarmOK = true; + if (vehicle.AlarmSound.GEOpopup) alarmOK = true; AlarmCountNotAck++; if (!withoutsound) { - if (((Vehicle)vehicleHT[Name]).AlarmSound.GEOsound && !isAlarmSilence) + if (vehicle.AlarmSound.GEOsound && !isAlarmSilence) { - myPlayer.Stream = Dispatcher.Properties.Resources.zone; + myPlayer.Stream = resources.zone; myPlayer.Play(); } } break; + case rep_type.LAND: //AlarmName.Text = Name + " " + Detail; - if (((Vehicle)vehicleHT[Name]).AlarmSound.GEOpopup) alarmOK = true; + if (vehicle.AlarmSound.GEOpopup) alarmOK = true; AlarmCountNotAck++; if (!withoutsound) { - if (((Vehicle)vehicleHT[Name]).AlarmSound.GEOsound && !isAlarmSilence) + if (vehicle.AlarmSound.GEOsound && !isAlarmSilence) { - myPlayer.Stream = Dispatcher.Properties.Resources.zone; + myPlayer.Stream = resources.zone; myPlayer.Play(); } } break; + case rep_type.TELEMETRY_ALARM: //AlarmName.Text = Name + " " + Detail; - if (((Vehicle)vehicleHT[Name]).AlarmSound.TELEMpopup) alarmOK = true; + if (vehicle.AlarmSound.TELEMpopup) alarmOK = true; AlarmCountNotAck++; if (!withoutsound) { - if (((Vehicle)vehicleHT[Name]).AlarmSound.TELEMsound && !isAlarmSilence) + if (vehicle.AlarmSound.TELEMsound && !isAlarmSilence) { - myPlayer.Stream = Dispatcher.Properties.Resources.telem; + myPlayer.Stream = resources.telem; myPlayer.Play(); } } @@ -4326,8 +4404,8 @@ namespace Safedispatch_4_0 } try { - if (MainForm2.PopupOpen[((Vehicle)vehicleHT[Name]).IMEI] != null) - ((FastCommandWindow)MainForm2.PopupOpen[((Vehicle)vehicleHT[Name]).IMEI]).populate(); + if (MainForm2.PopupOpen[vehicle.IMEI] != null) + ((FastCommandWindow)MainForm2.PopupOpen[vehicle.IMEI]).populate(); } catch (Exception ex) { @@ -4348,7 +4426,7 @@ namespace Safedispatch_4_0 /* else { - AlarmIcon.Image = global::Dispatcher.Properties.Resources.emergencyoff16x; + AlarmIcon.Image = resources.emergencyoff16x; AlarmName.Text = returnLNGString("noalarm"); } if (AlarmCountNotAck > 0) @@ -4358,7 +4436,7 @@ namespace Safedispatch_4_0 } else { - AlarmIcon.Image = global::Dispatcher.Properties.Resources.emergencyoff16x; + AlarmIcon.Image = resources.emergencyoff16x; AlarmName.Text = returnLNGString("noalarm"); } * */ @@ -5116,9 +5194,9 @@ namespace Safedispatch_4_0 // do not show text cellElement.DrawText = false; if (cellElement != null && cellElement.Value != null && (int)cellElement.Value == 0) - cellElement.BackgroundImage = Dispatcher.Properties.Resources.call_made_24x20; + cellElement.BackgroundImage = resources.call_made_24x20; else - cellElement.BackgroundImage = Dispatcher.Properties.Resources.call_received_24X20; + cellElement.BackgroundImage = resources.call_received_24X20; } } @@ -5126,7 +5204,7 @@ namespace Safedispatch_4_0 { // style only desired tabs - if (args.Window == tabLive || args.Window == tabHistory + if (args.Window == tabLive || args.Window == tabHistory || args.Window == tabGeo || args.Window == tabSMS || args.Window == tabTicketing || args.Window == tabVoice @@ -5175,10 +5253,7 @@ namespace Safedispatch_4_0 args.TabItem.MouseLeave += delegate (object sender2, EventArgs e2) { // decide if tab is active or not - if (radDock1 != null && radDock1.ActiveWindow == args.Window) - args.TabItem.BackColor = TabSelectedColor; - else - args.TabItem.BackColor = TabNormalColor; + args.TabItem.BackColor = (radDock1 != null && radDock1.ActiveWindow == args.Window) ? TabSelectedColor : TabNormalColor; }; } @@ -5198,6 +5273,178 @@ namespace Safedispatch_4_0 } + private CultureInfo getCultureInfo(int idx) + { + Dictionary culture_dictionary = new Dictionary < int, string> { { 0, "en" }, { 1, "zh-CN" }, { 2, "cs" }, {3, "fr" }, { 4, "de" }, + { 5, "it"}, { 6, "ja"},{ 7, "pl"},{ 8, "pt"},{ 9, "ro"},{ 10, "ru"},{ 11, "sr"},{12, "es"},{ 13, "sv"},{ 14, "tr"},{ 15, "ar"}}; + + + if (culture_dictionary.ContainsKey(idx)) + return CultureInfo.CreateSpecificCulture(culture_dictionary[idx]); + + + return culture = CultureInfo.CreateSpecificCulture("en"); + } + + private void PopulateImageDictionary() + { + + imagesDictionary.Add("fc_sms", Utils.ScaleImage(resources.fc_sms, 24, 24)); + imagesDictionary.Add("fc_remote", Utils.ScaleImage(resources.fc_remote, 24, 24)); + imagesDictionary.Add("fc_favorite_yellow", Utils.ScaleImage(resources.fc_favorite_yellow, 24, 24)); + imagesDictionary.Add("fc_favorite", Utils.ScaleImage(resources.fc_favorite, 24, 24)); + imagesDictionary.Add("fc_live", Utils.ScaleImage(resources.fc_live, 24, 24)); + + imagesDictionary.Add("i_classic_bus_02", Utils.ScaleImage(resources.i_classic_bus_02, 64, 64)); + imagesDictionary.Add("i_classic_moto_05", Utils.ScaleImage(resources.i_classic_moto_05, 64, 64)); + imagesDictionary.Add("i_dispatch", Utils.ScaleImage(resources.i_dispatch, 64, 64)); + imagesDictionary.Add("i_group", Utils.ScaleImage(resources.i_group, 64, 64)); + imagesDictionary.Add("i_all_call", Utils.ScaleImage(resources.i_all_call, 64, 64)); + imagesDictionary.Add("i_manual_dial", Utils.ScaleImage(resources.i_manual_dial, 64, 64)); + + imagesDictionary.Add("l_alert", resources.l_alert); + imagesDictionary.Add("l_text", resources.l_text); + imagesDictionary.Add("l_center", resources.l_center); + } + + + private void SetTabsForEachWindow() + { + tabAlerts.Tag = Tabs.ALERTS; + tabLive.Tag = Tabs.LIVE; + tabGeo.Tag = Tabs.GEOFENCE; + tabHistory.Tag = Tabs.HISTORY; + tabSMS.Tag = Tabs.TEXT; + tabTicketing.Tag = Tabs.TICKETING; + tabVoice.Tag = Tabs.VOICE; + tabNewRadio.Tag = Tabs.RADIO; + tabTelem.Tag = Tabs.TELEMETRY; + tabReport.Tag = Tabs.REPORTS; + tabSystem.Tag = Tabs.SYSTEM; + } + + private void DestroyMapPoint() + { + Process[] processes = Process.GetProcessesByName("MapPoint"); + foreach (Process proc in processes) + { + proc.CloseMainWindow(); + proc.Kill(); + proc.WaitForExit(); + } + } + + + private void ChangeIconAndText(Login parent) + { + try + { + switch (MainForm2.radioType) + { + case RADIOTYPE.UNKNOWN: + this.Text = parent.Text; + break; + case RADIOTYPE.HYT: + this.Icon = resources.HytSmall24; + this.Text = parent.Text; + break; + case RADIOTYPE.HARRIS: + this.Icon = resources.HarrisSmall; + this.Text = parent.Text; + break; + case RADIOTYPE.ATLAS: + this.Icon = resources.ATLICO32; + this.Text = parent.Text; + break; + case RADIOTYPE.SIMOCO: + this.Icon = resources.simoco_dispatch_24; + this.Text = parent.Text; + break; + case RADIOTYPE.EXCERA: + this.Icon = resources.AXYS_ICON; + this.Text = parent.Text; + break; + default: + break; + } + } + catch (Exception ex) + { + SM.Debug("Error on change icon and text on MainForm:\n" + ex.ToString()); + + } + } + + private void InitializeSystemGridView() + { + string dateTimeFormat = ""; + try + { + SystemGridView.DataSource = null; + SystemGridView.DataSource = startList; + SystemGridView.Columns["timecmd"].IsVisible = true; + SystemGridView.Columns["timeAgo"].IsVisible = false; + + + if (MainForm2.is24hours) + dateTimeFormat = MainForm2.DayFirst ? "{0:dd/MM/yyyy HH:mm:ss}" : "{0:MM/dd/yyyy HH:mm:ss}"; + else + dateTimeFormat = MainForm2.DayFirst ? "{0:dd/MM/yyyy HH:mm:ss tt}" : "{0:MM/dd/yyyy HH:mm:ss tt}"; + + + + ((GridViewDateTimeColumn)SystemGridView.Columns["timecmd"]).FormatString = dateTimeFormat; + } + catch (Exception ex) + { + SM.Debug("Error on populate grid" + ex.ToString()); + } + } + + private void LoadTabList() + { + tabsHash.Clear(); + tabsHash.Add(tabAlerts.Name, false); + tabsHash.Add(tabLive.Name, false); + tabsHash.Add(tabHistory.Name, false); + tabsHash.Add(tabSMS.Name, false); + tabsHash.Add(tabTicketing.Name, false); + tabsHash.Add(tabVoice.Name, false); + tabsHash.Add(tabNewRadio.Name, false); + tabsHash.Add(tabTelem.Name, false); + tabsHash.Add(tabReport.Name, false); + tabsHash.Add(tabGeo.Name, false); + tabsHash.Add(tabSystem.Name, false); + } + + private void SetDefaultFloatingSizeForTabs(int width, int height) + { + tabLive.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabHistory.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabSMS.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabTicketing.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabVoice.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabNewRadio.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabTelem.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabReport.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabGeo.DefaultFloatingSize = new System.Drawing.Size(width, height); + tabSystem.DefaultFloatingSize = new System.Drawing.Size(width, height); + + } + + private void RemoveCloseButtonFromTabs() + { + tabSMS.DocumentButtons &= ~DocumentStripButtons.Close; + tabTicketing.DocumentButtons &= ~DocumentStripButtons.Close; + tabVoice.DocumentButtons &= ~DocumentStripButtons.Close; + tabNewRadio.DocumentButtons &= ~DocumentStripButtons.Close; + tabTelem.DocumentButtons &= ~DocumentStripButtons.Close; + tabReport.DocumentButtons &= ~DocumentStripButtons.Close; + tabGeo.DocumentButtons &= ~DocumentStripButtons.Close; + tabSystem.DocumentButtons &= ~DocumentStripButtons.Close; + } + + public MainForm2(Login parent) { RadDockEvents.TabStripItemCreating += RadDockEvents_TabStripItemCreating; @@ -5211,6 +5458,7 @@ namespace Safedispatch_4_0 } else FailoverStatus(ToggleState.Indeterminate); + notifyStatic = notifyIcon1; @@ -5234,21 +5482,13 @@ namespace Safedispatch_4_0 UpdateForm uf = new UpdateForm(appType, true) { IsDevelop = cfg.isDevelope }; uf.Show(); }); + contextMenu.MenuItems.Add("Exit", (s, e) => CloseApp()); notifyIcon1.ContextMenu = contextMenu; - imagesDictionary.Add("fc_sms", Utils.ScaleImage(Dispatcher.Properties.Resources.fc_sms, 24, 24)); - imagesDictionary.Add("fc_remote", Utils.ScaleImage(Dispatcher.Properties.Resources.fc_remote, 24, 24)); - imagesDictionary.Add("fc_favorite_yellow", Utils.ScaleImage(Dispatcher.Properties.Resources.fc_favorite_yellow, 24, 24)); - imagesDictionary.Add("fc_favorite", Utils.ScaleImage(Dispatcher.Properties.Resources.fc_favorite, 24, 24)); - imagesDictionary.Add("fc_live", Utils.ScaleImage(Dispatcher.Properties.Resources.fc_live, 24, 24)); - imagesDictionary.Add("i_classic_bus_02", Utils.ScaleImage(Dispatcher.Properties.Resources.i_classic_bus_02, 64, 64)); - imagesDictionary.Add("i_classic_moto_05", Utils.ScaleImage(Dispatcher.Properties.Resources.i_classic_moto_05, 64, 64)); - imagesDictionary.Add("i_dispatch", Utils.ScaleImage(Dispatcher.Properties.Resources.i_dispatch, 64, 64)); - imagesDictionary.Add("i_group", Utils.ScaleImage(Dispatcher.Properties.Resources.i_group, 64, 64)); - imagesDictionary.Add("i_all_call", Utils.ScaleImage(Dispatcher.Properties.Resources.i_all_call, 64, 64)); - imagesDictionary.Add("i_manual_dial", Utils.ScaleImage(Dispatcher.Properties.Resources.i_manual_dial, 64, 64)); + + PopulateImageDictionary(); // set theme according to the radio type //setThemingColors(radioType); @@ -5336,77 +5576,22 @@ namespace Safedispatch_4_0 RManager = new ResourceManager("Dispatcher.Language.myRes", typeof(MainForm2).Assembly); + + culture = getCultureInfo(Langidx); //set language - switch (Langidx) - { - case 0: - culture = CultureInfo.CreateSpecificCulture("en"); - break; - case 1: - culture = CultureInfo.CreateSpecificCulture("zh-CN"); - break; - case 2: - culture = CultureInfo.CreateSpecificCulture("cs"); - break; - case 3: - culture = CultureInfo.CreateSpecificCulture("fr"); - break; - case 4: - culture = CultureInfo.CreateSpecificCulture("de"); - break; - case 5: - culture = CultureInfo.CreateSpecificCulture("it"); - break; - case 6: - culture = CultureInfo.CreateSpecificCulture("ja"); - break; - case 7: - culture = CultureInfo.CreateSpecificCulture("pl"); - break; - case 8: - culture = CultureInfo.CreateSpecificCulture("pt"); - break; - case 9: - culture = CultureInfo.CreateSpecificCulture("ro"); - break; - case 10: - culture = CultureInfo.CreateSpecificCulture("ru"); - break; - case 11: - culture = CultureInfo.CreateSpecificCulture("sr"); - break; - case 12: - culture = CultureInfo.CreateSpecificCulture("es"); - break; - case 13: - culture = CultureInfo.CreateSpecificCulture("sv"); - break; - case 14: - culture = CultureInfo.CreateSpecificCulture("tr"); - break; - case 15: - culture = CultureInfo.CreateSpecificCulture("ar"); - break; - } setLanguage(); - // populate images hashtable - imagesDictionary.Add("l_alert", global::Dispatcher.Properties.Resources.l_alert); - imagesDictionary.Add("l_text", global::Dispatcher.Properties.Resources.l_text); - imagesDictionary.Add("l_center", global::Dispatcher.Properties.Resources.l_center); - - // set theme for the Message Box RadMessageBox.SetThemeName("TelerikMetroBlue"); RadMessageBox.ShowInTaskbar = true; #region THEMING - pbReportType.Image = Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_system, ButtonColor); + pbReportType.Image = Utils.ChangeColor(resources.r_system, ButtonColor); labelReportName.ForeColor = LabelColor; pbClearStartTime.Image = pbClearEndTime.Image - = Utils.ChangeColor(global::Dispatcher.Properties.Resources.b_clear, ButtonColor); + = Utils.ChangeColor(resources.b_clear, ButtonColor); btExportReport.ButtonElement.ButtonFillElement.BackColor = Color.White; btExportReport.ButtonElement.TextElement.ForeColor = ButtonColor; #endregion @@ -5415,8 +5600,8 @@ namespace Safedispatch_4_0 RegisterCustomCommand(); radDock1.RootElement.Margin = new Padding(-2); - radDock1.RootElement.Padding = new Padding(-2); + documentContainer1.RootElement.Padding = new Padding(-2); documentContainer1.RootElement.Margin = new Padding(-2); //radScrollablePanel1.RootElement.Padding = new Padding(0); @@ -5429,18 +5614,7 @@ namespace Safedispatch_4_0 radDock1.ActivateWindow(tabLive); // set Tabs for each toolWindow - tabAlerts.Tag = Tabs.ALERTS; - tabLive.Tag = Tabs.LIVE; - tabGeo.Tag = Tabs.GEOFENCE; - tabHistory.Tag = Tabs.HISTORY; - tabSMS.Tag = Tabs.TEXT; - tabTicketing.Tag = Tabs.TICKETING; - tabVoice.Tag = Tabs.VOICE; - tabNewRadio.Tag = Tabs.RADIO; - tabTelem.Tag = Tabs.TELEMETRY; - tabReport.Tag = Tabs.REPORTS; - tabSystem.Tag = Tabs.SYSTEM; - + SetTabsForEachWindow(); // set time for system grid filtering rdpStartTime.Value = DateTime.Now; @@ -5448,17 +5622,14 @@ namespace Safedispatch_4_0 // set the allowed dock state for each tool windows // in order to prevent them from being closed or hide - foreach (Control ctr in documentTabStrip1.Controls) + foreach (ToolWindow tool in documentTabStrip1.Controls.OfType().ToList()) { - if (ctr is ToolWindow) - { - ToolWindow tool = ctr as ToolWindow; + tool.AllowedDockState = AllowedDockState.Docked | AllowedDockState.Floating | AllowedDockState.TabbedDocument; // ADD close option if Live or History tab if (((Tabs)tool.Tag) == Tabs.LIVE || ((Tabs)tool.Tag) == Tabs.HISTORY) - tool.AllowedDockState = AllowedDockState.Docked | AllowedDockState.Floating | AllowedDockState.TabbedDocument | AllowedDockState.Hidden; - } + tool.AllowedDockState |= AllowedDockState.Hidden; } @@ -5494,8 +5665,11 @@ namespace Safedispatch_4_0 e.DockWindow.DockTabStrip is DocumentTabStrip) { //remove the "Close" menu items - for (int i = 0; i < e.MenuItems.Count; i++) - e.MenuItems[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; + //for (int i = 0; i < e.MenuItems.Count; i++) + // e.MenuItems[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; + + e.MenuItems.ForEach(x => x.Visibility = ElementVisibility.Collapsed); + } }; //this disables the context menu @@ -5504,6 +5678,7 @@ namespace Safedispatch_4_0 menuService2.AllowToolContextMenu = false; ChangeFont(); + //old main parent.Visible = false; //LoginControl = parent; @@ -5545,6 +5720,7 @@ namespace Safedispatch_4_0 if (TelemDecide) documentTabStrip1.Controls.Remove(tabTelem); // if (VoiceDecide) documentTabStrip1.Controls.Remove(tabVoice); } + try { if ((radioType == RADIOTYPE.ATLAS) || (radioType == RADIOTYPE.CONECTPLUS) || (radioType == RADIOTYPE.LISF)) @@ -5566,6 +5742,7 @@ namespace Safedispatch_4_0 documentTabStrip1.Controls.Remove(tabTelem); documentTabStrip1.Controls.Remove(tabTicketing); } + if ((radioType == RADIOTYPE.LINXB)) { notifyIcon1.BalloonTipText = notifyIcon1.BalloonTipTitle = notifyIcon1.Text = this.Text = " LINX Dispatch"; @@ -5585,6 +5762,7 @@ namespace Safedispatch_4_0 m_AOLicenseInitializer.ShutdownApplication(); initTextSize(); } + SM.Debug("Before load hashtable"); LoadValue(); LoadHashTable(); @@ -5615,8 +5793,8 @@ namespace Safedispatch_4_0 if (SMSDecide) documentTabStrip1.Controls.Remove(tabSMS); if (TicketingDecide) documentTabStrip1.Controls.Remove(tabTicketing); if (GPSDecide) documentTabStrip1.Controls.Remove(tabHistory); - documentTabStrip1.Controls.Remove(tabSystem); } + if (MainForm2.userType == USERTYPE.TicketingAdmin) { documentTabStrip1.Controls.Remove(tabGeo); @@ -5626,8 +5804,6 @@ namespace Safedispatch_4_0 documentTabStrip1.Controls.Add(tabTicketing); } - - // disable close and HIDE //ContextMenuService menuService = this.radDock1.GetService(); //menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying1; @@ -5637,88 +5813,20 @@ namespace Safedispatch_4_0 this.KeyPreview = true; ///init SystemGridView - try - { - SystemGridView.DataSource = null; - SystemGridView.DataSource = startList; - SystemGridView.Columns["timecmd"].IsVisible = true; - SystemGridView.Columns["timeAgo"].IsVisible = false; - /*if (is24hours) ((GridViewDateTimeColumn)SystemGridView.Columns[4]).FormatString = "{0:MM/dd/yyyy HH:mm:ss}"; - else ((GridViewDateTimeColumn)SystemGridView.Columns[4]).FormatString = "{0:MM/dd/yyyy hh:mm:ss tt}"; */ - if (MainForm2.is24hours) - { - if (MainForm2.DayFirst) - ((GridViewDateTimeColumn)SystemGridView.Columns["timecmd"]).FormatString = "{0:dd/MM/yyyy HH:mm:ss}"; - else - ((GridViewDateTimeColumn)SystemGridView.Columns["timecmd"]).FormatString = "{0:MM/dd/yyyy HH:mm:ss}"; - } - else - { - if (MainForm2.DayFirst) - ((GridViewDateTimeColumn)SystemGridView.Columns["timecmd"]).FormatString = "{0:dd/MM/yyyy hh:mm:ss tt}"; - else - ((GridViewDateTimeColumn)SystemGridView.Columns["timecmd"]).FormatString = "{0:MM/dd/yyyy hh:mm:ss tt}"; - } - } - catch (Exception ex) - { - SM.Debug("Error on populate grid" + ex.ToString()); - } + InitializeSystemGridView(); initComunicaton(); setLanguage(); checkMessage.RunWorkerAsync(); - //distroy mappoint - Process[] processes; - - processes = Process.GetProcessesByName("MapPoint"); - foreach (Process proc in processes) - { - proc.CloseMainWindow(); - proc.Kill(); - proc.WaitForExit(); - } + //destroy mappoint + DestroyMapPoint(); // Chamge icon and form text - try - { - switch (MainForm2.radioType) - { - case RADIOTYPE.UNKNOWN: - this.Text = parent.Text; - break; - case RADIOTYPE.HYT: - this.Icon = global::Dispatcher.Properties.Resources.HytSmall24; - this.Text = parent.Text; - break; - case RADIOTYPE.HARRIS: - this.Icon = global::Dispatcher.Properties.Resources.HarrisSmall; - this.Text = parent.Text; - break; - case RADIOTYPE.ATLAS: - this.Icon = global::Dispatcher.Properties.Resources.ATLICO32; - this.Text = parent.Text; - break; - case RADIOTYPE.SIMOCO: - this.Icon = global::Dispatcher.Properties.Resources.simoco_dispatch_24; - this.Text = parent.Text; - break; - case RADIOTYPE.EXCERA: - this.Icon = global::Dispatcher.Properties.Resources.AXYS_ICON; - this.Text = parent.Text; - break; - default: - break; - } - } - catch (Exception ex) - { - SM.Debug("Error on change icon and text on MainForm:\n" + ex.ToString()); - - } - + ChangeIconAndText(parent); + + // Display caption and the version try { Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; @@ -5730,54 +5838,16 @@ namespace Safedispatch_4_0 } //load list tabs - tabsHash.Clear(); - tabsHash.Add(tabAlerts.Name, false); - tabsHash.Add(tabLive.Name, false); - tabsHash.Add(tabHistory.Name, false); - tabsHash.Add(tabSMS.Name, false); - tabsHash.Add(tabTicketing.Name, false); - tabsHash.Add(tabVoice.Name, false); - tabsHash.Add(tabNewRadio.Name, false); - tabsHash.Add(tabTelem.Name, false); - tabsHash.Add(tabReport.Name, false); - tabsHash.Add(tabGeo.Name, false); - tabsHash.Add(tabSystem.Name, false); - - /*tabLive.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabHistory.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabSMS.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabVoice.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabTelem.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabReport.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabGeo.DefaultFloatingSize = new System.Drawing.Size(800, 600); - tabHelp.DefaultFloatingSize = new System.Drawing.Size(800, 600);*/ - - tabLive.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabHistory.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabSMS.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabTicketing.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabVoice.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabNewRadio.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabTelem.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabReport.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabGeo.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - tabSystem.DefaultFloatingSize = new System.Drawing.Size(1024, 768); - - tabSMS.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabTicketing.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabVoice.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabNewRadio.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabTelem.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabReport.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabGeo.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - tabSystem.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + LoadTabList(); + SetDefaultFloatingSizeForTabs(1024, 768); + RemoveCloseButtonFromTabs(); + this.Visible = true; documentTabStrip1.SelectedIndex = 0; - DBsettingsManager dbSettingsManager = new DBsettingsManager( - ServerDBip, Schema, UserDB, PassDB, PortDB); + DBsettingsManager dbSettingsManager = new DBsettingsManager(ServerDBip, Schema, UserDB, PassDB, PortDB); #region read voice parameters @@ -5788,24 +5858,26 @@ namespace Safedispatch_4_0 RadioTab.voicemanager_bitDepth = Convert.ToInt32(dbSettingsManager.getSettingValue(0, "bitDepth")); } catch(Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } + #endregion OnEnterValid = true; //on ENter don' work here - if (documentTabStrip1.SelectedTab == tabLive) CheckTabs(track_type.LIVE, tabLive); - else if (documentTabStrip1.SelectedTab == tabGeo) CheckTabs(track_type.LANDZONE, tabGeo); - else if (documentTabStrip1.SelectedTab == tabHistory) CheckTabs(track_type.HIST, tabHistory); - else if (documentTabStrip1.SelectedTab == tabReport) CheckTabs(track_type.REPORTS, tabReport); - else if (documentTabStrip1.SelectedTab == tabSMS) CheckTabs(track_type.SMS, tabSMS); + if (documentTabStrip1.SelectedTab == tabLive) CheckTabs(track_type.LIVE, tabLive); + else if (documentTabStrip1.SelectedTab == tabGeo) CheckTabs(track_type.LANDZONE, tabGeo); + else if (documentTabStrip1.SelectedTab == tabHistory) CheckTabs(track_type.HIST, tabHistory); + else if (documentTabStrip1.SelectedTab == tabReport) CheckTabs(track_type.REPORTS, tabReport); + else if (documentTabStrip1.SelectedTab == tabSMS) CheckTabs(track_type.SMS, tabSMS); else if (documentTabStrip1.SelectedTab == tabTicketing) CheckTabs(track_type.TICKETING, tabTicketing); - else if (documentTabStrip1.SelectedTab == tabNewRadio) - CheckTabs(track_type.RADIO, tabNewRadio); - else if (documentTabStrip1.SelectedTab == tabTelem) CheckTabs(track_type.TELEM, tabTelem); - else if (documentTabStrip1.SelectedTab == tabSystem) CheckTabs(track_type.SYSTEM, tabSystem); + else if (documentTabStrip1.SelectedTab == tabNewRadio) CheckTabs(track_type.RADIO, tabNewRadio); + else if (documentTabStrip1.SelectedTab == tabTelem) CheckTabs(track_type.TELEM, tabTelem); + else if (documentTabStrip1.SelectedTab == tabSystem) CheckTabs(track_type.SYSTEM, tabSystem); + GisAddress.RunWorkerAsync(); SendDataToMap.RunWorkerAsync(); SystemlogWorker.RunWorkerAsync(); + if (MapType == MapTYPE.Google) RestartSoftware.RunWorkerAsync(); // get all dispatchers @@ -5882,7 +5954,7 @@ namespace Safedispatch_4_0 #endregion -#region init voice for Linx + #region init voice for Linx if((radioType == RADIOTYPE.LINX || radioType == RADIOTYPE.LINXB || radioType == RADIOTYPE.EXCERA) && HasVoice) CheckTabs(track_type.RADIO, GetTabNewRadio); #endregion @@ -5910,7 +5982,8 @@ namespace Safedispatch_4_0 obj.livetab.onUnitPositionOrStateChanged(vehName); //obj.livetab.UpdateVehList(name, true); //else if (MapType == MapTYPE.ArcGis) obj.livetabgis.UpdateVehList(name, true); - else if (MapType == MapTYPE.ArcGis) obj.livetabgis.onUnitPositionOrStateChanged(vehName); + else if (MapType == MapTYPE.ArcGis) + obj.livetabgis.onUnitPositionOrStateChanged(vehName); //ONLY FOR TEST obj.livetab.onGPSPositionReceivedHandler(vehName, false); @@ -5918,8 +5991,6 @@ namespace Safedispatch_4_0 } } - - void _userStatusTimer_Elapsed(object obj) { string test1 = "#600#" + userIDX + "#ON#"; @@ -5944,6 +6015,7 @@ namespace Safedispatch_4_0 { obj.livetab.populateTableVehiclesList2(false, null); } + if (MapType == MapTYPE.ArcGis) obj.livetabgis.populateTableVehiclesList2(false, null); } @@ -6037,11 +6109,11 @@ namespace Safedispatch_4_0 RadMenuItemBase menuItem = e.MenuItems[i]; if (menuItem.AccessibleName.StartsWith("Close All") || menuItem.AccessibleName.StartsWith("Close All") || - menuItem.AccessibleName == "Auto-Hide" || - menuItem.AccessibleName == "Rename" || + menuItem.AccessibleName.Equals("Auto-Hide") || + menuItem.AccessibleName.Equals("Rename") || menuItem.AccessibleName.StartsWith("New Horizontal") || menuItem.AccessibleName.StartsWith("New Vertical") || - menuItem.AccessibleName == "Hide" || + menuItem.AccessibleName.Equals("Hide") || menuItem is RadMenuSeparatorItem) { menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; @@ -6070,6 +6142,7 @@ namespace Safedispatch_4_0 menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } } + RadMenuSeparatorItem sp = new RadMenuSeparatorItem(); e.MenuItems.Add(sp); RadMenuItemBase menuItem1; @@ -6092,6 +6165,7 @@ namespace Safedispatch_4_0 } } } + if (e.DockWindow.FloatingParent != null) { e.MenuItems[0].Visibility = ElementVisibility.Collapsed; @@ -6130,10 +6204,11 @@ namespace Safedispatch_4_0 ToolWindow tmpWind = new ToolWindow(); tmpWind.Text = title; tmpWind.Tag = Tabs.LIVE; - tmpWind.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live_b, 25, 25); + tmpWind.Image = Utils.ScaleImage(resources.t_live_b, 25, 25); tmpWind.DefaultFloatingSize = new System.Drawing.Size(800, 600); tmpWind.Enter += new EventHandler(tabLive_Enter); tmpWind.Leave += new EventHandler(tabLive_Leave); + documentTabStrip1.Controls.Add(tmpWind); } @@ -6185,10 +6260,11 @@ namespace Safedispatch_4_0 ToolWindow tmpWind = new ToolWindow(); tmpWind.Text = frmName.Name; tmpWind.Tag = Tabs.HISTORY; - tmpWind.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history_b, 25, 25); + tmpWind.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history_b, 25, 25); tmpWind.DefaultFloatingSize = new System.Drawing.Size(800, 600); tmpWind.Enter += new EventHandler(tabHistory_Enter); tmpWind.Leave += new EventHandler(tabHistory_Leave); + documentTabStrip1.Controls.Add(tmpWind); } } @@ -6201,6 +6277,7 @@ namespace Safedispatch_4_0 tmpWind.Text = frmName.Name; tmpWind.DefaultFloatingSize = new System.Drawing.Size(800, 600); tmpWind.Enter += new EventHandler(tabGeo_Enter); + documentTabStrip1.Controls.Add(tmpWind); } @@ -6365,6 +6442,7 @@ namespace Safedispatch_4_0 if (OnEnterValid) { if (tabsHash[tool.Name] != null) + { if (((Boolean)tabsHash[tool.Name]) == false) { tabsHash[tool.Name] = true; @@ -6378,10 +6456,14 @@ namespace Safedispatch_4_0 { GoogleMapCheck = false; } - if ((type == track_type.TELEM) && (TelemGOControl.docLoad)) + + if (type == track_type.TELEM) { - GoogleMapCheck = false; + if (TelemGOControl.docLoad) + GoogleMapCheck = false; } + + if (type == track_type.LIVE) { foreach (LiveTabWind obj in LiveTabs.Values) @@ -6396,8 +6478,10 @@ namespace Safedispatch_4_0 } } } + if (type == track_type.HIST) { + foreach (HistTabWind obj in HistTabs) { if (obj.toolwind == tool) @@ -6410,8 +6494,10 @@ namespace Safedispatch_4_0 } } } + } } + } else { tabsHash.Add(tool.Name, true); @@ -6472,6 +6558,7 @@ namespace Safedispatch_4_0 TelemGOControl.toolWindow3.AutoHide(); TelemGOControl.toolWindow3.DockState = DockState.Docked; } + if (TelemGOControl.toolWindow2.DockState == DockState.TabbedDocument) { TelemGOControl.toolWindow2.AutoHide(); @@ -6519,60 +6606,90 @@ namespace Safedispatch_4_0 } + private Icon getClasicIcon(ToolWindow dockWindow) + { + Icon icon; + + + if (dockWindow == tabLive) + icon = Icon.FromHandle(resources.t_live.GetHicon()); //Icon.FromHandle(resources.Live_mini_ico_norm.GetHicon()); + else if (dockWindow == tabGeo) + icon = Icon.FromHandle(resources.Geo_mini_ico_norm.GetHicon()); + else if (dockWindow == tabHistory) + icon = Icon.FromHandle(resources.Hist_mini_ico_norm.GetHicon()); + else if (dockWindow == tabReport) + icon = Icon.FromHandle(resources.Report_mini_ico_norm.GetHicon()); + else if (dockWindow == tabSMS) + icon = Icon.FromHandle(resources.SMS_mini_ico_norm.GetHicon()); + else if (dockWindow == tabVoice) + icon = Icon.FromHandle(resources.Voice_mini_ico_norm.GetHicon()); + else if (dockWindow == tabNewRadio) + icon = Icon.FromHandle(resources.Voice_mini_ico_norm.GetHicon()); + else if (dockWindow == tabTelem) + icon = Icon.FromHandle(resources.Telem_mini_ico_norm.GetHicon()); + else + icon = Icon.FromHandle(resources.Sys_mini_ico_norm.GetHicon()); + + return icon; + } + + private Icon getPinIcon(ToolWindow dockWindow) + { + Icon icon; + + if (dockWindow == tabLive) + icon = Icon.FromHandle(resources.t_live.GetHicon()); //Icon.FromHandle(resources.Live_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabGeo) + icon = Icon.FromHandle(resources.Geo_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabHistory) + icon = Icon.FromHandle(resources.Hist_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabReport) + icon = Icon.FromHandle(resources.Report_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabSMS) + icon = Icon.FromHandle(resources.SMS_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabVoice) + icon = Icon.FromHandle(resources.Voice_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabNewRadio) + icon = Icon.FromHandle(resources.Voice_mini_ico_pin_norm.GetHicon()); + else if (dockWindow == tabTelem) + icon = Icon.FromHandle(resources.Telem_mini_ico_pin_norm.GetHicon()); + else + icon = Icon.FromHandle(resources.Sys_mini_ico_pin_norm.GetHicon()); + + return icon; + } + + + private void radDock1_DockStateChanged(object sender, DockWindowEventArgs e) { + try { if (e.DockWindow.DockState == Telerik.WinControls.UI.Docking.DockState.Floating) { - ((FloatingWindow)e.DockWindow.FloatingParent).FormBorderStyle = FormBorderStyle.Sizable; - ((FloatingWindow)e.DockWindow.FloatingParent).MaximizeBox = true; + FloatingWindow floatingWindow = (FloatingWindow)e.DockWindow.FloatingParent; - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Live_mini_ico_pin.GetHicon()); + floatingWindow.FormBorderStyle = FormBorderStyle.Sizable; + floatingWindow.MaximizeBox = true; + + if (iconThemeType == IconTheme.CLASSIC) { - if ((ToolWindow)e.DockWindow == tabLive) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.t_live.GetHicon()); //Icon.FromHandle(global::Dispatcher.Properties.Resources.Live_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabGeo) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Geo_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabHistory) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Hist_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabReport) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Report_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabSMS) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.SMS_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabVoice) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Voice_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabNewRadio) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Voice_mini_ico_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabTelem) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Telem_mini_ico_norm.GetHicon()); - else - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Sys_mini_ico_norm.GetHicon()); + + floatingWindow.Icon = getClasicIcon((ToolWindow)e.DockWindow); + } else if (iconThemeType == IconTheme.PIN) { - if ((ToolWindow)e.DockWindow == tabLive) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.t_live.GetHicon()); //Icon.FromHandle(global::Dispatcher.Properties.Resources.Live_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabGeo) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Geo_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabHistory) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Hist_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabReport) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Report_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabSMS) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.SMS_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabVoice) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Voice_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabNewRadio) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Voice_mini_ico_pin_norm.GetHicon()); - else if ((ToolWindow)e.DockWindow == tabTelem) - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Telem_mini_ico_pin_norm.GetHicon()); - else - ((FloatingWindow)e.DockWindow.FloatingParent).Icon = Icon.FromHandle(global::Dispatcher.Properties.Resources.Sys_mini_ico_pin_norm.GetHicon()); + floatingWindow.Icon = getPinIcon((ToolWindow)e.DockWindow); + } - //((FloatingWindow)e.DockWindow.FloatingParent).MinimizeBox = true; - ((FloatingWindow)e.DockWindow.FloatingParent).FormElement.TitleBar.CloseButton.Visibility = ElementVisibility.Collapsed; + else + floatingWindow.Icon = Icon.FromHandle(resources.Live_mini_ico_pin.GetHicon()); + + //floatingWindow.MinimizeBox = true; + floatingWindow.FormElement.TitleBar.CloseButton.Visibility = ElementVisibility.Collapsed; } } catch (Exception ex) @@ -6593,6 +6710,7 @@ namespace Safedispatch_4_0 CheckTabs(track_type.HIST, (ToolWindow)sender); } + private void tabSMS_Enter(object sender, EventArgs e) { CheckTabs(track_type.SMS, (ToolWindow)sender); @@ -6611,8 +6729,7 @@ namespace Safedispatch_4_0 { CheckTabs(track_type.VOICE, (ToolWindow)sender); } - - + private void tabNewRadio_Enter(object sender, EventArgs e) { CheckTabs(track_type.RADIO, (ToolWindow)sender); @@ -6723,6 +6840,7 @@ namespace Safedispatch_4_0 } } + private void documentTabStrip1_ControlRemoved(object sender, ControlEventArgs e) { try @@ -6998,11 +7116,13 @@ namespace Safedispatch_4_0 valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; if (AddrHass[valHash] != null) { + // get address from hashtable tmpAddrAndID.Address = (String)AddrHass[valHash]; findaddress = true; } else { + // get address from database AddrtmpX = smdbObjAddress.get_address_one_connection(tmpAddrAndID.LAT, tmpAddrAndID.LNG); if (AddrtmpX != "") { @@ -7020,9 +7140,10 @@ namespace Safedispatch_4_0 if (!findaddress) { + // get address by reverse geocoding tmpAddrAndID.Address = volltmpGo2.getAddressLATLNG(tmpAddrAndID.LAT, tmpAddrAndID.LNG); } - //tmpAddrAndID.Address = ""; + if ((tmpAddrAndID.Address != "") && (tmpAddrAndID.Address != " ")) { @@ -7035,7 +7156,8 @@ namespace Safedispatch_4_0 valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; AddrHass.Add(valHash, tmpAddrAndID.Address); AddrtmpX = smdbObjAddress.get_address_one_connection(tmpAddrAndID.LAT, tmpAddrAndID.LNG); //just for avoid Error from Event Viewer - if (AddrtmpX == "") smdbObjAddress.Insert_Address_with_one_connection(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); + if (AddrtmpX == "") + smdbObjAddress.Insert_Address_with_one_connection(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); } } catch (Exception ex) @@ -7043,43 +7165,18 @@ namespace Safedispatch_4_0 SM.Debug("Error: " + ex.ToString()); } } + GisAddress.ReportProgress(tmpAddrAndID.ID, tmpAddrAndID); if ((tmpAddrAndID.ID == 0) && (tmpAddrAndID.Address != "N/A")) - smdbObjAddress.Update_address_with_one_connection(((Vehicle)vehicleHT[tmpAddrAndID.Name]).IMEI, ((Vehicle)vehicleHT[tmpAddrAndID.Name]).sc_id, ((Vehicle)vehicleHT[tmpAddrAndID.Name]).lastActivityTime, tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); + { + + Vehicle vehicle = ((Vehicle)vehicleHT[tmpAddrAndID.Name]); + smdbObjAddress.Update_address_with_one_connection(vehicle.IMEI, vehicle.sc_id, vehicle.lastActivityTime, tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); + } else smdbObjAddress.UpdateInsertAddressHash(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); } - else - { - Thread.Sleep(1100); - tmpAddrAndID.Address = volltmpGo2.getAddressLATLNG2(tmpAddrAndID.LAT, tmpAddrAndID.LNG); - - if ((tmpAddrAndID.Address != "") && (tmpAddrAndID.Address != " ")) - { - if (!findaddress) - { - try - { - if (tmpAddrAndID.Address != "N/A") - { - valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; - AddrHass.Add(valHash, tmpAddrAndID.Address); - AddrtmpX = smdbObjAddress.get_address_one_connection(tmpAddrAndID.LAT, tmpAddrAndID.LNG); //just for avoid Error from Event Viewer - if (AddrtmpX == "") smdbObjAddress.Insert_Address_with_one_connection(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); - } - } - catch (Exception ex) - { - SM.Debug("Error: " + ex.ToString()); - } - } - GisAddress.ReportProgress(tmpAddrAndID.ID, tmpAddrAndID); - if ((tmpAddrAndID.ID == 0) && (tmpAddrAndID.Address != "N/A")) - smdbObjAddress.Update_address_with_one_connection(((Vehicle)vehicleHT[tmpAddrAndID.Name]).IMEI, ((Vehicle)vehicleHT[tmpAddrAndID.Name]).sc_id, ((Vehicle)vehicleHT[tmpAddrAndID.Name]).lastActivityTime, tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); - else - smdbObjAddress.UpdateInsertAddressHash(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); - } - } + } } catch (Exception ex) @@ -7220,6 +7317,7 @@ namespace Safedispatch_4_0 { SM.Debug("Error on populate grid" + ex.ToString()); } + SystemGridView.Columns["timecmd"].SortOrder = RadSortOrder.Descending; SystemGridView.TableElement.ScrollToRow(0); } @@ -7269,35 +7367,50 @@ namespace Safedispatch_4_0 { Utils.WriteLine("SendDataToMap_DoWork error: " + ex.ToString(), ConsoleColor.Red); } - if ((vehicleHT[tmpname] != null) && (((Vehicle)vehicleHT[tmpname]).MapsHT != null)) + + + + //=================================================== + Vehicle vehicle = vehicleHT[tmpname] as Vehicle; + //=================================================== + + + if ( vehicle != null && vehicle.MapsHT != null) { - foreach (String name in ((Vehicle)vehicleHT[tmpname]).MapsHT.Keys) + foreach (String name in vehicle.MapsHT.Keys) { - if (((HideInactiveUnitsCheck) && ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).itemCheck) || - (emergOnlyCheck && ((Vehicle)vehicleHT[tmpname]).actual_status == Status_for_tab.EMERG)) + + //================================================================================== + MapElement mapElement = (MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]; + //================================================================================== + + if (( HideInactiveUnitsCheck && mapElement.itemCheck) || + (emergOnlyCheck && vehicle.actual_status == Status_for_tab.EMERG)) { - ((MapElement)((Vehicle)MainForm2.vehicleHT[tmpname]).MapsHT[name]).isActive = true; + mapElement.isActive = true; } - if (((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).isActive) + if (mapElement.isActive) { - ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).SetLastLocation(); - ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).SetLastPushpin(); + mapElement.SetLastLocation(); + mapElement.SetLastPushpin(); //temp solution for don't update the address on the Icon on live + if (MapType != MapTYPE.ArcGis) - ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).ActivatePushPin(); + mapElement.ActivatePushPin(); + if (MapType == MapTYPE.Google) { - if (((Vehicle)vehicleHT[tmpname]).needAddress) - ((Vehicle)vehicleHT[tmpname]).SetLastAddress(msgRetAddr); + if (vehicle.needAddress) + vehicle.SetLastAddress(msgRetAddr); - ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).pp.Note = - langSpeed + " " + Convert.ToString(((Vehicle)vehicleHT[tmpname]).GetSpeed()) + Measure - + " " + langTime + " " + ((Vehicle)vehicleHT[tmpname]).lastActivityTime.TimeOfDayHHMMLocal() - + "
" + FixComma(((Vehicle)vehicleHT[tmpname]).lastAddress); + mapElement.pp.Note = + langSpeed + " " + Convert.ToString(vehicle.GetSpeed()) + Measure + + " " + langTime + " " + vehicle.lastActivityTime.TimeOfDayHHMMLocal() + + "
" + FixComma(vehicle.lastAddress); //if ((MainForm2.POLLunit == tmpname) && ((Math.Round(((Vehicle)vehicleHT[volVehN]).LAT) != 0) && (Math.Round(((Vehicle)vehicleHT[volVehName]).LNG) != 0))) - if ((MainForm2.POLLunit == tmpname) && ((Math.Round(((Vehicle)vehicleHT[tmpname]).LAT) != 0) && (Math.Round(((Vehicle)vehicleHT[tmpname]).LNG) != 0))) + if (MainForm2.POLLunit == tmpname && Math.Round(vehicle.LAT) != 0 && Math.Round(vehicle.LNG) != 0) { MovePOLL = true; ;// SendDataToMap.ReportProgress(1, ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name])); @@ -7340,19 +7453,24 @@ namespace Safedispatch_4_0 { foreach (String unitName in unitNames) { - Vehicle veh = (Vehicle)vehicleHT[unitName]; - - Boolean hasVoice = ((Vehicle)vehicleHT[unitName]).has_voice; - Boolean hasText = ((Vehicle)vehicleHT[unitName]).has_text; - Boolean isInCall = ((Vehicle)vehicleHT[unitName]).inCall; - DateTime positionTime = ((Vehicle)vehicleHT[unitName]).lastValidPositionTime.ConvertGMTToLocal().GetDTFromSeconds(); + //================================================== + Vehicle vehicle = (Vehicle)vehicleHT[unitName]; + //================================================== + + Boolean hasVoice = vehicle.has_voice; + Boolean hasText = vehicle.has_text; + Boolean isInCall = vehicle.inCall; + DateTime positionTime = vehicle.lastValidPositionTime.ConvertGMTToLocal().GetDTFromSeconds(); #region mapCallTimeout && sms length int smsLength = SmsUtils.GetMaxNumberOfCharacters(MainForm2.radioType); int mapCallTimeout = 3; - ((Vehicle)MainForm2.vehicleHT[unitName]).CheckPositionInSystem(); - string GatewayAndRadioID = ((Vehicle)MainForm2.vehicleHT[unitName]).GwandRadioID; + vehicle.CheckPositionInSystem(); + string GatewayAndRadioID = vehicle.GwandRadioID; int gwType = (int)GatewayType.Unknown; + + + if (MainForm2.radioGwHT[GatewayAndRadioID] != null) { if (((RadioGateway)MainForm2.radioGwHT[GatewayAndRadioID]).Type == (int)GatewayType.Broadband @@ -7360,21 +7478,27 @@ namespace Safedispatch_4_0 { mapCallTimeout = MainForm2.MapCallTimeout; } + gwType = ((RadioGateway)MainForm2.radioGwHT[GatewayAndRadioID]).Type; smsLength = SmsUtils.GetMaxNumberOfCharacters(gwType); } #endregion - foreach (String name in ((Vehicle)vehicleHT[unitName]).MapsHT.Keys) + foreach (String name in vehicle.MapsHT.Keys) { - string iconName = ((MapElement)(veh.MapsHT[name])).pp.GetSymbName(); - if (((Vehicle)vehicleHT[unitName]).is_emergency) + //================================================================================== + MapElement mapElement = (MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]; + //================================================================================== + + string iconName = mapElement.pp.GetSymbName(); + + if (vehicle.is_emergency) { iconName = iconName.Replace(".png", "_FF79A6_l.png"); // check and create emergency icon - CheckCreateEmergencyIcon(veh.IconID); + CheckCreateEmergencyIcon(vehicle.IconID); } /* else if (MainForm2.Displaywithname) @@ -7385,14 +7509,14 @@ namespace Safedispatch_4_0 }*/ // set the command which will contains the points icon, name, speed, lat, lng, altitude, address - ((MapElement)((Vehicle)vehicleHT[unitName]).MapsHT[name]).mapControl.parLive.updatecomand += "," - + FixDoubleLAT(((Vehicle)vehicleHT[unitName]).LAT.ToString()) + "," - + FixDoubleLNG(((Vehicle)vehicleHT[unitName]).LNG.ToString()) + "," + mapElement.mapControl.parLive.updatecomand += "," + + FixDoubleLAT(vehicle.LAT.ToString()) + "," + + FixDoubleLNG(vehicle.LNG.ToString()) + "," + positionTime.ToString("yyyy-MM-dd HH:mm:ss") + "," + unitName + "," - + ((Vehicle)vehicleHT[unitName]).GetSpeed() + (MainForm2.isInMile ? "mph" : "kph") + "," - + ((Vehicle)vehicleHT[unitName]).GetAlt() + "," - + ((Vehicle)vehicleHT[unitName]).GetLastAddress().Replace(',', ' ') + "," + + vehicle.GetSpeed() + (MainForm2.isInMile ? "mph" : "kph") + "," + + vehicle.GetAlt() + "," + + vehicle.GetLastAddress().Replace(',', ' ') + "," //+ ((MapElement)((Vehicle)vehicleHT[tmpname]).MapsHT[name]).pp.GetSymbName() + "," + iconName + "," + (hasVoice ? mapCallTimeout : 0) + "," + (hasText ? smsLength : 0) + "," + isInCall; } @@ -7506,6 +7630,7 @@ namespace Safedispatch_4_0 } Thread.Sleep(10); } + if ((SystemLogFinish) && (SystemLogDataComplete) && (SystemLogSortComplete)) { if (MainForm2.is24hours) lbLastRefresh.Text = lasttimeRef + ": " + DateTime.Now.ToLocalTime().ToString("MM/dd/yyyy HH:mm:ss"); @@ -7515,6 +7640,7 @@ namespace Safedispatch_4_0 SystemLogDataComplete = false; SystemGridView.Columns["timecmd"].SortOrder = RadSortOrder.None; SystemLogSortComplete = false; + try { SystemGridView.DataSource = null; @@ -7524,6 +7650,7 @@ namespace Safedispatch_4_0 { SM.Debug("Error on populate grid" + ex.ToString()); } + SystemGridView.Columns["timecmd"].SortOrder = RadSortOrder.Descending; SystemGridView.TableElement.ScrollToRow(0); SystemLogFinish = true; @@ -7612,6 +7739,7 @@ namespace Safedispatch_4_0 { Process oldProcess = Process.GetCurrentProcess(); oldProcess.WaitForExit(8000); + String argument = " forcelogin"; switch (MainForm2.radioType) { @@ -7643,7 +7771,8 @@ namespace Safedispatch_4_0 argument = String.Concat("excera", argument); break; } - System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath, argument); + + Process.Start(System.Windows.Forms.Application.ExecutablePath, argument); oldProcess.Kill(); System.Windows.Forms.Application.Exit(); } @@ -7818,9 +7947,9 @@ namespace Safedispatch_4_0 { //write image to the memory stream if (logInfo.Direct == 0) - Dispatcher.Properties.Resources.call_made_24x20.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + resources.call_made_24x20.Save(ms, System.Drawing.Imaging.ImageFormat.Png); else - Dispatcher.Properties.Resources.call_received_24X20.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + resources.call_received_24X20.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // go to the begining of the picture ms.Seek(0, SeekOrigin.Begin); @@ -7870,72 +7999,72 @@ namespace Safedispatch_4_0 //foreach (Control dw in documentTabStrip1.Controls) { //tw.TabStripItem.Font = f; - tw.TabStripItem.Image = global::Dispatcher.Properties.Resources.adduserwhite1; + tw.TabStripItem.Image = resources.adduserwhite1; //if (iconThemeType == IconType.CLASSIC) { if (tw.TabStripItem.TabPanel == tabLive) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_live, 25, 25); else if (tw.TabStripItem.TabPanel == tabGeo) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_geofence, 25, 25); else if (tw.TabStripItem.TabPanel == tabHistory) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history, 25, 25); else if (tw.TabStripItem.TabPanel == tabReport) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_reports, 25, 25); else if (tw.TabStripItem.TabPanel == tabSMS) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_sms, 25, 25); else if (tw.TabStripItem.TabPanel == tabVoice) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); else if (tw.TabStripItem.TabPanel == tabNewRadio) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); else if (tw.TabStripItem.TabPanel == tabTicketing) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_ticketing, 25, 25); else if (tw.TabStripItem.TabPanel == tabTelem) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_telemetry, 25, 25); else if (tw.TabStripItem.TabPanel == tabAlerts) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert, 25, 25); else if (tw.Tag != null && tw.Tag is Tabs) { if (tw.Tag == Tabs.LIVE) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_live, 25, 25); else if (tw.Tag == Tabs.HISTORY) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history, 25, 25); else if (tw.Tag == Tabs.GEOFENCE) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_geofence, 25, 25); else if (tw.Tag == Tabs.REPORTS) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_reports, 25, 25); else if (tw.Tag == Tabs.TEXT) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_sms, 25, 25); else if (tw.Tag == Tabs.TICKETING) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_ticketing, 25, 25); else if (tw.Tag == Tabs.VOICE) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); else if (tw.Tag == Tabs.RADIO) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); else if (tw.Tag == Tabs.SYSTEM) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system, 25, 25); else if (tw.Tag == Tabs.TELEMETRY) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_telemetry, 25, 25); else if (tw.Tag == Tabs.ALERTS) - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert, 25, 25); else - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system, 25, 25); } else - tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system, 25, 25); + tw.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system, 25, 25); tw.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); } /* else if (iconThemeType == IconType.PIN) { - if (tw.TabStripItem.TabPanel == tabLive) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Live_mini_ico_pin, 28, 28); - else if (tw.TabStripItem.TabPanel == tabGeo) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Geo_mini_ico_pin, 28, 28); - else if (tw.TabStripItem.TabPanel == tabHistory) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Hist_mini_ico_pin, 28, 28); - else if (tw.TabStripItem.TabPanel == tabReport) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Report_mini_ico_pin, 28, 28); - else if (tw.TabStripItem.TabPanel == tabSMS) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.SMS_mini_ico_pin, 28, 28); - else if (tw.TabStripItem.TabPanel == tabVoice) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Voice_mini_ico_pin, 28, 28); - else if (tw.TabStripItem.TabPanel == tabTelem) tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Telem_mini_ico_pin, 28, 28); - else tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.Sys_mini_ico_pin, 28, 28); + if (tw.TabStripItem.TabPanel == tabLive) tw.TabStripItem.Image = Utils.ScaleImage(resources.Live_mini_ico_pin, 28, 28); + else if (tw.TabStripItem.TabPanel == tabGeo) tw.TabStripItem.Image = Utils.ScaleImage(resources.Geo_mini_ico_pin, 28, 28); + else if (tw.TabStripItem.TabPanel == tabHistory) tw.TabStripItem.Image = Utils.ScaleImage(resources.Hist_mini_ico_pin, 28, 28); + else if (tw.TabStripItem.TabPanel == tabReport) tw.TabStripItem.Image = Utils.ScaleImage(resources.Report_mini_ico_pin, 28, 28); + else if (tw.TabStripItem.TabPanel == tabSMS) tw.TabStripItem.Image = Utils.ScaleImage(resources.SMS_mini_ico_pin, 28, 28); + else if (tw.TabStripItem.TabPanel == tabVoice) tw.TabStripItem.Image = Utils.ScaleImage(resources.Voice_mini_ico_pin, 28, 28); + else if (tw.TabStripItem.TabPanel == tabTelem) tw.TabStripItem.Image = Utils.ScaleImage(resources.Telem_mini_ico_pin, 28, 28); + else tw.TabStripItem.Image = Utils.ScaleImage(resources.Sys_mini_ico_pin, 28, 28); } */ //tw.TabStripItem.ImageAlignment = ContentAlignment.TopLeft; @@ -7964,7 +8093,7 @@ namespace Safedispatch_4_0 if (e.NewWindow.Tag == Tabs.ALERTS && !isMainForm2Loaded) { // set the image for the alerts tab - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert, 25, 25); + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert, 25, 25); e.NewWindow.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); // cancel this event in order to not change the tab @@ -7981,132 +8110,141 @@ namespace Safedispatch_4_0 } - // reset the background icon for the previous tab - e.OldWindow.TabStripItem.BackColor = MainForm2.TabNormalColor; - - - - if (e.OldWindow.TabStripItem.TabPanel == tabLive) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabGeo) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabHistory) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabReport) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabSMS) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabVoice) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabNewRadio) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabTicketing) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing, 25, 25); - else if (e.OldWindow.TabStripItem.TabPanel == tabTelem) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry, 25, 25); - - // change the image for the selected tab if the TAG is a Tabs object - else if (e.OldWindow.Tag != null && e.OldWindow.Tag is Tabs) + if (e.OldWindow != null) { - if (e.OldWindow.Tag == Tabs.LIVE) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live, 25, 25); - else if (e.OldWindow.Tag == Tabs.HISTORY) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history, 25, 25); - else if (e.OldWindow.Tag == Tabs.GEOFENCE) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence, 25, 25); - else if (e.OldWindow.Tag == Tabs.REPORTS) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports, 25, 25); - else if (e.OldWindow.Tag == Tabs.TEXT) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms, 25, 25); - else if (e.OldWindow.Tag == Tabs.TICKETING) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing, 25, 25); - else if (e.OldWindow.Tag == Tabs.VOICE) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); - else if (e.OldWindow.Tag == Tabs.RADIO) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); - else if (e.OldWindow.Tag == Tabs.SYSTEM) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system, 25, 25); - else if (e.OldWindow.Tag == Tabs.TELEMETRY) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry, 25, 25); - else if (e.OldWindow.Tag == Tabs.ALERTS) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert, 25, 25); - else - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system_b, 25, 25); - } - else if (e.OldWindow.TabStripItem.TabPanel == tabAlerts) - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert, 25, 25); - else - e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system, 25, 25); - - // rotate the image 90 degrees clockwise - e.OldWindow.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); + // reset the background icon for the previous tab + e.OldWindow.TabStripItem.BackColor = MainForm2.TabNormalColor; - // change the background color of the tab - e.NewWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor;// Color.FromArgb(79, 139, 237); - // change the image for the selected tab - if (e.NewWindow.TabStripItem.TabPanel == tabLive) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabGeo) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabHistory) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabReport) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabSMS) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabVoice) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabNewRadio) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabTicketing) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing_b, 25, 25); - else if (e.NewWindow.TabStripItem.TabPanel == tabTelem) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry_b, 25, 25); - else if (e.NewWindow.Tag != null && e.OldWindow.Tag is Tabs) - { + if (e.OldWindow.TabStripItem.TabPanel == tabLive) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_live, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabGeo) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_geofence, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabHistory) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabReport) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_reports, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabSMS) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_sms, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabVoice) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabNewRadio) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabTicketing) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_ticketing, 25, 25); + else if (e.OldWindow.TabStripItem.TabPanel == tabTelem) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_telemetry, 25, 25); // change the image for the selected tab if the TAG is a Tabs object - if (e.NewWindow.Tag == Tabs.LIVE) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.HISTORY) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.GEOFENCE) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.REPORTS) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.TEXT) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.TICKETING) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.VOICE) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.RADIO) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.SYSTEM) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.TELEMETRY) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry_b, 25, 25); - else if (e.NewWindow.Tag == Tabs.ALERTS) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert_b, 25, 25); + else if (e.OldWindow.Tag != null && e.OldWindow.Tag is Tabs) + { + if (e.OldWindow.Tag == Tabs.LIVE) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_live, 25, 25); + else if (e.OldWindow.Tag == Tabs.HISTORY) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history, 25, 25); + else if (e.OldWindow.Tag == Tabs.GEOFENCE) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_geofence, 25, 25); + else if (e.OldWindow.Tag == Tabs.REPORTS) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_reports, 25, 25); + else if (e.OldWindow.Tag == Tabs.TEXT) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_sms, 25, 25); + else if (e.OldWindow.Tag == Tabs.TICKETING) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_ticketing, 25, 25); + else if (e.OldWindow.Tag == Tabs.VOICE) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); + else if (e.OldWindow.Tag == Tabs.RADIO) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice, 25, 25); + else if (e.OldWindow.Tag == Tabs.SYSTEM) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system, 25, 25); + else if (e.OldWindow.Tag == Tabs.TELEMETRY) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_telemetry, 25, 25); + else if (e.OldWindow.Tag == Tabs.ALERTS) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert, 25, 25); + else + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system_b, 25, 25); + } + else if (e.OldWindow.TabStripItem.TabPanel == tabAlerts) + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert, 25, 25); else - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system_b, 25, 25); - } - else if (e.NewWindow.TabStripItem.TabPanel == tabAlerts) - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_alert_b, 25, 25); - else - e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system_b, 25, 25); + e.OldWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system, 25, 25); - // rotate the image 90 degrees clockwise - e.NewWindow.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); + // rotate the image 90 degrees clockwise + e.OldWindow.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); + } + + + if (e.NewWindow != null) + { + // change the background color of the tab + e.NewWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor;// Color.FromArgb(79, 139, 237); + + // change the image for the selected tab + if (e.NewWindow.TabStripItem.TabPanel == tabLive) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_live_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabGeo) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_geofence_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabHistory) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabReport) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_reports_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabSMS) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_sms_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabVoice) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabNewRadio) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabTicketing) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_ticketing_b, 25, 25); + else if (e.NewWindow.TabStripItem.TabPanel == tabTelem) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_telemetry_b, 25, 25); + else if (e.NewWindow.Tag != null && e.OldWindow != null && e.OldWindow.Tag is Tabs) + { + // change the image for the selected tab if the TAG is a Tabs object + if (e.NewWindow.Tag == Tabs.LIVE) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_live_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.HISTORY) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_history_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.GEOFENCE) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_geofence_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.REPORTS) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_reports_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.TEXT) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_sms_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.TICKETING) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_ticketing_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.VOICE) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.RADIO) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_voice_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.SYSTEM) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.TELEMETRY) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_telemetry_b, 25, 25); + else if (e.NewWindow.Tag == Tabs.ALERTS) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert_b, 25, 25); + else + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system_b, 25, 25); + } + else if (e.NewWindow.TabStripItem.TabPanel == tabAlerts) + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_alert_b, 25, 25); + else + e.NewWindow.TabStripItem.Image = SafeMobileLib.Utils.ScaleImage(resources.t_system_b, 25, 25); + + // rotate the image 90 degrees clockwise + e.NewWindow.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); + } // reset font familiy for both tabs - e.OldWindow.TabStripItem.Font = new Font( - new FontFamily("Segoe UI"), - 9, - FontStyle.Regular, - GraphicsUnit.Pixel); - e.NewWindow.TabStripItem.Font + + if( e.OldWindow != null) + e.OldWindow.TabStripItem.Font = new Font( + new FontFamily("Segoe UI"), + 9, + FontStyle.Regular, + GraphicsUnit.Pixel); + + if (e.NewWindow != null) + e.NewWindow.TabStripItem.Font = new Font( new FontFamily("Segoe UI"), 9, @@ -8170,28 +8308,28 @@ namespace Safedispatch_4_0 - //e.DockWindow.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history_b, 25, 25); + //e.DockWindow.TabStripItem.Image = Utils.ScaleImage(resources.t_history_b, 25, 25); /* foreach (ToolWindow tw in this.radDock1.DockWindows.ToolWindows) { if (e.DockWindow.TabStripItem.TabPanel == tabLive) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_live, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_live, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabGeo) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_geofence, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_geofence, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabHistory) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_history, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_history, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabReport) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_reports, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_reports, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabSMS) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_sms, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_sms, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabVoice) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_voice, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_voice, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabTicketing) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_ticketing, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_ticketing, 25, 25); else if (e.DockWindow.TabStripItem.TabPanel == tabTelem) - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_telemetry, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_telemetry, 25, 25); else - tw.TabStripItem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.t_system, 25, 25); + tw.TabStripItem.Image = Utils.ScaleImage(resources.t_system, 25, 25); tw.TabStripItem.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); } @@ -8225,8 +8363,6 @@ namespace Safedispatch_4_0 } } - - private void rcbDropDropDownUnitEvent_ItemCheckedChanged(object sender, RadCheckedListDataItemEventArgs e) { // clear all priority filters @@ -8321,15 +8457,15 @@ namespace Safedispatch_4_0 /// it was selected. ///
/// Picture box corresponding for the filter needed - private Image themelFilterUser_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.s_filter_user, MainForm2.ButtonColor); - private Image themelFilterType_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.s_filter_type, MainForm2.ButtonColor); - private Image themelFilterDirection_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.s_filter_direction, MainForm2.ButtonColor); + private Image themelFilterUser_Image = Utils.ChangeColor(resources.s_filter_user, MainForm2.ButtonColor); + private Image themelFilterType_Image = Utils.ChangeColor(resources.s_filter_type, MainForm2.ButtonColor); + private Image themelFilterDirection_Image = Utils.ChangeColor(resources.s_filter_direction, MainForm2.ButtonColor); private void pbFilter_Click(object sender, EventArgs e) { // set all images to gray - pbFilterDirection.Image = Dispatcher.Properties.Resources.s_filter_direction_grey; - pbFilterType.Image = Dispatcher.Properties.Resources.s_filter_type_grey; - pbFilterUnit.Image = Dispatcher.Properties.Resources.s_filter_user_grey; + pbFilterDirection.Image = resources.s_filter_direction_grey; + pbFilterType.Image = resources.s_filter_type_grey; + pbFilterUnit.Image = resources.s_filter_user_grey; filterName = "none"; @@ -8628,10 +8764,8 @@ namespace Safedispatch_4_0 ///
private void tabAlerts_Enter(object sender, EventArgs e) { - if (tabLive != null) - radDock1.ActivateWindow(tabLive); - else - radDock1.ActivateWindow(tabSystem); + ToolWindow toolWindow = (tabLive != null) ? tabLive : tabSystem; + radDock1.ActivateWindow(toolWindow); } @@ -8690,8 +8824,8 @@ namespace Safedispatch_4_0 { if (imagesDictionary.ContainsKey(key)) return imagesDictionary[key]; - else - return global::Dispatcher.Properties.Resources.classic_unknown; + + return resources.classic_unknown; } @@ -8734,35 +8868,40 @@ namespace Safedispatch_4_0 { this.Invoke((MethodInvoker)delegate { + string message = ""; + switch (MainForm2.radioType) { case RADIOTYPE.CONECTPLUS: case RADIOTYPE.TETRA: case RADIOTYPE.MOTO: case RADIOTYPE.REPEATER_TRBO: - RadMessageBox.Show("Please register your copy of SafeDispatch using the Administrative Module.\n Your IP address is:" + Login.IPaddress, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + message = $"Please register your copy of SafeDispatch using the Administrative Module.\n Your IP address is: {Login.IPaddress}"; break; case RADIOTYPE.HYT: - RadMessageBox.Show("Please register your copy of SafeSyt using the Administrative Module.\n Your IP address is:" + Login.IPaddress, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + message = $"Please register your copy of SafeSyt using the Administrative Module.\n Your IP address is: {Login.IPaddress} "; break; case RADIOTYPE.HARRIS: ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; - RadMessageBox.Show("Please register your copy of Vision using the Administrative Module.\n Your IP address is:" + Login.IPaddress, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + message = $"Please register your copy of Vision using the Administrative Module.\n Your IP address is: {Login.IPaddress}"; break; case RADIOTYPE.ATLAS: ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; - RadMessageBox.Show("Please register your copy of ATL25 using the Administrative Module.\n Your IP address is:" + Login.IPaddress, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + message = $"Please register your copy of ATL25 using the Administrative Module.\n Your IP address is: {Login.IPaddress}"; break; case RADIOTYPE.SIMOCO: ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; - RadMessageBox.Show("Please register your copy of Simoco using the Administrative Module.\n Your IP address is:" + Login.IPaddress, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + message = $"Please register your copy of Simoco using the Administrative Module.\n Your IP address is: {Login.IPaddress}"; break; case RADIOTYPE.EXCERA: ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; - RadMessageBox.Show("Please register your copy of Excera using the Administrative Module.\n Your IP address is:" + Login.IPaddress, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + message = $"Please register your copy of Excera using the Administrative Module.\n Your IP address is: {Login.IPaddress}"; break; } - // System.Environment.Exit(1); + + if( !string.IsNullOrEmpty(message) ) + RadMessageBox.Show(message, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); + System.Windows.Forms.Application.Exit(); }); @@ -9260,21 +9399,23 @@ namespace Safedispatch_4_0 } - if ((VehIDHash[sc_id] != null) && (vehicleHT[VehIDHash[sc_id].ToString()] != null)) + string veh_name = (String)VehIDHash[sc_id]; + + if ( !string.IsNullOrEmpty(veh_name) && vehicleHT.ContainsKey(veh_name)) { - Vehicle veh = ((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]); + Vehicle veh = ((Vehicle)vehicleHT[veh_name]); veh.CheckPositionInSystem(); - String Totrans = "#" + (int)MessageBusCmds.SendSMSRequest + "#" + ((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).GwandRadioID + "." + ((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).IMEI + "#" + mbusText + "#" + sched_timegmt + "#" + userIDX + "#"; + String Totrans = "#" + (int)MessageBusCmds.SendSMSRequest + "#" + veh.GwandRadioID + "." + veh.IMEI + "#" + mbusText + "#" + sched_timegmt + "#" + userIDX + "#"; //old //String Totrans = "#142#" + ((Vehicle)MainForm2.vehicleHT[MainForm2.VehIDHash[sc_id].ToString()]).IMEI + "#" + text + "#" + sched_timegmt + "#"; string smsSeqID = Send_UDP_cmd(Totrans, 0, 0); Utils.WriteLine("»»» Text message to " + sc_id + " [" + text + "]", ConsoleColor.White); - ((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).EventLists.Add(new Alarms(rep_type.SMSSEND, DateTime.Now, "", text)); - if (PopupOpen[((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).IMEI] != null) - ((FastCommandWindow)PopupOpen[((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).IMEI]).populate(); + veh.EventLists.Add(new Alarms(rep_type.SMSSEND, DateTime.Now, "", text)); + if (PopupOpen[veh.IMEI] != null) + ((FastCommandWindow)PopupOpen[veh.IMEI]).populate(); DisplayToast(returnLNGString("txtMsgTo") + veh.busName, "" + returnLNGString("msj") + " " + "" + text + "" + " " + returnLNGString("wasSentToGW") + ""); @@ -9282,9 +9423,9 @@ namespace Safedispatch_4_0 // Send also sip message if destination is linx if (_sipClient != null) { - if (((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).canMakeSipCalls) + if (veh.canMakeSipCalls) { - bool sipSmsReceived = await SendSipSmsAsync(((Vehicle)vehicleHT[VehIDHash[sc_id].ToString()]).sipID.ToString(), text); + bool sipSmsReceived = await SendSipSmsAsync(veh.sipID.ToString(), text); // Send sms confirmation on mbus diff --git a/Safedispatch_4_0/ReverseGeocodingModule.cs b/Safedispatch_4_0/ReverseGeocodingModule.cs index bd5714a..2118c98 100644 --- a/Safedispatch_4_0/ReverseGeocodingModule.cs +++ b/Safedispatch_4_0/ReverseGeocodingModule.cs @@ -11,13 +11,17 @@ namespace Dispatcher public class ReverseGeocodingModule { public static String osnServer = "192.168.65.130"; - - public static List CalculateAddressForPositions(List positions) + + public static List CalculateAddressForPositions(List positions) { List results = new List(); - foreach(PositionData pos in positions) + foreach(ILocationAddress pos in positions) { + + if (pos.Lat == 0.0 && pos.Lng == 0.0) + continue; + String address = GetAddressFromOSM(pos.Lat, pos.Lng); if (address == null) address = GetAddressFromGoogle(pos.Lat, pos.Lng); @@ -39,8 +43,11 @@ namespace Dispatcher await Task.Factory.StartNew(() => { - foreach (PositionData pos in positions) + foreach (ILocationAddress pos in positions) { + if (pos.Lat == 0.0 && pos.Lng == 0.0) + continue; + String address = GetAddressFromOSM(pos.Lat, pos.Lng); if (address == null) address = GetAddressFromGoogle(pos.Lat, pos.Lng); diff --git a/Safedispatch_4_0/SMdb_accessMS.cs b/Safedispatch_4_0/SMdb_accessMS.cs index ab14aad..8ae23b7 100644 --- a/Safedispatch_4_0/SMdb_accessMS.cs +++ b/Safedispatch_4_0/SMdb_accessMS.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.Collections; using System.Data; @@ -684,8 +685,6 @@ namespace Safedispatch_4_0 Console.WriteLine(ee.Message + " " + ee.StackTrace + " " + ee.Source); } } - conn.Close(); - } } @@ -729,6 +728,7 @@ namespace Safedispatch_4_0 Start = (MainForm2.vehicleHT[p_vehicle] as Vehicle).sc_id * 10000000000 + p_start; Stop = (MainForm2.vehicleHT[p_vehicle] as Vehicle).sc_id * 10000000000 + p_stop; } + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); @@ -785,7 +785,7 @@ namespace Safedispatch_4_0 } } } - conn.Close(); + } /*System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test3.txt"); @@ -825,11 +825,10 @@ namespace Safedispatch_4_0 { using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { - conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand("UPDATE \"userSettings\" SET value='" + value + "' WHERE user_id=" + MainForm2.userIDX.ToString() +" AND key='" + key + "'", conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + conn.Open(); + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE \"userSettings\" SET value='" + value + "' WHERE user_id=" + MainForm2.userIDX.ToString() + " AND key='" + key + "'", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -870,11 +869,10 @@ namespace Safedispatch_4_0 { conn.Open(); String query = "select count(address) from address"; - - using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) - ret = Convert.ToInt32(cmd.ExecuteScalar()); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) + { ret = Convert.ToInt32(cmd.ExecuteScalar()); } + } return ret; } @@ -885,12 +883,11 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - String query = "select count(*) from user_radio"; + String query = "SELECT COUNT(*) FROM user_radio"; using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) - ret = Convert.ToInt32(cmd.ExecuteScalar()); + { ret = Convert.ToInt32(cmd.ExecuteScalar()); } - conn.Close(); } return ret; } @@ -906,7 +903,7 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - String query = String.Format("select lat,lng,timeGMT,address from messages where scevtime>{0} and scevtime<{1}", Start, Stop); + String query = String.Format("SELECT lat,lng,timeGMT,address FROM messages where scevtime>{0} and scevtime<{1}", Start, Stop); using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) { int cnt = 0; @@ -926,7 +923,6 @@ namespace Safedispatch_4_0 } } } - conn.Close(); } return ret; } @@ -943,7 +939,7 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - String query = String.Format("select lat,lng,timeGMT,address from messages where scevtime={0}", exact); + String query = String.Format("SELECT lat,lng,timeGMT,address FROM messages WHERE scevtime={0}", exact); using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) { int cnt = 0; @@ -965,7 +961,7 @@ namespace Safedispatch_4_0 } } - query = String.Format("select lat,lng,timeGMT,address from messages where scevtime>{0} and scevtime<{1}", Start, Stop); + query = String.Format("SELECT lat,lng,timeGMT,address FROM messages WHERE scevtime>{0} and scevtime<{1}", Start, Stop); using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) { int cnt = 0; @@ -985,7 +981,6 @@ namespace Safedispatch_4_0 } } } - conn.Close(); } return ret; } @@ -1004,7 +999,7 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("select sc_id,lat,lng,timeGMT,rfid from messages where scevtime>{0} and scevtime<{1} and rfid>''", Start,Stop), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("SELECT sc_id,lat,lng,timeGMT,rfid FROM messages WHERE scevtime>{0} AND scevtime<{1} and rfid>''", Start,Stop), conn)) { int cnt = 0; using (NpgsqlDataReader dr = cmd.ExecuteReader()) @@ -1026,7 +1021,7 @@ namespace Safedispatch_4_0 } } } - conn.Close(); + } return ret; } @@ -1165,7 +1160,6 @@ namespace Safedispatch_4_0 while (dr.Read()) ret.Add(new VehandID(dr.GetString(0), dr.GetInt32(1), dr.GetInt32(2).ToString())); } - conn.Close(); } return ret; } @@ -1214,7 +1208,6 @@ namespace Safedispatch_4_0 } dr.Close(); } - conn.Close(); } return landmarks; @@ -1232,25 +1225,24 @@ namespace Safedispatch_4_0 { int crt = 0; conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT type_id, type_name, icon_name" - + " FROM placetype" - + " ORDER BY type_name", conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT type_id, type_name, icon_name FROM placetype" + + " ORDER BY type_name", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - landmarkTypes.Add(dr.GetInt32(0), - new LandmarkType() - { - CrtIdx = crt++, - Idx = dr.GetInt32(0), - TypeName = dr.GetString(1), - IconName = dr.IsDBNull(2) ? "" : dr.GetString(2) - }); + while (dr.Read()) + { + landmarkTypes.Add(dr.GetInt32(0), + new LandmarkType() + { + CrtIdx = crt++, + Idx = dr.GetInt32(0), + TypeName = dr.GetString(1), + IconName = dr.IsDBNull(2) ? "" : dr.GetString(2) + }); + } } - dr.Close(); } - conn.Close(); } return landmarkTypes; } @@ -1389,7 +1381,6 @@ namespace Safedispatch_4_0 } dr.Close(); } - conn.Close(); } return geofences; @@ -1427,7 +1418,7 @@ namespace Safedispatch_4_0 while (dr.Read()) ret.Add(new GatewayIDandIP(dr.GetInt32(0), dr.GetInt32(1), dr.GetString(2))); } - conn.Close(); + } return ret; } @@ -1438,14 +1429,14 @@ namespace Safedispatch_4_0 NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("select sms from defineSMS order by sms", conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand("SEELCT sms FROM defineSMS ORDER BY sms", conn)) { NpgsqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) //ret.Add(new Zone_type(dr.GetString(0), dr.GetInt32(1), 0)); ret.Add(dr.GetString(0)); } - conn.Close(); + } return ret; } @@ -1455,13 +1446,12 @@ namespace Safedispatch_4_0 NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("select login from users where userid='{0}' and password ='{1}'", userID,pass), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT login FROM users WHERE userid='{userID}' and password ='{pass}'", conn)) { NpgsqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) return true; } - conn.Close(); } return false; } @@ -1471,10 +1461,9 @@ namespace Safedispatch_4_0 NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("DELETE FROM messages where timeGMT <{0}",timelimit), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM messages where timeGMT <{timelimit}", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -1483,10 +1472,9 @@ namespace Safedispatch_4_0 NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE vehicle SET time_route={0} WHERE name='{1}'", col, name), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE vehicle SET time_route = {col} WHERE name = '{name}'", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -1495,10 +1483,9 @@ namespace Safedispatch_4_0 NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE vehicle SET driver_id={0} WHERE id={1}",driver_id, idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE vehicle SET driver_id = {driver_id} WHERE id={idx}", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -1513,22 +1500,23 @@ namespace Safedispatch_4_0 conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT p.name , p.note , p.lat , p.lng , p.address, t.type_name, p.callout, p.callout_severity from place p, placetype t where p.type_id=t.type_id and p.name = '{0}' and p.idx<>{1}",name,idxmod), conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - if (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - ret = new Place + if (dr.Read()) { - name = dr.GetString(0), - desc = dr.GetString(1), - lat = dr.GetDouble(2), - lng = dr.GetDouble(3), - address = dr.GetString(4), - type = dr.GetString(5), - callout = dr.GetBoolean(6), - callout_severity=dr.GetInt16(7) - }; + ret = new Place + { + name = dr.GetString(0), + desc = dr.GetString(1), + lat = dr.GetDouble(2), + lng = dr.GetDouble(3), + address = dr.GetString(4), + type = dr.GetString(5), + callout = dr.GetBoolean(6), + callout_severity = dr.GetInt16(7) + }; + } } - dr.Close(); } conn.Close(); } @@ -1541,10 +1529,9 @@ namespace Safedispatch_4_0 NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand("SELECT version,idx from updatelist where idx IN (select max(idx) from updatelist)", conn)) - name = (String)cmd.ExecuteScalar(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT version,idx FROM updatelist WHERE idx IN (SELECT MAX(idx) FROM updatelist)", conn)) + { name = (String)cmd.ExecuteScalar(); } + } return name; } @@ -1558,17 +1545,19 @@ namespace Safedispatch_4_0 if (descris != null) descris = descris.Replace(c, '`'); String addr = Address; if (addr != null) { addr = addr.Replace(c, '`'); addr = addr.Replace(',', ' '); } + NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString); { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("INSERT INTO place (name,note,lat,lng,type_id,address,useridx) VALUES('{0}','{1}',@lat,@lng,{2},'{3}',{4})",name,descris,p_id,addr,useridx); - cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; - cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; - cmd.Prepare(); - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.Connection = conn; + cmd.CommandText = string.Format("INSERT INTO place (name,note,lat,lng,type_id,address,useridx) VALUES('{0}','{1}',@lat,@lng,{2},'{3}',{4})", name, descris, p_id, addr, useridx); + cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; + cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; + cmd.Prepare(); + cmd.ExecuteNonQuery(); + } } } @@ -1582,21 +1571,23 @@ namespace Safedispatch_4_0 if (descris != null) descris = descris.Replace(c, '`'); String addr = Address; if (addr != null) { addr = addr.Replace(c, '`'); addr = addr.Replace(',', ' '); } + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { // get the hex colors for the desired color String hexColor = "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2"); conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("INSERT INTO place (name,note,lat,lng,type_id,address,useridx, color, icon_size, callout, callout_severity) " - + " VALUES('{0}','{1}',@lat,@lng,{2},'{3}',{4}, '{5}', '{6}', {7}, {8})", name, descris, p_id, addr, useridx, hexColor, iconSize.ToDBString(), callout, callout_severity); - cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; - cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; - cmd.Prepare(); - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.Connection = conn; + cmd.CommandText = string.Format("INSERT INTO place (name,note,lat,lng,type_id,address,useridx, color, icon_size, callout, callout_severity) " + + " VALUES('{0}','{1}',@lat,@lng,{2},'{3}',{4}, '{5}', '{6}', {7}, {8})", name, descris, p_id, addr, useridx, hexColor, iconSize.ToDBString(), callout, callout_severity); + cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; + cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; + cmd.Prepare(); + cmd.ExecuteNonQuery(); + } } } @@ -1607,10 +1598,10 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT max(idx) from place", conn)) - returnValue = (Int32)cmd.ExecuteScalar(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT MAX(idx) FROM place", conn)) + { returnValue = (Int32)cmd.ExecuteScalar(); } } + return returnValue; } @@ -1619,17 +1610,19 @@ namespace Safedispatch_4_0 Char c = (char)39; String addr = p_addr; if (addr != null) { addr = addr.Replace(c, '`'); addr = addr.Replace(',', ' '); } + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("INSERT INTO address (lat,lng,address,type) VALUES(@lat,@lng,'{0}',1)", addr); - cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; - cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; - cmd.Prepare(); - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.Connection = conn; + cmd.CommandText = string.Format("INSERT INTO address (lat,lng,address,type) VALUES(@lat,@lng,'{0}',1)", addr); + cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; + cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; + cmd.Prepare(); + cmd.ExecuteNonQuery(); + } } } @@ -1641,32 +1634,34 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("UPDATE reports SET startdate={0}, stopdate={1}, unit_ids='{2}', geofence_id={3}, " - + "type_stat={4}, idletime={5}, report_id={6}, email='{7}', latlng={8}, userid={9}, ticket_status='{10}', " - + "ticket_date_type='{11}', type='{12}', day='{13}', is_activated='{14}' WHERE idx = {15} AND unit_ids='{2}'; ", - startdate, stopdate, unit_ids, geo_id, type, idle, repID, email, LatLng, MainForm2.userIDX, TicketStatus, TicketDateType, - reportType, days, is_activated, id) - + Environment.NewLine - + string.Format("INSERT INTO reports (startdate,stopdate,unit_ids,geofence_id,type_stat," + - "idletime,report_id,email,latlng,userid, ticket_status, ticket_date_type, type, day, is_activated) " + - //"VALUES({0},{1},'{2}',{3},{4},{5},{6},'{7}',{8},{9},'{10}','{11}', '{12}', '{13}', 'TRUE')", - " SELECT {0},{1},'{2}',{3},{4},{5},{6},'{7}',{8},{9},'{10}','{11}', '{12}', '{13}', 't'" - + " WHERE NOT EXISTS (SELECT 1 FROM reports WHERE report_id=" + repID + " AND unit_ids='{2}' and userid={9}) RETURNING idx ", - startdate, stopdate, unit_ids, geo_id, type, idle, repID, email, LatLng, MainForm2.userIDX, TicketStatus, TicketDateType, reportType, days); - //cmd.ExecuteNonQuery(); - //conn.Close(); - - - // execute and get index if inserted - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlCommand cmd = new NpgsqlCommand()) { - id = dr.GetInt32(0); + cmd.Connection = conn; + cmd.CommandText = string.Format("UPDATE reports SET startdate={0}, stopdate={1}, unit_ids='{2}', geofence_id={3}, " + + "type_stat={4}, idletime={5}, report_id={6}, email='{7}', latlng={8}, userid={9}, ticket_status='{10}', " + + "ticket_date_type='{11}', type='{12}', day='{13}', is_activated='{14}' WHERE idx = {15} AND unit_ids='{2}'; ", + startdate, stopdate, unit_ids, geo_id, type, idle, repID, email, LatLng, MainForm2.userIDX, TicketStatus, TicketDateType, + reportType, days, is_activated, id) + + Environment.NewLine + + string.Format("INSERT INTO reports (startdate,stopdate,unit_ids,geofence_id,type_stat," + + "idletime,report_id,email,latlng,userid, ticket_status, ticket_date_type, type, day, is_activated) " + + //"VALUES({0},{1},'{2}',{3},{4},{5},{6},'{7}',{8},{9},'{10}','{11}', '{12}', '{13}', 'TRUE')", + " SELECT {0},{1},'{2}',{3},{4},{5},{6},'{7}',{8},{9},'{10}','{11}', '{12}', '{13}', 't'" + + " WHERE NOT EXISTS (SELECT 1 FROM reports WHERE report_id=" + repID + " AND unit_ids='{2}' and userid={9}) RETURNING idx ", + startdate, stopdate, unit_ids, geo_id, type, idle, repID, email, LatLng, MainForm2.userIDX, TicketStatus, TicketDateType, reportType, days); + //cmd.ExecuteNonQuery(); + //conn.Close(); + + + // execute and get index if inserted + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + while (dr.Read()) + { + id = dr.GetInt32(0); + } + } } - dr.Close(); - conn.Close(); return new ReportDefinition() { @@ -1741,7 +1736,6 @@ namespace Safedispatch_4_0 } dr.Close(); } - conn.Close(); } return reportsDefinitions; } @@ -1752,12 +1746,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("UPDATE reports SET is_activated='{0}' " - + " WHERE idx = {1} AND userid = {2} ",isActive , id, userId); - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE reports SET is_activated='{isActive}' WHERE idx = {id} AND userid = {userId} ", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -1766,26 +1757,21 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("UPDATE geozoneinout SET zone_id={0} where zone_id={1}", idx_new,idx_old); - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE geozoneinout SET zone_id={idx_new} WHERE zone_id = {idx_old}", conn)) + { cmd.ExecuteNonQuery(); } } } public void Update_all_old_Reports(String idx_new, String idx_old,Boolean Geofence) { - Int32 type = 1; - if (!Geofence) type = 4; + Int32 type = (!Geofence) ? 4 : 1; + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("UPDATE reports SET geofence_id={0} where geofence_id={1} and type_stat={2}", idx_new, idx_old,type); - cmd.ExecuteNonQuery(); - conn.Close(); + NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE reports SET geofence_id = {idx_new} WHERE geofence_id = {idx_old} and type_stat = {type}", conn); + { cmd.ExecuteNonQuery(); } + } } @@ -1799,13 +1785,13 @@ namespace Safedispatch_4_0 { try { - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = connAddress; - cmd.CommandText = string.Format("INSERT INTO address (lat,lng,address,type) VALUES(@lat,@lng,'{0}',1)", addr); - cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; - cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; - cmd.Prepare(); - cmd.ExecuteNonQuery(); + NpgsqlCommand cmd = new NpgsqlCommand(); + cmd.Connection = connAddress; + cmd.CommandText = string.Format("INSERT INTO address (lat,lng,address,type) VALUES(@lat,@lng,'{0}',1)", addr); + cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; + cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; + cmd.Prepare(); + cmd.ExecuteNonQuery(); nrofErrors=3; } catch (Exception ex) @@ -1825,19 +1811,20 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = string.Format("UPDATE address SET address='{0}' WHERE lat = {1} AND lng = {2}; ", - p_addr, lat, lng) - + Environment.NewLine - + string.Format("INSERT INTO address (lat,lng,address,type) " + - " SELECT {0},{1}, '{2}', {3}" - + " WHERE NOT EXISTS (SELECT 1 FROM address WHERE lat=" + lat + " AND lng=" + lng +" )", - lat, lng, p_addr, 1); + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.Connection = conn; + cmd.CommandText = string.Format("UPDATE address SET address='{0}' WHERE lat = {1} AND lng = {2}; ", + p_addr, lat, lng) + + Environment.NewLine + + string.Format("INSERT INTO address (lat,lng,address,type) " + + " SELECT {0},{1}, '{2}', {3}" + + " WHERE NOT EXISTS (SELECT 1 FROM address WHERE lat=" + lat + " AND lng=" + lng + " )", + lat, lng, p_addr, 1); - // execute and get index if inserted - NpgsqlDataReader dr = cmd.ExecuteReader(); - conn.Close(); + // execute and get index if inserted + NpgsqlDataReader dr = cmd.ExecuteReader(); + } } } @@ -1859,13 +1846,16 @@ namespace Safedispatch_4_0 Char c = (char)39; String addr = p_addr; if (addr != null) { addr = addr.Replace(c, '`'); addr = addr.Replace(',', ' '); } - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = connX; - cmd.CommandText = string.Format("INSERT INTO address (lat,lng,address,type) VALUES(@lat,@lng,'{0}',1)", addr); - cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; - cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; - cmd.Prepare(); - cmd.ExecuteNonQuery(); + + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.Connection = connX; + cmd.CommandText = string.Format("INSERT INTO address (lat,lng,address,type) VALUES(@lat,@lng,'{0}',1)", addr); + cmd.Parameters.Add("@lat", NpgsqlTypes.NpgsqlDbType.Double).Value = lat; + cmd.Parameters.Add("@lng", NpgsqlTypes.NpgsqlDbType.Double).Value = lng; + cmd.Prepare(); + cmd.ExecuteNonQuery(); + } } public void Update_address_with_one_connection(String p_imei, Int32 p_sc_id, Int32 p_timeGMT, String p_address, Double LAT, Double LNG) @@ -1877,6 +1867,7 @@ namespace Safedispatch_4_0 Int64 intLAT = 0, intLNG = 0; intLAT = (Int64)(LAT * 10000); intLNG = (Int64)(LNG * 10000); + while (nrofErrors<2) { try @@ -1904,13 +1895,14 @@ namespace Safedispatch_4_0 conn.Open(); Double scev_id; using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE lastpos set address ='{0}' where imei='{1}' and round(lat*10000)={2} and round(lng*10000)={3}", name, p_imei,intLAT,intLNG), conn)) - cmd.ExecuteNonQuery(); + new NpgsqlCommand(string.Format("UPDATE lastpos set address ='{0}' where imei='{1}' and round(lat*10000)={2} and round(lng*10000)={3}", name, p_imei, intLAT, intLNG), conn)) + { cmd.ExecuteNonQuery(); } + scev_id = p_sc_id * 10000000000 + p_timeGMT; using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("UPDATE messages set address ='{0}' where scevtime={1}", name, scev_id), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + { cmd.ExecuteNonQuery(); } + } } @@ -1925,12 +1917,13 @@ namespace Safedispatch_4_0 Double scev_id; using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("UPDATE speedalarm set address='{2}', lat={3}, lng={4} where sc_id={0} and timegmt={1}", p_sc_id, p_timeGMT, name, p_lat, p_lng), conn)) - cmd.ExecuteNonQuery(); + { cmd.ExecuteNonQuery(); } scev_id = p_sc_id * 10000000000 + p_timeGMT; + using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("UPDATE messages set address ='{0}' where scevtime={1}", name, scev_id), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + { cmd.ExecuteNonQuery(); } + } } @@ -1939,6 +1932,7 @@ namespace Safedispatch_4_0 Char c = (char)39; String name = p_address; if (name != null) name = name.Replace(c, '`'); + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); @@ -1947,7 +1941,7 @@ namespace Safedispatch_4_0 new NpgsqlCommand(string.Format("UPDATE sms set address='{2}', lat={3}, lng={4} where sc_id_sour={0} and timegmt={1}", p_sc_id, p_timeGMT, name, p_lat, p_lng), conn)) cmd.ExecuteNonQuery(); scev_id = p_sc_id * 10000000000 + p_timeGMT; - conn.Close(); + } } @@ -1956,12 +1950,13 @@ namespace Safedispatch_4_0 Char c = (char)39; String name = p_address; if (name != null) name = name.Replace(c, '`'); + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { - conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("UPDATE telemetry_history set address='{2}', lat={3}, lng={4} where sc_id={0} and timegmt={1}", p_sc_id, p_timeGMT,name, p_lat, p_lng), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + conn.Open(); + using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("UPDATE telemetry_history set address='{2}', lat={3}, lng={4} where sc_id={0} and timegmt={1}", p_sc_id, p_timeGMT, name, p_lat, p_lng), conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -1970,12 +1965,13 @@ namespace Safedispatch_4_0 Char c = (char)39; String name = p_address.Substring(0,45); if (name != null) name = name.Replace(c, '`'); + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("UPDATE emergalarm set address='{2}', lat={3}, lng={4} where sc_id={0} and timegmt={1}", p_sc_id, p_timeGMT, name, p_lat, p_lng), conn)) cmd.ExecuteNonQuery(); - conn.Close(); + } } @@ -1987,10 +1983,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE messages set address ='{0}' where scevtime={1}", name, scevMSSQL), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE messages set address ='{name}' where scevtime={scevMSSQL}", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -2062,14 +2057,14 @@ namespace Safedispatch_4_0 cmd.ExecuteNonQuery(); Thread.Sleep(200); - cmd = new NpgsqlCommand("SELECT max(idx) from zonename", conn); + cmd = new NpgsqlCommand("SELECT MAX(idx) FROM zonename", conn); idx = (Int32)cmd.ExecuteScalar(); foreach (PointonZone obj in points) { cmd = new NpgsqlCommand(); cmd.Connection = conn; - cmd.CommandText = string.Format("INSERT INTO zonepoints (lat,lng,zone_id) VALUES(@lat1,@lng1,{0})", idx); + cmd.CommandText = string.Format("INSERT INTO zonepoints (lat,lng,zone_id) VALUES (@lat1, @lng1, {0})", idx); cmd.Parameters.Add("@lat1", NpgsqlTypes.NpgsqlDbType.Double).Value = obj.lat; cmd.Parameters.Add("@lng1", NpgsqlTypes.NpgsqlDbType.Double).Value = obj.lng; cmd.Prepare(); @@ -2086,26 +2081,26 @@ namespace Safedispatch_4_0 Char c = (char)39; String name = p_SMS; if (name != null) name = name.Replace(c, '`'); + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); object temp = null; - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("SELECT count(sms) FROM definesms where sms='{0}'", name), conn)) - temp = cmd.ExecuteScalar(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT count(sms) FROM definesms where sms='{name}'", conn)) + { temp = cmd.ExecuteScalar(); } if (temp.ToString() == "0") { - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("INSERT INTO defineSMS (sms) VALUES('{0}')", name), conn)) - cmd.ExecuteNonQuery(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"INSERT INTO defineSMS (sms) VALUES('{name}')", conn)) + { cmd.ExecuteNonQuery(); } + ret = true; } else { ret = false; } - conn.Close(); + } return ret; } @@ -2115,13 +2110,12 @@ namespace Safedispatch_4_0 Char c = (char)39; String name = p_SMS; if (name != null) name = name.Replace(c, '`'); + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE defineSMS SET sms ='{0}' where idx={1}", name, p_idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE defineSMS SET sms ='{name}' WHERE idx = {p_idx}", conn)) + { cmd.ExecuteNonQuery(); } } } @@ -2133,26 +2127,27 @@ namespace Safedispatch_4_0 conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT p.name, p.note, p.lat, p.lng, p.address, t.type_name, p.useridx, p.callout, p.callout_severity from place p, placetype t where p.type_id=t.type_id {0}", glwhere), conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - var tmp = new Place + while (dr.Read()) { - name = dr.GetString(0), - desc = dr.GetString(1), - lat = dr.GetDouble(2), - lng = dr.GetDouble(3), - address = dr.GetString(4), - type = dr.GetString(5), - useridx = dr.GetInt32(6), - callout = dr.GetBoolean(7), - callout_severity = dr.GetInt16(8) - }; - ret.Add(tmp); + var tmp = new Place + { + name = dr.GetString(0), + desc = dr.GetString(1), + lat = dr.GetDouble(2), + lng = dr.GetDouble(3), + address = dr.GetString(4), + type = dr.GetString(5), + useridx = dr.GetInt32(6), + callout = dr.GetBoolean(7), + callout_severity = dr.GetInt16(8) + }; + ret.Add(tmp); + } } - dr.Close(); } - conn.Close(); + } return ret; } @@ -2184,7 +2179,6 @@ namespace Safedispatch_4_0 } dr.Close(); } - conn.Close(); } return ret; } @@ -2195,27 +2189,27 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT type_name, type_id from placetype ORDER by type_name", conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT type_name, type_id FROM placetype ORDER BY type_name", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - Place obj = new Place(); - obj.type = dr.GetString(0); - obj.idx = dr.GetInt32(1); - obj.pic = ""; - try + while (dr.Read()) { - ret.Add(obj.type, obj); - } - catch (Exception ex) - { - SM.Debug("Error add place type"+ex.ToString()); + Place obj = new Place(); + obj.type = dr.GetString(0); + obj.idx = dr.GetInt32(1); + obj.pic = ""; + try + { + ret.Add(obj.type, obj); + } + catch (Exception ex) + { + SM.Debug("Error add place type" + ex.ToString()); + } } } - dr.Close(); } - conn.Close(); } // check if resource directory exists @@ -2307,29 +2301,29 @@ namespace Safedispatch_4_0 " JOIN place p on p.type_id = pt.type_id "+ " ORDER by type_name ", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - Place obj = new Place(); - obj.type = dr.GetString(0); - obj.idx = dr.GetInt32(1); - obj.pic = ""; - obj.iconSize = dr.GetValue(2).ToString(); - obj.color = dr.GetValue(3).ToString(); - obj.iconName = dr.GetValue(4).ToString(); - try + while (dr.Read()) { - if (!ret.Contains(obj.type + obj.color + obj.iconSize)) - ret.Add(obj.type + obj.color + obj.iconSize, obj); - } - catch (Exception ex) - { - SM.Debug("Error add place type" + ex.ToString()); + Place obj = new Place(); + obj.type = dr.GetString(0); + obj.idx = dr.GetInt32(1); + obj.pic = ""; + obj.iconSize = dr.GetValue(2).ToString(); + obj.color = dr.GetValue(3).ToString(); + obj.iconName = dr.GetValue(4).ToString(); + try + { + if (!ret.Contains(obj.type + obj.color + obj.iconSize)) + ret.Add(obj.type + obj.color + obj.iconSize, obj); + } + catch (Exception ex) + { + SM.Debug("Error add place type" + ex.ToString()); + } } } - dr.Close(); } - conn.Close(); } // check if resource directory exists @@ -2486,15 +2480,15 @@ namespace Safedispatch_4_0 conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("SELECT timeGMT , address , lat , lng , di , speed FROM messages WHERE scevtime >{0} and scevtime <{1} ORDER by scevtime", scevtimemin, scevtimemax), conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - if ((dr.GetDouble(2)!=0)&&(dr.GetDouble(3)!=0)) - ret.Add(new PositionData(dr.GetDouble(2), dr.GetDouble(3), "", dr.GetInt32(0), car_state_e.CAR_RUNNING, dr.GetInt32(5))); + while (dr.Read()) + { + if ((dr.GetDouble(2) != 0) && (dr.GetDouble(3) != 0)) + ret.Add(new PositionData(dr.GetDouble(2), dr.GetDouble(3), "", dr.GetInt32(0), car_state_e.CAR_RUNNING, dr.GetInt32(5))); + } } - dr.Close(); } - conn.Close(); } return ret; } @@ -2516,38 +2510,41 @@ namespace Safedispatch_4_0 + " LEFT JOIN zonepoints as znpnt ON (zn.idx = znpnt.zone_id) " + " ORDER by zn.name,znpnt.idx", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - if (OldGrpId != dr.GetInt32(0)) + while (dr.Read()) { - if (first) first = false; - else + if (OldGrpId != dr.GetInt32(0)) { - ZoneClass g = new ZoneClass(oldZone, OldGrpId,arr); - try + if (first) first = false; + else { - GroupList.Add(OldGrpId, g); + ZoneClass g = new ZoneClass(oldZone, OldGrpId, arr); + try + { + if (!GroupList.ContainsKey(OldGrpId)) + GroupList.Add(OldGrpId, g); + } + catch (Exception ex) { SM.Debug("Unable to add Group" + ex.ToString()); } } - catch (Exception ex) { SM.Debug("Unable to add Group" + ex.ToString()); } - } - OldGrpId = dr.GetInt32(0); - SpeedValue = dr.GetInt32(17); - if (MainForm2.isInMile) SpeedValue = (Int32)Math.Round(SpeedValue * 0.621371); - oldZone = new ZoneClass(dr.GetString(1), dr.GetInt32(5), dr.GetInt32(6), dr.GetInt32(7), dr.GetBoolean(8), dr.GetString(9), dr.GetString(10), dr.GetBoolean(11), dr.GetString(12), dr.GetString(13), dr.GetString(14), dr.GetBoolean(15), dr.GetString(16),SpeedValue,dr.GetBoolean(18), dr.GetInt16(19)); - arr = new ArrayList(); - } - if (!dr.IsDBNull(2)) - arr.Add(new PointonZone(dr.GetDouble(2),dr.GetDouble(3),dr.GetInt32(4))); + + OldGrpId = dr.GetInt32(0); + SpeedValue = dr.GetInt32(17); + if (MainForm2.isInMile) SpeedValue = (Int32)Math.Round(SpeedValue * 0.621371); + oldZone = new ZoneClass(dr.GetString(1), dr.GetInt32(5), dr.GetInt32(6), dr.GetInt32(7), dr.GetBoolean(8), dr.GetString(9), dr.GetString(10), dr.GetBoolean(11), dr.GetString(12), dr.GetString(13), dr.GetString(14), dr.GetBoolean(15), dr.GetString(16), SpeedValue, dr.GetBoolean(18), dr.GetInt16(19)); + arr = new ArrayList(); + } + if (!dr.IsDBNull(2)) + arr.Add(new PointonZone(dr.GetDouble(2), dr.GetDouble(3), dr.GetInt32(4))); + } } - dr.Close(); + if (OldGrpId != 0) { - ZoneClass g1 = new ZoneClass(oldZone, OldGrpId, arr); - GroupList.Add(OldGrpId, g1); + if (!GroupList.ContainsKey(OldGrpId)) + GroupList.Add(OldGrpId, new ZoneClass(oldZone, OldGrpId, arr)); } } - conn.Close(); } return GroupList; } @@ -2971,23 +2968,23 @@ namespace Safedispatch_4_0 query = string.Format("select mess,timeGMT,sc_id_sour,status,email,idx, color FROM sms {0} ORDER BY timeGMT desc", glwhere); using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - SMSfromDB sms = new SMSfromDB(dr.GetInt32(2), dr.GetInt32(1), dr.GetString(0), dr.GetInt32(3), dr.GetInt32(5), dr.GetString(4)); + while (dr.Read()) + { + SMSfromDB sms = new SMSfromDB(dr.GetInt32(2), dr.GetInt32(1), dr.GetString(0), dr.GetInt32(3), dr.GetInt32(5), dr.GetString(4)); - sms.color = (dr.IsDBNull(6) ? System.Drawing.ColorTranslator.FromHtml("#FFFFFF") - : System.Drawing.ColorTranslator.FromHtml(dr.GetString(6))); + sms.color = (dr.IsDBNull(6) ? System.Drawing.ColorTranslator.FromHtml("#FFFFFF") + : System.Drawing.ColorTranslator.FromHtml(dr.GetString(6))); - // set scheduled time for those who are scheduled - if (!inbox && !dr.IsDBNull(7) && dr.GetInt32(7) > 0) - sms.date = dr.GetInt32(7); + // set scheduled time for those who are scheduled + if (!inbox && !dr.IsDBNull(7) && dr.GetInt32(7) > 0) + sms.date = dr.GetInt32(7); - ret.Add(sms); + ret.Add(sms); + } } - dr.Close(); } - conn.Close(); } return ret; } @@ -3002,15 +2999,15 @@ namespace Safedispatch_4_0 if (inbox) query = string.Format("select mess,timeGMT,sc_id_sour,status,email,idx FROM sms {0} ORDER BY timeGMT desc LIMIT 2000 OFFSET {1}", glwhere,page_number*2000); using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - SMSfromDB sms = new SMSfromDB(dr.GetInt32(2), dr.GetInt32(1), dr.GetString(0), dr.GetInt32(3), dr.GetInt32(5), dr.GetString(4)); - ret.Add(sms); + while (dr.Read()) + { + SMSfromDB sms = new SMSfromDB(dr.GetInt32(2), dr.GetInt32(1), dr.GetString(0), dr.GetInt32(3), dr.GetInt32(5), dr.GetString(4)); + ret.Add(sms); + } } - dr.Close(); } - conn.Close(); } return ret; } @@ -3023,15 +3020,15 @@ namespace Safedispatch_4_0 conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand("select mess,timeGMT,sc_id_sour,sc_id_dest, status,email,idx FROM sms Where deleted=1 ORDER BY timeGMT desc", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) - { - SMSfromDB sms = new SMSfromDB(dr.GetInt32(2),dr.GetInt32(3), dr.GetInt32(1), dr.GetString(0), dr.GetInt32(4), dr.GetInt32(6), dr.GetString(5)); - ret.Add(sms); + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + while (dr.Read()) + { + SMSfromDB sms = new SMSfromDB(dr.GetInt32(2), dr.GetInt32(3), dr.GetInt32(1), dr.GetString(0), dr.GetInt32(4), dr.GetInt32(6), dr.GetString(5)); + ret.Add(sms); + } } - dr.Close(); } - conn.Close(); } return ret; } @@ -3041,9 +3038,8 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE FROM place where idx={0}", p_idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM place WHERE idx={p_idx}", conn)) + { cmd.ExecuteNonQuery(); } } } @@ -3052,11 +3048,11 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE FROM zonename where idx={0}", p_idx), conn)) - cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE FROM zonepoints where zone_id={0}", p_idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM zonename WHERE idx = {p_idx}", conn)) + { cmd.ExecuteNonQuery(); } + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM zonepoints WHERE zone_id = {p_idx}", conn)) + { cmd.ExecuteNonQuery(); } } } @@ -3065,9 +3061,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE FROM geozoneinout where idx={0} and type=1", p_idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM geozoneinout WHERE idx={p_idx} and type=1", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -3076,9 +3072,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE FROM reports where geofence_id={0} and type_stat=1", p_idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM reports WHERE geofence_id = {p_idx} and type_stat = 1", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -3087,9 +3083,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE FROM defineSMS where sms='{0}'",sms), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM defineSMS WHERE sms = '{sms}'", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -3098,9 +3094,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 where type=6", conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id = 0 WHERE type = 6", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -3111,19 +3107,19 @@ namespace Safedispatch_4_0 conn.Open(); if (isZone) { - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE geozoneinout SET preview=1 where type=1", conn)) - cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 where type=2", conn)) - cmd.ExecuteNonQuery(); + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE geozoneinout SET preview=1 WHERE type=1", conn)) + { cmd.ExecuteNonQuery(); } + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 WHERE type=2", conn)) + { cmd.ExecuteNonQuery(); } } else { - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE geozoneinout SET preview=1 where type=2", conn)) - cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 where type=3", conn)) - cmd.ExecuteNonQuery(); + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE geozoneinout SET preview=1 WHERE type=2", conn)) + { cmd.ExecuteNonQuery(); } + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 WHERE type=3", conn)) + { cmd.ExecuteNonQuery(); } } - conn.Close(); + } } @@ -3133,10 +3129,14 @@ namespace Safedispatch_4_0 { conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE speedalarm SET preview=1", conn)) + { cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 where type=4", conn)) + } + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 WHERE type=4", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } + } } @@ -3145,11 +3145,16 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd =new NpgsqlCommand("UPDATE emergalarm SET preview=1", conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE emergalarm SET preview=1", conn)) + { cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 where type=5", conn)) + } + + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 WHERE type=5", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } + } } @@ -3159,10 +3164,14 @@ namespace Safedispatch_4_0 { conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE emergalarm SET preview=1", conn)) + { cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 where type=1", conn)) + } + + using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE alarm SET sc_id=0 WHERE type=1", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } } } @@ -3195,28 +3204,29 @@ namespace Safedispatch_4_0 public String get_address_one_connection(Double LAT,Double LNG) { String ret = ""; - Int32 nrofErrors =0; - while (nrofErrors<2) + Int32 nrofErrors = 0; + while (nrofErrors < 2) { try { - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = connAddress; - cmd.CommandText = "SELECT address from address where LAT=@lat1 and LNG=@lng1"; - cmd.Parameters.Add("@lat1", NpgsqlTypes.NpgsqlDbType.Double).Value = LAT; - cmd.Parameters.Add("@lng1", NpgsqlTypes.NpgsqlDbType.Double).Value = LNG; - cmd.Prepare(); - NpgsqlDataReader dr = cmd.ExecuteReader(); - if (dr.Read()) + using (NpgsqlCommand cmd = new NpgsqlCommand()) { - ret = dr.GetString(0); + cmd.Connection = connAddress; + cmd.CommandText = "SELECT address FROM address WHERE LAT=@lat1 and LNG=@lng1"; + cmd.Parameters.Add("@lat1", NpgsqlTypes.NpgsqlDbType.Double).Value = LAT; + cmd.Parameters.Add("@lng1", NpgsqlTypes.NpgsqlDbType.Double).Value = LNG; + cmd.Prepare(); + + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + if (dr.Read()) + { + ret = dr.GetString(0); + } + } + + break; } - try - { - dr.Close(); - } - catch (Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } - nrofErrors=3; } catch (Exception ex) { @@ -3236,20 +3246,24 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - NpgsqlCommand cmd = new NpgsqlCommand(); - cmd.Connection = conn; - cmd.CommandText = "SELECT address from address where LAT=@lat1 and LNG=@lng1"; - cmd.Parameters.Add("@lat1", NpgsqlTypes.NpgsqlDbType.Double).Value = LAT; - cmd.Parameters.Add("@lng1", NpgsqlTypes.NpgsqlDbType.Double).Value = LNG; - cmd.Prepare(); - NpgsqlDataReader dr = cmd.ExecuteReader(); - if (dr.Read()) + using (NpgsqlCommand cmd = new NpgsqlCommand()) { - ret = dr.GetString(0); + cmd.Connection = conn; + cmd.CommandText = "SELECT address FROM address WHERE LAT=@lat1 and LNG=@lng1"; + cmd.Parameters.Add("@lat1", NpgsqlTypes.NpgsqlDbType.Double).Value = LAT; + cmd.Parameters.Add("@lng1", NpgsqlTypes.NpgsqlDbType.Double).Value = LNG; + cmd.Prepare(); + + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + if (dr.Read()) + { + ret = dr.GetString(0); + } + } } - dr.Close(); - conn.Close(); } + return ret; } @@ -3259,22 +3273,22 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT name, note, lat, lng, address, type_id,useridx from place where idx={0} order by name", id.ToString()), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT name, note, lat, lng, address, type_id,useridx FROM place WHERE idx={id} ORDER BY name", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - if (dr.Read()) - { - ret.Add(dr.GetString(0)); - ret.Add(dr.GetString(1)); - ret.Add(dr.GetDouble(2)); - ret.Add(dr.GetDouble(3)); - ret.Add(dr.GetString(4)); - ret.Add(dr.GetInt32(5)); - ret.Add(dr.GetInt32(6)); + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + if (dr.Read()) + { + ret.Add(dr.GetString(0)); + ret.Add(dr.GetString(1)); + ret.Add(dr.GetDouble(2)); + ret.Add(dr.GetDouble(3)); + ret.Add(dr.GetString(4)); + ret.Add(dr.GetInt32(5)); + ret.Add(dr.GetInt32(6)); + } } - dr.Close(); } - conn.Close(); } return ret; } @@ -3284,10 +3298,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE messages SET di=128 where timeGMT>{0} and timeGMT<{1}", timeGMT, timeGMT2), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE messages SET di=128 WHERE timeGMT>{timeGMT} and timeGMT<{timeGMT2}", conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -3302,32 +3315,8 @@ namespace Safedispatch_4_0 conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT address,lat,lng from address where lat>{0} and lat<{1} and lng>{2} and lng<{3} and type=2", (double)(lat - 0.5), (double)(lat + 0.5), (double)(lng - 0.5), (double)(lng + 0.5)), conn)) { - drSafe = cmd.ExecuteReader(); - while (drSafe.Read()) + using (drSafe = cmd.ExecuteReader()) { - addrTmpSafe = drSafe.GetString(0); - latTmpSafe = drSafe.GetDouble(1); - lngTmpSafe = drSafe.GetDouble(2); - newMinSafe = System.Math.Abs(latTmpSafe - lat) + System.Math.Abs(lngTmpSafe - lng); - if (newMinSafe < mindistSafe) - { - Retur = addrTmpSafe; - mindistSafe = newMinSafe; - } - } - drSafe.Close(); - } - conn.Close(); - } - - if (Retur.CompareTo("") == 0) - { - using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) - { - conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT address,lat,lng from address where lat>{0} and lat<{1} and lng>{2} and lng<{3} and (type=1 or type=3)", (double)(lat - 0.0007), (double)(lat + 0.0007), (double)(lng - 0.0007), (double)(lng + 0.0007)), conn)) - { - drSafe = cmd.ExecuteReader(); while (drSafe.Read()) { addrTmpSafe = drSafe.GetString(0); @@ -3340,9 +3329,34 @@ namespace Safedispatch_4_0 mindistSafe = newMinSafe; } } - drSafe.Close(); } - conn.Close(); + + } + } + + if (Retur.CompareTo("") == 0) + { + using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) + { + conn.Open(); + using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT address,lat,lng from address where lat>{0} and lat<{1} and lng>{2} and lng<{3} and (type=1 or type=3)", (double)(lat - 0.0007), (double)(lat + 0.0007), (double)(lng - 0.0007), (double)(lng + 0.0007)), conn)) + { + using (drSafe = cmd.ExecuteReader()) + { + while (drSafe.Read()) + { + addrTmpSafe = drSafe.GetString(0); + latTmpSafe = drSafe.GetDouble(1); + lngTmpSafe = drSafe.GetDouble(2); + newMinSafe = System.Math.Abs(latTmpSafe - lat) + System.Math.Abs(lngTmpSafe - lng); + if (newMinSafe < mindistSafe) + { + Retur = addrTmpSafe; + mindistSafe = newMinSafe; + } + } + } + } } } @@ -3493,13 +3507,15 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT userID from users where login='{0}'",userLog), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT userID from users WHERE login='{userLog}'", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - if (dr.Read()) tmp = dr.GetInt32(0); - dr.Close(); + using (NpgsqlDataReader dr = cmd.ExecuteReader()) + { + if (dr.Read()) + tmp = dr.GetInt32(0); + } } - conn.Close(); + } return tmp; } @@ -3518,16 +3534,17 @@ namespace Safedispatch_4_0 conn.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("SELECT userID, login from users"), conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - // add the dispatcher name into the hash - dispatchers.Add(dr.GetInt32(0), dr.GetString(1)); + while (dr.Read()) + { + // add the dispatcher name into the hash + dispatchers.Add(dr.GetInt32(0), dr.GetString(1)); + } } - dr.Close(); } - conn.Close(); } + return dispatchers; } @@ -3596,7 +3613,7 @@ namespace Safedispatch_4_0 MainForm2.htGroupsKeyNAmeValueID.Add(OldGroupNAme, OldGrpId); } } - conn.Close(); + } return GroupList; } @@ -3607,12 +3624,11 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT ison FROM users where userid="+UserIdx, conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT ison FROM users WHERE userid={UserIdx}", conn)) { Int32 temp = Convert.ToInt32((object)cmd.ExecuteScalar()); if (temp == 1) ret = true; } - conn.Close(); } return ret; } @@ -3623,16 +3639,17 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(String.Format("SELECT dev_name FROM soundcards where user_id={0} and rad_disp_id={1} ORDER by type", MainForm2.userIDX, ID), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"SELECT dev_name FROM soundcards WHERE user_id={MainForm2.userIDX} AND rad_disp_id={ID} ORDER by type", conn)) { - NpgsqlDataReader dr = cmd.ExecuteReader(); - while (dr.Read()) + using (NpgsqlDataReader dr = cmd.ExecuteReader()) { - ret.Add(dr.GetString(0)); + while (dr.Read()) + { + ret.Add(dr.GetString(0)); + } } - dr.Close(); } - conn.Close(); + } return ret; } @@ -3642,12 +3659,12 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - Int32 Intstate = 0; - if (state) Intstate = 1; - using (NpgsqlCommand cmd = new NpgsqlCommand( - string.Format("update users set ison={0} where userid={1}", Intstate,UserIdx), conn)) + + Int32 Intstate = (state) ? 1:0; + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE users set ison = {Intstate} WHERE userid = {UserIdx}", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } } } @@ -3656,15 +3673,16 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("DELETE from soundcards where user_id='{0}' and rad_disp_id={1}", MainForm2.userIDX, ID), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE from soundcards WHERE user_id = '{MainForm2.userIDX}' and rad_disp_id = {ID}", conn)) cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("INSERT INTO soundcards (user_id,rad_disp_id,type,dev_name) VALUES({0},{1},{2},'{3}')", MainForm2.userIDX, ID, 0,OUTName), conn)) + + using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("INSERT INTO soundcards (user_id,rad_disp_id,type,dev_name) VALUES({0},{1},{2},'{3}')", MainForm2.userIDX, ID, 0, OUTName), conn)) cmd.ExecuteNonQuery(); using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("INSERT INTO soundcards (user_id,rad_disp_id,type,dev_name) VALUES({0},{1},{2},'{3}')", MainForm2.userIDX, ID, 1, INName), conn)) cmd.ExecuteNonQuery(); using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("INSERT INTO soundcards (user_id,rad_disp_id,type,dev_name) VALUES({0},{1},{2},'{3}')", MainForm2.userIDX, ID, 2, KeyName), conn)) cmd.ExecuteNonQuery(); - conn.Close(); + } } @@ -3673,13 +3691,14 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand( - string.Format("Delete from vehicle_group where sc_id={0}", sc_id), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM vehicle_group WHERE sc_id={sc_id}", conn)) + { cmd.ExecuteNonQuery(); - using (NpgsqlCommand cmd = new NpgsqlCommand( - string.Format("INSERT INTO vehicle_group (sc_id,grp_ip) VALUES ({0},{1})", sc_id, groupID), conn)) + } + using (NpgsqlCommand cmd = new NpgsqlCommand($"INSERT INTO vehicle_group (sc_id,grp_ip) VALUES ({sc_id},{groupID})", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } } } @@ -3713,24 +3732,21 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand( - string.Format("Delete from vehicle_group where sc_id={0}", sc_id), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM vehicle_group WHERE sc_id = {sc_id}", conn)) + { cmd.ExecuteNonQuery(); } } } public void Send_cmd_to_val(Boolean TypeDO, String IMEI, String command) { - Int32 typcmd = 0; // POLL command - if (TypeDO) typcmd = 1; //DO set command + Int32 typcmd = (TypeDO) ? 1: 0; // DO set command : POLL command using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = new NpgsqlCommand( - string.Format("INSERT INTO sendtoval (type,imei,cmd,status) VALUES({0},'{1}','{2}',0)", typcmd, IMEI,command), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"INSERT INTO sendtoval (type,imei,cmd,status) VALUES({typcmd},'{IMEI}','{command}',0)", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } } } @@ -3739,10 +3755,10 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE sms SET status={0} where idx={1}",status,idx), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE sms SET status = {status} WHERE idx = {idx}", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } } } @@ -3752,10 +3768,10 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE sms SET deleted=0 where idx={0}", idx), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE sms SET deleted = 0 WHERE idx = {idx}", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } } } @@ -3764,10 +3780,9 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("UPDATE sms SET deleted=1 where idx={0}", idx), conn)) - cmd.ExecuteNonQuery(); - conn.Close(); + using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format("UPDATE sms SET deleted=1 WHERE idx={0}", idx), conn)) + { cmd.ExecuteNonQuery(); } + } } @@ -3776,13 +3791,13 @@ namespace Safedispatch_4_0 using (NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString)) { conn.Open(); - for (int i = 0; i < smsIDX_list.Length; i++) + + string ids = string.Join(",", smsIDX_list.Select(x => $"{x}")); + using (NpgsqlCommand cmd = new NpgsqlCommand($"DELETE FROM sms WHERE idx IN ({ids})", conn)) { - using (NpgsqlCommand cmd = - new NpgsqlCommand(string.Format("Delete from sms where idx={0}", smsIDX_list[i]), conn)) - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); } - conn.Close(); + } } @@ -3792,10 +3807,11 @@ namespace Safedispatch_4_0 { String hex = "#" + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2"); conn.Open(); - using (NpgsqlCommand cmd = - new NpgsqlCommand(String.Format("UPDATE sms SET color='{0}' where idx={1}", hex, idx), conn)) + using (NpgsqlCommand cmd = new NpgsqlCommand($"UPDATE sms SET color = '{hex}' WHERE idx = {idx}", conn)) + { cmd.ExecuteNonQuery(); - conn.Close(); + } + } } @@ -3813,7 +3829,7 @@ namespace Safedispatch_4_0 { ret = Convert.ToInt32((object)cmd.ExecuteScalar()); } - conn.Close(); + } return ret; diff --git a/Safedispatch_4_0/config.ini b/Safedispatch_4_0/config.ini index 4b59394..4bc8ac0 100644 --- a/Safedispatch_4_0/config.ini +++ b/Safedispatch_4_0/config.ini @@ -1,5 +1,5 @@ [Server] -IP = 127.0.0.1 +IP = 10.120.1.149 ;localIP= [Google] diff --git a/Safedispatch_4_0/maptab/HistoryTab.cs b/Safedispatch_4_0/maptab/HistoryTab.cs index 4cd4eef..2c92db8 100644 --- a/Safedispatch_4_0/maptab/HistoryTab.cs +++ b/Safedispatch_4_0/maptab/HistoryTab.cs @@ -16,6 +16,7 @@ using SafeMobileLib; using System.IO; using Dispatcher.maptab.UIClasses; using Dispatcher.maptab; +using System.Linq; namespace Safedispatch_4_0 { @@ -64,20 +65,13 @@ namespace Safedispatch_4_0 //rdpEndTime.Culture = MainForm2.culture; //rdpStartTime.Culture = MainForm2.culture; + + string startTimeCustomFormat = MainForm2.DayFirst ? "dd/MM/yyyy hh:mm tt" : "MM/dd/yyyy hh:mm tt"; + if (MainForm2.is24hours) - { - if (MainForm2.DayFirst) - rdpStartTime.CustomFormat = "dd/MM/yyyy HH:mm"; - else - rdpStartTime.CustomFormat = "MM/dd/yyyy HH:mm"; - } - else - { - if (MainForm2.DayFirst) - rdpStartTime.CustomFormat = "dd/MM/yyyy hh:mm tt"; - else - rdpStartTime.CustomFormat = "MM/dd/yyyy hh:mm tt"; - } + startTimeCustomFormat = MainForm2.DayFirst ? "dd/MM/yyyy HH:mm" : "MM/dd/yyyy HH:mm"; + + rdpStartTime.CustomFormat = startTimeCustomFormat; // copy format to the end date picker rdpEndTime.CustomFormat = rdpStartTime.CustomFormat; @@ -241,20 +235,12 @@ namespace Safedispatch_4_0 // rcbComputeAddress.Checked = true; //else rcbComputeAddress.Checked = false; + string startTimeCustomFormat = MainForm2.DayFirst ? "dd/MM/yyyy hh:mm tt" : "MM/dd/yyyy hh:mm tt"; + if (MainForm2.is24hours) - { - if (MainForm2.DayFirst) - rdpStartTime.CustomFormat = "dd/MM/yyyy HH:mm"; - else - rdpStartTime.CustomFormat = "MM/dd/yyyy HH:mm"; - } - else - { - if (MainForm2.DayFirst) - rdpStartTime.CustomFormat = "dd/MM/yyyy hh:mm tt"; - else - rdpStartTime.CustomFormat = "MM/dd/yyyy hh:mm tt"; - } + startTimeCustomFormat = MainForm2.DayFirst ? "dd/MM/yyyy HH:mm" : "MM/dd/yyyy HH:mm"; + + rdpStartTime.CustomFormat = startTimeCustomFormat; rdpEndTime.CustomFormat = rdpStartTime.CustomFormat; // set history time format HistoryGridCellElement.timeFormat = rdpStartTime.CustomFormat; @@ -433,12 +419,12 @@ namespace Safedispatch_4_0 for (int i = 0; i < e.MenuItems.Count; i++) { RadMenuItemBase menuItem = e.MenuItems[i]; - if (menuItem.Name == "CloseWindow" || - menuItem.Name == "CloseAllButThis" || - menuItem.Name == "CloseAll" || - menuItem.Name == "Floating" || - menuItem.Name == "Docked" || - menuItem.Name == "Hidden" || + if (menuItem.Name.Equals("CloseWindow") || + menuItem.Name.Equals("CloseAllButThis") || + menuItem.Name.Equals("CloseAll") || + menuItem.Name.Equals("Floating") || + menuItem.Name.Equals("Docked") || + menuItem.Name.Equals("Hidden") || menuItem is RadMenuSeparatorItem) { menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; @@ -1207,52 +1193,23 @@ namespace Safedispatch_4_0 FirstGoogle = true; SMposition tmpos = (SMposition)Point_for_play[0]; - if (MainForm2.isInMile) volSpeedString = Convert.ToString((int)Math.Round(tmpos.m_speed * 0.621371192)); - else volSpeedString = Convert.ToString((int)(tmpos.m_speed)); - + worker.ReportProgress(3); - vehSelect = tmpos.m_vehName - + "_" + tmpos.m_posID; + updatecomand = FormatUpdateCommand(tmpos, FirstGoogle); - if (FirstGoogle) - { - updatecomand = "setDataset,heading_positions," + MainForm2.FixDoubleLAT(tmpos.m_lat.ToString()) - + "," + MainForm2.FixDoubleLNG(tmpos.m_lng.ToString()) - + "," + (tmpos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString("yyyy-MM-dd HH:mm:ss") - + "," + tmpos.m_vehName + "_" + tmpos.m_posID - + "," + volSpeedString + (MainForm2.isInMile ? "mph" : "kph") - + "," + tmpos.m_alt - + "," + MainForm2.FixComma(tmpos.m_address) + "," - + "history/" + GetSymbName(busSymb.GetSymbolFromOrientation(tmpos.m_heading)) + "," - + "false" + "," + "false" + "," + "false"; - - latitude = tmpos.m_lat; - longitude = tmpos.m_lng; + latitude = tmpos.m_lat; + longitude = tmpos.m_lng; + if (FirstGoogle) + { + Thread.Sleep(2000); FirstGoogle = false; - worker.ReportProgress(1,tmpos.m_evnt_id); - Thread.Sleep(2000); - } - else - { - updatecomand = "updateDataset,heading_positions," - + MainForm2.FixDoubleLAT(tmpos.m_lat.ToString()) - + "," + MainForm2.FixDoubleLNG(tmpos.m_lng.ToString()) - + "," + (tmpos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString("yyyy-MM-dd HH:mm:ss") - + "," + tmpos.m_vehName + "_" + tmpos.m_posID - + "," + volSpeedString + (MainForm2.isInMile ? "mph" : "kph") - + "," + tmpos.m_alt - + "," + MainForm2.FixComma(tmpos.m_address) + "," - + "history/" + GetSymbName(busSymb.GetSymbolFromOrientation(tmpos.m_heading)) + "," - + "false" + "," + "false" + "," + "false"; + } - latitude = tmpos.m_lat; - longitude = tmpos.m_lng; - - worker.ReportProgress(1,tmpos.m_evnt_id); - } + worker.ReportProgress(1, tmpos.m_evnt_id); Index_to_play++; + }// end if prev state is STOP try @@ -1260,37 +1217,27 @@ namespace Safedispatch_4_0 while ((Index_to_play < Point_for_play.Count) && (ePlayStatus == PS.PLAY)) { tempPos = ((SMposition)Point_for_play[Index_to_play]); - if (MainForm2.isInMile) volSpeedString = Convert.ToString((int)Math.Round(tempPos.m_speed * 0.621371192)); - else volSpeedString = Convert.ToString((int)(tempPos.m_speed)); + + // convert to km + volSpeedString = ConvertToKm(tempPos); + Index_to_play++; + if (ePlayStatus == PS.PLAY) { - vehSelect = tempPos.m_vehName + "_" + tempPos.m_posID; - if (FirstGoogle) - { - updatecomand = "setDataset,heading_positions"; - FirstGoogle = false; - } - else updatecomand = "updateDataset,heading_positions"; - //updatecomand = updatecomand + "," + MainForm2.FixDoubleLAT(tempPos.m_lat.ToString()) + "," + MainForm2.FixDoubleLNG(tempPos.m_lng.ToString()) + "," + vehSelect + "," + note + "," + GetSymbName(busSymb.GetSymbolFromOrientation(tempPos.m_heading)); + + updatecomand = FormatUpdateCommand(tempPos, FirstGoogle); + FirstGoogle = false; latitude = tempPos.m_lat; longitude = tempPos.m_lng; - - updatecomand = updatecomand + "," + MainForm2.FixDoubleLAT(tempPos.m_lat.ToString()) - + "," + MainForm2.FixDoubleLNG(tempPos.m_lng.ToString()) - + "," + (tempPos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString("yyyy-MM-dd HH:mm:ss") - + "," + tempPos.m_vehName + "_" + tempPos.m_posID - + "," + volSpeedString + (MainForm2.isInMile ? "mph" : "kph") - + "," + tempPos.m_alt - + "," + MainForm2.FixComma(tempPos.m_address) + "," - + "history/" + GetSymbName(busSymb.GetSymbolFromOrientation(tempPos.m_heading)) + "," - + "false" + "," + "false" + "," + "false"; + worker.ReportProgress(1,tempPos.m_evnt_id); } else - break; + break; + Thread.Sleep(10); if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) @@ -1375,25 +1322,13 @@ namespace Safedispatch_4_0 } tempPos = (SMposition)Point_for_play[Index_to_play]; - if (MainForm2.isInMile) volSpeedString = Convert.ToString((int)Math.Round(tempPos.m_speed * 0.621371192)); - else volSpeedString = Convert.ToString((int)(tempPos.m_speed)); - vehSelect = tempPos.m_vehName + "_" + tempPos.m_posID.ToString(); if (onthelimit) worker.ReportProgress(2, tempPos.m_evnt_id); else { - //String note = createnote(tempPos); - //updatecomand = "updateDataset,heading_positions," + MainForm2.FixDoubleLAT(tempPos.m_lat.ToString()) + "," + MainForm2.FixDoubleLNG(tempPos.m_lng.ToString()) + "," + vehSelect + "," + note + "," + GetSymbName(busSymb.GetSymbolFromOrientation(tempPos.m_heading)); - updatecomand = "updateDataset,heading_positions," + MainForm2.FixDoubleLAT(tempPos.m_lat.ToString()) - + "," + MainForm2.FixDoubleLNG(tempPos.m_lng.ToString()) - + "," + (tempPos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString("yyyy-MM-dd HH:mm:ss") - + "," + tempPos.m_vehName + "_" + tempPos.m_posID - + "," + volSpeedString + (MainForm2.isInMile ? "mph" : "kph") - + "," + tempPos.m_alt - + "," + MainForm2.FixComma(tempPos.m_address) + "," - + "history/" + GetSymbName(busSymb.GetSymbolFromOrientation(tempPos.m_heading)) + "," - + "false" + "," + "false" + "," + "false"; + + updatecomand = FormatUpdateCommand(tempPos, false); worker.ReportProgress(1, tempPos.m_evnt_id); } } @@ -1415,6 +1350,41 @@ namespace Safedispatch_4_0 return 0; } + + private string FormatUpdateCommand(SMposition tempPos, bool firstGoogle) + { + + // Convert To Km + string volSpeedString = ConvertToKm(tempPos); + string vehSelect = $"{tempPos.m_vehName}_{tempPos.m_posID}"; + + string command = firstGoogle ? "setDataset" : "updateDataset"; + + string updateComand = $"{command},heading_positions" + + "," + MainForm2.FixDoubleLAT(tempPos.m_lat.ToString()) + + "," + MainForm2.FixDoubleLNG(tempPos.m_lng.ToString()) + + "," + (tempPos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString("yyyy-MM-dd HH:mm:ss") + + "," + tempPos.m_vehName + "_" + tempPos.m_posID + + "," + volSpeedString + (MainForm2.isInMile ? "mph" : "kph") + + "," + tempPos.m_alt + + "," + MainForm2.FixComma(tempPos.m_address) + "," + + "history/" + GetSymbName(busSymb.GetSymbolFromOrientation(tempPos.m_heading)) + "," + + "false" + "," + "false" + "," + "false"; + + + return updateComand; + } + + + private string ConvertToKm(SMposition obj) + { + + if (MainForm2.isInMile) + return Convert.ToString((int)Math.Round(obj.m_speed * 0.621371192)); + + return Convert.ToString((int)(obj.m_speed)); + } + // Mihai private bool changeTrackbarValueFromCode = false; /// @@ -1468,12 +1438,14 @@ namespace Safedispatch_4_0 { hitLimit = false; string proc1 = MainForm2.returnLNGString("Update"), - proc2 = MainForm2.returnLNGString("Retriev"), - proc3 = MainForm2.returnLNGString("Computing"), - proc4 = MainForm2.returnLNGString("DelOld"); + proc2 = MainForm2.returnLNGString("Retriev"), + proc3 = MainForm2.returnLNGString("Computing"), + proc4 = MainForm2.returnLNGString("DelOld"); txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateStatusBar),proc4); + Thread.Sleep(5000); + Pushpinx pp1 = null; Locationx[] posTemp = null; Shapex shp = null; @@ -1483,6 +1455,7 @@ namespace Safedispatch_4_0 String SpeedData = "mile"; String AddressData = ""; IdReportHS.Clear(); + if (closeTabThread) { e.Cancel = true; @@ -1570,6 +1543,7 @@ namespace Safedispatch_4_0 List_of_Name_for_History.Add(unit.Text); int contRoute = -1; Int32 number = 0; + ArrayList POSList = new ArrayList(); SM.Debug("value for name:" + unit.Text); if (DataPos[unit.Text] != null) @@ -1628,6 +1602,7 @@ namespace Safedispatch_4_0 //note if (MainForm2.isInMile) SpeedData = " ;" + MainForm2.langSpeed + " " + Convert.ToString((int)Math.Round(obj3.m_speed * 0.621371192)) + MainForm2.milesh; else SpeedData = " ;" + MainForm2.langSpeed + " " + Convert.ToString(obj3.m_speed) + MainForm2.kmh; + if ((obj3.m_address != "") && (obj3.m_address != " ")) { try @@ -1641,6 +1616,7 @@ namespace Safedispatch_4_0 } } else AddressData = ""; + pp1.Note = MainForm2.langTime + " " + obj3.m_time.DateTimeOfDayHHMMLocal() + SpeedData + AddressData; pp1.BalloonState = GeoBalloonStatex.geoDisplayNone; if (closeTabThread) @@ -1648,11 +1624,13 @@ namespace Safedispatch_4_0 e.Cancel = true; return 1; } + // pp1.MoveTo(vehiclesDataSet2); progStep++; if (minTime > obj3.m_time) minTime = obj3.m_time; + if (maxTime < obj3.m_time) maxTime = obj3.m_time; } @@ -1668,6 +1646,7 @@ namespace Safedispatch_4_0 latlnt.Add(pos[k].Latitude); latlnt.Add(pos[k].Longitude); } + if (posTemp.Length > 1) { if (closeTabThread) return 1; @@ -1744,14 +1723,19 @@ namespace Safedispatch_4_0 foreach (SMposition obj in selectedPositions) { contx++; - if (MainForm2.isInMile) volSpeedString = Convert.ToString((int)Math.Round(obj.m_speed * 0.621371192)); - else volSpeedString = Convert.ToString((int)(obj.m_speed)); + // convert to km + volSpeedString = ConvertToKm(obj); + volAddress = obj.m_address; - if ((volAddress == "") || (volAddress == " ")) volAddress = "LAT:" + Math.Round(obj.m_lat, 5).ToString() + " , LNG:" + Math.Round(obj.m_lng, 5).ToString(); + if ((volAddress == "") || (volAddress == " ")) + volAddress = "LAT:" + Math.Round(obj.m_lat, 5).ToString() + " , LNG:" + Math.Round(obj.m_lng, 5).ToString(); + ListforGrid.Add(new DataforGRID(contx.ToString(), obj.m_vehName, (obj.m_time).ConvertGMTToLocal().GetDTFromSeconds(), volAddress, volSpeedString, "", "", Math.Round(obj.m_lat, 5).ToString(), Math.Round(obj.m_lng, 5).ToString(), Math.Round(obj.m_alt, 5).ToString(),obj.m_heading)); + obj.m_evnt_id = contx; - SliderPosition.Add(SliderCount); + SliderPosition.Add(SliderCount); + if ((obj.m_lat != 0) && (obj.m_lng != 0)) { Point_for_play.Add(obj); @@ -1797,8 +1781,8 @@ namespace Safedispatch_4_0 { if (docLoad) { - mapGoogles.ExecuteScript("window.GWTcallback('" + obj + "');"); - mapGoogles.ExecuteScript("window.GWTcallback('removelabels," + ((String [])obj.Split(','))[4] + "');"); + ExecuteScript(obj); + ExecuteScript($"removelabels,{((String [])obj.Split(",".ToCharArray()))[4]}"); } } //end history @@ -1818,9 +1802,10 @@ namespace Safedispatch_4_0 + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ",,,,,,false,false,false"; - mapGoogles.ExecuteScript("window.GWTcallback('" + corner + "');"); - mapGoogles.ExecuteScript("window.GWTcallback('" + "putOnMap,once,corner_positions" + "');"); - mapGoogles.ExecuteScript("window.GWTcallback('" + "removelabels,corner_positions" + "');"); + ExecuteScript(corner); + ExecuteScript("putOnMap,once,corner_positions"); + ExecuteScript("removelabels,corner_positions"); + /* SM.Debug("Face ZOOM pe un dataset"); if (vehiclesDataSet2.RecordCount > 0) vehiclesDataSet2.ZoomTo();*/ @@ -1882,7 +1867,9 @@ namespace Safedispatch_4_0 } if (MainForm2.Connfailed) { - if ((MainForm2.radioType == RADIOTYPE.HARRIS)||(MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + if ((MainForm2.radioType == RADIOTYPE.HARRIS)||(MainForm2.radioType == RADIOTYPE.ATLAS)) + ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + RadMessageBox.Show(MainForm2.returnLNGString("database"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Exclamation); MainForm2.Connfailed = false; } @@ -1892,6 +1879,8 @@ namespace Safedispatch_4_0 { backgroundWorker1.RunWorkerAsync(); VisualSettings.loadUserVisualSettings(this.Name, this.toolWindow4, MainForm2.HashVal); + + // convert in km if (MainForm2.isInMile) { rseSpeedLower.Value = (int)Math.Round(Convert.ToInt32(rseSpeedLower.Value) * 0.621371192); @@ -1922,7 +1911,7 @@ namespace Safedispatch_4_0 try { if (e.ProgressPercentage == 3) - mapGoogles.ExecuteScript("window.GWTcallback('" + "removeDataset,heading_positions" + "');"); + ExecuteScript("removeDataset,heading_positions"); else { Int32 index = (Int32)e.UserState; @@ -1936,18 +1925,21 @@ namespace Safedispatch_4_0 } if (e.ProgressPercentage == 1) { - //Utils.WriteLine("Yellow: " + updatecomand, ConsoleColor.Yellow); - mapGoogles.ExecuteScript("window.GWTcallback('" + updatecomand + "');"); + + ExecuteScript(updatecomand); if (updatecomand.StartsWith("setDataset,heading_positions")) { if (rcbShowLabels.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) - mapGoogles.ExecuteScript("window.GWTcallback('" + "putlabels,heading_positions" + "');"); - else mapControl.mapGoogles.ExecuteScript("window.GWTcallback('" + "removelabels,heading_positions" + "');"); + ExecuteScript("putlabels,heading_positions"); + else + mapControl.mapGoogles.ExecuteScript("window.GWTcallback('" + "removelabels,heading_positions" + "');"); } - mapGoogles.ExecuteScript("window.GWTcallback('" + "putOnMap,none,heading_positions" + "');"); + ExecuteScript("putOnMap,none,heading_positions"); } - mapGoogles.ExecuteScript("window.GWTcallback('" + "openInfo," + vehSelect + "');"); - mapGoogles?.ExecuteScript($"window.GWTcallback('centerzoom,{latitude},{longitude},-1');"); + + ExecuteScript($"openInfo,{vehSelect}"); + ExecuteScript($"centerzoom,{latitude},{longitude},-1"); + } } catch (Exception ex) @@ -1958,7 +1950,10 @@ namespace Safedispatch_4_0 } - + private void ExecuteScript(string command) + { + mapGoogles?.ExecuteScript($"window.GWTcallback('{command}');"); + } @@ -2087,7 +2082,9 @@ namespace Safedispatch_4_0 { if (FirstGoogle) { - mapGoogles.ExecuteScript("window.GWTcallback('removeDataset,heading_positions');"); + + ExecuteScript("removeDataset,heading_positions"); + updatecomand = "setDataset,heading_positions,"; FirstGoogle = false; @@ -2106,11 +2103,15 @@ namespace Safedispatch_4_0 Utils.WriteLine(updatecomand,ConsoleColor.Blue); if (docLoad) { - mapGoogles.ExecuteScript("window.GWTcallback('" + updatecomand + "');"); + + ExecuteScript(updatecomand); + if (PutonMap) - mapGoogles.ExecuteScript("window.GWTcallback('" + "putOnMap,none,heading_positions" + "');"); - mapGoogles.ExecuteScript("window.GWTcallback('" + "openInfo," + gridData.VehName + "_" + gridData.Id + "');"); - mapGoogles?.ExecuteScript($"window.GWTcallback('centerzoom,{gridData.Lat},{gridData.Lng},-1');"); + ExecuteScript("putOnMap,none,heading_positions"); + + ExecuteScript($"openInfo,{gridData.VehName}_{gridData.Id}"); + ExecuteScript($"centerzoom,{gridData.Lat},{gridData.Lng},-1"); + } } @@ -2125,7 +2126,7 @@ namespace Safedispatch_4_0 { if (docLoad) { - mapGoogles.ExecuteScript("window.GWTcallback('" + "openInfo," + pp.Name + "');"); + ExecuteScript($"openInfo,{pp.Name}"); } } @@ -2163,6 +2164,7 @@ namespace Safedispatch_4_0 { tmpAddrAndID.LNG = Math.Round(tmpAddrAndID.LNG, 4); tmpAddrAndID.LAT = Math.Round(tmpAddrAndID.LAT, 4); + valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; if (MainForm2.AddrHass[valHash] != null) { @@ -2184,6 +2186,7 @@ namespace Safedispatch_4_0 { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } + if (!findaddress) { tmpAddrAndID.Address = volltmpGo2.getAddressLATLNG(tmpAddrAndID.LAT, tmpAddrAndID.LNG); @@ -2211,41 +2214,43 @@ namespace Safedispatch_4_0 IdReportHS[tmpAddrAndID.ID.ToString()] = tmpAddrAndID.Address; if (inwhile) HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); + SM.Debug("Baga google in hash ID:" + tmpAddrAndID.ID.ToString() + "Addr:" + tmpAddrAndID.Address); } - else - { - //dau in open street maps si apoi ies prin prin cene - Thread.Sleep(1100); - tmpAddrAndID.Address = volltmpGo2.getAddressLATLNG2(tmpAddrAndID.LAT, tmpAddrAndID.LNG); - if ((tmpAddrAndID.Address != "") && (tmpAddrAndID.Address != " ")) - { - if (!findaddress) - { - try - { - if (tmpAddrAndID.Address != "N/A") - { - valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; - MainForm2.AddrHass.Add(valHash, tmpAddrAndID.Address); - AddrtmpX = smdbObj.get_address(tmpAddrAndID.LAT, tmpAddrAndID.LNG); //just for avoid Error from Event Viewer - if (AddrtmpX == "") smdbObj.Insert_Address(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); - } - } - catch (Exception ex) - { - SM.Debug("Error: " + ex.ToString()); - } - } - IdReportHS[tmpAddrAndID.ID.ToString()] = tmpAddrAndID.Address; - if (inwhile) HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); - SM.Debug("Baga open street maps in hash ID:"+tmpAddrAndID.ID.ToString() + "Addr:" + tmpAddrAndID.Address); - } - else - { - SM.Debug("Iese prin Cene cu nimic"); - } - } + //else + //{ + // //dau in open street maps si apoi ies prin prin cene + // Thread.Sleep(1100); + // tmpAddrAndID.Address = volltmpGo2.getAddressLATLNG2(tmpAddrAndID.LAT, tmpAddrAndID.LNG); + // if ((tmpAddrAndID.Address != "") && (tmpAddrAndID.Address != " ")) + // { + // if (!findaddress) + // { + // try + // { + // if (tmpAddrAndID.Address != "N/A") + // { + // valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; + // MainForm2.AddrHass.Add(valHash, tmpAddrAndID.Address); + // AddrtmpX = smdbObj.get_address(tmpAddrAndID.LAT, tmpAddrAndID.LNG); //just for avoid Error from Event Viewer + // if (AddrtmpX == "") smdbObj.Insert_Address(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); + // } + // } + // catch (Exception ex) + // { + // SM.Debug("Error: " + ex.ToString()); + // } + // } + + // IdReportHS[tmpAddrAndID.ID.ToString()] = tmpAddrAndID.Address; + // if (inwhile) HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); + // SM.Debug("Baga open street maps in hash ID:"+tmpAddrAndID.ID.ToString() + "Addr:" + tmpAddrAndID.Address); + // } + // else + // { + // SM.Debug("Iese prin Cene cu nimic"); + // } + //} } } catch (Exception ex) @@ -2332,10 +2337,10 @@ namespace Safedispatch_4_0 { try { - int cont = 0; if (docLoad) { - mapGoogles.ExecuteScript("window.GWTcallback('" + "deletePolygon,ALL');"); + + ExecuteScript("deletePolygon,ALL"); nrNavigatecnt++; } @@ -2387,7 +2392,8 @@ namespace Safedispatch_4_0 { if (docLoad) { - mapGoogles.ExecuteScript("window.GWTcallback('" + "deletePolygon,ALL');"); + + ExecuteScript("deletePolygon,ALL"); nrNavigatecnt++; } } @@ -2473,6 +2479,7 @@ namespace Safedispatch_4_0 /// private void speedLimit_CheckStateChanged(object sender, EventArgs e) { + if ((RadCheckBox)sender == rcbSpeedLower) rseSpeedLower.Enabled = ((RadCheckBox)sender).Checked; else if ((RadCheckBox)sender == rcbSpeedUpper) @@ -2700,26 +2707,22 @@ namespace Safedispatch_4_0 private void timeTrackBar_ValueChanged(object sender, EventArgs e) { Utils.WriteLine(timeTrackBar.Value.ToString(), ConsoleColor.Yellow); + if (changeTrackbarValueFromCode) { changeTrackbarValueFromCode = false; return; } + try { SMposition tmpos = (SMposition)Point_for_play[(Int32)timeTrackBar.Value]; - if (MainForm2.isInMile) volSpeedString = Convert.ToString((int)Math.Round(tmpos.m_speed * 0.621371192)); - else volSpeedString = Convert.ToString((int)(tmpos.m_speed)); - Index_to_play = (Int32)timeTrackBar.Value; - vehSelect = tmpos.m_vehName + "_" + tmpos.m_posID; - if (FirstGoogle) - { - mapGoogles.ExecuteScript("window.GWTcallback('removeDataset,heading_positions');"); - updatecomand = "setDataset,heading_positions"; + Index_to_play = (Int32)timeTrackBar.Value; + + updatecomand = FormatUpdateCommand(tmpos, FirstGoogle); + if (FirstGoogle) FirstGoogle = false; - } - else updatecomand = "updateDataset,heading_positions"; Int32 index = tmpos.m_evnt_id; if ((index >= 0) && (index < gridHistoryPoints.RowCount)) @@ -2728,21 +2731,15 @@ namespace Safedispatch_4_0 gridHistoryPoints.Rows[index].IsSelected = true; gridHistoryPoints.Rows[index].IsCurrent = true; } - updatecomand = updatecomand + "," - + MainForm2.FixDoubleLAT(tmpos.m_lat.ToString()) + "," - + MainForm2.FixDoubleLNG(tmpos.m_lng.ToString()) + "," - + (tmpos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString("yyyy-MM-dd HH:mm:ss") + "," - + vehSelect + "," - + volSpeedString + (MainForm2.isInMile ? "mph" : "kph") + "," + - + tmpos.m_alt + "," - + MainForm2.FixComma(tmpos.m_address) + "," - + "history/" + GetSymbName(busSymb.GetSymbolFromOrientation(tmpos.m_heading)) + "," - + "false" + "," + "false" + "," + "false"; - //Utils.WriteLine("Green: "+updatecomand,ConsoleColor.Green); - mapGoogles.ExecuteScript("window.GWTcallback('" + updatecomand + "');"); - mapGoogles.ExecuteScript("window.GWTcallback('" + "putOnMap,none,heading_positions" + "');"); - mapGoogles.ExecuteScript("window.GWTcallback('" + "openInfo," + vehSelect + "');"); - mapGoogles?.ExecuteScript($"window.GWTcallback('centerzoom,{tmpos.m_lat},{tmpos.m_lng},-1');"); + + + updatecomand = FormatUpdateCommand(tmpos, FirstGoogle); + + ExecuteScript(updatecomand); + ExecuteScript("putOnMap,none,heading_positions"); + ExecuteScript($"openInfo,{vehSelect}"); + ExecuteScript($"centerzoom,{tmpos.m_lat},{tmpos.m_lng},-1"); + } catch (Exception ex) { @@ -2760,7 +2757,7 @@ namespace Safedispatch_4_0 // remove old dataset points if (docLoad) { - mapGoogles.ExecuteScript("window.GWTcallback('" + "reset" + "');"); + ExecuteScript("reset"); } MaxLAT = -90; @@ -2770,11 +2767,10 @@ namespace Safedispatch_4_0 Index_to_play = 0; FirstGoogle = true; selectedPositions.Clear(); - if (gridHistoryPoints.Rows.Count > 0) - { - gridHistoryPoints.Rows.Clear(); - } + if (gridHistoryPoints.Rows.Count > 0) + gridHistoryPoints.Rows.Clear(); + gridHistoryPoints.DataSource = null; @@ -2782,6 +2778,8 @@ namespace Safedispatch_4_0 foreach (RadTreeNode node in treeViewUnits.Nodes) node.Checked = false; + + // clear speed values rseSpeedLower.Value = 0; rseSpeedUpper.Value = 0; @@ -2826,9 +2824,13 @@ namespace Safedispatch_4_0 try { if (rcbShowLabels.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) - mapGoogles.ExecuteScript("window.GWTcallback('" + "putlabels,heading_positions"+ "');"); - else mapGoogles.ExecuteScript("window.GWTcallback('" + "removelabels,heading_positions" + "');"); + + ExecuteScript("putlabels, heading_positions"); + else + ExecuteScript("removelabels, heading_positions"); + Thread.Sleep(1); + checkbox_UpdateHT(sender, args); } catch (Exception ex) @@ -2848,6 +2850,7 @@ namespace Safedispatch_4_0 if (rcbShowGeofence.Checked) ForceShowZone(); else ForceHideZone(); + checkbox_UpdateHT(sender, args); } catch (Exception ex) @@ -2862,10 +2865,8 @@ namespace Safedispatch_4_0 ///
private void rbtAnimation_EnabledChanged(object sender, EventArgs e) { - if(((RadButton)sender).Enabled) - ((RadButton)sender).ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; - else - ((RadButton)sender).ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColorDisabled; + Color bkColor = ((RadButton)sender).Enabled ? MainForm2.ButtonColor : MainForm2.ButtonColorDisabled; + ((RadButton)sender).ButtonElement.ButtonFillElement.BackColor = bkColor; } @@ -2954,17 +2955,27 @@ namespace Safedispatch_4_0 { if (isLoaded) { - int value = Convert.ToInt32(((RadSpinEditor)sender).Value); - if (((RadSpinEditor)sender).Name == "rseSpeedLower" || ((RadSpinEditor)sender).Name == "rseSpeedUpper") + + RadSpinEditor spinEditor = sender as RadSpinEditor; + + int value = Convert.ToInt32(spinEditor.Value); + if (spinEditor.Name.Equals("rseSpeedLower") || spinEditor.Name.Equals("rseSpeedUpper")) { if (MainForm2.isInMile) value = (int)(value * 1.60934); } - VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadSpinEditor)sender).Name, value.ToString()); - if (((RadSpinEditor)sender).Name == "rsePositionDisplay") - VisualSettings.InsertUpdateHTforVisualItems("hisPlayTime", value.ToString()); - if (((RadSpinEditor)sender).Name == "rseSkipSeconds") - VisualSettings.InsertUpdateHTforVisualItems("hisPauseTime", value.ToString()); + VisualSettings.InsertUpdateHTforVisualItems(this.Name, spinEditor.Name, value.ToString()); + + string spinEditorName = string.Empty; + + if (spinEditor.Name.Equals("rsePositionDisplay")) + spinEditorName = "hisPlayTime"; + else if (spinEditor.Name.Equals("rseSkipSeconds")) + spinEditorName = "hisPauseTime"; + + if(!string.IsNullOrEmpty(spinEditorName)) + VisualSettings.InsertUpdateHTforVisualItems(spinEditorName, value.ToString()); + } } /// diff --git a/Safedispatch_4_0/maptab/HistoryTab.designer.cs b/Safedispatch_4_0/maptab/HistoryTab.designer.cs index 22e92d9..03ea5f7 100644 --- a/Safedispatch_4_0/maptab/HistoryTab.designer.cs +++ b/Safedispatch_4_0/maptab/HistoryTab.designer.cs @@ -41,7 +41,7 @@ namespace Safedispatch_4_0 private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - Telerik.WinControls.UI.TableViewDefinition tableViewDefinition6 = new Telerik.WinControls.UI.TableViewDefinition(); + Telerik.WinControls.UI.TableViewDefinition tableViewDefinition1 = new Telerik.WinControls.UI.TableViewDefinition(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoryTab)); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.textBox3 = new Telerik.WinControls.UI.RadTextBox(); @@ -60,24 +60,6 @@ namespace Safedispatch_4_0 this.GoogleClick = new System.Windows.Forms.Timer(this.components); this.StartBasicHistory = new System.Windows.Forms.Timer(this.components); this.radDock1 = new Telerik.WinControls.UI.Docking.RadDock(); - this.windowHistoryResult = new Telerik.WinControls.UI.Docking.ToolWindow(); - this.panelAnimationButtons = new Telerik.WinControls.UI.RadPanel(); - this.rbPrev = new Telerik.WinControls.UI.RadButton(); - this.rbNext = new Telerik.WinControls.UI.RadButton(); - this.rbStop = new Telerik.WinControls.UI.RadButton(); - this.rbPause = new Telerik.WinControls.UI.RadButton(); - this.rbPlay = new Telerik.WinControls.UI.RadButton(); - this.gridHistoryPoints = new Telerik.WinControls.UI.RadGridView(); - this.timeTrackBar = new Telerik.WinControls.UI.RadTrackBar(); - this.rsePositionDisplay = new Telerik.WinControls.UI.RadSpinEditor(); - this.rseSkipSeconds = new Telerik.WinControls.UI.RadSpinEditor(); - this.radLabel10 = new Telerik.WinControls.UI.RadLabel(); - this.labelSlideshow = new Telerik.WinControls.UI.RadLabel(); - this.rcbShowLabels = new Telerik.WinControls.UI.RadCheckBox(); - this.rcbShowGeofence = new Telerik.WinControls.UI.RadCheckBox(); - this.rlPositionDisplayMs = new Telerik.WinControls.UI.RadLabel(); - this.rlAnimation = new Telerik.WinControls.UI.RadLabel(); - this.toolTabStripTabs = new Telerik.WinControls.UI.Docking.ToolTabStrip(); this.toolWindow4 = new Telerik.WinControls.UI.Docking.ToolWindow(); this.pbFilter = new System.Windows.Forms.PictureBox(); this.rbResetHistory = new Telerik.WinControls.UI.RadButton(); @@ -97,6 +79,24 @@ namespace Safedispatch_4_0 this.treeViewUnits = new Telerik.WinControls.UI.RadTreeView(); this.rlHistoryForSelectedUnits = new Telerik.WinControls.UI.RadLabel(); this.labelUnits = new Telerik.WinControls.UI.RadLabel(); + this.toolTabStripTabs = new Telerik.WinControls.UI.Docking.ToolTabStrip(); + this.windowHistoryResult = new Telerik.WinControls.UI.Docking.ToolWindow(); + this.panelAnimationButtons = new Telerik.WinControls.UI.RadPanel(); + this.rbPrev = new Telerik.WinControls.UI.RadButton(); + this.rbNext = new Telerik.WinControls.UI.RadButton(); + this.rbStop = new Telerik.WinControls.UI.RadButton(); + this.rbPause = new Telerik.WinControls.UI.RadButton(); + this.rbPlay = new Telerik.WinControls.UI.RadButton(); + this.gridHistoryPoints = new Telerik.WinControls.UI.RadGridView(); + this.timeTrackBar = new Telerik.WinControls.UI.RadTrackBar(); + this.rsePositionDisplay = new Telerik.WinControls.UI.RadSpinEditor(); + this.rseSkipSeconds = new Telerik.WinControls.UI.RadSpinEditor(); + this.radLabel10 = new Telerik.WinControls.UI.RadLabel(); + this.labelSlideshow = new Telerik.WinControls.UI.RadLabel(); + this.rcbShowLabels = new Telerik.WinControls.UI.RadCheckBox(); + this.rcbShowGeofence = new Telerik.WinControls.UI.RadCheckBox(); + this.rlPositionDisplayMs = new Telerik.WinControls.UI.RadLabel(); + this.rlAnimation = new Telerik.WinControls.UI.RadLabel(); this.documentContainer1 = new Telerik.WinControls.UI.Docking.DocumentContainer(); this.documentTabStrip1 = new Telerik.WinControls.UI.Docking.DocumentTabStrip(); this.documentWindow1 = new Telerik.WinControls.UI.Docking.DocumentWindow(); @@ -126,27 +126,6 @@ namespace Safedispatch_4_0 ((System.ComponentModel.ISupportInitialize)(this.skinButton4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.radDock1)).BeginInit(); this.radDock1.SuspendLayout(); - this.windowHistoryResult.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.panelAnimationButtons)).BeginInit(); - this.panelAnimationButtons.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.rbPrev)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbNext)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbStop)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbPause)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbPlay)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints.MasterTemplate)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.timeTrackBar)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rsePositionDisplay)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rseSkipSeconds)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel10)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.labelSlideshow)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rcbShowLabels)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rcbShowGeofence)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rlPositionDisplayMs)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rlAnimation)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.toolTabStripTabs)).BeginInit(); - this.toolTabStripTabs.SuspendLayout(); this.toolWindow4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbFilter)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rbResetHistory)).BeginInit(); @@ -166,6 +145,27 @@ namespace Safedispatch_4_0 ((System.ComponentModel.ISupportInitialize)(this.treeViewUnits)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rlHistoryForSelectedUnits)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.labelUnits)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.toolTabStripTabs)).BeginInit(); + this.toolTabStripTabs.SuspendLayout(); + this.windowHistoryResult.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.panelAnimationButtons)).BeginInit(); + this.panelAnimationButtons.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.rbPrev)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbNext)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbStop)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbPause)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbPlay)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints.MasterTemplate)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.timeTrackBar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rsePositionDisplay)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rseSkipSeconds)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.radLabel10)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.labelSlideshow)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rcbShowLabels)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rcbShowGeofence)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rlPositionDisplayMs)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.rlAnimation)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.documentContainer1)).BeginInit(); this.documentContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.documentTabStrip1)).BeginInit(); @@ -311,7 +311,6 @@ namespace Safedispatch_4_0 this.radDock1.Location = new System.Drawing.Point(0, 0); this.radDock1.MainDocumentContainer = this.documentContainer1; this.radDock1.Name = "radDock1"; - this.radDock1.Padding = new System.Windows.Forms.Padding(0); // // // @@ -326,6 +325,381 @@ namespace Safedispatch_4_0 this.radDock1.ActiveWindowChanging += new Telerik.WinControls.UI.Docking.DockWindowCancelEventHandler(this.radDock1_ActiveWindowChanging); this.radDock1.ActiveWindowChanged += new Telerik.WinControls.UI.Docking.DockWindowEventHandler(this.radDock1_ActiveWindowChanged); // + // toolWindow4 + // + this.toolWindow4.BackColor = System.Drawing.Color.WhiteSmoke; + this.toolWindow4.Caption = null; + this.toolWindow4.Controls.Add(this.pbFilter); + this.toolWindow4.Controls.Add(this.rbResetHistory); + this.toolWindow4.Controls.Add(this.rbSearchHistory); + this.toolWindow4.Controls.Add(this.rcbComputeAddress); + this.toolWindow4.Controls.Add(this.rcbSpeedUpper); + this.toolWindow4.Controls.Add(this.rseSpeedUpper); + this.toolWindow4.Controls.Add(this.pb24H); + this.toolWindow4.Controls.Add(this.rcbSpeedLower); + this.toolWindow4.Controls.Add(this.rtbFilterUnits); + this.toolWindow4.Controls.Add(this.rseSpeedLower); + this.toolWindow4.Controls.Add(this.rdpEndTime); + this.toolWindow4.Controls.Add(this.rdpStartTime); + this.toolWindow4.Controls.Add(this.rcb24H); + this.toolWindow4.Controls.Add(this.rlUntil); + this.toolWindow4.Controls.Add(this.radLabel6); + this.toolWindow4.Controls.Add(this.treeViewUnits); + this.toolWindow4.Controls.Add(this.rlHistoryForSelectedUnits); + this.toolWindow4.Controls.Add(this.labelUnits); + this.toolWindow4.DocumentButtons = Telerik.WinControls.UI.Docking.DocumentStripButtons.None; + this.toolWindow4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.toolWindow4.Location = new System.Drawing.Point(1, 29); + this.toolWindow4.Name = "toolWindow4"; + this.toolWindow4.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; + this.toolWindow4.Size = new System.Drawing.Size(294, 762); + this.toolWindow4.Text = "History search parameters"; + this.toolWindow4.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None; + // + // pbFilter + // + this.pbFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.pbFilter.BackColor = System.Drawing.Color.White; + this.pbFilter.Image = global::Dispatcher.Properties.Resources.i_search; + this.pbFilter.Location = new System.Drawing.Point(259, 468); + this.pbFilter.Name = "pbFilter"; + this.pbFilter.Size = new System.Drawing.Size(21, 21); + this.pbFilter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pbFilter.TabIndex = 68; + this.pbFilter.TabStop = false; + this.pbFilter.Tag = "unselected"; + this.pbFilter.MouseEnter += new System.EventHandler(this.pbFilter_MouseEnter); + this.pbFilter.MouseLeave += new System.EventHandler(this.pbFilter_MouseLeave); + // + // rbResetHistory + // + this.rbResetHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rbResetHistory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + this.rbResetHistory.Cursor = System.Windows.Forms.Cursors.Hand; + this.rbResetHistory.Font = new System.Drawing.Font("Segoe UI", 10F); + this.rbResetHistory.Location = new System.Drawing.Point(18, 716); + this.rbResetHistory.Name = "rbResetHistory"; + this.rbResetHistory.Size = new System.Drawing.Size(91, 34); + this.rbResetHistory.TabIndex = 76; + this.rbResetHistory.Text = "Reset"; + this.rbResetHistory.ThemeName = "TelerikMetroBlue"; + this.rbResetHistory.Click += new System.EventHandler(this.rbResetHistory_Click); + ((Telerik.WinControls.UI.RadButtonElement)(this.rbResetHistory.GetChildAt(0))).Text = "Reset"; + ((Telerik.WinControls.Primitives.FillPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Bold); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; + ((Telerik.WinControls.Primitives.FocusPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; + // + // rbSearchHistory + // + this.rbSearchHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rbSearchHistory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + this.rbSearchHistory.Cursor = System.Windows.Forms.Cursors.Hand; + this.rbSearchHistory.Font = new System.Drawing.Font("Segoe UI", 10F); + this.rbSearchHistory.Location = new System.Drawing.Point(147, 716); + this.rbSearchHistory.Name = "rbSearchHistory"; + this.rbSearchHistory.Size = new System.Drawing.Size(136, 34); + this.rbSearchHistory.TabIndex = 75; + this.rbSearchHistory.Text = "Search History"; + this.rbSearchHistory.ThemeName = "TelerikMetroBlue"; + this.rbSearchHistory.Click += new System.EventHandler(this.btDisplayHeadingHisotry_Click); + ((Telerik.WinControls.UI.RadButtonElement)(this.rbSearchHistory.GetChildAt(0))).Text = "Search History"; + ((Telerik.WinControls.Primitives.FillPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; + ((Telerik.WinControls.Primitives.FocusPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; + // + // rcbComputeAddress + // + this.rcbComputeAddress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rcbComputeAddress.BackColor = System.Drawing.Color.Transparent; + this.rcbComputeAddress.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); + this.rcbComputeAddress.Location = new System.Drawing.Point(20, 679); + this.rcbComputeAddress.Name = "rcbComputeAddress"; + // + // + // + this.rcbComputeAddress.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; + this.rcbComputeAddress.Size = new System.Drawing.Size(119, 19); + this.rcbComputeAddress.TabIndex = 74; + this.rcbComputeAddress.Text = "Compute address"; + this.rcbComputeAddress.ThemeName = "TelerikMetroBlue"; + this.rcbComputeAddress.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.checkbox_UpdateHT); + // + // rcbSpeedUpper + // + this.rcbSpeedUpper.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rcbSpeedUpper.BackColor = System.Drawing.Color.Transparent; + this.rcbSpeedUpper.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); + this.rcbSpeedUpper.Location = new System.Drawing.Point(95, 643); + this.rcbSpeedUpper.Name = "rcbSpeedUpper"; + // + // + // + this.rcbSpeedUpper.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; + this.rcbSpeedUpper.Size = new System.Drawing.Size(160, 19); + this.rcbSpeedUpper.TabIndex = 73; + this.rcbSpeedUpper.Text = "Upper speed limit [km/h]"; + this.rcbSpeedUpper.ThemeName = "TelerikMetroBlue"; + this.rcbSpeedUpper.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.checkbox_UpdateHT); + this.rcbSpeedUpper.CheckStateChanged += new System.EventHandler(this.speedLimit_CheckStateChanged); + // + // rseSpeedUpper + // + this.rseSpeedUpper.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rseSpeedUpper.Enabled = false; + this.rseSpeedUpper.Location = new System.Drawing.Point(19, 640); + this.rseSpeedUpper.Maximum = new decimal(new int[] { + 350, + 0, + 0, + 0}); + this.rseSpeedUpper.Name = "rseSpeedUpper"; + this.rseSpeedUpper.Size = new System.Drawing.Size(72, 21); + this.rseSpeedUpper.TabIndex = 72; + this.rseSpeedUpper.TabStop = false; + this.rseSpeedUpper.TextAlignment = System.Windows.Forms.HorizontalAlignment.Right; + this.rseSpeedUpper.ThemeName = "Office2013Light"; + this.rseSpeedUpper.Value = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.rseSpeedUpper.ValueChanged += new System.EventHandler(this.rse_ValueChanged); + // + // pb24H + // + this.pb24H.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.pb24H.BackColor = System.Drawing.Color.Transparent; + this.pb24H.Cursor = System.Windows.Forms.Cursors.Hand; + this.pb24H.Image = global::Dispatcher.Properties.Resources.h_24h; + this.pb24H.Location = new System.Drawing.Point(247, 548); + this.pb24H.Name = "pb24H"; + this.pb24H.Size = new System.Drawing.Size(36, 36); + this.pb24H.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb24H.TabIndex = 71; + this.pb24H.TabStop = false; + this.pb24H.Tag = "selected"; + this.pb24H.Click += new System.EventHandler(this.pb24H_Click); + this.pb24H.MouseEnter += new System.EventHandler(this.pb24H_MouseEnter); + this.pb24H.MouseLeave += new System.EventHandler(this.pb24H_MouseLeave); + // + // rcbSpeedLower + // + this.rcbSpeedLower.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rcbSpeedLower.BackColor = System.Drawing.Color.Transparent; + this.rcbSpeedLower.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); + this.rcbSpeedLower.Location = new System.Drawing.Point(95, 618); + this.rcbSpeedLower.Name = "rcbSpeedLower"; + // + // + // + this.rcbSpeedLower.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; + this.rcbSpeedLower.Size = new System.Drawing.Size(159, 19); + this.rcbSpeedLower.TabIndex = 70; + this.rcbSpeedLower.Text = "Lower speed limit [km/h]"; + this.rcbSpeedLower.ThemeName = "TelerikMetroBlue"; + this.rcbSpeedLower.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.checkbox_UpdateHT); + this.rcbSpeedLower.CheckStateChanged += new System.EventHandler(this.speedLimit_CheckStateChanged); + // + // rtbFilterUnits + // + this.rtbFilterUnits.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rtbFilterUnits.Font = new System.Drawing.Font("Segoe UI", 10F); + this.rtbFilterUnits.Location = new System.Drawing.Point(16, 467); + this.rtbFilterUnits.MaxLength = 140; + this.rtbFilterUnits.Name = "rtbFilterUnits"; + this.rtbFilterUnits.NullText = "Type to search unit"; + this.rtbFilterUnits.Size = new System.Drawing.Size(262, 23); + this.rtbFilterUnits.TabIndex = 58; + this.rtbFilterUnits.ThemeName = "Office2013Dark"; + this.rtbFilterUnits.TextChanged += new System.EventHandler(this.rtbFilterUnits_TextChanged); + // + // rseSpeedLower + // + this.rseSpeedLower.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rseSpeedLower.Enabled = false; + this.rseSpeedLower.Location = new System.Drawing.Point(19, 615); + this.rseSpeedLower.Maximum = new decimal(new int[] { + 350, + 0, + 0, + 0}); + this.rseSpeedLower.Name = "rseSpeedLower"; + this.rseSpeedLower.Size = new System.Drawing.Size(72, 21); + this.rseSpeedLower.TabIndex = 69; + this.rseSpeedLower.TabStop = false; + this.rseSpeedLower.TextAlignment = System.Windows.Forms.HorizontalAlignment.Right; + this.rseSpeedLower.ThemeName = "Office2013Light"; + this.rseSpeedLower.ValueChanged += new System.EventHandler(this.rse_ValueChanged); + // + // rdpEndTime + // + this.rdpEndTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rdpEndTime.CustomFormat = "MM/dd/yyyy, HH:mm"; + this.rdpEndTime.Enabled = false; + this.rdpEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.rdpEndTime.Location = new System.Drawing.Point(18, 567); + this.rdpEndTime.MaxDate = new System.DateTime(2030, 12, 31, 0, 0, 0, 0); + this.rdpEndTime.MinDate = new System.DateTime(2010, 1, 1, 0, 0, 0, 0); + this.rdpEndTime.Name = "rdpEndTime"; + this.rdpEndTime.Size = new System.Drawing.Size(225, 21); + this.rdpEndTime.TabIndex = 64; + this.rdpEndTime.TabStop = false; + this.rdpEndTime.Text = "01/01/2010, 00:00"; + this.rdpEndTime.ThemeName = "Office2013Light"; + this.rdpEndTime.Value = new System.DateTime(2010, 1, 1, 0, 0, 0, 0); + // + // rdpStartTime + // + this.rdpStartTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rdpStartTime.CustomFormat = "MM/dd/yyyy, HH:mm"; + this.rdpStartTime.Enabled = false; + this.rdpStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.rdpStartTime.Location = new System.Drawing.Point(18, 542); + this.rdpStartTime.MaxDate = new System.DateTime(2030, 12, 31, 0, 0, 0, 0); + this.rdpStartTime.MinDate = new System.DateTime(2010, 1, 1, 0, 0, 0, 0); + this.rdpStartTime.Name = "rdpStartTime"; + this.rdpStartTime.NullText = "Display all"; + this.rdpStartTime.Size = new System.Drawing.Size(225, 21); + this.rdpStartTime.TabIndex = 63; + this.rdpStartTime.TabStop = false; + this.rdpStartTime.Text = "01/01/2015, 00:00"; + this.rdpStartTime.ThemeName = "Office2013Light"; + this.rdpStartTime.Value = new System.DateTime(2015, 1, 1, 0, 0, 0, 0); + // + // rcb24H + // + this.rcb24H.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rcb24H.AutoSize = false; + this.rcb24H.BackColor = System.Drawing.Color.Transparent; + this.rcb24H.CheckState = System.Windows.Forms.CheckState.Checked; + this.rcb24H.Enabled = false; + this.rcb24H.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); + this.rcb24H.Location = new System.Drawing.Point(253, 550); + this.rcb24H.Name = "rcb24H"; + // + // + // + this.rcb24H.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; + this.rcb24H.Size = new System.Drawing.Size(25, 37); + this.rcb24H.TabIndex = 67; + this.rcb24H.Text = "24"; + this.rcb24H.TextWrap = true; + this.rcb24H.ThemeName = "TelerikMetroBlue"; + this.rcb24H.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On; + // + // rlUntil + // + this.rlUntil.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rlUntil.AutoSize = false; + this.rlUntil.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.rlUntil.ForeColor = System.Drawing.Color.DarkGray; + this.rlUntil.Location = new System.Drawing.Point(134, 587); + this.rlUntil.Name = "rlUntil"; + this.rlUntil.Size = new System.Drawing.Size(109, 19); + this.rlUntil.TabIndex = 66; + this.rlUntil.Text = "History until"; + this.rlUntil.TextAlignment = System.Drawing.ContentAlignment.TopRight; + // + // radLabel6 + // + this.radLabel6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radLabel6.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.radLabel6.ForeColor = System.Drawing.Color.DarkGray; + this.radLabel6.Location = new System.Drawing.Point(16, 525); + this.radLabel6.Name = "radLabel6"; + this.radLabel6.Size = new System.Drawing.Size(81, 19); + this.radLabel6.TabIndex = 65; + this.radLabel6.Text = "History from"; + // + // treeViewUnits + // + this.treeViewUnits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.treeViewUnits.CheckBoxes = true; + this.treeViewUnits.Location = new System.Drawing.Point(16, 25); + this.treeViewUnits.Name = "treeViewUnits"; + this.treeViewUnits.Size = new System.Drawing.Size(265, 443); + this.treeViewUnits.SortOrder = System.Windows.Forms.SortOrder.Ascending; + this.treeViewUnits.SpacingBetweenNodes = -1; + this.treeViewUnits.TabIndex = 60; + this.treeViewUnits.Text = "radTreeView1"; + this.treeViewUnits.ThemeName = "TelerikMetroBlue"; + this.treeViewUnits.TriStateMode = true; + this.treeViewUnits.NodeFormatting += new Telerik.WinControls.UI.TreeNodeFormattingEventHandler(this.treeViewUnits_NodeFormatting); + this.treeViewUnits.CreateNodeElement += new Telerik.WinControls.UI.CreateTreeNodeElementEventHandler(this.treeViewUnits_CreateNodeElement); + // + // rlHistoryForSelectedUnits + // + this.rlHistoryForSelectedUnits.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.rlHistoryForSelectedUnits.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.rlHistoryForSelectedUnits.ForeColor = System.Drawing.Color.DarkGray; + this.rlHistoryForSelectedUnits.Location = new System.Drawing.Point(16, 490); + this.rlHistoryForSelectedUnits.Name = "rlHistoryForSelectedUnits"; + this.rlHistoryForSelectedUnits.Size = new System.Drawing.Size(152, 19); + this.rlHistoryForSelectedUnits.TabIndex = 61; + this.rlHistoryForSelectedUnits.Text = "History for selected units"; + // + // labelUnits + // + this.labelUnits.BackColor = System.Drawing.Color.WhiteSmoke; + this.labelUnits.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); + this.labelUnits.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + this.labelUnits.Location = new System.Drawing.Point(16, 5); + this.labelUnits.Name = "labelUnits"; + this.labelUnits.Size = new System.Drawing.Size(40, 21); + this.labelUnits.TabIndex = 77; + this.labelUnits.Text = "Units"; + // + // toolTabStripTabs + // + this.toolTabStripTabs.CanUpdateChildIndex = true; + this.toolTabStripTabs.CaptionVisible = false; + this.toolTabStripTabs.Controls.Add(this.toolWindow4); + this.toolTabStripTabs.Controls.Add(this.windowHistoryResult); + this.toolTabStripTabs.Location = new System.Drawing.Point(5, 5); + this.toolTabStripTabs.Name = "toolTabStripTabs"; + // + // + // + this.toolTabStripTabs.RootElement.MinSize = new System.Drawing.Size(25, 25); + this.toolTabStripTabs.SelectedIndex = 0; + this.toolTabStripTabs.Size = new System.Drawing.Size(296, 793); + this.toolTabStripTabs.SizeInfo.AbsoluteSize = new System.Drawing.Size(296, 200); + this.toolTabStripTabs.SizeInfo.SplitterCorrection = new System.Drawing.Size(110, 0); + this.toolTabStripTabs.TabIndex = 4; + this.toolTabStripTabs.TabStop = false; + this.toolTabStripTabs.TabStripAlignment = Telerik.WinControls.UI.TabStripAlignment.Top; + this.toolTabStripTabs.ThemeName = "TelerikMetroBlue"; + ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).Width = 0F; + ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).LeftWidth = 12F; + ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).TopWidth = 0F; + ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).RightWidth = 12F; + ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).BottomWidth = 0F; + ((Telerik.WinControls.UI.Docking.ToolWindowCaptionElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + ((Telerik.WinControls.UI.Docking.ToolWindowCaptionElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(0))).Visibility = Telerik.WinControls.ElementVisibility.Collapsed; + ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(0).GetChildAt(1))).SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; + ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).ItemContentOrientation = Telerik.WinControls.UI.PageViewContentOrientation.Horizontal; + ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderWidth = 0F; + ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderLeftWidth = 0F; + ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderTopWidth = 0F; + ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderRightWidth = 0F; + ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderBottomWidth = 0F; + ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).BorderWidth = 0F; + ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).BorderBottomWidth = 3F; + ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).BorderBottomColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).Margin = new System.Windows.Forms.Padding(0); + ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderWidth = 0F; + ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderLeftWidth = 0F; + ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderTopWidth = 0F; + ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderRightWidth = 0F; + ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderBottomWidth = 0F; + ((Telerik.WinControls.UI.StripViewButtonsPanel)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(1))).BorderBottomWidth = 2F; + // // windowHistoryResult // this.windowHistoryResult.BackColor = System.Drawing.Color.WhiteSmoke; @@ -499,7 +873,7 @@ namespace Safedispatch_4_0 this.gridHistoryPoints.MasterTemplate.EnableGrouping = false; this.gridHistoryPoints.MasterTemplate.ShowColumnHeaders = false; this.gridHistoryPoints.MasterTemplate.ShowRowHeaderColumn = false; - this.gridHistoryPoints.MasterTemplate.ViewDefinition = tableViewDefinition6; + this.gridHistoryPoints.MasterTemplate.ViewDefinition = tableViewDefinition1; this.gridHistoryPoints.Name = "gridHistoryPoints"; this.gridHistoryPoints.ShowGroupPanel = false; this.gridHistoryPoints.Size = new System.Drawing.Size(273, 489); @@ -664,381 +1038,6 @@ namespace Safedispatch_4_0 this.rlAnimation.TabIndex = 85; this.rlAnimation.Text = "Animation active for less than 100 positions"; // - // toolTabStripTabs - // - this.toolTabStripTabs.CanUpdateChildIndex = true; - this.toolTabStripTabs.CaptionVisible = false; - this.toolTabStripTabs.Controls.Add(this.toolWindow4); - this.toolTabStripTabs.Controls.Add(this.windowHistoryResult); - this.toolTabStripTabs.Location = new System.Drawing.Point(0, 0); - this.toolTabStripTabs.Name = "toolTabStripTabs"; - // - // - // - this.toolTabStripTabs.RootElement.MinSize = new System.Drawing.Size(25, 25); - this.toolTabStripTabs.SelectedIndex = 0; - this.toolTabStripTabs.Size = new System.Drawing.Size(296, 803); - this.toolTabStripTabs.SizeInfo.AbsoluteSize = new System.Drawing.Size(296, 200); - this.toolTabStripTabs.SizeInfo.SplitterCorrection = new System.Drawing.Size(110, 0); - this.toolTabStripTabs.TabIndex = 4; - this.toolTabStripTabs.TabStop = false; - this.toolTabStripTabs.TabStripAlignment = Telerik.WinControls.UI.TabStripAlignment.Top; - this.toolTabStripTabs.ThemeName = "TelerikMetroBlue"; - ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).Width = 0F; - ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).LeftWidth = 12F; - ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).TopWidth = 0F; - ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).RightWidth = 12F; - ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(1))).BottomWidth = 0F; - ((Telerik.WinControls.UI.Docking.ToolWindowCaptionElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - ((Telerik.WinControls.UI.Docking.ToolWindowCaptionElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(0))).Visibility = Telerik.WinControls.ElementVisibility.Collapsed; - ((Telerik.WinControls.Primitives.BorderPrimitive)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(0).GetChildAt(1))).SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; - ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).ItemContentOrientation = Telerik.WinControls.UI.PageViewContentOrientation.Horizontal; - ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderWidth = 0F; - ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderLeftWidth = 0F; - ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderTopWidth = 0F; - ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderRightWidth = 0F; - ((Telerik.WinControls.UI.RadPageViewTabStripElement)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1))).BorderBottomWidth = 0F; - ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).BorderWidth = 0F; - ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).BorderBottomWidth = 3F; - ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).BorderBottomColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - ((Telerik.WinControls.UI.StripViewItemContainer)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0))).Margin = new System.Windows.Forms.Padding(0); - ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderWidth = 0F; - ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderLeftWidth = 0F; - ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderTopWidth = 0F; - ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderRightWidth = 0F; - ((Telerik.WinControls.UI.StripViewItemLayout)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(0))).BorderBottomWidth = 0F; - ((Telerik.WinControls.UI.StripViewButtonsPanel)(this.toolTabStripTabs.GetChildAt(0).GetChildAt(2).GetChildAt(1).GetChildAt(0).GetChildAt(1))).BorderBottomWidth = 2F; - // - // toolWindow4 - // - this.toolWindow4.BackColor = System.Drawing.Color.WhiteSmoke; - this.toolWindow4.Caption = null; - this.toolWindow4.Controls.Add(this.pbFilter); - this.toolWindow4.Controls.Add(this.rbResetHistory); - this.toolWindow4.Controls.Add(this.rbSearchHistory); - this.toolWindow4.Controls.Add(this.rcbComputeAddress); - this.toolWindow4.Controls.Add(this.rcbSpeedUpper); - this.toolWindow4.Controls.Add(this.rseSpeedUpper); - this.toolWindow4.Controls.Add(this.pb24H); - this.toolWindow4.Controls.Add(this.rcbSpeedLower); - this.toolWindow4.Controls.Add(this.rtbFilterUnits); - this.toolWindow4.Controls.Add(this.rseSpeedLower); - this.toolWindow4.Controls.Add(this.rdpEndTime); - this.toolWindow4.Controls.Add(this.rdpStartTime); - this.toolWindow4.Controls.Add(this.rcb24H); - this.toolWindow4.Controls.Add(this.rlUntil); - this.toolWindow4.Controls.Add(this.radLabel6); - this.toolWindow4.Controls.Add(this.treeViewUnits); - this.toolWindow4.Controls.Add(this.rlHistoryForSelectedUnits); - this.toolWindow4.Controls.Add(this.labelUnits); - this.toolWindow4.DocumentButtons = Telerik.WinControls.UI.Docking.DocumentStripButtons.None; - this.toolWindow4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.toolWindow4.Location = new System.Drawing.Point(1, 29); - this.toolWindow4.Name = "toolWindow4"; - this.toolWindow4.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.toolWindow4.Size = new System.Drawing.Size(294, 772); - this.toolWindow4.Text = "History search parameters"; - this.toolWindow4.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None; - // - // pbFilter - // - this.pbFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.pbFilter.BackColor = System.Drawing.Color.White; - this.pbFilter.Image = global::Dispatcher.Properties.Resources.i_search; - this.pbFilter.Location = new System.Drawing.Point(259, 478); - this.pbFilter.Name = "pbFilter"; - this.pbFilter.Size = new System.Drawing.Size(21, 21); - this.pbFilter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pbFilter.TabIndex = 68; - this.pbFilter.TabStop = false; - this.pbFilter.Tag = "unselected"; - this.pbFilter.MouseEnter += new System.EventHandler(this.pbFilter_MouseEnter); - this.pbFilter.MouseLeave += new System.EventHandler(this.pbFilter_MouseLeave); - // - // rbResetHistory - // - this.rbResetHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rbResetHistory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - this.rbResetHistory.Cursor = System.Windows.Forms.Cursors.Hand; - this.rbResetHistory.Font = new System.Drawing.Font("Segoe UI", 10F); - this.rbResetHistory.Location = new System.Drawing.Point(18, 726); - this.rbResetHistory.Name = "rbResetHistory"; - this.rbResetHistory.Size = new System.Drawing.Size(91, 34); - this.rbResetHistory.TabIndex = 76; - this.rbResetHistory.Text = "Reset"; - this.rbResetHistory.ThemeName = "TelerikMetroBlue"; - this.rbResetHistory.Click += new System.EventHandler(this.rbResetHistory_Click); - ((Telerik.WinControls.UI.RadButtonElement)(this.rbResetHistory.GetChildAt(0))).Text = "Reset"; - ((Telerik.WinControls.Primitives.FillPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Bold); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; - ((Telerik.WinControls.Primitives.FocusPrimitive)(this.rbResetHistory.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; - // - // rbSearchHistory - // - this.rbSearchHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rbSearchHistory.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - this.rbSearchHistory.Cursor = System.Windows.Forms.Cursors.Hand; - this.rbSearchHistory.Font = new System.Drawing.Font("Segoe UI", 10F); - this.rbSearchHistory.Location = new System.Drawing.Point(147, 726); - this.rbSearchHistory.Name = "rbSearchHistory"; - this.rbSearchHistory.Size = new System.Drawing.Size(136, 34); - this.rbSearchHistory.TabIndex = 75; - this.rbSearchHistory.Text = "Search History"; - this.rbSearchHistory.ThemeName = "TelerikMetroBlue"; - this.rbSearchHistory.Click += new System.EventHandler(this.btDisplayHeadingHisotry_Click); - ((Telerik.WinControls.UI.RadButtonElement)(this.rbSearchHistory.GetChildAt(0))).Text = "Search History"; - ((Telerik.WinControls.Primitives.FillPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; - ((Telerik.WinControls.Primitives.FocusPrimitive)(this.rbSearchHistory.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; - // - // rcbComputeAddress - // - this.rcbComputeAddress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rcbComputeAddress.BackColor = System.Drawing.Color.Transparent; - this.rcbComputeAddress.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); - this.rcbComputeAddress.Location = new System.Drawing.Point(20, 689); - this.rcbComputeAddress.Name = "rcbComputeAddress"; - // - // - // - this.rcbComputeAddress.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; - this.rcbComputeAddress.Size = new System.Drawing.Size(119, 19); - this.rcbComputeAddress.TabIndex = 74; - this.rcbComputeAddress.Text = "Compute address"; - this.rcbComputeAddress.ThemeName = "TelerikMetroBlue"; - this.rcbComputeAddress.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.checkbox_UpdateHT); - // - // rcbSpeedUpper - // - this.rcbSpeedUpper.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rcbSpeedUpper.BackColor = System.Drawing.Color.Transparent; - this.rcbSpeedUpper.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); - this.rcbSpeedUpper.Location = new System.Drawing.Point(95, 653); - this.rcbSpeedUpper.Name = "rcbSpeedUpper"; - // - // - // - this.rcbSpeedUpper.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; - this.rcbSpeedUpper.Size = new System.Drawing.Size(160, 19); - this.rcbSpeedUpper.TabIndex = 73; - this.rcbSpeedUpper.Text = "Upper speed limit [km/h]"; - this.rcbSpeedUpper.ThemeName = "TelerikMetroBlue"; - this.rcbSpeedUpper.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.checkbox_UpdateHT); - this.rcbSpeedUpper.CheckStateChanged += new System.EventHandler(this.speedLimit_CheckStateChanged); - // - // rseSpeedUpper - // - this.rseSpeedUpper.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rseSpeedUpper.Enabled = false; - this.rseSpeedUpper.Location = new System.Drawing.Point(19, 650); - this.rseSpeedUpper.Maximum = new decimal(new int[] { - 350, - 0, - 0, - 0}); - this.rseSpeedUpper.Name = "rseSpeedUpper"; - this.rseSpeedUpper.Size = new System.Drawing.Size(72, 21); - this.rseSpeedUpper.TabIndex = 72; - this.rseSpeedUpper.TabStop = false; - this.rseSpeedUpper.TextAlignment = System.Windows.Forms.HorizontalAlignment.Right; - this.rseSpeedUpper.ThemeName = "Office2013Light"; - this.rseSpeedUpper.Value = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.rseSpeedUpper.ValueChanged += new System.EventHandler(this.rse_ValueChanged); - // - // pb24H - // - this.pb24H.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.pb24H.BackColor = System.Drawing.Color.Transparent; - this.pb24H.Cursor = System.Windows.Forms.Cursors.Hand; - this.pb24H.Image = global::Dispatcher.Properties.Resources.h_24h; - this.pb24H.Location = new System.Drawing.Point(247, 558); - this.pb24H.Name = "pb24H"; - this.pb24H.Size = new System.Drawing.Size(36, 36); - this.pb24H.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pb24H.TabIndex = 71; - this.pb24H.TabStop = false; - this.pb24H.Tag = "selected"; - this.pb24H.Click += new System.EventHandler(this.pb24H_Click); - this.pb24H.MouseEnter += new System.EventHandler(this.pb24H_MouseEnter); - this.pb24H.MouseLeave += new System.EventHandler(this.pb24H_MouseLeave); - // - // rcbSpeedLower - // - this.rcbSpeedLower.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rcbSpeedLower.BackColor = System.Drawing.Color.Transparent; - this.rcbSpeedLower.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); - this.rcbSpeedLower.Location = new System.Drawing.Point(95, 628); - this.rcbSpeedLower.Name = "rcbSpeedLower"; - // - // - // - this.rcbSpeedLower.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; - this.rcbSpeedLower.Size = new System.Drawing.Size(159, 19); - this.rcbSpeedLower.TabIndex = 70; - this.rcbSpeedLower.Text = "Lower speed limit [km/h]"; - this.rcbSpeedLower.ThemeName = "TelerikMetroBlue"; - this.rcbSpeedLower.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.checkbox_UpdateHT); - this.rcbSpeedLower.CheckStateChanged += new System.EventHandler(this.speedLimit_CheckStateChanged); - // - // rtbFilterUnits - // - this.rtbFilterUnits.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rtbFilterUnits.Font = new System.Drawing.Font("Segoe UI", 10F); - this.rtbFilterUnits.Location = new System.Drawing.Point(16, 477); - this.rtbFilterUnits.MaxLength = 140; - this.rtbFilterUnits.Name = "rtbFilterUnits"; - this.rtbFilterUnits.NullText = "Type to search unit"; - this.rtbFilterUnits.Size = new System.Drawing.Size(262, 23); - this.rtbFilterUnits.TabIndex = 58; - this.rtbFilterUnits.ThemeName = "Office2013Dark"; - this.rtbFilterUnits.TextChanged += new System.EventHandler(this.rtbFilterUnits_TextChanged); - // - // rseSpeedLower - // - this.rseSpeedLower.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rseSpeedLower.Enabled = false; - this.rseSpeedLower.Location = new System.Drawing.Point(19, 625); - this.rseSpeedLower.Maximum = new decimal(new int[] { - 350, - 0, - 0, - 0}); - this.rseSpeedLower.Name = "rseSpeedLower"; - this.rseSpeedLower.Size = new System.Drawing.Size(72, 21); - this.rseSpeedLower.TabIndex = 69; - this.rseSpeedLower.TabStop = false; - this.rseSpeedLower.TextAlignment = System.Windows.Forms.HorizontalAlignment.Right; - this.rseSpeedLower.ThemeName = "Office2013Light"; - this.rseSpeedLower.ValueChanged += new System.EventHandler(this.rse_ValueChanged); - // - // rdpEndTime - // - this.rdpEndTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rdpEndTime.CustomFormat = "MM/dd/yyyy, HH:mm"; - this.rdpEndTime.Enabled = false; - this.rdpEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.rdpEndTime.Location = new System.Drawing.Point(18, 577); - this.rdpEndTime.MaxDate = new System.DateTime(2030, 12, 31, 0, 0, 0, 0); - this.rdpEndTime.MinDate = new System.DateTime(2010, 1, 1, 0, 0, 0, 0); - this.rdpEndTime.Name = "rdpEndTime"; - this.rdpEndTime.Size = new System.Drawing.Size(225, 21); - this.rdpEndTime.TabIndex = 64; - this.rdpEndTime.TabStop = false; - this.rdpEndTime.Text = "01/01/2010, 00:00"; - this.rdpEndTime.ThemeName = "Office2013Light"; - this.rdpEndTime.Value = new System.DateTime(2010, 1, 1, 0, 0, 0, 0); - // - // rdpStartTime - // - this.rdpStartTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rdpStartTime.CustomFormat = "MM/dd/yyyy, HH:mm"; - this.rdpStartTime.Enabled = false; - this.rdpStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.rdpStartTime.Location = new System.Drawing.Point(18, 552); - this.rdpStartTime.MaxDate = new System.DateTime(2030, 12, 31, 0, 0, 0, 0); - this.rdpStartTime.MinDate = new System.DateTime(2010, 1, 1, 0, 0, 0, 0); - this.rdpStartTime.Name = "rdpStartTime"; - this.rdpStartTime.NullText = "Display all"; - this.rdpStartTime.Size = new System.Drawing.Size(225, 21); - this.rdpStartTime.TabIndex = 63; - this.rdpStartTime.TabStop = false; - this.rdpStartTime.Text = "01/01/2015, 00:00"; - this.rdpStartTime.ThemeName = "Office2013Light"; - this.rdpStartTime.Value = new System.DateTime(2015, 1, 1, 0, 0, 0, 0); - // - // rcb24H - // - this.rcb24H.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rcb24H.AutoSize = false; - this.rcb24H.BackColor = System.Drawing.Color.Transparent; - this.rcb24H.CheckState = System.Windows.Forms.CheckState.Checked; - this.rcb24H.Enabled = false; - this.rcb24H.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(5)))), ((int)(((byte)(5))))); - this.rcb24H.Location = new System.Drawing.Point(253, 560); - this.rcb24H.Name = "rcb24H"; - // - // - // - this.rcb24H.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; - this.rcb24H.Size = new System.Drawing.Size(25, 37); - this.rcb24H.TabIndex = 67; - this.rcb24H.Text = "24"; - this.rcb24H.TextWrap = true; - this.rcb24H.ThemeName = "TelerikMetroBlue"; - this.rcb24H.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On; - // - // rlUntil - // - this.rlUntil.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rlUntil.AutoSize = false; - this.rlUntil.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); - this.rlUntil.ForeColor = System.Drawing.Color.DarkGray; - this.rlUntil.Location = new System.Drawing.Point(134, 597); - this.rlUntil.Name = "rlUntil"; - this.rlUntil.Size = new System.Drawing.Size(109, 19); - this.rlUntil.TabIndex = 66; - this.rlUntil.Text = "History until"; - this.rlUntil.TextAlignment = System.Drawing.ContentAlignment.TopRight; - // - // radLabel6 - // - this.radLabel6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radLabel6.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); - this.radLabel6.ForeColor = System.Drawing.Color.DarkGray; - this.radLabel6.Location = new System.Drawing.Point(16, 535); - this.radLabel6.Name = "radLabel6"; - this.radLabel6.Size = new System.Drawing.Size(81, 19); - this.radLabel6.TabIndex = 65; - this.radLabel6.Text = "History from"; - // - // treeViewUnits - // - this.treeViewUnits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.treeViewUnits.CheckBoxes = true; - this.treeViewUnits.Location = new System.Drawing.Point(16, 25); - this.treeViewUnits.Name = "treeViewUnits"; - this.treeViewUnits.Size = new System.Drawing.Size(265, 453); - this.treeViewUnits.SortOrder = System.Windows.Forms.SortOrder.Ascending; - this.treeViewUnits.SpacingBetweenNodes = -1; - this.treeViewUnits.TabIndex = 60; - this.treeViewUnits.Text = "radTreeView1"; - this.treeViewUnits.ThemeName = "TelerikMetroBlue"; - this.treeViewUnits.TriStateMode = true; - this.treeViewUnits.NodeFormatting += new Telerik.WinControls.UI.TreeNodeFormattingEventHandler(this.treeViewUnits_NodeFormatting); - this.treeViewUnits.CreateNodeElement += new Telerik.WinControls.UI.CreateTreeNodeElementEventHandler(this.treeViewUnits_CreateNodeElement); - // - // rlHistoryForSelectedUnits - // - this.rlHistoryForSelectedUnits.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.rlHistoryForSelectedUnits.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); - this.rlHistoryForSelectedUnits.ForeColor = System.Drawing.Color.DarkGray; - this.rlHistoryForSelectedUnits.Location = new System.Drawing.Point(16, 500); - this.rlHistoryForSelectedUnits.Name = "rlHistoryForSelectedUnits"; - this.rlHistoryForSelectedUnits.Size = new System.Drawing.Size(152, 19); - this.rlHistoryForSelectedUnits.TabIndex = 61; - this.rlHistoryForSelectedUnits.Text = "History for selected units"; - // - // labelUnits - // - this.labelUnits.BackColor = System.Drawing.Color.WhiteSmoke; - this.labelUnits.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); - this.labelUnits.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - this.labelUnits.Location = new System.Drawing.Point(16, 5); - this.labelUnits.Name = "labelUnits"; - this.labelUnits.Size = new System.Drawing.Size(40, 21); - this.labelUnits.TabIndex = 77; - this.labelUnits.Text = "Units"; - // // documentContainer1 // this.documentContainer1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(254))))); @@ -1075,7 +1074,7 @@ namespace Safedispatch_4_0 // this.documentTabStrip1.RootElement.MinSize = new System.Drawing.Size(25, 25); this.documentTabStrip1.SelectedIndex = 1; - this.documentTabStrip1.Size = new System.Drawing.Size(854, 803); + this.documentTabStrip1.Size = new System.Drawing.Size(844, 793); this.documentTabStrip1.TabIndex = 0; this.documentTabStrip1.TabStop = false; this.documentTabStrip1.TabStripVisible = false; @@ -1125,7 +1124,7 @@ namespace Safedispatch_4_0 this.toolWindow2.Margin = new System.Windows.Forms.Padding(0); this.toolWindow2.Name = "toolWindow2"; this.toolWindow2.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.toolWindow2.Size = new System.Drawing.Size(854, 803); + this.toolWindow2.Size = new System.Drawing.Size(844, 793); this.toolWindow2.Text = "toolWindow2"; this.toolWindow2.Resize += new System.EventHandler(this.toolWindow2_Resize); // @@ -1184,7 +1183,7 @@ namespace Safedispatch_4_0 this.HistMapPanel.Location = new System.Drawing.Point(0, 0); this.HistMapPanel.Margin = new System.Windows.Forms.Padding(0); this.HistMapPanel.Name = "HistMapPanel"; - this.HistMapPanel.Size = new System.Drawing.Size(854, 803); + this.HistMapPanel.Size = new System.Drawing.Size(844, 793); this.HistMapPanel.TabIndex = 0; this.HistMapPanel.ThemeName = "TelerikMetroBlue"; ((Telerik.WinControls.UI.RadPanelElement)(this.HistMapPanel.GetChildAt(0))).Text = ""; @@ -1268,28 +1267,6 @@ namespace Safedispatch_4_0 ((System.ComponentModel.ISupportInitialize)(this.skinButton4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.radDock1)).EndInit(); this.radDock1.ResumeLayout(false); - this.windowHistoryResult.ResumeLayout(false); - this.windowHistoryResult.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.panelAnimationButtons)).EndInit(); - this.panelAnimationButtons.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.rbPrev)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbNext)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbStop)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbPause)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rbPlay)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints.MasterTemplate)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.timeTrackBar)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rsePositionDisplay)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rseSkipSeconds)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel10)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.labelSlideshow)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rcbShowLabels)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rcbShowGeofence)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rlPositionDisplayMs)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rlAnimation)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.toolTabStripTabs)).EndInit(); - this.toolTabStripTabs.ResumeLayout(false); this.toolWindow4.ResumeLayout(false); this.toolWindow4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbFilter)).EndInit(); @@ -1310,6 +1287,28 @@ namespace Safedispatch_4_0 ((System.ComponentModel.ISupportInitialize)(this.treeViewUnits)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rlHistoryForSelectedUnits)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.labelUnits)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.toolTabStripTabs)).EndInit(); + this.toolTabStripTabs.ResumeLayout(false); + this.windowHistoryResult.ResumeLayout(false); + this.windowHistoryResult.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.panelAnimationButtons)).EndInit(); + this.panelAnimationButtons.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.rbPrev)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbNext)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbStop)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbPause)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rbPlay)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints.MasterTemplate)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gridHistoryPoints)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.timeTrackBar)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rsePositionDisplay)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rseSkipSeconds)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.radLabel10)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.labelSlideshow)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rcbShowLabels)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rcbShowGeofence)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rlPositionDisplayMs)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.rlAnimation)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.documentContainer1)).EndInit(); this.documentContainer1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.documentTabStrip1)).EndInit(); diff --git a/Safedispatch_4_0/maptab/HistoryTab.resx b/Safedispatch_4_0/maptab/HistoryTab.resx index efac71d..5834889 100644 --- a/Safedispatch_4_0/maptab/HistoryTab.resx +++ b/Safedispatch_4_0/maptab/HistoryTab.resx @@ -149,7 +149,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABI - HQAAAk1TRnQBSQFMAgEBBgEAAWgBCAFoAQgBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + HQAAAk1TRnQBSQFMAgEBBgEAAXABCAFwAQgBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABIAMAAQEBAAEgBgABICIAAywBQwNQAZ4BYAJbAdYCXAFVAeoCYAFZAesBXwJcAdsDVAGuAzQBVCAA AyYBOANPAZcDXAHPA1cB6ANVAeoDWgHTA1EBoAMsAUSYAAMIAQsDUAGdAZACAAH/AY4CAAH/AZACAAH/ AZECAAH/AZECAAH/AZACAAH/AY4CAAH/AY4CAAH/A1gBuQMUARsQAAMMARADTgGVAysB/AMAAf8DAAH/ diff --git a/Safedispatch_4_0/maptab/ReportCont.Designer.cs b/Safedispatch_4_0/maptab/ReportCont.Designer.cs index 7a04d46..543443d 100644 --- a/Safedispatch_4_0/maptab/ReportCont.Designer.cs +++ b/Safedispatch_4_0/maptab/ReportCont.Designer.cs @@ -29,22 +29,23 @@ private void InitializeComponent() { this.radDock1 = new Telerik.WinControls.UI.Docking.RadDock(); - this.repGeofenc = new Telerik.WinControls.UI.Docking.ToolWindow(); + this.repSMSLocation = new Telerik.WinControls.UI.Docking.ToolWindow(); this.documentContainer1 = new Telerik.WinControls.UI.Docking.DocumentContainer(); this.documentTabStrip1 = new Telerik.WinControls.UI.Docking.DocumentTabStrip(); this.repSpeed = new Telerik.WinControls.UI.Docking.ToolWindow(); + this.repGeofenc = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repLand = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repONOFF = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repEmerg = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repALL = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repHist = new Telerik.WinControls.UI.Docking.ToolWindow(); + this.repBatchHist = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repEndDay = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repIdle = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repStop = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repFleet = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repTelem = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repTelemEvn = new Telerik.WinControls.UI.Docking.ToolWindow(); - this.repSMSLocation = new Telerik.WinControls.UI.Docking.ToolWindow(); this.repTicketing = new Telerik.WinControls.UI.Docking.ToolWindow(); this.radThemeManager1 = new Telerik.WinControls.RadThemeManager(); ((System.ComponentModel.ISupportInitialize)(this.radDock1)).BeginInit(); @@ -57,7 +58,7 @@ // // radDock1 // - this.radDock1.ActiveWindow = this.repONOFF; + this.radDock1.ActiveWindow = this.repBatchHist; this.radDock1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(254))))); this.radDock1.CausesValidation = false; this.radDock1.Controls.Add(this.documentContainer1); @@ -79,22 +80,23 @@ this.radDock1.ThemeName = "TelerikMetroBlue"; this.radDock1.ActiveWindowChanging += new Telerik.WinControls.UI.Docking.DockWindowCancelEventHandler(this.radDock1_ActiveWindowChanging); this.radDock1.ActiveWindowChanged += new Telerik.WinControls.UI.Docking.DockWindowEventHandler(this.radDock1_ActiveWindowChanged); + ((Telerik.WinControls.UI.SplitPanelElement)(this.radDock1.GetChildAt(0))).Padding = new System.Windows.Forms.Padding(5); ((Telerik.WinControls.Primitives.BorderPrimitive)(this.radDock1.GetChildAt(0).GetChildAt(1))).Width = 0F; ((Telerik.WinControls.Primitives.BorderPrimitive)(this.radDock1.GetChildAt(0).GetChildAt(1))).LeftWidth = 0F; ((Telerik.WinControls.Primitives.BorderPrimitive)(this.radDock1.GetChildAt(0).GetChildAt(1))).TopWidth = 0F; ((Telerik.WinControls.Primitives.BorderPrimitive)(this.radDock1.GetChildAt(0).GetChildAt(1))).RightWidth = 0F; ((Telerik.WinControls.Primitives.BorderPrimitive)(this.radDock1.GetChildAt(0).GetChildAt(1))).BottomWidth = 0F; // - // repGeofenc + // repSMSLocation // - this.repGeofenc.Caption = null; - this.repGeofenc.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.repGeofenc.Location = new System.Drawing.Point(4, 32); - this.repGeofenc.Name = "repGeofenc"; - this.repGeofenc.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.repGeofenc.Size = new System.Drawing.Size(1454, 502); - this.repGeofenc.Text = "Geofencing Retroactive"; - this.repGeofenc.Enter += new System.EventHandler(this.repGeofenc_Enter); + this.repSMSLocation.Caption = null; + this.repSMSLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.repSMSLocation.Location = new System.Drawing.Point(4, 32); + this.repSMSLocation.Name = "repSMSLocation"; + this.repSMSLocation.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; + this.repSMSLocation.Size = new System.Drawing.Size(1454, 502); + this.repSMSLocation.Text = "Text message location"; + this.repSMSLocation.Enter += new System.EventHandler(this.repSMSLocation_Enter); // // documentContainer1 // @@ -114,13 +116,14 @@ // this.documentTabStrip1.CanUpdateChildIndex = true; this.documentTabStrip1.CausesValidation = false; + this.documentTabStrip1.Controls.Add(this.repHist); this.documentTabStrip1.Controls.Add(this.repSpeed); this.documentTabStrip1.Controls.Add(this.repGeofenc); this.documentTabStrip1.Controls.Add(this.repLand); this.documentTabStrip1.Controls.Add(this.repONOFF); this.documentTabStrip1.Controls.Add(this.repEmerg); this.documentTabStrip1.Controls.Add(this.repALL); - this.documentTabStrip1.Controls.Add(this.repHist); + this.documentTabStrip1.Controls.Add(this.repBatchHist); this.documentTabStrip1.Controls.Add(this.repEndDay); this.documentTabStrip1.Controls.Add(this.repIdle); this.documentTabStrip1.Controls.Add(this.repStop); @@ -135,7 +138,7 @@ // // this.documentTabStrip1.RootElement.MinSize = new System.Drawing.Size(25, 25); - this.documentTabStrip1.SelectedIndex = 3; + this.documentTabStrip1.SelectedIndex = 7; this.documentTabStrip1.Size = new System.Drawing.Size(1462, 538); this.documentTabStrip1.TabIndex = 0; this.documentTabStrip1.TabStop = false; @@ -165,6 +168,17 @@ this.repSpeed.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None; this.repSpeed.Enter += new System.EventHandler(this.repSpeed_Enter); // + // repGeofenc + // + this.repGeofenc.Caption = null; + this.repGeofenc.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.repGeofenc.Location = new System.Drawing.Point(4, 32); + this.repGeofenc.Name = "repGeofenc"; + this.repGeofenc.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; + this.repGeofenc.Size = new System.Drawing.Size(1454, 502); + this.repGeofenc.Text = "Geofencing Retroactive"; + this.repGeofenc.Enter += new System.EventHandler(this.repGeofenc_Enter); + // // repLand // this.repLand.Caption = null; @@ -180,10 +194,10 @@ // this.repONOFF.Caption = null; this.repONOFF.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.repONOFF.Location = new System.Drawing.Point(4, 32); + this.repONOFF.Location = new System.Drawing.Point(5, 28); this.repONOFF.Name = "repONOFF"; this.repONOFF.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.repONOFF.Size = new System.Drawing.Size(1454, 502); + this.repONOFF.Size = new System.Drawing.Size(1442, 495); this.repONOFF.Text = "Mototrbo ON / OFF"; this.repONOFF.Enter += new System.EventHandler(this.repONOFF_Enter); // @@ -213,13 +227,24 @@ // this.repHist.Caption = null; this.repHist.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.repHist.Location = new System.Drawing.Point(6, 28); + this.repHist.Location = new System.Drawing.Point(4, 32); this.repHist.Name = "repHist"; this.repHist.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.repHist.Size = new System.Drawing.Size(1015, 446); + this.repHist.Size = new System.Drawing.Size(1454, 502); this.repHist.Text = "History"; this.repHist.Enter += new System.EventHandler(this.repHist_Enter); // + // repBatchHist + // + this.repBatchHist.Caption = null; + this.repBatchHist.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.repBatchHist.Location = new System.Drawing.Point(4, 32); + this.repBatchHist.Name = "repBatchHist"; + this.repBatchHist.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; + this.repBatchHist.Size = new System.Drawing.Size(1454, 502); + this.repBatchHist.Text = "Batch History"; + this.repBatchHist.Enter += new System.EventHandler(this.repBatchHist_Enter); + // // repEndDay // this.repEndDay.Caption = null; @@ -286,25 +311,14 @@ this.repTelemEvn.Text = "Telemetry Event"; this.repTelemEvn.Enter += new System.EventHandler(this.repTelemEvn_Enter); // - // repSMSLocation - // - this.repSMSLocation.Caption = null; - this.repSMSLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.repSMSLocation.Location = new System.Drawing.Point(4, 32); - this.repSMSLocation.Name = "repSMSLocation"; - this.repSMSLocation.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.repSMSLocation.Size = new System.Drawing.Size(1454, 502); - this.repSMSLocation.Text = "Text message location"; - this.repSMSLocation.Enter += new System.EventHandler(this.repSMSLocation_Enter); - // // repTicketing // this.repTicketing.Caption = null; this.repTicketing.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.repTicketing.Location = new System.Drawing.Point(6, 29); + this.repTicketing.Location = new System.Drawing.Point(4, 32); this.repTicketing.Name = "repTicketing"; this.repTicketing.PreviousDockState = Telerik.WinControls.UI.Docking.DockState.Docked; - this.repTicketing.Size = new System.Drawing.Size(1440, 493); + this.repTicketing.Size = new System.Drawing.Size(1454, 502); this.repTicketing.Text = "Job Ticketing"; this.repTicketing.Enter += new System.EventHandler(this.repTicketing_Enter); // @@ -328,6 +342,7 @@ private Telerik.WinControls.UI.Docking.DocumentContainer documentContainer1; private Telerik.WinControls.UI.Docking.ToolWindow repHist; + private Telerik.WinControls.UI.Docking.ToolWindow repBatchHist; private Telerik.WinControls.UI.Docking.DocumentTabStrip documentTabStrip1; private Telerik.WinControls.UI.Docking.ToolWindow repONOFF; private Telerik.WinControls.UI.Docking.ToolWindow repGeofenc; diff --git a/Safedispatch_4_0/maptab/ReportCont.cs b/Safedispatch_4_0/maptab/ReportCont.cs index 12c4fd4..fad3b18 100644 --- a/Safedispatch_4_0/maptab/ReportCont.cs +++ b/Safedispatch_4_0/maptab/ReportCont.cs @@ -25,6 +25,7 @@ namespace Safedispatch_4_0 repEmerg.Text = MainForm2.returnLNGString("emergAlarm"); repFleet.Text = MainForm2.returnLNGString("FleetReport"); repHist.Text = MainForm2.returnLNGString("tabHist"); + repBatchHist.Text = MainForm2.returnLNGString("tabBatchHist"); switch (MainForm2.radioType) { @@ -73,8 +74,6 @@ namespace Safedispatch_4_0 InitializeComponent(); setLanguage(); - - repHash.Clear(); if ((MainForm2.radioType == RADIOTYPE.MOTO) || (MainForm2.radioType == RADIOTYPE.HYT) @@ -84,10 +83,13 @@ namespace Safedispatch_4_0 repHash.Add(repTelem.Name, false); repHash.Add(repTelemEvn.Name, false); } + if (MainForm2.radioType != RADIOTYPE.SIMOCO && MainForm2.radioType != RADIOTYPE.EXCERA) repHash.Add(repONOFF.Name, false); + if (MainForm2.radioType != RADIOTYPE.CONECTPLUS) repHash.Add(repEmerg.Name, false); + if (MainForm2.SMSDecide) repHash.Add(repSMSLocation.Name, false); @@ -95,6 +97,7 @@ namespace Safedispatch_4_0 repHash.Add(repFleet.Name, false); repHash.Add(repGeofenc.Name, false); repHash.Add(repHist.Name, false); + repHash.Add(repBatchHist.Name, false); repHash.Add(repIdle.Name, false); //repHash.Add(repONOFF.Name, false); repHash.Add(repSpeed.Name, false); @@ -102,6 +105,7 @@ namespace Safedispatch_4_0 repHash.Add(repALL.Name, false); documentTabStrip1.SelectedIndex = 0; + OnEnterValid = true; //on ENter don' work here CheckTabs(rep_type.SPEED, repSpeed); @@ -113,22 +117,10 @@ namespace Safedispatch_4_0 menuService.AllowDocumentContextMenu = false; menuService.AllowToolContextMenu = false; - repALL.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repEmerg.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repEndDay.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repFleet.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repGeofenc.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repHist.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repIdle.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repONOFF.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repSpeed.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repStop.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repTelem.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repTelemEvn.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repSMSLocation.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repTicketing.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - repLand.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + RemoveCloseButtons(); + MainForm2.RestartMEM += 40000000; + try { switch (MainForm2.radioType) @@ -205,7 +197,10 @@ namespace Safedispatch_4_0 { SM.Debug("Error remove reports constructor" + ex.ToString()); } - if (!MainForm2.SMSDecide) documentTabStrip1.Controls.Remove(repSMSLocation); + + + if (!MainForm2.SMSDecide) + documentTabStrip1.Controls.Remove(repSMSLocation); if(MainForm2.radioType == RADIOTYPE.LINX) @@ -218,6 +213,26 @@ namespace Safedispatch_4_0 } } + private void RemoveCloseButtons() + { + repALL.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repEmerg.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repEndDay.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repFleet.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repGeofenc.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repHist.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repBatchHist.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repIdle.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repONOFF.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repSpeed.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repStop.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repTelem.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repTelemEvn.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repSMSLocation.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repTicketing.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + repLand.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; + } + private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { if (e.MenuType == ContextMenuType.DockWindow && @@ -226,10 +241,10 @@ namespace Safedispatch_4_0 for (int i = 0; i < e.MenuItems.Count; i++) { RadMenuItemBase menuItem = e.MenuItems[i]; - if (menuItem.Name == "CloseWindow" || - menuItem.Name == "CloseAllButThis" || - menuItem.Name == "CloseAll" || - menuItem.Name == "Hidden" || + if (menuItem.Name.Equals("CloseWindow") || + menuItem.Name.Equals("CloseAllButThis") || + menuItem.Name.Equals("CloseAll") || + menuItem.Name.Equals("Hidden") || menuItem is RadMenuSeparatorItem) { menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; @@ -243,35 +258,27 @@ namespace Safedispatch_4_0 if (OnEnterValid) { if (repHash[tool.Name] != null) + { if (((Boolean)repHash[tool.Name]) == false) { repHash[tool.Name] = true; AddReportWindow(type, tool); - // add geofences to the combobox - if (type == rep_type.GEOFENC) - OnFocusControl.Refresh_GeoName(); - else if (type == rep_type.LAND) - OnFocusControl.Refresh_LandName(); } else { OnFocusControl = (ReportsControl)tool.Controls[0]; - // refresh geofecens from the combobox - if (type == rep_type.GEOFENC) - OnFocusControl.Refresh_GeoName(); - else if (type == rep_type.LAND) - OnFocusControl.Refresh_LandName(); } + } else { repHash.Add(tool.Name, true); AddReportWindow(type, tool); - // add geofences to the combobox - if (type == rep_type.GEOFENC) - OnFocusControl.Refresh_GeoName(); - else if (type == rep_type.LAND) - OnFocusControl.Refresh_LandName(); } + + if (type == rep_type.GEOFENC) + OnFocusControl.Refresh_GeoName(); + else if (type == rep_type.LAND) + OnFocusControl.Refresh_LandName(); } } @@ -310,6 +317,11 @@ namespace Safedispatch_4_0 CheckTabs(rep_type.HIST, (ToolWindow)sender); } + private void repBatchHist_Enter(object sender, EventArgs e) + { + CheckTabs(rep_type.BATCH_HIST, (ToolWindow)sender); + } + private void repIdle_Enter(object sender, EventArgs e) { CheckTabs(rep_type.IDLE, (ToolWindow)sender); @@ -391,5 +403,7 @@ namespace Safedispatch_4_0 e.DockWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor; } #endregion + + } } diff --git a/Safedispatch_4_0/maptab/Reports/ReportsControl.Designer.cs b/Safedispatch_4_0/maptab/Reports/ReportsControl.Designer.cs index db72ac0..775cddb 100644 --- a/Safedispatch_4_0/maptab/Reports/ReportsControl.Designer.cs +++ b/Safedispatch_4_0/maptab/Reports/ReportsControl.Designer.cs @@ -31,6 +31,9 @@ this.components = new System.ComponentModel.Container(); this.radDock1 = new Telerik.WinControls.UI.Docking.RadDock(); this.documentWindow1 = new Telerik.WinControls.UI.Docking.DocumentWindow(); + this.btPrintReportInCsv = new Telerik.WinControls.UI.RadButton(); + this.btPrintReport = new Telerik.WinControls.UI.RadButton(); + this.radTreeUnits = new Telerik.WinControls.UI.RadTreeView(); this.pbReportDaily = new System.Windows.Forms.PictureBox(); this.ckReportDaily = new Telerik.WinControls.UI.RadCheckBox(); this.pbStatus = new System.Windows.Forms.PictureBox(); @@ -48,7 +51,6 @@ this.rProgressBar = new Telerik.WinControls.UI.RadProgressBar(); this.rlComputing = new Telerik.WinControls.UI.RadLabel(); this.ckComputeAddress = new Telerik.WinControls.UI.RadCheckBox(); - this.btPrintReport = new Telerik.WinControls.UI.RadButton(); this.rdtUntil = new Telerik.WinControls.UI.RadDateTimePicker(); this.ckDataFilter = new Telerik.WinControls.UI.RadCheckBox(); this.ckSelectALL = new Telerik.WinControls.UI.RadCheckBox(); @@ -99,9 +101,13 @@ this.GisAddressWorker = new System.ComponentModel.BackgroundWorker(); this.toolTipHelp = new System.Windows.Forms.ToolTip(this.components); this.office2013LightTheme1 = new Telerik.WinControls.Themes.Office2013LightTheme(); + this.ckKeepValidPositions = new Telerik.WinControls.UI.RadCheckBox(); ((System.ComponentModel.ISupportInitialize)(this.radDock1)).BeginInit(); this.radDock1.SuspendLayout(); this.documentWindow1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.btPrintReportInCsv)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.btPrintReport)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.radTreeUnits)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbReportDaily)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ckReportDaily)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbStatus)).BeginInit(); @@ -121,7 +127,6 @@ this.rProgressBar.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.rlComputing)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ckComputeAddress)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.btPrintReport)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rdtUntil)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ckDataFilter)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ckSelectALL)).BeginInit(); @@ -173,6 +178,7 @@ ((System.ComponentModel.ISupportInitialize)(this.panelNoReport)).BeginInit(); this.panelNoReport.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbReportType)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.ckKeepValidPositions)).BeginInit(); this.SuspendLayout(); // // radDock1 @@ -207,13 +213,16 @@ // documentWindow1 // this.documentWindow1.BackColor = System.Drawing.Color.WhiteSmoke; + this.documentWindow1.Controls.Add(this.ckKeepValidPositions); + this.documentWindow1.Controls.Add(this.btPrintReportInCsv); + this.documentWindow1.Controls.Add(this.btPrintReport); + this.documentWindow1.Controls.Add(this.radTreeUnits); this.documentWindow1.Controls.Add(this.pbReportDaily); this.documentWindow1.Controls.Add(this.ckReportDaily); this.documentWindow1.Controls.Add(this.pbStatus); this.documentWindow1.Controls.Add(this.rgbReport); this.documentWindow1.Controls.Add(this.rProgressBar); this.documentWindow1.Controls.Add(this.ckComputeAddress); - this.documentWindow1.Controls.Add(this.btPrintReport); this.documentWindow1.Controls.Add(this.rdtUntil); this.documentWindow1.Controls.Add(this.ckDataFilter); this.documentWindow1.Controls.Add(this.ckSelectALL); @@ -239,6 +248,60 @@ this.documentWindow1.Size = new System.Drawing.Size(287, 725); this.documentWindow1.Text = "documentWindow1"; // + // btPrintReportInCsv + // + this.btPrintReportInCsv.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + this.btPrintReportInCsv.CausesValidation = false; + this.btPrintReportInCsv.Cursor = System.Windows.Forms.Cursors.Hand; + this.btPrintReportInCsv.Font = new System.Drawing.Font("Segoe UI", 10F); + this.btPrintReportInCsv.Location = new System.Drawing.Point(14, 671); + this.btPrintReportInCsv.Name = "btPrintReportInCsv"; + this.btPrintReportInCsv.Size = new System.Drawing.Size(257, 34); + this.btPrintReportInCsv.TabIndex = 92; + this.btPrintReportInCsv.Text = "Generate Report in CSV"; + this.btPrintReportInCsv.ThemeName = "TelerikMetroBlue"; + this.btPrintReportInCsv.Click += new System.EventHandler(this.btPrintReportInCsv_Click); + ((Telerik.WinControls.UI.RadButtonElement)(this.btPrintReportInCsv.GetChildAt(0))).Text = "Generate Report in CSV"; + ((Telerik.WinControls.Primitives.FillPrimitive)(this.btPrintReportInCsv.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReportInCsv.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReportInCsv.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReportInCsv.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; + ((Telerik.WinControls.Primitives.FocusPrimitive)(this.btPrintReportInCsv.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; + // + // btPrintReport + // + this.btPrintReport.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + this.btPrintReport.CausesValidation = false; + this.btPrintReport.Cursor = System.Windows.Forms.Cursors.Hand; + this.btPrintReport.Font = new System.Drawing.Font("Segoe UI", 10F); + this.btPrintReport.Location = new System.Drawing.Point(15, 631); + this.btPrintReport.Name = "btPrintReport"; + this.btPrintReport.Size = new System.Drawing.Size(257, 34); + this.btPrintReport.TabIndex = 91; + this.btPrintReport.Text = "Generate Report"; + this.btPrintReport.ThemeName = "TelerikMetroBlue"; + this.btPrintReport.Click += new System.EventHandler(this.btPrintReport_Click); + ((Telerik.WinControls.UI.RadButtonElement)(this.btPrintReport.GetChildAt(0))).Text = "Generate Report"; + ((Telerik.WinControls.Primitives.FillPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); + ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; + ((Telerik.WinControls.Primitives.FocusPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; + // + // radTreeUnits + // + this.radTreeUnits.CheckBoxes = true; + this.radTreeUnits.Location = new System.Drawing.Point(16, 483); + this.radTreeUnits.Name = "radTreeUnits"; + this.radTreeUnits.Size = new System.Drawing.Size(257, 142); + this.radTreeUnits.SortOrder = System.Windows.Forms.SortOrder.Ascending; + this.radTreeUnits.SpacingBetweenNodes = -1; + this.radTreeUnits.TabIndex = 130; + this.radTreeUnits.Text = "radTreeView1"; + this.radTreeUnits.ThemeName = "TelerikMetroBlue"; + this.radTreeUnits.TriStateMode = true; + this.radTreeUnits.Visible = false; + // // pbReportDaily // this.pbReportDaily.BackColor = System.Drawing.Color.Transparent; @@ -529,28 +592,6 @@ this.ckComputeAddress.Text = "Compute address"; this.ckComputeAddress.ThemeName = "TelerikMetroBlue"; // - // btPrintReport - // - this.btPrintReport.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.btPrintReport.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - this.btPrintReport.CausesValidation = false; - this.btPrintReport.Cursor = System.Windows.Forms.Cursors.Hand; - this.btPrintReport.Font = new System.Drawing.Font("Segoe UI", 10F); - this.btPrintReport.Location = new System.Drawing.Point(16, 480); - this.btPrintReport.Name = "btPrintReport"; - this.btPrintReport.Size = new System.Drawing.Size(257, 34); - this.btPrintReport.TabIndex = 91; - this.btPrintReport.Text = "Generate Report"; - this.btPrintReport.ThemeName = "TelerikMetroBlue"; - this.btPrintReport.Click += new System.EventHandler(this.btPrintReport_Click); - ((Telerik.WinControls.UI.RadButtonElement)(this.btPrintReport.GetChildAt(0))).Text = "Generate Report"; - ((Telerik.WinControls.Primitives.FillPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(1).GetChildAt(1))).ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold); - ((Telerik.WinControls.Primitives.TextPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter; - ((Telerik.WinControls.Primitives.FocusPrimitive)(this.btPrintReport.GetChildAt(0).GetChildAt(3))).BackColor = System.Drawing.Color.DeepSkyBlue; - // // rdtUntil // this.rdtUntil.CustomFormat = "MM/dd/yyyy, HH:mm"; @@ -1214,6 +1255,17 @@ this.GisAddressWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.GisAddressWorker_DoWork); this.GisAddressWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.GisAddressWorker_RunWorkerCompleted); // + // ckKeepValidPositions + // + this.ckKeepValidPositions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); + this.ckKeepValidPositions.Location = new System.Drawing.Point(17, 356); + this.ckKeepValidPositions.Name = "ckKeepValidPositions"; + this.ckKeepValidPositions.Size = new System.Drawing.Size(144, 18); + this.ckKeepValidPositions.TabIndex = 131; + this.ckKeepValidPositions.Text = "Keep only valid positions"; + this.ckKeepValidPositions.ThemeName = "TelerikMetroBlue"; + this.ckKeepValidPositions.Visible = false; + // // ReportsControl // this.Controls.Add(this.radDock1); @@ -1224,6 +1276,9 @@ this.radDock1.ResumeLayout(false); this.documentWindow1.ResumeLayout(false); this.documentWindow1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.btPrintReportInCsv)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.btPrintReport)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.radTreeUnits)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbReportDaily)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ckReportDaily)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbStatus)).EndInit(); @@ -1244,7 +1299,6 @@ this.rProgressBar.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.rlComputing)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ckComputeAddress)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.btPrintReport)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rdtUntil)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ckDataFilter)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ckSelectALL)).EndInit(); @@ -1301,6 +1355,7 @@ ((System.ComponentModel.ISupportInitialize)(this.panelNoReport)).EndInit(); this.panelNoReport.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pbReportType)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.ckKeepValidPositions)).EndInit(); this.ResumeLayout(false); } @@ -1377,5 +1432,8 @@ private Telerik.WinControls.UI.RadButton btSaveEmail; private Telerik.WinControls.Themes.Office2013LightTheme office2013LightTheme1; private Telerik.WinControls.UI.RadLabel rlIdle; + private Telerik.WinControls.UI.RadTreeView radTreeUnits; + public Telerik.WinControls.UI.RadButton btPrintReportInCsv; + private Telerik.WinControls.UI.RadCheckBox ckKeepValidPositions; } } diff --git a/Safedispatch_4_0/maptab/Reports/ReportsControl.cs b/Safedispatch_4_0/maptab/Reports/ReportsControl.cs index 4c4e136..850fef5 100644 --- a/Safedispatch_4_0/maptab/Reports/ReportsControl.cs +++ b/Safedispatch_4_0/maptab/Reports/ReportsControl.cs @@ -20,6 +20,7 @@ using System.Drawing.Drawing2D; using Dispatcher; using System.Threading.Tasks; using ReportsLibrary; +using resources = Dispatcher.Properties.Resources; namespace Safedispatch_4_0 { @@ -70,6 +71,7 @@ namespace Safedispatch_4_0 //ckStatus.Text = MainForm2.returnLNGString("SMSStatus"); rlIdle.Text = MainForm2.returnLNGString("txIDLE"); btPrintReport.Text = MainForm2.returnLNGString("btShowReport"); + btPrintReportInCsv.Text = MainForm2.returnLNGString("btShowReportInCsv"); minval = MainForm2.returnLNGString("min"); toolWindow2.Text = MainForm2.returnLNGString("Report"); @@ -180,6 +182,7 @@ namespace Safedispatch_4_0 foreach (Int32 obj in MainForm2.LandIDHash.Keys) ZoneListNames.Add(new VehandID((String)MainForm2.LandIDHash[obj], obj, "")); } + rcbGeoLandName.DataSource = null; ZoneListNames.Sort(new VehandIDComparer()); rcbGeoLandName.DataSource = ZoneListNames; @@ -194,21 +197,34 @@ namespace Safedispatch_4_0 } } + private void GetMessagesFromResources() + { + msgLimit = MainForm2.returnLNGString("endtimegreate"); + msgInteger = MainForm2.returnLNGString("msgInteger"); + msgMustSel = MainForm2.returnLNGString("mustselect"); + msgInvalidEmail = MainForm2.returnLNGString("msgInvalidEmail"); + msgSplitEmail = MainForm2.returnLNGString("msgSplitEmail"); + msgEmailSaved = MainForm2.returnLNGString("msgEmailSaved"); + } + public ReportsControl(rep_type _RepType) { MainForm2.RestartMEM += 60000000; + smdbObj = new SMdb_access(); dbRep = new DBReportingManager(MainForm2.cfg.DB_IP, MainForm2.cfg.DB_schema, MainForm2.cfg.DB_user, MainForm2.cfg.DB_passwd, MainForm2.cfg.DB_port); + vehicleListNames = new ArrayList(); ZoneListNames = new ArrayList(); //convDT = new ConvertDT(); RepType = _RepType; + InitializeComponent(); // set theme for the Message Box RadMessageBox.SetThemeName("TelerikMetroBlue"); - + GetMessagesFromResources(); #region THEMING btPrintReport.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; @@ -225,133 +241,58 @@ namespace Safedispatch_4_0 UpdateUIForReportType(_RepType); setLanguage(); - toolWindow2.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu; - toolWindow2.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; - msgLimit = MainForm2.returnLNGString("endtimegreate"); - msgInteger = MainForm2.returnLNGString("msgInteger"); - msgMustSel = MainForm2.returnLNGString("mustselect"); - msgInvalidEmail = MainForm2.returnLNGString("msgInvalidEmail"); - msgSplitEmail = MainForm2.returnLNGString("msgSplitEmail"); - msgEmailSaved = MainForm2.returnLNGString("msgEmailSaved"); - rdtFrom.CustomFormat = rdtUntil.CustomFormat = Utils.getDayCustomFormat(MainForm2.is24hours, StaticMembers.DayFirst); - //if (MainForm2.is24hours) - //{ - // if (MainForm2.DayFirst) - // { - // rdtFrom.CustomFormat = "dd/MM/yyyy HH:mm"; - // rdtUntil.CustomFormat = "dd/MM/yyyy HH:mm"; - // } - // else - // { - // rdtFrom.CustomFormat = "MM/dd/yyyy HH:mm"; - // rdtUntil.CustomFormat = "MM/dd/yyyy HH:mm"; - // } - //} - //else - //{ - // if (MainForm2.DayFirst) - // { - // rdtFrom.CustomFormat = "dd/MM/yyyy hh:mm tt"; - // rdtUntil.CustomFormat = "dd/MM/yyyy hh:mm tt"; - // } - // else - // { - // rdtFrom.CustomFormat = "MM/dd/yyyy hh:mm tt"; - // rdtUntil.CustomFormat = "MM/dd/yyyy hh:mm tt"; - // } - //} - DateTime now = DateTime.Now; - DateTime beginOfDay = new DateTime(now.Year, now.Month, now.Day); - rdtFrom.Value = beginOfDay; - rdtUntil.Value = now; + toolWindow2.ToolCaptionButtons = ToolStripCaptionButtons.AutoHide | ToolStripCaptionButtons.SystemMenu; + toolWindow2.DocumentButtons &= ~DocumentStripButtons.Close; + + + PopulateDateTimeInterval(); try { - foreach (String obj in StaticMembers.vehicleHT.Keys) + if (_RepType == rep_type.BATCH_HIST) { - // get the vehicle for this key - VehicleForReports veh = (VehicleForReports)(StaticMembers.vehicleHT[obj]); - - // create the DropList Item and add it to the items list - DropListItem item = new DropListItem(); - item.Text = veh.busName; - item.Image = GetIconForCombobox(MainForm2.radioType, "unit", true); //Dispatcher.Properties.Resources.icon_u; - item.ValueImei = "'" + veh.IMEI + "'"; - item.ValueScID = veh.sc_id + ""; - - UnitGroupItems.Add(item); - vehicleListNames.Add(new VehandID(((VehicleForReports)StaticMembers.vehicleHT[obj]).busName, ((VehicleForReports)StaticMembers.vehicleHT[obj]).sc_id, ((VehicleForReports)StaticMembers.vehicleHT[obj]).IMEI)); + // populate RadTreeView + PopulateRadTreeView(); } - - // sort alphabetically the list - List sortedList = UnitGroupItems.OrderBy(x => x.Text).ToList(); - UnitGroupItems = new BindingList(sortedList); - - // do not add the Groups to the comboBox if one of this types - if (!(_RepType == rep_type.ENDOFDAY || _RepType == rep_type.FLEET || - _RepType == rep_type.IDLE || _RepType == rep_type.STOP || _RepType == rep_type.HIST)) + else { - // create a temporary binding list which will be sorted before being added to the - // main binding list - BindingList tempGroupList = new BindingList(); - // add groups into drop list - foreach (DictionaryEntry pair in MainForm2.GroupHash) + + //=============== + // Units + //=============== + PopulateUnits(); + + // do not add the Groups to the comboBox if one of this types + if (!(_RepType == rep_type.ENDOFDAY || _RepType == rep_type.FLEET || + _RepType == rep_type.IDLE || _RepType == rep_type.STOP || _RepType == rep_type.HIST)) { - GroupClass group = (GroupClass)pair.Value; - DropListItem item = new DropListItem(); - item.Image = GetIconForCombobox(MainForm2.radioType, "group", true); //Dispatcher.Properties.Resources.icon_group; - item.Text = group.name; - item.IsGroup = true; - - // create the list of sc_ids contained in this group - string scIDs = ""; - foreach (int unitScID in group.arrSc_id) - { - scIDs = scIDs + unitScID + ","; - } - - // remove last , - if (scIDs.Length > 0 && scIDs.Substring(scIDs.Length - 1, 1).Equals(",")) - scIDs = scIDs.Remove(scIDs.Length - 1); - - // add group imeis to the data item value - item.ValueScID = scIDs; - - // add only groups with units - if (scIDs.Length > 0) - tempGroupList.Add(item); - - // create the list of imeis contained in this group - string imeis = ""; - foreach (String unitImei in group.arrImei) - { - imeis = imeis + "'" + unitImei + "',"; - } - - // remove last , - if (imeis.Length > 0 && imeis.Substring(imeis.Length - 1, 1).Equals(",")) - imeis = imeis.Remove(imeis.Length - 1); - - // add group imeis to the data item value - item.ValueImei = imeis; + //=============== + // Groups + //=============== + PopulateGroups(); } - - // sort alphabetically the list - List sortedGroupList = tempGroupList.OrderBy(x => x.Text).ToList(); - - // add the temporary list to the main one - foreach (DropListItem ite in sortedGroupList) - UnitGroupItems.Add(ite); + // add the datasource for the vehicles ComboBox + rcbUnitGroup.DataSource = UnitGroupItems; + if (rcbUnitGroup.Items.Count > 1) + rcbUnitGroup.SelectedIndex = 0; } + + //=============== + // Geofence + //=============== if (RepType == rep_type.GEOFENC) { foreach (Int32 obj in MainForm2.ZoneIDHash.Keys) ZoneListNames.Add(new VehandID(((ZoneClass)MainForm2.ZoneIDHash[obj]).Name, obj, "")); } + + //=============== + // Landmark + //=============== else if (RepType == rep_type.LAND) { foreach (Int32 obj in MainForm2.LandIDHash.Keys) @@ -365,24 +306,25 @@ namespace Safedispatch_4_0 return; } - vehicleListNames.Sort(new VehandIDComparer()); - - // add the datasource for the vehicles ComboBox - rcbUnitGroup.DataSource = UnitGroupItems; - - //cbVehName.DataSource = vehicleListNames; - //cbVehName.DisplayMember = "Name"; - if (rcbUnitGroup.Items.Count > 1) - rcbUnitGroup.SelectedIndex = 0; - - - foreach (VehandID obj in vehicleListNames) - rcbUnitFleet2.Items.Add(new RadCheckedListDataItem(obj.Name, false)); + //========= + // Fleet + //========= + if (_RepType == rep_type.FLEET) + { + PopulateFleet(); + } + //============= + // Ticketing + //============= if (rcbTicketing != null) - foreach (DictionaryEntry obj in MainForm2.TicketingStatusesHT) - rcbTicketing.Items.Add(new RadCheckedListDataItem(((TicketingStatus)obj.Value).Status.Trim(), false)); + { + PopulateTicketing(); + } + //================ + // Context menu + //================ ContextMenuService menuService = this.radDock1.GetService(); menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying; //this disables the context menu @@ -392,6 +334,7 @@ namespace Safedispatch_4_0 // get all reports definitions as in the database reportsDefinitions = smdbObj.GetReportsForUser(MainForm2.userIDX); + // populate fields in the UI as defined in the DB CheckValueReporteSaving(); repHashKey = reportid + "-" + unit_ids; @@ -402,47 +345,173 @@ namespace Safedispatch_4_0 StopDataObj.ReverseGeoOSM = MainForm2.cfg.ReverseGeoOSM; } + private void PopulateDateTimeInterval() + { + // Format and populate rdtFrom and rdtUntil + rdtFrom.CustomFormat = rdtUntil.CustomFormat = Utils.getDayCustomFormat(MainForm2.is24hours, StaticMembers.DayFirst); + + DateTime now = DateTime.Now; + DateTime beginOfDay = new DateTime(now.Year, now.Month, now.Day); + + rdtFrom.Value = beginOfDay; + rdtUntil.Value = now; + } + + private void PopulateUnits() + { + foreach (String obj in StaticMembers.vehicleHT.Keys) + { + // get the vehicle for this key + VehicleForReports veh = (VehicleForReports)(StaticMembers.vehicleHT[obj]); + + // create the DropList Item and add it to the items list + UnitGroupItems.Add(new DropListItem() + { + Text = veh.busName, + Image = GetIconForCombobox(MainForm2.radioType, "unit", true), //Dispatcher.Properties.Resources.icon_u; + ValueImei = $"'{veh.IMEI}'", + ValueScID = veh.sc_id.ToString() + }); + + + vehicleListNames.Add(new VehandID(veh.busName, veh.sc_id, veh.IMEI)); + } + + // add units sorted alphabetically into list + List sortedList = UnitGroupItems.OrderBy(x => x.Text).ToList(); + UnitGroupItems = new BindingList(sortedList); + + } + + + private void PopulateGroups() + { + + BindingList bindingGroupList = new BindingList(); + // add groups into drop list + foreach (DictionaryEntry pair in MainForm2.GroupHash) + { + GroupClass group = (GroupClass)pair.Value; + + + string scIDs = string.Join(",", group.arrSc_id.ToArray().Select(x => $"{x}")); + if (scIDs.Length > 0) + { + + string imeis = string.Join(",", group.arrImei.ToArray().Select(x => $"'{x}'")); + bindingGroupList.Add(new DropListItem() + { + Image = GetIconForCombobox(MainForm2.radioType, "group", true), + Text = group.name, + IsGroup = true, + ValueScID = scIDs, + ValueImei = imeis + }); + } + } + + + // add groups sorted alphabetically into list + List sortedGroupList = bindingGroupList.OrderBy(x => x.Text).ToList(); + + // add the temporary list to the main one + foreach (DropListItem ite in sortedGroupList) + UnitGroupItems.Add(ite); + + } + + private void PopulateTicketing() + { + foreach (DictionaryEntry obj in MainForm2.TicketingStatusesHT) + rcbTicketing.Items.Add(new RadCheckedListDataItem(((TicketingStatus)obj.Value).Status.Trim(), false)); + } + + private void PopulateFleet() + { + // populate fleet + vehicleListNames.Sort(new VehandIDComparer()); + + foreach (VehandID obj in vehicleListNames) + rcbUnitFleet2.Items.Add(new RadCheckedListDataItem(obj.Name, false)); + } + + private void PopulateRadTreeView() + { + foreach (DictionaryEntry pair in MainForm2.GroupHash) + { + GroupClass group = (GroupClass)pair.Value; + RadTreeNode groupNode = radTreeUnits.Nodes.Add(group.name); + groupNode.Tag = group.id; + + foreach (Int32 sc_id in group.arrSc_id) + { + if (MainForm2.VehIDHash.ContainsKey(sc_id)) + { + string key = (String)MainForm2.VehIDHash[sc_id]; + if (MainForm2.vehicleHT.ContainsKey(key)) + { + Vehicle vehicle = ((Vehicle)MainForm2.vehicleHT[key]); + RadTreeNode vehicleNode = groupNode.Nodes.Add(vehicle.busName); + vehicleNode.Tag = vehicle.sc_id; + } + } + } + } + } + + + private void SetResetWeekDays(bool value) + { + rcbMonday.Checked = value; + rcbTuesday.Checked = value; + rcbWednesday.Checked = value; + rcbThursday.Checked = value; + rcbFriday.Checked = value; + rcbSaturday.Checked = value; + rcbSunday.Checked = value; + } + + private void PopulateDaysField(string reportDays) + { + + String[] days = reportDays.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (String day in days) + { + if (day.Equals("Mo")) + rcbMonday.Checked = true; + else if (day.Equals("Tu")) + rcbTuesday.Checked = true; + else if (day.Equals("We")) + rcbWednesday.Checked = true; + else if (day.Equals("Th")) + rcbThursday.Checked = true; + else if (day.Equals("Fr")) + rcbFriday.Checked = true; + else if (day.Equals("Sa")) + rcbSaturday.Checked = true; + else if (day.Equals("Su")) + rcbSunday.Checked = true; + } + } + + private void PopulateFields() { + // clear previous values + SetResetWeekDays(false); + if (reportsDefinitions.ContainsKey(repHashKey)) { - // clear previous values - rcbMonday.Checked = false; - rcbTuesday.Checked = false; - rcbWednesday.Checked = false; - rcbThursday.Checked = false; - rcbFriday.Checked = false; - rcbSaturday.Checked = false; - rcbSunday.Checked = false; - + ReportDefinition report = reportsDefinitions[repHashKey]; // populate email field rtbEmail.Text = report.Email; // populate days field - String[] days = report.Day.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - foreach (String day in days) - { - if (day.Equals("Mo")) - rcbMonday.Checked = true; - if (day.Equals("Tu")) - rcbTuesday.Checked = true; - if (day.Equals("We")) - rcbWednesday.Checked = true; - if (day.Equals("Th")) - rcbThursday.Checked = true; - if (day.Equals("Fr")) - rcbFriday.Checked = true; - if (day.Equals("Sa")) - rcbSaturday.Checked = true; - if (day.Equals("Su")) - rcbSunday.Checked = true; - } + PopulateDaysField(report.Day); + - if (report.IsActive) - pbReportDaily.Tag = "enabled"; - else - pbReportDaily.Tag = "disabled"; + pbReportDaily.Tag = report.IsActive ? "enabled" : "disabled"; // enable or disable the email panel pbEnableDisable_Click(pbReportDaily, null); @@ -450,13 +519,6 @@ namespace Safedispatch_4_0 else { rtbEmail.Text = ""; - rcbMonday.Checked = false; - rcbTuesday.Checked = false; - rcbWednesday.Checked = false; - rcbThursday.Checked = false; - rcbFriday.Checked = false; - rcbSaturday.Checked = true; - rcbSunday.Checked = true; } // validate fields in order to enable or disable the save button @@ -512,20 +574,39 @@ namespace Safedispatch_4_0 for (int i = 0; i < e.MenuItems.Count; i++) { RadMenuItemBase menuItem = e.MenuItems[i]; - if (menuItem.Name == "CloseWindow" || - menuItem.Name == "CloseAllButThis" || - menuItem.Name == "CloseAll" || - menuItem.Name == "Floating" || - menuItem.Name == "Docked" || - menuItem.Name == "Hidden" || + if (menuItem.Name.Equals("CloseWindow") || + menuItem.Name.Equals("CloseAllButThis") || + menuItem.Name.Equals("CloseAll") || + menuItem.Name.Equals("Floating") || + menuItem.Name.Equals("Docked") || + menuItem.Name.Equals("Hidden") || menuItem is RadMenuSeparatorItem) { - menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; + menuItem.Visibility = ElementVisibility.Collapsed; } } } } + + private void PopulateFleetListForCheckedItems() + { + StaticMembers.FleetPosList = new ArrayList(); + if (pbUnitGroup.Tag.ToString().Equals("enabled")) + { + // checked items + foreach (RadCheckedListDataItem item in rcbUnitFleet2.CheckedItems.Where(x => x.Checked)) + { + StaticMembers.FleetPosList.Add(new FleetIdandPos + { + Name = item.Text, + Position = new ArrayList() + }); + + } + } + } + private void btPrintReport_Click(object sender, EventArgs e) { // hide no report panel @@ -538,32 +619,19 @@ namespace Safedispatch_4_0 { if (RepType == rep_type.FLEET) { - - StaticMembers.FleetPosList = new ArrayList(); - if (pbUnitGroup.Tag == "enabled") - { - foreach (RadCheckedListDataItem item in rcbUnitFleet2.CheckedItems) - { - if (item.Checked) - { - var tmp = new FleetIdandPos - { - Name = item.Text, - Position = new ArrayList() - }; - StaticMembers.FleetPosList.Add(tmp); - } - } - } + PopulateFleetListForCheckedItems(); } - if (((RepType == rep_type.HIST) && (ckComputeAddress.Checked)) || ((RepType == rep_type.SPEED) && (ckComputeAddress.Checked)) - /* - || ((RepType == rep_type.ENDOFDAY) && (ckComputeAddress.Checked)) - || ((RepType == rep_type.IDLE) && (ckComputeAddress.Checked)) - || ((RepType == rep_type.STOP) && (ckComputeAddress.Checked))*/ - || ((RepType == rep_type.TELEMETRY_ALARM) && (ckComputeAddress.Checked)) - || ((RepType == rep_type.TELEMETRY_EVENT) && (ckComputeAddress.Checked)) - || ((RepType == rep_type.SMS_LOCATION) && (ckComputeAddress.Checked))) + + if ((RepType == rep_type.HIST && ckComputeAddress.Checked) + || (RepType == rep_type.BATCH_HIST && ckComputeAddress.Checked) + || (RepType == rep_type.SPEED && ckComputeAddress.Checked) + /* + || ((RepType == rep_type.ENDOFDAY) && (ckComputeAddress.Checked)) + || ((RepType == rep_type.IDLE) && (ckComputeAddress.Checked)) + || ((RepType == rep_type.STOP) && (ckComputeAddress.Checked))*/ + || (RepType == rep_type.TELEMETRY_ALARM && ckComputeAddress.Checked) + || (RepType == rep_type.TELEMETRY_EVENT && ckComputeAddress.Checked) + || (RepType == rep_type.SMS_LOCATION && ckComputeAddress.Checked)) { ckComputeAddress.Visible = false; rlComputing.Visible = true; @@ -573,6 +641,7 @@ namespace Safedispatch_4_0 rtbEmail.Visible = false; //btPrintReport.Enabled = false; } + backDB.RunWorkerAsync(); ButtonStatusCancel = true; btPrintReport.Text = MainForm2.returnLNGString("canReport"); @@ -582,6 +651,7 @@ namespace Safedispatch_4_0 DialogResult dr; if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + dr = RadMessageBox.Show(this, MainForm2.returnLNGString("qReport"), MainForm2.returnLNGString("confirm"), MessageBoxButtons.YesNo, RadMessageIcon.Question); if (dr == DialogResult.Yes) { @@ -594,7 +664,9 @@ namespace Safedispatch_4_0 catch (Exception ex) { SM.Debug("Error on search reports : " + ex.ToString()); - if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) + ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + RadMessageBox.Show(MainForm2.returnLNGString("database"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Exclamation); } } @@ -604,10 +676,12 @@ namespace Safedispatch_4_0 Boolean Valid = true; if (((RepType == rep_type.ENDOFDAY) || (RepType == rep_type.STOP) || (RepType == rep_type.IDLE)) && (rdtFrom.Value.GetSecondsFromDT() > rdtUntil.Value.GetSecondsFromDT())) { - if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) + ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; RadMessageBox.Show(msgLimit); Valid = false; } + if (RepType == rep_type.IDLE) { try @@ -619,7 +693,8 @@ namespace Safedispatch_4_0 catch (Exception ex) { SM.Debug("Ex:" + ex.ToString()); - if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) + ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; RadMessageBox.Show(msgInteger); Valid = false; } @@ -632,6 +707,19 @@ namespace Safedispatch_4_0 private void CheckValue() { + + if (RepType == rep_type.BATCH_HIST) + return; + + + if (rcbUnitGroup.SelectedIndex < 0) + return; + + DropListItem dropListItem = UnitGroupItems[rcbUnitGroup.SelectedIndex]; + if (dropListItem == null) + return; + + glwhere = ""; if (this.ckUnitGroupFilter.Checked) { @@ -648,11 +736,13 @@ namespace Safedispatch_4_0 if (glwhere != "") glwhere = glwhere + " and "; else glwhere = " where "; } - if (RepType == rep_type.LOG) glwhere = glwhere + " imei IN (" + UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueImei + ") "; - else if (RepType == rep_type.SMS_LOCATION) glwhere = glwhere + " sc_id_sour IN (" + UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID + ") "; - else if (RepType == rep_type.JOB_TICKETING) glwhere = glwhere + " jt.sc_id IN (" + UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID + ") "; - else if (RepType == rep_type.HIST) Hisotry_sc_id = Convert.ToInt32(UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID); - else glwhere = glwhere + " sc_id IN (" + UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID + ") "; + + + if (RepType == rep_type.LOG) glwhere = glwhere + " imei IN (" + dropListItem.ValueImei + ") "; + else if (RepType == rep_type.SMS_LOCATION) glwhere = glwhere + " sc_id_sour IN (" + dropListItem.ValueScID + ") "; + else if (RepType == rep_type.JOB_TICKETING) glwhere = glwhere + " jt.sc_id IN (" + dropListItem.ValueScID + ") "; + else if (RepType == rep_type.HIST) Hisotry_sc_id = Convert.ToInt32(dropListItem.ValueScID); + else glwhere = glwhere + " sc_id IN (" + dropListItem.ValueScID + ") "; } if (this.ckStatus.Checked) @@ -679,6 +769,7 @@ namespace Safedispatch_4_0 if (rcbGeoLandName.Items.Count > 0) glwhere = glwhere + " zone_id = " + (((RadListDataItem)rcbGeoLandName.Items[rcbGeoLandName.SelectedIndex]).Value as VehandID).sc_id; else glwhere = glwhere + " zone_id != -1"; } + if (ckDataFilter.Checked) { if (RepType == rep_type.JOB_TICKETING) @@ -715,12 +806,14 @@ namespace Safedispatch_4_0 if (RepType != rep_type.HIST) glwhere = glwhere + " timeGMT >= " + rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT() + " and timeGMT <= " + rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); else { - Double Stop = 0, Start = 0; - Start = Hisotry_sc_id * 10000000000 + rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(); - Stop = Hisotry_sc_id * 10000000000 + rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); - String query = String.Format(" scevtime>{0} and scevtime<{1}", Start, Stop); - glwhere = glwhere + query; - glwhere += " AND sc_id IN (" + UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID + ") "; + //Double Stop = 0, Start = 0; + //Start = Hisotry_sc_id * 10000000000 + rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(); + //Stop = Hisotry_sc_id * 10000000000 + rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); + //String query = String.Format(" scevtime>{0} and scevtime<{1}", Start, Stop); + //glwhere = glwhere + query; + glwhere = glwhere + " timeGMT >= " + rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT() + " and timeGMT <= " + rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); + glwhere += $" AND sc_id = {dropListItem.ValueScID}"; + } } } @@ -738,7 +831,7 @@ namespace Safedispatch_4_0 { if (glwhere != "") glwhere = glwhere + " and "; else glwhere = " where "; - glwhere += " sc_id IN (" + UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID + ") "; + glwhere += " sc_id IN (" + dropListItem.ValueScID + ") "; } } } @@ -747,6 +840,7 @@ namespace Safedispatch_4_0 { //// TODO see what needs to be changed here in order for the LAT LNG to be displayed } + if (ckTicketing.Checked && rcbTicketing.Text != "") { string glwhereStatuses = ""; @@ -798,19 +892,26 @@ namespace Safedispatch_4_0 TicketDateType = null; if (UnitGroupItems.Count == 0) return; + + + DropListItem dropListItem = UnitGroupItems[rcbUnitGroup.SelectedIndex]; + if (this.ckUnitGroupFilter.Checked) { - if (RepType == rep_type.LOG) unit_ids = UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueImei; - else unit_ids = UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID; + + if (RepType == rep_type.LOG) + unit_ids = dropListItem.ValueImei; + else + unit_ids = dropListItem.ValueScID; } - if ((ckSelectALL.Checked) && (RepType == rep_type.HIST)) type = 1; - else type = 0; + type = ((ckSelectALL.Checked) && (RepType == rep_type.HIST)) ? 1 : 0; + - if ((ckSelectALL.Checked) && ((RepType == rep_type.HIST) || (RepType == rep_type.ALLALARM) || (RepType == rep_type.EMERG) || - (RepType == rep_type.SPEED) || (RepType == rep_type.TELEMETRY_ALARM) || (RepType == rep_type.TELEMETRY_EVENT) || - (RepType == rep_type.ENDOFDAY) || (RepType == rep_type.IDLE) || (RepType == rep_type.STOP))) - LatLng = true; + if (ckSelectALL.Checked && (RepType == rep_type.HIST || RepType == rep_type.BATCH_HIST || RepType == rep_type.ALLALARM || RepType == rep_type.EMERG || + RepType == rep_type.SPEED || RepType == rep_type.TELEMETRY_ALARM || RepType == rep_type.TELEMETRY_EVENT || + RepType == rep_type.ENDOFDAY || RepType == rep_type.IDLE || RepType == rep_type.STOP)) + LatLng = true; if (this.ckStatus.Checked) { @@ -820,14 +921,16 @@ namespace Safedispatch_4_0 } else { - if (rcbStatus.Items.Count > 0) geo_id = Int16.Parse(UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID); - else geo_id = 0; + geo_id = 0; + if (rcbStatus.Items.Count > 0) + geo_id = Int16.Parse(dropListItem.ValueScID); + } } if (this.ckGeofenceType.Checked) { - if ((RepType == rep_type.LAND) || (RepType == rep_type.GEOFENC)) + if (RepType == rep_type.LAND || RepType == rep_type.GEOFENC) { type = rcbGeoLandType.SelectedIndex + 1; } @@ -837,27 +940,40 @@ namespace Safedispatch_4_0 if (ckDataFilter.Checked) { startdate = rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(); - stopdate = rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); + stopdate = rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); } - if ((RepType == rep_type.ENDOFDAY) || (RepType == rep_type.IDLE) || (RepType == rep_type.STOP) || (RepType == rep_type.FLEET)) + + if (RepType == rep_type.ENDOFDAY || RepType == rep_type.IDLE || RepType == rep_type.STOP || RepType == rep_type.FLEET) { - startdate =rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(); - stopdate = rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); + startdate = rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(); + stopdate = rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); } + + if ((RepType == rep_type.ENDOFDAY) || (RepType == rep_type.IDLE) || (RepType == rep_type.STOP)) { - unit_ids = UnitGroupItems[rcbUnitGroup.SelectedIndex].ValueScID; + unit_ids = dropListItem.ValueScID; } + + //========= + //FLEET + //========= if (RepType == rep_type.FLEET) { + + idle_time = ckSelectALL.Checked ? 1 : 0; + + + // get comma separated unit_ids unit_ids = ""; - if (ckSelectALL.Checked) idle_time = 1; - else idle_time = 0; foreach (FleetIdandPos obj in StaticMembers.FleetPosList) { unit_ids += ((VehicleForReports)StaticMembers.vehicleHT[obj.Name]).sc_id.ToString() + ','; } } + //========= + // IDLE + //========= if (RepType == rep_type.IDLE) { try @@ -873,19 +989,27 @@ namespace Safedispatch_4_0 reportid = (Int32)RepType; reportType = RepType.ToString(); + //================== + // JOB_TICKETING + //================== if (RepType == rep_type.JOB_TICKETING) { if (ckDataFilter.Checked) { if (rcbTicketingTime.Items.Count() > 0) { + + // get comma separated values for ticketing foreach (CustomListDataItem item in rcbTicketingTime.Items) { - if (item.Checked) TicketDateType += item.Index + ","; + if (item.Checked) + TicketDateType += item.Index + ","; } TicketDateType = TicketDateType.Substring(0, TicketDateType.Length - 1); + } } + if (ckTicketing.Checked) { TicketStatus = rcbTicketing.Text.Trim().Substring(0, rcbTicketing.Text.Trim().Length - 1); @@ -895,28 +1019,20 @@ namespace Safedispatch_4_0 private void ckDataFilter_ToggleStateChanged(object sender, StateChangedEventArgs args) { - if (ckDataFilter.Checked) - { - rdtFrom.Enabled = true; - rdtUntil.Enabled = true; - } - else - { - rdtFrom.Enabled = false; - rdtUntil.Enabled = false; - } + + rdtFrom.Enabled = rdtUntil.Enabled = ckDataFilter.Checked; + } private void chStatus_ToggleStateChanged(object sender, StateChangedEventArgs args) { - if (this.ckStatus.Checked) this.rcbStatus.Enabled = true; - else this.rcbStatus.Enabled = false; + this.rcbStatus.Enabled = this.ckStatus.Checked; + } private void chVehName_ToggleStateChanged(object sender, StateChangedEventArgs args) { - if (this.ckUnitGroupFilter.Checked) this.rcbUnitGroup.Enabled = true; - else this.rcbUnitGroup.Enabled = false; + this.rcbUnitGroup.Enabled = this.ckUnitGroupFilter.Checked; } private void backDB_DoWork(object sender, DoWorkEventArgs e) @@ -925,6 +1041,83 @@ namespace Safedispatch_4_0 e.Result = ComputeDB(worker, e); } + + private SMposition getNearTheTime(object obj) + { + int sc_id = 0, timeGMT = 0; + + if (obj is ONOFFData) + { + sc_id = ((ONOFFData)obj).sc_id; + timeGMT = ((ONOFFData)obj).timeGMT; + } + else if (obj is SpeedData) + { + sc_id = ((SpeedData)obj).sc_id; + timeGMT = ((SpeedData)obj).timeGMT; + } + else if (obj is SMS_Location) + { + sc_id = ((SMS_Location)obj).sc_id; + timeGMT = ((SMS_Location)obj).timeGMT; + } + + + Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[sc_id]]).gps_interval; + if (step * 2 < 120) + step = 120; + else + step = step * 2; + + //gethistory + SMposition neartheTime = null; + ArrayList list = smdbObj.get_HistoryTelem(sc_id, timeGMT - step, timeGMT + step); + if (list.Count > 0) + { + foreach (SMposition obj2 in list) + { + if (neartheTime == null) + neartheTime = obj2; + else if (Math.Abs(neartheTime.m_time - timeGMT) > Math.Abs(obj2.m_time - timeGMT)) + neartheTime = obj2; + } + + } + + return neartheTime; + + } + + private List GetCheckedNodes(RadTreeNodeCollection nodes) + { + List checkedNodes = new List(); + + + foreach (RadTreeNode node in nodes) + { + + if (node.Parent != null && node.Checked) + { + checkedNodes.Add(node); // add node if checked + } + + if (node.Nodes.Count > 0) + { + // recursive function call + List childCheckedNodes = GetCheckedNodes(node.Nodes); + if (childCheckedNodes.Count > 0) + { + // append the results from recursive call + + checkedNodes.AddRange(childCheckedNodes); + } + } + } + + return checkedNodes; + } + + async Task ComputeDB(BackgroundWorker worker, DoWorkEventArgs e) { try @@ -932,7 +1125,7 @@ namespace Safedispatch_4_0 StaticMembers.LATLNGforDinamicReports = false; ValidReport = true; StaticMembers.ReportType = RepType; - if ((RepType != rep_type.FLEET) && (RepType != rep_type.ENDOFDAY) && (RepType != rep_type.STOP) && (RepType != rep_type.IDLE)) + if (RepType != rep_type.FLEET && RepType != rep_type.ENDOFDAY && RepType != rep_type.STOP && RepType != rep_type.IDLE) { CheckValue(); switch (RepType) @@ -941,10 +1134,12 @@ namespace Safedispatch_4_0 //smdbObj.get_log_view_all(glwhere); StaticMembers.ONOFFList = dbRep.get_log_view_all(glwhere, StaticMembers.is24hours, StaticMembers.DayFirst, MainForm2.VehIMEIHash); break; + case rep_type.EMERG: //smdbObj.get_EMERG(glwhere); StaticMembers.ONOFFList = dbRep.get_EMERG(glwhere, StaticMembers.is24hours, MainForm2.VehIDHash); rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), StaticMembers.ONOFFList.Count + (Int32)Math.Round(StaticMembers.ONOFFList.Count * 0.25)); + foreach (ONOFFData obj in StaticMembers.ONOFFList) { if (!ckCoordinates.Checked) @@ -954,35 +1149,24 @@ namespace Safedispatch_4_0 { try { - Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; - //gethistory - SMposition neartheTime = null; - ArrayList tmp = smdbObj.get_HistoryTelem(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step); - if (tmp.Count > 0) - { - foreach (SMposition obj2 in tmp) - { - try - { - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; - } - catch (Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } - } - if ((neartheTime.m_address == "") || (neartheTime.m_address == " ")) + SMposition nearTheTime = getNearTheTime(obj); + if (nearTheTime != null) + { + + + if ((nearTheTime.m_address == "") || (nearTheTime.m_address == " ")) { // compute addresses only if checked and no coordinates checked if (/*ckComputeAddress.Checked &&*/ !ckCoordinates.Checked) { - MainForm2.AddrCnt++; - MainForm2.AddrGISQueue.Enqueue(new AddrAndID(MainForm2.AddrCnt, neartheTime.m_lat, neartheTime.m_lng)); + MainForm2.AddrCnt++; + MainForm2.AddrGISQueue.Enqueue(new AddrAndID(MainForm2.AddrCnt, nearTheTime.m_lat, nearTheTime.m_lng)); StaticMembers.IdReportHS.Add(MainForm2.AddrCnt.ToString(), "no address"); String Idtofind = MainForm2.AddrCnt.ToString(); Boolean retrynew = true; Int32 cntmax = 0; + while (retrynew) { if (this.backDB.CancellationPending) @@ -1005,18 +1189,21 @@ namespace Safedispatch_4_0 } else obj.Status = ""; if ((obj.Status == "") || (obj.Status == " ")) - obj.Status = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); - else updateDB = true; + obj.Status = "LAT:" + Math.Round(nearTheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(nearTheTime.m_lng, 5).ToString(); + else + updateDB = true; } else { - obj.Status = neartheTime.m_address; + obj.Status = nearTheTime.m_address; updateDB = true; } } - else obj.Status = "N/A"; + else + obj.Status = "N/A"; //update datebase telemetry - if (updateDB) smdbObj.Update_address_emergency(obj.sc_id, obj.timeGMT, obj.Status.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); + if (updateDB) + smdbObj.Update_address_emergency(obj.sc_id, obj.timeGMT, obj.Status.Replace(',', ' '), nearTheTime.m_lat, nearTheTime.m_lng); } catch (Exception ex) { @@ -1029,40 +1216,47 @@ namespace Safedispatch_4_0 { if (((Int32)Math.Round(obj.lat) == 0) && ((Int32)Math.Round(obj.lng) == 0)) { - Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; - //gethistory - SMposition neartheTime = null; - ArrayList tmp = smdbObj.get_HistoryTelem(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step); - if (tmp.Count > 0) - { - foreach (SMposition obj2 in tmp) - { - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; - } - obj.Status = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); - //smdbObj.Update_address_emergency(obj.sc_id, obj.timeGMT, obj.Status.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); - } + SMposition nearTheTime = getNearTheTime(obj); + if(nearTheTime != null) + obj.Status = "LAT:" + Math.Round(nearTheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(nearTheTime.m_lng, 5).ToString(); + } + + else + { + obj.Status = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); } - else obj.Status = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); } rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); } break; + + case rep_type.BATCH_HIST: + + + string sc_ids = ""; + List checkednodes = GetCheckedNodes(radTreeUnits.Nodes); + if( checkednodes != null && checkednodes.Count > 0 ) + sc_ids = string.Join(",", checkednodes.Select(x => $"{x.Tag}")); + + StaticMembers.BatchHistoryReport = dbRep.getBatchHistory(sc_ids, rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(), rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(), MainForm2.isInMile, MainForm2.is24hours, 20000, ckComputeAddress.Checked, ckKeepValidPositions.Checked); + + break; + case rep_type.HIST: StaticMembers.IdReportHS.Clear(); //TODO //smdbObj.get_History(glwhere, ckComputeAddress.Checked, ckCoordinates.Checked); + StaticMembers.HistDataReport = dbRep.get_History(glwhere, ckComputeAddress.Checked, ckCoordinates.Checked, StaticMembers.is24hours, MainForm2.isInMile, ref MainForm2.cntaddr, ref MainForm2.AddrGISQueue, ref StaticMembers.IdReportHS); if (ckComputeAddress.Checked) { rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), StaticMembers.IdReportHS.Keys.Count + (Int32)Math.Round(StaticMembers.IdReportHS.Keys.Count * 0.25)); GisAddressWorker.RunWorkerAsync(); + retrynew = true; inwhile = false; int cntmax = 0; + if (StaticMembers.IdReportHS.Keys.Count > 0) { Int32 contNR = StaticMembers.IdReportHS.Keys.Count; @@ -1071,6 +1265,7 @@ namespace Safedispatch_4_0 retrynew = false; inwhile = false; } + while (retrynew) { if (this.backDB.CancellationPending) @@ -1083,10 +1278,15 @@ namespace Safedispatch_4_0 Thread.Sleep(1000); SM.Debug("Wait 1 second to update"); cntmax++; - if (cntmax > contNR) retrynew = false; + + if (cntmax > contNR) + retrynew = false; } - if (GisAddressWorker.IsBusy) GisAddressWorker.CancelAsync(); + + if (GisAddressWorker.IsBusy) + GisAddressWorker.CancelAsync(); } + try { foreach (StopData obj3 in StaticMembers.HistDataReport) @@ -1094,7 +1294,8 @@ namespace Safedispatch_4_0 if (StaticMembers.IdReportHS[obj3.Location] != null) { obj3.Location = (String)StaticMembers.IdReportHS[obj3.Location]; - if (!obj3.Location.Contains("no address")) smdbObj.Update_address_hist(obj3.Location, obj3.unique_id, obj3.Location); + if (!obj3.Location.Contains("no address")) + smdbObj.Update_address_hist(obj3.Location, obj3.unique_id, obj3.Location); } } } @@ -1107,27 +1308,29 @@ namespace Safedispatch_4_0 //MainForm2.HistDataReport = new List(); //MainForm2.HistDataReport.Add(tmp); break; + case rep_type.ALLALARM: //smdbObj.get_ALLAlarm(glwhere); StaticMembers.HistDataReport = dbRep.get_ALLAlarm(glwhere, StaticMembers.is24hours, MainForm2.isInMile, StaticMembers.DayFirst, MainForm2.VehIDHash, MainForm2.ZoneIDHash, MainForm2.LandIDHash, StaticMembers.vehicleHT, MainForm2.milesh, MainForm2.kmh); break; + case rep_type.GEOFENC: case rep_type.LAND: //MainForm2.LandList = dbRep.get_LANDANDZONE(glwhere, RepType); StaticMembers.LandList = dbRep.get_LANDANDZONE(glwhere, RepType, StaticMembers.is24hours, StaticMembers.DayFirst, MainForm2.VehIDHash, MainForm2.ZoneIDHash, MainForm2.LandIDHash); break; + case rep_type.TELEMETRY_EVENT: case rep_type.TELEMETRY_ALARM: - if (glwhere != "") - glwhere = glwhere + " and "; - else - glwhere = " where "; - if (RepType == rep_type.TELEMETRY_ALARM) glwhere = glwhere + " alarm =1 "; - else - glwhere = glwhere + " alarm >= 0 "; + + glwhere = string.IsNullOrEmpty(glwhere) ? " where " : glwhere + " and "; + glwhere += (RepType == rep_type.TELEMETRY_ALARM) ? " alarm = 1 " : " alarm >= 0 "; + //smdbObj.get_TelemHist_alarm_event(glwhere); StaticMembers.SpeedingList = dbRep.get_TelemHist_alarm_event(glwhere, MainForm2.VehIDHash, StaticMembers.vehicleHT); + // progress bar rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), StaticMembers.SpeedingList.Count + (Int32)Math.Round(StaticMembers.SpeedingList.Count * 0.25)); + foreach (SpeedData obj in StaticMembers.SpeedingList) { if (!ckCoordinates.Checked) @@ -1137,9 +1340,12 @@ namespace Safedispatch_4_0 { try { + Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; + if (step * 2 < 120) + step = 120; + else + step = step * 2; //gethistory SMposition neartheTime = null; ArrayList tmp = smdbObj.get_HistoryTelem(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step); @@ -1153,9 +1359,12 @@ namespace Safedispatch_4_0 return -1; } - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; + if (neartheTime == null) + neartheTime = obj2; + else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) + neartheTime = obj2; } + if ((neartheTime.m_address == "") || (neartheTime.m_address == " ")) { if (ckComputeAddress.Checked) @@ -1166,6 +1375,7 @@ namespace Safedispatch_4_0 String Idtofind = MainForm2.AddrCnt.ToString(); Boolean retrynew = true; Int32 cntmax = 0; + while (retrynew) { if (this.backDB.CancellationPending) @@ -1186,10 +1396,13 @@ namespace Safedispatch_4_0 if (cntmax > 10) retrynew = false; } } - else obj.Address = ""; + else + obj.Address = ""; + if ((obj.Address == "") || (obj.Address == " ")) obj.Address = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); - else updateDB = true; + else + updateDB = true; } else { @@ -1199,7 +1412,8 @@ namespace Safedispatch_4_0 } else obj.Address = "N/A"; //update datebase telemetry - if (updateDB) smdbObj.Update_address_telem(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); + if (updateDB) + smdbObj.Update_address_telem(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); } catch (Exception ex) { @@ -1211,28 +1425,22 @@ namespace Safedispatch_4_0 { if (((Int32)Math.Round(obj.lat) == 0) && ((Int32)Math.Round(obj.lng) == 0)) { - Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; - //gethistory - SMposition neartheTime = null; - ArrayList tmp = smdbObj.get_HistoryTelem(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step); - if (tmp.Count > 0) + + SMposition neartheTime = getNearTheTime(obj); + if (neartheTime != null) { - foreach (SMposition obj2 in tmp) - { - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; - } obj.Address = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); smdbObj.Update_address_telem(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); } + } - else obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); + else + obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); } rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); } break; + case rep_type.SPEED: //smdbObj.get_Speeding(glwhere); StaticMembers.SpeedingList = dbRep.get_Speeding(glwhere, StaticMembers.is24hours, MainForm2.isInMile, MainForm2.VehIDHash); @@ -1255,6 +1463,7 @@ namespace Safedispatch_4_0 MainForm2.IdReportHS.Add(MainForm2.AddrCnt.ToString(), "no address"); String Idtofind = MainForm2.AddrCnt.ToString(); Boolean retrynew = true; + Int32 cntmax = 0; while (retrynew) { @@ -1272,15 +1481,23 @@ namespace Safedispatch_4_0 SM.Debug("Wait 200msec"); retrynew = true; } - else obj.Address = (String)MainForm2.IdReportHS[Idtofind]; - if (cntmax > 10) retrynew = false; + else + obj.Address = (String)MainForm2.IdReportHS[Idtofind]; + + if (cntmax > 10) + retrynew = false; } } - else obj.Address = ""; + else + obj.Address = ""; + if ((obj.Address == "") || (obj.Address == " ")) obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); - else updateDB = true; - if (updateDB) smdbObj.Update_address_speed(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), obj.lat, obj.lng); + else + updateDB = true; + + if (updateDB) + smdbObj.Update_address_speed(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), obj.lat, obj.lng); } catch (Exception ex) { @@ -1292,32 +1509,27 @@ namespace Safedispatch_4_0 { if (((Int32)Math.Round(obj.lat) == 0) && ((Int32)Math.Round(obj.lng) == 0)) { - Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; - //gethistory - SMposition neartheTime = null; - ArrayList tmp = smdbObj.get_HistoryTelem(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step); - if (tmp.Count > 0) + + SMposition neartheTime = getNearTheTime(obj); + if (neartheTime != null) { - foreach (SMposition obj2 in tmp) - { - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; - } obj.Address = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); smdbObj.Update_address_speed(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); } + } - else obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); + else + obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); } rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); } break; + case rep_type.SMS_LOCATION: //smdbObj.get_SMS_Location(glwhere); StaticMembers.SMSLocList = dbRep.get_SMS_Location(glwhere, StaticMembers.is24hours, MainForm2.VehIDHash); rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), StaticMembers.SMSLocList.Count + (Int32)Math.Round(StaticMembers.SMSLocList.Count * 0.25)); + foreach (SMS_Location obj in StaticMembers.SMSLocList) { if (!ckCoordinates.Checked) @@ -1327,19 +1539,11 @@ namespace Safedispatch_4_0 { try { - Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; - //gethistory - SMposition neartheTime = null; - ArrayList tmp = smdbObj.get_HistorySpeed(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step, obj.timeGMT); - if (tmp.Count > 0) + + SMposition neartheTime = getNearTheTime(obj); + if (neartheTime != null) { - foreach (SMposition obj2 in tmp) - { - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; - } + if ((neartheTime.m_address == "") || (neartheTime.m_address == " ")) { if (ckComputeAddress.Checked) @@ -1370,10 +1574,13 @@ namespace Safedispatch_4_0 if (cntmax > 10) retrynew = false; } } - else obj.Address = ""; + else + obj.Address = ""; + if ((obj.Address == "") || (obj.Address == " ")) obj.Address = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); - else updateDB = true; + else + updateDB = true; } else { @@ -1381,9 +1588,12 @@ namespace Safedispatch_4_0 updateDB = true; } } - else obj.Address = "N/A"; + else + obj.Address = "N/A"; + //update datebase Speed - if (updateDB) smdbObj.Update_address_SMS_Location(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); + if (updateDB) + smdbObj.Update_address_SMS_Location(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '), neartheTime.m_lat, neartheTime.m_lng); } catch (Exception ex) { @@ -1395,28 +1605,21 @@ namespace Safedispatch_4_0 { if (((Int32)Math.Round(obj.lat) == 0) && ((Int32)Math.Round(obj.lng) == 0)) { - Int32 step = ((VehicleForReports)StaticMembers.vehicleHT[(String)MainForm2.VehIDHash[obj.sc_id]]).gps_interval; - if (step * 2 < 120) step = 120; - else step = step * 2; - //gethistory - SMposition neartheTime = null; - ArrayList tmp = smdbObj.get_HistoryTelem(obj.sc_id, obj.timeGMT - step, obj.timeGMT + step); - if (tmp.Count > 0) - { - foreach (SMposition obj2 in tmp) - { - if (neartheTime == null) neartheTime = obj2; - else if (Math.Abs(neartheTime.m_time - obj.timeGMT) > Math.Abs(obj2.m_time - obj.timeGMT)) neartheTime = obj2; - } + + SMposition neartheTime = getNearTheTime(obj); + if (neartheTime != null) + { obj.Address = "LAT:" + Math.Round(neartheTime.m_lat, 5).ToString() + " , LNG:" + Math.Round(neartheTime.m_lng, 5).ToString(); smdbObj.Update_address_SMS_Location(obj.sc_id, obj.timeGMT, "no address", neartheTime.m_lat, neartheTime.m_lng); } } - else obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); + else + obj.Address = "LAT:" + Math.Round(obj.lat, 5).ToString() + " , LNG:" + Math.Round(obj.lng, 5).ToString(); } rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); } break; + case rep_type.JOB_TICKETING: StaticMembers.SpeedingList = dbRep.get_Ticketing(glwhere, StaticMembers.is24hours); break; @@ -1452,10 +1655,10 @@ namespace Safedispatch_4_0 // get the list of positions that needs to be computed List toCompute = isComputingNeeded ? StaticMembers.PositionList.Cast() - .Where(d => (d.Address == null || d.Address.Trim().Length < 1)).ToList() : new List(); + .Where(d => (d.Address == null || d.Address.Trim().Length < 1)).ToList() : new List(); List notToCompute = isComputingNeeded ? StaticMembers.PositionList.Cast().Where(d => (d.Address != null && d.Address.Trim().Length > 0)).ToList() : - StaticMembers.PositionList.Cast().ToList(); + StaticMembers.PositionList.Cast().ToList(); List computedAddresses = new List(); @@ -1494,27 +1697,32 @@ namespace Safedispatch_4_0 if (RepType == rep_type.FLEET) { - // the display all logic is applied when no unit was selected + // the display all logic is applied when no unit was selected if (StaticMembers.FleetPosList.Count == 0) { - if (rcbUnitFleet2.CheckedItems.Count == 0 || pbUnitGroup.Tag != "enabled") + if (rcbUnitFleet2.CheckedItems.Count == 0 || !pbUnitGroup.Tag.ToString().Equals("enabled")) { foreach (RadCheckedListDataItem item in rcbUnitFleet2.Items) { - var tmp = new FleetIdandPos - { - Name = item.Text, - Position = new ArrayList() - }; - StaticMembers.FleetPosList.Add(tmp); + StaticMembers.FleetPosList.Add( new FleetIdandPos + { + Name = item.Text, + Position = new ArrayList() + }); } } } + Int32 from = (Int32)(rdtFrom.Value.GetSecondsLocalFromDT()); + Int32 until = (Int32)(rdtUntil.Value.GetSecondsLocalFromDT()); + foreach (FleetIdandPos obj in StaticMembers.FleetPosList) { + + int sc_id = ((VehicleForReports)StaticMembers.vehicleHT[obj.Name]).sc_id; + //obj.Position = smdbObj.get_position_for_report((Int32)(new ConvertDT().GetSecondsLocalFromDT(dtFrom.Value)) - dtFrom.Value.Hour * 3600 - dtFrom.Value.Minute * 60 - dtFrom.Value.Second, (Int32)(new ConvertDT().GetSecondsLocalFromDT(dtTo.Value)) - dtTo.Value.Hour * 3600 - dtTo.Value.Minute * 60 - dtTo.Value.Second + 86400, ((Vehicle)MainForm2.vehicleHT[obj.Name]).sc_id); - obj.Position = dbRep.get_position_for_report((Int32)(rdtFrom.Value.GetSecondsLocalFromDT()), (Int32)(rdtUntil.Value.GetSecondsLocalFromDT()), ((VehicleForReports)StaticMembers.vehicleHT[obj.Name]).sc_id); + obj.Position = dbRep.get_position_for_report(from, until, sc_id); SM.Debug(obj.Name + " " + obj.Position.Count); } } @@ -1528,6 +1736,13 @@ namespace Safedispatch_4_0 return 1; } + private List CalculateAdresses(List list ) + { + ReverseGeocodingModule.osnServer = MainForm2.cfg.ReverseGeoOSM; + return ReverseGeocodingModule.CalculateAddressForPositions(list); + } + + private void backDB_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { switch (RepType) @@ -1566,17 +1781,22 @@ namespace Safedispatch_4_0 tmp.statusCaptionTextBox.Value = MainForm2.returnLNGString("SMSStatus"); tmp.nameCaptionTextBox.Value = MainForm2.returnLNGString("htableVehiclesListColumns1"); reportViewer1.ReportSource = tmp; + break; case rep_type.SPEED: + rlComputing.Visible = false; rProgressBar.Visible = false; ckReportDaily.Visible = true; rtbEmail.Visible = true; ckComputeAddress.Visible = true; + + + + //SpeedingReport SpeedingReport tmpSpeed = new SpeedingReport(); tmpSpeed.nameCaptionTextBox.Value = MainForm2.returnLNGString("htableVehiclesListColumns1"); - if (MainForm2.isInMile) tmpSpeed.speedCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.milesh + ")"; - else tmpSpeed.speedCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.kmh + ")"; + tmpSpeed.speedCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + (MainForm2.isInMile ? MainForm2.milesh : MainForm2.kmh) + ")"; tmpSpeed.timeCaptionTextBox.Value = MainForm2.returnLNGString("alarmsListColumns1"); tmpSpeed.titleTextBox.Value = MainForm2.returnLNGString("speedalarm"); tmpSpeed.Name = tmpSpeed.titleTextBox.Value; @@ -1584,13 +1804,16 @@ namespace Safedispatch_4_0 tmpSpeed.addressCaptionTextBox.Value = MainForm2.returnLNGString("addrOrLatLng"); tmpSpeed.txObeserv.Value = MainForm2.returnLNGString("obsSpeed"); tmpSpeed.graph1.Visible = true; + reportViewer1.ReportSource = tmpSpeed; + if (StaticMembers.SpeedingList.Count > 40000) { if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; DialogResult dr = RadMessageBox.Show(this, MainForm2.returnLNGString("limit65000"), MainForm2.returnLNGString("info"), MessageBoxButtons.OK, RadMessageIcon.Info); } + break; case rep_type.TELEMETRY_EVENT: case rep_type.TELEMETRY_ALARM: @@ -1619,6 +1842,7 @@ namespace Safedispatch_4_0 tmpTelem.graph1.Visible = false; tmpTelem.reportFooterSection1.Height = Telerik.Reporting.Drawing.Unit.Pixel(1); reportViewer1.ReportSource = tmpTelem; + break; case rep_type.GEOFENC: ZoneReport tmpZone = new ZoneReport(); @@ -1629,6 +1853,7 @@ namespace Safedispatch_4_0 tmpZone.titleTextBox.Value = MainForm2.returnLNGString("InZoneReport"); tmpZone.Name = tmpZone.titleTextBox.Value; reportViewer1.ReportSource = tmpZone; + break; case rep_type.LAND: ZoneReport tmpLand = new ZoneReport(); @@ -1639,6 +1864,7 @@ namespace Safedispatch_4_0 tmpLand.titleTextBox.Value = MainForm2.returnLNGString("landmarkrep"); tmpLand.Name = tmpLand.titleTextBox.Value; reportViewer1.ReportSource = tmpLand; + break; case rep_type.EMERG: ONOFFReport tmpEmerg = new ONOFFReport(); @@ -1648,6 +1874,31 @@ namespace Safedispatch_4_0 tmpEmerg.statusCaptionTextBox.Value = MainForm2.returnLNGString("addrOrLatLng"); tmpEmerg.nameCaptionTextBox.Value = MainForm2.returnLNGString("htableVehiclesListColumns1"); reportViewer1.ReportSource = tmpEmerg; + + break; + case rep_type.BATCH_HIST: + if (ckComputeAddress.Checked) + { + //btPrintReport.Enabled = true; + rlComputing.Visible = false; + rProgressBar.Visible = false; + ckReportDaily.Visible = true; + rtbEmail.Visible = true; + ckComputeAddress.Visible = true; + ckKeepValidPositions.Visible = true; + } + + BatchHistoryReport batchHistoryReport = new BatchHistoryReport(); + + batchHistoryReport.titleTextBox.Value = MainForm2.returnLNGString("BatchHistoryRep"); + batchHistoryReport.dateCaptionTextBox.Value = MainForm2.returnLNGString("Date"); + batchHistoryReport.timeCaptionTextBox.Value = MainForm2.returnLNGString("Time"); + batchHistoryReport.locationCaptionTextBox.Value = MainForm2.returnLNGString("location"); + + batchHistoryReport.speedCaptionTextBox.Value = MainForm2.returnLNGString("Speed") + " (" + (MainForm2.isInMile ? MainForm2.milesh : MainForm2.kmh) + ")"; + + reportViewer1.ReportSource = batchHistoryReport; + break; case rep_type.HIST: StaticMembers.IsHistroyNotStop = true; @@ -1683,55 +1934,59 @@ namespace Safedispatch_4_0 { if (StaticMembers.HistDataReport.Count > 10000) { - if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) + ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; + DialogResult dr = RadMessageBox.Show(this, MainForm2.returnLNGString("limit10000"), MainForm2.returnLNGString("info"), MessageBoxButtons.OK, RadMessageIcon.Info); StaticMembers.HistDataReport.RemoveRange(10000, StaticMembers.HistDataReport.Count - 10000); } + /// SINGLE UNIT REPORT StopReport tmpRep2 = new StopReport(); //tmpRep2.titleTextBox.Value = MainForm2.returnLNGString("namesandvehicleHistory") + " " + cbVehName.Text; // set title - if (ckUnitGroupFilter.Checked) tmpRep2.titleTextBox.Value = MainForm2.returnLNGString("HistoryRep") + " " + + if (ckUnitGroupFilter.Checked) + tmpRep2.titleTextBox.Value = MainForm2.returnLNGString("HistoryRep") + " " + (UnitGroupItems[rcbUnitGroup.SelectedIndex].IsGroup ? MainForm2.returnLNGString("forGroup") : MainForm2.returnLNGString("forvehicle")) + " " + rcbUnitGroup.Text; - else tmpRep2.titleTextBox.Value = MainForm2.returnLNGString("HistoryRep"); + else + tmpRep2.titleTextBox.Value = MainForm2.returnLNGString("HistoryRep"); + tmpRep2.Name = tmpRep2.titleTextBox.Value; // set address tmpRep2.locationCaptionTextBox.Value = MainForm2.returnLNGString("addrOrLatLng"); - - // set speed - if (MainForm2.isInMile) tmpRep2.durationCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.milesh + ")"; - else tmpRep2.durationCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.kmh + ")"; - - + tmpRep2.durationCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + (MainForm2.isInMile ? MainForm2.milesh : MainForm2.kmh) + ")"; tmpRep2.timeCaptionTextBox.Value = MainForm2.returnLNGString("label3"); tmpRep2.dataCaptionTextBox.Value = MainForm2.returnLNGString("dateSTOP"); reportViewer1.ReportSource = tmpRep2; } - else { //MainForm2.SpeedingList = new List(); Int32 countdata = 0; foreach (StopData obj in StaticMembers.HistDataReport) { - SpeedData tmpSpeedData = new SpeedData(); - tmpSpeedData.Name = obj.unit_name; - tmpSpeedData.Speed = obj.Duration; - tmpSpeedData.Time = obj.Time; - tmpSpeedData.Data = obj.Data; - tmpSpeedData.Address = obj.Location; + //SpeedData tmpSpeedData = new SpeedData() + //{ + // Name = obj.unit_name, + // Speed = obj.Duration, + // Time = obj.Time, + // Data = obj.Data, + // Address = obj.Location + //}; + //MainForm2.SpeedingList.Add(tmpSpeedData); countdata++; if (countdata > 50000) break; } Console.WriteLine("End of transfer DATA"); + + // SpeedingReport SpeedingReport tmpGroupHistoryReport = new SpeedingReport(); - // set title tmpGroupHistoryReport.titleTextBox.Value = MainForm2.returnLNGString("HistoryRep") + " " + MainForm2.returnLNGString("forGroup") + " " + rcbUnitGroup.Text; // set report name @@ -1740,8 +1995,7 @@ namespace Safedispatch_4_0 tmpGroupHistoryReport.addressCaptionTextBox.Value = MainForm2.returnLNGString("addrOrLatLng"); // set speed - if (MainForm2.isInMile) tmpGroupHistoryReport.speedCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.milesh + ")"; - else tmpGroupHistoryReport.speedCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.kmh + ")"; + tmpGroupHistoryReport.speedCaptionTextBox.Value = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + (MainForm2.isInMile ? MainForm2.milesh : MainForm2.kmh) + ")"; // set unit name tmpGroupHistoryReport.nameCaptionTextBox.Value = MainForm2.returnLNGString("htableVehiclesListColumns1"); @@ -1756,6 +2010,7 @@ namespace Safedispatch_4_0 //tmpGroupHistoryReport.txObeserv.Value = MainForm2.returnLNGString("obsSpeed"); reportViewer1.ReportSource = tmpGroupHistoryReport; + if (countdata > 50000) { if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; @@ -1766,10 +2021,14 @@ namespace Safedispatch_4_0 case rep_type.ALLALARM: StaticMembers.IsHistroyNotStop = true; StopReport tmpRep3 = new StopReport(); - if (ckUnitGroupFilter.Checked) tmpRep3.titleTextBox.Value = MainForm2.returnLNGString("allAlarmTitle") + " " + + if (ckUnitGroupFilter.Checked) + + tmpRep3.titleTextBox.Value = MainForm2.returnLNGString("allAlarmTitle") + " " + (UnitGroupItems[rcbUnitGroup.SelectedIndex].IsGroup ? MainForm2.returnLNGString("forGroup") : MainForm2.returnLNGString("forvehicle")) + " " + rcbUnitGroup.Text; - else tmpRep3.titleTextBox.Value = MainForm2.returnLNGString("allAlarmTitle"); + else + tmpRep3.titleTextBox.Value = MainForm2.returnLNGString("allAlarmTitle"); + tmpRep3.Name = tmpRep3.titleTextBox.Value; tmpRep3.timeCaptionTextBox.Value = MainForm2.returnLNGString("alarmtype"); tmpRep3.locationCaptionTextBox.Value = MainForm2.returnLNGString("SMSMessTime"); @@ -1842,6 +2101,7 @@ namespace Safedispatch_4_0 reportViewer1.ReportSource = tmpFleet; } break; + case rep_type.SMS_LOCATION: rlComputing.Visible = false; rProgressBar.Visible = false; @@ -1859,6 +2119,7 @@ namespace Safedispatch_4_0 reportViewer1.ReportSource = tmpSMSLoc; } break; + case rep_type.JOB_TICKETING: //rlComputing.Visible = false; //rProgressBar.Visible = false; @@ -1891,17 +2152,10 @@ namespace Safedispatch_4_0 private void ckSelectALL_ToggleStateChanged(object sender, StateChangedEventArgs args) { - if (ckSelectALL.Checked) - { + foreach (RadCheckedListDataItem item in rcbUnitFleet2.Items) - item.Checked = true; + item.Checked = ckSelectALL.Checked; //cbVehNameFleet.SelectedItems.Add(((CustomListDataItem)cbVehNameFleet.Items[i])); - } - else - { - foreach (RadCheckedListDataItem item in rcbUnitFleet2.Items) - item.Checked = false; - } } private void ReportsControl_Load(object sender, EventArgs e) @@ -1991,14 +2245,17 @@ namespace Safedispatch_4_0 { tmpAddrAndID.LNG = Math.Round(tmpAddrAndID.LNG, 4); tmpAddrAndID.LAT = Math.Round(tmpAddrAndID.LAT, 4); + valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; if (MainForm2.AddrHass[valHash] != null) { + // get address from hashtable tmpAddrAndID.Address = (String)MainForm2.AddrHass[valHash]; findaddress = true; } else { + // get address from database AddrtmpX = smdbObj.get_address(tmpAddrAndID.LAT, tmpAddrAndID.LNG); if (AddrtmpX != "") { @@ -2012,8 +2269,11 @@ namespace Safedispatch_4_0 { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } + + if (!findaddress) { + // get address from reverse geocoding tmpAddrAndID.Address = volltmpGo.getAddressLATLNG(tmpAddrAndID.LAT, tmpAddrAndID.LNG); } @@ -2026,9 +2286,12 @@ namespace Safedispatch_4_0 if (tmpAddrAndID.Address != "N/A") { valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; + + // save in hashtable MainForm2.AddrHass.Add(valHash, tmpAddrAndID.Address); AddrtmpX = smdbObj.get_address(tmpAddrAndID.LAT, tmpAddrAndID.LNG); //just for avoid Error from Event Viewer - if (AddrtmpX == "") smdbObj.Insert_Address(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); + if (AddrtmpX == "") + smdbObj.Insert_Address(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); // save in database } } catch (Exception ex) @@ -2036,49 +2299,21 @@ namespace Safedispatch_4_0 SM.Debug("Error: " + ex.ToString()); } } + StaticMembers.IdReportHS[tmpAddrAndID.ID.ToString()] = tmpAddrAndID.Address; - if (inwhile) rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); - SM.Debug("Baga google in hash ID:" + tmpAddrAndID.ID.ToString() + "Addr:" + tmpAddrAndID.Address); - } - else - { - //dau in open street maps si apoi ies prin prin cene - Thread.Sleep(1100); - tmpAddrAndID.Address = volltmpGo.getAddressLATLNG2(tmpAddrAndID.LAT, tmpAddrAndID.LNG); - if ((tmpAddrAndID.Address != "") && (tmpAddrAndID.Address != " ")) - { - if (!findaddress) - { - try - { - if (tmpAddrAndID.Address != "N/A") - { - valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001; - MainForm2.AddrHass.Add(valHash, tmpAddrAndID.Address); - AddrtmpX = smdbObj.get_address(tmpAddrAndID.LAT, tmpAddrAndID.LNG); //just for avoid Error from Event Viewer - if (AddrtmpX == "") smdbObj.Insert_Address(tmpAddrAndID.Address, tmpAddrAndID.LAT, tmpAddrAndID.LNG); - } - } - catch (Exception ex) - { - SM.Debug("Error: " + ex.ToString()); - } - } - StaticMembers.IdReportHS[tmpAddrAndID.ID.ToString()] = tmpAddrAndID.Address; - if (inwhile) rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); - SM.Debug("Baga open street maps in hash ID:" + tmpAddrAndID.ID.ToString() + "Addr:" + tmpAddrAndID.Address); - } - else - { - SM.Debug("Iese prin Cene cu nimic"); - } + if (inwhile) + rProgressBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); + + } + } } catch (Exception ex) { SM.Debug("Error retrive address:" + ex.ToString()); } + Thread.Sleep(10); } @@ -2105,9 +2340,7 @@ namespace Safedispatch_4_0 private void cbDaily_ToggleStateChanged(object sender, StateChangedEventArgs args) { - if (ckReportDaily.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) - btSaveEmail.Enabled = true; - else btSaveEmail.Enabled = false; + btSaveEmail.Enabled = (ckReportDaily.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On); } private void btSaveEmail_Click(object sender, EventArgs e) @@ -2142,6 +2375,7 @@ namespace Safedispatch_4_0 repHashKey = reportid + "-" + unit_ids; if (reportsDefinitions.ContainsKey(repHashKey)) repId = reportsDefinitions[repHashKey].Idx; + // insert or update report into DB ReportDefinition rep = smdbObj.Insert_Report(startdate, stopdate, unit_ids, geo_id, type, idle_time, reportid, rtbEmail.Text, LatLng,TicketStatus,TicketDateType, days, RepType.ToString(), true, repId); @@ -2169,13 +2403,13 @@ namespace Safedispatch_4_0 /// Handles the picture box click for simulating a checkbox and to /// enable/disable other panels /// - private Image themeDateTime_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_time, MainForm2.ButtonColor); - private Image themeUnitGroup_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_user, MainForm2.ButtonColor); - private Image themeEmail_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_email, MainForm2.ButtonColor); - private Image themeGeofence_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_geofence, MainForm2.ButtonColor); - private Image themeGeoType_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_type, MainForm2.ButtonColor); - private Image themeStatus_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_status, MainForm2.ButtonColor); - private Image themeTicketing_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.r_ticketing, MainForm2.ButtonColor); + private Image themeDateTime_Image = Utils.ChangeColor(resources.r_time, MainForm2.ButtonColor); + private Image themeUnitGroup_Image = Utils.ChangeColor(resources.r_user, MainForm2.ButtonColor); + private Image themeEmail_Image = Utils.ChangeColor(resources.r_email, MainForm2.ButtonColor); + private Image themeGeofence_Image = Utils.ChangeColor(resources.r_geofence, MainForm2.ButtonColor); + private Image themeGeoType_Image = Utils.ChangeColor(resources.r_type, MainForm2.ButtonColor); + private Image themeStatus_Image = Utils.ChangeColor(resources.r_status, MainForm2.ButtonColor); + private Image themeTicketing_Image = Utils.ChangeColor(resources.r_ticketing, MainForm2.ButtonColor); private void pbEnableDisable_Click(object sender, EventArgs e) { @@ -2186,7 +2420,7 @@ namespace Safedispatch_4_0 if (pbDateTime.Tag.Equals("disabled")) { pbDateTime.Tag = "enabled"; - pbDateTime.Image = Dispatcher.Properties.Resources.r_time_d; + pbDateTime.Image = resources.r_time_d; rdtFrom.Enabled = true; rdtUntil.Enabled = true; @@ -2211,7 +2445,7 @@ namespace Safedispatch_4_0 if (pbUnitGroup.Tag.Equals("disabled")) { pbUnitGroup.Tag = "enabled"; - pbUnitGroup.Image = Dispatcher.Properties.Resources.r_user_d; + pbUnitGroup.Image = resources.r_user_d; rcbUnitGroup.Enabled = true; rcbUnitFleet2.Enabled = true; @@ -2239,7 +2473,7 @@ namespace Safedispatch_4_0 if (pbReportDaily.Tag.Equals("disabled")) { pbReportDaily.Tag = "enabled"; - pbReportDaily.Image = Dispatcher.Properties.Resources.r_email_d; + pbReportDaily.Image = resources.r_email_d; rgbReport.Enabled = true; ckReportDaily.Checked = true; @@ -2273,7 +2507,7 @@ namespace Safedispatch_4_0 if (pbGeofenceName.Tag.Equals("disabled")) { pbGeofenceName.Tag = "enabled"; - pbGeofenceName.Image = Dispatcher.Properties.Resources.r_geofence_d; + pbGeofenceName.Image = resources.r_geofence_d; rcbGeoLandName.Enabled = true; ckGeofenceName.Checked = true; } @@ -2291,7 +2525,7 @@ namespace Safedispatch_4_0 if (pbGeofenceType.Tag.Equals("disabled")) { pbGeofenceType.Tag = "enabled"; - pbGeofenceType.Image = Dispatcher.Properties.Resources.r_type_d; + pbGeofenceType.Image = resources.r_type_d; rcbGeoLandType.Enabled = true; ckGeofenceType.Checked = true; } @@ -2309,7 +2543,7 @@ namespace Safedispatch_4_0 if (pbStatus.Tag.Equals("disabled")) { pbStatus.Tag = "enabled"; - pbStatus.Image = Dispatcher.Properties.Resources.r_status_d; + pbStatus.Image = resources.r_status_d; radPanelStatus.Enabled = true; ckStatus.Checked = true; } @@ -2327,7 +2561,7 @@ namespace Safedispatch_4_0 if (pbTicketing.Tag.Equals("disabled")) { pbTicketing.Tag = "enabled"; - pbTicketing.Image = Dispatcher.Properties.Resources.r_ticketing_d; + pbTicketing.Image = resources.r_ticketing_d; rcbTicketing.Enabled = true; ckTicketing.Checked = true; } @@ -2359,20 +2593,20 @@ namespace Safedispatch_4_0 try { - List addressPanelVisible = new List() { rep_type.SPEED, rep_type.HIST, rep_type.TELEMETRY_ALARM, rep_type.TELEMETRY_EVENT, rep_type.SMS_LOCATION, + List addressPanelVisible = new List() { rep_type.SPEED, rep_type.HIST, rep_type.BATCH_HIST, rep_type.TELEMETRY_ALARM, rep_type.TELEMETRY_EVENT, rep_type.SMS_LOCATION, /*rep_type.STOP, rep_type.IDLE, rep_type.ENDOFDAY*/ }; List landmarkPanelVisible = new List() { rep_type.LAND, rep_type.GEOFENC }; - List latLngPanelVisible = new List() { rep_type.SPEED, rep_type.EMERG, rep_type.HIST, rep_type.ENDOFDAY, rep_type.IDLE, + List latLngPanelVisible = new List() { rep_type.SPEED, rep_type.EMERG, rep_type.HIST, rep_type.BATCH_HIST, rep_type.ENDOFDAY, rep_type.IDLE, rep_type.STOP, rep_type.TELEMETRY_ALARM, rep_type.TELEMETRY_EVENT, rep_type.SMS_LOCATION }; List statusPanelVisible = new List() { rep_type.LOG }; List idlePanelVisible = new List() { rep_type.IDLE }; //remove selectAllPanel for fleet List selectAllPanelVisible = new List() { /*rep_type.FLEET*/ }; - List unitMandatory = new List() { rep_type.HIST, rep_type.ENDOFDAY, rep_type.IDLE, rep_type.STOP /*, rep_type.FLEET*/ }; + List unitMandatory = new List() { rep_type.HIST, rep_type.BATCH_HIST, rep_type.ENDOFDAY, rep_type.IDLE, rep_type.STOP /*, rep_type.FLEET*/ }; List dateMandatory = new List() { rep_type.ENDOFDAY, rep_type.IDLE, rep_type.STOP, rep_type.FLEET }; - List progressBarSpace = new List() { rep_type.SPEED, rep_type.HIST, rep_type.TELEMETRY_ALARM, rep_type.TELEMETRY_EVENT }; + List progressBarSpace = new List() { rep_type.SPEED, rep_type.HIST, rep_type.BATCH_HIST, rep_type.TELEMETRY_ALARM, rep_type.TELEMETRY_EVENT }; List ticketingPanelVisible = new List() { rep_type.JOB_TICKETING }; // show hide pannels @@ -2408,8 +2642,10 @@ namespace Safedispatch_4_0 ZoneListNames.Sort(new VehandIDComparer()); rcbStatus.DataSource = ZoneListNames; rcbStatus.DisplayMember = "Name"; + if (rcbStatus.Items.Count >= 1) rcbStatus.SelectedIndex = 0; + if (rcbGeoLandType.Items.Count >= 1) rcbGeoLandType.SelectedIndex = 0; @@ -2431,6 +2667,7 @@ namespace Safedispatch_4_0 radPanelGeofence.Visible = false; } + // make unit mandatory if (unitMandatory.Contains(reportType)) { @@ -2443,6 +2680,7 @@ namespace Safedispatch_4_0 pbUnitGroup.Visible = pbDateTime.Visible = true; pbUnitGroup.Tag = pbDateTime.Tag = "enabled"; } + pbReportDaily.Tag = pbGeofenceName.Tag = pbGeofenceType.Tag = pbTicketing.Tag = "enabled"; pbEnableDisable_Click(pbUnitGroup, null); pbEnableDisable_Click(pbDateTime, null); @@ -2508,6 +2746,28 @@ namespace Safedispatch_4_0 } else radPanelTicketing.Visible = false; + + + if (reportType == rep_type.BATCH_HIST) + { + rcbUnitGroup.Visible = false; + pbUnitGroup.Visible = false; + rlUnitGroup.Visible = false; + ckUnitGroupFilter.Visible = false; + + radTreeUnits.Visible = true; + btPrintReportInCsv.Visible = true; + ckKeepValidPositions.Visible = true; + + } + else + { + radTreeUnits.Visible = false; + btPrintReportInCsv.Visible = false; + ckKeepValidPositions.Visible = false; + } + + } catch (Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } } @@ -2526,82 +2786,87 @@ namespace Safedispatch_4_0 if (reportType == rep_type.SPEED) { reportName = MainForm2.returnLNGString("r_SpeedingReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_speeding, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_speeding, MainForm2.ButtonColor); } else if (reportType == rep_type.STOP) { reportName = MainForm2.returnLNGString("r_StopsReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_stops, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_stops, MainForm2.ButtonColor); } else if (reportType == rep_type.TELEMETRY_ALARM) { reportName = MainForm2.returnLNGString("r_TelemetryEventReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_telemetry_alarm, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_telemetry_alarm, MainForm2.ButtonColor); } else if (reportType == rep_type.TELEMETRY_EVENT) { reportName = MainForm2.returnLNGString("r_TelemetryReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_telemetry, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_telemetry, MainForm2.ButtonColor); } else if (reportType == rep_type.ALLALARM) { reportName = MainForm2.returnLNGString("r_AllAlarmsReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_allalarm, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_allalarm, MainForm2.ButtonColor); } else if (reportType == rep_type.EMERG) { reportName = MainForm2.returnLNGString("r_EmergencyReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_emergency, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_emergency, MainForm2.ButtonColor); } else if (reportType == rep_type.ENDOFDAY) { reportName = MainForm2.returnLNGString("r_EndOfDayReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_endofday, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_endofday, MainForm2.ButtonColor); } else if (reportType == rep_type.FLEET) { reportName = MainForm2.returnLNGString("r_FleetReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_fleet, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_fleet, MainForm2.ButtonColor); } else if (reportType == rep_type.GEOFENC) { reportName = MainForm2.returnLNGString("r_GeofenceReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_geofences, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_geofences, MainForm2.ButtonColor); } else if (reportType == rep_type.HIST) { reportName = MainForm2.returnLNGString("r_HistoryReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_time, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_time, MainForm2.ButtonColor); + } + else if (reportType == rep_type.BATCH_HIST) + { + reportName = MainForm2.returnLNGString("r_BatchHistoryReport"); + return Utils.ChangeColor(resources.r_time, MainForm2.ButtonColor); } else if (reportType == rep_type.IDLE) { reportName = MainForm2.returnLNGString("r_IdlingReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_idling, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_idling, MainForm2.ButtonColor); } else if (reportType == rep_type.JOB_TICKETING) { reportName = MainForm2.returnLNGString("r_TicketingReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_tickets, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_tickets, MainForm2.ButtonColor); } else if (reportType == rep_type.LAND) { reportName = MainForm2.returnLNGString("r_LandmarkReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_landmark, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_landmark, MainForm2.ButtonColor); } else if (reportType == rep_type.SMS_LOCATION) { reportName = MainForm2.returnLNGString("r_TextMessageLocationReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_textmessaging, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_textmessaging, MainForm2.ButtonColor); } else if (reportType == rep_type.LOG) { reportName = MainForm2.returnLNGString("r_OnOffReport"); - return Utils.ChangeColor(global::Dispatcher.Properties.Resources.r_onoff, MainForm2.ButtonColor); + return Utils.ChangeColor(resources.r_onoff, MainForm2.ButtonColor); } reportName = MainForm2.returnLNGString("r_SpeedingReport"); - return global::Dispatcher.Properties.Resources.r_reports; + return resources.r_reports; } @@ -2618,13 +2883,13 @@ namespace Safedispatch_4_0 switch (MainForm2.radioType) { case RADIOTYPE.ATLAS: - pbIconDateTime.Image = Dispatcher.Properties.Resources.icon_date_enabled_at; + pbIconDateTime.Image = resources.icon_date_enabled_at; break; case RADIOTYPE.HARRIS: - pbIconDateTime.Image = Dispatcher.Properties.Resources.icon_date_enabled_ha; + pbIconDateTime.Image = resources.icon_date_enabled_ha; break; default: - pbIconDateTime.Image = Dispatcher.Properties.Resources.icon_date_enabled; + pbIconDateTime.Image = resources.icon_date_enabled; break; } @@ -2635,11 +2900,11 @@ namespace Safedispatch_4_0 { case RADIOTYPE.ATLAS: case RADIOTYPE.HARRIS: - pbIconDateTime.Image = Dispatcher.Properties.Resources.icon_date_disabled_at; + pbIconDateTime.Image = resources.icon_date_disabled_at; break; default: - pbIconDateTime.Image = Dispatcher.Properties.Resources.icon_date_disabled; + pbIconDateTime.Image = resources.icon_date_disabled; break; } } @@ -2651,14 +2916,14 @@ namespace Safedispatch_4_0 switch (MainForm2.radioType) { case RADIOTYPE.ATLAS: - pbIconUnitGroup.Image = Dispatcher.Properties.Resources.icon_unit_enabled_at; + pbIconUnitGroup.Image = resources.icon_unit_enabled_at; break; case RADIOTYPE.HARRIS: - pbIconUnitGroup.Image = Dispatcher.Properties.Resources.icon_unit_enabled_ha; + pbIconUnitGroup.Image = resources.icon_unit_enabled_ha; break; default: - pbIconUnitGroup.Image = Dispatcher.Properties.Resources.icon_unit_enabled; + pbIconUnitGroup.Image = resources.icon_unit_enabled; break; } @@ -2669,11 +2934,11 @@ namespace Safedispatch_4_0 { case RADIOTYPE.ATLAS: case RADIOTYPE.HARRIS: - pbIconUnitGroup.Image = Dispatcher.Properties.Resources.icon_unit_disabled_at; + pbIconUnitGroup.Image = resources.icon_unit_disabled_at; break; default: - pbIconUnitGroup.Image = Dispatcher.Properties.Resources.icon_unit_disabled; + pbIconUnitGroup.Image = resources.icon_unit_disabled; break; } @@ -2685,15 +2950,15 @@ namespace Safedispatch_4_0 switch (MainForm2.radioType) { case RADIOTYPE.ATLAS: - pbIconReportDaily.Image = Dispatcher.Properties.Resources.icon_email_enabled_at; + pbIconReportDaily.Image = resources.icon_email_enabled_at; break; case RADIOTYPE.HARRIS: - pbIconReportDaily.Image = Dispatcher.Properties.Resources.icon_email_enabled_ha; + pbIconReportDaily.Image = resources.icon_email_enabled_ha; break; default: - pbIconReportDaily.Image = Dispatcher.Properties.Resources.icon_email_enabled; + pbIconReportDaily.Image = resources.icon_email_enabled; break; } } @@ -2703,11 +2968,11 @@ namespace Safedispatch_4_0 { case RADIOTYPE.ATLAS: case RADIOTYPE.HARRIS: - pbIconReportDaily.Image = Dispatcher.Properties.Resources.icon_email_disabled_at; + pbIconReportDaily.Image = resources.icon_email_disabled_at; break; default: - pbIconReportDaily.Image = Dispatcher.Properties.Resources.icon_email_disabled; + pbIconReportDaily.Image = resources.icon_email_disabled; break; } @@ -2723,7 +2988,7 @@ namespace Safedispatch_4_0 { // display the text and image for each item in the comboBox DropListItem item = (DropListItem)args.NewItem.DataBoundItem; - args.NewItem.Text = item.Text; + args.NewItem.Text = item.Text; args.NewItem.Image = item.Image; } @@ -2774,16 +3039,18 @@ namespace Safedispatch_4_0 /// The image which fulfills the constrains private Image GetIconForCombobox(RADIOTYPE radioType, String iconType, bool isEnabled) { + + if (iconType.Equals("unit")) { switch (MainForm2.radioType) { case RADIOTYPE.ATLAS: - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_unit_enabled : Dispatcher.Properties.Resources.icon_cb_unit_disabled); + return (isEnabled ? resources.icon_cb_unit_enabled : resources.icon_cb_unit_disabled); case RADIOTYPE.HARRIS: - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_unit_enabled_ha : Dispatcher.Properties.Resources.icon_cb_unit_disabled); + return (isEnabled ? resources.icon_cb_unit_enabled_ha : resources.icon_cb_unit_disabled); default: - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_unit_enabled : Dispatcher.Properties.Resources.icon_cb_unit_disabled); + return (isEnabled ? resources.icon_cb_unit_enabled : resources.icon_cb_unit_disabled); } } else if (iconType.Equals("group")) @@ -2791,15 +3058,15 @@ namespace Safedispatch_4_0 switch (MainForm2.radioType) { case RADIOTYPE.ATLAS: - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_group_enabled : Dispatcher.Properties.Resources.icon_cb_group_disabled); + return (isEnabled ? resources.icon_cb_group_enabled : resources.icon_cb_group_disabled); case RADIOTYPE.HARRIS: - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_group_enabled_ha : Dispatcher.Properties.Resources.icon_cb_group_disabled); + return (isEnabled ? resources.icon_cb_group_enabled_ha : resources.icon_cb_group_disabled); default: - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_group_enabled : Dispatcher.Properties.Resources.icon_cb_group_disabled); + return (isEnabled ? resources.icon_cb_group_enabled : resources.icon_cb_group_disabled); } } - return (isEnabled ? Dispatcher.Properties.Resources.icon_cb_group_enabled : Dispatcher.Properties.Resources.icon_cb_group_disabled); + return (isEnabled ? resources.icon_cb_group_enabled : resources.icon_cb_group_disabled); } private void rlComputing_Click(object sender, EventArgs e) @@ -2832,6 +3099,76 @@ namespace Safedispatch_4_0 } + + string GeneratedReportsFolder = "GeneratedReports"; + + private string formatReportFileName(string folderPath) + { + // format the file name to contain the current date + DateTime now = DateTime.Now; + + + string date = $"{now.Year.ToString("D2")}{now.Month.ToString("D2")}{now.Day.ToString("D2")}"; + string time_with_miliseconds = $"{now.Hour.ToString("D2")}{now.Minute.ToString("D2")}{now.Second.ToString("D2")}_{now.Millisecond}"; + + + string filePath = $"{folderPath}\\BatchHistoryReport_{date}_{time_with_miliseconds}.csv"; + + return filePath; + } + + private void btPrintReportInCsv_Click(object sender, EventArgs e) + { + + // display on button "InProgress" until the report is generated + btPrintReportInCsv.Text = MainForm2.returnLNGString("InProgress"); + // don't allow another report to be generated meanwhile + btPrintReportInCsv.Enabled = false; + + // start fetching report on a new thread + Task.Factory.StartNew(() => + { + + try + { + // get selected nodes as comma separated list + string sc_ids = ""; + List checkednodes = GetCheckedNodes(radTreeUnits.Nodes); + if (checkednodes != null && checkednodes.Count > 0) + sc_ids = string.Join(",", checkednodes.Select(x => $"{x.Tag}")); + + + int startDate = rdtFrom.Value.GetSecondsFromDT().ConvertLocalToGMT(); + int endDate = rdtUntil.Value.GetSecondsFromDT().ConvertLocalToGMT(); + + // Check if the forder where the reports are stored exists => otherwise create it + string reportsFolder = $"{System.IO.Path.GetDirectoryName(Application.ExecutablePath)}\\{GeneratedReportsFolder}"; + + if (!Directory.Exists(reportsFolder)) + Directory.CreateDirectory(reportsFolder); + + // format in csv and save the file into the above creatd folder + string filePath = formatReportFileName(reportsFolder); + + List excludeFields = new List() { "Address", "Lat", "Lng" }; + + // save the report into csv + if (!string.IsNullOrEmpty(filePath)) + dbRep.saveBatchHistoryToCsv(filePath, excludeFields, sc_ids, startDate, endDate, MainForm2.isInMile, MainForm2.is24hours, Int32.MaxValue, ckComputeAddress.Checked, ckKeepValidPositions.Checked); + + } + finally + { + this.Invoke((MethodInvoker)delegate + { + btPrintReportInCsv.Text = MainForm2.returnLNGString("btShowReportInCsv"); + btPrintReportInCsv.Enabled = true; + }); + } + }); + } + + /// /// Change fore color and background color for the save email button when its state changes /// @@ -2864,13 +3201,18 @@ namespace Safedispatch_4_0 bool areEmailsAddressesValid = true; bool areDaysChecked = false; - string[] emailAddresses = rtbEmail.Text.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries); + string[] emailAddresses = rtbEmail.Text.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + if (emailAddresses.Length == 0) areEmailsAddressesValid = false; + foreach (String str in emailAddresses) // foreach email address check if it's a valid email address - if (str.Length > 0 && !IsValidEmail(str)) + if ((str.Length == 0) || (str.Length > 0 && !IsValidEmail(str))) + { areEmailsAddressesValid = false; + break; + } areDaysChecked = (rcbMonday.Checked || rcbTuesday.Checked @@ -2878,11 +3220,7 @@ namespace Safedispatch_4_0 || rcbFriday.Checked || rcbSaturday.Checked || rcbSunday.Checked); - if (areEmailsAddressesValid && areDaysChecked) - btSaveEmail.Enabled = true; - else - btSaveEmail.Enabled = false; - + btSaveEmail.Enabled = areEmailsAddressesValid && areDaysChecked; } diff --git a/SubscriberAndUserManager/MainForm.cs b/SubscriberAndUserManager/MainForm.cs index b3d897a..ff5cda0 100644 --- a/SubscriberAndUserManager/MainForm.cs +++ b/SubscriberAndUserManager/MainForm.cs @@ -726,20 +726,28 @@ namespace SubscriberAndUserManager string data = System.Text.Encoding.ASCII.GetString(rawData, 0, actualLen); //SM.Debug("RX: " + data.Trim()); - string[] tempArr = data.Split('#'); + string[] tempArr = data.Split("#".ToCharArray()); if (tempArr.Length == 0) { SM.Debug("incorect message=" + data); return false; } - int messLen = Convert.ToInt32(tempArr[1]); + int messLen = 0; + if( tempArr[1] != "") + messLen = Convert.ToInt32(tempArr[1]); + if (actualLen != messLen) { Console.WriteLine("message length({0}) != actual length({1})", messLen, actualLen); return false; } - int opCode = Convert.ToInt32(tempArr[3]); + + + int opCode = 0; + if(tempArr[3] != "") + opCode = Convert.ToInt32(tempArr[3]); + switch (opCode) { diff --git a/SubscriberAndUserManager/VehiclesForm.Designer.cs b/SubscriberAndUserManager/VehiclesForm.Designer.cs index 096b053..23c112f 100644 --- a/SubscriberAndUserManager/VehiclesForm.Designer.cs +++ b/SubscriberAndUserManager/VehiclesForm.Designer.cs @@ -279,6 +279,7 @@ namespace SubscriberAndUserManager this.pictureBox1.Location = new System.Drawing.Point(257, 143); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(32, 32); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pictureBox1.TabIndex = 48; this.pictureBox1.TabStop = false; // diff --git a/SubscriberAndUserManager/controlRegistration.cs b/SubscriberAndUserManager/controlRegistration.cs index 1275246..27b5439 100644 --- a/SubscriberAndUserManager/controlRegistration.cs +++ b/SubscriberAndUserManager/controlRegistration.cs @@ -283,6 +283,7 @@ namespace SubscriberAndUserManager { try { gatewayRegs = regManager.getAllGateways(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("dberr"), MainForm.returnLNGString("err")); return; } + remainingGateways = totalGateways - regManager.gatewaysCount(); //gvGateways.DataSource = gatewayRegs; @@ -310,6 +311,7 @@ namespace SubscriberAndUserManager int usedMapUS = 0; int usedMapEu = 0; int usedArcgis = 0; + for (int i = 0; i < safeDispatchRegs.Count; i++) { if (safeDispatchRegs[i].gps) @@ -368,16 +370,23 @@ namespace SubscriberAndUserManager remainingOpenStreetMap = totalOpenStreetMap - usedMapEu; remainingUS = totalUS - usedMapUS; remainingGoogle = totalGoogle - usedGoogle; + + gvSafeDispatches.DataSource = safeDispatchRegs; #region broadcast SD for dispatcher IP changed - string ipList = ""; - foreach (var item in safeDispatchRegs) - ipList += item.ip + "/"; - - string test1 = "#475#" + ipList; - String cmdok1 = "#" + "0.0" + test1; Int32 tmp1 = cmdok1.Length + 1; tmp1 += tmp1.ToString().Length; cmdok1 = "#" + tmp1.ToString() + cmdok1; - MainForm.BroadcastRegistrationSD(cmdok1); + + //broadcast SD for dispatcher IP changed + + string ipList = string.Join("/", safeDispatchRegs.Select(x => x.ip)); + string cmd = $"#0.0#475#{ipList}"; + + // calc length and insert it at the begining + Int32 length = cmd.Length + 1; + length += length.ToString().Length; + cmd = $"#{length}{cmd}"; + + MainForm.BroadcastRegistrationSD(cmd); #endregion //gvSafeDispatches.Columns[5].HeaderText = "Geo-Fences"; From f7c11bd88482c65d88c908cb37510860e014b668 Mon Sep 17 00:00:00 2001 From: Laurentiu Date: Wed, 5 Jun 2024 14:02:43 +0300 Subject: [PATCH 2/4] Batch_Historical_Group_Report --- ReportsLibrary/Properties/VersionInfo.cs | 10 + .../Reports/BatchHistoryReport.Designer.cs | 491 ++++++++++++++++++ ReportsLibrary/Reports/BatchHistoryReport.cs | 27 + .../Reports/BatchHistoryReport.resx | 120 +++++ 4 files changed, 648 insertions(+) create mode 100644 ReportsLibrary/Properties/VersionInfo.cs create mode 100644 ReportsLibrary/Reports/BatchHistoryReport.Designer.cs create mode 100644 ReportsLibrary/Reports/BatchHistoryReport.cs create mode 100644 ReportsLibrary/Reports/BatchHistoryReport.resx diff --git a/ReportsLibrary/Properties/VersionInfo.cs b/ReportsLibrary/Properties/VersionInfo.cs new file mode 100644 index 0000000..6164417 --- /dev/null +++ b/ReportsLibrary/Properties/VersionInfo.cs @@ -0,0 +1,10 @@ + +// Generated on Wed, Jun 5, 2024 11:58:38 AM by prebuild script +namespace SafeDispatch-git +{ + public class VersionInfo + { + public string Version{ get; set; } = "8.1.0.10898-4-g9084fa4"; + } +} + diff --git a/ReportsLibrary/Reports/BatchHistoryReport.Designer.cs b/ReportsLibrary/Reports/BatchHistoryReport.Designer.cs new file mode 100644 index 0000000..eeb9099 --- /dev/null +++ b/ReportsLibrary/Reports/BatchHistoryReport.Designer.cs @@ -0,0 +1,491 @@ +namespace ReportsLibrary +{ + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + using Telerik.Reporting; + using Telerik.Reporting.Drawing; + + partial class BatchHistoryReport + { + #region Component Designer generated code + /// + /// Required method for telerik Reporting designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + Telerik.Reporting.GraphGroup graphGroup1 = new Telerik.Reporting.GraphGroup(); + Telerik.Reporting.GraphTitle graphTitle1 = new Telerik.Reporting.GraphTitle(); + Telerik.Reporting.NumericalScale numericalScale1 = new Telerik.Reporting.NumericalScale(); + Telerik.Reporting.CategoryScale categoryScale1 = new Telerik.Reporting.CategoryScale(); + Telerik.Reporting.GraphGroup graphGroup2 = new Telerik.Reporting.GraphGroup(); + Telerik.Reporting.Group group1 = new Telerik.Reporting.Group(); + Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule(); + Telerik.Reporting.Drawing.StyleRule styleRule2 = new Telerik.Reporting.Drawing.StyleRule(); + Telerik.Reporting.Drawing.StyleRule styleRule3 = new Telerik.Reporting.Drawing.StyleRule(); + Telerik.Reporting.Drawing.StyleRule styleRule4 = new Telerik.Reporting.Drawing.StyleRule(); + this.labelsGroupFooter = new Telerik.Reporting.GroupFooterSection(); + this.labelsGroupHeader = new Telerik.Reporting.GroupHeaderSection(); + this.dateCaptionTextBox = new Telerik.Reporting.TextBox(); + this.timeCaptionTextBox = new Telerik.Reporting.TextBox(); + this.locationCaptionTextBox = new Telerik.Reporting.TextBox(); + this.speedCaptionTextBox = new Telerik.Reporting.TextBox(); + this.unitCaptionTextBox = new Telerik.Reporting.TextBox(); + this.departmentCaptionTextBox = new Telerik.Reporting.TextBox(); + this.graph1 = new Telerik.Reporting.Graph(); + this.polarCoordinateSystem1 = new Telerik.Reporting.PolarCoordinateSystem(); + this.graphAxis1 = new Telerik.Reporting.GraphAxis(); + this.graphAxis2 = new Telerik.Reporting.GraphAxis(); + this.barSeries1 = new Telerik.Reporting.BarSeries(); + this.pageHeader = new Telerik.Reporting.PageHeaderSection(); + this.pageFooter = new Telerik.Reporting.PageFooterSection(); + this.currentTimeTextBox = new Telerik.Reporting.TextBox(); + this.pageInfoTextBox = new Telerik.Reporting.TextBox(); + this.reportHeader = new Telerik.Reporting.ReportHeaderSection(); + this.titleTextBox = new Telerik.Reporting.TextBox(); + this.periodTextBox = new Telerik.Reporting.TextBox(); + this.detail = new Telerik.Reporting.DetailSection(); + this.departmentDataTextBox = new Telerik.Reporting.TextBox(); + this.unitDataTextBox = new Telerik.Reporting.TextBox(); + this.dateDataTextBox = new Telerik.Reporting.TextBox(); + this.timeDataTextBox = new Telerik.Reporting.TextBox(); + this.locationDataTextBox = new Telerik.Reporting.TextBox(); + this.speedDataTextBox = new Telerik.Reporting.TextBox(); + this.objectDataSource1 = new Telerik.Reporting.ObjectDataSource(); + this.reportFooterSection1 = new Telerik.Reporting.ReportFooterSection(); + ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); + // + // labelsGroupFooter + // + this.labelsGroupFooter.Height = Telerik.Reporting.Drawing.Unit.Inch(0.052083294838666916D); + this.labelsGroupFooter.Name = "labelsGroupFooter"; + this.labelsGroupFooter.Style.Visible = false; + // + // labelsGroupHeader + // + this.labelsGroupHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(0.51875019073486328D); + this.labelsGroupHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { + this.dateCaptionTextBox, + this.timeCaptionTextBox, + this.locationCaptionTextBox, + this.speedCaptionTextBox, + this.unitCaptionTextBox, + this.departmentCaptionTextBox}); + this.labelsGroupHeader.Name = "labelsGroupHeader"; + this.labelsGroupHeader.PrintOnEveryPage = true; + // + // dateCaptionTextBox + // + this.dateCaptionTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.dateCaptionTextBox.CanGrow = true; + this.dateCaptionTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(2.5D), Telerik.Reporting.Drawing.Unit.Inch(0.019999999552965164D)); + this.dateCaptionTextBox.Name = "dateCaptionTextBox"; + this.dateCaptionTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.800000011920929D), Telerik.Reporting.Drawing.Unit.Inch(0.43999999761581421D)); + this.dateCaptionTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.dateCaptionTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.dateCaptionTextBox.StyleName = "Caption"; + this.dateCaptionTextBox.Value = "Date"; + // + // timeCaptionTextBox + // + this.timeCaptionTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.timeCaptionTextBox.CanGrow = true; + this.timeCaptionTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(3.309999942779541D), Telerik.Reporting.Drawing.Unit.Inch(0.019999999552965164D)); + this.timeCaptionTextBox.Name = "timeCaptionTextBox"; + this.timeCaptionTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.800000011920929D), Telerik.Reporting.Drawing.Unit.Inch(0.43999999761581421D)); + this.timeCaptionTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.timeCaptionTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.timeCaptionTextBox.StyleName = "Caption"; + this.timeCaptionTextBox.Value = "Time"; + // + // locationCaptionTextBox + // + this.locationCaptionTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.locationCaptionTextBox.CanGrow = true; + this.locationCaptionTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(4.119999885559082D), Telerik.Reporting.Drawing.Unit.Inch(0.019999999552965164D)); + this.locationCaptionTextBox.Name = "locationCaptionTextBox"; + this.locationCaptionTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.6699999570846558D), Telerik.Reporting.Drawing.Unit.Inch(0.43999999761581421D)); + this.locationCaptionTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.locationCaptionTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.locationCaptionTextBox.StyleName = "Caption"; + this.locationCaptionTextBox.Value = "Location"; + // + // speedCaptionTextBox + // + this.speedCaptionTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.speedCaptionTextBox.CanGrow = true; + this.speedCaptionTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(5.8000001907348633D), Telerik.Reporting.Drawing.Unit.Inch(0.019999999552965164D)); + this.speedCaptionTextBox.Name = "speedCaptionTextBox"; + this.speedCaptionTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.699999988079071D), Telerik.Reporting.Drawing.Unit.Inch(0.43999999761581421D)); + this.speedCaptionTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.speedCaptionTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.speedCaptionTextBox.StyleName = "Caption"; + this.speedCaptionTextBox.Value = "Speed"; + // + // unitCaptionTextBox + // + this.unitCaptionTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.unitCaptionTextBox.CanGrow = true; + this.unitCaptionTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(1.1799999475479126D), Telerik.Reporting.Drawing.Unit.Inch(0.019999999552965164D)); + this.unitCaptionTextBox.Name = "unitCaptionTextBox"; + this.unitCaptionTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.309999942779541D), Telerik.Reporting.Drawing.Unit.Inch(0.43999999761581421D)); + this.unitCaptionTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.unitCaptionTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.unitCaptionTextBox.StyleName = "Caption"; + this.unitCaptionTextBox.Value = "Unit"; + // + // departmentCaptionTextBox + // + this.departmentCaptionTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.departmentCaptionTextBox.CanGrow = true; + this.departmentCaptionTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(3.9378803194267675E-05D), Telerik.Reporting.Drawing.Unit.Inch(0.02083333395421505D)); + this.departmentCaptionTextBox.Name = "departmentCaptionTextBox"; + this.departmentCaptionTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.1699999570846558D), Telerik.Reporting.Drawing.Unit.Inch(0.43999999761581421D)); + this.departmentCaptionTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.departmentCaptionTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.departmentCaptionTextBox.StyleName = "Caption"; + this.departmentCaptionTextBox.Value = "Department"; + // + // graph1 + // + graphGroup1.Name = "categoryGroup"; + this.graph1.CategoryGroups.Add(graphGroup1); + this.graph1.CoordinateSystems.Add(this.polarCoordinateSystem1); + this.graph1.Legend.Style.LineColor = System.Drawing.Color.LightGray; + this.graph1.Legend.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D); + this.graph1.Legend.Style.Visible = false; + this.graph1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.60000008344650269D), Telerik.Reporting.Drawing.Unit.Inch(3.9498012483818457E-05D)); + this.graph1.Name = "graph1"; + this.graph1.PlotAreaStyle.LineColor = System.Drawing.Color.LightGray; + this.graph1.PlotAreaStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D); + this.graph1.Series.Add(this.barSeries1); + this.graph1.SeriesGroups.Add(graphGroup2); + this.graph1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(5.0899996757507324D), Telerik.Reporting.Drawing.Unit.Inch(1.6000000238418579D)); + graphTitle1.Position = Telerik.Reporting.GraphItemPosition.TopCenter; + graphTitle1.Style.LineColor = System.Drawing.Color.LightGray; + graphTitle1.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D); + graphTitle1.Text = ""; + this.graph1.Titles.Add(graphTitle1); + // + // polarCoordinateSystem1 + // + this.polarCoordinateSystem1.AngularAxis = this.graphAxis1; + this.polarCoordinateSystem1.Name = "polarCoordinateSystem1"; + this.polarCoordinateSystem1.RadialAxis = this.graphAxis2; + // + // graphAxis1 + // + this.graphAxis1.MajorGridLineStyle.LineColor = System.Drawing.Color.LightGray; + this.graphAxis1.MajorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D); + this.graphAxis1.MajorGridLineStyle.Visible = false; + this.graphAxis1.MinorGridLineStyle.LineColor = System.Drawing.Color.LightGray; + this.graphAxis1.MinorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D); + this.graphAxis1.MinorGridLineStyle.Visible = false; + this.graphAxis1.Name = "graphAxis1"; + this.graphAxis1.Scale = numericalScale1; + this.graphAxis1.Style.Visible = false; + // + // graphAxis2 + // + this.graphAxis2.MajorGridLineStyle.LineColor = System.Drawing.Color.LightGray; + this.graphAxis2.MajorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D); + this.graphAxis2.MajorGridLineStyle.Visible = false; + this.graphAxis2.MinorGridLineStyle.LineColor = System.Drawing.Color.LightGray; + this.graphAxis2.MinorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D); + this.graphAxis2.MinorGridLineStyle.Visible = false; + this.graphAxis2.Name = "graphAxis2"; + categoryScale1.PositionMode = Telerik.Reporting.AxisPositionMode.OnTicks; + categoryScale1.SpacingSlotCount = 0D; + this.graphAxis2.Scale = categoryScale1; + this.graphAxis2.Style.Visible = false; + // + // barSeries1 + // + this.barSeries1.ArrangeMode = Telerik.Reporting.GraphSeriesArrangeMode.Stacked100; + this.barSeries1.CategoryGroup = graphGroup1; + this.barSeries1.CoordinateSystem = this.polarCoordinateSystem1; + this.barSeries1.DataPointLabel = "= Sum(Fields.Value) / CDbl(Exec(\'graph1\', Sum(Fields.Value)))"; + this.barSeries1.DataPointLabelAlignment = Telerik.Reporting.BarDataPointLabelAlignment.OutsideColumn; + this.barSeries1.DataPointLabelConnectorStyle.Padding.Bottom = Telerik.Reporting.Drawing.Unit.Point(2D); + this.barSeries1.DataPointLabelConnectorStyle.Padding.Top = Telerik.Reporting.Drawing.Unit.Point(2D); + this.barSeries1.DataPointLabelFormat = "{0:P}"; + this.barSeries1.DataPointLabelOffset = Telerik.Reporting.Drawing.Unit.Mm(5D); + this.barSeries1.DataPointLabelStyle.Visible = true; + this.barSeries1.DataPointStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D); + this.barSeries1.DataPointStyle.Visible = true; + this.barSeries1.LegendItem.Value = "= Fields.Type"; + this.barSeries1.Name = "barSeries1"; + graphGroup2.Groupings.Add(new Telerik.Reporting.Grouping("= Fields.Type")); + graphGroup2.Name = "typeGroup"; + graphGroup2.Sortings.Add(new Telerik.Reporting.Sorting("= Fields.Type", Telerik.Reporting.SortDirection.Asc)); + this.barSeries1.SeriesGroup = graphGroup2; + this.barSeries1.X = "= Sum(Fields.Value)"; + // + // pageHeader + // + this.pageHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(0.099999986588954926D); + this.pageHeader.Name = "pageHeader"; + // + // pageFooter + // + this.pageFooter.Height = Telerik.Reporting.Drawing.Unit.Inch(0.28125D); + this.pageFooter.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { + this.currentTimeTextBox, + this.pageInfoTextBox}); + this.pageFooter.Name = "pageFooter"; + // + // currentTimeTextBox + // + this.currentTimeTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.02083333395421505D), Telerik.Reporting.Drawing.Unit.Inch(0.02083333395421505D)); + this.currentTimeTextBox.Name = "currentTimeTextBox"; + this.currentTimeTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(3.1979167461395264D), Telerik.Reporting.Drawing.Unit.Inch(0.20000003278255463D)); + this.currentTimeTextBox.StyleName = "PageInfo"; + this.currentTimeTextBox.Value = "=NOW()"; + // + // pageInfoTextBox + // + this.pageInfoTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(3.2395832538604736D), Telerik.Reporting.Drawing.Unit.Inch(0.02083333395421505D)); + this.pageInfoTextBox.Name = "pageInfoTextBox"; + this.pageInfoTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(3.1979167461395264D), Telerik.Reporting.Drawing.Unit.Inch(0.20000003278255463D)); + this.pageInfoTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Right; + this.pageInfoTextBox.StyleName = "PageInfo"; + this.pageInfoTextBox.Value = "=PageNumber"; + // + // reportHeader + // + this.reportHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(0.60000008344650269D); + this.reportHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { + this.titleTextBox, + this.periodTextBox}); + this.reportHeader.Name = "reportHeader"; + // + // titleTextBox + // + this.titleTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.titleTextBox.Name = "titleTextBox"; + this.titleTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(6.4583334922790527D), Telerik.Reporting.Drawing.Unit.Inch(0.30000001192092896D)); + this.titleTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.titleTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.titleTextBox.StyleName = "Title"; + this.titleTextBox.Value = "BatchHistoryReport"; + // + // periodTextBox + // + this.periodTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0.30000004172325134D)); + this.periodTextBox.Name = "periodTextBox"; + this.periodTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(6.4583334922790527D), Telerik.Reporting.Drawing.Unit.Inch(0.30000004172325134D)); + this.periodTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.periodTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.periodTextBox.Style.Visible = false; + this.periodTextBox.StyleName = "Title"; + this.periodTextBox.Value = ""; + // + // detail + // + this.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D); + this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { + this.departmentDataTextBox, + this.unitDataTextBox, + this.dateDataTextBox, + this.timeDataTextBox, + this.locationDataTextBox, + this.speedDataTextBox}); + this.detail.Name = "detail"; + this.detail.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + // + // departmentDataTextBox + // + this.departmentDataTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.departmentDataTextBox.Angle = 0D; + this.departmentDataTextBox.CanGrow = true; + this.departmentDataTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(3.9365557313431054E-05D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.departmentDataTextBox.Name = "departmentDataTextBox"; + this.departmentDataTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.1699999570846558D), Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D)); + this.departmentDataTextBox.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + this.departmentDataTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.departmentDataTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.departmentDataTextBox.StyleName = "Data"; + this.departmentDataTextBox.Value = "=Fields.Department"; + // + // unitDataTextBox + // + this.unitDataTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.unitDataTextBox.Angle = 0D; + this.unitDataTextBox.CanGrow = true; + this.unitDataTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(1.1799999475479126D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.unitDataTextBox.Name = "unitDataTextBox"; + this.unitDataTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.309999942779541D), Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D)); + this.unitDataTextBox.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + this.unitDataTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.unitDataTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.unitDataTextBox.StyleName = "Data"; + this.unitDataTextBox.Value = "=Fields.Unit"; + // + // dateDataTextBox + // + this.dateDataTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.dateDataTextBox.Angle = 0D; + this.dateDataTextBox.CanGrow = true; + this.dateDataTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(2.5D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.dateDataTextBox.Name = "dateDataTextBox"; + this.dateDataTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.800000011920929D), Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D)); + this.dateDataTextBox.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + this.dateDataTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.dateDataTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.dateDataTextBox.StyleName = "Data"; + this.dateDataTextBox.Value = "=Fields.Date"; + // + // timeDataTextBox + // + this.timeDataTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.timeDataTextBox.Angle = 0D; + this.timeDataTextBox.CanGrow = true; + this.timeDataTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(3.309999942779541D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.timeDataTextBox.Name = "timeDataTextBox"; + this.timeDataTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.800000011920929D), Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D)); + this.timeDataTextBox.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + this.timeDataTextBox.Style.BorderStyle.Left = Telerik.Reporting.Drawing.BorderType.Solid; + this.timeDataTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.timeDataTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.timeDataTextBox.StyleName = "Data"; + this.timeDataTextBox.Value = "=Fields.Time"; + // + // locationDataTextBox + // + this.locationDataTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.locationDataTextBox.Angle = 0D; + this.locationDataTextBox.CanGrow = true; + this.locationDataTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(4.119999885559082D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.locationDataTextBox.Name = "locationDataTextBox"; + this.locationDataTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.6699999570846558D), Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D)); + this.locationDataTextBox.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + this.locationDataTextBox.Style.BorderStyle.Left = Telerik.Reporting.Drawing.BorderType.Solid; + this.locationDataTextBox.Style.BorderStyle.Right = Telerik.Reporting.Drawing.BorderType.Solid; + this.locationDataTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.locationDataTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.locationDataTextBox.StyleName = "Data"; + this.locationDataTextBox.Value = "=Fields.Location"; + // + // speedDataTextBox + // + this.speedDataTextBox.Anchoring = ((Telerik.Reporting.AnchoringStyles)((Telerik.Reporting.AnchoringStyles.Top | Telerik.Reporting.AnchoringStyles.Bottom))); + this.speedDataTextBox.Angle = 0D; + this.speedDataTextBox.CanGrow = true; + this.speedDataTextBox.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(5.8000001907348633D), Telerik.Reporting.Drawing.Unit.Inch(0D)); + this.speedDataTextBox.Name = "speedDataTextBox"; + this.speedDataTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(0.699999988079071D), Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D)); + this.speedDataTextBox.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; + this.speedDataTextBox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; + this.speedDataTextBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.speedDataTextBox.StyleName = "Data"; + this.speedDataTextBox.Value = "=Fields.Speed"; + // + // objectDataSource1 + // + this.objectDataSource1.DataMember = "GetALL"; + this.objectDataSource1.DataSource = typeof(ReportsLibrary.BatchHistoryDataObj); + this.objectDataSource1.Name = "objectDataSource1"; + // + // reportFooterSection1 + // + this.reportFooterSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(1.6000394821166992D); + this.reportFooterSection1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { + this.graph1}); + this.reportFooterSection1.Name = "reportFooterSection1"; + // + // BatchHistoryReport + // + this.DataSource = this.objectDataSource1; + group1.GroupFooter = this.labelsGroupFooter; + group1.GroupHeader = this.labelsGroupHeader; + group1.Name = "labelsGroup"; + this.Groups.AddRange(new Telerik.Reporting.Group[] { + group1}); + this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { + this.labelsGroupHeader, + this.labelsGroupFooter, + this.pageHeader, + this.pageFooter, + this.reportHeader, + this.detail, + this.reportFooterSection1}); + this.Name = "BatchHistoryReport"; + this.PageSettings.Landscape = false; + this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D)); + this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter; + this.Style.BackgroundColor = System.Drawing.Color.White; + styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] { + new Telerik.Reporting.Drawing.StyleSelector("Title")}); + styleRule1.Style.BackgroundColor = System.Drawing.Color.Empty; + styleRule1.Style.Color = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(58)))), ((int)(((byte)(112))))); + styleRule1.Style.Font.Name = "Tahoma"; + styleRule1.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(18D); + styleRule2.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] { + new Telerik.Reporting.Drawing.StyleSelector("Caption")}); + styleRule2.Style.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(58)))), ((int)(((byte)(112))))); + styleRule2.Style.Color = System.Drawing.Color.White; + styleRule2.Style.Font.Bold = true; + styleRule2.Style.Font.Italic = false; + styleRule2.Style.Font.Name = "Tahoma"; + styleRule2.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(11D); + styleRule2.Style.Font.Strikeout = false; + styleRule2.Style.Font.Underline = false; + styleRule2.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + styleRule3.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] { + new Telerik.Reporting.Drawing.StyleSelector("Data")}); + styleRule3.Style.Color = System.Drawing.Color.Black; + styleRule3.Style.Font.Name = "Tahoma"; + styleRule3.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(10D); + styleRule3.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + styleRule4.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] { + new Telerik.Reporting.Drawing.StyleSelector("PageInfo")}); + styleRule4.Style.Color = System.Drawing.Color.Black; + styleRule4.Style.Font.Name = "Tahoma"; + styleRule4.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(8D); + styleRule4.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; + this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] { + styleRule1, + styleRule2, + styleRule3, + styleRule4}); + this.Width = Telerik.Reporting.Drawing.Unit.Inch(6.5D); + ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); + + } + #endregion + + private ObjectDataSource objectDataSource1; + private GroupHeaderSection labelsGroupHeader; + private GroupFooterSection labelsGroupFooter; + private Group labelsGroup; + private PageHeaderSection pageHeader; + private PageFooterSection pageFooter; + private Telerik.Reporting.TextBox currentTimeTextBox; + private Telerik.Reporting.TextBox pageInfoTextBox; + private ReportHeaderSection reportHeader; + private DetailSection detail; + private Telerik.Reporting.TextBox departmentDataTextBox; + private Telerik.Reporting.TextBox unitDataTextBox; + private Telerik.Reporting.TextBox dateDataTextBox; + private Telerik.Reporting.TextBox timeDataTextBox; + private Telerik.Reporting.TextBox locationDataTextBox; + private Telerik.Reporting.TextBox speedDataTextBox; + public Telerik.Reporting.TextBox titleTextBox; + + public Telerik.Reporting.TextBox departmentCaptionTextBox; + public Telerik.Reporting.TextBox unitCaptionTextBox; + public Telerik.Reporting.TextBox dateCaptionTextBox; + public Telerik.Reporting.TextBox timeCaptionTextBox; + public Telerik.Reporting.TextBox locationCaptionTextBox; + public Telerik.Reporting.TextBox speedCaptionTextBox; + public Telerik.Reporting.TextBox periodTextBox; + public Graph graph1; + private PolarCoordinateSystem polarCoordinateSystem1; + private GraphAxis graphAxis1; + private GraphAxis graphAxis2; + private BarSeries barSeries1; + public ReportFooterSection reportFooterSection1; + + } +} \ No newline at end of file diff --git a/ReportsLibrary/Reports/BatchHistoryReport.cs b/ReportsLibrary/Reports/BatchHistoryReport.cs new file mode 100644 index 0000000..affe6e8 --- /dev/null +++ b/ReportsLibrary/Reports/BatchHistoryReport.cs @@ -0,0 +1,27 @@ +namespace ReportsLibrary +{ + using System; + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + using Telerik.Reporting; + using Telerik.Reporting.Drawing; + + /// + /// Summary description for BatchHistoryReport. + /// + public partial class BatchHistoryReport : Telerik.Reporting.Report + { + public BatchHistoryReport() + { + /// + /// Required for telerik Reporting designer support + /// + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + } +} \ No newline at end of file diff --git a/ReportsLibrary/Reports/BatchHistoryReport.resx b/ReportsLibrary/Reports/BatchHistoryReport.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ReportsLibrary/Reports/BatchHistoryReport.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From a2c35ac9a52f8c85aff89fd2aa0f9bdc6de7a89f Mon Sep 17 00:00:00 2001 From: Laurentiu Date: Wed, 5 Jun 2024 14:05:05 +0300 Subject: [PATCH 3/4] Batch_Historical_Group_Report --- ReportsLibrary/ReportsLibrary.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/ReportsLibrary/ReportsLibrary.csproj b/ReportsLibrary/ReportsLibrary.csproj index 97eac69..439bbb5 100644 --- a/ReportsLibrary/ReportsLibrary.csproj +++ b/ReportsLibrary/ReportsLibrary.csproj @@ -1179,7 +1179,6 @@ - From 1cf795aa28e18b53c7088423fa78ffb804654e7b Mon Sep 17 00:00:00 2001 From: Laurentiu Date: Wed, 5 Jun 2024 15:17:35 +0300 Subject: [PATCH 4/4] Batch_Historical_Group_Report --- ReportsLibrary/Properties/VersionInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReportsLibrary/Properties/VersionInfo.cs b/ReportsLibrary/Properties/VersionInfo.cs index 6164417..3ade37e 100644 --- a/ReportsLibrary/Properties/VersionInfo.cs +++ b/ReportsLibrary/Properties/VersionInfo.cs @@ -1,10 +1,10 @@ -// Generated on Wed, Jun 5, 2024 11:58:38 AM by prebuild script +// 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-4-g9084fa4"; + public string Version{ get; set; } = "8.1.0.10898-7-ga2c35ac"; } }