public List <TestPaperReportInfo> ReadTheFirstRecordList(string companyID) { List <TestPaperReportInfo> tempList = new List <TestPaperReportInfo>(); if (!string.IsNullOrEmpty(companyID)) { StringBuilder sql = new StringBuilder(); sql.Append("select * from ("); sql.Append("select [UserID],[CateId],[PaperName],[Scorse],[TestDate],[IsPass],row_number() over(partition by [UserID] order by [TestDate]) as rownumber from [" + ShopMssqlHelper.TablePrefix + "TestPaper] where [companyID] in (" + companyID + ")"); sql.Append(") as t where t.rownumber <=1"); using (SqlDataReader dr = DbSQLHelper.ExecuteReader(sql.ToString())) { while (dr.Read()) { TestPaperReportInfo latestTestPaper = new TestPaperReportInfo(); latestTestPaper.UserID = int.Parse(dr["UserId"].ToString()); latestTestPaper.CourseID = int.Parse(dr["CateId"].ToString()); latestTestPaper.CourseName = dr["PaperName"].ToString(); latestTestPaper.Score = decimal.Parse(dr["Scorse"].ToString()); latestTestPaper.TestDate = Convert.ToDateTime(dr["TestDate"]); latestTestPaper.IsPass = int.Parse(dr["IsPass"].ToString()); tempList.Add(latestTestPaper); } } } return(tempList); }
/// <summary> /// 读取最新的成绩 /// </summary> /// <param name="userID"></param> /// <param name="courseID"></param> /// <returns></returns> public static TestPaperReportInfo ReadTheLatestPaper(int userID, int courseID) { TestPaperReportInfo testPaper = new TestPaperReportInfo(); List <TestPaperReportInfo> theLastestList = ReadThelatestList(userID, courseID.ToString()); if (theLastestList.Count > 0) { testPaper = theLastestList[0]; } return(testPaper); }
protected string HtmlOut1(CompanyInfo company, ref StringBuilder TotalTable) { StringBuilder TextOut = new StringBuilder(); DateTime PostPlanStartDate = DateTime.MinValue; if (string.IsNullOrEmpty(company.PostStartDate.ToString())) { PostPlanStartDate = Convert.ToDateTime("2013-7-1"); } else { PostPlanStartDate = Convert.ToDateTime(company.PostStartDate.ToString()); } int PeoperNum = 0; //统计目标课程数 int TargetNum = 0, CompanyDelayNum = 0; //统计通过课程数量第一的数据信息 string PassCourseFirstUser = string.Empty, GoodStudent = string.Empty; int FirstPassCourseNum = 0; //单个岗位的岗位计划开始时间 DateTime PostStartDate = DateTime.MinValue; int PostCourseNum = 0; //岗位课程数 string AllPostPlan = "0"; //岗位下所有级别的岗位课程 int RedNum = 0, YellowNum = 0, GreenNum = 0; //把公司所有员工的考试记录都一起调起 TestPaperInfo TestPaperModel = new TestPaperInfo(); if (!string.IsNullOrEmpty(company.PostStartDate.ToString())) { TestPaperModel.TestMinDate = Convert.ToDateTime(company.PostStartDate); } TestPaperModel.TestMaxDate = endDate; TestPaperModel.CompanyIdCondition = company.CompanyId.ToString(); //TestPaperModel.Field = "UserID"; TestPaperModel.Condition = "[UserID] in (select [ID] from [_User] where [companyID]=" + company.CompanyId.ToString(); if (!string.IsNullOrEmpty(groupID)) { TestPaperModel.Condition += " and [GroupID] in (" + groupID + ")"; } if (!string.IsNullOrEmpty(postIdCondition)) { TestPaperModel.Condition += " and [WorkingPostID] in (" + postIdCondition + ")"; } if (!string.IsNullOrEmpty(studyPostIdCondition)) { TestPaperModel.Condition += " and [StudyPostId] in (" + studyPostIdCondition + ")"; } if (!string.IsNullOrEmpty(state)) { TestPaperModel.Condition += " and [Status] in (" + state + ")"; } TestPaperModel.Condition += ")"; List <TestPaperInfo> TestPaperList = TestPaperBLL.NewReadList(TestPaperModel); UserSearchInfo userSearch = new UserSearchInfo(); userSearch.InStatus = state; userSearch.InWorkingPostID = postIdCondition; //if (base.IsGroupCompany(company.GroupId)) //{ // userSearch.InCompanyID = CompanyBLL.ReadCompanyIdList(company.CompanyId.ToString()); // ColNum = 11; // userSearch.InStudyPostID = "45";//集团打开默认显示学习岗位 //} //else { userSearch.InCompanyID = company.CompanyId.ToString(); userSearch.InStudyPostID = studyPostIdCondition; //只显示该学习岗位下的人员 } userSearch.InGroupID = groupID; List <UserInfo> userList = UserBLL.SearchReportUserList(userSearch); //把公司所有员工的第一次考试记录都一起调起 List <TestPaperReportInfo> userFirstTestRecordList = TestPaperBLL.ReadTheFirstRecordList(userSearch.InCompanyID); //把所有员工的认证记录一起调用 PostPassInfo postPassSearch = new PostPassInfo(); postPassSearch.CreateDate = endDate; postPassSearch.InCompanyID = userSearch.InCompanyID; List <PostPassInfo> postPassList = PostPassBLL.ReadPostPassList(postPassSearch); //记录岗位课程ID串 Dictionary <int, string[]> postCourseDic = new Dictionary <int, string[]>(); foreach (UserInfo Info in userList) { int PostId = int.MinValue, PerPassCourseNum = 0, PerCourseNum = 0; PostId = Info.StudyPostID; PostInfo PostModel = PostBLL.ReadPost(PostId); if (PostModel != null) //排除掉没有设置岗位的人 { //筛选出当前用户ID的成绩列表 List <TestPaperInfo> currentUserPaperList = TestPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.UserId == Info.ID); }); List <TestPaperInfo> currentUserPassPaperList = currentUserPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.IsPass == 1); }); int ResidueCourseNum = 0;//岗位内剩余岗位课程数 if (!postCourseDic.ContainsKey(PostId)) { //岗位数据信息 1:岗位课程ID串;2:岗位课程数量;3:岗位开始时间;4:目标课程数量 string[] postData = { "0", "0", DateTime.MinValue.ToString(), "0" }; AllPostPlan = PostBLL.ReadPostCourseID(company.CompanyId, PostId); postData[0] = AllPostPlan; if (!string.IsNullOrEmpty(AllPostPlan)) { PostCourseNum = AllPostPlan.Split(',').Length; postData[1] = PostCourseNum.ToString(); } //公司有事耽误的数量 由于岗位不一样,岗位计划开始的时间也不一样,所以有事耽误的数量也是不一致的,按岗位计算 PostStartDate = CompanyPostPlanBLL.ReadCompanyPostPlan(company.CompanyId, PostId); //如果没有设置岗位开始时间或者岗位开始时间比公司开始时间早,统一使用公司开始时间 if (PostStartDate == DateTime.MinValue || PostStartDate < PostPlanStartDate) { PostStartDate = PostPlanStartDate; } //根据统一的岗位开始时间调取数据 CompanyDelayNum = ChangeNumBLL.CompanyChangeNum(company.CompanyId, PostId, PostStartDate, endDate); TargetNum = CompanyRuleBLL.GetCourseNum(company.CompanyId, PostId, PostStartDate, endDate); //理论值是每周两门 TargetNum = TargetNum - CompanyDelayNum; postData[2] = PostStartDate.ToString(); postData[3] = TargetNum.ToString(); postCourseDic.Add(PostId, postData); } else { AllPostPlan = postCourseDic[PostId][0]; PostCourseNum = int.Parse(postCourseDic[PostId][1]); PostStartDate = Convert.ToDateTime(postCourseDic[PostId][2]); TargetNum = int.Parse(postCourseDic[PostId][3]); } //如果员工是后来的,要以员工进来的时间为起始点 if (PostStartDate < Info.PostStartDate)//Info.RegisterDate { PostStartDate = Info.PostStartDate; CompanyDelayNum = ChangeNumBLL.CompanyChangeNum(company.CompanyId, PostId, PostStartDate, endDate); TargetNum = CompanyRuleBLL.GetCourseNum(company.CompanyId, PostId, PostStartDate, endDate); //理论值是每周两门 TargetNum = TargetNum - CompanyDelayNum; } TargetNum = TargetNum - ChangeNumBLL.UserChangeNum(Info.ID, PostStartDate, endDate); //PassCateId 跨岗位通过的课程 PostResidueCourse 岗位内剩余课程 string PassCateId = string.Empty, NoPassCateId = string.Empty, PostResidueCourse = string.Empty; if (!string.IsNullOrEmpty(company.PostStartDate.ToString())) { PassCateId = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= PostStartDate && TempModel.TestDate <= endDate); })); PostResidueCourse = StringHelper.SubString(AllPostPlan, TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate <= endDate); }))); } else { PassCateId = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate <= endDate); })); PostResidueCourse = StringHelper.SubString(AllPostPlan, PassCateId); } //跨岗位通过的课程数(全岗位计划开始后,累计完成的课程数) int AllPassCourseNum = 0; if (!string.IsNullOrEmpty(PassCateId)) { AllPassCourseNum = PassCateId.Split(',').Length; } //获取岗位内剩余课程数 if (!string.IsNullOrEmpty(PostResidueCourse)) { ResidueCourseNum = PostResidueCourse.Split(',').Length; } string PastPassCourse = string.Empty; PeoperNum = PeoperNum + 1; TotalPeoperNum += 1; TextOut.Append("<tr class=\"listTableMain\">\r\n"); TextOut.Append("<td>" + TotalPeoperNum + "</td>"); TextOut.Append("<td>" + company.CompanySimpleName + "</td>"); TextOut.Append("<td>" + Info.RealName + "</td>"); if (!string.IsNullOrEmpty(Info.PostName)) { TextOut.Append("<td>" + Info.PostName + "</td>"); } else { TextOut.Append("<td>" + PostBLL.ReadPost(Info.WorkingPostID).PostName + "</td>"); } TextOut.Append("<td>" + PostModel.PostName + "</td>"); TextOut.Append("<td>" + EnumHelper.ReadEnumChineseName <UserState>(Info.Status) + "</td>"); TestPaperReportInfo currentUserFirstTestRecord = userFirstTestRecordList.Find(delegate(TestPaperReportInfo tempModel) { return(tempModel.UserID == Info.ID); }); if (currentUserFirstTestRecord != null) { TextOut.Append("<td>" + currentUserFirstTestRecord.TestDate.ToString("d") + "</td>"); } else { TextOut.Append("<td> </td>"); } PostPassInfo selfPostRZ = postPassList.Find(delegate(PostPassInfo postpass) { return(postpass.UserId == Info.ID && postpass.PostId == Info.WorkingPostID); }); if (selfPostRZ != null) { TextOut.Append("<td>是</td>"); TextOut.Append("<td>" + selfPostRZ.CreateDate.ToString("d") + "</td>"); } else { TextOut.Append("<td> </td>"); TextOut.Append("<td> </td>"); } List <PostPassInfo> otherPostRZ = postPassList.FindAll(delegate(PostPassInfo postpass) { return(postpass.UserId == Info.ID && postpass.PostId != Info.WorkingPostID); }); if (otherPostRZ.Count > 0) { TextOut.Append("<td>是</td>"); //TextOut.Append("<td>"); //string otherPostName = string.Empty; //foreach (ReportPostPassInfo info in otherPostRZ) //{ // TextOut.Append(info.PassPostName + " "); //} //TextOut.Append("</td>"); } else { TextOut.Append("<td> </td>"); } for (int j = 1; j <= WeekNum; j++) { int WeekCourseNum = 0; DateTime _StartDate = startDate.AddDays(7 * (j - 1)); DateTime _EndDate = startDate.AddDays(7 * j); if (j == WeekNum) { _EndDate = endDate; } if (_StartDate < PostStartDate) { _StartDate = PostStartDate; } if (_EndDate > PostStartDate) { PastPassCourse = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= _StartDate && TempModel.TestDate <= _EndDate); })); WeekCourseNum = currentUserPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= _StartDate && TempModel.TestDate <= _EndDate); }).Count; } int PastPassCourseNum = 0; if (!string.IsNullOrEmpty(PastPassCourse)) { PastPassCourseNum = PastPassCourse.Split(',').Length; } PerPassCourseNum += PastPassCourseNum; PerCourseNum += WeekCourseNum; TextOut.Append("<td>" + WeekCourseNum + "</td>"); TextOut.Append("<td>" + (PastPassCourseNum) + "</td>"); if (PastPassCourseNum == 0) { TextOut.Append("<td>0</td>"); } else { TextOut.Append("<td>" + ((double)PastPassCourseNum / (double)WeekCourseNum).ToString("P") + "</td>"); } } //统计好学生 学习课程超过30门的人 if (PerCourseNum >= 30) { GoodStudent += " " + Info.RealName; } //统计通过课程数量第一的数据 if (PerPassCourseNum > 0 && PerPassCourseNum >= FirstPassCourseNum) { if (PerPassCourseNum > FirstPassCourseNum) { PassCourseFirstUser = Info.RealName; FirstPassCourseNum = PerPassCourseNum; } else { PassCourseFirstUser = PassCourseFirstUser + " " + Info.RealName; } } TextOut.Append("<td>" + PerCourseNum + "</td>"); TextOut.Append("<td>" + PerPassCourseNum + "</td>"); if (PerCourseNum <= 0) { TextOut.Append("<td>0</td>"); } else { TextOut.Append("<td>" + ((double)PerPassCourseNum / (double)PerCourseNum).ToString("P") + "</td>"); } TextOut.Append("<td>" + (AllPassCourseNum) + "</td>"); TextOut.Append("<td>" + (TargetNum) + "</td>"); TargetNum = AllPassCourseNum - TargetNum; TextOut.Append("<td style=\""); if (TargetNum > 0) { TextOut.Append("background: #00b050;"); GreenNum += 1; } else if (TargetNum < 0) { TextOut.Append("background: #ff0000;"); RedNum += 1; } else { TextOut.Append("background: #ffff00;"); YellowNum += 1; } TextOut.Append(" color:#000;\">" + (TargetNum) + "</td>"); TextOut.Append("</tr>\r\n"); currentUserPaperList = null; currentUserPassPaperList = null; } PostModel = null; } TestPaperList = null; //集团性质不显示总结描述 if (TotalTable == null) { if (FirstPassCourseNum > 0) { TextOut.Append("<tr class=\"listTableHead\"><th colspan=\"" + (ColNum + WeekNum * 3) + "\">课程考试通过数量最多的学霸为: <font color=red>" + PassCourseFirstUser + "</font> ,数量为: <font color=red>" + FirstPassCourseNum.ToString() + "</font> 。</th></tr>"); } if (!string.IsNullOrEmpty(GoodStudent)) { TextOut.Append("<tr class=\"listTableHead\"><th colspan=\"" + (ColNum + WeekNum * 3) + "\">月度考试数量超过30门的为好学生,此次好学生为: <font color=red>" + GoodStudent + "</font> 。</th></tr>"); } TextOut.Append("<tr class=\"listTableHead\"><th colspan=\"" + (ColNum + WeekNum * 3) + "\">未达标人数:" + RedNum.ToString() + " 刚好达标人数:" + YellowNum.ToString() + " 超越目标人数:" + GreenNum.ToString() + "</th></tr>"); TextOut.Append("<tr class=\"listTableHead\"><th colspan=\"" + (ColNum + WeekNum * 3) + "\">未达标人数:" + RedNum.ToString() + " 达标人数:" + (YellowNum + GreenNum).ToString() + " 达成率:" + ((double)(YellowNum + GreenNum) / (double)PeoperNum).ToString("P") + "</th></tr>"); } //生成集团报表内容 if (TotalTable != null) { //集团报表内容开始 groupResult[1] = (int)groupResult[1] + PeoperNum; groupResult[2] = (int)groupResult[2] + (YellowNum + GreenNum); groupResult[3] = (int)groupResult[3] + RedNum; if (((double)(YellowNum + GreenNum) / (double)PeoperNum) == 1.0) { groupResult[4] = groupResult[4] + "<span style=\"margin:0px 10px;\">" + company.CompanySimpleName + "</span>"; } else if (((double)(YellowNum + GreenNum) / (double)PeoperNum) < 0.7) { groupResult[5] = groupResult[5] + "<span style=\"margin:0px 10px;\">" + company.CompanySimpleName + "</span>"; } //GroupResult[4] += ((double)(YellowNum + GreenNum) / (double)PeoperNum); if (FirstPassCourseNum > 0 && FirstPassCourseNum >= (int)groupResult[7]) { if (FirstPassCourseNum == (int)groupResult[7]) { groupResult[6] = string.IsNullOrEmpty(groupResult[6].ToString()) ? PassCourseFirstUser : groupResult[6] + " " + PassCourseFirstUser; } else { groupResult[6] = PassCourseFirstUser; groupResult[7] = FirstPassCourseNum; } } TotalTable.AppendLine("<tr class=\"listTableMain\"><td>" + company.CompanySimpleName + "</td><td>" + PeoperNum + "</td><td>" + (YellowNum + GreenNum).ToString() + "</td><td>" + RedNum.ToString() + "</td><td>" + ((double)(YellowNum + GreenNum) / (double)PeoperNum).ToString("P") + "</td><td>" + PassCourseFirstUser + "</td><td>" + FirstPassCourseNum.ToString() + "</td></tr>"); } return(TextOut.ToString()); }
/// <summary> /// 计算考试成绩 /// </summary> /// <returns></returns> public static TestPaperInfo CalcTestResult(int companyID, int userID, int productID) { TestPaperInfo PaperModel = new TestPaperInfo(); string filePath = ReadTestPaperPath(userID, productID); TestPaperReportInfo testPaper = ReadTheLatestPaper(userID, productID); TestSettingInfo testSetting = TestSettingBLL.ReadTestSetting(companyID, productID); if (File.Exists(filePath) && (testPaper.TestDate == DateTime.MinValue || (DateTime.Now - testPaper.TestDate).TotalHours >= testSetting.TestInterval)) { XmlHelper XmlDoc = new XmlHelper(filePath); int QuestionNum = int.Parse(XmlDoc.ReadAttribute("TestPaper", "QuestionNum")); decimal Scorse = 0; //试卷得分 int RightNum = 0; //正确的题目数量 //从xml里读取答案,进行校卷 string QuestionList = string.Empty; string UserAnswerList = string.Empty; for (int StyleId = 1; StyleId <= 3; StyleId++) { string NodeName = GetTestPaperStyleNodeName(StyleId); //判断题型库里是否有考题 XmlNode Node = XmlDoc.ReadNode(NodeName); if (Node != null && Node.HasChildNodes) { XmlNodeList NodeList = XmlDoc.ReadChildNodes(NodeName); //遍历节点 foreach (XmlNode node in NodeList) { QuestionList = QuestionList + "," + node.ChildNodes[9].InnerText; UserAnswerList = UserAnswerList + "," + node.ChildNodes[6].InnerText; if (node.ChildNodes[6].InnerText.ToLower() == node.ChildNodes[5].InnerText.ToLower()) { RightNum = RightNum + 1; } } } } //UserInfo user = UserBLL.ReadUser(userID); //TestSettingInfo testSetting = TestSettingBLL.ReadTestSetting(companyID, productID); if (QuestionNum == 0) { Scorse = 0; } else { Scorse = Convert.ToDecimal(Math.Round((decimal.Parse(testSetting.PaperScore.ToString()) * RightNum / QuestionNum), 1));//这样计算的总分更准备 } if (QuestionList != string.Empty && QuestionList.StartsWith(",")) { QuestionList = QuestionList.Substring(1); UserAnswerList = UserAnswerList.Substring(1); } PaperModel.CateId = productID; PaperModel.PaperName = ProductBLL.ReadProduct(productID).Name; PaperModel.CompanyId = companyID; PaperModel.UserId = userID; PaperModel.QuestionId = QuestionList; PaperModel.Answer = UserAnswerList; PaperModel.Scorse = Scorse; if (Scorse >= testSetting.LowScore) { PaperModel.Point = 2; PaperModel.IsPass = 1; } else { PaperModel.IsPass = 0; } UserLogBLL.AddUserLog(ShopLanguage.ReadLanguage("ApplyTest"), ShopLanguage.ReadLanguage("TestPaper"), ProductBLL.ReadProduct(productID).Name); TestPaperBLL.AddPaper(PaperModel); File.SetLastWriteTime(filePath, DateTime.Now); } if ((testPaper.TestDate > DateTime.MinValue && (DateTime.Now - testPaper.TestDate).TotalHours < testSetting.TestInterval)) { PaperModel.Scorse = testPaper.Score; } //解除本课程的考试限制 //TestSettingBLL.TestEnd(userID, productID); return(PaperModel); }
//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); }
protected void HtmlOut() { startDate = Convert.ToDateTime(RequestHelper.GetQueryString <string>("SearchStartDate")); endDate = Convert.ToDateTime(RequestHelper.GetQueryString <string>("SearchEndDate")).AddDays(1); SearchStartDate.Text = startDate.ToString("d"); SearchEndDate.Text = endDate.AddDays(-1).ToShortDateString(); int WeekNum = 0, ColNum = 14; int PeoperNum = 0; StringBuilder TextOut = new StringBuilder(); CompanyInfo company = CompanyBLL.ReadCompany(companyID); companyName = company.CompanyName; //string CompanyBrandId = company.BrandId; bool isGroupCompany = base.IsGroupCompany(company.GroupId); if (isGroupCompany) { ColNum = 15; } string rowspan = string.Empty; TextOut.Append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); TextOut.Append("<thead>"); TextOut.Append("<tr class=\"listTableHead\">"); //循环开始日期 DateTime loopStartDate = startDate; if (SelectMonth == "Other") { //目前只要一周的数据 loopStartDate = endDate.AddDays(-7); WeekNum = (endDate - loopStartDate).Days / 7; if ((endDate - loopStartDate).Days % 7 > 0) { WeekNum = WeekNum + 1; } TextOut.Append("<th colspan=\"" + (ColNum + WeekNum) + "\">" + company.CompanySimpleName);//+ " [" + loopStartDate.ToString("d") + "—" + EndDate.AddDays(-1).ToString("d") + "]" rowspan = " rowspan=\"2\""; } TextOut.Append("</th></tr>\r\n"); TextOut.Append("<tr class=\"listTableHead\">\r\n"); TextOut.Append("<th" + rowspan + ">序号</th>"); if (isGroupCompany) { TextOut.Append("<td" + rowspan + ">公司名</th>"); } TextOut.Append("<th" + rowspan + " data-sort=\"string\">姓名</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"string\">工作岗位</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"string\">学习岗位</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"string\">状态</th>"); TextOut.Append("<th" + rowspan + ">初考时间</th>"); TextOut.Append("<th" + rowspan + ">岗位课程数</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"int\">岗位课程<br>完成总数</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"int\">岗位剩余<br>课程总数</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"int\">学习完成率</th>"); TextOut.Append("<th" + rowspan + ">所有已过岗位</th>"); TextOut.Append("<th" + rowspan + " data-sort=\"int\">已过岗位数量<i class=\"icon_arrow\"></i></th>"); TextOut.Append("<th" + rowspan + ">岗位已学习<br>考试未通过</th>"); TextOut.Append("<th" + rowspan + ">已通过数量</th>"); if (SelectMonth == "Other") { TextOut.Append("<th colspan=\"" + WeekNum.ToString() + "\">学习已通过</th></tr>\r\n"); TextOut.Append("<tr class=\"listTableHead\">\r\n"); for (int j = 1; j <= WeekNum; j++) { TextOut.Append("<th>第" + j.ToString() + "周<br>" + loopStartDate.AddDays(7 * (j - 1)).ToString("M-d") + "—"); if (j == WeekNum) { TextOut.Append(endDate.AddDays(-1).ToString("M-d") + "</th>"); } else { TextOut.Append(loopStartDate.AddDays((7 * j) - 1).ToString("M-d") + "</th>"); } } TextOut.Append("</tr>\r\n"); } TextOut.Append("</thead>"); TextOut.Append("<tbody>"); UserSearchInfo user = new UserSearchInfo(); user.InStatus = state; user.InGroupID = groupID; user.InWorkingPostID = postIdCondition; user.InStudyPostID = studyPostIdCondition; //只显示该学习岗位下的人员 if (isGroupCompany) { user.InCompanyID = CompanyBLL.ReadCompanyIdList(companyID.ToString()); //user.StudyPostIdCondition = "45";//集团打开默认显示学习岗位 } else { user.InCompanyID = companyID.ToString(); } if (rzDate == 1) { if (rz == 0) { user.Condition = "[id] not in (select [userid] from [_passpost] where [CreateDate]<='" + endDate + "' and [isrz]=1 and [_passpost].[postid] in (select [postid] from [_post]))"; } else if (rz == 1) { user.Condition = "[id] in (select [userid] from [_passpost] where [CreateDate]<='" + endDate + "' and [isrz]=1 and [_passpost].[postid] in (select [postid] from [_post]))"; } } else if (rzDate == 0) { if (rz == 0) { user.Condition = "[id] not in (select [userid] from [_passpost] where [CreateDate]>='" + startDate + "' And [CreateDate]<='" + endDate + "' and [isrz]=1 and [_passpost].[postid] in (select [postid] from [_post]))"; } else if (rz == 1) { user.Condition = "[id] in (select [userid] from [_passpost] where [CreateDate]>='" + startDate + "' And [CreateDate]<='" + endDate + "' and [isrz]=1 and [_passpost].[postid] in (select [postid] from [_post]))"; } } //user.Condition = string.IsNullOrEmpty(user.Condition) ? "Order by [CompanyID] Desc" : user.Condition + " Order by [CompanyID] Desc"; //user.PostIdCondition = PostIdStr; List <UserInfo> userList = UserBLL.SearchReportUserList(user);//UserBLL.SearchUserList(user); //把公司所有员工的第一次考试记录都一起调起 List <TestPaperReportInfo> userFirstTestRecordList = TestPaperBLL.ReadTheFirstRecordList(user.InCompanyID); //把公司所有员工的考试记录都一起调起 TestPaperInfo TestPaperModel = new TestPaperInfo(); //if (!string.IsNullOrEmpty(company.PostStartDate.ToString())) // TestPaperModel.TestMinDate = Convert.ToDateTime(company.PostStartDate); TestPaperModel.TestMaxDate = endDate; TestPaperModel.CompanyIdCondition = user.InCompanyID; //TestPaperModel.Field = "UserID"; TestPaperModel.Condition = "[UserID] in (select [ID] from [_User] where [CompanyID] in (" + user.InCompanyID + ")"; if (!string.IsNullOrEmpty(groupID)) { TestPaperModel.Condition += " and [GroupID] in (" + groupID + ")"; } if (!string.IsNullOrEmpty(postIdCondition)) { TestPaperModel.Condition += " and [WorkingPostID] in (" + postIdCondition + ")"; } if (!string.IsNullOrEmpty(studyPostIdCondition)) { TestPaperModel.Condition += " and [StudyPostId] in (" + studyPostIdCondition + ")"; } if (!string.IsNullOrEmpty(state)) { TestPaperModel.Condition += " and [Status] in (" + state + ")"; } TestPaperModel.Condition += ")"; List <TestPaperInfo> TestPaperList = TestPaperBLL.NewReadList(TestPaperModel); foreach (UserInfo Info in userList) { int PostId = int.MinValue; PostId = Info.StudyPostID; PostInfo PostModel = PostBLL.ReadPost(Info.StudyPostID); if (PostModel != null) //排除掉没有设置岗位的人 { //string PassCateId = TestPaperBLL.ReadListStr(Info.ID, endDate, 1); //string NoPassCateId = TestPaperBLL.ReadListStr(Info.ID, endDate, 0); //筛选出当前用户ID的成绩列表 List <TestPaperInfo> currentUserPaperList = TestPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.UserId == Info.ID); }); List <TestPaperInfo> currentUserPassPaperList = currentUserPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.IsPass == 1); }); List <TestPaperInfo> currentUserNoPassPaperList = currentUserPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.IsPass == 0); }); string PassCateId = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList); string NoPassCateId = TestPaperBLL.ReadCourseIDStr(currentUserNoPassPaperList); //从未通过的记录中去除后期又补考通过的记录 NoPassCateId = StringHelper.SubString(NoPassCateId, PassCateId); int PostCourseNum = 0; int PassCourseNum = 0; int NoPassCourseNum = 0; //岗位下所有已过级别的岗位课程 //if (isGroupCompany) // CompanyBrandId = CompanyBLL.ReadCompany(Info.CompanyID).BrandId; string AllPostPlan = PostBLL.ReadPostCourseID(Info.CompanyID, Info.StudyPostID);//PostBLL.ReadPostCourseID(Info.StudyPostID, CompanyBrandId); if (string.IsNullOrEmpty(AllPostPlan)) { PostCourseNum = 0; } else { PostCourseNum = AllPostPlan.Split(',').Length; } string PassPostCateId = StringHelper.EqualString(PassCateId, AllPostPlan); string NoPassPostCateId = StringHelper.EqualString(AllPostPlan, NoPassCateId); if (string.IsNullOrEmpty(PassPostCateId)) { PassCourseNum = 0; } else { PassCourseNum = PassPostCateId.Split(',').Length; } //选取时间段内 if (rzDate == 0) { //时间段内的学习中的岗位课程补丁,去掉即为到截止时间所有的学习中的岗位课程 if (SelectMonth == "Other") { NoPassPostCateId = StringHelper.EqualString(NoPassPostCateId, TestPaperBLL.ReadCourseIDStr(currentUserNoPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= startDate && TempModel.TestDate <= endDate); }))); } //补丁结束 } if (string.IsNullOrEmpty(NoPassPostCateId)) { NoPassCourseNum = 0; } else { NoPassCourseNum = NoPassPostCateId.Split(',').Length; } //如果公司ID不同,再次获取公司信息,减少重复操作 if (Info.CompanyID != company.CompanyId) { company = CompanyBLL.ReadCompany(Info.CompanyID); } string PastPassCourse = string.Empty; PeoperNum = PeoperNum + 1; TextOut.Append("<tr class=\"listTableMain\">\r\n"); TextOut.Append("<td>" + PeoperNum + "</td>"); if (isGroupCompany) { TextOut.Append("<td>" + company.CompanySimpleName + "</td>"); } TextOut.Append("<td>" + Info.RealName + "</td>"); if (!string.IsNullOrEmpty(Info.PostName)) { TextOut.Append("<td>" + Info.PostName + "</td>"); } else { TextOut.Append("<td>" + PostBLL.ReadPost(Info.WorkingPostID).PostName + "</td>"); } TextOut.Append("<td>" + PostModel.PostName + "</td>"); TextOut.Append("<td>" + EnumHelper.ReadEnumChineseName <UserState>(Info.Status) + "</td>"); //DateTime firstTestDate = TestPaperBLL.ReadTheOldTestPaperInfo(Info.ID).TestDate; TestPaperReportInfo currentUserFirstTestRecord = userFirstTestRecordList.Find(delegate(TestPaperReportInfo tempModel) { return(tempModel.UserID == Info.ID); }); if (currentUserFirstTestRecord != null) { TextOut.Append("<td>" + currentUserFirstTestRecord.TestDate.ToString("d") + "</td>"); } else { TextOut.Append("<td> </td>"); } TextOut.Append("<td>" + PostCourseNum.ToString() + "</td>"); TextOut.Append("<td>" + PassCourseNum.ToString() + "</td>"); TextOut.Append("<td>" + (PostCourseNum - PassCourseNum) + "</td>"); if (PostCourseNum > 0) { TextOut.Append("<td>" + (Math.Round((double)PassCourseNum / PostCourseNum, 4) * 100) + "%</td>"); } else { TextOut.Append("<td>0</td>"); } int passPostNum = 0; if (rzDate == 1) { TextOut.Append("<td>" + PostPassBLL.ReadPassPostName(Info.ID, endDate, ref passPostNum) + "</td>"); } else { TextOut.Append("<td>" + PostPassBLL.ReadPassPostName(Info.ID, startDate, endDate, ref passPostNum) + "</td>"); } TextOut.Append("<td>" + passPostNum + "</td>"); TextOut.Append("<td>" + (NoPassCourseNum) + "</td>"); if (rzDate == 0) { List <TestPaperInfo> tempList = currentUserPassPaperList.FindAll(m => m.TestDate >= startDate && m.TestDate <= endDate); if (tempList.Count > 0) { TextOut.Append("<td>" + TestPaperBLL.ReadCourseIDStr(tempList).Split(',').Length + "</td>"); } else { TextOut.Append("<td>0</td>"); } } else { TextOut.Append("<td>" + (string.IsNullOrEmpty(PassCateId) ? 0 : PassCateId.Split(',').Length) + "</td>"); } if (SelectMonth == "Other") { for (int j = 1; j <= WeekNum; j++) { if (j == WeekNum) { PastPassCourse = StringHelper.EqualString(AllPostPlan, TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= loopStartDate.AddDays(7 * (j - 1)) && TempModel.TestDate <= endDate); }))); //TestPaperBLL.ReadListStr(Info.ID, loopStartDate.AddDays(7 * (j - 1)), endDate, 1) } else { PastPassCourse = StringHelper.EqualString(AllPostPlan, TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= loopStartDate.AddDays(7 * (j - 1)) && TempModel.TestDate <= loopStartDate.AddDays(7 * j)); }))); //TestPaperBLL.ReadListStr(Info.ID, loopStartDate.AddDays(7 * (j - 1)), loopStartDate.AddDays(7 * j), 1) } int PastPassCourseNum = 0; if (!string.IsNullOrEmpty(PastPassCourse)) { PastPassCourseNum = PastPassCourse.Split(',').Length; } TextOut.Append("<td>" + (PastPassCourseNum) + "</td>"); } } else { //计算到上个时间学过的课程数 //算法(到现在所有通过的课程-到上个时间点所有完成的课程=时间段内新增课程) //时间段内新增课程与岗位计划相同的部分=时间段内新增课程 PastPassCourse = StringHelper.EqualString(AllPostPlan, StringHelper.SubString(PassCateId, TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate <= startDate); })))); //TestPaperBLL.ReadListStr(Info.ID, startDate, 1) int PastPassCourseNum = 0; if (!string.IsNullOrEmpty(PastPassCourse)) { PastPassCourseNum = PastPassCourse.Split(',').Length; } TextOut.Append("<td>" + (PastPassCourseNum) + "</td>"); } TextOut.Append("</tr>\r\n"); } } TextOut.Append("</tbody>"); TextOut.Append("</table>"); this.ReportList.InnerHtml = TextOut.ToString(); }