Esempio n. 1
0
        internal void Update(Agente parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects
            foreach (AgenteDocumento obj in DeletedList)
            {
                try
                {
                    obj.DeleteSelf(parent);
                }
                catch { continue; }
            }

            // now that they are deleted, remove them from memory too
            DeletedList.Clear();

            // add/update any current child objects
            foreach (AgenteDocumento obj in this)
            {
                if (obj.IsNew)
                {
                    obj.Insert(parent);
                }
                else
                {
                    obj.Update(parent);
                }
            }

            this.RaiseListChangedEvents = true;
        }
Esempio n. 2
0
        internal void DeleteSelf(Agente parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            try
            {
                SessionCode = parent.SessionCode;
                Session().Delete(Session().Get <AgentDocumentRecord>(Oid));
            }
            catch (Exception ex)
            {
                throw new iQPersistentException(iQExceptionHandler.GetAllMessages(ex));
            }

            MarkNew();
        }
Esempio n. 3
0
 public static string SELECT(EntidadInfo source)
 {
     return(Agente.SELECT(new QueryConditions()
     {
         Entity = source
     }, true));
 }
Esempio n. 4
0
        internal void CopyValues(Agente source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source.Base.Record);

            _entidad = source.Entidad;
        }
Esempio n. 5
0
        public static AgenteDocumento NewChild(Agente parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(Resources.Messages.USER_NOT_ALLOWED);
            }

            AgenteDocumento obj = new AgenteDocumento();

            obj.OidAgente = parent.Oid;
            return(obj);
        }
Esempio n. 6
0
        public static bool CheckDuplicate(Agente agente, Documento doc)
        {
            DocumentoList documentos = DocumentoList.GetListByAgente(agente);

            foreach (DocumentoInfo obj in documentos)
            {
                if (obj.Nombre.Equals(doc.Nombre) && obj.Oid != doc.Oid)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 7
0
        public static AgenteList GetList(bool childs)
        {
            CriteriaEx criteria = Agente.GetCriteria(Agente.OpenSession());

            criteria.Childs = childs;

            //No criteria. Retrieve all de List
            if (nHManager.Instance.UseDirectSQL)
            {
                criteria.Query = AgenteList.SELECT();
            }

            AgenteList list = DataPortal.Fetch <AgenteList>(criteria);

            CloseSession(criteria.SessionCode);
            return(list);
        }
Esempio n. 8
0
        // called to retrieve data from database
        protected override void Fetch(CriteriaEx criteria)
        {
            this.RaiseListChangedEvents = false;

            SessionCode = criteria.SessionCode;
            Childs      = criteria.Childs;

            try
            {
                if (nHMng.UseDirectSQL)
                {
                    IDataReader reader = nHManager.Instance.SQLNativeSelect(criteria.Query, Session());

                    IsReadOnly = false;

                    while (reader.Read())
                    {
                        this.AddItem(AgenteInfo.Get(SessionCode, reader, Childs));
                    }

                    IsReadOnly = true;

                    if (criteria.PagingInfo != null)
                    {
                        reader = nHManager.Instance.SQLNativeSelect(Agente.SELECT_COUNT(criteria), criteria.Session);
                        if (reader.Read())
                        {
                            criteria.PagingInfo.TotalItems = Format.DataReader.GetInt32(reader, "TOTAL_ROWS");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex, new object[] { criteria.Query });
            }

            this.RaiseListChangedEvents = true;
        }
Esempio n. 9
0
        internal void Insert(Agente parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidAgente = parent.Oid;

            try
            {
                SessionCode = parent.SessionCode;
                parent.Session().Save(Base.Record);
            }
            catch (Exception ex)
            {
                throw new iQPersistentException(iQExceptionHandler.GetAllMessages(ex));
            }

            MarkOld();
        }
Esempio n. 10
0
        //Fetch independiente de DataPortal para generar un Entidad a partir de un IDataReader
        private void Fetch(IDataReader source)
        {
            try
            {
                _base.CopyValues(source);

                if (Childs)
                {
                    if (nHMng.UseDirectSQL)
                    {
                        Agente.DoLOCK(Session());
                        string      query  = Agentes.SELECT(this);
                        IDataReader reader = nHMng.SQLNativeSelect(query, Session());
                        _agentes = Agentes.GetChildList(reader, false);
                    }
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }
        }
Esempio n. 11
0
        internal void Update(Agente parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects

            /* foreach (Entidad obj in DeletedList)
             *   obj.DeleteSelf(parent);
             *
             * // now that they are deleted, remove them from memory too
             * DeletedList.Clear();
             *
             * // add/update any current child objects
             * foreach (Entidad obj in this)
             * {
             *   if (obj.IsNew)
             *       obj.Insert(parent);
             *   else
             *       obj.Update(parent);
             * }*/

            this.RaiseListChangedEvents = true;
        }
Esempio n. 12
0
        private void DataPortal_Fetch(CriteriaEx criteria)
        {
            try
            {
                _base.Record.Oid = 0;
                SessionCode      = criteria.SessionCode;
                Childs           = criteria.Childs;

                if (nHMng.UseDirectSQL)
                {
                    Entidad.DoLOCK(Session());
                    IDataReader reader = nHMng.SQLNativeSelect(criteria.Query, Session());

                    if (reader.Read())
                    {
                        _base.CopyValues(reader);
                    }

                    if (Childs)
                    {
                        Agente.DoLOCK(Session());
                        string query = Agentes.SELECT(this);
                        reader   = nHMng.SQLNativeSelect(query, Session());
                        _agentes = Agentes.GetChildList(reader, false);
                    }
                }
            }
            catch (Exception ex)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                iQExceptionHandler.TreatException(ex, new object[] { criteria.Query });
            }
        }
Esempio n. 13
0
        internal void Update(Agente parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidAgente = parent.Oid;

            try
            {
                SessionCode = parent.SessionCode;
                AgentDocumentRecord obj = Session().Get <AgentDocumentRecord>(Oid);
                obj.CopyValues(Base.Record);
                Session().Update(obj);
            }
            catch (Exception ex)
            {
                throw new iQPersistentException(iQExceptionHandler.GetAllMessages(ex));
            }

            MarkOld();
        }
Esempio n. 14
0
 public Entidad NewItem(Agente parent)
 {
     //this.NewItem(Entidad.NewChild(parent));
     return(this[Count - 1]);
 }
Esempio n. 15
0
 public static string SELECT(QueryConditions conditions)
 {
     return(Agente.SELECT(conditions, true));
 }
Esempio n. 16
0
 public static DocumentoList GetListByAgente(Agente agente)
 {
     return(GetListByAgente(agente.GetInfo(false)));
 }
Esempio n. 17
0
 public static string SELECT(Agente source)
 {
     return(SELECT(new QueryConditions {
         Agent = source.GetInfo(false)
     }));
 }
Esempio n. 18
0
 public AgenteDocumento NewItem(Agente parent)
 {
     this.AddItem(AgenteDocumento.NewChild(parent));
     return(this[Count - 1]);
 }