Esempio n. 1
0
        private void frmJunoSistema_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;

            if (JunoSystem.Properties.Settings.Default.GoogleDriveOption != "")
            {
                LGoogleDriveOption = JunoSystem.Properties.Settings.Default.GoogleDriveOption.ToString();
            }

            if (LGoogleDriveOption != "0")
            {
                ServiceDriveAPI objDriveApi = new ServiceDriveAPI();

                //Seach Credenciais
                LCredenciais = objDriveApi.Autenticar();

                //OpenService
                LServico = objDriveApi.AbrirServico(LCredenciais);

                if (LCredenciais == null || LServico == null)
                {
                    lblStatus.Text = "Connected";
                }
            }
        }
Esempio n. 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            ServiceDriveAPI objDriveApi = new ServiceDriveAPI();

            if (LGoogleDriveOption != "0")
            {
                //Download to perform database synchronization
                objDriveApi.Download(LServico, "Juno.csv", "C:\\JunoRadio\\juno.csv");
                if (objDriveApi.msgErro == "Nenhum Registro")
                {
                    return;
                }
            }

            if (JunoSystem.Properties.Settings.Default.GoogleDriveOption.ToString() != "")
            {
                bool SSL = false;

                if (JunoSystem.Properties.Settings.Default.SSL.ToString() == "1")
                {
                    SSL = true;
                }

                Downloadattachment(JunoSystem.Properties.Settings.Default.Server.ToString(),
                                   Convert.ToInt32(JunoSystem.Properties.Settings.Default.Port.ToString()),
                                   JunoSystem.Properties.Settings.Default.Email.ToString(),
                                   JunoSystem.Properties.Settings.Default.Password.ToString(),
                                   SSL);
            }

            //Create List
            List <Importacao> lstImportacao = new List <Importacao>();

            string[] PLinhas;             try
            {
                PLinhas = File.ReadAllLines("C:\\JunoRadio\\Juno.csv");
            }
            catch (Exception)
            {
                MessageBox.Show("Error downloading data from Nasa servers");
                return;
            }

            try
            {
                string[] PCamposLinha;
                foreach (string UmaLinha in PLinhas)
                {
                    if (UmaLinha == "latitude,longitude,brightness,scan,track,acq_date,acq_time,satellite,confidence,version,bright_t31,frp,day_night")
                    {
                        continue;
                    }

                    if (UmaLinha.Replace(" ", "").Length == 0)
                    {
                        continue;
                    }
                    PCamposLinha = UmaLinha.Split(',');

                    PCamposLinha[0] = PCamposLinha[0].Trim();

                    string Sql = "INSERT INTO Importacao (Long, Lat, Brilho) ";
                    Sql = Sql + "VALUES(" + PCamposLinha[0].ToString() + ", " + PCamposLinha[1].ToString() + ", " + PCamposLinha[2].ToString() + ")";

                    Conexoes objConexoes = new Conexoes();
                    objConexoes.ExecutaComando(Sql);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading file.\n" + ex.Message, "Juno", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            finally
            {
                DateTime objData   = new DateTime();
                string   PDataHora = objData.Day.ToString() + "-" + objData.Month.ToString() + "-" + objData.Hour.ToString() + "-" + objData.Minute.ToString();

                if (LGoogleDriveOption != "0")
                {
                    //download and Synchronization with database
                    objDriveApi.DeletarItem(LServico, "Juno.csv");
                }
                System.IO.File.Delete("C:\\JunoRadio\\Juno.csv");
            }
        }