Esempio n. 1
0
        public async Task <PageListUtility <Article_Dto> > SearchArticleWithPaginations(PaginationParams param, string articleCateID, string articleName)
        {
            var articleCateList = _articleCategoryRepository.FindAll();
            var articleList     = _articleRepository.FindAll();

            if (!string.IsNullOrEmpty(articleCateID))
            {
                articleCateList = articleCateList.Where(x => x.Article_Cate_ID == articleCateID);
            }
            if (!string.IsNullOrEmpty(articleName))
            {
                articleList = articleList.Where(x => x.Article_Name == articleName);
            }

            var query = articleCateList.Join(
                articleList,
                x => x.Article_Cate_ID,
                y => y.Article_Cate_ID,
                (x, y) => new Article_Dto
            {
                Article_Cate_ID = y.Article_Cate_ID,
                Alias           = y.Alias,
                Article_ID      = y.Article_ID,
                Article_Name    = y.Article_Name,
                Content         = y.Content,
                Files           = y.Files,
                Link            = y.Link,
                Status          = y.Status,
                Update_By       = y.Update_By,
                Update_Time     = y.Update_Time
            }).OrderByDescending(x => x.Article_Cate_ID).ThenBy(x => x.Article_ID);

            return(await PageListUtility <Article_Dto> .PageListAsync(query, param.PageNumber, param.PageSize));
        }
Esempio n. 2
0
        public async Task <PageListUtility <Employee> > GetAllEmployee(SortParams[] sortParams, PaginationParams paginationParams, string filter)
        {
            var data = _employeeRepository.FindAll();

            if (!string.IsNullOrEmpty(filter))
            {
                data = data.Where(x => x.Name.Contains(filter));
            }
            var orderedData = data.OrderBy(x => 0);

            foreach (var sort in sortParams)
            {
                switch (sort.sortBy)
                {
                case nameof(Employee.Name):
                    orderedData = sort.sortType == SortBy.Asc ? orderedData.ThenBy(x => x.Name) : orderedData.ThenByDescending(x => x.Name);
                    break;

                case nameof(Employee.Address):
                    orderedData = sort.sortType == SortBy.Asc ? orderedData.ThenBy(x => x.Address) : orderedData.ThenByDescending(x => x.Address);
                    break;

                default:
                    break;
                }
            }

            return(await PageListUtility <Employee> .PageListAsync(orderedData, paginationParams.PageNumber, paginationParams.PageSize));
        }
Esempio n. 3
0
        public async Task <PageListUtility <User_Detail_Dto> > Search(PaginationParams param, string text)
        {
            var usersQuery = _userRepository
                             .FindAll(x => x.Factory_ID.ToLower().Contains(text.ToLower()) || x.User_Account.ToLower().Contains(text.ToLower()) || x.User_Name.ToLower().Contains(text.ToLower()) || x.Email.ToLower().Contains(text.ToLower()))
                             .OrderByDescending(x => x.Update_Time)
                             .ProjectTo <User_Detail_Dto>(_mapperConfiguration);

            return(await PageListUtility <User_Detail_Dto> .PageListAsync(usersQuery, param.PageNumber, param.PageSize));
        }
Esempio n. 4
0
        public async Task <PageListUtility <User_Detail_Dto> > GetUserWithPaginations(PaginationParams param)
        {
            var usersQuery = _userRepository
                             .FindAll()
                             .OrderByDescending(x => x.Update_Time)
                             .ProjectTo <User_Detail_Dto>(_mapperConfiguration);

            return(await PageListUtility <User_Detail_Dto> .PageListAsync(usersQuery, param.PageNumber, param.PageSize));
        }
Esempio n. 5
0
        public override async Task <PageListUtility <PDCDto> > Search(string keyword, PaginationParams parms)
        {
            var query = _repo.FindAll();

            if (!String.IsNullOrEmpty(keyword))
            {
                query = query.Where(x => x.PDCName.Contains(keyword) || x.PDCCode.Contains(keyword));
            }

            return(await PageListUtility <PDCDto> .PageListAsync(query.AsNoTracking().ProjectTo <PDCDto>(_configuration), parms.PageNumber, parms.PageSize));
        }
Esempio n. 6
0
        public async Task <PageListUtility <ProductCategory_Dto> > GetProductCategoryWithPaginations(PaginationParams param, string text)
        {
            var data = _productCategoryRepository.FindAll().ProjectTo <ProductCategory_Dto>(_configuration).OrderByDescending(x => x.Update_Time);

            if (text != null)
            {
                data = data.Where(x => x.Product_Cate_Name.ToLower().Contains(text.ToLower()) ||
                                  x.Update_By.ToLower().Contains(text.ToLower()) ||
                                  x.Product_Cate_ID.ToLower().Contains(text.ToLower())).OrderByDescending(x => x.Update_Time);
            }
            return(await PageListUtility <ProductCategory_Dto> .PageListAsync(data, param.PageNumber, param.PageSize));
        }
Esempio n. 7
0
        public override async Task <PageListUtility <UserDto> > Search(string keyword, PaginationParams parms)
        {
            var queryData = _repo.FindAll();

            if (!String.IsNullOrEmpty(keyword))
            {
                queryData = queryData.Where(x => x.UserName.Contains(keyword.ToString()) ||
                                            x.EmpName.Contains(keyword.ToString()) ||
                                            x.UpdateBy.Contains(keyword.ToString()));
            }
            return(await PageListUtility <UserDto> .PageListAsync(queryData.AsNoTracking().ProjectTo <UserDto>(_configuration).OrderByDescending(x => x.UpdateDate), parms.PageNumber, parms.PageSize));
        }
        public async Task <PageListUtility <ArticleCategory_Dto> > GetArticleCategoryWithPaginations(PaginationParams param, string text, bool isPaging = true)
        {
            var data = _articleCategoryRepository.FindAll().ProjectTo <ArticleCategory_Dto>(_configuration).OrderByDescending(x => x.Update_Time);

            if (!string.IsNullOrEmpty(text))
            {
                data = data.Where(x => x.Article_Cate_Name.ToLower().Contains(text.ToLower()) ||
                                  x.Update_By.ToLower().Contains(text.ToLower()) ||
                                  x.Article_Cate_ID.ToLower().Contains(text.ToLower())).OrderByDescending(x => x.Update_Time);
            }
            return(await PageListUtility <ArticleCategory_Dto> .PageListAsync(data, param.PageNumber, param.PageSize, isPaging));
        }
Esempio n. 9
0
        public async Task <PageListUtility <Product_Dto> > GetProductWithPaginations(PaginationParams param, string text)
        {
            var data = _productRepository.FindAll().ProjectTo <Product_Dto>(_configuration).OrderByDescending(x => x.Product_Cate_ID).ThenBy(x => x.Product_ID);

            if (!string.IsNullOrEmpty(text))
            {
                data = data.Where(x => x.Product_ID.ToString().ToLower().Contains(text.ToLower()) ||
                                  x.Product_Name.ToLower().Contains(text.ToLower()) ||
                                  x.Update_By.ToLower().Contains(text.ToLower()) ||
                                  x.Product_Cate_ID.ToLower().Contains(text.ToLower())
                                  ).OrderByDescending(x => x.Product_Cate_ID).ThenBy(x => x.Product_ID);
            }
            return(await PageListUtility <Product_Dto> .PageListAsync(data, param.PageNumber, param.PageSize));
        }
Esempio n. 10
0
        public async Task <PageListUtility <Product_Dto> > SearchProductWithPaginations(PaginationParams param, string productCateID, string productName, bool isPaging = true)
        {
            var productCateList = _productCategoryRepository.FindAll();
            var productList     = _productRepository.FindAll();

            if (!string.IsNullOrEmpty(productCateID))
            {
                productCateList = productCateList.Where(x => x.Product_Cate_ID == productCateID);
            }
            if (!string.IsNullOrEmpty(productName))
            {
                productList = productList.Where(x => x.Product_Name == productName);
            }

            var query = productCateList.Join(
                productList,
                x => x.Product_Cate_ID,
                y => y.Product_Cate_ID,
                (x, y) => new Product_Dto {
                Amount          = y.Amount,
                Content         = y.Content,
                Discount        = y.Discount,
                From_Date_Sale  = y.From_Date_Sale,
                Hot_Sale        = y.Hot_Sale,
                IsSale          = y.IsSale,
                New             = y.New,
                Price           = y.Price,
                Price_Sale      = y.Price_Sale,
                Product_Cate_ID = y.Product_Cate_ID,
                Product_ID      = y.Product_ID,
                Product_Name    = y.Product_Name,
                Status          = y.Status,
                Time_Sale       = y.Time_Sale,
                To_Date_Sale    = y.To_Date_Sale,
                Update_By       = y.Update_By,
                Update_Time     = y.Update_Time,
                FileImages      = y.FileImages,
                FileVideos      = y.FileVideos
            }).OrderByDescending(x => x.Update_Time);

            return(await PageListUtility <Product_Dto> .PageListAsync(query, param.PageNumber, param.PageSize, isPaging));
        }
Esempio n. 11
0
        public async Task <PageListUtility <ChartReason> > GetDataChart(string factory, string building, string machine, string machine_type, string shift, string date, int page = 1)
        {
            if (factory.Trim() == "ALL")
            {
                return(null);
            }
            else
            {
                var machineFirst = new M_ActionTimeForOEE();
                var dataAll      = await _repoDownTimeReson.GetAll()
                                   .Where(x => x.shift_date == Convert.ToDateTime(date))
                                   .ToListAsync();

                if (shift.Trim() != "0")
                {
                    dataAll = dataAll.Where(x => x.shift_id.ToString() == shift.ToString()).ToList();
                }
                if (factory != "ALL")
                {
                    dataAll      = dataAll.Where(x => x.factory_id.Trim() == factory.Trim()).ToList();
                    machineFirst = dataAll.FirstOrDefault();
                }
                if (building != "ALL")
                {
                    dataAll = dataAll.Where(x => x.factory_id.Trim() == factory.Trim() &&
                                            x.building_id.Trim() == building.Trim()).ToList();
                    machineFirst = dataAll.FirstOrDefault();
                }

                if (machine_type != "ALL")
                {
                    var machines = await _serverCommon.ListMachineID(factory, building, machine_type);

                    dataAll = dataAll.Where(x => x.factory_id.Trim() == factory.Trim() &&
                                            x.building_id.Trim() == building.Trim() &&
                                            machines.Contains(x.machine_id.Trim())).ToList();
                    machineFirst = dataAll.Where(x => x.factory_id.Trim() == factory.Trim() &&
                                                 x.building_id.Trim() == building.Trim() &&
                                                 machines.Contains(x.machine_id.Trim())).FirstOrDefault();
                }
                if (machine != "ALL")
                {
                    dataAll = dataAll.Where(x => x.factory_id.Trim() == factory.Trim() &&
                                            x.building_id.Trim() == building.Trim() &&
                                            x.machine_id.Trim() == machine.Trim()).ToList();
                    machineFirst = dataAll.FirstOrDefault();
                }
                if (dataAll.Count() != 0)
                {
                    DbFunctions dfunc       = null;
                    DateTime    day         = Convert.ToDateTime(date);
                    var         machineName = machineFirst.machine_id;
                    var         data        = dataAll.Where(x => x.machine_id.Trim() == machineFirst.machine_id.Trim()).Select(x => new ChartReason()
                    {
                        id          = x.id,
                        title       = x.is_work_time == true ? "RUN" : "IDLE",
                        start_time  = x.start_time,
                        end_time    = x.end_time,
                        diffTime    = SqlServerDbFunctionsExtensions.DateDiffMinute(dfunc, x.start_time, x.end_time),
                        factory_id  = x.factory_id,
                        machine_id  = x.machine_id,
                        building_id = x.building_id,
                        shift_id    = x.shift_id.ToString(),
                        shift_date  = x.shift_date,
                        isEdit      = false,
                    }).OrderByDescending(x => x.title).ToList();
                    var dataTable = data.Where(x => x.title == "IDLE").ToList();
                    return(await PageListUtility <ChartReason> .PageListAsyncChartReason(data, dataTable, machineName, page));
                }
                else
                {
                    return(null);
                }
            }
        }