public AbaAtualizar() { AtualizarModel = new AtualizarModel(); Status = new Status(); IsVisibleButtonPausar = false; IsEnableButtonAtualizar = true; BotaoBloquear = Visibility.Hidden; BotaoDesbloquear = Visibility.Visible; }
public byte[] Download(string path, MainWindowViewModel mainwindowviewmodel) { MainWindowViewModel = mainwindowviewmodel; AtualizarModel = MainWindowViewModel.AbaAtualizar.AtualizarModel; byte[] buffer = new byte[32 * 1024]; int read; try { GetFileSize(path); HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default); HttpWebRequest.DefaultCachePolicy = policy; HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + Url + "/" + path); request.Credentials = new NetworkCredential(Usuario, Senha); request.Method = WebRequestMethods.Ftp.DownloadFile; request.CachePolicy = noCachePolicy; using (MemoryStream ms = new MemoryStream()) { Stream ftpStream = request.GetResponse().GetResponseStream(); var Progresso = 0; while ((read = ftpStream.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); Progresso += read; var Porcentagem = ((double)Progresso / FileSize) * 100; if (Porcentagem > 100) { MainWindowViewModel.AbaAtualizar.Status.StatusLabel.LabelContent = "Finalizando o download..."; } else { MainWindowViewModel.AbaAtualizar.Status.BarraProgresso.ProgressoBarra1 = Porcentagem; MainWindowViewModel.AbaAtualizar.Status.StatusLabel.LabelContent = "Baixando aquivos... ( " + (Porcentagem / 100).ToString("P1") + " )"; } } return(ms.ToArray()); } } catch (Exception e) { log.Error(e); } return(buffer); }
public Task <HttpResponseMessage> Put([FromUri] Guid?id, [FromBody] AtualizarModel parametros) { InvocarSeNulo <AtualizarModel>(ref parametros); parametros.Id = id; Usuario resultado = null; if (this.EhValido()) { resultado = this._appUsuario.Atualizar(parametros); this.Validar(this._appUsuario); } return(CriarRespostaTask(HttpStatusCode.OK)); }
public AbaAtualizacao() { AtualizarModel = new AtualizarModel(); IsVisibleButtonPausar = false; IsEnableButtonAtualizar = true; BotaoBloquear = false; BotaoDesbloquear = true; //--Barras de progresso IsEnabledBarras = false; IsVisibleBarras = false; ProgressoBarra1 = 0; ProgressoBarra2 = 0; IsIndeterminateBarra1 = false; //--Label LabelContent = ""; LabelPadding = new Padding(0, 25, 0, 0); }