private void DoUpload(BackgroundWorker bk) { PgMng.Grow(Resources.Messages.CONNECTING_SERVER); if (_ftp == null) { _ftp = new FtpClient(Principal.GetHipatiaFTPHost(), Principal.GetHipatiaFTPUser(), Principal.GetHipatiaFTPPwd(), Principal.GetHipatiaFTPRootPath()); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); } PgMng.Grow(); if (HipatiaCtl.ExistsDirectory(_ftp, CurrentDocumento.Ruta)) { PgMng.Message = Resources.Messages.UPLOADING_FILE; PgMng.Grow(); HipatiaCtl.Copy(_ftp, TempFile, CurrentDocumento.Ruta); PgMng.Message = Resources.Messages.CLOSING_SERVER; PgMng.Grow(); PgMng.Result = BGResult.OK; } else { PgMng.Result = BGResult.Error; throw new iQException(Resources.Messages.OPERATION_ERROR); } }
private void DoDownload(BackgroundWorker bk) { PgMng.Grow(Resources.Messages.CONNECTING_SERVER); if (_ftp == null) { _ftp = new FtpClient(Principal.GetHipatiaFTPHost(), Principal.GetHipatiaFTPUser(), Principal.GetHipatiaFTPPwd(), Principal.GetHipatiaFTPRootPath()); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); } PgMng.Grow(); if (HipatiaCtl.ExistsDirectory(_ftp, CurrentDocumento.Ruta)) { PgMng.Message = Resources.Messages.DOWNLOADING_FILE; PgMng.Grow(); _ftp.DownloadFile(Path.GetDirectoryName(CurrentDocumento.Ruta), DestinationPath, Path.GetFileName(CurrentDocumento.Nombre)); PgMng.Message = Resources.Messages.CLOSING_SERVER; PgMng.Grow(); PgMng.Result = BGResult.OK; } else { PgMng.Result = BGResult.Error; throw new iQException(Resources.Errors.FILE_NOT_FOUND); } }
public override void DownloadAction() { PgMng.Reset(5, 1, Resources.Messages.CONNECTING_SERVER, this); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); PgMng.Grow(); if (HipatiaCtl.ExistsDirectory(_ftp, ActiveItem.Ruta)) { if (Browser.ShowDialog() == DialogResult.OK) { string destinationPath = Browser.SelectedPath; string tempFile = destinationPath + "\\" + System.Web.HttpUtility.UrlEncode(ActiveItem.Nombre); PgMng.Message = Resources.Messages.DOWNLOADING_FILE; PgMng.Grow(); _ftp.DownloadFile(Path.GetDirectoryName(ActiveItem.Ruta), destinationPath, Path.GetFileName(ActiveItem.Nombre)); PgMng.Message = Resources.Messages.CLOSING_SERVER; PgMng.Grow(); PgMng.Result = BGResult.OK; } } else { PgMng.Result = BGResult.Error; throw new iQException(Resources.Errors.FILE_NOT_FOUND); } PgMng.FillUp(); }
public override void DeleteObject(long oid) { if (ProgressInfoMng.ShowQuestion(moleQule.Face.Resources.Messages.DELETE_CONFIRM) == DialogResult.Yes) { if (ActiveItem.Shared) { if (ProgressInfoMng.ShowQuestion(Resources.Messages.DOC_SHARED) != DialogResult.OK) { _action_result = DialogResult.Cancel; return; } } try { PgMng.Reset(5, 1, Resources.Messages.CONNECTING_SERVER, this); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); PgMng.Grow(moleQule.Face.Resources.Messages.DELETING); Documento item = Documento.Get(ActiveItem.OidDocumento); item.AgenteDocumentos.Clear(); item.Save(); item.CloseSession(); PgMng.Grow(); Documento.Delete(ActiveItem.OidDocumento); PgMng.Grow(); if (HipatiaCtl.ExistsFile(_ftp, ActiveItem.Ruta)) { _ftp.DeleteFile(ActiveItem.Ruta); } PgMng.Grow(); } catch (Exception ex) { _action_result = DialogResult.Cancel; throw ex; } finally { PgMng.FillUp(); } _action_result = DialogResult.OK; } }
public override void OpenViewForm() { try { string destinationPath = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string tempFile = destinationPath + "\\" + System.Web.HttpUtility.UrlEncode(ActiveItem.Nombre); PgMng.Reset(5, 1, Resources.Messages.CONNECTING_SERVER, this); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); PgMng.Grow(); if (HipatiaCtl.ExistsFile(_ftp, ActiveItem.Ruta)) { PgMng.Grow(Resources.Messages.DOWNLOADING_FILE); _ftp.DownloadFile(Path.GetDirectoryName(ActiveItem.Ruta), destinationPath, Path.GetFileName(ActiveItem.Nombre)); PgMng.Grow(Resources.Messages.CLOSING_SERVER); if (File.Exists(tempFile)) { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = tempFile; process.Start(); PgMng.FillUp(); process.WaitForExit(); File.Delete(tempFile); } else { PgMng.ShowInfoException(Resources.Errors.FILE_NOT_FOUND); } } else { PgMng.Result = BGResult.Error; PgMng.ShowInfoException(Resources.Errors.FILE_NOT_FOUND); } } finally { PgMng.FillUp(); } }
private void Aplicar_BT_Click(object sender, EventArgs e) { PgMng.Reset(BarSteps, 1); if (_ftp == null) { _ftp = new FtpClient(Principal.GetHipatiaFTPHost(), Principal.GetHipatiaFTPUser(), Principal.GetHipatiaFTPPwd(), Principal.GetHipatiaFTPRootPath()); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); } if (!HipatiaCtl.ExistsAgentDirectory(_ftp, _entity.GetInfo(false))) { HipatiaCtl.CreateAgentDirectory(_ftp, _entity.GetInfo(false)); } //_ftp.Close(); _action_result = SaveObject() ? DialogResult.OK : DialogResult.Ignore; PgMng.FillUp(); }
private void DoDelete(BackgroundWorker bk) { PgMng.Grow(Resources.Messages.CONNECTING_SERVER); if (_ftp == null) { _ftp = new FtpClient(Principal.GetHipatiaFTPHost(), Principal.GetHipatiaFTPUser(), Principal.GetHipatiaFTPPwd(), Principal.GetHipatiaFTPRootPath()); HipatiaCtl.InitHipatia(_ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); } PgMng.Grow(); _entity.Documentos.RemoveAgent(CurrentDocumento); PgMng.Grow(); if (CurrentDocumento.AgenteDocumentos.Count == 1) { if (ProgressInfoMng.ShowQuestion(Resources.Messages.DELETE_LAST_FILE) == DialogResult.No) { try { Documento.Delete(CurrentDocumento.OidDocumento); PgMng.Grow(); if (HipatiaCtl.ExistsFile(_ftp, CurrentDocumento.Ruta)) { _ftp.DeleteFile(CurrentDocumento.Ruta); } PgMng.Grow(); } catch (Exception ex) { PgMng.Result = BGResult.Error; throw ex; } } } PgMng.Result = BGResult.OK; }
private void DoUpdate() { PgMng.Result = BGResult.OK; PgMng.Message = Resources.Messages.CONNECTING_SERVER; if (Nombre_TB.Text == string.Empty) { throw new iQException(Resources.Messages.NO_NAME); } PgMng.Grow(); if (_doc != null) { //Los nombres de los ficheros deben coincidir if (_doc.Nombre != Nombre_TB.Text) { throw new iQException(Resources.Messages.NOT_EQUAL_DOC_NAME); } } else if (HipatiaCtl.CheckDuplicate(_agente, _entity)) { throw new iQException(Resources.Messages.DOC_REPEATED); } PgMng.Grow(); FtpClient ftp = new FtpClient(Principal.GetHipatiaFTPHost(), Principal.GetHipatiaFTPUser(), Principal.GetHipatiaFTPPwd(), Principal.GetHipatiaFTPRootPath()); HipatiaCtl.InitHipatia(ftp, Principal.GetHipatiaFTPRootPath(), Principal.GetHipatiaFTPHost()); PgMng.Grow(); PgMng.Message = Resources.Messages.UPLOADING_FILE; AgenteInfo _ag_info = _agente.GetInfo(false); if (!HipatiaCtl.ExistsAgentDirectory(ftp, _ag_info)) { HipatiaCtl.CreateAgentDirectory(ftp, _ag_info); } PgMng.Grow(); try { //Estamos añadiendo uno nuevo if (_doc == null) { if (HipatiaCtl.ExistsFile(ftp, _ag_info, _entity.GetInfo(false))) { if (ProgressInfoMng.ShowQuestion(Resources.Messages.OVERWRITE_FILE) == DialogResult.Yes) { HipatiaCtl.Copy(ftp, _ag_info, _entity.Ruta); } } else { HipatiaCtl.Copy(ftp, _ag_info, _entity.Ruta); } } //Estamos reemplazando uno existente else { HipatiaCtl.ExistsDirectory(ftp, _doc.Ruta); HipatiaCtl.Copy(ftp, _ag_info, _entity.Ruta); } } catch (Exception ex) { PgMng.Result = BGResult.Error; throw new iQException(Resources.Messages.OPERATION_ERROR + Environment.NewLine + ex.Message); } _entity.Ruta = HipatiaCtl.GetAgenteDirectory(ftp, _ag_info) + "/" + _entity.Nombre; PgMng.Grow(); PgMng.Message = Resources.Messages.CLOSING_SERVER; PgMng.Grow(); _entity.ApplyEdit(); _entity.Save(); PgMng.Grow(); }