// METHOD HEADER COMMENT ------------------------------------------------------------------------------- /** * \fn AtOrPastCity * \brief This method determins if a truck is currently at or past a destination city * \param[in] FC_LocalContract inContract, FC_TripTicket inTicket * \param[out] none * \return bool * ---------------------------------------------------------------------------------------------------- */ public bool AtOrPastCity(FC_LocalContract inContract, FC_TripTicket inTicket) { int OrginId = LoadCSV.ToCityID(inContract.Origin); int DestId = LoadCSV.ToCityID(inContract.Destination); int current = LoadCSV.ToCityID(inTicket.CurrentLocation); if (OrginId > DestId) { //going west if (current <= DestId) { return(true); } } else { if (current >= DestId) { return(true); } } return(false); }
public static int AddContractToTicket(FC_TripTicket OriginalTick, FC_TripTicket TempTicket, FC_LocalContract TheContract) { string Query = "select * from FC_RouteSeg where FC_TripTicketID = " + OriginalTick.FC_TripTicketID + ";"; FC_RouteSeg r = new FC_RouteSeg(); List <FC_RouteSeg> OriginalSegs = r.ObjToTable(SQL.Select(r, Query)); MappingClass map = new MappingClass(); List <FC_RouteSeg> NewSegs = map.GetTravelData(TheContract.Origin, TheContract.Destination, 0, -1); //check that these tickets are going in the same direction if (OriginalSegs[0].CityA == NewSegs[0].CityA && OriginalSegs[0].CityB == NewSegs[0].CityB && TempTicket.Size_in_Palettes != 0) { int PalletesAddedToOgrinal = 26 - OriginalTick.Size_in_Palettes; if (PalletesAddedToOgrinal > TempTicket.Size_in_Palettes) { PalletesAddedToOgrinal = TempTicket.Size_in_Palettes; } int OrignalTickNewSize = OriginalTick.Size_in_Palettes + PalletesAddedToOgrinal; if (OrignalTickNewSize == 26) { OrignalTickNewSize = 0; } string query = "update FC_TripTicket " + "set Size_in_Palettes = " + OrignalTickNewSize + " where FC_TripTicketID = " + OriginalTick.FC_TripTicketID + ";"; SQL.GenericFunction(query); int FTL = 0; List <FC_RouteSeg> NewSegmentsFTL = new List <FC_RouteSeg>(); List <FC_RouteSeg> NewSegmentsLTL = new List <FC_RouteSeg>(); if (NewSegs.Count > OriginalSegs.Count) { string orginCity = LoadCSV.ToCityName(OriginalSegs[0].CityA); string EndOfFTL = LoadCSV.ToCityName(OriginalSegs[OriginalSegs.Count - 1].CityB); string startLTL = LoadCSV.ToCityName(NewSegs[OriginalSegs.Count].CityA); string endCity = LoadCSV.ToCityName(NewSegs[NewSegs.Count - 1].CityB); NewSegmentsFTL = map.GetTravelData(orginCity, EndOfFTL, FTL, OriginalTick.FC_TripTicketID); NewSegmentsLTL = map.GetTravelData(startLTL, endCity, 1, OriginalTick.FC_TripTicketID); } else if (NewSegs.Count < OriginalSegs.Count) { string orginCity = LoadCSV.ToCityName(OriginalSegs[0].CityA); string EndOfFTL = LoadCSV.ToCityName(NewSegs[NewSegs.Count - 1].CityB); string startLTL = LoadCSV.ToCityName(OriginalSegs[NewSegs.Count].CityA); string endCity = LoadCSV.ToCityName(OriginalSegs[OriginalSegs.Count - 1].CityB); NewSegmentsFTL = map.GetTravelData(orginCity, EndOfFTL, FTL, OriginalTick.FC_TripTicketID); NewSegmentsLTL = map.GetTravelData(startLTL, endCity, 1, OriginalTick.FC_TripTicketID); } else { string orginCity = LoadCSV.ToCityName(OriginalSegs[0].CityA); string endCity = LoadCSV.ToCityName(OriginalSegs[NewSegs.Count - 1].CityB); NewSegmentsLTL = map.GetTravelData(orginCity, endCity, FTL, OriginalTick.FC_TripTicketID); } if (NewSegmentsLTL != null) { NewSegmentsLTL[0].PickUpTime = 0; } query = "delete from FC_RouteSeg where FC_TripTicketID = " + OriginalTick.FC_TripTicketID + ";"; SQL.GenericFunction(query); foreach (FC_RouteSeg x in NewSegmentsFTL) { SQL.Insert(x); } foreach (FC_RouteSeg x in NewSegmentsLTL) { SQL.Insert(x); } FC_TripTicketLine NewLine = new FC_TripTicketLine(OriginalTick.FC_TripTicketID, TheContract.FC_LocalContractID, PalletesAddedToOgrinal); SQL.Insert(NewLine); TMSLogger.LogIt(" | " + "PlannerClass.cs" + " | " + "PlannerClass" + " | " + "AddContractToTicket" + " | " + "Confirmation" + " | " + "Contract added to ticket" + " | "); return(PalletesAddedToOgrinal); } return(-1); }
// GetTravelData METHOD HEADER COMMENT ------------------------------------------------------------------------------- /** * \fn List<RouteData> GetTravelData(int OriginID, int DestinationID, bool FLTorLTL) * \brief This method will determine the info for a trip the between to cities. * \details A list of RouteData structs, each struct will hold all timing and KM data. * The timing for each element will keep track of the pick up time at the origin city, the drop off time at the destination, and the LTL time at intermediate cities. * \param[in] int OriginID, int DestinationID, bool FLTorLTL The origin and destination cities, and if the trip is Flt or Ltl. * \param[out] null * \exception null * \see Struct: RouteData * \return List<RouteData> A list of the RouteData structs. The list all together will hold all the data for a trip. * * ---------------------------------------------------------------------------------------------------- */ public List <FC_RouteSeg> GetTravelData(string Origin, string Destination, int inFTL, int InTicketID) //one is ltl { int OriginID = LoadCSV.ToCityID(Origin); int DestinationID = LoadCSV.ToCityID(Destination); bool FTL = true; if (inFTL == 1) { FTL = false; } try { //figure out if we need to travel east or west CityNode current = nodes.Find(x => x.CityID == OriginID); CityNode nextCity; List <FC_RouteSeg> returnList = new List <FC_RouteSeg>(); if (OriginID >= 0 && OriginID < Number_of_Cities && DestinationID >= 0 && DestinationID < Number_of_Cities && OriginID != DestinationID) { do { FC_RouteSeg tripDataPassBack = new FC_RouteSeg(InTicketID, 0, 0, 0, 0, 0, 0, 0); if (OriginID > DestinationID) { //going west nextCity = current.West; tripDataPassBack.KM = current.WestKM; tripDataPassBack.DrivenTime = current.WestHour; } else { //going east nextCity = current.East; tripDataPassBack.KM = current.EastKM; tripDataPassBack.DrivenTime = current.EastHour; } tripDataPassBack.CityA = current.CityID; tripDataPassBack.CityB = nextCity.CityID; if (current.CityID == OriginID) { tripDataPassBack.PickUpTime += 2; } if (nextCity.CityID == DestinationID) { tripDataPassBack.DropOffTime += 2; } if (!FTL && (nextCity.CityID != DestinationID)) { tripDataPassBack.LtlTime += 2; } returnList.Add(tripDataPassBack); current = nextCity; } while (nextCity.CityID != DestinationID); TMSLogger.LogIt(" | " + "MappingClass.cs" + " | " + "MappingClass" + " | " + "GetTravelData" + " | " + "Confirmation" + " | " + "Route List calculated" + " | "); return(returnList); } } catch (Exception e) { TMSLogger.LogIt(" | " + "MappingClass.cs" + " | " + "MappingClass" + " | " + "GetTravelData" + " | " + e.GetType().ToString() + " | " + e.Message + " | "); } return(null); }
public static void IncrementOneDay() { try { string FirstQuery = "Select * from FC_TripTicket where not Is_Complete = 0;"; FC_TripTicket t = new FC_TripTicket(); List <FC_TripTicket> AllTickets = t.ObjToTable(SQL.Select(t, FirstQuery)); foreach (FC_TripTicket x in AllTickets) { x.Days_Passes++; FC_RouteSeg s = new FC_RouteSeg(); string query = "Select FC_TripTicketID, CityA, CityB, PickUpTime, DropOffTime, LtlTime, DrivenTime, KM from FC_RouteSeg where FC_TripTicketID = " + x.FC_TripTicketID + ";"; List <FC_RouteSeg> AllSegments = s.ObjToTable(SQL.Select(s, query)); double totalTime = x.Days_Passes * 12; double DriveTime = x.Days_Passes * 8; int SegIndex = 0; FC_RouteSeg currentSegment = AllSegments[SegIndex]; while (true) { totalTime -= currentSegment.PickUpTime; totalTime -= currentSegment.DrivenTime; DriveTime -= currentSegment.DrivenTime; totalTime -= currentSegment.LtlTime; totalTime -= currentSegment.DropOffTime; if (totalTime <= 0 || DriveTime <= 0) { x.CurrentLocation = LoadCSV.ToCityName(currentSegment.CityA); break; } else { SegIndex++; if (SegIndex >= AllSegments.Count) { x.CurrentLocation = LoadCSV.ToCityName(currentSegment.CityB); break; } else { currentSegment = AllSegments[SegIndex]; } x.CurrentLocation = LoadCSV.ToCityName(currentSegment.CityB); } } PlannerClass.UpdateTicketLocation(x); } string Query = "select FC_LocalContractID, Client_Name, Job_type, Quantity, Origin, Destination, Van_type, Contract_Status from " + "FC_LocalContract where Contract_Status = 1"; FC_LocalContract l = new FC_LocalContract(); List <FC_LocalContract> OnrouteContracts = l.ObjToTable(SQL.Select(l, Query)); MappingClass map = new MappingClass(); foreach (FC_LocalContract x in OnrouteContracts) { bool isComplete = true; List <FC_TripTicket> theTickets = PlannerClass.ConnectedTickets_Populate(x); foreach (FC_TripTicket y in theTickets) { if (!map.AtOrPastCity(x, y)) { isComplete = false; break; } } if (isComplete) { PlannerClass.UpdateContratState(x, 2); } } string theQuery = "Select * from FC_TripTicket where Is_Complete = 1"; FC_TripTicket w = new FC_TripTicket(); List <FC_TripTicket> ActiveTickets = t.ObjToTable(SQL.Select(t, theQuery)); foreach (FC_TripTicket x in ActiveTickets) { bool foundNotComple = false; List <FC_LocalContract> ContactsPerTick = PlannerClass.ContractsPerTicket_Populate(x); foreach (FC_LocalContract y in ContactsPerTick) { if (y.Contract_Status < 2) { foundNotComple = true; } } if (!foundNotComple) { theQuery = "Update FC_TripTicket set Is_Complete = 2 where FC_TripTicketID = " + x.FC_TripTicketID + ";"; SQL.GenericFunction(theQuery); } } TMSLogger.LogIt(" | " + "TimePass.cs" + " | " + "TimePass" + " | " + "IncrementOneDay" + " | " + "Confirmation" + " | " + "Day incremented" + " | "); } catch (Exception e) { TMSLogger.LogIt(" | " + "TimePass.cs" + " | " + "TimePass" + " | " + "IncrementOneDay" + " | " + e.GetType().ToString() + " | " + e.Message + " | "); } }