public static ShipScheduleDataset GetShipSchedule(DateTime scheduleDate, long agentTerminalID) { //Get a ship schedule (collection of ttrips and associated tls) for the specified terminal, date, and agent ShipScheduleDataset schedule = new ShipScheduleDataset(); ZoneClosingServiceClient client = new ZoneClosingServiceClient(); try { DataSet ds = client.GetShipScheduleView(int.Parse(Program.TerminalCode), scheduleDate); ShipScheduleDataset _schedule = new ShipScheduleDataset(); if (ds != null) { _schedule.Merge(ds); } if (_schedule.ShipScheduleViewTable.Rows.Count > 0) { string filter1 = agentTerminalID > 0 ? "AgentTerminalID=" + agentTerminalID + " OR S2AgentTerminalID=" + agentTerminalID : ""; string filter2 = agentTerminalID > 0 ? "AgentTerminalID=" + agentTerminalID : ""; if (filter1.Length > 0) { schedule.Merge(_schedule.ShipScheduleViewTable.Select(filter1)); schedule.Merge(_schedule.ShipScheduleTLTable.Select(filter2)); } else { schedule.Merge(_schedule); } } client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <ShipScheduleFault> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(schedule); }
public static ShipScheduleDataset GetAvailableTrips(DateTime scheduleDate, long agentTerminalID) { //Get trips for the specified main zone and date that are available for assignment ShipScheduleDataset trips = new ShipScheduleDataset(); ZoneClosingServiceClient client = new ZoneClosingServiceClient(); try { DataSet ds = client.GetShipScheduleView(int.Parse(Program.TerminalCode), scheduleDate); ShipScheduleDataset _schedule = new ShipScheduleDataset(); if (ds != null) { _schedule.Merge(ds); } if (_schedule.ShipScheduleViewTable.Rows.Count > 0) { ShipScheduleDataset __schedule = new ShipScheduleDataset(); __schedule.Merge(_schedule.ShipScheduleViewTable.Select("AgentTerminalID='" + agentTerminalID + "' OR S2AgentTerminalID=" + agentTerminalID)); trips.Merge(__schedule.ShipScheduleViewTable.Select("IsNull(FreightAssigned, #08/02/61#) = #08/02/61#")); } client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <ShipScheduleFault> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(trips); }
public static void RefreshSchedules() { //Update a collection of all ship schedules for single terminal try { //Clear and update ship schedules _Schedules.Clear(); DateTime dateMin = DateTime.Today.AddDays(-App.Config.ScheduleDaysBack); DateTime dateMax = DateTime.Today.AddDays(App.Config.ScheduleDaysForward); DateTime date = DateTime.Today; for (int i = 0; i < App.Config.PastBusinessDays; i++) { date = date.AddDays(-1); while (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday) { date = date.AddDays(-1); } } ShipScheduleDataset schedules = ShipScheduleGateway.GetShipSchedules(date); _Schedules.Merge(schedules.ShipScheduleTable.Select("ScheduleDate >= '" + dateMin + "' AND ScheduleDate <= '" + dateMax + "'")); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } finally { if (SchedulesChanged != null) { SchedulesChanged(null, EventArgs.Empty); } } }
public void OnAutoRefreshCompleted(object sender, RunWorkerCompletedEventArgs e) { // try { ShipScheduleDataset ds = null; //if(this.InvokeRequired) { // this.Invoke(new RunWorkerCompletedEventHandler(OnAutoRefreshCompleted), new object[] { sender, e }); //} //else { ds = (ShipScheduleDataset)e.Result; //if(this.grdTLs.ActiveCell == null || !this.grdTLs.ActiveCell.IsInEditMode) { lock (this.mTrips) { this.mTrips.Clear(); this.mTrips.Merge(ds.Tables["ShipScheduleViewTable"]); } lock (this.mTemplates) { this.mTemplates.Clear(); this.mTemplates.Merge(ds.Tables["TemplateViewTable"]); } //} //} } catch { } finally { if (this.Changed != null) { this.Changed(this, EventArgs.Empty); } } }
//Interface static AgentLineHaulGateway() { // _Trips = new ShipScheduleDataset(); ShipScheduleServiceClient client = new ShipScheduleServiceClient(); _state = true; _address = client.Endpoint.Address.Uri.AbsoluteUri; }
private void OnAutoRefresh(object sender, DoWorkEventArgs e) { //Event handler for background worker thread DoWork event; runs on worker thread try { ShipScheduleDataset ds = new ShipScheduleDataset(); ds.Merge(ShipScheduleGateway.GetShipSchedule(this.mSortCenterID, this.mScheduleDate)); ds.Merge(ShipScheduleGateway.GetShipScheduleTemplates(this.mSortCenterID, this.mScheduleDate)); e.Result = ds; } catch { } }
public void Update() { //Extract the row versions and update the updated rows. This will keep the selected row in the view //Checks for duplicate load number within the same carrier during the past and future 7 days try { //Determine changes made to the trips in this ship schedule ShipScheduleDataset trips = (ShipScheduleDataset)this.mTrips.GetChanges(DataRowState.Modified); if (trips != null && trips.ShipScheduleViewTable.Rows.Count > 0) { //Update each modified trip foreach (ShipScheduleDataset.ShipScheduleViewTableRow row in trips.ShipScheduleViewTable.Rows) { //Check to see if load# or carrier has changed; if so, then make sure it's unique within the same //carrier (updated once if it's updated along with load#) and during the past one week schedule if (row.LoadNumber.Trim() != row["LoadNumber", DataRowVersion.Original].ToString().Trim() && row.CarrierServiceID.ToString().Trim() == row["CarrierServiceID", DataRowVersion.Original].ToString().Trim()) { string tripID = ShipScheduleGateway.FindShipScheduleTrip(row.ScheduleDate, 0, row.LoadNumber.Trim()); if (tripID.Trim().Length > 0) { throw new DuplicateLoadNumberException("Duplicate load# found in ship schedule for " + tripID + "."); } } //Save trip details ShipScheduleGateway.UpdateShipSchedule(row); try { //Refresh the details of the current trip (instead of a full refresh) ShipScheduleDataset viewItems = ShipScheduleGateway.GetShipSchedule(row.SortCenterID, row.ScheduleDate); if (viewItems.ShipScheduleViewTable.Rows.Count > 0) { ShipScheduleDataset.ShipScheduleViewTableRow viewItem = viewItems.ShipScheduleViewTable.FindByTripID(row.TripID); ShipScheduleDataset.ShipScheduleViewTableRow trip = this.mTrips.ShipScheduleViewTable.FindByTripID(row.TripID); trip.SCDERowVersion = viewItem.SCDERowVersion; trip.S1RowVersion = viewItem.S1RowVersion; if (!row.IsS2StopIDNull()) { trip.S2RowVersion = viewItem.S2RowVersion; } this.mTrips.AcceptChanges(); } } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } } //Refresh(); Doing partial refresh above for performance reasons (i.e. cell editing) } } catch (DuplicateLoadNumberException ex) { throw ex; } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } }
public static ShipSchedule SchedulesAdd(long sortCenterID, string sortCenter, DateTime scheduleDate) { //Add a new ship schedule ShipSchedule schedule = null; try { //Add and update collection ShipScheduleDataset ds = new ShipScheduleDataset(); ds.ShipScheduleTable.AddShipScheduleTableRow("", sortCenterID, sortCenter, scheduleDate, DateTime.Now, Environment.UserName); schedule = new ShipSchedule(ds.ShipScheduleTable[0]); schedule.Changed += new EventHandler(OnShipScheduleChanged); schedule.Create(); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(schedule); }
public static ShipScheduleDataset GetShipSchedules(DateTime scheduleDate) { //Get a list of ship schedules for the specified date ShipScheduleDataset schedules = new ShipScheduleDataset(); ShipScheduleServiceClient client = new ShipScheduleServiceClient(); try { schedules.Merge(client.GetShipSchedules(int.Parse(Program.TerminalCode), scheduleDate)); 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(schedules); }
public ShipSchedule(ShipScheduleDataset.ShipScheduleTableRow schedule) { //Constructor try { if (schedule != null) { this.mScheduleID = schedule.ScheduleID; this.mSortCenterID = schedule.SortCenterID; this.mSortCenter = schedule.SortCenter.Trim(); this.mScheduleDate = schedule.ScheduleDate; } this.mTrips = new ShipScheduleDataset(); this.mTemplates = new ShipScheduleDataset(); this.mAutoRefreshSvc = new AutoRefreshService(this); Refresh(); } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } }
public static void RefreshTrips() { //Update a collection (dataset) of all ship schedule trips for the terminal on the local LAN database ZoneClosingServiceClient client = new ZoneClosingServiceClient(); try { //Clear and update cached trips/stops for current schedule date _ScheduleID = ""; _Trips.Clear(); DataSet ds = client.GetShipScheduleView(int.Parse(Program.TerminalCode), _ScheduleDate); ShipScheduleDataset _schedule = new ShipScheduleDataset(); if (ds != null) { _schedule.Merge(ds); } if (_schedule.ShipScheduleViewTable.Rows.Count > 0) { _ScheduleID = _schedule.ShipScheduleViewTable[0].ScheduleID; string filter1 = _AgentTerminalID > 0 ? "AgentTerminalID=" + _AgentTerminalID + " OR S2AgentTerminalID=" + _AgentTerminalID : ""; string filter2 = _AgentTerminalID > 0 ? "AgentTerminalID=" + _AgentTerminalID : ""; if (filter1.Length > 0) { _Trips.Merge(_schedule.ShipScheduleViewTable.Select(filter1)); _Trips.Merge(_schedule.ShipScheduleTLTable.Select(filter2)); } else { _Trips.Merge(_schedule); } } client.Close(); } catch (ConstraintException ex) { throw new ApplicationException(ex.Message, ex); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } finally { if (Changed != null) { Changed(null, EventArgs.Empty); } } }
public static ShipSchedule SchedulesArchiveItem(long sortCenterID, string sortCenter, DateTime scheduleDate) { //Return an archived ship schedule ShipSchedule schedule = null; try { // ShipScheduleDataset schedules = new ShipScheduleDataset(); schedules.Merge(ShipScheduleGateway.GetShipSchedules(scheduleDate)); if (schedules.ShipScheduleTable.Rows.Count > 0) { DataRow[] rows = schedules.ShipScheduleTable.Select("SortCenterID=" + sortCenterID + " AND ScheduleDate='" + scheduleDate + "'"); if (rows.Length > 0) { ShipScheduleDataset scheduleDS = new ShipScheduleDataset(); scheduleDS.ShipScheduleTable.AddShipScheduleTableRow("", sortCenterID, sortCenter, scheduleDate, DateTime.Now, Environment.UserName); schedule = new ShipSchedule(scheduleDS.ShipScheduleTable[0]); schedule.Changed += new EventHandler(OnShipScheduleChanged); } } } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(schedule); }
public ShipScheduleItem(ShipScheduleDataset.ShipScheduleViewTableRow viewRow, ShipScheduleDataset.ShipScheduleTLTableRow[] tls) { //Constructor try { this.mAssignedTLs = new ShipScheduleDataset(); if (viewRow != null) { this._scheduleid = viewRow.ScheduleID; this._sortcenterid = viewRow.SortCenterID; if (!viewRow.IsSortCenterNull()) { this._sortcenter = viewRow.SortCenter; } this._scheduledate = viewRow.ScheduleDate; this._tripid = viewRow.TripID; if (!viewRow.IsTemplateIDNull()) { this._templateid = viewRow.TemplateID; } if (!viewRow.IsBolNumberNull()) { this._bolnumber = viewRow.BolNumber; } if (!viewRow.IsCarrierServiceIDNull()) { this._carrierserviceid = viewRow.CarrierServiceID; } if (!viewRow.IsCarrierNull()) { this._carrier = viewRow.Carrier; } if (!viewRow.IsLoadNumberNull()) { this._loadnumber = viewRow.LoadNumber; } if (!viewRow.IsTrailerIDNull()) { this._trailerid = viewRow.TrailerID; } if (!viewRow.IsTrailerNumberNull()) { this._trailernumber = viewRow.TrailerNumber; } if (!viewRow.IsTractorNumberNull()) { this._tractornumber = viewRow.TractorNumber; } if (!viewRow.IsScheduledCloseNull()) { this._scheduledclose = viewRow.ScheduledClose; } if (!viewRow.IsScheduledDepartureNull()) { this._scheduleddeparture = viewRow.ScheduledDeparture; } if (!viewRow.IsIsMandatoryNull()) { this._ismandatory = viewRow.IsMandatory; } if (!viewRow.IsFreightAssignedNull()) { this._freightassigned = viewRow.FreightAssigned; } if (!viewRow.IsTrailerCompleteNull()) { this._trailercomplete = viewRow.TrailerComplete; } if (!viewRow.IsPaperworkCompleteNull()) { this._paperworkcomplete = viewRow.PaperworkComplete; } if (!viewRow.IsTrailerDispatchedNull()) { this._trailerdispatched = viewRow.TrailerDispatched; } if (!viewRow.IsCanceledNull()) { this._canceled = viewRow.Canceled; } if (!viewRow.IsSCDEUserIDNull()) { this._scdeuserid = viewRow.SCDEUserID; } if (!viewRow.IsSCDELastUpdatedNull()) { this._scdelastupdated = viewRow.SCDELastUpdated; } if (!viewRow.IsSCDERowVersionNull()) { this._scderowversion = viewRow.SCDERowVersion; } if (!viewRow.IsStopIDNull()) { this._stopid = viewRow.StopID; } if (!viewRow.IsStopNumberNull()) { this._stopnumber = viewRow.StopNumber; } if (!viewRow.IsAgentTerminalIDNull()) { this._agentterminalid = viewRow.AgentTerminalID; } if (!viewRow.IsAgentNumberNull()) { this._agentnumber = viewRow.AgentNumber; } if (!viewRow.IsMainZoneNull()) { this._mainzone = viewRow.MainZone; } if (!viewRow.IsTagNull()) { this._tag = viewRow.Tag; } if (!viewRow.IsNotesNull()) { this._notes = viewRow.Notes; } if (!viewRow.IsScheduledArrivalNull()) { this._scheduledarrival = viewRow.ScheduledArrival; } if (!viewRow.IsScheduledOFD1Null()) { this._scheduledofd1 = viewRow.ScheduledOFD1; } if (!viewRow.IsS1UserIDNull()) { this._s1userid = viewRow.S1UserID; } if (!viewRow.IsS1LastUpdatedNull()) { this._s1lastupdated = viewRow.S1LastUpdated; } if (!viewRow.IsS1RowVersionNull()) { this._s1rowversion = viewRow.S1RowVersion; } if (!viewRow.IsS2StopIDNull()) { this._s2stopid = viewRow.S2StopID; } if (!viewRow.IsS2StopNumberNull()) { this._s2stopnumber = viewRow.S2StopNumber; } if (!viewRow.IsS2AgentTerminalIDNull()) { this._s2agentterminalid = viewRow.S2AgentTerminalID; } if (!viewRow.IsS2AgentNumberNull()) { this._s2agentnumber = viewRow.S2AgentNumber; } if (!viewRow.IsS2MainZoneNull()) { this._s2mainzone = viewRow.S2MainZone; } if (!viewRow.IsS2TagNull()) { this._s2tag = viewRow.S2Tag; } if (!viewRow.IsS2NotesNull()) { this._s2notes = viewRow.S2Notes; } if (!viewRow.IsS2ScheduledArrivalNull()) { this._s2scheduledarrival = viewRow.S2ScheduledArrival; } if (!viewRow.IsS2ScheduledOFD1Null()) { this._s2scheduledofd1 = viewRow.S2ScheduledOFD1; } if (!viewRow.IsS2UserIDNull()) { this._s2userid = viewRow.S2UserID; } if (!viewRow.IsS2LastUpdatedNull()) { this._s2lastupdated = viewRow.S2LastUpdated; } if (!viewRow.IsS2RowVersionNull()) { this._s2rowversion = viewRow.S2RowVersion; } if (!viewRow.IsNextCarrierNull()) { this._nextcarrier = viewRow.NextCarrier; } if (!viewRow.IsCarrierIDNull()) { this._carrierid = viewRow.CarrierID; } if (tls != null) { ShipScheduleDataset.ShipScheduleViewTableRow _trip = this.mAssignedTLs.ShipScheduleViewTable.NewShipScheduleViewTableRow(); _trip.ScheduleID = this.ScheduleID; _trip.SortCenterID = this.SortCenterID; _trip.TripID = this.TripID; this.mAssignedTLs.ShipScheduleViewTable.AddShipScheduleViewTableRow(_trip); this.mAssignedTLs.Merge(tls); } } } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } }
//Interface static ShipSchedules() { //Constructor _Schedules = new ShipScheduleDataset(); }