Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static bool UpdateShipScheduleTrip(ShipScheduleDataset.ShipScheduleTripTableRow trip)
        {
            //
            bool updated = false;
            ShipScheduleServiceClient client = new ShipScheduleServiceClient();

            try {
                //Map datarow to data transfer object
                ShipScheduleTrip sstrip = new ShipScheduleTrip();
                sstrip.TripID           = trip.TripID;
                sstrip.ScheduleID       = trip.ScheduleID;
                sstrip.TemplateID       = trip.TemplateID;
                sstrip.BolNumber        = !trip.IsBolNumberNull() ? trip.BolNumber : 0;
                sstrip.CarrierServiceID = !trip.IsCarrierServiceIDNull() ? trip.CarrierServiceID : 0;
                sstrip.LoadNumber       = !trip.IsLoadNumberNull() ? trip.LoadNumber : "";
                sstrip.TrailerNumber    = !trip.IsTrailerNumberNull() ? trip.TrailerNumber : "";
                sstrip.TractorNumber    = !trip.IsTractorNumberNull() ? trip.TractorNumber : "";
                sstrip.DriverName       = !trip.IsDriverNameNull() ? trip.DriverName : "";
                if (!trip.IsScheduledCloseNull())
                {
                    sstrip.ScheduledClose = trip.ScheduledClose;
                }
                if (!trip.IsScheduledDepartureNull())
                {
                    sstrip.ScheduledDeparture = trip.ScheduledDeparture;
                }
                sstrip.IsMandatory = !trip.IsIsMandatoryNull() ? trip.IsMandatory : (byte)0;
                if (!trip.IsFreightAssignedNull())
                {
                    sstrip.FreightAssigned = trip.FreightAssigned;
                }
                if (!trip.IsTrailerCompleteNull())
                {
                    sstrip.TrailerComplete = trip.TrailerComplete;
                }
                if (!trip.IsPaperworkCompleteNull())
                {
                    sstrip.PaperworkComplete = trip.PaperworkComplete;
                }
                if (!trip.IsTrailerDispatchedNull())
                {
                    sstrip.TrailerDispatched = trip.TrailerDispatched;
                }
                if (!trip.IsCanceledNull())
                {
                    sstrip.Canceled = trip.Canceled;
                }
                sstrip.LastUpdated = DateTime.Now;
                sstrip.UserID      = Environment.UserName;
                sstrip.RowVersion  = trip.RowVersion;

                updated = client.UpdateShipScheduleTrip(int.Parse(Program.TerminalCode), sstrip);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <ShipScheduleFault> ssf) { client.Abort(); throw new ApplicationException(ssf.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(updated);
        }
Exemplo n.º 3
0
        public bool UpdateShipScheduleTrip(int terminalID, ShipScheduleTrip trip)
        {
            //Update the specified ship schedule trip
            bool updated = false;

            try {
                updated = new TsortGateway(terminalID).UpdateShipScheduleTrip(trip);
            }
            catch (Exception ex) { throw new FaultException <ShipScheduleFault>(new ShipScheduleFault(ex.Message), "Service Error"); }
            return(updated);
        }
Exemplo n.º 4
0
        public static bool MoveTL(ShipScheduleTrip trip, string tl)
        {
            //Move a closed TL to this trip
            bool ret = false;

            try {
                ret = App.Mediator.ExecuteNonQuery(USP_SHIPSCHEDULE_MOVEFREIGHT, new object[] { tl, trip.TripID });
                RefreshTrips();
            }
            catch (Exception ex) { throw new ApplicationException("Failed to move open TL#" + tl + " to ship schedule trip#" + trip.TripID + ".", ex); }
            return(ret);
        }
Exemplo n.º 5
0
        public static bool UnassignTL(ShipScheduleTrip trip, string tl)
        {
            //Unassign an open TL from this trip
            bool ret = false;

            try {
                ret = App.Mediator.ExecuteNonQuery(USP_SHIPSCHEDULE_UNASSIGNFREIGHT, new object[] { tl });
                RefreshTrips();
            }
            catch (Exception ex) { throw new ApplicationException("Failed to unassign open TL#" + tl + " to ship schedule trip#" + trip.TripID + ".", ex); }
            return(ret);
        }
Exemplo n.º 6
0
        public bool DepartShipScheduleTrip(ShipScheduleTrip trip)
        {
            //
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SS_TRIP_DEPART,
                                                            new object[] { trip.TripID, trip.BolNumber, trip.TrailerNumber,
                                                                           trip.LastUpdated, trip.UserID });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Exemplo n.º 7
0
        public bool DispatchShipScheduleTrip(ShipScheduleTrip trip)
        {
            //
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SS_TRIP_DISPATCH,
                                                            new object[] { trip.TripID, trip.LoadNumber, trip.TrailerNumber, trip.DriverName,
                                                                           (trip.ScheduledDeparture != DateTime.MinValue ? trip.ScheduledDeparture : null as object),
                                                                           trip.LastUpdated, trip.UserID });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Exemplo n.º 8
0
        public static ShipScheduleTrip GetTrip(string tripID)
        {
            //Return an existing trip from this ship schedule
            ShipScheduleTrip trip = null;

            try {
                //Merge from collection (dataset)
                ShipScheduleDS.ShipScheduleMasterTableRow   _trip = (ShipScheduleDS.ShipScheduleMasterTableRow)_Trips.ShipScheduleMasterTable.Select("TripID='" + tripID + "'")[0];
                ShipScheduleDS.ShipScheduleDetailTableRow[] _tls  = (ShipScheduleDS.ShipScheduleDetailTableRow[])_Trips.ShipScheduleDetailTable.Select("TripID='" + tripID + "'");
                trip = new ShipScheduleTrip(_trip, _tls);
            }
            catch (Exception ex) { throw new ApplicationException("Failed to get trip " + tripID + ".", ex); }
            return(trip);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        public bool UpdateShipScheduleTrip(ShipScheduleTrip trip)
        {
            //
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SS_TRIP_UPDATE,
                                                            new object[] { trip.TripID, trip.CarrierServiceID, trip.LoadNumber,
                                                                           trip.TrailerNumber, trip.TractorNumber, trip.DriverName,
                                                                           (trip.ScheduledClose != DateTime.MinValue ? trip.ScheduledClose : null as object),
                                                                           (trip.ScheduledDeparture != DateTime.MinValue ? trip.ScheduledDeparture : null as object),
                                                                           (trip.FreightAssigned != DateTime.MinValue ? trip.FreightAssigned : null as object),
                                                                           (trip.TrailerComplete != DateTime.MinValue ? trip.TrailerComplete : null as object),
                                                                           (trip.PaperworkComplete != DateTime.MinValue ? trip.PaperworkComplete : null as object),
                                                                           (trip.TrailerDispatched != DateTime.MinValue ? trip.TrailerDispatched : null as object),
                                                                           (trip.Canceled != DateTime.MinValue ? trip.Canceled : null as object),
                                                                           trip.LastUpdated, trip.UserID, trip.RowVersion });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Exemplo n.º 11
0
        public static bool Close(ShipScheduleTrip trip)
        {
            //Close a trip from further TL assignments
            bool ret = false;

            try {
                //Validate, then close
                if (!trip.IsOpen)
                {
                    throw new ApplicationException("Trip#" + trip.TripID + " is already closed!");
                }
                if (trip.IsComplete)
                {
                    throw new ApplicationException("Trip#" + trip.TripID + " is complete and cannot be closed!");
                }
                ret = App.Mediator.ExecuteNonQuery(USP_SHIPSCHEDULE_ALLASSIGNED, new object[] { trip.TripID, 1 });
                RefreshTrips();
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Failed to close trip#" + trip.TripID + ".", ex); }
            return(ret);
        }
Exemplo n.º 12
0
        public bool UpdateShipSchedule(int terminalID, ShipScheduleTrip trip, ShipScheduleStop stop1, ShipScheduleStop stop2)
        {
            //Update the specified ship schedule including the trip and 2 stops
            bool updated = false;

            try {
                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //UPdate trip and stop1; update stop2 if not null
                    new TsortGateway(terminalID).UpdateShipScheduleTrip(trip);
                    new TsortGateway(terminalID).UpdateShipScheduleTripStop(stop1);
                    if (stop2 != null)
                    {
                        new TsortGateway(terminalID).UpdateShipScheduleTripStop(stop2);
                    }
                    updated = true;

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <ShipScheduleFault>(new ShipScheduleFault(ex.Message), "Service Error"); }
            return(updated);
        }
Exemplo n.º 13
0
        public static bool UpdateShipSchedule(ShipScheduleDataset.ShipScheduleViewTableRow viewItem)
        {
            //
            bool updated = false;
            ShipScheduleServiceClient client = new ShipScheduleServiceClient();

            try {
                //Map datarows to data transfer objects
                ShipScheduleTrip sstrip = new ShipScheduleTrip();
                sstrip.TripID           = viewItem.TripID;
                sstrip.ScheduleID       = viewItem.ScheduleID;
                sstrip.TemplateID       = viewItem.TemplateID;
                sstrip.BolNumber        = !viewItem.IsBolNumberNull() ? viewItem.BolNumber : 0;
                sstrip.CarrierServiceID = !viewItem.IsCarrierServiceIDNull() ? viewItem.CarrierServiceID : 0;
                sstrip.LoadNumber       = !viewItem.IsLoadNumberNull() ? viewItem.LoadNumber : "";
                sstrip.TrailerNumber    = !viewItem.IsTrailerNumberNull() ? viewItem.TrailerNumber : "";
                sstrip.TractorNumber    = !viewItem.IsTractorNumberNull() ? viewItem.TractorNumber : "";
                sstrip.DriverName       = !viewItem.IsDriverNameNull() ? viewItem.DriverName : "";
                if (!viewItem.IsScheduledCloseNull())
                {
                    sstrip.ScheduledClose = viewItem.ScheduledClose;
                }
                if (!viewItem.IsScheduledDepartureNull())
                {
                    sstrip.ScheduledDeparture = viewItem.ScheduledDeparture;
                }
                sstrip.IsMandatory = !viewItem.IsIsMandatoryNull() ? viewItem.IsMandatory : (byte)0;
                if (!viewItem.IsFreightAssignedNull())
                {
                    sstrip.FreightAssigned = viewItem.FreightAssigned;
                }
                if (!viewItem.IsTrailerCompleteNull())
                {
                    sstrip.TrailerComplete = viewItem.TrailerComplete;
                }
                if (!viewItem.IsPaperworkCompleteNull())
                {
                    sstrip.PaperworkComplete = viewItem.PaperworkComplete;
                }
                if (!viewItem.IsTrailerDispatchedNull())
                {
                    sstrip.TrailerDispatched = viewItem.TrailerDispatched;
                }
                if (!viewItem.IsCanceledNull())
                {
                    sstrip.Canceled = viewItem.Canceled;
                }
                sstrip.LastUpdated = DateTime.Now;
                sstrip.UserID      = Environment.UserName;
                sstrip.RowVersion  = viewItem.SCDERowVersion;

                ShipScheduleStop ssstop1 = new ShipScheduleStop();
                ssstop1.StopID          = viewItem.StopID;
                ssstop1.TripID          = viewItem.TripID;
                ssstop1.StopNumber      = !viewItem.IsStopNumberNull() ? viewItem.StopNumber : "";
                ssstop1.AgentTerminalID = !viewItem.IsAgentTerminalIDNull() ? viewItem.AgentTerminalID : 0;
                ssstop1.Tag             = !viewItem.IsTagNull() ? viewItem.Tag : "";
                ssstop1.Notes           = !viewItem.IsNotesNull() ? viewItem.Notes : "";
                if (!viewItem.IsScheduledArrivalNull())
                {
                    ssstop1.ScheduledArrival = viewItem.ScheduledArrival;
                }
                if (!viewItem.IsScheduledOFD1Null())
                {
                    ssstop1.ScheduledOFD1 = viewItem.ScheduledOFD1;
                }
                ssstop1.LastUpdated = DateTime.Now;
                ssstop1.UserID      = Environment.UserName;
                ssstop1.RowVersion  = viewItem.S1RowVersion;

                ShipScheduleStop ssstop2 = null;
                if (!viewItem.IsS2MainZoneNull() && viewItem.S2MainZone.Trim().Length > 0)
                {
                    ssstop2                 = new ShipScheduleStop();
                    ssstop2.StopID          = viewItem.S2StopID;
                    ssstop2.TripID          = viewItem.TripID;
                    ssstop2.StopNumber      = !viewItem.IsS2StopNumberNull() ? viewItem.S2StopNumber : "";
                    ssstop2.AgentTerminalID = !viewItem.IsS2AgentTerminalIDNull() ? viewItem.S2AgentTerminalID : 0;
                    ssstop2.Tag             = !viewItem.IsS2TagNull() ? viewItem.S2Tag : "";
                    ssstop2.Notes           = !viewItem.IsS2NotesNull() ? viewItem.S2Notes : "";
                    if (!viewItem.IsS2ScheduledArrivalNull())
                    {
                        ssstop2.ScheduledArrival = viewItem.S2ScheduledArrival;
                    }
                    if (!viewItem.IsS2ScheduledOFD1Null())
                    {
                        ssstop2.ScheduledOFD1 = viewItem.S2ScheduledOFD1;
                    }
                    ssstop2.LastUpdated = DateTime.Now;
                    ssstop2.UserID      = Environment.UserName;
                    ssstop2.RowVersion  = viewItem.S2RowVersion;
                }

                updated = client.UpdateShipSchedule(int.Parse(Program.TerminalCode), sstrip, ssstop1, ssstop2);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <ShipScheduleFault> ssf) { client.Abort(); throw new ApplicationException(ssf.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(updated);
        }