示例#1
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);
        }
示例#2
0
        public TerminalDataset GetTerminals(int terminalID)
        {
            //Returns a list of terminals
            TerminalDataset        terminals = new TerminalDataset();
            TLViewerService2Client client    = new TLViewerService2Client();

            try {
                DataSet ds = client.GetTerminals2();
                if (ds != null)
                {
                    TerminalDataset ts = new TerminalDataset();
                    ts.Merge(ds);
                    for (int i = 0; i < ts.TerminalTable.Rows.Count; i++)
                    {
                        TerminalDataset.TerminalTableRow t = ts.TerminalTable[i];
                        if (terminalID == 0 || t.TerminalID == terminalID)
                        {
                            terminals.TerminalTable.LoadDataRow(t.ItemArray, true);
                        }
                    }
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <TLViewerFault> tle) { client.Abort(); throw new ApplicationException(tle.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(terminals);
        }