Пример #1
0
        //private List<PostCateInfo> ConvertToPostCate(List<PostInfo> PostList, bool ChildList)
        //{
        //    List<PostCateInfo> PostCateList = new List<PostCateInfo>();
        //    if (PostList != null)
        //    {
        //        foreach (PostInfo Info in PostList)
        //        {
        //            PostCateInfo PostCateModel = new PostCateInfo();
        //            PostCateModel.EncryptFcateID = Info.PostId.ToString();
        //            PostCateModel.Title = Info.PostName;
        //            if (ChildList) PostCateModel.ChildCourseFCateView = ConvertToPostCate(PostBLL.ReadPostList(Info.PostId), false);
        //            PostCateList.Add(PostCateModel);
        //        }
        //    }
        //    return PostCateList;
        //}

        private List <MCourseInfo> GetCourseList()
        {
            int postID   = RequestHelper.GetForm <int>("postID");
            int page     = RequestHelper.GetForm <int>("pageIndex");
            int pageSize = RequestHelper.GetForm <int>("pageSize");
            int classID  = RequestHelper.GetForm <int>("classID");

            if (pageSize <= 0)
            {
                pageSize = base.PageSize;
            }
            List <MCourseInfo> CourseList = new List <MCourseInfo>();
            int    userID          = base.UserID;
            string prepaidCourseId = BLLMTestCate.ReadPrepaidTestCate(userID);

            if (postID < 0)
            {
                postID = int.Parse(CookiesHelper.ReadCookieValue("UserStudyPostId"));
            }

            List <ProductInfo> productList      = new List <ProductInfo>();
            string             inProductID      = PostBLL.ReadPostCourseID(base.UserCompanyID, postID);
            string             passPostCourseID = string.IsNullOrEmpty(inProductID) ? "" : TestPaperBLL.ReadCourseIDStr(TestPaperBLL.ReadList(base.UserID, inProductID, 1));

            inProductID = StringHelper.SubString(inProductID, passPostCourseID);
            ProductSearchInfo productSearch = new ProductSearchInfo();

            if (!string.IsNullOrEmpty(inProductID))
            {
                productSearch.InProductID = inProductID;
                productSearch.IsSale      = 1;
                if (classID > 0)
                {
                    productSearch.ClassID = "|" + classID + "|";
                }
                productSearch.OrderField = "[IsTop],[ClassID],[Sort],[ID]";
                productList = ProductBLL.SearchProductList(page, pageSize, productSearch, ref base.Count);
            }

            int pageCount = (int)Math.Ceiling((double)base.Count / pageSize);

            //加载选修课程(岗位课程罗列完成后,再加载选修)
            if ((classID < 0 || classID == 6) && (page == pageCount) && StringHelper.CompareSingleString("4,5,64", UserBLL.ReadUser(base.UserID).StudyPostID.ToString()))
            {
                productSearch.InProductID = string.Empty;
                productSearch.ClassID     = "|6|";
                productSearch.InBrandID   = base.CompanyBrandID;
                productSearch.NotLikeName = "必修";
                productSearch.IsSale      = 1;
                productList.AddRange(ProductBLL.SearchProductList(productSearch));
            }

            //加载认证考试
            if ((classID < 0 && page == 1) || classID == 4387)
            {
                PostPassInfo passpost = new PostPassInfo();
                passpost.UserId = base.UserID;
                passpost.IsRZ   = 0;

                RenZhengCateInfo rzCate = new RenZhengCateInfo();
                rzCate.InPostID = PostPassBLL.PassPostString(passpost);
                string rzProductID = RenZhengCateBLL.ReadTestCateID(rzCate);
                if (!string.IsNullOrEmpty(rzProductID))
                {
                    productSearch.InProductID = rzProductID;
                    productSearch.ClassID     = string.Empty;
                    productSearch.InBrandID   = base.CompanyBrandID;
                    productSearch.NotLikeName = string.Empty;
                    productSearch.IsSale      = 1;
                    productList.InsertRange(0, ProductBLL.SearchProductList(productSearch));
                }
            }

            //加载大课件
            if ((classID < 0 && page == 1) || classID == 5298)
            {
                productSearch.InProductID = string.Empty;
                productSearch.InBrandID   = string.Empty;
                productSearch.NotLikeName = string.Empty;
                productSearch.IsSale      = 1;
                productSearch.ClassID     = "|5298|";
                productList.InsertRange(0, ProductBLL.SearchProductList(productSearch));
            }

            //加载指定时间考试
            if (classID < 0 && page == 1)
            {
                string parentCompanyID = base.ParentCompanyID;
                if (string.IsNullOrEmpty(parentCompanyID))
                {
                    parentCompanyID = base.UserCompanyID.ToString();
                }
                else
                {
                    parentCompanyID += "," + base.UserCompanyID.ToString();
                }
                List <TestSettingInfo> specialTestList = TestSettingBLL.ReadSpecialTestList(parentCompanyID);
                if (specialTestList.Count > 0)
                {
                    string specialCourseID = TestSettingBLL.ReadSpecialTestCourseID(specialTestList);
                    if (!string.IsNullOrEmpty(specialCourseID))
                    {
                        productSearch.InProductID = specialCourseID;
                        productSearch.ClassID     = string.Empty;
                        productSearch.InBrandID   = base.CompanyBrandID;
                        productSearch.NotLikeName = string.Empty;
                        productSearch.IsSale      = 1;
                        List <ProductInfo> specialProductList = ProductBLL.SearchProductList(productSearch);
                        productList.InsertRange(0, specialProductList);
                    }
                }
            }

            //重新获取产品ID串
            inProductID      = ProductBLL.ReadProductIdStr(productList);
            passPostCourseID = string.IsNullOrEmpty(inProductID) ? "" : TestPaperBLL.ReadCourseIDStr(TestPaperBLL.ReadList(base.UserID, inProductID, 1));

            //获取未通过的最新记录
            string noPassCourseID = StringHelper.SubString(inProductID, passPostCourseID);
            List <TestPaperReportInfo> noPassTestPaperList = string.IsNullOrEmpty(noPassCourseID) ? new List <TestPaperReportInfo>() : TestPaperBLL.ReadThelatestList(base.UserID, noPassCourseID);

            List <AttributeRecordInfo> attributeRecordList = AttributeRecordBLL.ReadList("5", noPassCourseID);

            foreach (ProductInfo Info in productList)
            {
                //通过的课程不用显示
                //if (!StringHelper.CompareSingleString(passPostCourseID, Info.ID.ToString()))
                {
                    TestSettingInfo testSetting = TestSettingBLL.ReadTestSetting(base.UserCompanyID, Info.ID);

                    MCourseInfo CourseModel = new MCourseInfo();
                    CourseModel.ClassID   = Info.ID.ToString();
                    CourseModel.Title     = Info.Name;
                    CourseModel.IsPass    = false;
                    CourseModel.PageCount = pageCount;
                    TestPaperReportInfo currentPaper = noPassTestPaperList.Find(delegate(TestPaperReportInfo tempPaper) { return(tempPaper.CourseID == Info.ID); });
                    if (currentPaper != null)
                    {
                        //剩余时间
                        int remainingTime = (testSetting.TestInterval - (int)(DateTime.Now - currentPaper.TestDate).TotalHours);
                        CourseModel.ValidDateShow = remainingTime > 0 ? remainingTime.ToString() : "";
                    }
                    CourseModel.OriginalPrice = Info.MarketPrice.ToString();
                    if (!string.IsNullOrEmpty(Info.ProductNumber))
                    {
                        CourseModel.IsVideo = true;
                    }

                    if (!string.IsNullOrEmpty(Info.Accessory))
                    {
                        CourseModel.IsTest = true;

                        //通过的课程不用再考
                        if (StringHelper.CompareSingleString(passPostCourseID, Info.ID.ToString()))
                        {
                            CourseModel.IsTest = false;
                        }

                        if (testSetting != null && (testSetting.TestStartTime != null || testSetting.TestEndTime != null))
                        {
                            //指定时间考试考过了就不要再考了
                            if (!string.IsNullOrEmpty(CourseModel.ValidDateShow))
                            {
                                CourseModel.IsTest = false;
                            }
                            if (DateTime.Now < testSetting.TestStartTime || DateTime.Now > testSetting.TestEndTime)
                            {
                                CourseModel.IsTest = false;
                            }
                        }
                    }
                    CourseModel.IsPostCourse    = true;
                    CourseModel.IsPrepaidCourse = StringHelper.CompareSingleString(prepaidCourseId, Info.ID.ToString());

                    //产品知识 练车剧本地址
                    {
                        CourseModel.RCUrl = AttributeRecordBLL.ReadAttributeRecord(attributeRecordList, 5, Info.ID).Value;
                        if (!string.IsNullOrEmpty(CourseModel.RCUrl))
                        {
                            CourseModel.IsRC = true;
                        }
                    }
                    CourseList.Add(CourseModel);
                }
            }
            return(CourseList);
        }
Пример #2
0
        private List <MCourseInfo> GetCoursesByKeyWord()
        {
            string             Keyword    = StringHelper.SearchSafe(RequestHelper.GetForm <string>("keyWord"));
            int                PageIndex  = RequestHelper.GetForm <int>("pageIndex");
            int                PageSize   = RequestHelper.GetForm <int>("pageSize");
            List <MCourseInfo> CourseList = new List <MCourseInfo>();
            int                i          = 1;

            ProductSearchInfo productSearch = new ProductSearchInfo();

            productSearch.Key         = Keyword;
            productSearch.IsSale      = 1;
            productSearch.InCompanyID = CompanyBLL.SystemCompanyId.ToString();
            productSearch.InBrandID   = CookiesHelper.ReadCookieValue("UserCompanyBrandID");
            List <ProductInfo> productList = ProductBLL.SearchProductList(productSearch);

            if (productList.Count > 0)
            {
                //通过的课程ID
                string PassCourseId    = TestPaperBLL.ReadCourseIDStr(TestPaperBLL.ReadList(base.UserID, 1));
                string PostCourseId    = PostBLL.ReadPostCourseID(base.UserCompanyID, int.Parse(CookiesHelper.ReadCookieValue("UserStudyPostId")));
                string perpaidCourseId = BLLMTestCate.ReadPrepaidTestCate(base.UserID);
                foreach (ProductInfo Info in productList)
                {
                    if (i >= PageSize * (PageIndex - 1) && i < PageSize * PageIndex)
                    {
                        MCourseInfo CourseModel = new MCourseInfo();
                        CourseModel.ClassID = Info.ID.ToString();
                        CourseModel.Title   = Info.Name;

                        TestPaperInfo Model = new TestPaperInfo();
                        Model.UserId          = base.UserID;
                        Model.CateIdCondition = Info.ID.ToString();
                        Model.GroupCondition  = "CateId";
                        TestPaperInfo TestPaperModel = TestPaperBLL.ReadList(Model).Find(delegate(TestPaperInfo TempModel) { return(TempModel.CateId == Info.ID); });
                        if (TestPaperModel != null)
                        {
                            CourseModel.TestCount = TestPaperModel.TestNum;
                        }
                        else
                        {
                            CourseModel.TestCount = 0;
                        }
                        CourseModel.IsPass    = StringHelper.CompareSingleString(PassCourseId, Info.ID.ToString());
                        CourseModel.PageCount = (int)Math.Ceiling((double)productList.Count / (double)PageSize);
                        if (!string.IsNullOrEmpty(Info.ProductNumber))
                        {
                            CourseModel.IsVideo = true;
                        }
                        if (!string.IsNullOrEmpty(Info.Accessory))
                        {
                            CourseModel.IsTest = true;
                        }
                        CourseModel.IsPostCourse = StringHelper.CompareSingleString(PostCourseId, Info.ID.ToString());
                        if (!CourseModel.IsPostCourse && CourseModel.Title.ToLower().IndexOf("vs") < 0)
                        {
                            continue;
                        }
                        CourseModel.OriginalPrice = Info.MarketPrice.ToString();
                        List <AttributeRecordInfo> attributeRecordList = AttributeRecordBLL.ReadList("5", Info.ID.ToString());
                        if (attributeRecordList.Count > 0)
                        {
                            CourseModel.IsRC  = true;
                            CourseModel.RCUrl = attributeRecordList[0].Value;
                        }
                        //选修也列为可以查看对象
                        if (!CourseModel.IsPostCourse && Info.Name.ToUpper().Contains("VS"))
                        {
                            CourseModel.IsPostCourse = true;
                        }
                        CourseModel.IsPrepaidCourse = StringHelper.CompareSingleString(perpaidCourseId, Info.ID.ToString());
                        CourseList.Add(CourseModel);
                    }
                    if (i >= PageSize * PageIndex)
                    {
                        break;
                    }
                    i++;
                }
            }
            return(CourseList);
        }