Exemple #1
0
        protected void btnStartSurvey_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRunTime.Text) || string.IsNullOrEmpty(txtStartDT.Text) || (chkDownload.Checked == false && chkUpload.Checked == false && chkPing.Checked == false))
            {
                Response.Write("No run time or start time or upload, download, and ping are unchecked");
                return;
            }
            if (!string.IsNullOrEmpty(ddlTrucks.Text))
            {
                TowTruck.TowTruck tFound = DataClasses.GlobalData.FindTowTruckByVehicleNumber(ddlTrucks.Text);
                if (tFound == null)
                {
                    Response.Write("Couldn't find truck");
                    return;
                }
                string IPAddress = tFound.Identifier;
                string msg       = string.Empty;

                string dt       = txtStartDT.Text;
                string duration = txtRunTime.Text;
                string ud       = string.Empty;
                if (chkUpload.Checked == true)
                {
                    ud += "U";
                }
                if (chkDownload.Checked == true)
                {
                    ud += "D";
                }
                if (chkPing.Checked == true)
                {
                    ud += "P";
                }
                msg = "<Survey>" + dt + "|" + duration + "|" + ud + "</Survey>";
                UDP.SendMessage sm = new UDP.SendMessage();
                sm.SendMyMessage(msg, IPAddress);
                TowTruck.SurveyTruck st         = new TowTruck.SurveyTruck();
                string[]             splitStart = txtStartDT.Text.Split(' ');
                string   startDate = splitStart[0].ToString() + " 00:00:00";
                DateTime dtEndDate = Convert.ToDateTime(txtStartDT.Text).AddMinutes(Convert.ToInt32(txtRunTime.Text));
                string   endDate   = dtEndDate.ToString();
                st.TruckNumber = ddlTrucks.Text;
                st.StartTime   = Convert.ToDateTime(txtStartDT.Text);
                st.EndTime     = dtEndDate;

                TowTruck.SurveyTruck stAdd = DataClasses.GlobalData.surveyTrucks.Find(delegate(TowTruck.SurveyTruck find) { return(find.TruckNumber == ddlTrucks.Text); });
                if (stAdd == null)
                {
                    DataClasses.GlobalData.surveyTrucks.Add(st);
                }
                else
                {
                    DataClasses.GlobalData.surveyTrucks.Remove(stAdd);
                    DataClasses.GlobalData.surveyTrucks.Add(st);
                }
                LoadTruckGrid();
            }
        }
Exemple #2
0
 void tmrCheck_Elapsed(object sender, ElapsedEventArgs e)
 {
     for (int i = DataClasses.GlobalData.surveyTrucks.Count - 1; i >= 0; i--)
     {
         if (DataClasses.GlobalData.surveyTrucks[i].EndTime < DateTime.Now)
         {
             //send a notification to the truck to shut down the survey, just to be sure
             TowTruck.TowTruck t = DataClasses.GlobalData.FindTowTruckByVehicleNumber(DataClasses.GlobalData.surveyTrucks[i].TruckNumber);
             if (t != null)
             {
                 string          IPAddress = t.Identifier;
                 string          cmd       = "<Survey>F</Survey>";
                 UDP.SendMessage sm        = new UDP.SendMessage();
                 sm.SendMyMessage(cmd, IPAddress);
             }
             DataClasses.GlobalData.surveyTrucks.RemoveAt(i);
         }
     }
 }
Exemple #3
0
 protected void btnForceStop_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(ddlTrucks.Text))
     {
         TowTruck.TowTruck tFound = DataClasses.GlobalData.FindTowTruckByVehicleNumber(ddlTrucks.Text);
         if (tFound == null)
         {
             Response.Write("Couldn't find truck");
             return;
         }
         string          IPAddress = tFound.Identifier;
         string          cmd       = "<Survey>F</Survey>";
         UDP.SendMessage sm        = new UDP.SendMessage();
         sm.SendMyMessage(cmd, IPAddress);
         TowTruck.SurveyTruck find = DataClasses.GlobalData.surveyTrucks.Find(delegate(TowTruck.SurveyTruck get) { return(get.TruckNumber == tFound.TruckNumber); });
         if (find != null)
         {
             DataClasses.GlobalData.surveyTrucks.Remove(find);
         }
         LoadTruckGrid();
     }
 }
Exemple #4
0
 public static void AddTowTruck(TowTruck.TowTruck thisTruck)
 {
     UDP.SendMessage msgAck = new UDP.SendMessage();
     try
     {
         TowTruck.TowTruck foundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck myTruck)
         {
             return(myTruck.Identifier == thisTruck.Identifier);
         });
         lock (currentTrucks)
         {
             if (foundTruck == null)
             {
                 currentTrucks.Add(thisTruck);
             }
         }
         //ack moved to TowTruck object's update functions
         //msgAck.SendMyMessage("MsgID: " + thisTruck.GPSPosition.MessageID.ToString() + " Received");
     }
     catch (Exception ex)
     {
         string msg = "IP Address: " + thisTruck.Identifier + Environment.NewLine;
         msg += "VehicleNumber: " + thisTruck.Identifier + Environment.NewLine;
         msg += "Contractor: " + thisTruck.Extended.ContractorName + Environment.NewLine;
         msg += "VehicleStatus: " + thisTruck.Status.VehicleStatus + Environment.NewLine;
         msg += "Direction: " + thisTruck.GPSPosition.Head + Environment.NewLine;
         msg += "LastUpdate: " + thisTruck.GPSPosition.Time.ToString() + Environment.NewLine;
         msg += "BeatSegmentID: " + thisTruck.GPSPosition.BeatSegmentID + Environment.NewLine;
         msg += "Speed: " + thisTruck.GPSPosition.Speed + Environment.NewLine;
         msg += "Alarms: " + thisTruck.Status.SpeedingAlarm + Environment.NewLine;
         msg += "Lat: " + thisTruck.GPSPosition.Lat.ToString() + Environment.NewLine;
         msg += "Lon: " + thisTruck.GPSPosition.Lon.ToString() + Environment.NewLine;
         logger.LogEvent(DateTime.Now.ToString() + " Error adding/updating tow truck" + Environment.NewLine + msg + Environment.NewLine
                         + ex.ToString() + Environment.NewLine, true);
         msgAck.SendMyMessage("MsgID: " + thisTruck.GPSPosition.Id.ToString() + " Failed To Process");
     }
 }