private void Atualizargrid()
        {
            List <claNegocioBackup> lstArquivosDrive = objNegocioBackup.ListarArquivos(LServico);

            grdArquivo.Rows.Clear();
            foreach (claNegocioBackup objLstArquivosDrive in lstArquivosDrive)
            {
                string[] row = new string[]
                {
                    objLstArquivosDrive.fdNomeItem.ToString()
                };
                grdArquivo.Rows.Add(row);
            }
        }
예제 #2
0
        private void cmdDownload_Click(object sender, EventArgs e)
        {
            //testando se o caminho foi configurado
            if (BeckupListo.Properties.Settings.Default.PastaDestinoBackup == "")
            {
                MessageBox.Show("Parametro Pasta de Destino de compactação não preenchido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            if (MessageBox.Show("Deseja baixar todo o diretorio?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                this.Cursor = Cursors.WaitCursor;
                List <claNegocioBackup> lstArquivosDrive = objNegocioBackup.ListarArquivos(LServico);
                foreach (claNegocioBackup objLstArquivosDrive in lstArquivosDrive)
                {
                    try
                    {
                        objNegocioBackup.Download(LServico, objLstArquivosDrive.fdNomeItem.ToString(), BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Arquivo: " + objLstArquivosDrive.fdNomeItem + " Impossivel realizar download", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                this.Cursor = Cursors.Default;
                MessageBox.Show("Concluido!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Sistema Realizará somente download do dia atual!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Cursor = Cursors.WaitCursor;

                //Descobrir Dia Da semana
                DateTime PDiaMes = DateTime.Today;

                switch (PDiaMes.DayOfWeek.ToString())
                {
                case "Segunda-Feira":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Segunda", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;

                case "Terça-Feira":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Terca", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;

                case "Quarta-Feira":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Quarta", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;

                case "Quinta-Feira":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Quinta", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;

                case "Sexta-Feira":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Sexta", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;

                case "Sabado":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Sabado", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;

                case "Domingo":
                    try
                    {
                        objNegocioBackup.Download(LServico, BeckupListo.Properties.Settings.Default.NomeArquivo + "Domingo", BeckupListo.Properties.Settings.Default.PastaDestinoBackup);
                    }
                    catch (Exception)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(" Impossivel realizar download do arquivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    break;
                }
            }
        }