コード例 #1
0
        internal List <MaterialPriceListDataView> GetAllMaterialPriceList(ICollection <AbstractSearch> searchCriteria,
                                                                          DateTime?dateActiveTo,
                                                                          string sortExpression, string sortDirection)
        {
            List <MaterialPriceListDataView> listView = new List <MaterialPriceListDataView>();

            listView = (from mpl in this.dbContext.MaterialPriceLists
                        orderby mpl.DateFrom ascending
                        where (dateActiveTo.HasValue ?
                               ((!mpl.DateTo.HasValue && mpl.DateFrom <= dateActiveTo.Value) ||
                                (mpl.DateTo.HasValue && mpl.DateFrom <= dateActiveTo.Value && mpl.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        select new MaterialPriceListDataView
            {
                idMaterialPriceList = mpl.idMaterialPriceList,
                LME = mpl.LME,
                Premium = mpl.Premium,
                DateFrom = mpl.DateFrom,
                DateTo = mpl.DateTo
            }).ApplySearchCriterias(searchCriteria).ToList();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "DateFrom";
            }

            listView = OrderByHelper.OrderBy <MaterialPriceListDataView>(listView, sortExpression, sortDirection).ToList <MaterialPriceListDataView>();

            return(listView);
        }
コード例 #2
0
        internal List <ProductivityAndScrapDataView> GetAllProductivityAndScrapList(ICollection <AbstractSearch> searchCriteria,
                                                                                    DateTime?dateActiveTo,
                                                                                    string sortExpression, string sortDirection)
        {
            List <ProductivityAndScrapDataView> listView = new List <ProductivityAndScrapDataView>();

            listView = (from ps in this.dbContext.ProductivityAndScraps
                        orderby ps.DateFrom ascending
                        where (dateActiveTo.HasValue ?
                               ((!ps.DateTo.HasValue && ps.DateFrom <= dateActiveTo.Value) ||
                                (ps.DateTo.HasValue && ps.DateFrom <= dateActiveTo.Value && ps.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        select new ProductivityAndScrapDataView
            {
                idProductivityAndScrap = ps.idProductivityAndScrap,
                DateFrom = ps.DateFrom,
                DateTo = ps.DateTo
            }).ApplySearchCriterias(searchCriteria).ToList();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "DateFrom";
            }

            listView = OrderByHelper.OrderBy <ProductivityAndScrapDataView>(listView, sortExpression, sortDirection).ToList <ProductivityAndScrapDataView>();

            return(listView);
        }
コード例 #3
0
 public ActionResult List(Guid webApplicationId, int pageIndex = 1, int pageSize = 10)
 {
     try
     {
         if (webApplicationId == Guid.Empty)
         {
             throw new BaseException("webApplicationId不能为空");
         }
         var orderBys = OrderByHelper.Create().Desc("OpenId");
         var where = Where.Create().Eq("WebApplicationId", webApplicationId);
         var listResult = this.IWeiXinQRCodePromotionActivityAccountService.Page(orderBys, where, pageIndex, pageSize);
         foreach (var item in listResult.Data)
         {
             item.LoadWeiXinAccount();
         }
         return(this.JsonSuccessGenericPageExecResult(listResult));
     }
     catch (BaseException ex)
     {
         return(this.JsonFailureGenericPageExecResult(ex));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #4
0
ファイル: DiePriceListBL.cs プロジェクト: borisov90/Projects
        internal List <DiePriceListDataView> GetAllDiePriceList(ICollection <AbstractSearch> searchCriteria,
                                                                DateTime?dateActiveTo,
                                                                string sortExpression, string sortDirection)
        {
            List <DiePriceListDataView> listView = new List <DiePriceListDataView>();

            listView = (from dpl in this.dbContext.DiePriceLists
                        join kvV in this.dbContext.KeyValues on dpl.idVendor equals kvV.idKeyValue
                        where (dateActiveTo.HasValue ?
                               ((!dpl.DateTo.HasValue && dpl.DateFrom <= dateActiveTo.Value) ||
                                (dpl.DateTo.HasValue && dpl.DateFrom <= dateActiveTo.Value && dpl.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        orderby kvV.Name ascending, dpl.DateFrom ascending
                        select new DiePriceListDataView
            {
                idDiePriceList = dpl.idDiePriceList,
                VendorName = kvV.Name,
                idVendor = dpl.idVendor,
                DateFrom = dpl.DateFrom,
                DateTo = dpl.DateTo
            }).ApplySearchCriterias(searchCriteria).ToList <DiePriceListDataView>();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "VendorName, DateFrom";
            }

            listView = OrderByHelper.OrderBy <DiePriceListDataView>(listView, sortExpression, sortDirection).ToList <DiePriceListDataView>();

            return(listView);
        }
コード例 #5
0
        internal List <SAPDataDataView> GetAllSAPData(ICollection <AbstractSearch> searchCriteria,
                                                      DateTime?dateActiveTo,
                                                      string sortExpression, string sortDirection)
        {
            List <SAPDataDataView> listView = new List <SAPDataDataView>();

            listView = (from sd in this.dbContext.SAPDatas
                        where (dateActiveTo.HasValue ?
                               ((!sd.DateTo.HasValue && sd.DateFrom <= dateActiveTo.Value) ||
                                (sd.DateTo.HasValue && sd.DateFrom <= dateActiveTo.Value && sd.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        orderby sd.DateFrom ascending
                        select new SAPDataDataView
            {
                idSAPData = sd.idSAPData,
                DateFrom = sd.DateFrom,
                DateTo = sd.DateTo
            }).ApplySearchCriterias(searchCriteria).ToList <SAPDataDataView>();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "DateFrom";
            }

            listView = OrderByHelper.OrderBy <SAPDataDataView>(listView, sortExpression, sortDirection).ToList <SAPDataDataView>();

            return(listView);
        }
コード例 #6
0
        internal List <AverageOutturnOverTimeDataView> GetAllAverageOutturnOverTimeDataView(ICollection <AbstractSearch> searchCriteria,
                                                                                            DateTime?dateActiveTo,
                                                                                            string sortExpression, string sortDirection)
        {
            List <AverageOutturnOverTimeDataView> listView = new List <AverageOutturnOverTimeDataView>();

            listView = (from mpl in this.dbContext.AverageOutturnOverTimes
                        orderby mpl.DateFrom ascending
                        where (dateActiveTo.HasValue ?
                               ((!mpl.DateTo.HasValue && mpl.DateFrom <= dateActiveTo.Value) ||
                                (mpl.DateTo.HasValue && mpl.DateFrom <= dateActiveTo.Value && mpl.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        select new AverageOutturnOverTimeDataView
            {
                idAverageOutturnOverTime = mpl.idAverageOutturnOverTime,
                ValueOfPressSMS1 = mpl.ValueOfPressSMS1,
                ValueOfPressSMS2 = mpl.ValueOfPressSMS2,
                ValueOfPressBREDA = mpl.ValueOfPressBREDA,
                ValueOfPressFARREL = mpl.ValueOfPressFARREL,
                DateFrom = mpl.DateFrom,
                DateTo = mpl.DateTo
            }).ApplySearchCriterias(searchCriteria).ToList();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "DateFrom";
            }

            listView = OrderByHelper.OrderBy <AverageOutturnOverTimeDataView>(listView, sortExpression, sortDirection).ToList <AverageOutturnOverTimeDataView>();

            return(listView);
        }
コード例 #7
0
 private void HandleOrderByClause(SelectStatement selectStatement)
 {
     if (selectStatement.OrderByClause != null)
     {
         _stages.Add(OrderByHelper.GetOrderByStage(LastStage, selectStatement.OrderByClause, _visitorMetadata, _usedProperties));
     }
 }
コード例 #8
0
        public IEnumerable <TEntity> Buscar(Expression <Func <TEntity, bool> > condition, string orderBy = "", string sortDirection = "", int take = 0, int skip = 0)
        {
            var query = _contexto.Set <TEntity>().Where(condition);//

            if (!string.IsNullOrEmpty(orderBy))
            {
                if (!string.IsNullOrEmpty(sortDirection))
                {
                    if (sortDirection == "asc")
                    {
                        query = OrderByHelper.OrderBy(query, orderBy);
                    }
                    else
                    {
                        query = OrderByHelper.OrderByDescending(query, orderBy);
                    }

                    if (take > 0)
                    {
                        query = query.Take(take);
                    }
                    if (skip > 0)
                    {
                        query = query.Skip(skip);
                    }
                }
            }
            return(query.AsNoTracking().ToList());
        }
コード例 #9
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());
        }
コード例 #10
0
        public SearchResult <ItemMonitoramentoDTO> Buscar(Expression <Func <ItemMonitoramentoDTO, bool> > condition, string orderBy = "", string sortDirection = "", int take = 0, int skip = 0)
        {
            var query        = QueryBase().Where(condition);
            int totalRecords = query.Count();

            if (!string.IsNullOrEmpty(orderBy))
            {
                if (sortDirection == "asc")
                {
                    query = OrderByHelper.OrderBy(query, orderBy);
                }
                else
                {
                    query = OrderByHelper.OrderByDescending(query, orderBy);
                }

                if (take > 0)
                {
                    query = query.Take(take);
                }
                if (skip > 0)
                {
                    query = query.Skip(skip);
                }
            }



            return(new SearchResult <ItemMonitoramentoDTO>
            {
                Itens = query.ToList(),
                TotalRecords = totalRecords,
                RecordsPerPage = take
            });
        }
コード例 #11
0
        public void ValidateKeyValueListWithOrderByTermIsTrue_GivenValidDesiredOrderByElements()
        {
            string commaSeparatedOrderBy = "testTerm1,testTerm2_desc,testTerm3_asc";

            List <string> desiredOrderByTerms = new List <string>
            {
                "testTerm1",
                "testTerm2",
                "testTerm3"
            };

            var orderByHelper = new OrderByHelper();
            var convertedList = orderByHelper.ConvertCommaSeparateOrderByStringToKeyValuePairList(commaSeparatedOrderBy);

            try
            {
                orderByHelper.ValidateOrderByListOnlyContainsCertainElements(convertedList, desiredOrderByTerms);
            }
            catch (InvalidFormatException invalidFormatException)
            {
                Assert.True(false, $"Expected no Exception but an invalid formate exception was thrown with message '{invalidFormatException.Message}'");
            }

            Assert.True(true);
        }
コード例 #12
0
        internal List <CommissionsByAgentDataView> GetAllCommissionsByAgentsList(ICollection <AbstractSearch> searchCriteria,
                                                                                 DateTime?dateActiveTo,
                                                                                 string sortExpression, string sortDirection)
        {
            List <CommissionsByAgentDataView> listView = new List <CommissionsByAgentDataView>();

            listView = (from ca in this.dbContext.CommissionsByAgents
                        join kvA in this.dbContext.KeyValues on ca.idAgent equals kvA.idKeyValue
                        where (dateActiveTo.HasValue ?
                               ((!ca.DateTo.HasValue && ca.DateFrom <= dateActiveTo.Value) ||
                                (ca.DateTo.HasValue && ca.DateFrom <= dateActiveTo.Value && ca.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        orderby kvA.Name ascending, ca.DateFrom ascending
                        select new CommissionsByAgentDataView
            {
                idCommissionsByAgent = ca.idCommissionsByAgent,
                idAgent = ca.idAgent,
                AgentName = kvA.Name,
                FixedCommission = ca.FixedCommission,
                CommissionPercent = ca.CommissionPercent,
                DateFrom = ca.DateFrom,
                DateTo = ca.DateTo
            }).ApplySearchCriterias(searchCriteria).ToList <CommissionsByAgentDataView>();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "AgentName, DateFrom";
            }

            listView = OrderByHelper.OrderBy <CommissionsByAgentDataView>(listView, sortExpression, sortDirection).ToList <CommissionsByAgentDataView>();

            return(listView);
        }
コード例 #13
0
ファイル: AttachmentBL.cs プロジェクト: borisov90/Projects
        internal List <AttachmentDataView> GetAccountingAttachmentList(ICollection <AbstractSearch> searchCriteria, string sortExpression, string sortDirection)
        {
            List <AttachmentDataView> list = (from a in dbContext.Attachments
                                              join kvAttachmentType in dbContext.KeyValues on a.idAttachmentType equals kvAttachmentType.idKeyValue
                                              join u in dbContext.Users on a.idUser equals u.idUser
                                              join p in dbContext.Persons on u.idPerson equals p.idPerson
                                              select new AttachmentDataView
            {
                idAttachment = a.idAttachment,
                idAttachmentType = a.idAttachmentType,
                idModule = a.idModule,
                Description = a.Description,
                AttachmentDate = a.AttachmentDate,
                idUser = a.idUser,
                Title = p.Title,
                FirstName = p.FirstName,
                LastName = p.LastName,
                AttachmentTypeName = kvAttachmentType.Name,
                idAttachmentTypeKeyType = kvAttachmentType.idKeyType
            }).ApplySearchCriterias(searchCriteria).ToList();

            list = OrderByHelper.OrderBy <AttachmentDataView>(list, sortExpression, sortDirection).ToList <AttachmentDataView>();

            return(list);
        }
コード例 #14
0
        public void GetKeyValueListWithOrderByTerm_ExpectInvalidaFormatException_GivenErroneousDirectionalCommaSeparatedOrderByString()
        {
            string commaSeparatedOrderBy = "testTerm1_rubbish";

            var orderByHelper = new OrderByHelper();

            Assert.Throws <InvalidFormatException>(() => orderByHelper.ConvertCommaSeparateOrderByStringToKeyValuePairList(commaSeparatedOrderBy));
        }
コード例 #15
0
        internal List <DiePriceListDetailDataView> GetAllDiePriceListDetails(ICollection <AbstractSearch> searchCriteria,
                                                                             DateTime?dateActiveTo,
                                                                             string sortExpression, string sortDirection)
        {
            List <DiePriceListDetailDataView> listView = new List <DiePriceListDetailDataView>();

            listView = (from dpld in this.dbContext.DiePriceListDetails
                        join dpl in this.dbContext.DiePriceLists on dpld.idDiePriceList equals dpl.idDiePriceList
                        join kvV in this.dbContext.KeyValues on dpl.idVendor equals kvV.idKeyValue into grV
                        from subV in grV.DefaultIfEmpty()
                        join kvNmCav in this.dbContext.KeyValues on dpld.idNumberOfCavities equals kvNmCav.idKeyValue into grNmCav
                        from subNmCav in grNmCav.DefaultIfEmpty()
                        join kvPrCat in this.dbContext.KeyValues on dpld.idProfileCategory equals kvPrCat.idKeyValue into grPrCat
                        from subPrCat in grPrCat.DefaultIfEmpty()
                        join kvPrCompl in this.dbContext.KeyValues on dpld.idProfileComplexity equals kvPrCompl.idKeyValue into grPrCompl
                        from subPrCompl in grPrCompl.DefaultIfEmpty()
                        where (dateActiveTo.HasValue ?
                               ((!dpl.DateTo.HasValue && dpl.DateFrom <= dateActiveTo.Value) ||
                                (dpl.DateTo.HasValue && dpl.DateFrom <= dateActiveTo.Value && dpl.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        orderby dpl.DateFrom ascending
                        select new DiePriceListDetailDataView
            {
                idDiePriceListDetail = dpld.idDiePriceListDetail,
                idDiePriceList = dpl.idDiePriceList,
                VendorName = (subV != null ? subV.Name : string.Empty),
                idVendor = dpl.idVendor,
                DateFrom = dpl.DateFrom,
                DateTo = dpl.DateTo,
                idNumberOfCavities = dpld.idNumberOfCavities,
                NumberOfCavitiesName = (subNmCav != null ? subNmCav.Name : string.Empty),
                idProfileCategory = dpld.idProfileCategory,
                ProfileCategoryName = (subPrCat != null ? subPrCat.Name : string.Empty),
                idProfileComplexity = dpld.idProfileComplexity,
                ProfileComplexityName = (subPrCompl != null ? subPrCompl.Name : string.Empty),
                DimensionA = dpld.DimensionA,
                DimensionB = dpld.DimensionB,
                Price = dpld.Price,
                Lifespan = dpld.Lifespan
            }).ApplySearchCriterias(searchCriteria).ToList <DiePriceListDetailDataView>();



            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "VendorName, DimensionA, DimensionB, ProfileComplexityName, ProfileCategoryName, NumberOfCavitiesName";
            }

            listView = OrderByHelper.OrderBy <DiePriceListDetailDataView>(listView, sortExpression, sortDirection).ToList <DiePriceListDetailDataView>();

            return(listView);
        }
コード例 #16
0
        private ICypherQuery <TResult> CreateCypherQuery(IQuery <TAggregate> query)
        {
            var session = CreateFluentQuery();
            var cypher  = GetDataset(session, (TQuery)query);

            cypher = OrderByHelper <TResult, TAggregate> .OrderBy(cypher, query);

            cypher = cypher.Skip(query.Skip).Limit(query.Take);
            Log(cypher);
            return(cypher);
        }
コード例 #17
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());
        }
コード例 #18
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);
            }
        }
コード例 #19
0
 public void TestTransInsertAndQuery()
 {
     for (var i = 0; i < 200; i++)
     {
         var rnd = new Random();
         ServiceContext.IComClickService.Insert(new Entities.ComClickDto()
         {
             ID         = Guid.NewGuid(),
             Category   = "t",
             ClickCount = rnd.Next(1, 200)
         });
     }
     var list = ServiceContext.IComClickService.Top(10, 50, OrderByHelper.Create().Desc("ClickCount"));
     var kk   = 0;
 }
コード例 #20
0
        public void ValidateKeyValueListWithOrderByTermThrowsException_GivenInValidDesiredOrderByElements()
        {
            string commaSeparatedOrderBy = "testTerm1,testTerm2_desc,testTerm5_asc";

            List <string> desiredOrderByTerms = new List <string>
            {
                "testTerm1",
                "testTerm2",
                "testTerm3"
            };

            var orderByHelper = new OrderByHelper();
            var convertedList = orderByHelper.ConvertCommaSeparateOrderByStringToKeyValuePairList(commaSeparatedOrderBy);

            Assert.Throws <InvalidFormatException>(() => orderByHelper.ValidateOrderByListOnlyContainsCertainElements(convertedList, desiredOrderByTerms));
        }
コード例 #21
0
        public GenericPageResult <WeiXinQRCodePromotionActivityAccountPointsHistoryDto> Find(Guid webApplicationId, string openId, int pageIndex = 1, int pageSize = 10)
        {
            if (this.IValidatorTool.IsEmpty(openId))
            {
                throw new BaseException("openId不能为空");
            }
            if (webApplicationId == Guid.Empty)
            {
                throw new BaseException("webApplicationId不能为空");
            }
            var where = Where.Create().Eq("WebApplicationId", webApplicationId).Eq("OpenId", openId);
            var orderBy = OrderByHelper.Create().Desc("CreatedDate");
            var list    = this.Page(orderBy, where, pageIndex, pageSize);

            return(list);
        }
コード例 #22
0
        public void GetKeyValueListWithOrderByTermAndOrderDirection_GivenSingleCommaSeparatedOrderByString()
        {
            string commaSeparatedOrderBy = "testTerm1,testTerm2_desc,testTerm3_asc";

            var orderByHelper = new OrderByHelper();

            var convertedKeyValuePairList = orderByHelper.ConvertCommaSeparateOrderByStringToKeyValuePairList(commaSeparatedOrderBy);

            Assert.True(convertedKeyValuePairList[0].Key == "testTerm1", $"Expected first converted orderBy term key to be 'testTerm1' but actual value is {convertedKeyValuePairList[0].Key}");
            Assert.True(convertedKeyValuePairList[0].Value == "asc", $"Expected first covnerted orderBy term value to be 'asc' but actual value is {convertedKeyValuePairList[0].Key}");

            Assert.True(convertedKeyValuePairList[1].Key == "testTerm2", $"Expected second converted orderBy term key to be 'testTerm2' but actual value is {convertedKeyValuePairList[1].Key}");
            Assert.True(convertedKeyValuePairList[1].Value == "desc", $"Expected second covnerted orderBy term value to be 'desc' but actual value is {convertedKeyValuePairList[1].Key}");

            Assert.True(convertedKeyValuePairList[2].Key == "testTerm3", $"Expected third converted orderBy term key to be 'testTerm3' but actual value is {convertedKeyValuePairList[2].Key}");
            Assert.True(convertedKeyValuePairList[2].Value == "asc", $"Expected third covnerted orderBy term value to be 'asc' but actual value is {convertedKeyValuePairList[2].Key}");
        }
コード例 #23
0
        internal List <ProfileSettingDataView> GetProfilesList(ICollection <AbstractSearch> searchCriteria, string sortExpression, string sortDirection)
        {
            List <ProfileSettingDataView> listView = new List <ProfileSettingDataView>();

            listView = (from ps in this.dbContext.ProfileSettings
                        //Profile Complexity
                        join kvPrCom in this.dbContext.KeyValues on ps.idProfileComplexity equals kvPrCom.idKeyValue into grPrCom
                        from subPrCom in grPrCom.DefaultIfEmpty()
                        //Profile type
                        join kvPT in this.dbContext.KeyValues on ps.idProfileType equals kvPT.idKeyValue into grPT
                        from subPT in grPT.DefaultIfEmpty()
                        //Profile category
                        join kvPC in this.dbContext.KeyValues on ps.idProfileCategory equals kvPC.idKeyValue into grPC
                        from subPC in grPC.DefaultIfEmpty()

                        select new ProfileSettingDataView
            {
                idProfileSetting = ps.idProfileSetting,
                ProfileName = ps.ProfileName,
                idProfileType = ps.idProfileType,
                idProfileCategory = ps.idProfileCategory,
                idProfileComplexity = ps.idProfileComplexity,
                hasA = ps.hasA,
                hasB = ps.hasB,
                hasC = ps.hasC,
                hasD = ps.hasD,
                hasS = ps.hasS,
                DiameterFormula = ps.DiameterFormula,
                idCreateUser = ps.idCreateUser,
                dCreate = ps.dCreate,
                idModifyUser = ps.idModifyUser,
                dModify = ps.dModify,
                ImagePath = ps.ImagePath,

                //NumberOfCavitiesName    = (subNC != null ? subNC.Name : string.Empty),
                ProfileCategoryName = (subPC != null ? subPC.Name : string.Empty),
                ProfileTypeName = (subPT != null ? subPT.Name : string.Empty),
                ProfileComplexityName = (subPrCom != null ? subPrCom.Name : string.Empty),
            }
                        ).ApplySearchCriterias(searchCriteria).OrderBy(z => z.ProfileTypeName).ThenBy(z => z.ProfileCategoryName).ThenBy(z => z.ProfileComplexityName).ToList <ProfileSettingDataView>();

            listView = OrderByHelper.OrderBy <ProfileSettingDataView>(listView, sortExpression, sortDirection).ToList <ProfileSettingDataView>();

            return(listView);
        }
コード例 #24
0
        internal List <ProductivityAndScrapDetailDataView> GetAllProductivityAndScrapDetailList(ICollection <AbstractSearch> searchCriteria,
                                                                                                DateTime?dateActiveTo,
                                                                                                string sortExpression, string sortDirection)
        {
            List <ProductivityAndScrapDetailDataView> listView = new List <ProductivityAndScrapDetailDataView>();

            listView = (from psd in this.dbContext.ProductivityAndScrapDetails
                        join ps in this.dbContext.ProductivityAndScraps on psd.idProductivityAndScrap equals ps.idProductivityAndScrap
                        join kvCc in this.dbContext.KeyValues on psd.idCostCenter equals kvCc.idKeyValue
                        join pfs in this.dbContext.ProfileSettings on psd.idProfileSetting equals pfs.idProfileSetting into grPfs
                        from subPfs in grPfs.DefaultIfEmpty()
                        orderby ps.DateFrom ascending
                        where (dateActiveTo.HasValue ?
                               ((!ps.DateTo.HasValue && ps.DateFrom <= dateActiveTo.Value) ||
                                (ps.DateTo.HasValue && ps.DateFrom <= dateActiveTo.Value && ps.DateTo >= dateActiveTo.Value)) :
                               1 == 1)
                        select new ProductivityAndScrapDetailDataView
            {
                idProductivityAndScrapDetail = psd.idProductivityAndScrapDetail,
                idProductivityAndScrap = psd.idProductivityAndScrap,
                DateFrom = ps.DateFrom,
                DateTo = ps.DateTo,
                idCostCenter = psd.idCostCenter,
                CostCenterName = kvCc.DefaultValue4,
                idProfileSetting = psd.idProfileSetting,
                ProfileSettingName = (subPfs != null ? subPfs.ProfileName : string.Empty),
                SumOfHours = psd.SumOfHours,
                SumOfConsumption = psd.SumOfConsumption,
                SumOfProduction = psd.SumOfProduction,
                ProductivityKGh = psd.ProductivityKGh,
                ScrapRate = psd.ScrapRate
            }).ApplySearchCriterias(searchCriteria).ToList();

            if (string.IsNullOrEmpty(sortExpression) || sortExpression == Constants.INVALID_ID_STRING)
            {
                sortDirection = string.Empty;

                sortExpression = "DateFrom";
            }

            listView = OrderByHelper.OrderBy <ProductivityAndScrapDetailDataView>(listView, sortExpression, sortDirection).ToList <ProductivityAndScrapDetailDataView>();

            return(listView);
        }
コード例 #25
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()));
        }
コード例 #26
0
        /// <summary>
        /// 用于渲染订单页面
        /// </summary>
        /// <param name="queryParams"></param>
        /// <returns></returns>
        public JsonResult GetOrder(queryParam queryParams)
        {
            OrderManageDbContext db       = new OrderManageDbContext();
            DbSet <Order>        data     = db.Orders;
            List <Order>         dataRows = null;


            if (queryParams.sortName != null && queryParams.sortOrder != null)
            {
                dataRows = OrderByHelper <Order> .OrderBy(data, queryParams.sortName, queryParams.sortOrder).ToList();
            }
            else
            {
                dataRows = data.ToList();
            }
            var total = dataRows.Count;
            var rows  = dataRows.Skip(queryParams.offset).Take(queryParams.limit).ToList();

            return(Json(new { total = total, rows = rows }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult List(Guid weiXinQRCodePromotionActivityAccountId, int pageIndex = 1, int pageSize = 10)
        {
            try
            {
                if (weiXinQRCodePromotionActivityAccountId == Guid.Empty)
                {
                    throw new BaseException("WeiXinQRCodePromotionActivityAccountId不能为空");
                }
                var orderBys = OrderByHelper.Create().Desc("CreatedDate");
                var where = Where.Create().Eq("WeiXinQRCodePromotionActivityAccountId", weiXinQRCodePromotionActivityAccountId);
                var listResult = this.IWeiXinQRCodePromotionActivityAccountPointsHistoryService
                                 .Page(orderBys, where, pageIndex, pageSize);

                return(this.JsonSuccessGenericPageExecResult(listResult));
            }
            catch (Exception ex)
            {
                return(this.JsonFailureGenericPageExecResult(ex));
            }
        }
コード例 #28
0
        public SearchResult <TEntity> BuscaAvancada(Expression <Func <TEntity, bool> > condition, string orderBy = "", string sortDirection = "", int take = 0, int skip = 0)
        {
            var query = _contexto.Set <TEntity>().AsQueryable();

            if (condition != null)
            {
                query = query.Where(condition);
            }

            int totalRecords = query.Count();

            if (!string.IsNullOrEmpty(orderBy))
            {
                if (!string.IsNullOrEmpty(sortDirection))
                {
                    if (sortDirection == "asc")
                    {
                        query = OrderByHelper.OrderBy(query, orderBy);
                    }
                    else
                    {
                        query = OrderByHelper.OrderByDescending(query, orderBy);
                    }

                    if (take > 0)
                    {
                        query = query.Take(take);
                    }
                    if (skip > 0)
                    {
                        query = query.Skip(skip);
                    }
                }
            }
            return(new SearchResult <TEntity>
            {
                Itens = query.ToList(),
                TotalRecords = totalRecords,
                RecordsPerPage = take
            });
        }
コード例 #29
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());
        }
コード例 #30
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());
        }