Exemplo n.º 1
0
 private void UpdateBarraArquivosSistema(int tamanho)
 {
     if (this.CompSistemaProgressBarControl.InvokeRequired)
     {
         CompSistemaProgressBarControl.Invoke(new MethodInvoker(delegate
         {
             this.CompSistemaProgressBarControl.Properties.Maximum = tamanho;
             this.CompSistemaProgressBarControl.Properties.Step    = 1;
             this.CompSistemaProgressBarControl.PerformStep();
             this.CompSistemaProgressBarControl.Update();
         }));
     }
 }
Exemplo n.º 2
0
        private bool DownloadArquivos(BackgroundWorker status, string pasta, string subpasta)
        {
            tamanho             = 0;
            subPastaSelecionada = subpasta;
            try
            {
                if (subpasta.Length > 11 && subpasta.Substring(0, 12).Equals("ScriptsSQL/"))
                {
                    if (this.DownloadScriptSQLProgressBarControl.InvokeRequired)
                    {
                        DownloadScriptSQLProgressBarControl.Invoke(new MethodInvoker(delegate
                        {
                            this.DownloadScriptSQLProgressBarControl.EditValue = 0;
                            this.DownloadScriptSQLProgressBarControl.Update();
                        }));
                    }
                }
                else if (subpasta.Equals("Sistema"))
                {
                    if (this.CompSistemaProgressBarControl.InvokeRequired)
                    {
                        CompSistemaProgressBarControl.Invoke(new MethodInvoker(delegate
                        {
                            this.CompSistemaProgressBarControl.EditValue = 0;
                            this.CompSistemaProgressBarControl.Update();
                        }));
                    }
                }
                else if (subpasta.Equals("DevExpress") ||
                         subpasta.Equals("postgres/93") ||
                         subpasta.Equals("pt-br"))
                {
                    if (this.CompExternoProgressBarControl.InvokeRequired)
                    {
                        CompExternoProgressBarControl.Invoke(new MethodInvoker(delegate
                        {
                            this.CompExternoProgressBarControl.EditValue = 0;
                            this.CompExternoProgressBarControl.Update();
                        }));
                    }
                }

                if (ftp.DirectoryExists("/" + subpasta))
                {
                    ftp.SetCurrentDirectory("/" + subpasta);
                }

                var dir = ftp.GetCurrentDirectoryInfo();
                tamanho = dir.GetFiles().Length;

                foreach (var file in dir.GetFiles())
                {
                    if (!File.Exists(pasta + file.Name) || subpasta.Equals("ScriptsSQL"))
                    {
                        SetText("[" + file.Name + "]");
                        ftp.GetFile("/" + subpasta + "/" + file.Name, pasta + file.Name, false);
                    }
                    else
                    {
                        long     size  = TamanhoArquivoServidor(subpasta, file.Name);
                        FileInfo f     = new FileInfo(pasta + file.Name);
                        long     size2 = f.Length;

                        //COMPARAR ARQUIVOS DO SERVIDOR/ARQUIVOS LOCAIS
                        if (size != size2)
                        {
                            SetText("[" + file.Name + "]");
                            ftp.GetFile("/" + subpasta + "/" + file.Name, pasta + file.Name, false);
                        }
                        else
                        {
                            if (subpasta.Length > 11 && subpasta.Substring(0, 12).Equals("ScriptsSQL/"))
                            {
                                DownloadScriptSQLProgressBarControl.Invoke(new MethodInvoker(delegate
                                {
                                    this.DownloadScriptSQLProgressBarControl.Properties.Maximum = tamanho;
                                }));
                            }
                            else if (subpasta.Equals("Sistema"))
                            {
                                CompSistemaProgressBarControl.Invoke(new MethodInvoker(delegate
                                {
                                    this.CompSistemaProgressBarControl.Properties.Maximum = tamanho;
                                }));
                            }
                            else if (subpasta.Equals("DevExpress") ||
                                     subpasta.Equals("postgres/93") ||
                                     subpasta.Equals("pt-br"))
                            {
                                if (this.CompExternoProgressBarControl.InvokeRequired)
                                {
                                    CompExternoProgressBarControl.Invoke(new MethodInvoker(delegate
                                    {
                                        this.CompExternoProgressBarControl.Properties.Maximum = tamanho;
                                    }));
                                }
                            }
                        }

                        if (subpasta.Equals("Sistema"))
                        {
                            UpdateBarraArquivosSistema(tamanho);
                        }
                        else if (subpasta.Length > 11 && subpasta.Substring(0, 12).Equals("ScriptsSQL/1"))
                        {
                            UpdateBarraArquivosDownloadScripts(tamanho);
                        }
                        else if (subpasta.Equals("DevExpress") ||
                                 subpasta.Equals("postgres/93") ||
                                 subpasta.Equals("pt-br"))
                        {
                            UpdateBarraArquivosExternos(tamanho);
                        }

                        SetText("");
                    }
                }
            }
            catch
            {
                MessageBox.Show("O Sistema identificou que a conexão com o servidor não foi possível. Por favor, tente mais tarde.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            return(true);
        }