SafeDispatch/ReportsLibrary/Reports/ReportsControl.cs

597 lines
36 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using SafeMobileLib;
using System.Threading;
using System.IO;
namespace ReportstoEmail
{
public partial class ReportsControl : UserControl
{
private SMdb_access smdbObj;
private String glwhere,msgLimit,msgInteger,msgMustSel;
private rep_type RepType;
private ConvertDT convDT;
private ArrayList vehicleListNames;
private ArrayList ZoneListNames;
private volatile Boolean ValidReport = false;
private String minval = "";
private Boolean ButtonStatusCancel = false;
public static volatile Hashtable IdReportHS = new Hashtable();
private void backDB_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
e.Result = ComputeDB(worker, e);
}
long ComputeDB(BackgroundWorker worker, DoWorkEventArgs e)
{
try
{
ValidReport = true;
if ((RepType != rep_type.ENDOFDAY) && (RepType != rep_type.STOP) && (RepType != rep_type.IDLE) && (RepType != rep_type.FLEET))
{
CheckValue();
switch (RepType)
{
case rep_type.LOG:
smdbObj.get_log_view_all(glwhere);
break;
case rep_type.EMERG:
smdbObj.get_EMERG(glwhere);
break;
case rep_type.HIST:
IdReportHS.Clear();
smdbObj.get_History(glwhere, cbComputeAddress.Checked, ckSelectALL.Checked);
if (cbComputeAddress.Checked)
{
GisAddressWorker.RunWorkerAsync();
retrynew = true;
inwhile = false;
int cntmax = 0;
if (IdReportHS.Keys.Count > 0)
{
Int32 contNR = IdReportHS.Keys.Count;
if (cntmax >= contNR)
{
retrynew = false;
inwhile = false;
}
while (retrynew)
{
inwhile = true;
Thread.Sleep(1000);
SM.Debug("Wait 1 second to update");
cntmax++;
if (cntmax > contNR) retrynew = false;
}
if (GisAddressWorker.IsBusy) GisAddressWorker.CancelAsync();
}
try
{
foreach (StopData obj3 in MainForm1.HistDataReport)
{
if (IdReportHS[obj3.Location] != null)
{
obj3.Location = (String)IdReportHS[obj3.Location];
if (obj3.Location != "no address") smdbObj.Update_address_hist(obj3.Location, obj3.unique_id, obj3.Location);
}
}
}
catch (Exception ex)
{
SM.Debug("Exception on add address data in DB:" + ex.ToString());
}
}
break;
case rep_type.ALLALARM:
smdbObj.get_ALLAlarm(glwhere);
break;
case rep_type.GEOFENC:
case rep_type.LAND:
smdbObj.get_LANDANDZONE(glwhere, RepType);
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 ";
smdbObj.get_TelemHist_alarm_event(glwhere);
foreach (SpeedData obj in MainForm1.SpeedingList)
{
Boolean updateDB = false;
if ((obj.Address == "") || (obj.Address == " "))
{
try
{
Int32 step = ((Vehicle)MainForm1.vehicleHT[(String)MainForm1.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;
}
if ((neartheTime.m_address == "") || (neartheTime.m_address == " "))
{
if (cbComputeAddress.Checked)
{
MainForm1.AddrCnt++;
MainForm1.AddrGISQueue.Enqueue(new AddrAndID(MainForm1.AddrCnt, neartheTime.m_lat, neartheTime.m_lng));
MainForm1.IdReportHS.Add(MainForm1.AddrCnt.ToString(), "no address");
String Idtofind = MainForm1.AddrCnt.ToString();
Boolean retrynew = true;
Int32 cntmax = 0;
while (retrynew)
{
cntmax++;
retrynew = false;
if ((String)MainForm1.IdReportHS[Idtofind] == "no address")
{
System.Threading.Thread.Sleep(200);
SM.Debug("wait 200msec for address");
retrynew = true;
}
else obj.Address = (String)MainForm1.IdReportHS[Idtofind];
if (cntmax > 10) retrynew = false;
}
}
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
{
obj.Address = neartheTime.m_address;
updateDB = true;
}
}
else obj.Address = "N/A";
//update datebase telemetry
if (updateDB) smdbObj.Update_address_telem(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '));
}
catch (Exception ex)
{
SM.Debug("Error on update telemetry address:" + ex.ToString());
}
}
}
break;
case rep_type.SPEED:
smdbObj.get_Speeding(glwhere);
foreach (SpeedData obj in MainForm1.SpeedingList)
{
Boolean updateDB = false;
if (obj.Address == "no address")
{
try
{
Int32 step = ((Vehicle)MainForm1.vehicleHT[(String)MainForm1.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)
{
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 (cbComputeAddress.Checked)
{
MainForm1.AddrCnt++;
MainForm1.AddrGISQueue.Enqueue(new AddrAndID(MainForm1.AddrCnt, neartheTime.m_lat, neartheTime.m_lng));
MainForm1.IdReportHS.Add(MainForm1.AddrCnt.ToString(), "no address");
String Idtofind = MainForm1.AddrCnt.ToString();
Boolean retrynew = true;
Int32 cntmax = 0;
while (retrynew)
{
cntmax++;
retrynew = false;
if ((String)MainForm1.IdReportHS[Idtofind] == "no address")
{
System.Threading.Thread.Sleep(200);
SM.Debug("Wait 200msec");
retrynew = true;
}
else obj.Address = (String)MainForm1.IdReportHS[Idtofind];
if (cntmax > 10) retrynew = false;
}
}
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
{
obj.Address = neartheTime.m_address;
updateDB = true;
}
}
else obj.Address = "N/A";
//update datebase Speed
if (updateDB) smdbObj.Update_address_speed(obj.sc_id, obj.timeGMT, obj.Address.Replace(',', ' '));
}
catch (Exception ex)
{
SM.Debug("Error on update telemetry address:" + ex.ToString());
}
}
}
break;
}
}
else
{
if (CheckLimit())
{
if ((RepType == rep_type.ENDOFDAY) || (RepType == rep_type.STOP) || (RepType == rep_type.IDLE))
{
//MainForm1.PositionList = 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, (((RadComboBoxItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).sc_id);
MainForm1.PositionList = smdbObj.get_position_for_report((Int32)(new ConvertDT().GetSecondsLocalFromDT(dtFrom.Value)), (Int32)(new ConvertDT().GetSecondsLocalFromDT(dtTo.Value)), (((RadListDataItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).sc_id);
MainForm1.NameReport = (((RadListDataItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).Name;
}
if (RepType == rep_type.FLEET)
{
foreach (FleetIdandPos obj in MainForm1.FleetPosList)
{
//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)MainForm1.vehicleHT[obj.Name]).sc_id);
obj.Position = smdbObj.get_position_for_report((Int32)(new ConvertDT().GetSecondsLocalFromDT(dtFrom.Value)), (Int32)(new ConvertDT().GetSecondsLocalFromDT(dtTo.Value)), ((Vehicle)MainForm1.vehicleHT[obj.Name]).sc_id);
SM.Debug(obj.Name + " " + obj.Position.Count);
}
}
}
else
{
SM.Debug("Not valid Report");
ValidReport = false;
}
}
}
catch (Exception ex)
{
SM.Debug("Error compute date from DB:" + ex.ToString());
}
return 1;
}
private void backDB_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
switch (RepType)
{
case rep_type.LOG:
ONOFFReport tmp = new ONOFFReport();
tmp.timeCaptionTextBox.Value = MainForm1.returnLNGString("SMSMessTime");
switch (MainForm1.radioType)
{
case RADIOTYPE.CONECTPLUS:
case RADIOTYPE.MOTO:
tmp.titleTextBox.Value = MainForm1.returnLNGString("SMSlogradio");
break;
case RADIOTYPE.HYT:
tmp.titleTextBox.Value = MainForm1.returnLNGString("SMSlogradioHYT");
break;
case RADIOTYPE.HARRIS:
tmp.titleTextBox.Value = MainForm1.returnLNGString("SMSlogradioHARRIS");
break;
case RADIOTYPE.ATLAS:
tmp.titleTextBox.Value = MainForm1.returnLNGString("SMSlogradioAstro");
break;
case RADIOTYPE.TETRA:
tmp.titleTextBox.Value = MainForm1.returnLNGString("SMSlogradioTetra");
break;
}
tmp.statusCaptionTextBox.Value = MainForm1.returnLNGString("SMSStatus");
tmp.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
reportViewer1.ReportSource = tmp;
break;
case rep_type.SPEED:
lbwaitbar.Visible = false;
prog.Visible = false;
cbComputeAddress.Visible = true;
SpeedingReport tmpSpeed = new SpeedingReport();
tmpSpeed.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
if (MainForm1.isInMile) tmpSpeed.speedCaptionTextBox.Value = MainForm1.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm1.milesh + ")";
else tmpSpeed.speedCaptionTextBox.Value = MainForm1.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm1.kmh + ")";
tmpSpeed.timeCaptionTextBox.Value = MainForm1.returnLNGString("alarmsListColumns1");
tmpSpeed.titleTextBox.Value = MainForm1.returnLNGString("speedalarm");
tmpSpeed.dataCaptionTextBox.Value = MainForm1.returnLNGString("rapday");
tmpSpeed.addressCaptionTextBox.Value = MainForm1.returnLNGString("addrOrLatLng");
tmpSpeed.txObeserv.Value = MainForm1.returnLNGString("obsSpeed");
reportViewer1.ReportSource = tmpSpeed;
break;
case rep_type.TELEMETRY_EVENT:
case rep_type.TELEMETRY_ALARM:
lbwaitbar.Visible = false;
prog.Visible = false;
cbComputeAddress.Visible = true;
SpeedingReport tmpTelem = new SpeedingReport();
tmpTelem.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
tmpTelem.timeCaptionTextBox.Value = MainForm1.returnLNGString("alarmsListColumns1");
if (RepType == rep_type.TELEMETRY_ALARM)
{
tmpTelem.titleTextBox.Value = MainForm1.returnLNGString("telemreport");
tmpTelem.speedCaptionTextBox.Value = MainForm1.returnLNGString("alarmtype");
}
else
{
tmpTelem.titleTextBox.Value = MainForm1.returnLNGString("telemevent");
tmpTelem.speedCaptionTextBox.Value = MainForm1.returnLNGString("eventype");
}
tmpTelem.dataCaptionTextBox.Value = MainForm1.returnLNGString("rapday");
tmpTelem.addressCaptionTextBox.Value = MainForm1.returnLNGString("addrOrLatLng");
tmpTelem.txObeserv.Value = "";
reportViewer1.ReportSource = tmpTelem;
break;
case rep_type.GEOFENC:
ZoneReport tmpZone = new ZoneReport();
tmpZone.landNameCaptionTextBox.Value = MainForm1.returnLNGString("zonename");
tmpZone.landTypeCaptionTextBox.Value = MainForm1.returnLNGString("alarmtype");
tmpZone.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
tmpZone.timeCaptionTextBox.Value = MainForm1.returnLNGString("alarmsListColumns1");
tmpZone.titleTextBox.Value = MainForm1.returnLNGString("InZoneReport");
reportViewer1.ReportSource = tmpZone;
break;
case rep_type.LAND:
ZoneReport tmpLand = new ZoneReport();
tmpLand.landNameCaptionTextBox.Value = MainForm1.returnLNGString("landmarkname");
tmpLand.landTypeCaptionTextBox.Value = MainForm1.returnLNGString("alarmtype");
tmpLand.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
tmpLand.timeCaptionTextBox.Value = MainForm1.returnLNGString("alarmsListColumns1");
tmpLand.titleTextBox.Value = MainForm1.returnLNGString("landmarkrep");
reportViewer1.ReportSource = tmpLand;
break;
case rep_type.EMERG:
ONOFFReport tmpEmerg = new ONOFFReport();
tmpEmerg.timeCaptionTextBox.Value = MainForm1.returnLNGString("alarmsListColumns1");
tmpEmerg.titleTextBox.Value = MainForm1.returnLNGString("emergAlarmRep");
tmpEmerg.statusCaptionTextBox.Value = MainForm1.returnLNGString("rapday");
tmpEmerg.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
reportViewer1.ReportSource = tmpEmerg;
break;
case rep_type.HIST:
MainForm1.IsHistroyNotStop = true;
if (cbComputeAddress.Checked)
{
//btPrintReport.Enabled = true;
lbwaitbar.Visible = false;
prog.Visible = false;
cbComputeAddress.Visible = true;
}
StopReport tmpRep2 = new StopReport();
//tmpRep2.titleTextBox.Value = MainForm1.returnLNGString("namesandvehicleHistory") + " " + cbVehName.Text;
if (chVehName.Checked) tmpRep2.titleTextBox.Value = MainForm1.returnLNGString("HistoryRep") + " " + MainForm1.returnLNGString("forvehicle") + " " + cbVehName.Text;
else tmpRep2.titleTextBox.Value = MainForm1.returnLNGString("HistoryRep");
tmpRep2.timeCaptionTextBox.Value = MainForm1.returnLNGString("label3");
tmpRep2.locationCaptionTextBox.Value = MainForm1.returnLNGString("addrOrLatLng");
if (MainForm1.isInMile) tmpRep2.durationCaptionTextBox.Value = MainForm1.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm1.milesh + ")";
else tmpRep2.durationCaptionTextBox.Value = MainForm1.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm1.kmh + ")";
tmpRep2.dataCaptionTextBox.Value = MainForm1.returnLNGString("dateSTOP");
reportViewer1.ReportSource = tmpRep2;
/* Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = (Telerik.Reporting.Report)tmpRep2;
Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
using (FileStream fs = new FileStream("C:\\biguhist.pdf", FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}*/
break;
case rep_type.ALLALARM:
MainForm1.IsHistroyNotStop = true;
StopReport tmpRep3 = new StopReport();
if (chVehName.Checked)
tmpRep3.titleTextBox.Value = MainForm1.returnLNGString("allAlarmTitle") + " " + MainForm1.returnLNGString("forvehicle") + " " + cbVehName.Text;
else tmpRep3.titleTextBox.Value = MainForm1.returnLNGString("allAlarmTitle");
tmpRep3.timeCaptionTextBox.Value = MainForm1.returnLNGString("alarmtype");
tmpRep3.locationCaptionTextBox.Value = MainForm1.returnLNGString("SMSMessTime");
tmpRep3.durationCaptionTextBox.Value = MainForm1.returnLNGString("lbDescript");
tmpRep3.dataCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
reportViewer1.ReportSource = tmpRep3;
break;
case rep_type.ENDOFDAY:
if (ValidReport)
{
EndOfDay tmpEND = new EndOfDay();
tmpEND.distanceCaptionTextBox.Value = MainForm1.returnLNGString("namedistance");
tmpEND.startAddressCaptionTextBox.Value = MainForm1.returnLNGString("namestrlocTRAV");
tmpEND.stopAddressCaptionTextBox.Value = MainForm1.returnLNGString("namestoplocTRAV");
tmpEND.startTimeCaptionTextBox.Value = MainForm1.returnLNGString("namestrhourTRAV");
tmpEND.stopTimeCaptionTextBox.Value = MainForm1.returnLNGString("label3");
tmpEND.titleTextBox.Value = MainForm1.returnLNGString("nameandvehicleTRAV") + " " + cbVehName.Text;
tmpEND.tripCaptionTextBox.Value = MainForm1.returnLNGString("nameroad");
reportViewer1.ReportSource = tmpEND;
}
break;
case rep_type.STOP:
if (ValidReport)
{
MainForm1.IsHistroyNotStop = false;
MainForm1.IsIdle = false;
StopReport tmpRep = new StopReport();
tmpRep.titleTextBox.Value = MainForm1.returnLNGString("namesandvehicleSTOP") + " " + cbVehName.Text;
tmpRep.timeCaptionTextBox.Value = MainForm1.returnLNGString("label3");
tmpRep.locationCaptionTextBox.Value = MainForm1.returnLNGString("locationSTOP");
tmpRep.durationCaptionTextBox.Value = MainForm1.returnLNGString("waitingSTOP");
tmpRep.dataCaptionTextBox.Value = MainForm1.returnLNGString("dateSTOP");
reportViewer1.ReportSource = tmpRep;
}
break;
case rep_type.IDLE:
if (ValidReport)
{
MainForm1.IsHistroyNotStop = false;
MainForm1.IsIdle = true;
StopReport tmpIDLE = new StopReport();
tmpIDLE.titleTextBox.Value = MainForm1.returnLNGString("namesandvehicleSTOPENG") + " " + cbVehName.Text;
tmpIDLE.timeCaptionTextBox.Value = MainForm1.returnLNGString("label3");
tmpIDLE.locationCaptionTextBox.Value = MainForm1.returnLNGString("locationSTOP");
tmpIDLE.durationCaptionTextBox.Value = MainForm1.returnLNGString("waitingSTOP");
tmpIDLE.dataCaptionTextBox.Value = MainForm1.returnLNGString("dateSTOP");
reportViewer1.ReportSource = tmpIDLE;
}
break;
case rep_type.FLEET:
if (ValidReport)
{
FleetReport tmpFleet = new FleetReport();
tmpFleet.distanceCaptionTextBox.Value = MainForm1.returnLNGString("namedistance");
tmpFleet.nameCaptionTextBox.Value = MainForm1.returnLNGString("htableVehiclesListColumns1");
tmpFleet.startCaptionTextBox.Value = MainForm1.returnLNGString("namefirst") + " " + MainForm1.returnLNGString("namerun");
tmpFleet.stopCaptionTextBox.Value = MainForm1.returnLNGString("namefirst") + " " + MainForm1.returnLNGString("namewait");
tmpFleet.titleTextBox.Value = MainForm1.returnLNGString("titleFLEET");
tmpFleet.tripsCaptionTextBox.Value = MainForm1.returnLNGString("nameroute");
reportViewer1.ReportSource = tmpFleet;
}
break;
}
//reportViewer1.RefreshReport();
ButtonStatusCancel = false;
btPrintReport.Text = MainForm1.returnLNGString("btShowReport");
}
public static volatile Queue AddrGISQueue = new Queue();
private volatile Boolean findaddress;
private volatile AddrAndID tmpAddrAndID;
private Double valHash;
private volatile String AddrtmpX;
private volatile GoogleAddr2 volltmpGo = new GoogleAddr2();
private volatile Boolean retrynew;
private volatile Boolean inwhile = false;
private void GisAddressWorker_DoWork(object sender, DoWorkEventArgs e)
{
try
{
BackgroundWorker worker = sender as BackgroundWorker;
while (AddrGISQueue.Count > 0)
{
if ((worker.CancellationPending == true))
{
e.Cancel = true;
break;
}
tmpAddrAndID = (AddrAndID)AddrGISQueue.Dequeue();
findaddress = false;
try
{
tmpAddrAndID.LNG = Math.Round(tmpAddrAndID.LNG, 4);
tmpAddrAndID.LAT = Math.Round(tmpAddrAndID.LAT, 4);
valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001;
if (MainForm1.AddrHass[valHash] != null)
{
tmpAddrAndID.Address = (String)MainForm1.AddrHass[valHash];
findaddress = true;
}
else
{
AddrtmpX = smdbObj.get_address(tmpAddrAndID.LAT, tmpAddrAndID.LNG);
if (AddrtmpX != "")
{
MainForm1.AddrHass.Add(valHash, AddrtmpX);
tmpAddrAndID.Address = AddrtmpX;
findaddress = true;
}
}
}
catch
{
}
if (!findaddress)
{
tmpAddrAndID.Address = volltmpGo.getAddressLATLNG(tmpAddrAndID.LAT, tmpAddrAndID.LNG);
}
if ((tmpAddrAndID.Address != "") && (tmpAddrAndID.Address != " "))
{
if (!findaddress)
{
try
{
if (tmpAddrAndID.Address != "N/A")
{
valHash = tmpAddrAndID.LNG + tmpAddrAndID.LAT * 0.000001;
MainForm1.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;
}
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;
MainForm1.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;
}
}
}
}
catch (Exception ex)
{
SM.Debug("Error retrive address:" + ex.ToString());
}
Thread.Sleep(10);
}
}
}