Beispiel #1
0
 public override void ShowDocumentsAction()
 {
     try
     {
         AgenteInfo     agent = AgenteInfo.Get(ActiveItem.TipoEntidad, ActiveItem);
         AgenteEditForm form  = new AgenteEditForm(ActiveItem.TipoEntidad, ActiveItem, this);
         AddForm(form);
     }
     catch
     {
         AgenteAddForm form = new AgenteAddForm(ActiveItem.TipoEntidad, ActiveItem, this);
         AddForm(form);
     }
 }
        /// <summary>
        /// Copia los atributos del objeto
        /// </summary>
        /// <param name="source">Objeto origen</param>
        protected void CopyValues(IncidenciaInfo source)
        {
            if (source == null)
            {
                return;
            }


            AgenteInfo agente = AgenteInfo.Get(OidAgente, false);

            if (agente != null)
            {
                _base.Agente = agente.Nombre;
            }
        }
Beispiel #3
0
 public override void ShowDocumentsAction()
 {
     try
     {
         AgenteInfo     agent = AgenteInfo.Get(ActiveItem.TipoEntidad, ActiveItem);
         AgenteEditForm form  = new AgenteEditForm(ActiveItem.TipoEntidad, ActiveItem, this);
         AddForm(form);
     }
     catch (HipatiaException ex)
     {
         if (ex.Code == HipatiaCode.NO_AGENTE)
         {
             AgenteAddForm form = new AgenteAddForm(ActiveItem.TipoEntidad, ActiveItem, this);
             AddForm(form);
         }
     }
 }
        public override void ShowDocumentsAction()
        {
            switch (ActiveItem.ETipoAcreedor)
            {
            case ETipoAcreedor.Acreedor:
            case ETipoAcreedor.Proveedor:
            {
                ProveedorInfo agente = ProveedorInfo.Get(ActiveItem.Oid, ActiveItem.ETipoAcreedor, false);

                try
                {
                    AgenteInfo     agent = AgenteInfo.Get(typeof(Proveedor), agente);
                    AgenteEditForm form  = new AgenteEditForm(typeof(Proveedor), agente, this);
                    AddForm(form);
                }
                catch (HipatiaException ex)
                {
                    if (ex.Code == HipatiaCode.NO_AGENTE)
                    {
                        AgenteAddForm form = new AgenteAddForm(typeof(Proveedor), agente, this);
                        AddForm(form);
                    }
                }
            }
            break;

            case ETipoAcreedor.Naviera:
            {
                NavieraInfo agente = NavieraInfo.Get(ActiveItem.Oid, false);

                try
                {
                    AgenteInfo     agent = AgenteInfo.Get(typeof(Naviera), agente);
                    AgenteEditForm form  = new AgenteEditForm(typeof(Naviera), agente, this);
                    AddForm(form);
                }
                catch (HipatiaException ex)
                {
                    if (ex.Code == HipatiaCode.NO_AGENTE)
                    {
                        AgenteAddForm form = new AgenteAddForm(typeof(Naviera), agente, this);
                        AddForm(form);
                    }
                }
            }
            break;

            case ETipoAcreedor.Despachante:
            {
                DespachanteInfo agente = DespachanteInfo.Get(ActiveItem.Oid, false);

                try
                {
                    AgenteInfo     agent = AgenteInfo.Get(typeof(Despachante), agente);
                    AgenteEditForm form  = new AgenteEditForm(typeof(Despachante), agente, this);
                    AddForm(form);
                }
                catch (HipatiaException ex)
                {
                    if (ex.Code == HipatiaCode.NO_AGENTE)
                    {
                        AgenteAddForm form = new AgenteAddForm(typeof(Despachante), agente, this);
                        AddForm(form);
                    }
                }
            }
            break;

            case ETipoAcreedor.TransportistaOrigen:
            case ETipoAcreedor.TransportistaDestino:
            {
                TransporterInfo agente = TransporterInfo.Get(ActiveItem.Oid, ActiveItem.ETipoAcreedor, false);

                try
                {
                    AgenteInfo     agent = AgenteInfo.Get(typeof(Transporter), agente);
                    AgenteEditForm form  = new AgenteEditForm(typeof(Transporter), agente, this);
                    AddForm(form);
                }
                catch (HipatiaException ex)
                {
                    if (ex.Code == HipatiaCode.NO_AGENTE)
                    {
                        AgenteAddForm form = new AgenteAddForm(typeof(Transporter), agente, this);
                        AddForm(form);
                    }
                }
            }
            break;
            }
        }
        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();
        }
 protected override void GetFormSourceData(long oid)
 {
     _entity = AgenteInfo.Get(oid, true);
 }