1521 lines
70 KiB
C#
1521 lines
70 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using SafeMobileLib;
|
|
using Telerik.WinControls;
|
|
using Telerik.WinControls.Enumerations;
|
|
using Telerik.WinControls.UI;
|
|
using System.Collections;
|
|
|
|
namespace SubscriberAndUserManager
|
|
{
|
|
public partial class controlSystem : UserControl
|
|
{
|
|
private DBvehiclesManager DBunits;
|
|
private List<Vehicles> unitList;
|
|
private DBtelemetryManager DBtel;
|
|
private List<TelemetryObj> telList;
|
|
private DBalarmManager DBalarm;
|
|
private MainForm parent;
|
|
|
|
private void setLanguage()
|
|
{
|
|
gbDigital1.Text = MainForm.returnLNGString("dig") + "1";
|
|
gbDigital2.Text = MainForm.returnLNGString("dig") + "2";
|
|
gbDigital3.Text = MainForm.returnLNGString("dig") + "3";
|
|
gbDigital4.Text = MainForm.returnLNGString("dig") + "4";
|
|
gbDigital5.Text = MainForm.returnLNGString("dig") + "5";
|
|
chbDigital1.Text = MainForm.returnLNGString("alarm");
|
|
chbDigital2.Text = MainForm.returnLNGString("alarm");
|
|
chbDigital3.Text = MainForm.returnLNGString("alarm");
|
|
chbDigital4.Text = MainForm.returnLNGString("alarm");
|
|
chbDigital5.Text = MainForm.returnLNGString("alarm");
|
|
|
|
tbName1.Text = MainForm.returnLNGString("dig") + "1";
|
|
tbName2.Text = MainForm.returnLNGString("dig") + "2";
|
|
tbName3.Text = MainForm.returnLNGString("dig") + "3";
|
|
tbName4.Text = MainForm.returnLNGString("dig") + "4";
|
|
tbName5.Text = MainForm.returnLNGString("dig") + "5";
|
|
|
|
gbEmailAlarm.Text = MainForm.returnLNGString("emailname");
|
|
gbSpeed.Text = MainForm.returnLNGString("speedalarm");
|
|
gbTelemetry.Text = MainForm.returnLNGString("telem");
|
|
gbZoneAndLandmarks.Text = MainForm.returnLNGString("geoandland");
|
|
gpAlarms.Text = MainForm.returnLNGString("emerg");
|
|
|
|
cbInOut1.Items[0].Text = MainForm.returnLNGString("inname");
|
|
cbInOut1.Items[1].Text = MainForm.returnLNGString("outname");
|
|
cbHighLow1.Items[0].Text = MainForm.returnLNGString("high");
|
|
cbHighLow1.Items[1].Text = MainForm.returnLNGString("low");
|
|
|
|
cbInOut2.Items[0].Text = MainForm.returnLNGString("inname");
|
|
cbInOut2.Items[1].Text = MainForm.returnLNGString("outname");
|
|
cbHighLow2.Items[0].Text = MainForm.returnLNGString("high");
|
|
cbHighLow2.Items[1].Text = MainForm.returnLNGString("low");
|
|
|
|
cbInOut3.Items[0].Text = MainForm.returnLNGString("inname");
|
|
cbInOut3.Items[1].Text = MainForm.returnLNGString("outname");
|
|
cbHighLow3.Items[0].Text = MainForm.returnLNGString("high");
|
|
cbHighLow3.Items[1].Text = MainForm.returnLNGString("low");
|
|
|
|
cbInOut4.Items[0].Text = MainForm.returnLNGString("inname");
|
|
cbInOut4.Items[1].Text = MainForm.returnLNGString("outname");
|
|
cbHighLow4.Items[0].Text = MainForm.returnLNGString("high");
|
|
cbHighLow4.Items[1].Text = MainForm.returnLNGString("low");
|
|
|
|
cbInOut5.Items[0].Text = MainForm.returnLNGString("inname");
|
|
cbInOut5.Items[1].Text = MainForm.returnLNGString("outname");
|
|
cbHighLow5.Items[0].Text = MainForm.returnLNGString("high");
|
|
cbHighLow5.Items[1].Text = MainForm.returnLNGString("low");
|
|
|
|
chbEmergency.Text = MainForm.returnLNGString("emergname");
|
|
chbLoneWorker.Text = MainForm.returnLNGString("loneworker");
|
|
chbLand.Text = MainForm.returnLNGString("landmark");
|
|
chbGeofence.Text = MainForm.returnLNGString("geofenc");
|
|
chbSendAlarmEmail.Text = MainForm.returnLNGString("sendemail");
|
|
lbEmail.Text = MainForm.returnLNGString("emailfor") + ":";
|
|
|
|
chbSpeed.Text = MainForm.returnLNGString("speed");
|
|
lbSpeed.Text = MainForm.returnLNGString("maxspeed") + ":";
|
|
rbKMs.Text = MainForm.returnLNGString("kmh");
|
|
rbMiles.Text = MainForm.returnLNGString("mph");
|
|
|
|
lbAlarmType.Text = MainForm.returnLNGString("alarmtype")+":";
|
|
chbPopupEm.Text = MainForm.returnLNGString("popup");
|
|
chbPopupGeo.Text = MainForm.returnLNGString("popup");
|
|
chbPopupSpeed.Text = MainForm.returnLNGString("popup");
|
|
chbPopupTelem.Text = MainForm.returnLNGString("popup");
|
|
chbSoundEm.Text = MainForm.returnLNGString("sound");
|
|
chbSoundGeo.Text = MainForm.returnLNGString("sound");
|
|
chbSoundSpeed.Text = MainForm.returnLNGString("sound");
|
|
chbSoundTelem.Text = MainForm.returnLNGString("sound");
|
|
}
|
|
private String names = "";
|
|
public controlSystem(DBvehiclesManager DBunits, DBtelemetryManager DBtel, DBalarmManager DBalarm, MainForm _parent)
|
|
{
|
|
this.DBunits = DBunits;
|
|
try{
|
|
unitList = DBunits.getAllVehiclesWithSc_ID();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
CustomMessageBox.Show(CustomMessageBoxType.exclamation, MainForm.returnLNGString("dberr"), MainForm.returnLNGString("err"));
|
|
return;
|
|
}
|
|
|
|
this.DBtel = DBtel;
|
|
this.DBalarm = DBalarm;
|
|
|
|
InitializeComponent();
|
|
setLanguage();
|
|
|
|
listBoxUnits.DataSource = unitList;
|
|
listBoxUnits.DisplayMember = "VehName";
|
|
|
|
if (unitList.Count > 0)
|
|
{
|
|
listBoxUnits.SelectedIndex = 0;
|
|
lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + ((Vehicles)((RadListDataItem)listBoxUnits.SelectedItems[0]).Value).VehName;//((Vehicles)listBoxUnits.SelectedValue).VehName;
|
|
|
|
//add telemetry for old Units that were added in a previos version
|
|
/*foreach (Vehicles veh in unitList)
|
|
{
|
|
AddTelItems2Imei(DBunits.getSCID(veh.Imei));
|
|
}*/
|
|
AddTelemetry();
|
|
|
|
}
|
|
//panel1.Enabled = false; panel2.Enabled = false; panel3.Enabled = false; panel4.Enabled = false; panel5.Enabled = false;
|
|
ManageTelemetryItems();
|
|
ManageAlarmsItems();
|
|
|
|
if ((MainForm.radioType != RADIOTYPE.MOTO) && (MainForm.radioType != RADIOTYPE.LINXB)
|
|
&& (MainForm.radioType != RADIOTYPE.HYT) && (MainForm.radioType != RADIOTYPE.HARRIS) && (MainForm.radioType != RADIOTYPE.REPEATER_TRBO))
|
|
{
|
|
gbTelemetry.Visible = false;
|
|
}
|
|
|
|
if ((MainForm.radioType == RADIOTYPE.HARRIS)||(MainForm.radioType == RADIOTYPE.ATLAS))
|
|
{
|
|
lbAlarmType.ForeColor = MainForm.HarTextColor;
|
|
lbEmail.ForeColor = MainForm.HarTextColor;
|
|
lbSpeed.ForeColor = MainForm.HarTextColor;
|
|
lbUnitName.ForeColor = MainForm.HarTextColor;
|
|
gbDigital1.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbDigital2.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbDigital3.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbDigital4.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbDigital5.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbEmailAlarm.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbSpeed.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbTelemetry.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gbZoneAndLandmarks.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
gpAlarms.GroupBoxElement.ForeColor = MainForm.HarTextColor;
|
|
chbDigital1.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbDigital2.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbDigital3.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbDigital4.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbDigital5.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbEmergency.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbLand.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbLoneWorker.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbPopupEm.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbPopupGeo.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbPopupSpeed.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbPopupTelem.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbSendAlarmEmail.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbSoundEm.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbSoundGeo.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbSoundSpeed.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbSoundTelem.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbSpeed.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
chbGeofence.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
rbKMs.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
rbMiles.ButtonElement.TextElement.ForeColor = MainForm.HarTextColor;
|
|
}
|
|
|
|
if (MainForm.radioType == RADIOTYPE.CONECTPLUS)
|
|
{
|
|
gpAlarms.Visible = false;
|
|
gbZoneAndLandmarks.Location = new Point(gbZoneAndLandmarks.Location.X - 139, gbZoneAndLandmarks.Location.Y);
|
|
gbSpeed.Location = new Point(gbSpeed.Location.X - 139, gbSpeed.Location.Y);
|
|
gbEmailAlarm.Location = new Point(gbEmailAlarm.Location.X - 139, gbEmailAlarm.Location.Y);
|
|
}
|
|
|
|
if (MainForm.radioType == RADIOTYPE.SIMOCO)
|
|
{
|
|
//decide after we see all idea of desing
|
|
}
|
|
chbLoneWorker.Visible = MainForm.radioType != RADIOTYPE.LINX || MainForm.radioType != RADIOTYPE.LINXB;
|
|
parent = _parent;
|
|
tbEmailAdr.ReadOnly = !chbSendAlarmEmail.Checked;
|
|
}
|
|
Int32 oldlistcount = 0;
|
|
|
|
#region digital panel enable handles
|
|
/*
|
|
private void chbDigital1_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
panel1.Enabled = chbDigital1.Checked;
|
|
}
|
|
|
|
private void chbDigital2_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
panel2.Enabled = chbDigital2.Checked;
|
|
}
|
|
|
|
private void chbDigital3_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
panel3.Enabled = chbDigital3.Checked;
|
|
}
|
|
|
|
private void chbDigital4_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
panel4.Enabled = chbDigital4.Checked;
|
|
}
|
|
|
|
private void chbDigital5_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
panel5.Enabled = chbDigital5.Checked;
|
|
}
|
|
*/
|
|
#endregion
|
|
|
|
|
|
public void Save()
|
|
{
|
|
List<AdminAlerts> alerts = new List<AdminAlerts>();
|
|
// check and add the Emergency panel fields
|
|
if (chbEmergency.ToggleState != ToggleState.Indeterminate || chbLoneWorker.ToggleState != ToggleState.Indeterminate)
|
|
{
|
|
alerts.Add(AdminAlerts.EMERGENCY);
|
|
//if (chbLoneWorker.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.LONE_WORKER);
|
|
}
|
|
|
|
if (chbSoundEm.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.EMERGENCY_SOUND);
|
|
if (chbPopupEm.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.EMERGENCY_POPUP);
|
|
|
|
// check and add the Geo/Landmark panel fields
|
|
if (chbGeofence.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.GEOFENCE);
|
|
if (chbLand.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.LANDMARK);
|
|
if (chbSoundGeo.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.GEOFENCE_SOUND);
|
|
if (chbPopupGeo.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.GEOFENCE_POPUP);
|
|
|
|
|
|
// check and add the Speed panel fields
|
|
if (chbSpeed.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.SPEED);
|
|
if (chbSoundSpeed.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.SPEED_SOUND);
|
|
if (chbPopupSpeed.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.SPEED_POPUP);
|
|
|
|
// check and add the Email panel fields
|
|
if (chbSendAlarmEmail.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.ALARM_ON_EMAIL);
|
|
|
|
// check and add the Telemetry panel fields
|
|
if (chbPopupTelem.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.TELEMETRY_POPUP);
|
|
if (chbSoundTelem.ToggleState != ToggleState.Indeterminate)
|
|
alerts.Add(AdminAlerts.TELEMETRY_SOUND);
|
|
|
|
// do not continue if at least one state is undetermined
|
|
if (alerts.Count < 1)
|
|
{
|
|
RadMessageBox.SetThemeName("TelerikMetroBlue");
|
|
RadMessageBox.Show(MainForm.returnLNGString("selectvalue"), MainForm.returnLNGString("err"), MessageBoxButtons.OK, RadMessageIcon.Info);
|
|
return;
|
|
}
|
|
|
|
if ((MainForm.radioType == RADIOTYPE.MOTO) || (MainForm.radioType == RADIOTYPE.HARRIS) || (MainForm.radioType == RADIOTYPE.HYT) || (MainForm.radioType == RADIOTYPE.REPEATER_TRBO))
|
|
{
|
|
if (tbName1.Text.Trim().Length < 1)
|
|
tbName1.Text = MainForm.returnLNGString("dig") + "1";
|
|
if (tbName2.Text.Trim().Length < 1)
|
|
tbName2.Text = MainForm.returnLNGString("dig") + "2";
|
|
if (tbName3.Text.Trim().Length < 1)
|
|
tbName3.Text = MainForm.returnLNGString("dig") + "3";
|
|
if (tbName4.Text.Trim().Length < 1)
|
|
tbName4.Text = MainForm.returnLNGString("dig") + "4";
|
|
if (tbName5.Text.Trim().Length < 1)
|
|
tbName5.Text = MainForm.returnLNGString("dig") + "5";
|
|
|
|
}
|
|
|
|
|
|
string imei = "";
|
|
List<TelemetryObj> allTelemetries = new List<TelemetryObj>();
|
|
List<int> scIds = new List<int>();
|
|
|
|
foreach (RadListDataItem tmpItem in listBoxUnits.SelectedItems)
|
|
{
|
|
|
|
//string imei = ((Vehicles)listBoxUnits.SelectedValue).Imei;
|
|
imei = ((Vehicles)tmpItem.Value).Imei;
|
|
int scID = ((Vehicles)tmpItem.Value).Sc_id;
|
|
//SM.Debug("IMEI to update:" + imei);
|
|
|
|
// add scId to the list
|
|
scIds.Add(scID);
|
|
|
|
if ((MainForm.radioType == RADIOTYPE.MOTO) || (MainForm.radioType == RADIOTYPE.LINXB) || (MainForm.radioType == RADIOTYPE.HARRIS)
|
|
|| (MainForm.radioType == RADIOTYPE.HYT) || (MainForm.radioType == RADIOTYPE.REPEATER_TRBO))
|
|
{
|
|
// int id, int digitalNr, string digitalType, string transition, string name, bool alarm
|
|
allTelemetries.Add(new TelemetryObj
|
|
{
|
|
Id = 0,
|
|
DigitalNr = 1,
|
|
DigitalType = cbInOut1.Text,
|
|
Transition = cbHighLow1.Text,
|
|
Name = tbName1.Text,
|
|
Alarm = chbDigital1.Checked,
|
|
Sc_Id = scID
|
|
});
|
|
|
|
allTelemetries.Add(new TelemetryObj
|
|
{
|
|
Id = 0,
|
|
DigitalNr = 2,
|
|
DigitalType = cbInOut2.Text,
|
|
Transition = cbHighLow2.Text,
|
|
Name = tbName2.Text,
|
|
Alarm = chbDigital2.Checked,
|
|
Sc_Id = scID
|
|
});
|
|
|
|
allTelemetries.Add(new TelemetryObj
|
|
{
|
|
Id = 0,
|
|
DigitalNr = 3,
|
|
DigitalType = cbInOut3.Text,
|
|
Transition = cbHighLow3.Text,
|
|
Name = tbName3.Text,
|
|
Alarm = chbDigital3.Checked,
|
|
Sc_Id = scID
|
|
});
|
|
|
|
allTelemetries.Add(new TelemetryObj
|
|
{
|
|
Id = 0,
|
|
DigitalNr = 4,
|
|
DigitalType = cbInOut4.Text,
|
|
Transition = cbHighLow4.Text,
|
|
Name = tbName4.Text,
|
|
Alarm = chbDigital4.Checked,
|
|
Sc_Id = scID
|
|
});
|
|
|
|
allTelemetries.Add(new TelemetryObj
|
|
{
|
|
Id = 0,
|
|
DigitalNr = 5,
|
|
DigitalType = cbInOut5.Text,
|
|
Transition = cbHighLow5.Text,
|
|
Name = tbName5.Text,
|
|
Alarm = chbDigital5.Checked,
|
|
Sc_Id = scID
|
|
});
|
|
}
|
|
}
|
|
|
|
List<int> telemetryAlerts = new List<int>();
|
|
if (chbDigital1.ToggleState != ToggleState.Indeterminate)
|
|
telemetryAlerts.Add(1);
|
|
if (chbDigital2.ToggleState != ToggleState.Indeterminate)
|
|
telemetryAlerts.Add(2);
|
|
if (chbDigital3.ToggleState != ToggleState.Indeterminate)
|
|
telemetryAlerts.Add(3);
|
|
if (chbDigital4.ToggleState != ToggleState.Indeterminate)
|
|
telemetryAlerts.Add(4);
|
|
if (chbDigital5.ToggleState != ToggleState.Indeterminate)
|
|
telemetryAlerts.Add(5);
|
|
|
|
|
|
SaveAlarmItems(scIds, alerts);
|
|
|
|
// update all telemetry in one query
|
|
if ((MainForm.radioType == RADIOTYPE.MOTO) || (MainForm.radioType == RADIOTYPE.LINXB) || (MainForm.radioType == RADIOTYPE.HARRIS)
|
|
|| (MainForm.radioType == RADIOTYPE.HYT) || (MainForm.radioType == RADIOTYPE.REPEATER_TRBO))
|
|
DBtel.updateTelemtry(allTelemetries, telemetryAlerts);
|
|
|
|
if (imei != "")
|
|
{
|
|
ManageTelemetryItems();
|
|
ManageAlarmsItems();
|
|
}
|
|
//send restart
|
|
parent.SendRestart();
|
|
}
|
|
|
|
private void ManageTelemetryItems()
|
|
{
|
|
ResetTelemetryItems();
|
|
|
|
if (listBoxUnits.SelectedIndex == -1) return;
|
|
if (listBoxUnits.SelectedItems.Count == 1)
|
|
{
|
|
Int32 sc_id = ((Vehicles)((RadListDataItem)listBoxUnits.SelectedItems[0]).Value).Sc_id;
|
|
chbDigital1.IsThreeState = false;
|
|
chbDigital2.IsThreeState = false;
|
|
chbDigital3.IsThreeState = false;
|
|
chbDigital4.IsThreeState = false;
|
|
chbDigital5.IsThreeState = false;
|
|
try
|
|
{
|
|
telList = DBtel.getAllTelemetryObjs(sc_id);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
return;
|
|
}
|
|
|
|
if (telList.Count > 0)
|
|
{
|
|
foreach (TelemetryObj tObj in telList)
|
|
{
|
|
switch (tObj.DigitalNr)
|
|
{
|
|
case 1:
|
|
chbDigital1.Checked = tObj.Alarm;
|
|
cbInOut1.SelectedIndex = (tObj.DigitalType == "IN") ? 0 : 1;
|
|
cbHighLow1.SelectedIndex = (tObj.Transition == "High") ? 0 : 1;
|
|
tbName1.Text = (tObj.Name == "Digital 1") ? MainForm.returnLNGString("dig") + " 1" : tObj.Name;
|
|
break;
|
|
case 2:
|
|
chbDigital2.Checked = tObj.Alarm;
|
|
cbInOut2.SelectedIndex = (tObj.DigitalType == "IN") ? 0 : 1;
|
|
cbHighLow2.SelectedIndex = (tObj.Transition == "High") ? 0 : 1;
|
|
tbName2.Text = (tObj.Name == "Digital 2") ? MainForm.returnLNGString("dig") + " 2" : tObj.Name;
|
|
break;
|
|
case 3:
|
|
chbDigital3.Checked = tObj.Alarm;
|
|
cbInOut3.SelectedIndex = (tObj.DigitalType == "IN") ? 0 : 1;
|
|
cbHighLow3.SelectedIndex = (tObj.Transition == "High") ? 0 : 1;
|
|
tbName3.Text = (tObj.Name == "Digital 3") ? MainForm.returnLNGString("dig") + " 3" : tObj.Name;
|
|
break;
|
|
case 4:
|
|
chbDigital4.Checked = tObj.Alarm;
|
|
cbInOut4.SelectedIndex = (tObj.DigitalType == "IN") ? 0 : 1;
|
|
cbHighLow4.SelectedIndex = (tObj.Transition == "High") ? 0 : 1;
|
|
tbName4.Text = (tObj.Name == "Digital 4") ? MainForm.returnLNGString("dig") + " 4" : tObj.Name;
|
|
break;
|
|
case 5:
|
|
chbDigital5.Checked = tObj.Alarm;
|
|
cbInOut5.SelectedIndex = (tObj.DigitalType == "IN") ? 0 : 1;
|
|
cbHighLow5.SelectedIndex = (tObj.Transition == "High") ? 0 : 1;
|
|
tbName5.Text = (tObj.Name == "Digital 5") ? MainForm.returnLNGString("dig") + " 5" : tObj.Name;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SM.Debug("telemetry list empty for " + ((Vehicles)((RadListDataItem)listBoxUnits.SelectedItems[0]).Value).VehName/*((Vehicles)listBoxUnits.SelectedValue).VehName*/);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
chbDigital1.IsThreeState = true;
|
|
chbDigital2.IsThreeState = true;
|
|
chbDigital3.IsThreeState = true;
|
|
chbDigital4.IsThreeState = true;
|
|
chbDigital5.IsThreeState = true;
|
|
Byte Dig1Stat = 0; // 0 -false 1 -true 2 -Intermediar
|
|
Byte Dig2Stat = 0;
|
|
Byte Dig3Stat = 0;
|
|
Byte Dig4Stat = 0;
|
|
Byte Dig5Stat = 0;
|
|
Byte IN1Stat = 0, IN2Stat = 0, IN3Stat = 0, IN4Stat = 0,IN5Stat = 0;
|
|
Byte LOW1Stat = 0, LOW2Stat = 0, LOW3Stat = 0, LOW4Stat = 0, LOW5Stat = 0;
|
|
String Dig1value = "", Dig2value = "", Dig3value = "", Dig4value = "", Dig5value = "";
|
|
Boolean first = true;
|
|
List<TelemetryObj> telListTMP = DBtel.getAllTelObjs();
|
|
foreach (RadListDataItem tmpItem in listBoxUnits.SelectedItems)
|
|
{
|
|
string imei = ((Vehicles)tmpItem.Value).Imei;
|
|
telList.Clear();
|
|
try
|
|
{
|
|
foreach (TelemetryObj objx in telListTMP)
|
|
if (objx.Sc_Id == ((Vehicles)tmpItem.Value).Sc_id) telList.Add(objx);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
return;
|
|
}
|
|
if (first)
|
|
{
|
|
|
|
if (telList.Count == 0)
|
|
telList.AddRange(DBtel.getAllTelemetryObjs(((Vehicles)tmpItem.Value).Sc_id));
|
|
|
|
if (telList.Count > 0)
|
|
{
|
|
foreach (TelemetryObj tObj in telList)
|
|
{
|
|
switch (tObj.DigitalNr)
|
|
{
|
|
case 1:
|
|
if (tObj.Alarm) Dig1Stat = 1;
|
|
if (tObj.DigitalType != "IN") IN1Stat = 1;
|
|
if (tObj.Transition == "High") LOW1Stat = 1;
|
|
Dig1value = tObj.Name;
|
|
break;
|
|
case 2:
|
|
if (tObj.Alarm) Dig2Stat = 1;
|
|
if (tObj.DigitalType != "IN") IN2Stat = 1;
|
|
if (tObj.Transition == "High") LOW2Stat = 1;
|
|
Dig2value = tObj.Name;
|
|
break;
|
|
case 3:
|
|
if (tObj.Alarm) Dig3Stat = 1;
|
|
if (tObj.DigitalType != "IN") IN3Stat = 1;
|
|
if (tObj.Transition == "High") LOW3Stat = 1;
|
|
Dig3value = tObj.Name;
|
|
break;
|
|
case 4:
|
|
if (tObj.Alarm) Dig4Stat = 1;
|
|
if (tObj.DigitalType != "IN") IN4Stat = 1;
|
|
if (tObj.Transition == "High") LOW4Stat = 1;
|
|
Dig4value = tObj.Name;
|
|
break;
|
|
case 5:
|
|
if (tObj.Alarm) Dig5Stat = 1;
|
|
if (tObj.DigitalType != "IN") IN5Stat = 1;
|
|
if (tObj.Transition == "High") LOW5Stat = 1;
|
|
Dig5value = tObj.Name;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SM.Debug("telemetry list empty for " + imei/*((Vehicles)listBoxUnits.SelectedValue).VehName*/);
|
|
}
|
|
first = false;
|
|
}
|
|
else
|
|
{
|
|
if(telList.Count == 0)
|
|
telList.AddRange(DBtel.getAllTelemetryObjs(((Vehicles)tmpItem.Value).Sc_id));
|
|
|
|
if (telList.Count > 0)
|
|
{
|
|
foreach (TelemetryObj tObj in telList)
|
|
{
|
|
switch (tObj.DigitalNr)
|
|
{
|
|
case 1:
|
|
if (((tObj.Alarm) && (Dig1Stat == 0)) || ((!tObj.Alarm) && (Dig1Stat == 1))) Dig1Stat = 2;
|
|
if (((tObj.DigitalType == "IN") && (IN1Stat==1)) || ((tObj.DigitalType != "IN") && (IN1Stat==0))) IN1Stat=2;
|
|
if (((tObj.Transition != "High") && (LOW1Stat == 1)) || ((tObj.Transition == "High") && (LOW1Stat == 0))) LOW1Stat = 2;
|
|
Dig1value = tObj.Name;
|
|
break;
|
|
case 2:
|
|
if (((tObj.Alarm) && (Dig2Stat == 0)) || ((!tObj.Alarm) && (Dig2Stat == 1))) Dig2Stat = 2;
|
|
if (((tObj.DigitalType == "IN") && (IN2Stat==1)) || ((tObj.DigitalType != "IN") && (IN2Stat==0))) IN2Stat=2;
|
|
if (((tObj.Transition != "High") && (LOW2Stat == 1)) || ((tObj.Transition == "High") && (LOW2Stat == 0))) LOW2Stat = 2;
|
|
Dig2value = tObj.Name;
|
|
break;
|
|
case 3:
|
|
if (((tObj.Alarm) && (Dig3Stat == 0)) || ((!tObj.Alarm) && (Dig3Stat == 1))) Dig3Stat = 2;
|
|
if (((tObj.DigitalType == "IN") && (IN3Stat==1)) || ((tObj.DigitalType != "IN") && (IN3Stat==0))) IN3Stat=2;
|
|
if (((tObj.Transition != "High") && (LOW3Stat == 1)) || ((tObj.Transition == "High") && (LOW3Stat == 0))) LOW3Stat = 2;
|
|
Dig3value = tObj.Name;
|
|
break;
|
|
case 4:
|
|
if (((tObj.Alarm) && (Dig4Stat == 0)) || ((!tObj.Alarm) && (Dig4Stat == 1))) Dig4Stat = 2;
|
|
if (((tObj.DigitalType == "IN") && (IN4Stat==1)) || ((tObj.DigitalType != "IN") && (IN4Stat==0))) IN4Stat=2;
|
|
if (((tObj.Transition != "High") && (LOW4Stat == 1)) || ((tObj.Transition == "High") && (LOW4Stat == 0))) LOW4Stat = 2;
|
|
Dig4value = tObj.Name;
|
|
break;
|
|
case 5:
|
|
if (((tObj.Alarm) && (Dig5Stat == 0)) || ((!tObj.Alarm) && (Dig5Stat == 1))) Dig5Stat = 2;
|
|
if (((tObj.DigitalType == "IN") && (IN5Stat==1)) || ((tObj.DigitalType != "IN") && (IN5Stat==0))) IN5Stat=2;
|
|
if (((tObj.Transition != "High") && (LOW5Stat == 1)) || ((tObj.Transition == "High") && (LOW5Stat == 0))) LOW5Stat = 2;
|
|
Dig5value = tObj.Name;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SM.Debug("telemetry list empty for " + ((Vehicles)((RadListDataItem)listBoxUnits.SelectedItems[0]).Value).Imei/*((Vehicles)listBoxUnits.SelectedValue).VehName*/);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (Dig1Stat == 1) chbDigital1.Checked = true;
|
|
else if (Dig1Stat == 2) chbDigital1.ToggleState = ToggleState.Indeterminate;
|
|
if (Dig2Stat == 1) chbDigital2.Checked = true;
|
|
else if (Dig2Stat == 2) chbDigital2.ToggleState = ToggleState.Indeterminate;
|
|
if (Dig3Stat == 1) chbDigital3.Checked = true;
|
|
else if (Dig3Stat == 2) chbDigital3.ToggleState = ToggleState.Indeterminate;
|
|
if (Dig4Stat == 1) chbDigital4.Checked = true;
|
|
else if (Dig4Stat == 2) chbDigital4.ToggleState = ToggleState.Indeterminate;
|
|
if (Dig5Stat == 1) chbDigital5.Checked = true;
|
|
else if (Dig5Stat == 2) chbDigital5.ToggleState = ToggleState.Indeterminate;
|
|
|
|
if (IN1Stat == 0) cbInOut1.SelectedIndex = 0;
|
|
else if (IN1Stat == 1) cbInOut1.SelectedIndex = 1;
|
|
else cbInOut1.Text = "IN/OUT";
|
|
if (IN2Stat == 0) cbInOut2.SelectedIndex = 0;
|
|
else if (IN2Stat == 1) cbInOut2.SelectedIndex = 1;
|
|
else cbInOut2.Text = "IN/OUT";
|
|
if (IN3Stat == 0) cbInOut3.SelectedIndex = 0;
|
|
else if (IN3Stat == 1) cbInOut3.SelectedIndex = 1;
|
|
else cbInOut3.Text = "IN/OUT";
|
|
if (IN4Stat == 0) cbInOut4.SelectedIndex = 0;
|
|
else if (IN4Stat == 1) cbInOut4.SelectedIndex = 1;
|
|
else cbInOut4.Text = "IN/OUT";
|
|
if (IN5Stat == 0) cbInOut5.SelectedIndex = 0;
|
|
else if (IN5Stat == 1) cbInOut5.SelectedIndex = 1;
|
|
else cbInOut5.Text = "IN/OUT";
|
|
|
|
if (LOW1Stat == 0) cbHighLow1.SelectedIndex = 1;
|
|
else if (LOW1Stat == 1) cbHighLow1.SelectedIndex = 0;
|
|
else cbHighLow1.Text = "Low/High";
|
|
if (LOW2Stat == 0) cbHighLow2.SelectedIndex = 1;
|
|
else if (LOW2Stat == 1) cbHighLow2.SelectedIndex = 0;
|
|
else cbHighLow2.Text = "Low/High";
|
|
if (LOW3Stat == 0) cbHighLow3.SelectedIndex = 1;
|
|
else if (LOW3Stat == 1) cbHighLow3.SelectedIndex = 0;
|
|
else cbHighLow3.Text = "Low/High";
|
|
if (LOW4Stat == 0) cbHighLow4.SelectedIndex = 1;
|
|
else if (LOW4Stat == 1) cbHighLow4.SelectedIndex = 0;
|
|
else cbHighLow4.Text = "Low/High";
|
|
if (LOW5Stat == 0) cbHighLow5.SelectedIndex = 1;
|
|
else if (LOW5Stat == 1) cbHighLow5.SelectedIndex = 0;
|
|
else cbHighLow5.Text = "Low/High";
|
|
|
|
tbName1.Text = Dig1value;
|
|
tbName2.Text = Dig2value;
|
|
tbName3.Text = Dig3value;
|
|
tbName4.Text = Dig4value;
|
|
tbName5.Text = Dig5value;
|
|
}
|
|
}
|
|
|
|
/*private void AddTelItems2Imei(int sc_id)
|
|
{
|
|
SM.Debug("Testing telemetry items for sc_id:" + sc_id);
|
|
try
|
|
{
|
|
telList = DBtel.getAllTelemetryObjs(sc_id);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
return;
|
|
}
|
|
List<int> list_digitals = new List<int>();
|
|
if (telList.Count > 0)
|
|
{
|
|
foreach (TelemetryObj tObj in telList)
|
|
{
|
|
list_digitals.Add(tObj.DigitalNr);
|
|
}
|
|
}
|
|
//add telemetry objs
|
|
for (int i = 1; i < 6; i++)
|
|
{
|
|
if (!list_digitals.Contains(i))
|
|
{
|
|
TelemetryObj obj = new TelemetryObj(0, i, "IN", "Low", "Digital " + i, false);
|
|
try
|
|
{
|
|
SM.Debug("Adding tel OBJ ->Digital " + i + " scid:"+sc_id);
|
|
DBtel.addTelemetryObj(obj, sc_id);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("ERROR ADD tel obj for digital " + i);
|
|
SM.Debug(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
|
|
private void AddTelemetry()
|
|
{
|
|
try
|
|
{
|
|
telList = DBtel.getAllTelObjs();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
return;
|
|
}
|
|
//make hash of sc_id
|
|
try
|
|
{
|
|
ArrayList tmpX = new ArrayList();
|
|
foreach (TelemetryObj tObj in telList)
|
|
{
|
|
Boolean find = false;
|
|
foreach (int ox in tmpX)
|
|
if (ox == tObj.Sc_Id) { find = true; break; }
|
|
if (!find) tmpX.Add(tObj.Sc_Id);
|
|
}
|
|
int[,] matrix = new int[tmpX.Count, 5];
|
|
for (int i = 0; i < tmpX.Count; i++)
|
|
for (int j = 0; j < 5; j++)
|
|
matrix[i, j] = 0;
|
|
foreach (TelemetryObj tObj in telList)
|
|
{
|
|
Int32 cnt = -1;
|
|
foreach (Int32 ox in tmpX)
|
|
{
|
|
cnt++;
|
|
if (tObj.Sc_Id == ox) { matrix[cnt, tObj.DigitalNr-1] = 1; break; }
|
|
}
|
|
}
|
|
for (int i = 0; i < tmpX.Count; i++)
|
|
{
|
|
for (int j = 0; j < 5; j++)
|
|
{
|
|
if (matrix[i, j] == 0)
|
|
{
|
|
TelemetryObj obj = new TelemetryObj(0, j+1, "IN", "Low", "Digital " + (j+1).ToString(), false);
|
|
try
|
|
{
|
|
SM.Debug("Adding tel OBJ ->Digital " + (j+1).ToString() + " scid:" + (Int32)tmpX[i]);
|
|
DBtel.addTelemetryObj(obj, (Int32)tmpX[i]);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("ERROR ADD tel obj for digital " + i);
|
|
SM.Debug(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Error on matrix:"+ex.ToString());
|
|
}
|
|
}
|
|
|
|
private void ResetTelemetryItems()
|
|
{
|
|
chbDigital1.ToggleState = ToggleState.Off;
|
|
chbDigital2.ToggleState = ToggleState.Off;
|
|
chbDigital3.ToggleState = ToggleState.Off;
|
|
chbDigital4.ToggleState = ToggleState.Off;
|
|
chbDigital5.ToggleState = ToggleState.Off;
|
|
|
|
chbDigital1.Checked = false;
|
|
cbInOut1.SelectedIndex = 0;
|
|
cbHighLow1.SelectedIndex = 0;
|
|
//cbInOut1.Text = MainForm.returnLNGString("inout");
|
|
//cbHighLow1.Text = MainForm.returnLNGString("highLow");
|
|
tbName1.Text = MainForm.returnLNGString("name") + "1";
|
|
|
|
chbDigital2.Checked = false;
|
|
//cbInOut2.SelectedIndex = -1;
|
|
//cbHighLow2.SelectedIndex = -1;
|
|
cbInOut2.SelectedIndex = 0;
|
|
cbHighLow2.SelectedIndex = 0;
|
|
//cbInOut2.Text = MainForm.returnLNGString("inout");
|
|
//cbHighLow2.Text = MainForm.returnLNGString("highLow");
|
|
tbName2.Text = MainForm.returnLNGString("name") + "2";
|
|
|
|
chbDigital3.Checked = false;
|
|
cbInOut3.SelectedIndex = 0;
|
|
cbHighLow3.SelectedIndex = 0;
|
|
//cbInOut3.Text = MainForm.returnLNGString("inout");
|
|
//cbHighLow3.Text = MainForm.returnLNGString("highLow");
|
|
tbName3.Text = MainForm.returnLNGString("name") + "3";
|
|
|
|
chbDigital4.Checked = false;
|
|
cbInOut4.SelectedIndex = 0;
|
|
cbHighLow4.SelectedIndex = 0;
|
|
//cbInOut4.Text = MainForm.returnLNGString("inout");
|
|
//cbHighLow4.Text = MainForm.returnLNGString("highLow");
|
|
tbName4.Text = MainForm.returnLNGString("name") + "4";
|
|
|
|
chbDigital5.Checked = false;
|
|
cbInOut5.SelectedIndex = 0;
|
|
cbHighLow5.SelectedIndex = 0;
|
|
//cbInOut5.Text = MainForm.returnLNGString("inout");
|
|
//cbHighLow5.Text = MainForm.returnLNGString("highLow");
|
|
tbName5.Text = MainForm.returnLNGString("name") + "5";
|
|
}
|
|
|
|
private void ManageAlarmsItems()
|
|
{
|
|
ResetAlarmsItems();
|
|
if (listBoxUnits.SelectedIndex == -1)
|
|
return;
|
|
|
|
gbEmailAlarm.Enabled = MainForm.HasEmailSettings;
|
|
if (gbEmailAlarm.Enabled)
|
|
{
|
|
pbHint.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
pbHint.Visible = true;
|
|
pbHint.Location = new Point(645, 30);
|
|
}
|
|
|
|
|
|
if (listBoxUnits.SelectedItems.Count == 1)
|
|
{
|
|
string radioID = ((Vehicles)((RadListDataItem)listBoxUnits.SelectedItems[0]).Value).Imei;
|
|
chbEmergency.IsThreeState = false;
|
|
chbLand.IsThreeState = false;
|
|
chbGeofence.IsThreeState = false;
|
|
chbLoneWorker.IsThreeState = false;
|
|
chbSpeed.IsThreeState = false;
|
|
chbSendAlarmEmail.IsThreeState = false;
|
|
|
|
chbPopupTelem.IsThreeState = false;
|
|
chbPopupSpeed.IsThreeState = false;
|
|
chbPopupGeo.IsThreeState = false;
|
|
chbPopupEm.IsThreeState = false;
|
|
chbSoundEm.IsThreeState = false;
|
|
chbSoundGeo.IsThreeState = false;
|
|
chbSoundSpeed.IsThreeState = false;
|
|
chbSoundTelem.IsThreeState = false;
|
|
|
|
Alarm alm = null;
|
|
try { alm = DBalarm.getAllAlarms_Sc_id(((Vehicles)((RadListDataItem)listBoxUnits.SelectedItems[0]).Value).Sc_id); }
|
|
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
|
|
|
|
//chbEmergency.IsThreeState = true;
|
|
if (alm != null)
|
|
{
|
|
if (alm.Emergency != "") chbEmergency.Checked = true;
|
|
if (alm.Landmark != "") chbLand.Checked = true;
|
|
if (alm.Zone != "") chbGeofence.Checked = true;
|
|
if (alm.Loneworker != "") chbLoneWorker.Checked = true;
|
|
if (alm.Speed != "")
|
|
{
|
|
chbSpeed.Checked = true;
|
|
string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
|
|
Int16 speed = 1;
|
|
Int16.TryParse(arrSpeed[0], out speed);
|
|
|
|
if (speed < rseSpeed.Minimum || speed > rseSpeed.Maximum)
|
|
speed = 50;
|
|
|
|
rseSpeed.Value = speed;
|
|
rseSpeed.Text = arrSpeed[0];
|
|
|
|
if (arrSpeed.Length == 2)
|
|
{
|
|
if (arrSpeed[1] == "m") rbMiles.ToggleState = ToggleState.On;
|
|
else rbKMs.ToggleState = ToggleState.On;
|
|
}
|
|
else
|
|
;// SM.Debug("Speed in invalid format :" + alm.Speed);
|
|
}
|
|
else
|
|
chbSpeed.Checked = false;// SM.Debug("Speed in invalid format :" + alm.Speed);
|
|
if (alm.Email != "")
|
|
{chbSendAlarmEmail.Checked = true; tbEmailAdr.Text = alm.Email;}
|
|
if (!alm.Empopup) chbPopupEm.Checked = false;
|
|
if (!alm.Emsound) chbSoundEm.Checked = false;
|
|
if (!alm.Geopopup) chbPopupGeo.Checked = false;
|
|
if (!alm.Geosound) chbSoundGeo.Checked = false;
|
|
if (!alm.Speedpopup) chbPopupSpeed.Checked = false;
|
|
if (!alm.Speedsound) chbSoundSpeed.Checked = false;
|
|
if (!alm.Telempopup) chbPopupTelem.Checked = false;
|
|
if (!alm.Telemsound) chbSoundTelem.Checked = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
chbEmergency.IsThreeState = true;
|
|
chbLand.IsThreeState = true;
|
|
chbGeofence.IsThreeState = true;
|
|
chbLoneWorker.IsThreeState = true;
|
|
chbSpeed.IsThreeState = true;
|
|
chbSendAlarmEmail.IsThreeState = true;
|
|
|
|
chbPopupTelem.IsThreeState = true;
|
|
chbPopupSpeed.IsThreeState = true;
|
|
chbPopupGeo.IsThreeState = true;
|
|
chbPopupEm.IsThreeState = true;
|
|
chbSoundEm.IsThreeState = true;
|
|
chbSoundGeo.IsThreeState = true;
|
|
chbSoundSpeed.IsThreeState = true;
|
|
chbSoundTelem.IsThreeState = true;
|
|
|
|
Boolean first = true;
|
|
Byte EmergStat=0; // 0 -false 1 -true 2 -Intermediar
|
|
Byte LandStat=0;
|
|
Byte ZoneStat=0;
|
|
Byte LoneStat=0;
|
|
Byte SpeedStat = 0;
|
|
Byte EmailStat = 0;
|
|
Byte PopupEmStat = 1, SoundEmStat = 1, PopupGeoStat = 1, SoundGeoStat = 1, PopupSpeedStat = 1, SoundSpeedStat = 1, PopupTelemStat = 1, SoundTelemStat = 1;
|
|
String EmailValue = "";
|
|
String Speedvalue = "";
|
|
Boolean isMile = true;
|
|
|
|
// get all alarms for all the units
|
|
Dictionary<String, Alarm> allAlarms = DBalarm.getAllAlarms();
|
|
|
|
|
|
foreach (RadListDataItem tmpItem in listBoxUnits.SelectedItems)
|
|
{
|
|
Alarm alm = null;
|
|
|
|
try
|
|
{
|
|
// get the alert for a specific sc_id
|
|
if (allAlarms.ContainsKey(((Vehicles)tmpItem.Value).Sc_id + ""))
|
|
alm = allAlarms[((Vehicles)tmpItem.Value).Sc_id + ""];
|
|
// DBalarm.getAllAlarms_Sc_id(((Vehicles)tmpItem.Value).Sc_id);
|
|
}
|
|
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
|
|
|
|
|
|
if (first)
|
|
{
|
|
if (alm != null)
|
|
{
|
|
if (alm.Emergency != "") EmergStat=1;
|
|
if (alm.Landmark != "") LandStat = 1;
|
|
if (alm.Zone != "") ZoneStat=1;
|
|
if (alm.Loneworker != "") LoneStat=1;
|
|
if (alm.Speed != "")
|
|
{
|
|
SpeedStat = 1;
|
|
string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
|
|
Speedvalue = arrSpeed[0];
|
|
if (arrSpeed.Length == 2)
|
|
{
|
|
if (arrSpeed[1] == "m") isMile = true;
|
|
else isMile = false;
|
|
}
|
|
else
|
|
; // SM.Debug("Speed in invalid format :" + alm.Speed);
|
|
}
|
|
else
|
|
;// SM.Debug("Speed in invalid format :" + alm.Speed);
|
|
if (alm.Email != "")
|
|
{
|
|
EmailStat = 1; EmailValue = alm.Email;
|
|
}
|
|
if (!alm.Empopup) PopupEmStat = 0;
|
|
if (!alm.Emsound) SoundEmStat = 0;
|
|
if (!alm.Geopopup) PopupGeoStat = 0;
|
|
if (!alm.Geosound) SoundGeoStat = 0;
|
|
if (!alm.Speedpopup) PopupSpeedStat = 0;
|
|
if (!alm.Speedsound) SoundSpeedStat = 0;
|
|
if (!alm.Telempopup) PopupTelemStat = 0;
|
|
if (!alm.Telemsound) SoundTelemStat = 0;
|
|
}
|
|
first = false;
|
|
}
|
|
else
|
|
{
|
|
if (alm != null)
|
|
{
|
|
if (((alm.Emergency != "") && (EmergStat == 0))||((alm.Emergency == "") && (EmergStat == 1))) EmergStat = 2;
|
|
if (((alm.Landmark != "") && (LandStat == 0))||((alm.Landmark == "") && (LandStat == 1))) LandStat = 2;
|
|
if (((alm.Zone != "") && (ZoneStat ==0))||((alm.Zone == "") && (ZoneStat ==1))) ZoneStat = 2;
|
|
if (((alm.Loneworker != "") && (LoneStat ==0))||((alm.Loneworker == "") && (LoneStat ==1))) LoneStat = 2;
|
|
if (alm.Speed != "")
|
|
{
|
|
string[] arrSpeed = alm.Speed.Split("_".ToCharArray());
|
|
if (Speedvalue != arrSpeed[0])
|
|
{
|
|
Speedvalue = "0"; SpeedStat = 2;
|
|
}
|
|
|
|
if (((alm.Speed != "") && (SpeedStat == 0)) || ((alm.Speed == "") && (SpeedStat == 1)))
|
|
SpeedStat = 2;
|
|
|
|
if (arrSpeed.Length == 2)
|
|
{
|
|
if ((arrSpeed[1] == "m") && (!isMile)) { isMile = true; Speedvalue = "0"; }
|
|
else if ((arrSpeed[1] != "m") && (isMile)) { isMile = false; Speedvalue = "0"; }
|
|
}
|
|
else
|
|
;// SM.Debug("Speed in invalid format :" + alm.Speed);
|
|
}
|
|
else
|
|
{
|
|
if (SpeedStat == 1)
|
|
SpeedStat = 2;
|
|
}
|
|
|
|
if (((alm.Email != "")&&(EmailStat==0))||((alm.Email == "")&&(EmailStat==1)))
|
|
{
|
|
EmailStat = 2;
|
|
EmailValue = alm.Email;
|
|
}
|
|
if (((alm.Empopup)&&(PopupEmStat == 0))||((!alm.Empopup)&&(PopupEmStat == 1))) PopupEmStat = 2;
|
|
if (((alm.Emsound)&&(SoundEmStat == 0))||((!alm.Emsound)&&(SoundEmStat == 1))) SoundEmStat = 2;
|
|
if (((alm.Geopopup) && (PopupGeoStat == 0)) || ((!alm.Geopopup) && (PopupGeoStat == 1))) PopupGeoStat = 2;
|
|
if (((alm.Geosound) && (SoundGeoStat == 0)) || ((!alm.Geosound) && (SoundGeoStat == 1))) SoundGeoStat = 2;
|
|
if (((alm.Speedpopup) && (PopupSpeedStat == 0)) || ((!alm.Speedpopup) && (PopupSpeedStat == 1))) PopupSpeedStat = 2;
|
|
if (((alm.Speedsound) && (SoundSpeedStat == 0)) || ((!alm.Speedsound) && (SoundSpeedStat == 1))) SoundSpeedStat = 2;
|
|
if (((alm.Telempopup) && (PopupTelemStat == 0)) || ((!alm.Telempopup) && (PopupTelemStat == 1))) PopupTelemStat = 2;
|
|
if (((alm.Telemsound) && (SoundTelemStat == 0)) || ((!alm.Telemsound) && (SoundTelemStat == 1))) SoundTelemStat = 2;
|
|
}
|
|
else
|
|
{
|
|
if (EmergStat != 0) EmergStat = 2;
|
|
if (LandStat != 0) LandStat = 2;
|
|
if (ZoneStat != 0) ZoneStat = 2;
|
|
if (LoneStat != 0) LoneStat = 2;
|
|
if (SpeedStat != 0) SpeedStat = 2;
|
|
if (EmailStat != 0) EmailStat = 2;
|
|
if (Speedvalue != "") Speedvalue = "";
|
|
if (PopupEmStat==0) PopupEmStat = 2;
|
|
if (SoundEmStat==0) SoundEmStat = 2;
|
|
if (PopupGeoStat==0) PopupGeoStat = 2;
|
|
if (SoundGeoStat==0) SoundGeoStat = 2;
|
|
if (PopupSpeedStat==0) PopupSpeedStat = 2;
|
|
if (SoundSpeedStat==0) SoundSpeedStat = 2;
|
|
if (PopupTelemStat==0) PopupTelemStat = 2;
|
|
if (SoundTelemStat==0) SoundTelemStat = 2;
|
|
}
|
|
}
|
|
}
|
|
if (EmergStat == 1) chbEmergency.Checked = true;
|
|
else if (EmergStat == 2) { chbEmergency.ToggleState = ToggleState.Indeterminate; }
|
|
if (LandStat == 1) chbLand.Checked = true;
|
|
else if (LandStat == 2) { chbLand.ToggleState = ToggleState.Indeterminate; }
|
|
if (ZoneStat == 1) chbGeofence.Checked = true;
|
|
else if (ZoneStat == 2) { chbGeofence.ToggleState = ToggleState.Indeterminate; }
|
|
if (LoneStat == 1) chbLoneWorker.Checked = true;
|
|
else if (LoneStat == 2) { chbLoneWorker.ToggleState = ToggleState.Indeterminate; }
|
|
|
|
Int16 speed = 1;
|
|
Int16.TryParse(Speedvalue, out speed);
|
|
|
|
if (speed < rseSpeed.Minimum || speed > rseSpeed.Maximum)
|
|
speed = 50;
|
|
|
|
|
|
if (SpeedStat == 1)
|
|
{
|
|
chbSpeed.Checked = true;
|
|
|
|
rseSpeed.Value = speed;
|
|
rseSpeed.Text = Speedvalue;
|
|
|
|
if (isMile) rbMiles.ToggleState = ToggleState.On;
|
|
else rbKMs.ToggleState = ToggleState.On;
|
|
}
|
|
else if (SpeedStat == 2) { chbSpeed.ToggleState = ToggleState.Indeterminate;
|
|
rseSpeed.Value = speed;
|
|
rseSpeed.Text = Speedvalue;
|
|
}
|
|
|
|
if (EmailStat == 1)
|
|
{
|
|
chbSendAlarmEmail.Checked = true; tbEmailAdr.Text = EmailValue;
|
|
}
|
|
else if (EmailStat == 2) { chbSendAlarmEmail.ToggleState = ToggleState.Indeterminate; tbEmailAdr.Text = EmailValue; }
|
|
|
|
if (PopupEmStat == 0) chbPopupEm.Checked = false;
|
|
else if (PopupEmStat == 1) chbPopupEm.Checked = true;
|
|
else chbPopupEm.ToggleState = ToggleState.Indeterminate;
|
|
if (SoundEmStat == 0) chbSoundEm.Checked = false;
|
|
else if (SoundEmStat == 1) chbSoundEm.Checked = true;
|
|
else chbSoundEm.ToggleState = ToggleState.Indeterminate;
|
|
if (PopupGeoStat == 0) chbPopupGeo.Checked = false;
|
|
else if (PopupGeoStat == 1) chbPopupGeo.Checked = true;
|
|
else chbPopupGeo.ToggleState = ToggleState.Indeterminate;
|
|
if (SoundGeoStat == 0) chbSoundGeo.Checked = false;
|
|
else if (SoundGeoStat == 1) chbSoundGeo.Checked = true;
|
|
else chbSoundGeo.ToggleState = ToggleState.Indeterminate;
|
|
if (PopupSpeedStat == 0) chbPopupSpeed.Checked = false;
|
|
else if (PopupSpeedStat == 1) chbPopupSpeed.Checked = true;
|
|
else chbPopupSpeed.ToggleState = ToggleState.Indeterminate;
|
|
if (SoundSpeedStat == 0) chbSoundSpeed.Checked = false;
|
|
else if (SoundSpeedStat == 1) chbSoundSpeed.Checked = true;
|
|
else chbSoundSpeed.ToggleState = ToggleState.Indeterminate;
|
|
if (PopupTelemStat == 0) chbPopupTelem.Checked = false;
|
|
else if (PopupTelemStat == 1) chbPopupTelem.Checked = true;
|
|
else chbPopupTelem.ToggleState = ToggleState.Indeterminate;
|
|
if (SoundTelemStat == 0) chbSoundTelem.Checked = false;
|
|
else if (SoundTelemStat == 1) chbSoundTelem.Checked = true;
|
|
else chbSoundTelem.ToggleState = ToggleState.Indeterminate;
|
|
}
|
|
}
|
|
|
|
private void ResetAlarmsItems()
|
|
{
|
|
chbEmergency.Checked = false;
|
|
chbLoneWorker.Checked = false;
|
|
chbSendAlarmEmail.Checked = false;
|
|
chbSpeed.Checked = false;
|
|
chbGeofence.Checked = false;
|
|
chbLand.Checked = false;
|
|
|
|
chbEmergency.ToggleState = ToggleState.Off;
|
|
chbLoneWorker.ToggleState = ToggleState.Off;
|
|
chbSendAlarmEmail.ToggleState = ToggleState.Off;
|
|
chbSpeed.ToggleState = ToggleState.Off;
|
|
chbGeofence.ToggleState = ToggleState.Off;
|
|
chbLand.ToggleState = ToggleState.Off;
|
|
|
|
chbPopupEm.Checked = true;
|
|
chbPopupGeo.Checked = true;
|
|
chbPopupSpeed.Checked = true;
|
|
chbPopupTelem.Checked = true;
|
|
chbSoundEm.Checked = true;
|
|
chbSoundGeo.Checked = true;
|
|
chbSoundSpeed.Checked = true;
|
|
chbSoundTelem.Checked = true;
|
|
|
|
chbPopupEm.ToggleState = ToggleState.On;
|
|
chbPopupGeo.ToggleState = ToggleState.On;
|
|
chbPopupSpeed.ToggleState = ToggleState.On;
|
|
chbPopupTelem.ToggleState = ToggleState.On;
|
|
chbSoundEm.ToggleState = ToggleState.On;
|
|
chbSoundGeo.ToggleState = ToggleState.On;
|
|
chbSoundSpeed.ToggleState = ToggleState.On;
|
|
chbSoundTelem.ToggleState = ToggleState.On;
|
|
|
|
tbEmailAdr.Text = "mail@server.com";
|
|
|
|
rseSpeed.Value = 50;
|
|
rseSpeed.Text = "50";
|
|
}
|
|
|
|
private void SaveAlarmItems(List<int> scIds, List<AdminAlerts> toUpdateAlerts)
|
|
{
|
|
string emergency = (chbEmergency.Checked) ? "1" : "";
|
|
string loneworker = (chbLoneWorker.Checked) ? "1" : "";
|
|
string email = chbSendAlarmEmail.Checked ? tbEmailAdr.Text : "";
|
|
//compute speed
|
|
string speed4DB = rseSpeed.Value + "_" + ((rbMiles.ToggleState == ToggleState.On)?"m":"km");
|
|
Utils.WriteLine("Speed will be " + speed4DB, ConsoleColor.Cyan);
|
|
//SM.Debug("speed comp= " +speed4DB);
|
|
string speed = chbSpeed.Checked ? speed4DB : "";
|
|
string zone = chbGeofence.Checked ? "zoneIdhere" : "";
|
|
string landmark = chbLand.Checked ? "landmarkid" : "";
|
|
|
|
//string radioID =((Vehicles)listBoxUnits.SelectedValue).Imei;
|
|
|
|
Alarm alm = new Alarm(0, scIds[0], emergency, landmark, zone, loneworker, speed, email, chbPopupEm.Checked, chbSoundEm.Checked, chbPopupGeo.Checked,
|
|
chbSoundGeo.Checked, chbPopupSpeed.Checked, chbSoundSpeed.Checked, chbPopupTelem.Checked, chbSoundTelem.Checked);
|
|
sqlResponse resp = sqlResponse.SQLerror;
|
|
//Console.WriteLine("Face save");
|
|
try
|
|
{
|
|
resp = DBalarm.insertAlarm4ScIds(alm, scIds, toUpdateAlerts);
|
|
//resp = DBalarm.deleteAlarm(radioID);
|
|
//resp = DBalarm.addAlarm(alm, radioID);
|
|
}
|
|
catch (Exception ex) { Console.WriteLine(ex.ToString()); return; }
|
|
if (resp == sqlResponse.done)
|
|
Utils.WriteLine("Alarms saved for " + scIds.Count + " units");
|
|
else
|
|
Utils.WriteLine("sql error Alarms not saved for " + scIds.Count + " units");
|
|
}
|
|
|
|
private void chbEmergency_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
if (chbEmergency.Checked) if (chbLoneWorker.Checked) chbLoneWorker.Checked = false;
|
|
}
|
|
|
|
private void chbLoneWorker_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
|
|
{
|
|
if (chbLoneWorker.Checked) if (chbEmergency.Checked) chbEmergency.Checked = false;
|
|
}
|
|
|
|
private void listBoxUnits_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (oldlistcount != listBoxUnits.SelectedItems.Count)
|
|
{
|
|
//lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + listBoxUnits.SelectedText;
|
|
names = " ";
|
|
foreach (RadListDataItem tmpItem in listBoxUnits.SelectedItems)
|
|
names += " "+((Vehicles)tmpItem.Value).VehName + ",";
|
|
if (names.Length > 1) names = names.Remove(names.Length-1);
|
|
if (names.Length > 120) { names = names.Remove(120); names +="...."; }
|
|
lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + names;
|
|
ManageTelemetryItems();
|
|
ManageAlarmsItems();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Error on listBoxUnits: " + ex.ToString());
|
|
}
|
|
}
|
|
|
|
private void chbSendAlarmEmail_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbSendAlarmEmail.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbSendAlarmEmail.ToggleState = ToggleState.On;
|
|
chbSendAlarmEmail.Checked = true;
|
|
}
|
|
chbSendAlarmEmail.IsThreeState = false;
|
|
}
|
|
|
|
private void chbSpeed_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbSpeed.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbSpeed.ToggleState = ToggleState.On;
|
|
chbSpeed.Checked = true;
|
|
}
|
|
chbSpeed.IsThreeState = false;
|
|
}
|
|
|
|
private void chbZone_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbGeofence.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbGeofence.ToggleState = ToggleState.On;
|
|
chbGeofence.Checked = true;
|
|
}
|
|
chbGeofence.IsThreeState = false;
|
|
}
|
|
|
|
private void chbLand_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbLand.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbLand.ToggleState = ToggleState.On;
|
|
chbLand.Checked = true;
|
|
}
|
|
chbLand.IsThreeState = false;
|
|
}
|
|
|
|
private void chbEmergency_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbEmergency.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbEmergency.ToggleState = ToggleState.On;
|
|
chbEmergency.Checked = true;
|
|
}
|
|
chbEmergency.IsThreeState = false;
|
|
}
|
|
|
|
private void chbLoneWorker_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbLoneWorker.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbLoneWorker.ToggleState = ToggleState.On;
|
|
chbLoneWorker.Checked = true;
|
|
}
|
|
chbLoneWorker.IsThreeState = false;
|
|
}
|
|
|
|
private void chbDigital1_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbDigital1.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbDigital1.ToggleState = ToggleState.On;
|
|
chbDigital1.Checked = true;
|
|
}
|
|
chbDigital1.IsThreeState = false;
|
|
}
|
|
|
|
private void chbDigital2_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbDigital2.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbDigital2.ToggleState = ToggleState.On;
|
|
chbDigital2.Checked = true;
|
|
}
|
|
chbDigital2.IsThreeState = false;
|
|
}
|
|
|
|
private void chbDigital3_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbDigital3.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbDigital3.ToggleState = ToggleState.On;
|
|
chbDigital3.Checked = true;
|
|
}
|
|
chbDigital3.IsThreeState = false;
|
|
}
|
|
|
|
private void chbDigital4_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbDigital4.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbDigital4.ToggleState = ToggleState.On;
|
|
chbDigital4.Checked = true;
|
|
}
|
|
chbDigital4.IsThreeState = false;
|
|
}
|
|
|
|
private void chbDigital5_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbDigital5.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbDigital5.ToggleState = ToggleState.On;
|
|
chbDigital5.Checked = true;
|
|
}
|
|
chbDigital5.IsThreeState = false;
|
|
}
|
|
|
|
private void chbPopupEm_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbPopupEm.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbPopupEm.ToggleState = ToggleState.On;
|
|
chbPopupEm.Checked = true;
|
|
}
|
|
chbPopupEm.IsThreeState = false;
|
|
}
|
|
|
|
private void chbSoundEm_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbSoundEm.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbSoundEm.ToggleState = ToggleState.On;
|
|
chbSoundEm.Checked = true;
|
|
}
|
|
chbSoundEm.IsThreeState = false;
|
|
}
|
|
|
|
private void chbPopupGeo_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbPopupGeo.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbPopupGeo.ToggleState = ToggleState.On;
|
|
chbPopupGeo.Checked = true;
|
|
}
|
|
chbPopupGeo.IsThreeState = false;
|
|
}
|
|
|
|
private void chbSoundGeo_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbSoundGeo.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbSoundGeo.ToggleState = ToggleState.On;
|
|
chbSoundGeo.Checked = true;
|
|
}
|
|
chbSoundGeo.IsThreeState = false;
|
|
}
|
|
|
|
private void chbPopupSpeed_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbPopupSpeed.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbPopupSpeed.ToggleState = ToggleState.On;
|
|
chbPopupSpeed.Checked = true;
|
|
}
|
|
chbPopupSpeed.IsThreeState = false;
|
|
}
|
|
|
|
private void chbSoundSpeed_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbSoundSpeed.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbSoundSpeed.ToggleState = ToggleState.On;
|
|
chbSoundSpeed.Checked = true;
|
|
}
|
|
chbSoundSpeed.IsThreeState = false;
|
|
}
|
|
|
|
private void chbPopupTelem_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbPopupTelem.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbPopupTelem.ToggleState = ToggleState.On;
|
|
chbPopupTelem.Checked = true;
|
|
}
|
|
chbPopupTelem.IsThreeState = false;
|
|
}
|
|
|
|
private void chbSoundTelem_Click(object sender, EventArgs e)
|
|
{
|
|
if (chbSoundTelem.ToggleState == ToggleState.Indeterminate)
|
|
{
|
|
chbSoundTelem.ToggleState = ToggleState.On;
|
|
chbSoundTelem.Checked = true;
|
|
}
|
|
chbSoundTelem.IsThreeState = false;
|
|
}
|
|
|
|
private void listBoxUnits_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
|
|
{
|
|
//Utils.WriteLine("listBoxUnits_SelectedIndexChanged", ConsoleColor.Cyan);
|
|
/*
|
|
try
|
|
{
|
|
//lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + listBoxUnits.SelectedText;
|
|
names = " ";
|
|
foreach (RadListDataItem tmpItem in listBoxUnits.SelectedItems)
|
|
names += " "+((Vehicles)tmpItem.DataBoundItem).VehName + ",";
|
|
if (names.Length > 1) names = names.Remove(names.Length-1);
|
|
if (names.Length > 120) { names = names.Remove(120); names += "...."; }
|
|
lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + names;
|
|
oldlistcount = listBoxUnits.SelectedItems.Count;
|
|
ManageTelemetryItems();
|
|
ManageAlarmsItems();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Error on listBoxUnits: "+ex.ToString());
|
|
} */
|
|
}
|
|
|
|
private System.Windows.Forms.Timer checkSelectedItemChangedTimed;
|
|
private DateTime selecteItemChangedTime = new DateTime(0);
|
|
private void listBoxUnits_SelectedItemsChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
|
|
{
|
|
//Utils.WriteLine("listBoxUnits_SelectedItemsChanged", ConsoleColor.Green);
|
|
selecteItemChangedTime = DateTime.Now;
|
|
|
|
if (checkSelectedItemChangedTimed != null)
|
|
{
|
|
checkSelectedItemChangedTimed?.Stop();
|
|
checkSelectedItemChangedTimed = null;
|
|
}
|
|
|
|
checkSelectedItemChangedTimed = new System.Windows.Forms.Timer();
|
|
checkSelectedItemChangedTimed.Tick += new EventHandler(checkSelectedItemChangedTimer_Tick);
|
|
checkSelectedItemChangedTimed.Interval = 100; // 100 ms
|
|
checkSelectedItemChangedTimed.Start();
|
|
}
|
|
|
|
private void checkSelectedItemChangedTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + listBoxUnits.SelectedText;
|
|
names = " ";
|
|
foreach (RadListDataItem tmpItem in listBoxUnits.SelectedItems)
|
|
names += " " + ((Vehicles)tmpItem.DataBoundItem).VehName + ",";
|
|
if (names.Length > 1) names = names.Remove(names.Length - 1);
|
|
if (names.Length > 120) { names = names.Remove(120); names += "...."; }
|
|
lbUnitName.Text = MainForm.returnLNGString("setunit") + ":" + names;
|
|
oldlistcount = listBoxUnits.SelectedItems.Count;
|
|
ManageTelemetryItems();
|
|
ManageAlarmsItems();
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SM.Debug("Error on listBoxUnits: " + ex.ToString());
|
|
}
|
|
|
|
checkSelectedItemChangedTimed?.Stop();
|
|
checkSelectedItemChangedTimed = null;
|
|
}
|
|
|
|
private void listBoxUnits_CreatingVisualListItem(object sender, CreatingVisualListItemEventArgs args)
|
|
{
|
|
RadListVisualItem visualItem = new RadListVisualItem();
|
|
visualItem.Padding = new Padding(5, 5, 0, 5);
|
|
args.VisualItem = visualItem;
|
|
}
|
|
|
|
private void listBoxUnits_ItemDataBound(object sender, ListItemDataBoundEventArgs args)
|
|
{
|
|
Vehicles view = (Vehicles)args.NewItem.DataBoundItem;
|
|
args.NewItem.Text = "<html>" +
|
|
"<b>" + view.VehName + "</b>" +
|
|
"<br>" + "<i>" +
|
|
" " + view.Imei + "</i>";
|
|
|
|
if (MainForm.carImages.ContainsKey(view.ImgID))
|
|
args.NewItem.Image = MainForm.carImages[view.ImgID];
|
|
}
|
|
|
|
private void listBoxUnits_VisualItemFormatting(object sender, VisualItemFormattingEventArgs e)
|
|
{
|
|
e.VisualItem.DrawFill = true;
|
|
e.VisualItem.NumberOfColors = 1;
|
|
|
|
if (e.VisualItem.Selected)
|
|
e.VisualItem.BackColor = MainForm.GridSelectedRow;
|
|
else
|
|
e.VisualItem.BackColor = Color.White;
|
|
}
|
|
|
|
private void chbSendAlarmEmail_ToggleStateChanged(object sender, StateChangedEventArgs args)
|
|
{
|
|
tbEmailAdr.ReadOnly = !chbSendAlarmEmail.Checked;
|
|
}
|
|
|
|
private void pbHint_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
DisplayToolTip();
|
|
}
|
|
|
|
private void pbHint_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
toolTip1.Hide(pbHint);
|
|
}
|
|
|
|
|
|
private void DisplayToolTip()
|
|
{
|
|
String unitsExample = MainForm.returnLNGString("toolTipEmail1") + Environment.NewLine +
|
|
MainForm.returnLNGString("toolTipEmail2");
|
|
toolTip1.Show(unitsExample, pbHint, 150000);
|
|
}
|
|
}
|
|
}
|