public static string findBeat(double lat, double lon) { string beatName = "NOT FOUND"; try { foreach (beatInformation bi in beatInfos) { var bsFound = from bs in BeatSegments.bsPolyList where bi.beatSegmentList.Contains(bs.segmentID) select bs; foreach (beatSegmentPolygonData bsd in bsFound) { if (lat >= bsd.minLat && lon <= bsd.maxLat && lon >= bsd.minLon && lon <= bsd.maxLat) { int i; int j = bsd.geoFence.Count - 1; for (i = 0; i < bsd.geoFence.Count; i++) { if (bsd.geoFence[i].lon < lon && bsd.geoFence[j].lon >= lon || bsd.geoFence[j].lon < lon && bsd.geoFence[i].lon >= lon) { if (bsd.geoFence[i].lat + (lon - bsd.geoFence[i].lon) / (bsd.geoFence[j].lon - bsd.geoFence[i].lon) * (bsd.geoFence[j].lat - bsd.geoFence[i].lat) < lat) { beatInformation biRet = (beatInformation)bsFound; beatName = biRet.BeatName; return(beatName); } } j = i; } } } } } catch (Exception ex) { Logging.EventLogger logger = new Logging.EventLogger(); logger.LogEvent(ex.ToString(), true); } return(beatName); }
public static bool checkBeatIntersect(double lat, double lon, string beatID) { bool inPoly = false; try { var found = from bi in beatInfos where bi.BeatID == beatID select bi; foreach (beatInformation bi in found) { var bsFound = from bs in BeatSegments.bsPolyList where bi.beatSegmentList.Contains(bs.segmentID) select bs; foreach (beatSegmentPolygonData bsd in bsFound) { if (lat >= bsd.minLat && lon <= bsd.maxLat && lon >= bsd.minLon && lon <= bsd.maxLat) { int i; int j = bsd.geoFence.Count - 1; for (i = 0; i < bsd.geoFence.Count; i++) { if (bsd.geoFence[i].lon < lon && bsd.geoFence[j].lon >= lon || bsd.geoFence[j].lon < lon && bsd.geoFence[i].lon >= lon) { if (bsd.geoFence[i].lat + (lon - bsd.geoFence[i].lon) / (bsd.geoFence[j].lon - bsd.geoFence[i].lon) * (bsd.geoFence[j].lat - bsd.geoFence[i].lat) < lat) { inPoly = !inPoly; } } j = i; } } } } } catch (Exception ex) { Logging.EventLogger logger = new Logging.EventLogger(); logger.LogEvent(ex.ToString(), true); } return(inPoly); }
private void UDPListenThread() { logger = new Logging.EventLogger(); //for the initial dev phase we're going to log a lot, disable this before //rolling out to production udpListener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint ourEndPoint = new IPEndPoint(IPAddress.Any, 9017); IPEndPoint end = new IPEndPoint(IPAddress.Any, 9017); EndPoint Identifier = (EndPoint)end; udpListener.Bind(ourEndPoint); while (true) { string message = null;; try { bool fwdThisMessage = true; int length = udpListener.ReceiveFrom(data, ref Identifier); message = System.Text.Encoding.UTF8.GetString(data, 0, length); string _ipaddr = ((IPEndPoint)Identifier).Address.ToString(); if (message.Contains("<FWD>")) { //it's a forwarded message, remove the <FWD> tags and find the specified IPAddress //then treat it like a normal packet message = message.Replace("<FWD>", ""); int firstLT = message.IndexOf('<'); _ipaddr = message.Substring(0, firstLT); message = message.Replace(_ipaddr + "</FWD>", ""); fwdThisMessage = false; //done, let it move on } //JavaScriptSerializer js = new JavaScriptSerializer(); TowTruck.TowTruck thisTruck; thisTruck = DataClasses.GlobalData.FindTowTruck(_ipaddr); string type = ""; try { if (message.Contains("<GPS>")) { type = "GPS"; if (forward == true && fwdThisMessage == true) { string fwdMsg = "<FWD>" + _ipaddr + "</FWD>" + message; foreach (string s in OtherServers) { udpSend.ForwardMessage(fwdMsg, s); } } } } catch { } try { if (message.Contains("<State>")) { type = "State"; if (forward == true && fwdThisMessage == true) { string fwdMsg = "<FWD>" + _ipaddr + "</FWD>" + message; foreach (string s in OtherServers) { udpSend.ForwardMessage(fwdMsg, s); } } } } catch { } try { if (message.Contains("<IPHistory>")) { type = "IPHistory"; if (forward == true && fwdThisMessage == true) { string fwdMsg = "<FWD>" + _ipaddr + "</FWD>" + message; foreach (string s in OtherServers) { udpSend.ForwardMessage(fwdMsg, s); } } } } catch { } /* * string[] splitMsg = message.Split('|'); * string type = splitMsg[0].ToString(); * string msg = splitMsg[1].ToString(); * */ TowTruck.GPS thisGPS = null; TowTruck.State thisState = null; TowTruck.IPHistory history = null; if (type == "GPS") { //thisGPS = js.Deserialize<TowTruck.GPS>(msg); XmlSerializer ser = new XmlSerializer(typeof(TowTruck.GPS)); StringReader rdr = new StringReader(message); thisGPS = (TowTruck.GPS)ser.Deserialize(rdr); SqlGeographyBuilder builder = new SqlGeographyBuilder(); builder.SetSrid(4326); builder.BeginGeography(OpenGisGeographyType.Point); builder.BeginFigure(thisGPS.Lat, thisGPS.Lon); builder.EndFigure(); builder.EndGeography(); thisGPS.Position = builder.ConstructedGeography; } else if (type == "State") { XmlSerializer ser = new XmlSerializer(typeof(TowTruck.State)); //testing, this was causing an error on parse, but couldn't find a reason why message = message.Replace(" xmlns=''", ""); StringReader rdr = new StringReader(message); thisState = (TowTruck.State)ser.Deserialize(rdr); } else if (type == "IPHistory") { XmlSerializer ser = new XmlSerializer(typeof(TowTruck.IPHistory)); StringReader rdr = new StringReader(message); history = (TowTruck.IPHistory)ser.Deserialize(rdr); } if (thisTruck != null) { try { thisTruck.LastMessage.LastMessageReceived = DateTime.Now; DataClasses.GlobalData.UpdateTowTruck(_ipaddr, thisTruck); //DataClasses.GlobalData.AddTowTruck(thisTruck); if (string.IsNullOrEmpty(thisTruck.Extended.TruckNumber)) { SQL.SQLCode mySQL = new SQL.SQLCode(); TowTruck.TowTruckExtended thisExtended = mySQL.GetExtendedData(thisTruck.Identifier); thisTruck.Extended = thisExtended; thisTruck.TruckNumber = thisExtended.TruckNumber; } /*if (thisTruck.assignedBeat.Loaded == false) // * { * SQL.SQLCode mySQL = new SQL.SQLCode(); * TowTruck.AssignedBeat thisAssignedBeat = mySQL.GetAssignedBeat(thisTruck.Extended.FleetVehicleID); * if (thisAssignedBeat != null) * { * thisTruck.assignedBeat = thisAssignedBeat; * } * }*/ } catch { } } else { try { thisTruck = new TowTruck.TowTruck(_ipaddr); DataClasses.GlobalData.AddTowTruck(thisTruck); SQL.SQLCode mySQL = new SQL.SQLCode(); TowTruck.TowTruckExtended thisExtended = mySQL.GetExtendedData(thisTruck.Identifier); thisTruck.Extended = thisExtended; thisTruck.TruckNumber = thisExtended.TruckNumber; thisTruck.Status.StatusStarted = DateTime.Now; } catch { } } if (type == "GPS") { thisTruck.UpdateGPS(thisGPS); thisTruck.TowTruckGPSUpdate(); } if (type == "State") { thisTruck.UpdateState(thisState); thisTruck.TowTruckChanged(); } if (type == "IPHistory") { if (thisTruck.State != null && string.IsNullOrEmpty(thisTruck.State.IPList)) { thisTruck.State.IPList += history.IP; } else if (thisTruck.State != null && !string.IsNullOrEmpty(thisTruck.State.IPList)) { thisTruck.State.IPList += "," + history.IP; } } thisTruck.TTQueue.Enqueue(message); } catch (Exception ex) { logger.LogEvent(DateTime.Now.ToString() + " Error in UDP Listening Thread" + Environment.NewLine + ex.ToString() + Environment.NewLine + "Original Message:" + Environment.NewLine + message, true); } } }
void dumpTimer_Elapsed(object sender, ElapsedEventArgs e) { //throw new NotImplementedException(); try { if (DataClasses.GlobalData.currentTrucks.Count > 0) { Guid _beatID = new Guid("00000000-0000-0000-0000-000000000000"); string[] srvListString = ConfigurationManager.AppSettings["OtherServers"].ToString().Split('|'); //List<TowTruck.TowTruck> allTrucks = new List<TowTruck.TowTruck>(); List <srSecondaryService.CopyTruck> ctList = new List <srSecondaryService.CopyTruck>(); foreach (TowTruck.TowTruck t in DataClasses.GlobalData.currentTrucks) { if (t.assignedBeat.BeatID != null && t.assignedBeat.BeatID != new Guid("00000000-0000-0000-0000-000000000000")) { _beatID = t.GPSPosition.BeatID; } srSecondaryService.CopyTruck newTruck = new srSecondaryService.CopyTruck(); newTruck.Status = new srSecondaryService.CopyStatus(); newTruck.Driver = new srSecondaryService.CopyDriver(); newTruck.Extended = new srSecondaryService.CopyExtended(); newTruck.Identifier = t.Identifier; newTruck.BeatID = t.assignedBeat.BeatID; if (!string.IsNullOrEmpty(t.assignedBeat.BeatNumber)) { newTruck.BeatNumber = t.assignedBeat.BeatNumber; } else { newTruck.BeatNumber = "UNASSIGNED"; } //set up Status newTruck.Status.SpeedingAlarm = t.Status.SpeedingAlarm; newTruck.Status.SpeedingValue = t.Status.SpeedingValue; newTruck.Status.SpeedingTime = t.Status.SpeedingTime; newTruck.Status.OutOfBoundsAlarm = t.Status.OutOfBoundsAlarm; newTruck.Status.OutOfBoundsMessage = t.Status.OutOfBoundsMessage; newTruck.Status.OutOfBoundsTime = t.Status.OutOfBoundsTime; newTruck.Status.OutOfBoundsStartTime = t.Status.OutOfBoundsStartTime; newTruck.Status.VehicleStatus = t.Status.VehicleStatus; newTruck.Status.StatusStarted = t.Status.StatusStarted; newTruck.Status.LogOnAlarm = t.Status.LogOnAlarm; newTruck.Status.LogOnAlarmTime = t.Status.LogOnAlarmTime; newTruck.Status.LogOnAlarmCleared = t.Status.LogOnAlarmCleared; newTruck.Status.LogOnAlarmExcused = t.Status.LogOnAlarmExcused; newTruck.Status.LogOnAlarmComments = t.Status.LogOnAlarmComments; newTruck.Status.RollOutAlarm = t.Status.RollOutAlarm; newTruck.Status.RollOutAlarmTime = t.Status.RollOutAlarmTime; newTruck.Status.RollOutAlarmCleared = t.Status.RollOutAlarmCleared; newTruck.Status.RollOutAlarmExcused = t.Status.RollOutAlarmExcused; newTruck.Status.RollOutAlarmComments = t.Status.RollOutAlarmComments; newTruck.Status.OnPatrolAlarm = t.Status.OnPatrolAlarm; newTruck.Status.OnPatrolAlarmTime = t.Status.OnPatrolAlarmTime; newTruck.Status.OnPatrolAlarmCleared = t.Status.OnPatrolAlarmCleared; newTruck.Status.OnPatrolAlarmExcused = t.Status.OnPatrolAlarmExcused; newTruck.Status.OnPatrolAlarmComments = t.Status.OnPatrolAlarmComments; newTruck.Status.RollInAlarm = t.Status.RollInAlarm; newTruck.Status.RollInAlarmTime = t.Status.RollInAlarmTime; newTruck.Status.RollInAlarmCleared = t.Status.RollInAlarmCleared; newTruck.Status.RollInAlarmExcused = t.Status.RollInAlarmExcused; newTruck.Status.RollInAlarmComments = t.Status.RollInAlarmComments; newTruck.Status.LogOffAlarm = t.Status.LogOffAlarm; newTruck.Status.LogOffAlarmTime = t.Status.LogOffAlarmTime; newTruck.Status.LogOffAlarmCleared = t.Status.LogOffAlarmCleared; newTruck.Status.LogOffAlarmExcused = t.Status.LogOffAlarmExcused; newTruck.Status.LogOffAlarmComments = t.Status.LogOffAlarmComments; newTruck.Status.IncidentAlarm = t.Status.IncidentAlarm; newTruck.Status.IncidentAlarmTime = t.Status.IncidentAlarmTime; newTruck.Status.IncidentAlarmCleared = t.Status.IncidentAlarmCleared; newTruck.Status.IncidentAlarmExcused = t.Status.IncidentAlarmExcused; newTruck.Status.IncidentAlarmComments = t.Status.IncidentAlarmComments; newTruck.Status.GPSIssueAlarm = t.Status.GPSIssueAlarm; //handles NO GPS newTruck.Status.GPSIssueAlarmStart = t.Status.GPSIssueAlarmStart; //handles NO GPS newTruck.Status.GPSIssueAlarmCleared = t.Status.GPSIssueAlarmCleared; newTruck.Status.GPSIssueAlarmExcused = t.Status.GPSIssueAlarmExcused; newTruck.Status.GPSIssueAlarmComments = t.Status.GPSIssueAlarmComments; newTruck.Status.StationaryAlarm = t.Status.StationaryAlarm; //handles no movement, speed = 0 newTruck.Status.StationaryAlarmStart = t.Status.StationaryAlarmStart; //handles no movement, speed = 0 newTruck.Status.StationaryAlarmCleared = t.Status.StationaryAlarmCleared; newTruck.Status.StationaryAlarmExcused = t.Status.StationaryAlarmExcused; newTruck.Status.StationaryAlarmComments = t.Status.StationaryAlarmComments; //update driver newTruck.Driver.DriverID = t.Driver.DriverID; newTruck.Driver.LastName = t.Driver.LastName; newTruck.Driver.FirstName = t.Driver.FirstName; newTruck.Driver.TowTruckCompany = t.Driver.TowTruckCompany; newTruck.Driver.FSPID = t.Driver.FSPID; newTruck.Driver.AssignedBeat = t.Driver.AssignedBeat; newTruck.Driver.BeatScheduleID = t.Driver.BeatScheduleID; newTruck.Driver.BreakStarted = t.Driver.BreakStarted; newTruck.Driver.LunchStarted = t.Driver.LunchStarted; //Extended data newTruck.Extended.ContractorName = t.Extended.ContractorName; newTruck.Extended.ContractorID = t.Extended.ContractorID; newTruck.Extended.TruckNumber = t.Extended.TruckNumber; newTruck.Extended.FleetNumber = t.Extended.FleetNumber; newTruck.Extended.ProgramStartDate = t.Extended.ProgramStartDate; newTruck.Extended.VehicleType = t.Extended.VehicleType; newTruck.Extended.VehicleYear = t.Extended.VehicleYear; newTruck.Extended.VehicleMake = t.Extended.VehicleMake; newTruck.Extended.VehicleModel = t.Extended.VehicleModel; newTruck.Extended.LicensePlate = t.Extended.LicensePlate; newTruck.Extended.RegistrationExpireDate = t.Extended.RegistrationExpireDate; newTruck.Extended.InsuranceExpireDate = t.Extended.InsuranceExpireDate; newTruck.Extended.LastCHPInspection = t.Extended.LastCHPInspection; newTruck.Extended.ProgramEndDate = t.Extended.ProgramEndDate; newTruck.Extended.FAW = t.Extended.FAW; newTruck.Extended.RAW = t.Extended.RAW; newTruck.Extended.RAWR = t.Extended.RAWR; newTruck.Extended.GVW = t.Extended.GVW; newTruck.Extended.GVWR = t.Extended.GVWR; newTruck.Extended.Wheelbase = t.Extended.Wheelbase; newTruck.Extended.Overhang = t.Extended.Overhang; newTruck.Extended.MAXTW = t.Extended.MAXTW; newTruck.Extended.MAXTWCALCDATE = t.Extended.MAXTWCALCDATE; newTruck.Extended.FuelType = t.Extended.FuelType; newTruck.Extended.FleetVehicleID = t.Extended.FleetVehicleID; ctList.Add(newTruck); } for (int i = 0; i < srvListString.Count(); i++) { srSecondaryService.TowTruckServiceClient sr = new srSecondaryService.TowTruckServiceClient(); sr.Endpoint.Address = new EndpointAddress(new Uri("http://" + srvListString[i].ToString() + ":9007/TowTruckService.svc")); foreach (srSecondaryService.CopyTruck t in ctList) { sr.SingleTruckDump(t); } //sr.TruckDump(ctList.ToArray()); } } } catch (Exception ex) { evtLog = new Logging.EventLogger(); evtLog.LogEvent("Error dumping trucks to secondary service" + Environment.NewLine + ex.ToString(), true); logger.writeToLogFile(DateTime.Now.ToString() + Environment.NewLine + "Error dumping trucks to secondary service" + Environment.NewLine + ex.ToString() + Environment.NewLine + Environment.NewLine); } }
protected void Button1_Click(object sender, EventArgs e) { /* * Open connection to DB */ String ConnStr = ConfigurationManager.AppSettings["FSPdb"].ToString(); string txtInstaller, txtVehicleID, txtIPAddress, txtSSN, txtIDate, txtUSpeed, txtDspeed, txtTTC, txtSSC; bool txtSecure, txtCell, txtPower, txtRouterSecure, txtMoisture, txtSpeedTest, txtGPS; int[] check; check = new int[16]; bool clicked = true; if (clicked == true) { txtInstaller = installerName.Text; if (txtInstaller.Equals("")) { iName.InnerText = "*"; check[0] = 1; } else { iName.InnerText = ""; check[0] = 0; } txtVehicleID = vID.Text; if (txtVehicleID.Equals("")) { VehID.InnerText = "*"; check[1] = 1; } else { VehID.InnerText = ""; check[1] = 0; } txtIPAddress = IPAdd.Text; if (txtIPAddress.Equals("")) { IPA.InnerText = "*"; check[2] = 1; } else { IPA.InnerText = ""; check[2] = 0; } txtSSN = sysSerNumber.Text; if (txtSSN.Equals("")) { S.InnerText = "*"; check[3] = 1; } else { S.InnerText = ""; check[3] = 0; } txtIDate = installDate.Text; if (txtIDate.Equals("")) { ID.InnerText = "*"; check[4] = 1; } else { ID.InnerText = ""; check[4] = 0; } txtUSpeed = UploadSpeed.Text; if (txtUSpeed.Equals("")) { US.InnerText = "*"; check[5] = 1; } else { US.InnerText = ""; check[5] = 0; } txtDspeed = DownloadSpeed.Text; if (txtDspeed.Equals("")) { DS.InnerText = "*"; check[6] = 1; } else { DS.InnerText = ""; check[6] = 0; } txtTTC = towTruckCompany.Text; if (txtTTC.Equals("")) { tTC.InnerText = "*"; check[7] = 1; } else { tTC.InnerText = ""; check[7] = 0; } //Check box checking txtSecure = Secure.Checked; if (txtSecure == false) { Sec.InnerHtml = "*"; check[8] = 1; } else { Sec.InnerHtml = ""; check[8] = 0; } txtCell = Cell.Checked; if (txtCell == false) { Ce.InnerHtml = "*"; check[9] = 1; } else { Ce.InnerHtml = ""; check[9] = 0; } txtPower = Power.Checked; if (txtPower == false) { Pow.InnerHtml = "*"; check[10] = 1; } else { Pow.InnerHtml = ""; check[10] = 0; } txtRouterSecure = routerSecure.Checked; if (txtRouterSecure == false) { RoutSec.InnerHtml = "*"; check[11] = 1; } else { RoutSec.InnerHtml = ""; check[11] = 0; } txtMoisture = Moisture.Checked; if (txtMoisture == false) { Moist.InnerHtml = "*"; check[12] = 1; } else { Moist.InnerHtml = ""; check[12] = 0; } txtSpeedTest = SpeedTest.Checked; if (txtSpeedTest == false) { SpeedT.InnerHtml = "*"; check[13] = 1; } else { SpeedT.InnerHtml = ""; check[13] = 0; } txtGPS = GPS.Checked; if (txtGPS == false) { G.InnerHtml = "*"; check[14] = 1; } else { G.InnerHtml = ""; check[14] = 0; } txtSSC = ddlContractors.Text; if (txtSSC.Equals("")) { Cont.InnerHtml = "*"; check[15] = 1; } else { Cont.InnerHtml = ""; check[15] = 0; } for (int i = 0; i < check.Length; i++) { if (check[i] == 1) { emsg.InnerText = "* Indicates a required field."; } } if (check[0] == 0 && check[1] == 0 && check[2] == 0 && check[3] == 0 && check[4] == 0 && check[5] == 0 && check[6] == 0 && check[7] == 0 && check[8] == 0 && check[9] == 0 && check[10] == 0 && check[11] == 0 && check[12] == 0 && check[13] == 0 && check[14] == 0 && check[15] == 0) { emsg.InnerText = ""; } else { return; } } try{ SqlConnection conn = new SqlConnection(ConnStr); { conn.Open(); String SQL = "LogTowTruckSetup"; String SQL2 = "FixTruckNumber"; SqlCommand cmd = new SqlCommand(SQL, conn); SqlCommand cmd2 = new SqlCommand(SQL2, conn); cmd.CommandType = CommandType.StoredProcedure; cmd2.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@ParameterName", "ParameterValue"); cmd.Parameters.AddWithValue("@MountedSecurely", Secure.Checked); cmd.Parameters.AddWithValue("@ConnectedToCell", Cell.Checked); cmd.Parameters.AddWithValue("@DCPowerConnected", Power.Checked); cmd.Parameters.AddWithValue("@RouterUnitMountedSecurely", routerSecure.Checked); cmd.Parameters.AddWithValue("@MoistureFree", Moisture.Checked); cmd.Parameters.AddWithValue("@Speedtest", SpeedTest.Text); cmd.Parameters.AddWithValue("@GPSSentProperly", GPS.Checked); //Text Box input cmd.Parameters.AddWithValue("@InstallerName", installerName.Text); cmd.Parameters.AddWithValue("@TowTruckCompany", towTruckCompany.Text); cmd.Parameters.AddWithValue("@VehicleID", vID.Text); cmd.Parameters.AddWithValue("@SystemSerialNumber", sysSerNumber.Text); cmd.Parameters.AddWithValue("@IPAddress", IPAdd.Text); cmd.Parameters.AddWithValue("@UploadSpeed", UploadSpeed.Text); cmd.Parameters.AddWithValue("@DownloadSpeed", DownloadSpeed.Text); cmd.ExecuteNonQuery(); cmd = null; cmd2.Parameters.AddWithValue("@IPAddress", IPAdd.Text); cmd2.Parameters.AddWithValue("@ContractorID", ddlContractors.Text); cmd2.Parameters.AddWithValue("@VehicleNumber", vID.Text); cmd2.ExecuteNonQuery(); cmd2 = null; conn.Close(); } }catch (Exception ex) { Logging.EventLogger logger = new Logging.EventLogger(); logger.LogEvent(DateTime.Now.ToString() + Environment.NewLine + "Error uploading TowTruck CheckList" + Environment.NewLine + ex.ToString(), true); Response.Write("The following error has occured" + ex); } installerName.Text = ""; installDate.Text = ""; towTruckCompany.Text = ""; vID.Text = ""; sysSerNumber.Text = ""; IPAdd.Text = ""; UploadSpeed.Text = ""; DownloadSpeed.Text = ""; Secure.Checked = false; Cell.Checked = false; Power.Checked = false; routerSecure.Checked = false; Moisture.Checked = false; SpeedTest.Checked = false; GPS.Checked = false; /* * Checks for filled out text boxes * * if (string.IsNullOrEmpty(installerName.Text)) * { * Response.Write("Please fill out the Installer Name"); * return; * } * if (string.IsNullOrEmpty(vehicleIDDescription.Text)) * { * Response.Write("Please enter Vehicle ID/Description"); * } * if (string.IsNullOrEmpty(IPAddress.Text)) * { * Response.Write("Please enter an IP Address"); * } * if (string.IsNullOrEmpty(sysSerialNumber.Text)) * { * Response.Write("Please enter a System Serial Number"); * } * if (string.IsNullOrEmpty(installationDate.Text)) * { * Response.Write("Please fill out the Installation Date"); * } * if (string.IsNullOrEmpty(qualityAssurInspectDate.Text)) * { * Response.Write("Please fill out the Quality Assurance Inspection Date"); * } * * */ /* * Checks for checked boxes * * if(Secure.Checked.Equals(false)) * { * Response.Write("Is the Roof Antenna Mounted Securely?"); * } * if (Sealed.Checked.Equals(false)) * { * Response.Write("Is the Roof Antenna Sealed with Silicone Sealant?"); * } * if (Cell.Checked.Equals(false)) * { * Response.Write("Is the Roof Antenna Connected to \"Cell\" on the Router?"); * } * if (GPS.Checked.Equals(false)) * { * Response.Write("Is the Roof Antenna Connected to \"GPS\" on the Router?"); * } * if (Wifi.Checked.Equals(false)) * { * Response.Write("Is the roof Antenna Connected to \"WIFI\" on the Router?"); * } * if (Power.Checked.Equals(false)) * { * Response.Write("Is the DC Power Connected Properly to the Vehicle?"); * } * if (Moisture.Checked.Equals(false)) * { * Response.Write("Is the Router Unit Mounted Securely and Free from Moisture?"); * } * if (SSID.Checked.Equals(false)) * { * Response.Write("Is the Wireless SSID \"OCTAWIFI\" visible from test laptop?"); * } * if (Browse.Checked.Equals(false)) * { * Response.Write("Are You Able to Browse to ______?"); * } * if (Setup.Checked.Equals(false)) * { * Response.Write("Input Information on Tow Truck Setup?"); * } * if (Google.Checked.Equals(false)) * { * Response.Write("Are You Able to Browse to www.google.com?"); * } * if (Browse2.Checked.Equals(false)) * { * Response.Write("Are You Able to Browse to other Websites?"); * } * if (Speed.Checked.Equals(false)) * { * Response.Write("Successful Speed Test? (Please Record Kbits/s)"); * } * */ /* * Checks for signature on setup sheet * * if (string.IsNullOrEmpty(signature.Text)) * { * Response.Write("Please Sign at the Bottom of the Setup Sheet"); * } * */ }
public static void LoadBeats() //Load all the beat data in the feature layer { try { qt = new QueryTask(url); query = new Query(); query.ReturnGeometry = true; query.OutFields.Add("*"); query.Where = "1=1"; qt.Execute(query); beatPolygons.Clear(); foreach (Graphic resultFeature in qt.LastResult.Features) { string bID = string.Empty; string bDesc = string.Empty; System.Collections.Generic.IDictionary <string, object> allAttributes = resultFeature.Attributes; foreach (string theKey in allAttributes.Keys) { if (theKey == "BEAT_ID_1") { object theValue = allAttributes[theKey]; if (theValue != null) { bID = theValue.ToString(); } else { bID = "NO BEAT ID"; } } if (theKey == "BeatDescript") { object theValue = allAttributes[theKey]; if (theValue != null) { bDesc = theValue.ToString(); } else { bDesc = "NO DESCRIPTION"; } } } esriBeat eb = new esriBeat(); eb.BeatID = bID; eb.BeatDescription = bDesc; eb.beatData = resultFeature; //check for min/max lat/lon and log it //init vars so we can test each point in the polygon against something other than 0.0 ESRI.ArcGIS.Client.Geometry.Polygon p = (ESRI.ArcGIS.Client.Geometry.Polygon)eb.beatData.Geometry; foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings) { eb.maxLat = points[0].Y; eb.maxLon = points[0].X; eb.minLat = points[0].Y; eb.minLon = points[0].X; } foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings) { for (int i = 0; i < points.Count(); i++) { //start setting min/max points if (points[i].X > eb.maxLon) { eb.maxLon = points[i].X; } if (points[i].Y > eb.maxLat) { eb.maxLat = points[i].Y; } if (points[i].X < eb.minLon) { eb.minLon = points[i].X; } if (points[i].Y < eb.minLat) { eb.minLat = points[i].Y; } } } beatPolygons.Add(eb); } } catch (Exception ex) { Logging.EventLogger log = new Logging.EventLogger(); log.LogEvent(ex.ToString(), true); } }
public static void LoadYards() //Load the segment data into memory for faster querying { try { qt = new QueryTask(url); Query query = new Query(); query.ReturnGeometry = true; query.OutFields.Add("*"); query.Where = "1=1"; qt.Execute(query); yardPolygons.Clear(); foreach (Graphic resultFeature in qt.LastResult.Features) { string BeatID = string.Empty; string Contractor = string.Empty; string Desc = string.Empty; string Address = string.Empty; string City = string.Empty; string Zip = string.Empty; string Phone = string.Empty; string ObjectID = string.Empty; System.Collections.Generic.IDictionary <string, object> allAttributes = resultFeature.Attributes; foreach (string theKey in allAttributes.Keys) { if (theKey == "ID_1") { object theValue = allAttributes[theKey]; if (theValue != null) { BeatID = theValue.ToString(); } } if (theKey == "Contract_1") { object theValue = allAttributes[theKey]; if (theValue != null) { Contractor = theValue.ToString(); } } if (theKey == "Address_1") { object theValue = allAttributes[theKey]; if (theValue != null) { Address = theValue.ToString(); } } if (theKey == "City_1_1") { object theValue = allAttributes[theKey]; if (theValue != null) { City = theValue.ToString(); } } if (theKey == "Zip_1") { object theValue = allAttributes[theKey]; if (theValue != null) { Zip = theValue.ToString(); } } if (theKey == "Phone1") { object theValue = allAttributes[theKey]; if (theValue != null) { Phone = theValue.ToString(); } } if (theKey == "OBJECTID") { object theValue = allAttributes[theKey]; if (theValue != null) { ObjectID = theValue.ToString(); } } } esriYard ey = new esriYard(); ey.YardID = ObjectID; ey.BeatID = BeatID; ey.Contractor = Contractor; ey.yardData = resultFeature; ey.Address = Address; ey.City = City; ey.Zip = Zip; ey.Phone = Phone; ESRI.ArcGIS.Client.Geometry.Polygon p = (ESRI.ArcGIS.Client.Geometry.Polygon)ey.yardData.Geometry; foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings) { ey.maxLat = points[0].Y; ey.maxLon = points[0].X; ey.minLat = points[0].Y; ey.minLon = points[0].X; } foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings) { for (int i = 0; i < points.Count(); i++) { //start setting min/max points if (points[i].X > ey.maxLon) { ey.maxLon = points[i].X; } if (points[i].Y > ey.maxLat) { ey.maxLat = points[i].Y; } if (points[i].X < ey.minLon) { ey.minLon = points[i].X; } if (points[i].Y < ey.minLat) { ey.minLat = points[i].Y; } } } yardPolygons.Add(ey); } } catch (Exception ex) { Logging.EventLogger log = new Logging.EventLogger(); log.LogEvent(ex.ToString(), true); } }
public static void LoadSegments() //Load the segment data into memory for faster querying { try { segPolygons.Clear(); qt = new QueryTask(url); Query query = new Query(); query.ReturnGeometry = true; //query.OutFields.AddRange(new string[] { "SegmentID", "BeatID", "SegmentDescription" }); //for beats query.OutFields.Add("*"); query.Where = "1=1"; qt.Execute(query); foreach (Graphic resultFeature in qt.LastResult.Features) { string BeatID = string.Empty; string SegmentID = string.Empty; string SegDesc = string.Empty; System.Collections.Generic.IDictionary <string, object> allAttributes = resultFeature.Attributes; foreach (string theKey in allAttributes.Keys) { if (theKey == "BeatID") { object theValue = allAttributes[theKey]; if (theValue != null) { BeatID = theValue.ToString(); } } if (theKey == "BEAT_ID_1") { object theValue = allAttributes[theKey]; if (theValue != null) { BeatID = theValue.ToString(); } } if (theKey == "Beatsegmen") { object theValue = allAttributes[theKey]; if (theValue != null) { SegmentID = theValue.ToString(); } } if (theKey == "BeatSegmen") { object theValue = allAttributes[theKey]; if (theValue != null) { SegDesc = theValue.ToString(); } } if (theKey == "BeatSegeme") { object theValue = allAttributes[theKey]; if (theValue != null) { SegDesc = theValue.ToString(); } } } esriSegment es = new esriSegment(); es.BeatID = BeatID; es.SegmentID = SegmentID; es.SegmentDescription = SegDesc; es.segmentData = resultFeature; ESRI.ArcGIS.Client.Geometry.Polygon p = (ESRI.ArcGIS.Client.Geometry.Polygon)es.segmentData.Geometry; foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings) { es.maxLat = points[0].Y; es.maxLon = points[0].X; es.minLat = points[0].Y; es.minLon = points[0].X; } foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings) { for (int i = 0; i < points.Count(); i++) { //start setting min/max points if (points[i].X > es.maxLon) { es.maxLon = points[i].X; } if (points[i].Y > es.maxLat) { es.maxLat = points[i].Y; } if (points[i].X < es.minLon) { es.minLon = points[i].X; } if (points[i].Y < es.minLat) { es.minLat = points[i].Y; } } } segPolygons.Add(es); } } catch (Exception ex) { Logging.EventLogger log = new Logging.EventLogger(); log.LogEvent(ex.ToString(), true); } }
void dumpTimer_Elapsed(object sender, ElapsedEventArgs e) { //throw new NotImplementedException(); try { /* * if (DataClasses.GlobalData.currentTrucks.Count > 0) * { * Guid _beatID = new Guid("00000000-0000-0000-0000-000000000000"); * string[] srvListString = ConfigurationManager.AppSettings["OtherServers"].ToString().Split('|'); * //List<TowTruck.TowTruck> allTrucks = new List<TowTruck.TowTruck>(); * List<srSecondaryService.CopyTruck> ctList = new List<srSecondaryService.CopyTruck>(); * foreach (TowTruck.TowTruck t in DataClasses.GlobalData.currentTrucks) * { * if (t.assignedBeat.BeatID != null && t.assignedBeat.BeatID != new Guid("00000000-0000-0000-0000-000000000000")) * { * _beatID = t.GPSPosition.BeatID; * } * * TowTruck.AlarmTimer alarmSpd = t.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer findSpd) { return findSpd.alarmName == "Speeding"; }); * TowTruck.AlarmTimer alarmOB = t.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer findOB) { return findOB.alarmName == "OffBeat"; }); * TowTruck.AlarmTimer alarmOP = t.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer findOP) { return findOP.alarmName == "OnPatrol"; }); * TowTruck.AlarmTimer alarmInc = t.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer findInc) { return findInc.alarmName == "Incident"; }); * TowTruck.AlarmTimer alarmSta = t.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer findSta) { return findSta.alarmName == "OnPatrol"; }); * TowTruck.AlarmTimer alarmGPS = t.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer findGPS) { return findGPS.alarmName == "GPSIssue"; }); * * * bool _HasAlarms = false; * t.tta.checkAlarms(); * if (t.tta.hasAlarms) * { * _HasAlarms = true; * } * #region " Speeding " * * bool speedingAlarm = false; * string speedingValue = "NA"; * DateTime speedingTime = Convert.ToDateTime("01/01/2001 00:00:00"); * if (alarmSpd != null) * { * speedingAlarm = alarmSpd.hasAlarm; * speedingValue = alarmSpd.alarmValue; * speedingTime = alarmSpd.alarmStart; * } * #endregion * #region " Off Beat " * * bool obAlarm = false; * string obMessage = "NA"; * DateTime obTime = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime obCleared = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime obExcused = Convert.ToDateTime("01/01/2001 00:00:00"); * if (alarmOB != null) * { * obAlarm = alarmOB.hasAlarm; * obMessage = alarmOB.alarmValue; * obTime = alarmOB.alarmStart; * obExcused = alarmOB.alarmExcused; * obCleared = alarmOB.alarmExcused; * } * #endregion * #region " On Patrol " * * bool opAlarm = false; * DateTime opTime = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime opCleared = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime opExcused = Convert.ToDateTime("01/01/2001 00:00:00"); * string opComments = "NA"; * * if (alarmOP != null) * { * opAlarm = alarmOP.hasAlarm; * opTime = alarmOP.GetStartDateTime(); * opCleared = alarmOP.alarmCleared; * opExcused = alarmOP.alarmExcused; * opComments = alarmOP.alarmValue; * } * #endregion * #region " Incident " * * bool incAlarm = false; * DateTime incTime = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime incCleared = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime incExcused = Convert.ToDateTime("01/01/2001 00:00:00"); * string incComments = "NA"; * * if (alarmInc != null) * { * incAlarm = alarmInc.hasAlarm; * incTime = alarmInc.GetStartDateTime(); * incCleared = alarmInc.alarmCleared; * incExcused = alarmInc.alarmExcused; * incComments = alarmInc.alarmValue; * } * #endregion * #region " GPS " * * bool gpsAlarm = false; * DateTime gpsTime = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime gpsCleared = Convert.ToDateTime("01/01/2001 00:00:00"); * DateTime gpsExcused = Convert.ToDateTime("01/01/2001 00:00:00"); * string gpsComments = "NA"; * * if (alarmGPS != null) * { * gpsAlarm = alarmGPS.hasAlarm; * gpsTime = alarmGPS.GetStartDateTime(); * gpsCleared = alarmGPS.alarmCleared; * gpsExcused = alarmGPS.alarmExcused; * gpsComments = alarmGPS.alarmValue; * } * #endregion * #region " Stationary " * * bool staAlarm = false; * DateTime staTime = alarmSta.GetStartDateTime(); * DateTime staCleared = alarmSta.alarmCleared; * DateTime staExcused = alarmSta.alarmExcused; * string staComments = alarmSta.alarmValue; * #endregion * * } * * for (int i = 0; i < srvListString.Count(); i++) * { * srSecondaryService.TowTruckServiceClient sr = new srSecondaryService.TowTruckServiceClient(); * sr.Endpoint.Address = new EndpointAddress(new Uri("http://" + srvListString[i].ToString() + ":9007/TowTruckService.svc")); * foreach (srSecondaryService.CopyTruck t in ctList) * { * sr.SingleTruckDump(t); * } * //sr.TruckDump(ctList.ToArray()); * } * * }*/ } catch (Exception ex) { evtLog = new Logging.EventLogger(); evtLog.LogEvent("Error dumping trucks to secondary service" + Environment.NewLine + ex.ToString(), true); logger.writeToLogFile(DateTime.Now.ToString() + Environment.NewLine + "Error dumping trucks to secondary service" + Environment.NewLine + ex.ToString() + Environment.NewLine + Environment.NewLine); } }