예제 #1
0
        public static void RefreshZones(bool assignableOnly)
        {
            //Update a collection (dataset) of all open TLs for the terminal on the local LAN database
            ZoneClosingServiceClient client = new ZoneClosingServiceClient();

            try {
                _Zones.Clear();
                if (assignableOnly)
                {
                    _Zones.Merge(client.GetUnassignedTLs(int.Parse(Program.TerminalCode)));
                }
                else
                {
                    _Zones.Merge(client.GetTLs(int.Parse(Program.TerminalCode)));
                }
                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); }
            finally { if (ZonesChanged != null)
                      {
                          ZonesChanged(null, EventArgs.Empty);
                      }
            }
        }
예제 #2
0
        public static FreightDataset GetTerminals()
        {
            //Returns a list of terminals
            FreightDataset         terminals = new FreightDataset();
            TLViewerService2Client client    = new TLViewerService2Client();

            try {
                DataSet ds = client.GetTerminals2();
                if (ds != null && ds.Tables["TerminalTable"] != null && ds.Tables["TerminalTable"].Rows.Count > 0)
                {
                    if (Program.TerminalCode.Length > 0)
                    {
                        terminals.Merge(ds.Tables["TerminalTable"].Select("TerminalID=" + Program.TerminalCode));
                    }
                    else
                    {
                        terminals.Merge(ds);
                    }
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message, te); }
            catch (FaultException <TLViewerFault> tle) { client.Abort(); throw new ApplicationException(tle.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message, fe); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message, ce); }
            return(terminals);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public static FreightDataset ViewLTLClients()
        {
            FreightDataset         clients = new FreightDataset();
            LTLAdminService2Client client  = new LTLAdminService2Client();

            try {
                DataSet ds = client.ViewLTLClientsForAdmin();
                if (ds != null && ds.Tables["LTLClientTable"] != null && ds.Tables["LTLClientTable"].Rows.Count > 0)
                {
                    clients.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> 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(clients);
        }
예제 #5
0
        public static FreightDataset ReadLTLConsigneesList(string clientNumber)
        {
            FreightDataset         consignees = new FreightDataset();
            LTLAdminService2Client client     = new LTLAdminService2Client();

            try {
                DataSet ds = client.ReadLTLConsigneesListForAdmin(clientNumber);
                if (ds != null && ds.Tables["LTLConsigneeTable"] != null && ds.Tables["LTLConsigneeTable"].Rows.Count > 0)
                {
                    consignees.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> 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(consignees);
        }
예제 #6
0
        public static FreightDataset ReadPalletLabels(string shipmentNumber)
        {
            FreightDataset         labels = new FreightDataset();
            LTLAdminService2Client client = new LTLAdminService2Client();

            try {
                DataSet ds = client.ReadPalletLabels(shipmentNumber);
                if (ds != null && ds.Tables["LTLPalletLabelTable"].Rows.Count > 0)
                {
                    labels.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> 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(labels);
        }
예제 #7
0
        public static FreightDataset GetLanes()
        {
            //
            FreightDataset           lanes  = new FreightDataset();
            ZoneClosingServiceClient client = new ZoneClosingServiceClient();

            try {
                DataSet ds = client.GetLanes(int.Parse(Program.TerminalCode));
                if (ds != null)
                {
                    lanes.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(lanes);
        }
예제 #8
0
        public DataSet GetUnassignedClosedTLs(int terminalID, int closedDays)
        {
            //
            DataSet tls = new DataSet();

            try {
                if (terminalID > 0)
                {
                    DataSet        ds   = new TsortGateway(terminalID).GetUnassignedClosedTLs(closedDays);
                    FreightDataset _tls = new FreightDataset();
                    _tls.Merge(ds);
                    if (_tls.ZoneTable.Rows.Count > 0)
                    {
                        tls.Merge(_tls);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TsortFault>(new TsortFault(ex.Message), "Service Error"); }
            return(tls);
        }
예제 #9
0
        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);
        }
예제 #10
0
        public static FreightDataset ViewLTLShipments(string clientNumber)
        {
            //View all LTL shipments for the specified client
            FreightDataset         shipments = new FreightDataset();
            LTLAdminService2Client client    = new LTLAdminService2Client();

            try {
                DataSet ds = client.ViewLTLShipmentsForDispatch(clientNumber);
                if (ds != null && ds.Tables["LTLShipmentTable"] != null && ds.Tables["LTLShipmentTable"].Rows.Count > 0)
                {
                    shipments.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> 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(shipments);
        }
예제 #11
0
        public DataSet GetLanes(int terminalID)
        {
            //Get lists of all sort/small sort lanes for this terminal
            DataSet lanes = new DataSet();

            try {
                if (terminalID > 0)
                {
                    DataSet        ds     = new TsortGateway(terminalID).GetLanes();
                    FreightDataset _lanes = new FreightDataset();
                    _lanes.Merge(ds);
                    if (_lanes.LaneTable.Rows.Count > 0)
                    {
                        lanes.Merge(_lanes);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TsortFault>(new TsortFault(ex.Message), "Service Error"); }
            return(lanes);
        }
예제 #12
0
        public static FreightDataset GetAgentSummary(int terminalID)
        {
            //Get an agent summary view for the specified terminal
            FreightDataset         tls    = new FreightDataset();
            TLViewerService2Client client = new TLViewerService2Client();

            try {
                DataSet ds = client.GetAgentSummary2(terminalID);
                if (ds != null && ds.Tables["TLTable"] != null && ds.Tables["TLTable"].Rows.Count > 0)
                {
                    tls.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message, te); }
            catch (FaultException <TLViewerFault> tle) { client.Abort(); throw new ApplicationException(tle.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message, fe); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message, ce); }
            return(tls);
        }
예제 #13
0
        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);
        }
예제 #14
0
        public FreightDataset GetInboundFreight(int terminalID, string freightType)
        {
            FreightDataset             shipments = new FreightDataset();
            FreightAssignServiceClient client    = new FreightAssignServiceClient();

            try {
                DataSet ds = client.GetInboundFreight(terminalID, DateTime.Today.AddDays(-this.mSortedDays));
                if (ds != null)
                {
                    FreightDataset _shipments = new FreightDataset();
                    _shipments.Merge(ds);
                    shipments.Merge(_shipments.InboundFreightTable.Select("FreightType='" + freightType + "'", "TDSNumber ASC"));
                }
                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(shipments);
        }
예제 #15
0
        public TLs GetAgentSummary(int terminalID)
        {
            //Get an agent summary view for the specified terminal
            TLs tls = null;

            try {
                tls = new TLs();
                DataSet ds = new TLViewerGateway().GetAgentSummary(terminalID);
                if (ds != null)
                {
                    FreightDataset tlDS = new FreightDataset();
                    tlDS.Merge(ds);
                    for (int i = 0; i < tlDS.TLTable.Rows.Count; i++)
                    {
                        TL tl = new TL(tlDS.TLTable[i]);
                        tls.Add(tl);
                    }
                }
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(tls);
        }
예제 #16
0
        public TLs GetTLDetail(int terminalID, string tlNumber)
        {
            //Get TL detail for the specified TL#
            TLs tls = null;

            try {
                tls = new TLs();
                DataSet ds = new TLViewerGateway().GetTLDetail(terminalID, tlNumber);
                if (ds != null)
                {
                    FreightDataset tlDS = new FreightDataset();
                    tlDS.Merge(ds);
                    for (int i = 0; i < tlDS.TLTable.Rows.Count; i++)
                    {
                        TL tl = new TL(tlDS.TLTable[i]);
                        tls.Add(tl);
                    }
                }
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(tls);
        }
예제 #17
0
        public static FreightDataset ReadLTLClientList(bool addAll = false)
        {
            FreightDataset         clients = new FreightDataset();
            LTLAdminService2Client client  = new LTLAdminService2Client();

            try {
                if (addAll)
                {
                    clients.LTLClientTable.AddLTLClientTableRow(0, "", "All", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", DateTime.Today, "", DateTime.Today, "", 0, DateTime.Today, "", "");
                }
                DataSet ds = client.ReadLTLClientListForAdmin();
                if (ds != null && ds.Tables["LTLClientTable"] != null && ds.Tables["LTLClientTable"].Rows.Count > 0)
                {
                    clients.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> 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(clients);
        }
예제 #18
0
        public static FreightDataset GetTLView(int terminalID)
        {
            //Get a view of TLs for the opertaing terminal
            FreightDataset         tls    = new FreightDataset();
            TLViewerService2Client client = new TLViewerService2Client();

            try {
                DataSet ds = client.GetTLView2(terminalID);
                if (ds != null && ds.Tables["TLTable"] != null && ds.Tables["TLTable"].Rows.Count > 0)
                {
                    tls.Merge(ds);
                    for (int i = 0; i < tls.TLTable.Rows.Count; i++)
                    {
                        tls.TLTable[i].TerminalID = terminalID;
                    }
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message, te); }
            catch (FaultException <TLViewerFault> tle) { client.Abort(); throw new ApplicationException(tle.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message, fe); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message, ce); }
            return(tls);
        }