Example #1
0
        public string GerarJSON_TempoReal(string sChave, string sCampeonato)
        {
            string json = "[]";

            if (sCampeonato.Equals("BR_A"))
            {
                json = TempoReal.BuscarTempoReal("http://globoesporte.globo.com/futebol/brasileirao-serie-a/", sCampeonato);
            }
            else
            if (sCampeonato.Equals("BR_B"))
            {
                json = TempoReal.BuscarTempoReal("http://globoesporte.globo.com/futebol/brasileirao-serie-b/", sCampeonato);
            }
            else
            {
                json = "[]";
            }



            if (!json.Equals("[]"))
            {
                string sFile = "json_temporeal_" + sCampeonato + ".json";

                // Get the object used to communicate with the server.
                FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp.inaltum.futebol.servicos.ws/WEB/" + sFile);
                request.Method = WebRequestMethods.Ftp.UploadFile;

                // This example assumes the FTP site uses anonymous logon.
                request.Credentials = new NetworkCredential("inaltum", "androidapk1");



                // Copy the contents of the file to the request stream.
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                byte[] fileContents = Encoding.GetEncoding("iso8859-1").GetBytes(json);
                //and now plug that into your example
                try
                {
                    Stream requestStream = request.GetRequestStream();
                    requestStream.Write(fileContents, 0, fileContents.Length);
                    requestStream.Close();
                }
                catch
                {
                }

                request.ContentLength = fileContents.Length;

                FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                response.Close();
                return("( http://inaltum.futebol.servicos.ws/" + sFile + " )Complete status :" + response.StatusDescription);
            }
            else
            {
                return("erro ao gerar dados");
            }
        }
Example #2
0
 public string BuscarTempoReal(string sChave, string sCampeonato)
 {
     if (sCampeonato.Equals("BR_A"))
     {
         return(TempoReal.BuscarTempoReal("http://globoesporte.globo.com/futebol/brasileirao-serie-a/", sCampeonato));
     }
     else
     if (sCampeonato.Equals("BR_B"))
     {
         return(TempoReal.BuscarTempoReal("http://globoesporte.globo.com/futebol/brasileirao-serie-b/", sCampeonato));
     }
     else
     {
         return("[]");
     }
 }