示例#1
0
 public static void RefreshSchedules()
 {
     //Update a collection (dataset) of all ship schedules for all terminals
     try {
         //Clear and update ship schedules
         _Schedules.Clear();
         DateTime date = DateTime.Today;
         for (int i = 0; i < ShipScheduleFactory.PastBusinessDays; i++)
         {
             date = date.AddDays(-1);
             while (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
             {
                 date = date.AddDays(-1);
             }
         }
         DataSet ds = Mediator.FillDataset(Lib.USP_SCHEDULES, Lib.TBL_SCHEDULES, new object[] { date });
         if (ds.Tables[Lib.TBL_SCHEDULES].Rows.Count > 0)
         {
             //Filter out old schedules
             DateTime dateMin = DateTime.Today.AddDays(-ShipScheduleFactory.ScheduleDaysBack);
             DateTime dateMax = DateTime.Today.AddDays(ShipScheduleFactory.ScheduleDaysForward);
             //NOTE: Following statement not working since ported- replaced with next 3 lines
             //_Schedules.Merge(ds.Tables[Lib.TBL_SCHEDULES].Select("ScheduleDate >= '" + dateMin + "'"), true, MissingSchemaAction.Ignore);
             DataSet _ds = new DataSet();
             _ds.Merge(ds.Tables[Lib.TBL_SCHEDULES].Select("ScheduleDate >= '" + dateMin + "' AND ScheduleDate <= '" + dateMax + "'"));
             _Schedules.Merge(_ds);
         }
     }
     catch (Exception ex) { throw new ApplicationException("Failed to refresh ship schedule list.", ex); }
     finally { if (SchedulesChanged != null)
               {
                   SchedulesChanged(null, EventArgs.Empty);
               }
     }
 }
示例#2
0
        public static ShipScheduleTrip GetEarlierTripFromThisSchedule(string tripID, string freightID)
        {
            //Return an earlier trip from the current schedule than the one specified if one exists
            ShipScheduleTrip earlierTrip = null;

            try {
                //Get all earlier trips (open, not cancelled)
                DataSet ds = App.Mediator.FillDataset(USP_SHIPSCHEDULE_PRIORTRIPS, TBL_SHIPSCHEDULE_PRIORTRIPS, new object[] { tripID, freightID });
                if (ds.Tables[TBL_SHIPSCHEDULE_PRIORTRIPS].Rows.Count > 0)
                {
                    ShipScheduleDS schedule = new ShipScheduleDS();
                    schedule.Merge(ds);
                    int tag = 0;
                    for (int i = 0; i < schedule.ShipScheduleMasterTable.Rows.Count; i++)
                    {
                        //Select only trips with the same schedule date as this.mScheduleDate
                        ShipScheduleDS.ShipScheduleMasterTableRow trip = (ShipScheduleDS.ShipScheduleMasterTableRow)schedule.ShipScheduleMasterTable.Rows[i];
                        if (trip.ScheduleDate.CompareTo(_ScheduleDate) == 0)
                        {
                            //Capture the trip with the largest tag #
                            if (int.Parse(trip.Tag.Trim()) > tag)
                            {
                                tag         = int.Parse(trip.Tag.Trim());
                                earlierTrip = new ShipScheduleTrip(trip);
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { throw new ApplicationException("Failed determine if an earlier ship schedule trip exists.", ex); }
            return(earlierTrip);
        }
示例#3
0
 public static void RefreshTrips()
 {
     //Update a collection (dataset) of all ship schedule trips for the terminal on the local LAN database
     try {
         //Clear and update cached trips/stops for current schedule date
         _ScheduleID = "";
         _Trips.Clear();
         DataSet trips   = new DataSet();
         string  filter1 = _AgentTerminalID > 0 ? "AgentTerminalID=" + _AgentTerminalID + " OR S2AgentTerminalID=" + _AgentTerminalID : "";
         string  filter2 = _AgentTerminalID > 0 ? "AgentTerminalID=" + _AgentTerminalID : "";
         DataSet ds      = App.Mediator.FillDataset(USP_SHIPSCHEDULE_SCHEDULE, TBL_SHIPSCHEDULE_SCHEDULE, new object[] { _ScheduleDate });
         if (ds.Tables[TBL_SHIPSCHEDULE_SCHEDULE].Rows.Count > 0)
         {
             //Capture scheduleID; then merge in trips- filter as required
             _ScheduleID = ds.Tables[TBL_SHIPSCHEDULE_SCHEDULE].Rows[0]["ScheduleID"].ToString();
             if (filter1.Length > 0)
             {
                 trips.Merge(ds.Tables[TBL_SHIPSCHEDULE_SCHEDULE].Select(filter1));
             }
             else
             {
                 trips.Merge(ds);
             }
             if (trips.Tables[TBL_SHIPSCHEDULE_SCHEDULE] != null && trips.Tables[TBL_SHIPSCHEDULE_SCHEDULE].Rows.Count > 0)
             {
                 //Merge in stops- filter as required
                 ds = App.Mediator.FillDataset(USP_SHIPSCHEDULE_FREIGHT, TBL_SHIPSCHEDULE_FREIGHT, new object[] { _ScheduleID });
                 if (ds.Tables[TBL_SHIPSCHEDULE_FREIGHT].Rows.Count > 0)
                 {
                     if (filter2.Length > 0)
                     {
                         trips.Merge(ds.Tables[TBL_SHIPSCHEDULE_FREIGHT].Select(filter2));
                     }
                     else
                     {
                         trips.Merge(ds);
                     }
                 }
             }
         }
         _Trips.Merge(trips);
     }
     catch (ConstraintException ex) { throw new ApplicationException("Failed to refresh ship schedule- constraint exception.", ex); }
     catch (Exception ex) { throw new ApplicationException("Failed to refresh ship schedule.", ex); }
     finally { if (Changed != null)
               {
                   Changed(null, EventArgs.Empty);
               }
     }
 }
示例#4
0
        public static ShipScheduleTrip GetEarlierTripFromAPriorSchedule(string tripID, string freightID)
        {
            //Return an earlier trip from a schedule prior to the one specified
            ShipScheduleTrip earlierTrip = null;

            try {
                //Get all earlier trips (open, not cancelled)
                DataSet ds = App.Mediator.FillDataset(USP_SHIPSCHEDULE_PRIORTRIPS, TBL_SHIPSCHEDULE_PRIORTRIPS, new object[] { tripID, freightID });
                if (ds.Tables[TBL_SHIPSCHEDULE_PRIORTRIPS].Rows.Count > 0)
                {
                    ShipScheduleDS schedule = new ShipScheduleDS();
                    schedule.Merge(ds);
                    DateTime date = _ScheduleDate.AddYears(-5);
                    int      tag  = 0;
                    for (int i = 0; i < schedule.ShipScheduleMasterTable.Rows.Count; i++)
                    {
                        //Select a trip with the most recent schedule date (not including this.mScheduleDate)
                        ShipScheduleDS.ShipScheduleMasterTableRow trip = (ShipScheduleDS.ShipScheduleMasterTableRow)schedule.ShipScheduleMasterTable.Rows[i];
                        if (trip.ScheduleDate.CompareTo(_ScheduleDate) < 0)
                        {
                            //Capture the most recent trip date
                            if (trip.ScheduleDate.CompareTo(date) > 0)
                            {
                                date = trip.ScheduleDate; tag = 0;
                            }
                            if (trip.ScheduleDate.CompareTo(date) == 0)
                            {
                                //Capture the trip taht is most recent and with the largest tag #
                                if (int.Parse(trip.Tag.Trim()) > tag)
                                {
                                    tag         = int.Parse(trip.Tag.Trim());
                                    earlierTrip = new ShipScheduleTrip(trip);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { throw new ApplicationException("Failed determine if an earlier ship schedule trip exists.", ex); }
            return(earlierTrip);
        }
示例#5
0
        public static ShipScheduleDS GetAvailableTrips(long agentTerminalID, DateTime dt)
        {
            //Get trips for the specified main zone and date that are available for assignment
            ShipScheduleDS trips = null;

            try {
                //Get the schedule for the specified date
                trips = new ShipScheduleDS();
                DataSet ds = App.Mediator.FillDataset(USP_SHIPSCHEDULE_SCHEDULE, TBL_SHIPSCHEDULE_SCHEDULE, new object[] { dt });
                if (ds.Tables[TBL_SHIPSCHEDULE_SCHEDULE].Rows.Count > 0)
                {
                    //Filter for trips (both stops) matching the specified agent terminal and that are open for assignment
                    ShipScheduleDS s = new ShipScheduleDS();
                    s.Merge(ds);
                    ShipScheduleDS schedule = new ShipScheduleDS();
                    schedule.Merge(s.ShipScheduleMasterTable.Select("AgentTerminalID='" + agentTerminalID + "' OR S2AgentTerminalID=" + agentTerminalID));
                    trips.Merge(schedule.ShipScheduleMasterTable.Select("IsNull(FreightAssigned, #08/02/61#) = #08/02/61#"));
                }
            }
            catch (Exception ex) { throw new ApplicationException("Failed to get ship schedule.", ex); }
            return(trips);
        }