コード例 #1
0
        public ProductCollection GetProductsByKeywordAndBaseCatId(string keyword, int baseCatId)
        {
            int baseCategoryId = baseCatId;

            ProductCollection productList      = new ProductCollection();
            IPrefetchPath     prefetchCategory = new
                                                 PrefetchPath((int)EntityType.ProductEntity);

            prefetchCategory.Add(ProductEntity.PrefetchPathCategory);
            RelationCollection relations = new RelationCollection();

            relations.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId);
            relations.Add(ProductEntity.Relations.ProductKeywordEntityUsingProductId);
            relations.Add(KeywordEntity.Relations.ProductKeywordEntityUsingKeywordId);

            IPredicateExpression filter = new
                                          PredicateExpression();

            filter.Add(new FieldLikePredicate(KeywordFields.Keyword, null, "%" + keyword + "%"));
            filter.Add(CategoryFields.BaseCategoryId == baseCategoryId);

            productList.GetMulti(filter, 0, null, relations, prefetchCategory);

            return(productList);
        }
コード例 #2
0
        public ActionResult EditPolicySet(policyData vData, int id)
        {
            SortExpression se = new SortExpression(PolicyLinkFields.Order | SortOperator.Ascending);
            PrefetchPath   pp = new PrefetchPath(EntityType.PolicyLinkEntity);

            pp.Add(PolicyLinkEntity.PrefetchPathChildren, 0, null, null, se);
            vData.PolicyLink = new PolicyLinkEntity(id, pp);
            vData.PolicySet  = vData.PolicyLink.Policy;

            return(View(vData));
        }
コード例 #3
0
        public CategoryCollection GetSubCategories(int mainCatId)
        {
            CategoryCollection  subCategories = new CategoryCollection();
            PredicateExpression filter        = new PredicateExpression();
            IPrefetchPath       prefetchPath  = new PrefetchPath((int)EntityType.CategoryEntity);

            prefetchPath.Add(CategoryEntity.PrefetchPathCategories);
            filter.Add(CategoryFields.BaseCategoryId == mainCatId);
            subCategories.GetMulti(filter, prefetchPath);

            return(subCategories);
        }
コード例 #4
0
        public ActionResult EditPolicy(policyData vData, int id)
        {
            vData.PolicyLink = new PolicyLinkEntity(id);

            SortExpression se = new SortExpression(RuleFields.Order | SortOperator.Ascending);
            PrefetchPath   pp = new PrefetchPath(EntityType.PolicyEntity);

            pp.Add(PolicyEntity.PrefetchPathRule, 0, null, null, se);
            vData.Policy = new PolicyEntity(vData.PolicyLink.PolicyId, pp);

            return(View(vData));
        }
コード例 #5
0
        public ActionResult EditRule(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending);
            PrefetchPath   pp = new PrefetchPath(EntityType.RuleEntity);

            pp.Add(RuleEntity.PrefetchPathCondition).SubPath.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se);
            vData.Rule      = new RuleEntity(id, pp);
            vData.Condition = vData.Rule.Condition;

            return(View(vData));
        }
コード例 #6
0
        public ActionResult EditCondition(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending);
            PrefetchPath   pp = new PrefetchPath(EntityType.DecisionNodeEntity);

            pp.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se);
            vData.Condition = new DecisionNodeEntity(id, pp);

            ViewData["title"] = "edit condition";

            return(View(vData));
        }
コード例 #7
0
        public ProductCollection GetDetailedProduct(int pid)
        {
            IPrefetchPath prefatchPath = new PrefetchPath(EntityType.ProductEntity);

            prefatchPath.Add(ProductEntity.PrefetchPathComments).Filter.Add(CommentFields.Status == true);
            prefatchPath.Add(ProductEntity.PrefetchPathProductKeywords);
            prefatchPath.Add(ProductEntity.PrefetchPathProductSpecifications);
            prefatchPath.Add(ProductEntity.PrefetchPathProductPhotos);
            ProductEntity     p   = new ProductEntity(pid, prefatchPath);
            ProductCollection col = new ProductCollection();

            col.Add(p);
            return(col);
        }
コード例 #8
0
ファイル: SecurityGuiHelper.cs プロジェクト: priaonehaha/HnD
        /// <summary>
        /// Gets all IP ban entities, sorted by range for the page specified.
        /// </summary>
        /// <param name="pageNo">The page number for the page to read. Specify 0 to fetch all ip bans.</param>
        /// <param name="pageSize">Size of the page to fetch. Specify 0 to fetch all ip bans.</param>
        /// <param name="prefetchUser">If set to true, it will prefetch the user entity into the ipBan entity, for the user who set the IPBan</param>
        /// <returns>
        /// the collection of ipban entities requested
        /// </returns>
        public static IPBanCollection GetAllIPBans(int pageNo, int pageSize, bool prefetchUser)
        {
            IPBanCollection toReturn = new IPBanCollection();
            PrefetchPath    path     = null;

            if (prefetchUser)
            {
                // build the Prefetch path to fetch the user as well
                path = new PrefetchPath((int)EntityType.IPBanEntity);
                path.Add(IPBanEntity.PrefetchPathSetByUser);
            }
            toReturn.GetMulti(null, 0, new SortExpression(IPBanFields.Range.Ascending()), null, path, pageNo, pageSize);
            return(toReturn);
        }
コード例 #9
0
        /// <summary>
        /// Returns the user entity of the user with ID userID, With A UserEntityTitle prefetched.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <returns>entity with data requested</returns>
        public static UserEntity GetUserWithTitleDescription(int userID)
        {
            PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity);

            prefetchPath.Add(UserEntity.PrefetchPathUserTitle);

            UserEntity user = new UserEntity(userID, prefetchPath);

            if (user.IsNew)
            {
                // not found
                return(null);
            }
            return(user);
        }
コード例 #10
0
        public static EmployeeCollection GetEmployees()
        {
            var relations = new RelationCollection {
                EmployeeEntityBase.Relations.ContactEntityUsingContactID
            };
            ISortExpression lastFirstAlpha = (ContactFields.LastName | SortOperator.Ascending) & (ContactFields.FirstName | SortOperator.Ascending);
            var             employees      = new EmployeeCollection();
            IPrefetchPath   prefetch       = new PrefetchPath((int)EntityType.EmployeeEntity)
            {
                EmployeeEntityBase.PrefetchPathContact
            };
            var includeFields = new IncludeFieldsList(ContactFields.LastName, ContactFields.FirstName, EmployeeFields.EmployeeID);

            employees.GetMulti(null, 0, lastFirstAlpha, relations, prefetch, includeFields, 0, 0);
            return(employees);
        }
コード例 #11
0
        public object GetProductsByBrandId(int bid)
        {
            ProductCollection  productList = new ProductCollection();
            RelationCollection relation    = new RelationCollection();

            relation.Add(ProductEntity.Relations.BrandEntityUsingBrandId);
            IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity);

            prefatchPath.Add(ProductEntity.PrefetchPathBrand);
            PredicateExpression filter = new PredicateExpression();

            filter.Add(BrandFields.Id == bid);

            productList.GetMulti(filter, 0, null, relation, prefatchPath);

            return(productList);
        }
コード例 #12
0
        public ProductCollection GetProductsByMainCategoryId(int baseCatId)
        {
            int baseCategoryId = baseCatId;
            ProductCollection    productList  = new ProductCollection();
            IPredicateExpression filter       = new PredicateExpression();
            IPrefetchPath        prefetchPath = new PrefetchPath((int)EntityType.ProductEntity);

            prefetchPath.Add(ProductEntity.PrefetchPathCategory);
            RelationCollection relation = new RelationCollection();

            relation.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId);
            filter.Add(CategoryFields.BaseCategoryId == baseCategoryId);

            productList.GetMulti(filter, 0, null, relation, prefetchPath);

            return(productList);
        }
コード例 #13
0
        public ProductCollection GetProductsByStoreId(int storeId)
        {
            int strId = storeId;
            ProductCollection    productList  = new ProductCollection();
            IPredicateExpression filter       = new PredicateExpression();
            IPrefetchPath        prefetchPath = new PrefetchPath((int)EntityType.ProductEntity);

            prefetchPath.Add(ProductEntity.PrefetchPathStore);
            RelationCollection relation = new RelationCollection();

            relation.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            filter.Add(StoreFields.Id == strId);

            productList.GetMulti(filter, 0, null, relation, prefetchPath);

            return(productList);
        }
コード例 #14
0
        public ActionResult EditMatch(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            SortExpression se = new SortExpression(AttributeValueFields.Order | SortOperator.Ascending);
            PrefetchPath   pp = new PrefetchPath(EntityType.DecisionNodeEntity);

            pp.Add(DecisionNodeEntity.PrefetchPathAttributeValue, 0, null, null, se);
            vData.DecisionNode = new DecisionNodeEntity(id, pp);

            ViewData["title"] = "edit match";

//            if (vData.DecisionNode.Parent.Rule.Count > 0)
            ViewData["selectList"] = vData.allAttributes(vData.DecisionNode.AttributeId);
            //else
            //    ViewData["selectList"] = vData.subjectAttributes(vData.DecisionNode.AttributeId);

            return(View(vData));
        }
コード例 #15
0
        public ProductCollection GetSliderProducts()
        {
            ProductCollection    sliderProducts = new ProductCollection();
            PredicateExpression  filter         = new PredicateExpression();
            IPrefetchPath        prefetchPath   = new PrefetchPath((int)EntityType.ProductEntity);
            IPrefetchPathElement path           = prefetchPath.Add(ProductEntity.PrefetchPathComments);

            path.SubPath.Add(CommentEntity.PrefetchPathRate);


            filter.Add(ProductFields.IsSliderProduct == true);
            filter.Add(ProductFields.Status == true);
            sliderProducts.GetMulti(filter, prefetchPath);

            foreach (var item in sliderProducts)
            {
                int id = item.Id;
            }
            return(sliderProducts);
        }
コード例 #16
0
        /// <summary>
        /// Gets the support queue thread info entity and if specified, prefetches the user entity which claimed the related thread.
        /// </summary>
        /// <param name="threadID">The thread ID.</param>
        /// <param name="prefetchClaimUser">if set to true it will </param>
        /// <returns>fetched entity if found, otherwise null</returns>
        public static SupportQueueThreadEntity GetSupportQueueThreadInfo(int threadID, bool prefetchClaimUser)
        {
            SupportQueueThreadEntity toReturn = new SupportQueueThreadEntity();
            PrefetchPath             path     = null;

            if (prefetchClaimUser)
            {
                // prefetch the user who claimed this thread (if any)
                path = new PrefetchPath((int)EntityType.SupportQueueThreadEntity);
                path.Add(SupportQueueThreadEntity.PrefetchPathClaimedByUser);
            }

            // now fetch the entity using the unique constraint on Thread by specifying the threadID passed in. Also specify the prefetch path (if any)
            toReturn.FetchUsingUCThreadID(threadID, path);
            if (toReturn.IsNew)
            {
                // not found
                return(null);
            }
            return(toReturn);
        }
コード例 #17
0
ファイル: SecurityManager.cs プロジェクト: priaonehaha/HnD
        /// <summary>
        /// Authenticates the user with the given Nickname and the given Password.
        /// </summary>
        /// <param name="nickName">Nickname of the user</param>
        /// <param name="password">Password of the user</param>
        /// <returns>AuthenticateResult.AllOk if the user could be authenticated,
        ///	AuthenticateResult.WrongUsernamePassword if user couldn't be authenticated given the current credentials,
        /// AuthenticateResult.IsBanned if the user is banned. </returns>
        public static AuthenticateResult AuthenticateUser(string nickName, string password, out UserEntity user)
        {
            // fetch the Roles related to the user when fetching the user, using a prefetchPath object.
            PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity);

            prefetchPath.Add(UserEntity.PrefetchPathRoles);

            // fetch the user data using the nickname which has a unique constraint
            user = new UserEntity();
            bool fetchResult = user.FetchUsingUCNickName(nickName, prefetchPath);

            if (!fetchResult)
            {
                // not found. Simply return that the user has specified a wrong username/password combination.
                return(AuthenticateResult.WrongUsernamePassword);
            }

            // user was found, check if the user can be authenticated and has specified the correct password.
            if (user.IsBanned)
            {
                // user is banned. We'll report that to the caller
                return(AuthenticateResult.IsBanned);
            }
            else
            {
                // check password and UserID. We disallow the user with id 0 to login as that's the anonymous coward ID for a user not logged in.
                string md5HashedPassword = HnDGeneralUtils.CreateMD5HashedBase64String(password);
                if ((md5HashedPassword == user.Password) && (user.UserID != Globals.UserIDToDenyLogin))
                {
                    // correct username/password combination
                    return(AuthenticateResult.AllOk);
                }
                else
                {
                    // something was wrong, report wrong authentication combination
                    return(AuthenticateResult.WrongUsernamePassword);
                }
            }
        }
コード例 #18
0
        public LastViewedProductCollection GetLast5ViewedProducts(int storeId)
        {
            LastViewedProductCollection lastViewedProducts = new LastViewedProductCollection();
            RelationCollection          relationsToUse     = new RelationCollection();

            relationsToUse.Add(LastViewedProductEntity.Relations.ProductEntityUsingProductId);
            relationsToUse.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.LastViewedProductEntity);

            prefetchPath.Add(LastViewedProductEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathStore);

            PredicateExpression filter = new PredicateExpression();

            filter.Add(StoreFields.Id == storeId);
            SortExpression sorter = new SortExpression();

            sorter.Add(LastViewedProductFields.ViewedTime | SortOperator.Descending);


            lastViewedProducts.GetMulti(filter, 5, sorter, relationsToUse, prefetchPath);

            return(lastViewedProducts);
        }
コード例 #19
0
        //public ProductCollection SortProductsByRate(ProductCollection productList, bool isAscending)
        //{

        //}

        public ProductCollection GetLast5AddedProducts(object m)
        {
            MembershipEntity   member    = new MembershipEntity(3);
            ProductCollection  products  = new ProductCollection();
            RelationCollection relations = new RelationCollection();

            relations.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            relations.Add(StoreEntity.Relations.MembershipEntityUsingMembershipId);

            IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity);

            prefatchPath.Add(ProductEntity.PrefetchPathStore).SubPath.Add(StoreEntity.PrefetchPathMembership);

            PredicateExpression filter = new PredicateExpression();

            filter.Add(MembershipFields.Id == member.Id);

            SortExpression sorter = new SortExpression();

            sorter.Add(ProductFields.AddedDate | SortOperator.Descending);
            products.GetMulti(filter, 5, sorter, relations, prefatchPath);

            return(products);
        }
コード例 #20
0
        /// <summary>
        /// Gets the prefetch path for a Manager's Employees. By using this prefetch all a manager's employees a bought back in 1 query.
        /// </summary>
        /// <returns></returns>
        public static IPrefetchPath GetManagesPrefetchPath()
        {
            IPrefetchPath prefetch =
                new PrefetchPath((int)EntityType.EmployeeEntity)
            {
                EmployeeEntityBase.PrefetchPathContact
            };

            prefetch.Add(EmployeeEntityBase.PrefetchPathManages)
            .SubPath.Add(EmployeeEntityBase.PrefetchPathManages)
            .SubPath.Add(EmployeeEntityBase.PrefetchPathManages)
            .SubPath.Add(EmployeeEntityBase.PrefetchPathManages)
            .SubPath.Add(EmployeeEntityBase.PrefetchPathManages);
            prefetch[1].SubPath.Add(EmployeeEntityBase.PrefetchPathContact);
            prefetch[1].SubPath[0].SubPath.Add(
                EmployeeEntityBase.PrefetchPathContact);
            prefetch[1].SubPath[0].SubPath[0].SubPath.Add(
                EmployeeEntityBase.PrefetchPathContact);
            prefetch[1].SubPath[0].SubPath[0].SubPath[0].SubPath.Add(
                EmployeeEntityBase.PrefetchPathContact);
            prefetch[1].SubPath[0].SubPath[0].SubPath[0].SubPath[0].SubPath.Add(
                EmployeeEntityBase.PrefetchPathContact);
            return(prefetch);
        }
コード例 #21
0
        public ProductCollection GetProductsByMainCategoryId(int baseCatId)
        {
            int baseCategoryId = baseCatId;
            ProductCollection productList = new ProductCollection();
            IPredicateExpression filter = new PredicateExpression();
            IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity);
            prefetchPath.Add(ProductEntity.PrefetchPathCategory);
            RelationCollection relation = new RelationCollection();
            relation.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId);
            filter.Add(CategoryFields.BaseCategoryId == baseCategoryId);

            productList.GetMulti(filter, 0, null, relation, prefetchPath);

            return productList;
        }
コード例 #22
0
        public ProductCollection GetProductsByKeywordAndBaseCatId(string keyword, int baseCatId)
        {
            int baseCategoryId = baseCatId;

            ProductCollection productList = new ProductCollection();
            IPrefetchPath prefetchCategory = new
                PrefetchPath((int)EntityType.ProductEntity);
            prefetchCategory.Add(ProductEntity.PrefetchPathCategory);
            RelationCollection relations = new RelationCollection();
            relations.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId);
            relations.Add(ProductEntity.Relations.ProductKeywordEntityUsingProductId);
            relations.Add(KeywordEntity.Relations.ProductKeywordEntityUsingKeywordId);

            IPredicateExpression filter = new
                PredicateExpression();

            filter.Add(new FieldLikePredicate(KeywordFields.Keyword, null, "%" + keyword + "%"));
            filter.Add(CategoryFields.BaseCategoryId == baseCategoryId);

            productList.GetMulti(filter, 0, null, relations, prefetchCategory);

            return productList;
        }
コード例 #23
0
        public object GetProductsByBrandId(int bid)
        {
            ProductCollection productList = new ProductCollection();
            RelationCollection relation = new RelationCollection();
            relation.Add(ProductEntity.Relations.BrandEntityUsingBrandId);
            IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity);
            prefatchPath.Add(ProductEntity.PrefetchPathBrand);
            PredicateExpression filter = new PredicateExpression();
            filter.Add(BrandFields.Id == bid);

            productList.GetMulti(filter, 0, null, relation, prefatchPath);

            return productList;
        }
コード例 #24
0
        public LastViewedProductCollection GetLast5ViewedProducts(int storeId)
        {
            LastViewedProductCollection lastViewedProducts = new LastViewedProductCollection();
            RelationCollection relationsToUse = new RelationCollection();
            relationsToUse.Add(LastViewedProductEntity.Relations.ProductEntityUsingProductId);
            relationsToUse.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.LastViewedProductEntity);
            prefetchPath.Add(LastViewedProductEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathStore);

            PredicateExpression filter = new PredicateExpression();
            filter.Add(StoreFields.Id == storeId);
            SortExpression sorter = new SortExpression();
            sorter.Add( LastViewedProductFields.ViewedTime | SortOperator.Descending);

            lastViewedProducts.GetMulti(filter, 5, sorter, relationsToUse, prefetchPath);

            return lastViewedProducts;
        }
コード例 #25
0
        //public ProductCollection SortProductsByRate(ProductCollection productList, bool isAscending)
        //{
        //}
        public ProductCollection GetLast5AddedProducts(object m)
        {
            MembershipEntity member = new MembershipEntity(3);
            ProductCollection products = new ProductCollection();
            RelationCollection relations = new RelationCollection();
            relations.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            relations.Add(StoreEntity.Relations.MembershipEntityUsingMembershipId);

            IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity);
            prefatchPath.Add(ProductEntity.PrefetchPathStore).SubPath.Add(StoreEntity.PrefetchPathMembership);

            PredicateExpression filter = new PredicateExpression();

            filter.Add(MembershipFields.Id == member.Id);

            SortExpression sorter = new SortExpression();

            sorter.Add(ProductFields.AddedDate | SortOperator.Descending);
            products.GetMulti(filter, 5, sorter, relations, prefatchPath);

            return products;
        }
コード例 #26
0
        public ActionResult EditPolicySet(policyData vData, int id)
        {
            SortExpression se = new SortExpression(PolicyLinkFields.Order | SortOperator.Ascending);
            PrefetchPath pp = new PrefetchPath(EntityType.PolicyLinkEntity);
            pp.Add(PolicyLinkEntity.PrefetchPathChildren, 0, null, null, se);
            vData.PolicyLink = new PolicyLinkEntity(id,pp);
            vData.PolicySet = vData.PolicyLink.Policy;

            return View(vData);
        }
コード例 #27
0
        public ActionResult EditRule(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending);
            PrefetchPath pp = new PrefetchPath(EntityType.RuleEntity);
            pp.Add(RuleEntity.PrefetchPathCondition).SubPath.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se);
            vData.Rule = new RuleEntity(id, pp);
            vData.Condition = vData.Rule.Condition;

            return View(vData);
        }
コード例 #28
0
        public ActionResult EditTarget(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending);
            PrefetchPath pp = new PrefetchPath(EntityType.DecisionNodeEntity);
            pp.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se);
            vData.Condition = new DecisionNodeEntity(id,pp);

            ViewData["title"] = "edit target condition";

            return View(vData);
        }
コード例 #29
0
        /// <summary>
        /// Calculates the statistics for the Northwind database and shows them in the form, illustrating the
        /// direct database power LLBLGen Pro offers you through scalar functions, aggregates, group by and expressions.
        /// </summary>
        /// <remarks>No error checking is applied to this routine, it's for illustrating the framework functionality.</remarks>
        private void CalculateStatistics()
        {
            // get amount customers
            CustomerCollection customers = new CustomerCollection();
            int amountCustomers          = customers.GetDbCount();

            _amountCustomersTextBox.Text = amountCustomers.ToString();

            // get all order prices
            ResultsetFields orderPricesFields = new ResultsetFields(2);

            orderPricesFields.DefineField(OrderDetailFields.OrderId, 0, "OrderId");
            orderPricesFields.DefineField(OrderDetailFields.ProductId, 1, "OrderPrice", "", AggregateFunction.Sum);
            orderPricesFields[1].ExpressionToApply = (OrderDetailFields.Quantity * OrderDetailFields.UnitPrice);
            IGroupByCollection groupBy = new GroupByCollection();

            groupBy.Add(orderPricesFields[0]);

            // fetch in a datatable, orderid + the order price.
            DataTable    orderPrices = new DataTable();
            TypedListDAO dao         = new TypedListDAO();

            dao.GetMultiAsDataTable(orderPricesFields, orderPrices, 0, null, null, null, true, groupBy, null, 0, 0);

            // calculate average order price and which customer has the most expensive order
            decimal averageOrderPrice       = 0.0M;
            decimal highestOrderPrice       = 0.0M;
            int     orderIdWithHighestPrice = 0;

            for (int i = 0; i < orderPrices.Rows.Count; i++)
            {
                decimal currentOrderPrice = (decimal)orderPrices.Rows[i]["OrderPrice"];
                if (currentOrderPrice > highestOrderPrice)
                {
                    highestOrderPrice       = currentOrderPrice;
                    orderIdWithHighestPrice = (int)orderPrices.Rows[i]["OrderId"];
                }
                averageOrderPrice += currentOrderPrice;
            }
            averageOrderPrice = averageOrderPrice / orderPrices.Rows.Count;
            _highestOrderPriceTextBox.Text = highestOrderPrice.ToString("C");
            _averageOrderPriceTextBox.Text = averageOrderPrice.ToString("C");

            // get order with highest price. Pull customer also in 1 go
            IPrefetchPath prefetchPathCustomer = new PrefetchPath((int)EntityType.OrderEntity);

            prefetchPathCustomer.Add(OrderEntity.PrefetchPathCustomer);
            OrderEntity highestOrder = new OrderEntity();

            highestOrder.FetchUsingPK(orderIdWithHighestPrice, prefetchPathCustomer);
            _customerWithHighestOrder         = highestOrder.Customer;          // already loaded through prefetch path.
            _highestOrderCustomerTextBox.Text = _customerWithHighestOrder.CompanyName;

            // get customer with most orders.
            ResultsetFields orderCustomerFields = new ResultsetFields(2);

            orderCustomerFields.DefineField(OrderFields.CustomerId, 0, "CustomerID");
            orderCustomerFields.DefineField(OrderFields.OrderId, 1, "AmountOrders", "", AggregateFunction.Count);
            groupBy = new GroupByCollection();
            groupBy.Add(orderCustomerFields[0]);
            SortExpression sorter = new SortExpression();

            sorter.Add(new SortClause(orderCustomerFields[1], SortOperator.Descending));
            // now fetch the list, just 1 row, ordered descending on amount
            DataTable orderCustomer = new DataTable();

            dao.GetMultiAsDataTable(orderCustomerFields, orderCustomer, 1, sorter, null, null, true, groupBy, null, 0, 0);
            _mostOrdersPerCustomerTextBox.Text = orderCustomer.Rows[0]["AmountOrders"].ToString();

            // we'll assume the data was there, so there is a row.
            _customerWithMostOrders = new CustomerEntity(orderCustomer.Rows[0]["CustomerID"].ToString());

            _mostOrdersCustomerTextBox.Text = _customerWithMostOrders.CompanyName;
        }
コード例 #30
0
        public ActionResult EditPolicy(policyData vData, int id)
        {
            vData.PolicyLink = new PolicyLinkEntity(id);

            SortExpression se = new SortExpression(RuleFields.Order | SortOperator.Ascending);
            PrefetchPath pp = new PrefetchPath(EntityType.PolicyEntity);
            pp.Add(PolicyEntity.PrefetchPathRule, 0, null, null, se);
            vData.Policy = new PolicyEntity(vData.PolicyLink.PolicyId,pp);

            return View(vData);
        }
コード例 #31
0
ファイル: UserGuiHelper.cs プロジェクト: priaonehaha/HnD
        /// <summary>
        /// Returns the user entity of the user with ID userID, With A UserEntityTitle prefetched.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <returns>entity with data requested</returns>
        public static UserEntity GetUserWithTitleDescription(int userID)
        {
            PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity);
            prefetchPath.Add(UserEntity.PrefetchPathUserTitle);

            UserEntity user = new UserEntity(userID, prefetchPath);
            if(user.IsNew)
            {
                // not found
                return null;
            }
            return user;
        }
コード例 #32
0
        /// <summary>
        /// Gets the support queue thread info entity and if specified, prefetches the user entity which claimed the related thread. 
        /// </summary>
        /// <param name="threadID">The thread ID.</param>
        /// <param name="prefetchClaimUser">if set to true it will </param>
        /// <returns>fetched entity if found, otherwise null</returns>
        public static SupportQueueThreadEntity GetSupportQueueThreadInfo(int threadID, bool prefetchClaimUser)
        {
            SupportQueueThreadEntity toReturn = new SupportQueueThreadEntity();
            PrefetchPath path = null;
            if(prefetchClaimUser)
            {
                // prefetch the user who claimed this thread (if any)
                path = new PrefetchPath((int)EntityType.SupportQueueThreadEntity);
                path.Add(SupportQueueThreadEntity.PrefetchPathClaimedByUser);
            }

            // now fetch the entity using the unique constraint on Thread by specifying the threadID passed in. Also specify the prefetch path (if any)
            toReturn.FetchUsingUCThreadID(threadID, path);
            if(toReturn.IsNew)
            {
                // not found
                return null;
            }
            return toReturn;
        }
コード例 #33
0
        public ProductCollection GetProductsByStoreId(int storeId)
        {
            int strId = storeId;
            ProductCollection productList = new ProductCollection();
            IPredicateExpression filter = new PredicateExpression();
            IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity);
            prefetchPath.Add(ProductEntity.PrefetchPathStore);
            RelationCollection relation = new RelationCollection();
            relation.Add(ProductEntity.Relations.StoreEntityUsingStoreId);
            filter.Add(StoreFields.Id == strId);

            productList.GetMulti(filter, 0, null, relation, prefetchPath);

            return productList;
        }
コード例 #34
0
        public ActionResult EditMatch(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            SortExpression se = new SortExpression(AttributeValueFields.Order | SortOperator.Ascending);
            PrefetchPath pp = new PrefetchPath(EntityType.DecisionNodeEntity);
            pp.Add(DecisionNodeEntity.PrefetchPathAttributeValue, 0, null, null, se);
            vData.DecisionNode = new DecisionNodeEntity(id,pp);

            ViewData["title"] = "edit match";

            //            if (vData.DecisionNode.Parent.Rule.Count > 0)
                ViewData["selectList"] = vData.allAttributes(vData.DecisionNode.AttributeId);
            //else
            //    ViewData["selectList"] = vData.subjectAttributes(vData.DecisionNode.AttributeId);

            return View(vData);
        }
コード例 #35
0
        public ProductCollection GetSliderProducts()
        {
            ProductCollection sliderProducts = new ProductCollection();
            PredicateExpression filter = new PredicateExpression();
            IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity);
            IPrefetchPathElement path = prefetchPath.Add(ProductEntity.PrefetchPathComments);
            path.SubPath.Add(CommentEntity.PrefetchPathRate);

            filter.Add(ProductFields.IsSliderProduct == true);
            filter.Add(ProductFields.Status == true);
            sliderProducts.GetMulti(filter, prefetchPath);

            foreach (var item in sliderProducts)
            {
                int id = item.Id;
            }
            return sliderProducts;
        }
コード例 #36
0
 public ProductCollection GetDetailedProduct(int pid)
 {
     IPrefetchPath prefatchPath = new PrefetchPath(EntityType.ProductEntity);
     prefatchPath.Add(ProductEntity.PrefetchPathComments).Filter.Add(CommentFields.Status == true);
     prefatchPath.Add(ProductEntity.PrefetchPathProductKeywords);
     prefatchPath.Add(ProductEntity.PrefetchPathProductSpecifications);
     prefatchPath.Add(ProductEntity.PrefetchPathProductPhotos);
     ProductEntity p = new ProductEntity(pid, prefatchPath);
     ProductCollection col = new ProductCollection();
     col.Add(p);
     return col;
 }
コード例 #37
0
        public CategoryCollection GetSubCategories(int mainCatId)
        {
            CategoryCollection subCategories = new CategoryCollection();
            PredicateExpression filter = new PredicateExpression();
            IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.CategoryEntity);
            prefetchPath.Add(CategoryEntity.PrefetchPathCategories);
            filter.Add(CategoryFields.BaseCategoryId == mainCatId);
            subCategories.GetMulti(filter, prefetchPath);

            return subCategories;
        }
コード例 #38
0
ファイル: SecurityManager.cs プロジェクト: priaonehaha/HnD
        /// <summary>
        /// Authenticates the user with the given Nickname and the given Password.
        /// </summary>
        /// <param name="nickName">Nickname of the user</param>
        /// <param name="password">Password of the user</param>
        /// <returns>AuthenticateResult.AllOk if the user could be authenticated, 
        ///	AuthenticateResult.WrongUsernamePassword if user couldn't be authenticated given the current credentials,
        /// AuthenticateResult.IsBanned if the user is banned. </returns>
        public static AuthenticateResult AuthenticateUser(string nickName, string password, out UserEntity user)
        {
            // fetch the Roles related to the user when fetching the user, using a prefetchPath object.
            PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity);
            prefetchPath.Add(UserEntity.PrefetchPathRoles);

            // fetch the user data using the nickname which has a unique constraint
            user = new UserEntity();
            bool fetchResult = user.FetchUsingUCNickName(nickName, prefetchPath);

            if(!fetchResult)
            {
                // not found. Simply return that the user has specified a wrong username/password combination.
                return AuthenticateResult.WrongUsernamePassword;
            }

            // user was found, check if the user can be authenticated and has specified the correct password.
            if(user.IsBanned)
            {
                // user is banned. We'll report that to the caller
                return AuthenticateResult.IsBanned;
            }
            else
            {
                // check password and UserID. We disallow the user with id 0 to login as that's the anonymous coward ID for a user not logged in.
                string md5HashedPassword = HnDGeneralUtils.CreateMD5HashedBase64String(password);
                if((md5HashedPassword == user.Password)&&(user.UserID != Globals.UserIDToDenyLogin))
                {
                    // correct username/password combination
                    return AuthenticateResult.AllOk;
                }
                else
                {
                    // something was wrong, report wrong authentication combination
                    return AuthenticateResult.WrongUsernamePassword;
                }
            }
        }