Example #1
0
        public string[] Obu1_ActiveVehicles([FromBody] string address)
        {
            MySqlConnection conn = new MySqlConnection(connStr);

            try
            {
                conn.Open();

                if (string.IsNullOrEmpty(address))
                {
                    address = "http://127.0.0.1:8080/TRAAS_WS"; //default address
                }
                TraasReference.ServiceImplClient client = new TraasReference.ServiceImplClient();
                client.Endpoint.Address = new EndpointAddress(address);

                try
                {
                    client.Open();
                    string[] vehicleIDList = client.Vehicle_getIDList();
                    return(vehicleIDList);
                }
                catch (FaultException e)
                {
                    client.Abort();
                    throw new FaultException(e.Message);
                }
                catch (Exception e)
                {
                    throw new FaultException(e.InnerException.ToString());
                }
                finally
                {
                    client.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                conn.Close();
            }
            throw new Exception("Napaka!");
        }
Example #2
0
        private bool isVehicleActive(string address, string vehID)
        {
            if (string.IsNullOrEmpty(address))
            {
                address = "http://127.0.0.1:8080/TRAAS_WS"; //default address
            }
            TraasReference.ServiceImplClient client = new TraasReference.ServiceImplClient();
            client.Endpoint.Address = new EndpointAddress(address);

            try
            {
                client.Open();
                string[] vehicleIDList = client.Vehicle_getIDList();
                foreach (string searchedID in vehicleIDList)
                {
                    if (searchedID == vehID)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (FaultException e)
            {
                client.Abort();
                throw new FaultException(e.Message);
            }
            catch (Exception e)
            {
                throw new FaultException(e.InnerException.ToString());
            }
            finally
            {
                client.Close();
            }
        }