Exemple #1
0
        private List <Servico> GetServicosSearchBar(string search)
        {
            List <Servico> servicos = new List <Servico>();

            try
            {
                NetworkStream stream  = client.GetStream();
                StreamReader  sr      = new StreamReader(stream);
                StreamWriter  sw      = new StreamWriter(stream);
                int           result  = 0;
                string        request = "getServicosSearch/" + search + "/";
                sw.WriteLine(request);
                sw.Flush();
                string   line      = sr.ReadLine();
                string[] resultado = line.Split('/');
                if (resultado[0].Equals("RespostaNumServicos"))
                {
                    result = int.Parse(resultado[1]);
                }

                while (result > 0)
                {
                    string lineServico = sr.ReadLine();
                    servicos.Add(Servico.stringToServico(lineServico));
                    result--;
                }
                return(servicos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        private List <Servico> GetServicos()
        {
            List <Servico> servicos = new List <Servico>();

            try
            {
                NetworkStream stream  = client.GetStream();
                StreamReader  sr      = new StreamReader(stream);
                StreamWriter  sw      = new StreamWriter(stream);
                int           result  = 0;
                string        request = "getServicos/";
                sw.WriteLine(request);
                sw.Flush();
                string recebido = sr.ReadLine();
                Console.WriteLine("recebido " + recebido);
                string[] resultado = recebido.Split('/');
                if (resultado[0].Equals("RespostaNumServicos"))
                {
                    result = int.Parse(resultado[1]);
                }

                while (result > 0)
                {
                    string stringServico = sr.ReadLine();
                    Console.WriteLine("received: " + stringServico + "\n");
                    servicos.Add(Servico.stringToServico(stringServico));
                    result--;
                    Console.WriteLine("Result: " + result + "\n");
                }
                return(servicos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }