Пример #1
0
        public IEnumerable <OperatorRanking> GetOperatorsRanking(DateTime desde, DateTime hasta, List <int> choferes)
        {
            OperatorRanking or = null;

            DetachedCriteria dc = GetDatamartDetachedCriteria().FilterBeginBetween(desde, hasta);

            if (choferes.Count <= SQLParameterLimit)
            {
                dc.Add(Restrictions.In(Projections.Property <Datamart>(p => p.Employee.Id), choferes));
            }

            ProjectionList pl = Projections.ProjectionList();

            pl.Add(Projections.Sum <Datamart>(dm => dm.Kilometers).WithAlias(() => or.Kilometros));
            pl.Add(Projections.Sum <Datamart>(dm => dm.MovementHours).WithAlias(() => or.Hours));
            pl.Add(Projections.Group <Datamart>(dm => dm.Employee.Id).WithAlias(() => or.IdOperador));

            ICriteria crit = GetDatamartCriteria(0, dc, pl, null, typeof(OperatorRanking));
            IList <OperatorRanking> results = crit.List <OperatorRanking>();

            var empleadoDAO = new EmpleadoDAO();

            foreach (OperatorRanking r in results)
            {
                Empleado empleado = empleadoDAO.FindById(r.IdOperador);
                r.Operador = empleado.Entidad.Apellido;
                r.Legajo   = empleado.Legajo;
            }
            IEnumerable <OperatorRanking> result = (choferes.Count > SQLParameterLimit ? results.Where(c => choferes.Contains(c.IdOperador)) : results);

            return(result);
        }
Пример #2
0
        public IDictionary <string, int> getYearlyCompanyMap()
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StatisticsManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria criteria = DetachedCriteria.For <Entity_CompanyDetails>();

            criteria.Add(Restrictions.Eq("status", Utility.getEnumIndexByValue(Constant.ENUM_COMPANY_STATUS,
                                                                               EnumData.companyStatus.CONFIRMED.ToString())));
            criteria.Add(Restrictions.Eq("myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));

            ProjectionList projectionList = Projections.ProjectionList();

            projectionList.Add(Projections.GroupProperty(Projections.Property("myConfigObj.currentBatch")));
            projectionList.Add(Projections.Count(Projections.Property("compDetailsId")));

            criteria.SetProjection(projectionList);

            IList list = persistence.findByCriteria(criteria);

            if (list != null && list.Count > 0)
            {
                IDictionary <string, int> resultMap = new Dictionary <string, int>();

                foreach (Object[] item in list)
                {
                    resultMap.Add(item[0].ToString(), Convert.ToInt32(item[1]));
                }
                return(resultMap);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        public IDictionary <string, int> getYearlyStudentMap()
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StatisticsManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria criteria = DetachedCriteria.For <Entity_PlacementDetails>();

            criteria.CreateAlias("stuObj", "student");

            ProjectionList projectionList = Projections.ProjectionList();

            projectionList.Add(Projections.GroupProperty(Projections.Property("student.myConfigObj.currentBatch")));
            projectionList.Add(Projections.Count(Projections.Property("detailsId")));

            criteria.SetProjection(projectionList);
            criteria.Add(Restrictions.Eq("student.myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));

            IList list = persistence.findByCriteria(criteria);

            if (list != null && list.Count > 0)
            {
                IDictionary <string, int> resultMap = new Dictionary <string, int>();

                foreach (Object[] item in list)
                {
                    resultMap.Add(item[0].ToString(), Convert.ToInt32(item[1]));
                }
                return(resultMap);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// Gets mobile maintenance aggregat data for the specified vehicles.
        /// </summary>
        /// <param name="desde"></param>
        /// <param name="hasta"></param>
        /// <param name="vehiculos"></param>
        /// <returns></returns>
        public IEnumerable <MobileMaintenance> GetMobileMaintenanceData(DateTime desde, DateTime hasta, IEnumerable <Coche> vehiculos)
        {
            MobileMaintenance mm = null;

            int[] ids = vehiculos.Select(c => c.Id).ToArray();

            DetachedCriteria dc = GetDatamartDetachedCriteria(ids).FilterBeginBetween(desde, hasta);

            ProjectionList pl = Projections.ProjectionList();

            pl.Add(Projections.Sum <Datamart>(dm => dm.MovementHours).WithAlias(() => mm.HsMarcha));
            pl.Add(Projections.Sum <Datamart>(dm => dm.Kilometers).WithAlias(() => mm.Kilometros));
            pl.Add(Projections.Group <Datamart>(dm => dm.Vehicle.Id).WithAlias(() => mm.IdVehiculo));

            ICriteria crit = GetDatamartCriteria(0, dc, pl, null, typeof(MobileMaintenance));
            IList <MobileMaintenance> results = crit.List <MobileMaintenance>();

            var cocheDAO = new CocheDAO();

            foreach (MobileMaintenance r in results)
            {
                Coche coche = cocheDAO.FindById(r.IdVehiculo);
                r.Interno      = coche.Interno;
                r.TipoVehiculo = coche.TipoCoche != null ? coche.TipoCoche.Descripcion : null;
                r.Patente      = coche.Patente;
                r.Referencia   = coche.Referencia;
            }
            return(results);
        }
Пример #5
0
        public List <HistoricView> GetHistoricPrices(int priceBaseId)
        {
            PriceBase pb = ControllerManager.PriceBase.GetById(priceBaseId);

            if (pb == null)
            {
                return(null);
            }

            ICriteria crit = GetCriteria();

            crit.Add(Expression.Eq("Product", pb.Product));
            crit.Add(Expression.Eq("Provider", pb.Provider));
            ProjectionList pl = Projections.ProjectionList();

            pl.Add(Projections.Distinct(Projections.Property("PriceList")));
            pl.Add(Projections.Property("TimeStamp.ModifiedOn"));
            crit.SetProjection(pl);

            crit.AddOrder(new Order("TimeStamp.ModifiedOn", true));

            IList lst = crit.List();

            List <HistoricView> hv = new List <HistoricView>();

            foreach (object[] arr in lst)
            {
                hv.Add(new HistoricView(StringFormat.MilliTimeStamp((DateTime)arr[1]), Convert.ToDecimal(arr[0])));
            }

            return(hv);
        }
Пример #6
0
        public IList getCompanyStatCount()
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StatisticsManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria criteria = DetachedCriteria.For <Entity_CompanyDetails>();

            criteria.Add(Restrictions.Eq("myConfigObj.currentBatch", Common.loggedUser.myConfigObj.currentBatch));
            criteria.Add(Restrictions.Eq("myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));

            ProjectionList projectionList = Projections.ProjectionList();

            projectionList.Add(Projections.Count((Projections.Property("status"))));
            projectionList.Add(Projections.GroupProperty(Projections.Property("status")));

            criteria.SetProjection(projectionList);
            criteria.AddOrder(Order.Desc(Projections.Property("status")));

            IList list = persistence.findByCriteria(criteria);

            if (list != null && list.Count > 0)
            {
                return(list);
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(OrderDetailView));

        #region Customize
        criteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION));
        SecurityHelper.SetRegionSearchCriteria(criteria, "PartyTo.Code", this.CurrentUser.Code); //区域权限
        OrderHelper.SetActiveOrderStatusCriteria(criteria, "Status");                            //订单状态
        #endregion

        #region Select Parameters
        CriteriaHelper.SetFlowCriteria(criteria, "Flow", this._criteriaParam);
        CriteriaHelper.SetPartyCriteria(criteria, "PartyTo.Code", this._criteriaParam);
        CriteriaHelper.SetStartDateCriteria(criteria, "EffDate", this._criteriaParam);
        CriteriaHelper.SetEndDateCriteria(criteria, "EffDate", this._criteriaParam);
        CriteriaHelper.SetShiftCriteria(criteria, "Shift.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("OrderedQty").As("OrderedQty"))
                                        .Add(Projections.Sum("ReceivedQty").As("ReceivedQty"))
                                        .Add(Projections.Sum("RejectedQty").As("RejectedQty"))
                                        .Add(Projections.Sum("ScrapQty").As("ScrapQty"))
                                        .Add(Projections.GroupProperty("Item").As("Item"))
                                        .Add(Projections.GroupProperty("Uom").As("Uom"));

        if (!this._criteriaParam.ClassifiedFlow)
        {
            projectionList.Add(Projections.GroupProperty("Flow").As("Flow"));
            projectionList.Add(Projections.GroupProperty("Description").As("Description"));
        }
        if (!this._criteriaParam.ClassifiedParty)
        {
            projectionList.Add(Projections.GroupProperty("PartyTo").As("PartyTo"));
        }
        if (!this._criteriaParam.ClassifiedShift)
        {
            projectionList.Add(Projections.GroupProperty("Shift").As("Shift"));
        }
        if (!this._criteriaParam.ClassifiedDate)
        {
            projectionList.Add(Projections.GroupProperty("EffDate").As("EffDate"));
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(OrderDetailView)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
Пример #8
0
        public IList<SubjectList> GetAllSubject()
        {
            DetachedCriteria criteria = DetachedCriteria.For<SubjectList>();
            ProjectionList list = Projections.ProjectionList().Create();
            list.Add(Projections.Distinct(Projections.Property("SubjectCode")));
            list.Add(Projections.GroupProperty("SubjectCode"), "SubjectCode");
            list.Add(Projections.GroupProperty("SubjectName"), "SubjectName");
            criteria.SetProjection(list);
            criteria.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(SubjectList)));

            return criteriaMgr.FindAll<SubjectList>(criteria);
        }
Пример #9
0
        /// <summary>
        /// Gets aggregate activity for each specified transport company.
        /// </summary>
        /// <param name="desde"></param>
        /// <param name="hasta"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        public IEnumerable <TransportActivity> GetTransportActivities(DateTime desde, DateTime hasta, List <int> ids)
        {
            TransportActivity ta = null;

            DetachedCriteria dc = GetDatamartDetachedCriteria(ids.ToArray()).FilterBeginBetween(desde, hasta);

            ProjectionList pl = Projections.ProjectionList();

            pl.Add(Projections.Sum <Datamart>(dm => dm.MovementHours).WithAlias(() => ta.HsActivos));
            pl.Add(Projections.Sum <Datamart>(dm => dm.StoppedHours).WithAlias(() => ta.HsInactivos));
            pl.Add(Projections.Sum <Datamart>(dm => dm.InfractionMinutes).WithAlias(() => ta.HsInfraccion));
            pl.Add(Projections.Sum <Datamart>(dm => dm.Infractions).WithAlias(() => ta.Infracciones));
            pl.Add(Projections.Sum <Datamart>(dm => dm.Kilometers).WithAlias(() => ta.Recorrido));
            pl.Add(Projections.Max <Datamart>(dm => dm.MaxSpeed).WithAlias(() => ta.VelocidadMaxima));
            pl.Add(Projections.Avg <Datamart>(dm => dm.AverageSpeed).WithAlias(() => ta.VelocidadPromedio));
            pl.Add(Projections.Group <Datamart>(dm => dm.Vehicle.Id).WithAlias(() => ta.IdVehiculo));

            ICriteria crit = GetDatamartCriteria(0, dc, pl, null, typeof(TransportActivity));
            IList <TransportActivity> results = crit.List <TransportActivity>();

            var cocheDAO = new CocheDAO();

            foreach (TransportActivity r in results)
            {
                Coche coche = cocheDAO.FindById(r.Id);
                r.HsInfraccion  /= 60;
                r.Transport      = coche.Transportista.Descripcion;
                r.CentroDeCostos = coche.CentroDeCostos != null ? coche.CentroDeCostos.Descripcion : null;
                r.TipoVehiculo   = coche.TipoCoche != null ? coche.TipoCoche.Descripcion : null;
            }
            return(results);
        }
Пример #10
0
 private void AddLastProjection()
 {
     if (lastProjection != null)
     {
         projectionList.Add(lastProjection);
     }
 }
Пример #11
0
        protected IList <T> GetAllGeneric <T>(List <FilterOption> filters, int pageNumber, int pageSize, string sortBy, string sortDirection, List <string> selectColumnsList = null)
        {
            ICriteria query = GetQueryCondition <T>(filters);

            selectColumnsList = selectColumnsList ?? new List <string>();

            if (selectColumnsList.Any())
            {
                ProjectionList projectionList = Projections.ProjectionList();

                foreach (var column in selectColumnsList)
                {
                    projectionList.Add(Projections.Property(column), column);
                }
                query.SetProjection(projectionList);
            }

            string sortByText = string.Empty;

            var property = typeof(T).GetProperties().SingleOrDefault(prop => prop.Name.ToLower() == sortBy.ToLower());

            if (property != null)
            {
                sortByText = property.Name;
            }

            Order order = sortDirection.ToLower() == "asc" ? Order.Asc(sortByText) : Order.Desc(sortByText);

            return(query.SetFirstResult((pageNumber - 1) * pageSize)
                   .SetMaxResults(pageSize).AddOrder(order)
                   .SetResultTransformer(Transformers.AliasToBean(typeof(T)))
                   .List <T>());
        }
Пример #12
0
        /// <summary>
        /// 所有实体列表
        /// </summary>
        /// <param name="columnNames">列名</param>
        /// <param name="condition">条件</param>
        /// <param name="orderBy">排序字段</param>
        /// <param name="ascending">是否降序</param>
        /// <returns>返回结果</returns>
        public IList <TEntity> All(IList <string> columnNames, string condition, string orderBy, bool ascending)
        {
            ICriteria criteria = _session.CreateCriteria(typeof(TEntity));

            //添加排序字段
            if (!string.IsNullOrEmpty(orderBy))
            {
                criteria.AddOrder(new Order(orderBy, ascending));
            }
            //添加列
            ProjectionList projectionList = Projections.ProjectionList();

            foreach (string col in columnNames)
            {
                projectionList.Add(Projections.Property(col), col);
            }
            //添加查询条件
            if (!string.IsNullOrEmpty(condition))
            {
                criteria.Add(Expression.Sql(condition));
            }

            criteria.SetProjection(projectionList);
            criteria.SetResultTransformer(Transformers.AliasToBean <TEntity>());
            criteria.SetCacheable(true);//设置缓存
            return(criteria.List <TEntity>());
        }
Пример #13
0
 /// <summary>
 /// Adds the specified projection list.
 /// </summary>
 /// <typeparam name="TTo">The type of to.</typeparam>
 /// <typeparam name="TProperty">The type of the property.</typeparam>
 /// <param name="projectionList">The projection list.</param>
 /// <param name="projection">The projection.</param>
 /// <param name="alias">The alias.</param>
 /// <returns>A <see cref="ProjectionList"/></returns>
 public static ProjectionList Add <TTo, TProperty> (
     this ProjectionList projectionList,
     IProjection projection,
     Expression <Func <TTo, TProperty> > alias)
 {
     return(projectionList.Add(projection, PropertyUtil.ExtractPropertyName(alias)));
 }
Пример #14
0
        public ICriteria SetProjection(params IProjection[] projections)
        {
            if (projections == null)
            {
                throw new ArgumentNullException("projections");
            }
            if (projections.Length == 0)
            {
                throw new ArgumentException("projections must contain a least one projection");
            }

            if (projections.Length == 1)
            {
                projection = projections[0];
            }
            else
            {
                var projectionList = new ProjectionList();
                foreach (var childProjection in projections)
                {
                    projectionList.Add(childProjection);
                }
                projection = projectionList;
            }

            if (projection != null)
            {
                projectionCriteria = this;
                SetResultTransformer(CriteriaSpecification.Projection);
            }

            return(this);
        }
        /// <summary>
        ///     Adds the specified property to the projection list.
        /// </summary>
        /// <param name="list">
        ///     The projection list.
        /// </param>
        /// <param name="property">
        ///     The property.
        /// </param>
        /// <param name="data">
        ///     A <see cref="QueryHelperData" /> instance.
        /// </param>
        /// <typeparam name="TSource">
        ///     The <see cref="System.Type" /> of the source entity.
        /// </typeparam>
        /// <typeparam name="TProperty">
        ///     The <see cref="System.Type" /> of the property.
        /// </typeparam>
        /// <returns>
        ///     The <see cref="ProjectionList" /> instance.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="list" /> is null.
        /// </exception>
        public static ProjectionList AddProperty <TSource, TProperty>
        (
            this ProjectionList list,
            Expression <Func <TSource, TProperty> > property,
            QueryHelperData data
        )
        {
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }

            IProjection projection = ProjectionHelper.GetProjection(property, data);

            string alias = null;

            var propertyProjection = projection as IPropertyProjection;

            if (propertyProjection != null)
            {
                alias = propertyProjection.PropertyName;
            }

            list.Add(projection, alias);

            return(list);
        }
Пример #16
0
        public virtual void AddProjection(ProjectionList projections)
        {
            string propertyName = String.Join(".", _accessor.PropertyNames);
            var    projection   = Projections.Property(propertyName).As(_accessor.Name);

            projections.Add(projection);
        }
Пример #17
0
        /// <summary>
        ///     Adds the provided <see cref="IProjection" /> object to this <see cref="FqProjectionList" />.
        /// </summary>
        /// <param name="projection">
        ///     The <see cref="IProjection" /> object to add.
        /// </param>
        /// <returns>
        ///     This <see cref="FqProjectionList" /> object. Useful for chaining.
        /// </returns>
        public FqProjectionList Add(IProjection projection)
        {
            _elements.Add(projection);

            _list.Add(projection);

            return(this);
        }
        /// <summary>
        ///     Adds the specified property to the projection list.
        /// </summary>
        /// <param name="list">
        ///     The projection list.
        /// </param>
        /// <param name="property">
        ///     The property.
        /// </param>
        /// <param name="alias">
        ///     The alias.
        /// </param>
        /// <returns>
        ///     The <see cref="ProjectionList" /> instance.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="list" /> is null.
        /// </exception>
        public static ProjectionList AddProperty(this ProjectionList list, string property, string alias)
        {
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }

            return(list.Add(Projections.Property(property), alias));
        }
Пример #19
0
        /// <summary>
        /// Adds the specified projection list.
        /// </summary>
        /// <typeparam name="TFrom">The type of from.</typeparam>
        /// <typeparam name="TTo">The type of to.</typeparam>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="projectionList">The projection list.</param>
        /// <param name="projectionExpression">The projection expression.</param>
        /// <param name="aliasExpression">The alias expression.</param>
        /// <returns>A <see cref="ProjectionList"/></returns>
        public static ProjectionList Add <TFrom, TTo, TProperty> (
            this ProjectionList projectionList,
            Expression <Func <TFrom, object> > projectionExpression,
            Expression <Func <TTo, TProperty> > aliasExpression)
        {
            var projection = Projections.Property(projectionExpression);

            return(projectionList.Add(projection, PropertyUtil.ExtractPropertyName(aliasExpression)));
        }
Пример #20
0
        public IList <Trilha> ObterTrilhas()
        {
            ICriteria      criteria = repositorio.session.CreateCriteria(typeof(ViewUsuarioTrilhaAtividadeFormativaParticipacao), "vw");
            ProjectionList projList = Projections.ProjectionList();

            projList.Add(Projections.Distinct(Projections.Property <ViewUsuarioTrilhaAtividadeFormativaParticipacao>(d => d.TrilhaOrigem)));
            criteria.SetProjection(projList);
            return(criteria.List <Trilha>());
        }
Пример #21
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(CycleCountResult));

        criteria.CreateAlias("CycleCount", "cc");
        criteria.CreateAlias("cc.Location", "l");

        #region Customize
        SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        OrderHelper.SetActiveOrderStatusCriteria(criteria, "cc.Status");                          //状态
        #endregion

        #region Select Parameters
        CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", this._criteriaParam);
        CriteriaHelper.SetLocationCriteria(criteria, "cc.Location.Code", this._criteriaParam);
        CriteriaHelper.SetStartDateCriteria(criteria, "cc.EffectiveDate", this._criteriaParam);
        CriteriaHelper.SetEndDateCriteria(criteria, "cc.EffectiveDate", this._criteriaParam);
        CriteriaHelper.SetStorageBinCriteria(criteria, "StorageBin.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        CriteriaHelper.SetOrderNoCriteria(criteria, "CycleCount.Code", this._criteriaParam, MatchMode.Start);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("Qty").As("Qty"))
                                        .Add(Projections.Sum("InvQty").As("InvQty"))
                                        .Add(Projections.Sum("DiffQty").As("DiffQty"))
                                        .Add(Projections.Count("HuId").As("Cartons"))
                                        .Add(Projections.GroupProperty("Item").As("Item"));

        if (!this._criteriaParam.ClassifiedOrderNo)
        {
            projectionList.Add(Projections.GroupProperty("CycleCount").As("CycleCount"));
        }
        if (!this._criteriaParam.ClassifiedLocation)
        {
            projectionList.Add(Projections.GroupProperty("cc.Location").As("Location"));
        }
        if (!this._criteriaParam.ClassifiedBin)
        {
            projectionList.Add(Projections.GroupProperty("StorageBin").As("StorageBin"));//库格
        }
        if (!this._criteriaParam.ClassifiedHuId)
        {
            projectionList.Add(Projections.GroupProperty("HuId").As("HuId"));                           //条码
            projectionList.Add(Projections.GroupProperty("LotNo").As("LotNo"));                         //批号
            projectionList.Add(Projections.GroupProperty("ReferenceLocation").As("ReferenceLocation")); //参考库位
            projectionList.Add(Projections.GroupProperty("DiffReason").As("DiffReason"));               //差异原因
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(CycleCountResult)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
Пример #22
0
        public IList<SubjectList> GetCostCenter(string subjectCode)
        {
            if (subjectCode == null || subjectCode == string.Empty)
            {
                return null;
            }
            else
            {
                DetachedCriteria criteria = DetachedCriteria.For<SubjectList>();
                criteria.Add(Expression.Eq("SubjectCode", subjectCode));
                ProjectionList list = Projections.ProjectionList().Create();
                list.Add(Projections.Distinct(Projections.Property("CostCenterCode")));
                list.Add(Projections.GroupProperty("CostCenterCode"), "CostCenterCode");
                list.Add(Projections.GroupProperty("CostCenterName"), "CostCenterName");
                criteria.SetProjection(list);
                criteria.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(SubjectList)));

                return criteriaMgr.FindAll<SubjectList>(criteria);
            }
        }
Пример #23
0
        private ICriteria SetPropertiesBack(params string[] properties)
        {
            ProjectionList projects = Projections.ProjectionList();

            for (int i = 0; i < properties.Length; i++)
            {
                projects.Add(Projections.Property(properties[i]), properties[i]);
            }

            return(SetCriteria().SetProjection(projects));
        }
Пример #24
0
        /// <summary>
        /// Gets aggregate operator activities for the current timespan.
        /// </summary>
        /// <param name="desde"></param>
        /// <param name="hasta"></param>
        /// <param name="distrito"></param>
        /// <param name="planta"></param>
        /// <param name="ids"></param>
        /// <param name="km"></param>
        /// <returns></returns>
        public IEnumerable <OperatorActivity> GetOperatorActivities(DateTime desde, DateTime hasta, Int32 distrito, Int32 planta, List <Int32> ids, Double km)
        {
            OperatorActivity oa = null;

            DetachedCriteria dc = GetDatamartDetachedCriteria().FilterBeginBetween(desde, hasta).CreateAlias("Employee", "ch", JoinType.InnerJoin);

            if (distrito != -1)
            {
                dc.Add(Restrictions.Or(Restrictions.IsNull("ch.Empresa"), Restrictions.Eq("ch.Empresa.Id", distrito)));
            }

            if (planta != -1)
            {
                dc.Add(Restrictions.Or(Restrictions.IsNull("ch.Linea"), Restrictions.Eq("ch.Linea.Id", distrito)));
            }

            if (ids.Count <= SQLParameterLimit)
            {
                dc.Add(Restrictions.In("ch.Id", ids));
            }

            ProjectionList pl = Projections.ProjectionList();

            pl.Add(Projections.Sum <Datamart>(dm => dm.StoppedHours).WithAlias(() => oa.StoppedHours));
            pl.Add(Projections.Sum <Datamart>(dm => dm.MovementHours).WithAlias(() => oa.MovementHours));
            pl.Add(Projections.Sum <Datamart>(dm => dm.InfractionMinutes).WithAlias(() => oa.InfractionsMinutes));
            pl.Add(Projections.Sum <Datamart>(dm => dm.Infractions).WithAlias(() => oa.Infractions));
            IProjection kilometersProjection = Projections.Sum <Datamart>(dm => dm.Kilometers).WithAlias(() => oa.Kilometers);

            pl.Add(kilometersProjection);
            pl.Add(Projections.Max <Datamart>(dm => dm.MaxSpeed).WithAlias(() => oa.MaxSpeed));
            pl.Add(Projections.Group <Datamart>(dm => dm.Employee.Id).WithAlias(() => oa.OperatorId));

            ICriteria crit = GetDatamartCriteria(0, dc, pl, null, typeof(OperatorActivity));

            crit.Add(Restrictions.Ge(kilometersProjection, km));

            IList <OperatorActivity> results = crit.List <OperatorActivity>();

            var empleadoDAO = new EmpleadoDAO();

            foreach (OperatorActivity r in results)
            {
                Empleado empleado = empleadoDAO.FindById(r.OperatorId);
                r.Operator = empleado.Entidad != null ? empleado.Entidad.Descripcion : null;
            }

            foreach (OperatorActivity r in results.Where(filteredResult => filteredResult.Kilometers > 0 && filteredResult.MovementHours > 0))
            {
                r.AverageSpeed = Convert.ToInt32(r.Kilometers / r.MovementHours);
            }

            IEnumerable <OperatorActivity> result = (ids.Count > SQLParameterLimit ? results.Where(r => ids.Contains(r.OperatorId)) : results);

            return(result);
        }
        public List <StudentPlacedDto> getPlacedStudents()
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StudentPlacedManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria criteria = DetachedCriteria.For <Entity_PlacementDetails>();

            criteria.CreateAlias("stuObj", "student");
            criteria.CreateAlias("compDetailsObj", "compDetails");
            criteria.CreateAlias("compDetails.companyObj", "company");

            ProjectionList projectionsList = Projections.ProjectionList();

            projectionsList.Add(Projections.Property("detailsId"), "detailsId");
            projectionsList.Add(Projections.Property("student.collegeId"), "collegeId");
            projectionsList.Add(Projections.Property("student.studentName"), "name");
            projectionsList.Add(Projections.Property("student.gender"), "gender");
            projectionsList.Add(Projections.Property("student.branch"), "branch");
            projectionsList.Add(Projections.Property("student.myConfigObj.currentDegree"), "degree");
            projectionsList.Add(Projections.Property("student.phone"), "contact");
            projectionsList.Add(Projections.Property("company.companyName"), "company");
            projectionsList.Add(Projections.Property("compDetails.type"), "companyType");
            projectionsList.Add(Projections.Property("DOR"), "dor");

            criteria.SetProjection(projectionsList);
            criteria.Add(Restrictions.Eq("compDetails.myConfigObj.currentBatch", Common.loggedUser.myConfigObj.currentBatch));
            criteria.Add(Restrictions.Eq("compDetails.myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));
            criteria.Add(Restrictions.Eq("student.myConfigObj.currentBatch", Common.loggedUser.myConfigObj.currentBatch));
            criteria.Add(Restrictions.Eq("student.myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));

            criteria.AddOrder(Order.Asc("DOR"));
            criteria.SetResultTransformer(new AliasToBeanResultTransformer(typeof(StudentPlacedDto)));
            IList list = persistence.findByCriteria(criteria);

            if (list != null && list.Count > 0)
            {
                return(list.Cast <StudentPlacedDto>().ToList());
            }
            else
            {
                return(null);
            }
        }
Пример #26
0
        public void CountsOf <U>(Expression <Func <T, U> > property, Action <U, int> callback)
        {
            ICriteria criteria = _session.CreateCriteria(typeof(T));

            criteria = addWheres(criteria);

            var            propertyName = property.ToPropertyName();
            ProjectionList projections  = Projections.ProjectionList();

            projections.Add(Projections.GroupProperty(propertyName));
            projections.Add(Projections.Count(propertyName));


            criteria = criteria.SetProjection(projections);


            criteria.List().Cast <object[]>().Each(o =>
            {
                callback((U)o.GetValue(0), (int)o.GetValue(1));
            });
        }
Пример #27
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public IDictionary <NewsType, int> GetStatmemnt()
        {
            ProjectionList projectionList = Projections.ProjectionList();

            projectionList.Add(Projections.Property <News>(s => s.Type));
            projectionList.Add(Projections.RowCount());

            IList <object[]> f = DetachedCriteria.For <News>()
                                 .SetProjection(
                Projections.GroupProperty(Projections.Property <News>(s => s.Type)))
                                 .SetProjection(projectionList)
                                 .GetExecutableCriteria(CurrentSession).List <object[]>();

            var result = new Dictionary <NewsType, int>();

            foreach (var a in f)
            {
                result.Add((NewsType)a[0], Convert.ToInt32(1));
            }
            return(result);
        }
Пример #28
0
        public IList <TrilhaNivel> ObterTrilhasNivelPorTrilha(Trilha trilha)
        {
            ICriteria criteria = repositorio.session.CreateCriteria(typeof(ViewTrilha), "vw");

            criteria = criteria.Add(Expression.Eq("TrilhaOrigem", trilha));

            ProjectionList projList = Projections.ProjectionList();

            projList.Add(Projections.Distinct(Projections.Property <ViewTrilha>(d => d.TrilhaNivelOrigem)));
            criteria.SetProjection(projList);
            return(criteria.List <TrilhaNivel>());
        }
Пример #29
0
        public IDictionary <string, IList <string> > getDegreeWithBatch()
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StudentManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria subCriteria = DetachedCriteria.For <Entity_Student>();

            subCriteria.SetProjection(Projections.Distinct(Projections.Property("myConfigObj.currentBatch")));

            DetachedCriteria mainCriteria   = DetachedCriteria.For <Entity_Student>();
            ProjectionList   projectionList = Projections.ProjectionList();

            projectionList.Add(Projections.Distinct(Projections.Property("myConfigObj.currentDegree")));
            projectionList.Add(Projections.Property("myConfigObj.currentBatch"));
            mainCriteria.SetProjection(projectionList);
            mainCriteria.Add(Subqueries.Exists(subCriteria));

            IList resultList = persistence.findByCriteria(mainCriteria);

            if (resultList != null && resultList.Count > 0)
            {
                IList <string> degreeList;
                IDictionary <string, IList <string> > batchDegreeMap = new Dictionary <string, IList <string> >();
                foreach (Object[] arr in resultList)
                {
                    string key   = arr[1].ToString();
                    string value = arr[0].ToString();
                    if (batchDegreeMap.ContainsKey(key))
                    {
                        batchDegreeMap[key].Add(value);
                    }
                    else
                    {
                        degreeList = new List <string>();
                        degreeList.Add(value);
                        batchDegreeMap.Add(key, degreeList);
                    }
                }
                return(batchDegreeMap);
            }
            return(null);
        }
Пример #30
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationDetail));

        criteria.CreateAlias("Location", "l");

        #region Customize
        criteria.Add(Expression.Not(Expression.Eq("Qty", new decimal(0))));
        SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        #endregion

        #region Select Parameters
        CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", this._criteriaParam);
        CriteriaHelper.SetLocationCriteria(criteria, "Location.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("Qty").As("Qty"))
                                        .Add(Projections.GroupProperty("Item").As("Item"));

        if (this._criteriaParam.ClassifiedParty)
        {
            projectionList.Add(Projections.GroupProperty("l.Region").As("Region"));
        }
        if (this._criteriaParam.ClassifiedLocation)
        {
            projectionList.Add(Projections.GroupProperty("Location").As("Location"));
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationDetail)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }