protected void OnCommand(object sender, CommandEventArgs e) { // try { switch (e.CommandName) { case "Assign": if (this.cboSortType.SelectedValue.Trim().Length > 0 && this.cboStation.SelectedValue.Trim().Length > 0) { Argix.Freight.Workstation station = new Argix.Freight.Workstation(); station.WorkStationID = this.cboStation.SelectedValue; Argix.Freight.InboundShipment shipment = new Argix.Freight.InboundShipment(); shipment.TerminalID = int.Parse(Request.QueryString["terminalID"]); shipment.FreightID = Request.QueryString["freightID"]; int sortTypeID = int.Parse(this.cboSortType.SelectedValue); bool added = new Argix.Freight.TsortGateway().CreateStationAssignment(station, shipment, sortTypeID); if (added) { Response.Redirect("~/Stations.aspx"); } } break; case "Cancel": Response.Redirect("~/Default.aspx"); break; } } catch (Exception ex) { Master.ReportError(ex); } }
public static TsortDataset GetStationAssignments(InboundShipment shipment, string workStationID) { //Get a list of station-freight assignments for the specified terminal and workstation TsortDataset assignments = new TsortDataset(); try { TsortDataset _assignments = GetStationAssignments(); TsortDataset selectedAssignments = new TsortDataset(); if (workStationID.Trim().Length == 0) { selectedAssignments.Merge(_assignments.StationFreightAssignmentTable.Select("FreightID = '" + shipment.FreightID + "'")); } else { selectedAssignments.Merge(_assignments.StationFreightAssignmentTable.Select("FreightID = '" + shipment.FreightID + "' AND WorkStationID = '" + workStationID + "'")); } for (int i = 0; i < selectedAssignments.StationFreightAssignmentTable.Rows.Count; i++) { assignments.StationFreightAssignmentTable.ImportRow(selectedAssignments.StationFreightAssignmentTable[i]); } } catch (ApplicationException aex) { throw aex; } catch (Exception ex) { throw new ApplicationException(ex.Message); } return(assignments); }
protected void OnAssignment(object sender, CommandEventArgs e) { // try { switch (e.CommandName) { case "Add": if (this.cboSortType.SelectedValue.Trim().Length > 0 && this.cboStation.SelectedValue.Trim().Length > 0) { Argix.Freight.Workstation station = new Argix.Freight.Workstation(); station.WorkStationID = this.cboStation.SelectedValue; Argix.Freight.InboundShipment shipment = new Argix.Freight.InboundShipment(); shipment.TerminalID = int.Parse(this.cboTerminal.SelectedValue); shipment.FreightID = this.odsStations.SelectParameters["freightID"].DefaultValue; int sortTypeID = int.Parse(this.cboSortType.SelectedValue); bool added = new Argix.Freight.TsortGateway().CreateStationAssignment(station, shipment, sortTypeID); this.lsvAssignments.DataBind(); } break; case "Unassign": Argix.Freight.StationAssignment assignment = new Argix.Freight.StationAssignment(); assignment.SortStation = new Argix.Freight.Workstation(); assignment.SortStation.WorkStationID = e.CommandArgument.ToString().Split(new char[] { ',' })[0]; assignment.InboundFreight = new Argix.Freight.InboundShipment(); assignment.InboundFreight.TerminalID = int.Parse(this.cboTerminal.SelectedValue); assignment.InboundFreight.FreightID = e.CommandArgument.ToString().Split(new char[] { ',' })[1]; assignment.SortTypeID = int.Parse(e.CommandArgument.ToString().Split(new char[] { ',' })[2]); bool removed = new Argix.Freight.TsortGateway().DeleteStationAssignment(assignment); this.lsvAssignments.DataBind(); break; } } catch (Exception ex) { Master.ReportError(ex); } }
public static bool CreateStationAssignment(Workstation station, InboundShipment shipment, int sortTypeID, string initials) { // bool created = false; FreightAssignServiceClient client = new FreightAssignServiceClient(); try { created = client.CreateStationAssignment(shipment.TerminalID, station.WorkStationID, shipment.FreightID, sortTypeID); client.Close(); //Add to station assignment history _AssignmentHistory.FreightAssignmentHistoryTable.AddFreightAssignmentHistoryTableRow(DateTime.Today, shipment.TDSNumber, shipment.ClientNumber + "-" + shipment.ClientName, station.Number, DateTime.Now, initials); if (AssignmentHistoryChanged != null) { AssignmentHistoryChanged(null, EventArgs.Empty); } RefreshStationAssignments(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TsortFault> 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(created); }
//Interface public dlgAssignmentDetail(DialogActionEnum eDialogAction, InboundShipment shipment, string workstationID) { //Constructor try { InitializeComponent(); this.cmdCancel.Text = CMD_CANCEL; this.cmdBack.Text = CMD_BACK; this.cmdNext.Text = CMD_NEXT; this.mShipment = shipment; switch (this.mDialogAction = eDialogAction) { case DialogActionEnum.DialogActionAssign: this.Text = "Assign Freight To Sort Stations"; this.mAssignmentsDS.Clear(); break; case DialogActionEnum.DialogActionUnassignAny: this.Text = "Unassign Freight From Sort Stations"; this.mAssignmentsDS.Merge(TsortGateway.GetStationAssignments(this.mShipment, "")); break; case DialogActionEnum.DialogActionUnassign: this.Text = "Remove Freight Assignment"; this.mAssignmentsDS.Merge(TsortGateway.GetStationAssignments(this.mShipment, workstationID)); break; } } catch (Exception ex) { throw new ApplicationException("Could not crate new Assignment Detail dialog.", ex); } }
public StationAssignment(Workstation sortStation, InboundShipment inboundFreight, int sortTypeID) { //Constructor try { this.mWorkStation = sortStation; this.mInboundFreight = inboundFreight; this.mSortTypeID = sortTypeID; } catch (Exception ex) { throw new ApplicationException("Could not create a new station assignment.", ex); } }
public bool CreateStationAssignment(int terminalID, string workStationID, string freightID, int sortTypeID) { // bool created = false; try { //Verify shipment exists at this terminal InboundShipment _shipment = GetInboundShipment(terminalID, freightID); if (_shipment == null) { throw new ApplicationException("Inbound shipment " + freightID + " could not be found at terminal " + terminalID.ToString() + "."); } //Verify shipment is sortable if (!_shipment.IsSortable) { throw new ApplicationException("Freight cannot be assigned because all TDS arrival information has not been entered."); } //Verify freight is assignable to the specified station at this terminals FreightDataset stations = new FreightDataset(); stations.Merge(GetAssignableSortStations(terminalID, freightID, sortTypeID)); if (stations.WorkstationTable.Select("WorkstationID ='" + workStationID + "'", "").Length == 0) { throw new ApplicationException("WorkstationID " + workStationID + " is not assignable for freight " + freightID + " at terminal " + terminalID.ToString() + "."); } //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()) { // if (terminalID > 0) { bool unsorted = _shipment.Status.ToLower() == "unsorted"; bool sorting = _shipment.Status.ToLower() == "sorting"; bool sorted = _shipment.Status.ToLower() == "sorted"; if (unsorted) { sorting = new TsortGateway(terminalID).StartSort(freightID, DateTime.Now); } if (sorting || sorted) { created = new TsortGateway(terminalID).CreateStationAssignment(workStationID, freightID, sortTypeID); } } //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 <TsortFault>(new TsortFault(ex.Message), "Service Error"); } return(created); }
public static bool IsSortStopped(InboundShipment shipment) { //Determine if a shipment has completed sort bool sortStopped = false; try { InboundShipment ib = GetInboundShipment(shipment.FreightID); sortStopped = (ib.Status.ToLower() == "sorted"); } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Failed to determine if sort was stopped for freight ID#" + shipment.FreightID + ".", ex); } return(sortStopped); }
public bool StartSort(InboundShipment shipment) { // bool started = false; try { if (shipment.TerminalID > 0) { started = new TsortGateway(shipment.TerminalID).StartSort(shipment.FreightID, DateTime.Now); } } catch (Exception ex) { throw new FaultException <TsortFault>(new TsortFault(ex.Message), "Service Error"); } return(started); }
public bool CreateStationAssignment(Workstation station, InboundShipment shipment, int sortTypeID) { // bool created = false; FreightAssignServiceClient client = new FreightAssignServiceClient(); try { created = client.CreateStationAssignment(shipment.TerminalID, station.WorkStationID, shipment.FreightID, sortTypeID); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TsortFault> 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(created); }
public InboundShipment GetInboundShipment(string freightID) { //Get the operating enterprise terminal InboundShipment shipment = null; FreightServiceClient _Client = null; try { _Client = new FreightServiceClient(); shipment = _Client.GetInboundShipment(freightID); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetInboundShipment() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetInboundShipment() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetInboundShipment() communication error.", ce); } return(shipment); }
public static bool StopSort(InboundShipment shipment) { // bool stopped = false; FreightAssignServiceClient client = new FreightAssignServiceClient(); try { stopped = client.StopSort(shipment); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TsortFault> 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(stopped); }
public static InboundShipment GetInboundShipment(string freightID) { //Return the inbound shipment for the specified terminal and freightID InboundShipment shipment = null; FreightAssignServiceClient client = new FreightAssignServiceClient(); try { shipment = client.GetInboundShipment(int.Parse(Program.TerminalCode), freightID); client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TsortFault> 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(shipment); }
public InboundShipment GetInboundShipment(string freightID) { //Return the inbound shipment for the specified freightID InboundShipment shipment = null; try { DataSet ds = new DataService().FillDataset(SQL_CONNID, USP_SHIPMENT, TBL_FREIGHT, new object[] { freightID }); if (ds != null & ds.Tables[TBL_FREIGHT].Rows.Count > 0) { FreightDS freight = new FreightDS(); freight.Merge(ds, false, MissingSchemaAction.Ignore); shipment = new InboundShipment(freight.InboundFreightTable[0]); } } catch (Exception ex) { throw new FaultException <FreightFault>(new FreightFault(new ApplicationException("Unexpected error while reading inbound shipment.", ex))); } return(shipment); }
public static TsortDataset GetAssignableSortStations(InboundShipment shipment, int sortTypeID) { // TsortDataset sortStations = new TsortDataset(); FreightAssignServiceClient client = new FreightAssignServiceClient(); try { DataSet ds = client.GetAssignableSortStations(shipment.TerminalID, shipment.FreightID, sortTypeID); if (ds != null) { sortStations.Merge(ds); } client.Close(); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <TsortFault> 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(sortStations); }
public InboundShipment GetInboundShipment(int terminalID, string freightID) { //Return the inbound shipment for the specified terminal and freightID InboundShipment shipment = null; try { if (terminalID > 0) { DataSet ds = new TsortGateway(terminalID).GetInboundShipment(freightID); if (ds != null) { FreightDataset freight = new FreightDataset(); freight.Merge(ds, false, MissingSchemaAction.Ignore); shipment = new InboundShipment(freight.InboundFreightTable[0]); } } } catch (Exception ex) { throw new FaultException <TsortFault>(new TsortFault(ex.Message), "Service Error"); } return(shipment); }
public StationAssignment(FreightDataset.StationFreightAssignmentTableRow assignment) { //Constructor this.mWorkStation = new Workstation(); this.mWorkStation.WorkStationID = assignment.WorkStationID; this.mWorkStation.Number = assignment.StationNumber; this.mInboundFreight = new InboundShipment(); this.mInboundFreight.FreightID = assignment.FreightID; this.mInboundFreight.FreightType = assignment.FreightType; this.mInboundFreight.TDSNumber = assignment.TDSNumber; this.mInboundFreight.TrailerNumber = assignment.TrailerNumber; this.mInboundFreight.ClientNumber = assignment.Client; this.mInboundFreight.ShipperNumber = assignment.Shipper; this.mInboundFreight.Pickup = assignment.Pickup; this.mInboundFreight.TerminalID = assignment.TerminalID; this.mSortTypeID = assignment.SortTypeID; this.mSortType = assignment.SortType; }
public bool StopSort(InboundShipment shipment) { // bool stopped = false; try { //Shipment status = 'sorting' and no station assignments InboundShipment _shipment = GetInboundShipment(shipment.TerminalID, shipment.FreightID); if (_shipment == null) { throw new ApplicationException("Inbound shipment " + shipment.FreightID + " could not be found."); } if (_shipment.Status.ToLower() != "sorting") { throw new ApplicationException("Inbound shipment " + shipment.FreightID + " is currently not sorting."); } FreightDataset _assignments = new FreightDataset(); _assignments.Merge(GetStationAssignments(shipment.TerminalID)); if (_assignments.StationFreightAssignmentTable.Rows.Count > 0) { if (_assignments.StationFreightAssignmentTable.Select("FreightID = '" + shipment.FreightID + "'").Length > 0) { throw new ApplicationException("Inbound shipment " + shipment.FreightID + " currently has station assignments."); } } //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()) { // if (shipment.TerminalID > 0) { stopped = new TsortGateway(shipment.TerminalID).StopSort(shipment.FreightID, DateTime.Now); } //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 <TsortFault>(new TsortFault(ex.Message), "Service Error"); } return(stopped); }
private bool unassignFreight() { //Unassign one or more station assignments bool bOK = true; this.Cursor = Cursors.WaitCursor; try { foreach (TsortDataset.StationFreightAssignmentTableRow row in this.mAssignmentsDS.StationFreightAssignmentTable.Rows) { Workstation station = new Workstation(); station.TerminalID = row.TerminalID; station.WorkStationID = row.WorkStationID; station.Number = row.StationNumber; InboundShipment shipment = new InboundShipment(); shipment.TerminalID = row.TerminalID; shipment.FreightID = row.FreightID; shipment.TDSNumber = row.TDSNumber; shipment.ClientNumber = shipment.ClientName = row.Client; StationAssignment assignment = new StationAssignment(); assignment.SortStation = station; assignment.InboundFreight = shipment; assignment.SortTypeID = row.SortTypeID; bool deleted = false; try { deleted = TsortGateway.DeleteStationAssignment(assignment, "Unassigned"); } catch (ApplicationException ex) { App.ReportError(ex, true, LogLevel.Error); } catch (Exception ex) { App.ReportError(new ApplicationException("Failed to unassign freight " + row.FreightID + " from station " + row.WorkStationID + " (sorttypeID= " + row.SortTypeID.ToString() + ").", ex), true, LogLevel.Error); } if (!deleted) { bOK = false; } row.Result = (!deleted) ? EX_RESULT_FAILED : EX_RESULT_OK; this.grdAssignments.Refresh(); Application.DoEvents(); } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } return(bOK); }