コード例 #1
0
        public FreeRoomCheck IsRoomFree(DateTime start, DateTime end, BookingResource room, int assignmentID)
        {
            if (end <= start)
            {
                throw new Exception("Intervallo date non corretto per la verifica di assegnazioni già presenti");
            }

            if (room == null)
            {
                throw new Exception("Stanza non specificata per la verifica di assegnazioni già presenti");
            }


            end   = end.Date;
            start = start.Date;

            //cerco tutte le assegnazioni per una data camera che intersecano strettamente il periodo considerato
            //cosi facendo ottengo tutte le assegnazioni che si sovrappongono ad una potenziale assegnazione nel periodo
            //considerato.

            //l'input assignmentId serve per il caso in cui sto aggiornando una assegnazione esistente e il check
            //va fatto non considerando la presenza dell'assegnazione in questione
            Query q = _ps.CreateNewQuery("MapperAssignment");

            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            //criterio per la verifica della sovrapposizioe delle assegnazioni
            c.AddCriteria(Criteria.DateRangeStrictlyIntersects("StartDate", "EndDate", start, end, DataAccessServices.Instance().PersistenceFacade.DBType));
            //criterio sulla camera
            c.AddCriteria(Criteria.Equal("Id_Resource", room.Id.ToString()));

            //in caso di modifica
            if (assignmentID > 0)
            {
                NotExp exp = new NotExp(Criteria.Equal("ID", assignmentID.ToString()));
                c.AddCriteria(exp);
            }

            q.AddWhereClause(c);


            string p       = q.CreateQuery(_ps);
            IList  results = q.Execute(_ps);

            FreeRoomCheck cc = new FreeRoomCheck();

            cc.IsFree = results.Count == 0;

            if (cc.IsFree)
            {
                return(cc);
            }

            return(ConstructObject(results, cc, start, end, room));
        }
コード例 #2
0
        public IList GetBookings(DataRange period)
        {
            if (period == null)
            {
                throw new Exception("Periodo non valido!");
            }

            if (period.IsEmpty())
            {
                throw new Exception("Periodo non valido!");
            }

            Query q = _ps.CreateNewQuery("MapperBooking");

            AbstractBoolCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            c.AddCriteria(Criteria.DateTimeContained("Date", period.Start.Date, period.Finish.Date.AddDays(1).AddSeconds(-1), _ps.DBType));


            q.AddWhereClause(c);

            string sss = q.CreateQuery(_ps);

            return(q.Execute(_ps));
        }
コード例 #3
0
        public IList GetCheckins(DateTime date)
        {
            IList result           = null;
            IPersistenceFacade _ps = DataAccessServices.Instance().PersistenceFacade;

            Query q = _ps.CreateNewQuery("MapperCheckin");

            AbstractBoolCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            c.AddCriteria(Criteria.DateTimeContained("Checkin", date.Date, date.AddDays(1).Date.AddSeconds(-1), _ps.DBType));


            q.AddWhereClause(c);

            string p = q.CreateQuery(_ps);

            result = q.Execute(_ps);

            IList result1 = new ArrayList();

            foreach (Checkin item in result)
            {
                result1.Add(new ArrivedPerson(item));
            }

            return(result1);
        }
コード例 #4
0
        private CompositeCriteria CreateStapeCriteria()
        {
            if (_scaduti)
            {
                return(CreateScadutiCriteria());
            }



            if (_Non_iniziata == false && _In_corso == false && _Completata == false && _In_attesa == false && _Rinviata == false)
            {
                return(null);
            }

            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);

            if (_Non_iniziata)
            {
                c.AddCriteria(Criteria.Equal("Status", "0"));
            }

            if (_In_corso)
            {
                c.AddCriteria(Criteria.Equal("Status", "1"));
            }

            if (_Completata)
            {
                c.AddCriteria(Criteria.Equal("Status", "2"));
            }

            if (_In_attesa)
            {
                c.AddCriteria(Criteria.Equal("Status", "3"));
            }

            if (_Rinviata)
            {
                c.AddCriteria(Criteria.Equal("Status", "4"));
            }


            return(c);
        }
コード例 #5
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            if (!_createSubquery)
            {
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

                if (_senzaCliente)
                {
                    c.AddCriteria(Criteria.IsNull("CustomerID"));
                }
                else
                {
                    if (_customers.Count > 0)
                    {
                        CreateCustomerCriteria(c);
                    }
                    else
                    {
                        c = null;
                    }
                }

                return(c);
            }
            else // creo la subquery per i contatti sui documenti
            {
                if (_customers.Count == 0)
                {
                    return(null);
                }
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);
                //creo la clausola where per la sotto query
                AbstractBoolCriteria CompositeListaSoggetti = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                if (_customers.Count > 0)
                {
                    foreach (Customer elem in _customers)
                    {
                        CompositeListaSoggetti.AddCriteria(Criteria.Equal("ContactID", elem.Id.ToString()));
                    }
                }
                //creo il corpo della sottoquery
                AbstractBoolCriteria subCriteria = CompositeListaSoggetti;
                //aggiungo anche la clausola distinct   … Select Distinct DocumentID from App_Destinations….
                SubQueryCriteria subqry = new SubQueryCriteria("App_Destinations ", "DocumentID", true);
                //a ggiungo la clausola where … where ContactId = @par1 or ContactId = @par2 ….
                if (_customers.Count > 0)
                {
                    subqry.AddCriteria(subCriteria);
                }
                // aggiungo la sottoquery al criterio principale  ….select * from [Tabella]  where (ID in (select distinct DocumentId……))
                c.AddCriteria(Criteria.INClause("ID ", subqry));

                return(c);
            }
        }
コード例 #6
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            bool modified       = false;
            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);


            if (!string.IsNullOrEmpty(_subject))
            {
                c.AddCriteria(Criteria.Matches("Subject", _subject, DataAccessServices.Instance().PersistenceFacade.DBType));
                modified = true;
            }

            if (!string.IsNullOrEmpty(_priority))
            {
                PriorityType t = (PriorityType)Enum.Parse(typeof(PriorityType), _priority);
                c.AddCriteria(Criteria.Equal("Priority", Convert.ToInt32(t).ToString()));
                modified = true;
            }

            if (!_range.IsEmpty())
            {
                DataRange r = AppointmentUtils.CreateRangeForQuery(_range);
                c.AddCriteria(Criteria.DateTimeContained("OutcomeDate", r.Start, r.Finish, DataAccessServices.Instance().PersistenceFacade.DBType));
                modified = true;
            }


            CompositeCriteria c1 = CreateStapeCriteria();

            if (c1 != null)
            {
                c.AddCriteria(c1);
                modified = true;
            }


            if (modified)
            {
                return(c);
            }
            return(null);
        }
コード例 #7
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            if (_state == StateAppointmentDTOEnum.Non_Eseguiti)
            {
                c.AddCriteria(Criteria.Equal("OutcomeCreated", "0"));
                return(c);
            }
            else if (_state == StateAppointmentDTOEnum.Tutti)
            {
                return(null);
            }
            else
            {
                c.AddCriteria(Criteria.Equal("OutcomeCreated", "1"));
                //if (_conclusi)
                //c.AddCriteria(Criteria.Equal("Closed", "1"));
                //else
                if (!_conclusi)
                {
                    c.AddCriteria(Criteria.Equal("Closed", "0"));
                }


                if (_outcomes.Count > 0)
                {
                    CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                    foreach (Outcome item in _outcomes)
                    {
                        if (item != null)
                        {
                            c1.AddCriteria(Criteria.Equal("OutcomeID", item.Id.ToString()));
                        }
                    }
                    c.AddCriteria(c1);
                }

                return(c);
            }
        }
コード例 #8
0
        public IUser GetUser(string username, string password)
        {
            Query             query        = ps.CreateNewQuery("MapperUser");
            CompositeCriteria mainCriteria = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            mainCriteria.AddCriteria(Criteria.Equal("Username", "'" + username + "'"));
#if (FENEAL)
            mainCriteria.AddCriteria(Criteria.Equal("Password", "'" + password + "'"));
#else
            mainCriteria.AddCriteria(Criteria.Equal("Passwordd", "'" + password + "'"));
#endif

            query.AddWhereClause(mainCriteria);

            IList list = query.Execute(ps);
            if (list.Count == 0)
            {
                return(null);
            }
            return(list[0] as IUser);
        }
コード例 #9
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            if (_forRimesse)
            {
                c.AddCriteria(Criteria.Equal("Anno", _year.ToString()));
            }
            else
            {
                c.AddCriteria(Criteria.DateTimeContained("Data", _range.Start, _range.Finish, DataAccessServices.Instance().PersistenceFacade.DBType));
            }

            if (_province != null)
            {
                foreach (Provincia item in _province)
                {
                    c.AddCriteria(Criteria.Equal("Id_Provincia", item.Id.ToString()));
                }
            }

            if (_regioni != null)
            {
                foreach (Regione item in _regioni)
                {
                    c.AddCriteria(Criteria.Equal("Id_Regione", item.Id.ToString()));
                }
            }

            if (_causali != null)
            {
                foreach (CausaleAmministrativa item in _causali)
                {
                    c.AddCriteria(Criteria.Equal("Id_CausaleAmministrazione", item.Id.ToString()));
                }
            }


            return(c);
        }
コード例 #10
0
        private CompositeCriteria CreateScadutiCriteria()
        {
            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);

            c.AddCriteria(Criteria.Equal("Status", "0"));

            c.AddCriteria(Criteria.Equal("Status", "1"));

            c.AddCriteria(Criteria.Equal("Status", "3"));

            c.AddCriteria(Criteria.Equal("Status", "4"));



            if (_allaData != DateTime.MinValue)
            {
                AndExp a = new AndExp(c, Criteria.DateTimeContained("EndDate", new DateTime(1900, 1, 1), _allaData.AddDays(1).Date, DataAccessServices.Instance().PersistenceFacade.DBType));
                return(a);
            }

            return(c);
        }
コード例 #11
0
        private void CreateCustomerCriteria(CompositeCriteria c)
        {
            CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);

            foreach (Customer item in _customers)
            {
                if (item != null)
                {
                    c1.AddCriteria(Criteria.Equal("CustomerID", item.Id.ToString()));
                }
            }
            c.AddCriteria(c1);
        }
コード例 #12
0
        public IList GetArrivalsAndDepartures(DateTime date, bool arrivals)
        {
            IList result = null;


            Query q = _ps.CreateNewQuery("MapperAssignment");

            AbstractBoolCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            if (arrivals)
            {
                c.AddCriteria(Criteria.DateEqual("StartDate", date.Date, _ps.DBType));
            }
            else
            {
                c.AddCriteria(Criteria.DateEqual("EndDate", date.Date, _ps.DBType));
            }


            q.AddWhereClause(c);


            result = q.Execute(_ps);


            IList l = new ArrayList();


            foreach (Assignment item in result)
            {
                l.Add(new Arrival(item));
            }


            return(l);
        }
コード例 #13
0
        public IList ExecuteQuery(IList <IsearchDTO> criterias, int maxQueryresult, int deadlinesDays)
        {
            _bindableResults = new BindingList <MyAppointment>();

            Query q = _ps.CreateNewQuery("MapperMyAppointment");

            q.SetTable("App_Appointments");
            if (maxQueryresult > 0)
            {
                q.SetMaxNumberOfReturnedRecords(maxQueryresult);
            }

            if (criterias.Count > 0)
            {
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);
                foreach (IsearchDTO item in criterias)
                {
                    if (item != null)
                    {
                        AbstractBoolCriteria crit = item.GenerateSql();
                        if (crit != null)
                        {
                            c.AddCriteria(crit);
                        }
                    }
                }
                q.AddWhereClause(c);
            }

            string a = q.CreateQuery(_ps);

            IList l = q.Execute(_ps);


            //calcolo lo stato per ogni appp ritornato
            foreach (MyAppointment item in l)
            {
                item.CalculateAppointmentInfo(deadlinesDays);
                _bindableResults.Add(item);
            }

            return(l);
        }
コード例 #14
0
        public IList ExecuteQuery(IList <IsearchDTO> criterias, int maxQueryresult)
        {
            _bindableResults = new BindingList <DOMAIN.Booking.Booking>();

            Query q = _ps.CreateNewQuery("MapperBooking");

            q.SetTable("Book_Booking");
            if (maxQueryresult > 0)
            {
                q.SetMaxNumberOfReturnedRecords(maxQueryresult);
            }

            if (criterias.Count > 0)
            {
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);
                foreach (IsearchDTO item in criterias)
                {
                    if (item != null)
                    {
                        AbstractBoolCriteria crit = item.GenerateSql();
                        if (crit != null)
                        {
                            c.AddCriteria(crit);
                        }
                    }
                }
                q.AddWhereClause(c);
            }

            string a = q.CreateQuery(_ps);

            IList l = q.Execute(_ps);


            //calcolo lo stato per ogni appp ritornato
            foreach (DOMAIN.Booking.Booking item in l)
            {
                _bindableResults.Add(item);
            }

            return(l);
        }
コード例 #15
0
        public IList ExecuteQuery(IList <IsearchDTO> criterias)
        {
            _bindableResults = new BindingList <AbstractMovimentoContabile>();

            Query q = _ps.CreateNewQuery("Mapper" + ObjectTypeName);

            //q.SetTable("App_Appointments");


            if (criterias.Count > 0)
            {
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);
                foreach (IsearchDTO item in criterias)
                {
                    if (item != null)
                    {
                        AbstractBoolCriteria crit = item.GenerateSql();
                        if (crit != null)
                        {
                            c.AddCriteria(crit);
                        }
                    }
                }
                q.AddWhereClause(c);
            }

            string a = q.CreateQuery(_ps);

            IList l = q.Execute(_ps);


            //creo la binding list
            foreach (AbstractMovimentoContabile item in l)
            {
                _bindableResults.Add(item);
            }

            return(l);
        }
コード例 #16
0
        //#region MembriSovrascritti
        //[Secure(Area = "Contatti", Alias = "Visualizza contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForView()
        //{
        //    SecurityManager.Instance.Check();
        //}


        //[Secure(Area = "Contatti", Alias = "Inserisci contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForInsert()
        //{
        //    SecurityManager.Instance.Check();
        //}


        //[Secure(Area = "Contatti", Alias = "Aggiorna contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForUpdate()
        //{
        //    SecurityManager.Instance.Check();
        //}

        //[Secure(Area = "Contatti", Alias = "Elimina contatto", MacroArea = "Applicativo")]
        //public void CheckSecurityForDeletion()
        //{
        //    SecurityManager.Instance.Check();
        //}


        //public override AbstractPersistenceObject GetElementById(string id)
        //{
        //    CheckSecurityForView();
        //    return base.GetElementById(id);
        //}


        //public override void SaveOrUpdate(AbstractPersistenceObject element)
        //{
        //    if (element == null)
        //        return;

        //    if (element.Key == null)
        //        CheckSecurityForInsert();
        //    else
        //        CheckSecurityForUpdate();

        //    base.SaveOrUpdate(element);
        //}


        //public override void Delete(AbstractPersistenceObject element)
        //{
        //    CheckSecurityForDeletion();
        //    base.Delete(element);
        //}


        //public override IList GetAll()
        //{
        //    CheckSecurityForView();
        //    return base.GetAll();
        //}

//#endregion



        public IList SearchCustomers(CustomerSearchDTO dto)
        {
            //CheckSecurityForView();

            Query q = _ps.CreateNewQuery("MapperCustomer");

#if (FENEAL)
            q.SetTable("DB_UTENTE");
#else
            q.SetTable("App_Customers");
#endif
            q.SetMaxNumberOfReturnedRecords(dto.MaxResult);


            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);


            if (!string.IsNullOrEmpty(dto.Descrizione))
            {
                c.AddCriteria(Criteria.Matches("COGNOME", dto.Descrizione, _ps.DBType));
            }

            if (!string.IsNullOrEmpty(dto.Responsable))
            {
                c.AddCriteria(Criteria.Matches("NOME", dto.Responsable, _ps.DBType));
            }

            if (dto.CheckPrivate)
            {
                if (dto.IsPrivate)
                {
                    c.AddCriteria(Criteria.Equal("IS_PRIVATO", "1"));
                }
                else
                {
                    c.AddCriteria(Criteria.Equal("IS_PRIVATO", "0"));
                }
            }


            if (!string.IsNullOrEmpty(dto.Cellulare))
            {
                c.AddCriteria(Criteria.Matches("CELL1", dto.Cellulare, _ps.DBType));
            }

            if (!string.IsNullOrEmpty(dto.Mail))
            {
                c.AddCriteria(Criteria.Matches("MAIL", dto.Mail, _ps.DBType));
            }

            if (!string.IsNullOrEmpty(dto.Piva))
            {
                c.AddCriteria(Criteria.Matches("CODICE_FISCALE", dto.Piva, _ps.DBType));
            }


            if (dto.Resource != null)
            {
                c.AddCriteria(Criteria.Equal("ResourceID", dto.Resource.Id.ToString()));
            }

            if (dto.Province != null)
            {
                if (dto.Province.Id != -1)
                {
                    c.AddCriteria(Criteria.Equal("ID_TB_PROVINCIE_RESIDENZA", dto.Province.Id.ToString()));
                }
            }

            if (dto.Comune != null)
            {
                if (dto.Comune.Id != -1)
                {
                    c.AddCriteria(Criteria.Equal("ID_TB_COMUNI_RESIDENZA", dto.Comune.Id.ToString()));
                }
            }



            q.AddWhereClause(c);

            string d = q.CreateQuery(_ps);

            return(q.Execute(_ps));
        }
コード例 #17
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            if (_noPeriod)
            {
                return(null);
            }


            DataRange r;


            switch (_state)
            {
            case PeriodAppointmentDTOEnum.Prossimi_Sei_Mesi:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1).AddMonths(6)));
                break;

            case PeriodAppointmentDTOEnum.Prossimi_Tre_Mesi:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1).AddMonths(3)));
                break;

            case PeriodAppointmentDTOEnum.Prossimo_Mese:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1).AddMonths(1)));
                break;

            case PeriodAppointmentDTOEnum.Prossime_Due_Settimane:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(1), DateTime.Now.AddDays(15)));
                break;

            case PeriodAppointmentDTOEnum.Prossima_Settimana:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(1), DateTime.Now.AddDays(8)));
                break;

            case PeriodAppointmentDTOEnum.Domani:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(1), DateTime.Now.AddDays(1)));
                break;

            case PeriodAppointmentDTOEnum.Oggi:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now, DateTime.Now));
                break;

            case PeriodAppointmentDTOEnum.Ultima_Settimana:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(-8), DateTime.Now.AddDays(-1)));
                break;

            case PeriodAppointmentDTOEnum.Ultime_Due_Settimane:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(-15), DateTime.Now.AddDays(-1)));
                break;

            case PeriodAppointmentDTOEnum.Ultimo_Mese:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(-1).AddMonths(-1), DateTime.Now.AddDays(-1)));
                break;

            case PeriodAppointmentDTOEnum.Ultimi_Tre_Mesi:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(-1).AddMonths(-3), DateTime.Now.AddDays(-1)));
                break;

            case PeriodAppointmentDTOEnum.Ultimi_Sei_Mesi:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now.AddDays(-1).AddMonths(-6), DateTime.Now.AddDays(-1)));
                break;

            case PeriodAppointmentDTOEnum.Periodo:
                r = AppointmentUtils.CreateRangeForQuery(_range);
                break;

            default:
                r = AppointmentUtils.CreateRangeForQuery(new DataRange(DateTime.Now, DateTime.Now));
                break;
            }

            if (_findAlsoOverlappedAppointments)
            {
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);
                c.AddCriteria(Criteria.DateRangeIntersects("StartDate", "EndDate", r.Start, r.Finish, DataAccessServices.Instance().PersistenceFacade.DBType));
                return(c);
            }
            else
            {
                CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);
                c.AddCriteria(Criteria.DateTimeContained("StartDate", r.Start, r.Finish, DataAccessServices.Instance().PersistenceFacade.DBType));
                return(c);
            }
        }
コード例 #18
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            bool modified       = false;
            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);


            if (!string.IsNullOrEmpty(_subject))
            {
                c.AddCriteria(Criteria.Matches("Subject", _subject, DataAccessServices.Instance().PersistenceFacade.DBType));
                modified = true;
            }

            if (!string.IsNullOrEmpty(_location))
            {
                c.AddCriteria(Criteria.Matches("Location", _location, DataAccessServices.Instance().PersistenceFacade.DBType));
                modified = true;
            }



            if (_labels.Count > 0)
            {
                CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                foreach (Label item in _labels)
                {
                    if (item != null)
                    {
                        c1.AddCriteria(Criteria.Equal("LabelID", item.Id.ToString()));
                    }
                }
                c.AddCriteria(c1);
                modified = true;
            }

            if (_resources.Count > 0)
            {
                CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                foreach (Resource item in _resources)
                {
                    if (item != null)
                    {
                        c1.AddCriteria(Criteria.Equal("ResourceID", item.Id.ToString()));
                    }
                }
                c.AddCriteria(c1);
                modified = true;
            }

            if (_operators.Count > 0)
            {
                CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                foreach (Operator item in _operators)
                {
                    if (item != null)
                    {
                        c1.AddCriteria(Criteria.Equal("OperatorID", item.Id.ToString()));
                    }
                }
                c.AddCriteria(c1);
                modified = true;
            }

            if (modified)
            {
                return(c);
            }
            return(null);
        }
コード例 #19
0
        public WIN.TECHNICAL.PERSISTENCE.AbstractBoolCriteria GenerateSql()
        {
            //bool modified = false;
            CompositeCriteria c = new CompositeCriteria(AbstractBoolCriteria.Operatore.AndOp);

            c.AddCriteria(Criteria.Equal("DocYear", _year.ToString()));

            if (!string.IsNullOrEmpty(_subject))
            {
                c.AddCriteria(Criteria.Matches("Subject", _subject, DataAccessServices.Instance().PersistenceFacade.DBType));
                //modified = true;
            }

            if (!string.IsNullOrEmpty(_protocol))
            {
                c.AddCriteria(Criteria.Matches("Protocol", _protocol, DataAccessServices.Instance().PersistenceFacade.DBType));
                //modified = true;
            }



            if (_labels.Count > 0)
            {
                CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                foreach (DocumentType item in _labels)
                {
                    if (item != null)
                    {
                        c1.AddCriteria(Criteria.Equal("DocTypeID", item.Id.ToString()));
                    }
                }
                c.AddCriteria(c1);
                //modified = true;
            }

            if (_scopes.Count > 0)
            {
                CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                foreach (DocumentScope item in _scopes)
                {
                    if (item != null)
                    {
                        c1.AddCriteria(Criteria.Equal("ScopeID", item.Id.ToString()));
                    }
                }
                c.AddCriteria(c1);
                //modified = true;
            }

            if (_operators.Count > 0)
            {
                CompositeCriteria c1 = new CompositeCriteria(AbstractBoolCriteria.Operatore.OrOp);
                foreach (Operator item in _operators)
                {
                    if (item != null)
                    {
                        c1.AddCriteria(Criteria.Equal("OperatorID", item.Id.ToString()));
                    }
                }
                c.AddCriteria(c1);
                //modified = true;
            }

            //if (modified)
            return(c);
            // return null;
        }