Пример #1
0
        // 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);
        }
Пример #2
0
        // MappingClass Constructor HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn			MappingClass() Constructor
         *	\brief		The constructor for the Mapping Class
         *	\details	The data for each city will be read out of the database. It will then converted into a List datastructure so that it can be steped though easily.
         *	\param[in]	null
         *	\param[out]	null
         *	\exception	null
         *	\see		na
         *	\return		null
         * ---------------------------------------------------------------------------------------------------- */
        public MappingClass()
        {
            CityNode Windsor    = new CityNode("Windsor", 0);
            CityNode London     = new CityNode("London", 1);
            CityNode Hamilton   = new CityNode("Hamilton", 2);
            CityNode Toronto    = new CityNode("Toronto", 3);
            CityNode Oshawa     = new CityNode("Oshawa", 4);
            CityNode Belleville = new CityNode("Belleville", 5);
            CityNode Kingston   = new CityNode("Kingston", 6);
            CityNode Ottawa     = new CityNode("Ottawa", 7);

            Windsor.West    = null;
            London.West     = Windsor;
            Hamilton.West   = London;
            Toronto.West    = Hamilton;
            Oshawa.West     = Toronto;
            Belleville.West = Oshawa;
            Kingston.West   = Belleville;
            Ottawa.West     = Kingston;

            Windsor.East    = London;
            London.East     = Hamilton;
            Hamilton.East   = Toronto;
            Toronto.East    = Oshawa;
            Oshawa.East     = Belleville;
            Belleville.East = Kingston;
            Kingston.East   = Ottawa;
            Ottawa.East     = null;

            nodes.Add(Windsor);
            nodes.Add(London);
            nodes.Add(Hamilton);
            nodes.Add(Toronto);
            nodes.Add(Oshawa);
            nodes.Add(Belleville);
            nodes.Add(Kingston);
            nodes.Add(Ottawa);

            int[] eastKMArray = new int[Number_of_Cities] {
                191, 128, 68, 60, 134, 82, 196, -1
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].EastKM = eastKMArray[i];
            }

            int[] westKMArray = new int[Number_of_Cities] {
                -1, 191, 128, 68, 60, 134, 82, 196
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].WestKM = westKMArray[i];
            }

            double[] eastHourArray = new double[Number_of_Cities] {
                2.5, 1.75, 1.25, 1.3, 1.65, 1.2, 2.5, -1
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].EastHour = eastHourArray[i];
            }

            double[] WestHourArray = new double[Number_of_Cities] {
                -1, 2.5, 1.75, 1.25, 1.3, 1.65, 1.2, 2.5
            };
            for (int i = 0; i < Number_of_Cities; i++)
            {
                nodes[i].WestHour = WestHourArray[i];
            }

            TMSLogger.LogIt(" | " + "MappingClass.cs" + " | " + "MappingClass" + " | " + "Constructor" + " | " + "Confirmation" + " | " + "Mapping Class created" + " | ");

            int k = 0;
        }