Esempio n. 1
0
        public List <LACK2> GetCompletedByParam(Lack2GetByParamInput input)
        {
            Expression <Func <LACK2, bool> > queryFilter = c => c.STATUS == Enums.DocumentStatus.Completed;

            if (!string.IsNullOrEmpty((input.PlantId)))
            {
                queryFilter = queryFilter.And(c => c.LEVEL_PLANT_ID == input.PlantId);
            }
            if (!string.IsNullOrEmpty((input.Creator)))
            {
                queryFilter = queryFilter.And(c => c.CREATED_BY == input.Creator);
            }
            if (!string.IsNullOrEmpty((input.Poa)))
            {
                queryFilter = queryFilter.And(c => c.APPROVED_BY == input.Poa);
            }

            if (input.UserRole != Enums.UserRole.Administrator && input.UserRole != Enums.UserRole.Controller)
            {
                queryFilter = queryFilter.And(c => input.PlantList.Contains(c.LEVEL_PLANT_ID));
            }

            Func <IQueryable <LACK2>, IOrderedQueryable <LACK2> > orderBy = null;

            if (!string.IsNullOrEmpty(input.SortOrderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <LACK2>(input.SortOrderColumn));
            }

            var dbData = _repository.Get(queryFilter, orderBy, includeTables);

            return(dbData == null ? null : dbData.ToList());
        }
Esempio n. 2
0
        private List <REVERSAL> GetReversalData(Expression <Func <REVERSAL, bool> > queryFilter, string orderColumn)
        {
            Func <IQueryable <REVERSAL>, IOrderedQueryable <REVERSAL> > orderBy = null;

            if (!string.IsNullOrEmpty(orderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <REVERSAL>(orderColumn));
            }

            var dbData = _repository.Get(queryFilter);

            return(dbData.ToList());
        }
Esempio n. 3
0
        public List <PRODUCTION> GetFactAllByParam(ProductionGetByParamInput input)
        {
            Expression <Func <PRODUCTION, bool> > queryFilter = PredicateHelper.True <PRODUCTION>();

            if (!string.IsNullOrEmpty(input.Company))
            {
                queryFilter = queryFilter.And(c => c.COMPANY_CODE == input.Company);
            }
            if (!string.IsNullOrEmpty(input.Plant))
            {
                queryFilter = queryFilter.And(c => c.WERKS == input.Plant);
            }
            if (!string.IsNullOrEmpty(input.ProoductionDate))
            {
                var dt = Convert.ToDateTime(input.ProoductionDate);
                queryFilter = queryFilter.And(c => c.PRODUCTION_DATE == dt);
            }
            if (input.Month > 0)
            {
                queryFilter = queryFilter.And(c => c.PRODUCTION_DATE.Month == input.Month);
            }
            if (input.Year > 0)
            {
                queryFilter = queryFilter.And(c => c.PRODUCTION_DATE.Year == input.Year);
            }
            if (!string.IsNullOrEmpty(input.UserId))
            {
                var listUserPlant = _userPlantBll.GetPlantByUserId(input.UserId);

                var listPoaPlant = _poaMapBll.GetPlantByPoaId(input.UserId);

                queryFilter = queryFilter.And(c => listUserPlant.Contains(c.WERKS) || listPoaPlant.Contains(c.WERKS));
            }

            Func <IQueryable <PRODUCTION>, IOrderedQueryable <PRODUCTION> > orderBy = null;
            {
                if (!string.IsNullOrEmpty(input.ShortOrderColumn))
                {
                    orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <PRODUCTION>(input.ShortOrderColumn));
                }

                var dbData = _repository.Get(queryFilter, orderBy);
                if (dbData == null)
                {
                    throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
                }
                var mapResult = dbData.ToList();

                return(mapResult);
            }
        }
Esempio n. 4
0
        public List <Pbck1QuotaDto> GetByParam(Pbck1QuotaGetByParamInput input)
        {
            Expression <Func <PBCK1_QUOTA, bool> > queryFilter = PredicateHelper.True <PBCK1_QUOTA>();

            if (!string.IsNullOrEmpty(input.CompanyCode))
            {
                queryFilter = queryFilter.And(c => c.PBCK1 != null && c.PBCK1.NPPBKC_BUKRS == input.CompanyCode);
            }

            if (input.YearFrom.HasValue)
            {
                queryFilter =
                    queryFilter.And(
                        c =>
                        c.PBCK1 != null && c.PBCK1.PERIOD_FROM.HasValue &&
                        c.PBCK1.PERIOD_FROM.Value.Year >= input.YearFrom.Value);
            }

            if (input.YearTo.HasValue)
            {
                queryFilter =
                    queryFilter.And(
                        c =>
                        c.PBCK1 != null && c.PBCK1.PERIOD_TO.HasValue &&
                        c.PBCK1.PERIOD_TO.Value.Year >= input.YearTo.Value);
            }

            if (!string.IsNullOrEmpty(input.NppbkcId))
            {
                queryFilter = queryFilter.And(c => c.PBCK1 != null && c.PBCK1.NPPBKC_ID == input.NppbkcId);
            }

            Func <IQueryable <PBCK1_QUOTA>, IOrderedQueryable <PBCK1_QUOTA> > orderBy = null;

            if (!string.IsNullOrEmpty(input.SortOrderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <PBCK1_QUOTA>(input.SortOrderColumn));
            }

            var dbData = _quotaRepository.Get(queryFilter, orderBy, includeTables);

            return(Mapper.Map <List <Pbck1QuotaDto> >(dbData.ToList()));
        }
Esempio n. 5
0
        public List <LACK1> GetCompletedDocumentByParam(Lack1GetByParamInput input)
        {
            includeTables += ", LACK1_PLANT";
            Expression <Func <LACK1, bool> > queryFilter = c => (int)c.STATUS >= (int)Core.Enums.DocumentStatus.Completed;

            queryFilter = queryFilter.And(ProcessQueryFilter(input));

            Func <IQueryable <LACK1>, IOrderedQueryable <LACK1> > orderBy = null;

            if (!string.IsNullOrEmpty(input.SortOrderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <LACK1>(input.SortOrderColumn));
            }

            if (input.UserRole == Enums.UserRole.POA)
            {
                queryFilter = queryFilter.And(c => input.ListNppbkc.Contains(c.NPPBKC_ID));
            }
            else if (input.UserRole == Enums.UserRole.Administrator)
            {
                queryFilter = queryFilter.And(c => c.LACK1_LEVEL != null);
            }
            else if (input.UserRole == Enums.UserRole.Controller)
            {
                queryFilter = queryFilter.And(c => c.STATUS == Enums.DocumentStatus.Completed);
            }
            else
            {
                queryFilter = queryFilter.And(c => (input.ListUserPlant.Contains(c.LACK1_PLANT.FirstOrDefault().PLANT_ID) && c.LACK1_LEVEL == Enums.Lack1Level.Plant) ||
                                              (input.ListNppbkc.Contains(c.NPPBKC_ID) && c.LACK1_LEVEL == Enums.Lack1Level.Nppbkc));
            }

            var dbData = _repository.Get(queryFilter, orderBy, includeTables);

            if (dbData == null)
            {
                throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
            }

            return(dbData.ToList());
        }
Esempio n. 6
0
        public List <LACK1> GetAllByParam(Lack1GetByParamInput input)
        {
            includeTables += ", LACK1_PLANT";
            Expression <Func <LACK1, bool> > queryFilter = c => c.LACK1_LEVEL == input.Lack1Level;

            queryFilter = queryFilter.And(ProcessQueryFilter(input));

            Func <IQueryable <LACK1>, IOrderedQueryable <LACK1> > orderBy = c => c.OrderByDescending(l => l.LACK1_ID);

            if (!string.IsNullOrEmpty(input.SortOrderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <LACK1>(input.SortOrderColumn));
            }

            var dbData = _repository.Get(queryFilter, orderBy, includeTables);

            if (dbData == null)
            {
                throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
            }
            return(dbData.ToList());
        }
Esempio n. 7
0
        public List <ProductionDto> GetAllByParam(ProductionGetByParamInput input)
        {
            Expression <Func <PRODUCTION, bool> > queryFilter = PredicateHelper.True <PRODUCTION>();

            if (!string.IsNullOrEmpty(input.Company))
            {
                queryFilter = queryFilter.And(c => c.COMPANY_CODE == input.Company);
            }
            if (!string.IsNullOrEmpty(input.Plant))
            {
                queryFilter = queryFilter.And(c => c.WERKS == input.Plant);
            }
            if (!string.IsNullOrEmpty(input.ProoductionDate))
            {
                var dt = Convert.ToDateTime(input.ProoductionDate);
                queryFilter = queryFilter.And(c => c.PRODUCTION_DATE == dt);
            }
            if (input.UserRole != Core.Enums.UserRole.Administrator)
            {
                queryFilter = queryFilter.And(c => input.ListUserPlants.Contains(c.WERKS));
            }

            Func <IQueryable <PRODUCTION>, IOrderedQueryable <PRODUCTION> > orderBy = null;
            {
                if (!string.IsNullOrEmpty(input.ShortOrderColumn))
                {
                    orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <PRODUCTION>(input.ShortOrderColumn));
                }

                var dbData = _repository.Get(queryFilter, orderBy);
                if (dbData == null)
                {
                    throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
                }
                var mapResult = Mapper.Map <List <ProductionDto> >(dbData.ToList());

                return(mapResult);
            }
        }
Esempio n. 8
0
        public List <USER> GetUsers(UserInput input)
        {
            Expression <Func <USER, bool> > queryFilter = PredicateHelper.True <USER>();

            if (!string.IsNullOrEmpty(input.UserName))
            {
                queryFilter = queryFilter.And(s => s.USER_ID.Contains(input.UserName));
            }

            if (!string.IsNullOrEmpty(input.FirstName))
            {
                queryFilter = queryFilter.And(s => s.FIRST_NAME.Contains(input.FirstName));
            }

            if (!string.IsNullOrEmpty(input.LastName))
            {
                queryFilter = queryFilter.And(s => s.LAST_NAME.Contains(input.LastName));
            }



            Func <IQueryable <USER>, IOrderedQueryable <USER> > orderBy = null;

            if (!string.IsNullOrEmpty(input.SortOrderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <USER>(input.SortOrderColumn)) as IOrderedQueryable <USER>;
            }

            var rc = _repository.Get(queryFilter, orderBy);

            if (rc == null)
            {
                throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
            }

            return(rc.ToList());
        }
Esempio n. 9
0
        public List <LACK2> GetByParam(Lack2GetByParamInput input)
        {
            Expression <Func <LACK2, bool> > queryFilter = PredicateHelper.True <LACK2>();

            if (!string.IsNullOrEmpty((input.NppbKcId)))
            {
                queryFilter = queryFilter.And(c => c.NPPBKC_ID == input.NppbKcId);
            }
            if (!string.IsNullOrEmpty((input.PlantId)))
            {
                queryFilter = queryFilter.And(c => c.LEVEL_PLANT_ID == input.PlantId);
            }
            if (!string.IsNullOrEmpty((input.Creator)))
            {
                queryFilter = queryFilter.And(c => c.CREATED_BY == input.Creator);
            }
            if (!string.IsNullOrEmpty((input.Poa)))
            {
                queryFilter = queryFilter.And(c => c.APPROVED_BY == input.Poa);
            }

            if (input.SubmissionDate.HasValue)
            {
                var date          = input.SubmissionDate.Value.Day;
                var month         = input.SubmissionDate.Value.Month;
                var year          = input.SubmissionDate.Value.Year;
                var dateToCompare = new DateTime(year, month, date);
                queryFilter = queryFilter.And(c => c.SUBMISSION_DATE.Equals(dateToCompare));
            }

            queryFilter = input.IsOpenDocList ? queryFilter.And(c => c.STATUS != Enums.DocumentStatus.Completed) : queryFilter.And(c => c.STATUS == Enums.DocumentStatus.Completed);

            //switch (input.UserRole)
            //{
            //case Enums.UserRole.POA:
            //    queryFilter = queryFilter.And(c => (c.CREATED_BY == input.UserId
            //        || (c.STATUS != Enums.DocumentStatus.Draft
            //        && input.NppbkcList.Contains(c.NPPBKC_ID))));
            //    break;
            //case Enums.UserRole.Manager:
            //    queryFilter =
            //        queryFilter.And(
            //            c =>
            //                c.STATUS != Enums.DocumentStatus.Draft &&
            //                c.STATUS != Enums.DocumentStatus.WaitingForApproval &&
            //                input.DocumentNumberList.Contains(c.LACK2_NUMBER));
            //    break;
            //    default:
            //        queryFilter = queryFilter.And(c => c.CREATED_BY == input.UserId);
            //        break;
            //}

            if (input.UserRole != Enums.UserRole.Administrator && input.UserRole != Enums.UserRole.Controller)
            {
                queryFilter = queryFilter.And(c => input.PlantList.Contains(c.LEVEL_PLANT_ID));
            }


            Func <IQueryable <LACK2>, IOrderedQueryable <LACK2> > orderBy = null;

            if (!string.IsNullOrEmpty(input.SortOrderColumn))
            {
                orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <LACK2>(input.SortOrderColumn));
            }

            var dbData = _repository.Get(queryFilter, orderBy, includeTables);

            return(dbData == null ? null : dbData.ToList());
        }
Esempio n. 10
0
        public List <WasteDto> GetAllByParam(WasteGetByParamInput input)
        {
            Expression <Func <WASTE, bool> > queryFilter = PredicateHelper.True <WASTE>();

            if (!string.IsNullOrEmpty(input.Company))
            {
                queryFilter = queryFilter.And(c => c.COMPANY_CODE == input.Company);
            }
            if (!string.IsNullOrEmpty(input.Plant))
            {
                queryFilter = queryFilter.And(c => c.WERKS == input.Plant);
            }
            if (!string.IsNullOrEmpty(input.WasteProductionDate))
            {
                var dt = Convert.ToDateTime(input.WasteProductionDate);
                queryFilter = queryFilter.And(c => c.WASTE_PROD_DATE == dt);
            }
            if (input.Month > 0)
            {
                queryFilter = queryFilter.And(c => c.WASTE_PROD_DATE.Month == input.Month);
            }
            if (input.Year > 0)
            {
                queryFilter = queryFilter.And(c => c.WASTE_PROD_DATE.Year == input.Year);
            }
            if (!string.IsNullOrEmpty(input.UserId))
            {
                if (input.UserRole != Core.Enums.UserRole.Administrator)
                {
                    queryFilter = queryFilter.And(c => input.ListUserPlants.Contains(c.WERKS));
                }
            }

            if (input.BeginingProductionDate.HasValue)
            {
                queryFilter = queryFilter.And(c => c.WASTE_PROD_DATE >= input.BeginingProductionDate.Value);
            }

            if (input.EndProductionDate.HasValue)
            {
                queryFilter = queryFilter.And(c => c.WASTE_PROD_DATE <= input.EndProductionDate.Value);
            }

            if (!string.IsNullOrEmpty(input.FaCode))
            {
                queryFilter = queryFilter.And(c => c.FA_CODE == input.FaCode);
            }

            Func <IQueryable <WASTE>, IOrderedQueryable <WASTE> > orderBy = null;
            {
                if (!string.IsNullOrEmpty(input.ShortOrderColumn))
                {
                    orderBy = c => c.OrderBy(OrderByHelper.GetOrderByFunction <WASTE>(input.ShortOrderColumn));
                }

                var dbData = _repository.Get(queryFilter, orderBy);
                if (dbData == null)
                {
                    throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
                }
                var mapResult = Mapper.Map <List <WasteDto> >(dbData.ToList());

                return(mapResult);
            }
        }