Ejemplo n.º 1
0
        public List <TestPaperInfo> NewReadList(TestPaperInfo Model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from [" + ShopMssqlHelper.TablePrefix + "TestPaper] ");
            List <TestPaperInfo> TempList       = new List <TestPaperInfo>();
            MssqlCondition       mssqlCondition = new MssqlCondition();

            this.PrepareCondition(mssqlCondition, Model);

            if (mssqlCondition.ToString() != string.Empty)
            {
                sql.Append("where " + mssqlCondition.ToString());
            }
            if (Model.OrderByCondition == string.Empty)
            {
                sql.Append(" Order by TestPaperId desc");
            }
            else
            {
                sql.Append(" Order by " + Model.OrderByCondition);
            }
            using (SqlDataReader dr = DbSQLHelper.ExecuteReader(sql.ToString()))
            {
                this.PrepareModel(dr, TempList);
            }

            return(TempList);
        }
Ejemplo n.º 2
0
        private List <Dictionary <string, object> > GetRecordList()
        {
            int PageIndex = RequestHelper.GetForm <int>("pageIndex");
            int PageSize  = RequestHelper.GetForm <int>("pageSize");
            int Count     = 0;
            List <Dictionary <string, object> > ReturnResult = new List <Dictionary <string, object> >();

            TestPaperInfo TestPaperModel = new TestPaperInfo();

            TestPaperModel.UserId = base.UserID;
            List <TestPaperInfo> TestPaperList = TestPaperBLL.ReadList(TestPaperModel, PageIndex, PageSize, ref Count);

            if (TestPaperList.Count > 0)
            {
                foreach (TestPaperInfo Info in TestPaperList)
                {
                    Dictionary <string, object> TempDic = new Dictionary <string, object>();
                    TempDic.Add("TestCateName", Info.PaperName);
                    TempDic.Add("Scorse", Info.Scorse);
                    TempDic.Add("PageCount", Count);
                    ReturnResult.Add(TempDic);
                }
            }
            return(ReturnResult);
        }
Ejemplo n.º 3
0
 public void PrepareModel(SqlDataReader dr, List <TestPaperInfo> List)
 {
     while (dr.Read())
     {
         TestPaperInfo Model = new TestPaperInfo();
         {
             Model.TestPaperId   = dr.GetInt32(0);
             Model.PaperName     = dr[1].ToString();
             Model.CateId        = dr.GetInt32(2);
             Model.QuestionStyle = dr[3].ToString();
             Model.QuestionId    = dr[4].ToString();
             Model.Answer        = dr[5].ToString();
             Model.Locked        = dr.GetInt32(6);
             Model.CompanyId     = dr.GetInt32(7);
             Model.UserId        = dr.GetInt32(8);
             Model.Scorse        = dr.GetDecimal(9);
             Model.TestDate      = dr.GetDateTime(10);
             Model.Point         = dr.GetDecimal(11);
             Model.IsPass        = int.Parse(dr["IsPass"].ToString());
         }
         if (List.Find(s => s.UserId == Model.UserId && s.CateId == Model.CateId && s.Scorse == Model.Scorse && s.TestDate == Model.TestDate) == null)
         {
             List.Add(Model);
         }
     }
 }
Ejemplo n.º 4
0
        public static TestPaperInfo ReadPaper(int TestPaperId)
        {
            TestPaperInfo Model = new TestPaperInfo();

            Model.TestPaperId = TestPaperId;
            return(dal.ReadPaper(Model));
        }
        /// <summary>
        /// 添加试题
        /// </summary>
        /// <param name="id">试题id</param>
        /// <param name="testpaperid">试卷id</param>
        /// <param name="testType">跳转前的试卷类型</param>
        /// <param name="subject">跳转前的试题科目</param>
        /// <param name="section">跳转前的试题章节</param>
        /// <param name="diffcult">跳转前的试题难易程度</param>
        /// <returns></returns>
        public ActionResult Add(Guid?id, int?testpaperid, string type, string subject, string section, string diffcult)
        {
            TestPaperInfo testPaperInfo = db.TestPaperInfoes.Find(testpaperid);

            switch (type)
            {
            case "选择题":
                ChoiceQuestion choicequestion = db.ChoiceQuestions.Find(id);
                testPaperInfo.ChoiceQuestions.Add(choicequestion);
                break;

            case "填空题":
                FillQuestion fillquestion = db.FillQuestions.Find(id);
                testPaperInfo.FillQuestions.Add(fillquestion);
                break;

            case "判断题":
                CheckQuestion checkquestion = db.CheckQuestions.Find(id);
                testPaperInfo.CheckQuestions.Add(checkquestion);
                break;

            case "计算题":
                CalculateQuestion calculatate = db.CalculateQuestion.Find(id);
                testPaperInfo.CalculateQuestions.Add(calculatate);
                break;
            }
            db.SaveChanges();//保存数据
            //返回到添加试题页面
            return(RedirectToAction("AddQuestions", new { id = testpaperid, testType = type, subject = subject, section = section, diffcult = diffcult }));
        }
Ejemplo n.º 6
0
        protected void Button1_ServerClick(object sender, EventArgs e)
        {
            base.CheckAdminPower("DeleteTestPaper", PowerCheckType.Single);
            string intsForm = RequestHelper.GetIntsForm("SelectID");

            if (!string.IsNullOrEmpty(intsForm))
            {
                string[] Arr = intsForm.Split(',');
                for (int i = 0; i < Arr.Length; i++)
                {
                    TestPaperInfo TestPaperModel = TestPaperBLL.ReadPaper(int.Parse(Arr[i]));
                    string        FilePath       = ServerHelper.MapPath("~/xml/" + TestPaperModel.UserId.ToString() + "_" + TestPaperModel.CateId.ToString() + ".xml");
                    if (File.Exists(FilePath))
                    {
                        File.Delete(FilePath);
                    }
                    FilePath = ServerHelper.MapPath("~/m/xml/" + TestPaperModel.UserId.ToString() + "_" + TestPaperModel.CateId.ToString() + ".xml");
                    if (File.Exists(FilePath))
                    {
                        File.Delete(FilePath);
                    }
                    TestPaperBLL.DeletePaper(int.Parse(Arr[i]));
                }
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("TestPaper"), intsForm);
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("DeleteOK"), RequestHelper.RawUrl);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 该数据访问对象的属性值装载到数据库更新参数数组
        /// </summary>
        /// <remarks></remarks>
        protected IDbDataParameter[] ValueParas(TestPaperInfo Model)
        {
            SqlParameter[] par =
            {
                new SqlParameter("@TestPaperId",   SqlDbType.VarChar),
                new SqlParameter("@PaperName",     SqlDbType.VarChar),
                new SqlParameter("@CateId",        SqlDbType.VarChar),
                new SqlParameter("@QuestionStyle", SqlDbType.VarChar),
                new SqlParameter("@QuestionId",    SqlDbType.VarChar),
                new SqlParameter("@Answer",        SqlDbType.VarChar),
                new SqlParameter("@Locked",        SqlDbType.VarChar),
                new SqlParameter("@CompanyId",     SqlDbType.Int),
                new SqlParameter("@UserId",        SqlDbType.VarChar),
                new SqlParameter("@Scorse",        SqlDbType.VarChar),
                new SqlParameter("@Point",         SqlDbType.VarChar),
                new SqlParameter("@IsPass",        SqlDbType.Int)
            };
            par[0].Value  = Model.TestPaperId;
            par[1].Value  = Model.PaperName;
            par[2].Value  = Model.CateId;
            par[3].Value  = Model.QuestionStyle;
            par[4].Value  = Model.QuestionId;
            par[5].Value  = Model.Answer;
            par[6].Value  = Model.Locked;
            par[7].Value  = Model.CompanyId;
            par[8].Value  = Model.UserId;
            par[9].Value  = Model.Scorse;
            par[10].Value = Model.Point;
            par[11].Value = Model.IsPass;

            return(par);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TestPaperInfo testPaperInfo = db.TestPaperInfoes.Find(id);

            db.TestPaperInfoes.Remove(testPaperInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        public void UpdatePaper(TestPaperInfo Model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("Update [" + ShopMssqlHelper.TablePrefix + "TestPaper] set PaperName=@PaperName,CateId=@CateId,QuestionStyle=@QuestionStyle,QuestionId=@QuestionId,Answer=@Answer,Locked=@Locked,CompanyId=@CompanyId,UserId=@UserId,Scorse=@Scorse,Point=@Point,[IsPass]=@IsPass where TestPaperId=@TestPaperId");
            SqlParameter[] par = (SqlParameter[])this.ValueParas(Model);
            DbSQLHelper.ExecuteSql(sql.ToString(), par);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public int AddPaper(TestPaperInfo Model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("Insert into [" + ShopMssqlHelper.TablePrefix + "TestPaper] ( PaperName,CateId,QuestionStyle,QuestionId,Answer,Locked,CompanyId,UserId,Scorse,Point,IsPass ) values(@PaperName,@CateId,@QuestionStyle,@QuestionId,@Answer,@Locked,@CompanyId,@UserId,@Scorse,@Point,@IsPass)");
            sql.Append("SELECT @@identity");
            SqlParameter[] par = (SqlParameter[])this.ValueParas(Model);
            return(DbSQLHelper.ExecuteSql(sql.ToString(), par));
        }
Ejemplo n.º 11
0
        public static List <TestPaperInfo> ReadReportList(string CompanyId, string CateId, DateTime StartDate, DateTime EndDate)
        {
            TestPaperInfo TestPaperModel = new TestPaperInfo();

            TestPaperModel.TestMinDate        = StartDate;
            TestPaperModel.TestMaxDate        = EndDate;
            TestPaperModel.CompanyIdCondition = CompanyId.ToString();
            TestPaperModel.CateIdCondition    = CateId;
            return(NewReadList(TestPaperModel));
        }
 public ActionResult Edit([Bind(Include = "Id,Name")] TestPaperInfo testPaperInfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(testPaperInfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(testPaperInfo));
 }
        public ActionResult Create([Bind(Include = "Id,Name")] TestPaperInfo testPaperInfo)
        {
            if (ModelState.IsValid)
            {
                db.TestPaperInfoes.Add(testPaperInfo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(testPaperInfo));
        }
Ejemplo n.º 14
0
        //读取信息
        public TestPaperInfo ReadPaper(TestPaperInfo Model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from [" + ShopMssqlHelper.TablePrefix + "TestPaper] where  TestPaperId=@TestPaperId");
            SqlParameter[] par = (SqlParameter[])this.ValueParas(Model);
            using (SqlDataReader dr = DbSQLHelper.ExecuteReader(sql.ToString(), par))
            {
                return(GetModel(dr));
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 返回指定用户的成绩列表
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public static List <TestPaperInfo> ReadList(int userID, string productID, DateTime startDate, DateTime endDate, int isPass)
        {
            TestPaperInfo Model = new TestPaperInfo();

            Model.UserId           = userID;
            Model.TestMinDate      = startDate;
            Model.TestMaxDate      = endDate;
            Model.CateIdCondition  = productID;
            Model.IsPass           = isPass;
            Model.OrderByCondition = " CateId asc,Scorse desc";
            return(dal.NewReadList(Model));
        }
Ejemplo n.º 16
0
        private List <Dictionary <string, object> > GetPerPaidCourseList()
        {
            Dictionary <int, DateTime>          prepaidTestCateList = BLLMTestCate.ReadPrepaidTestCateList(base.UserID);
            List <Dictionary <string, object> > ReturnResult        = new List <Dictionary <string, object> >();

            if (prepaidTestCateList.Count > 0)
            {
                foreach (KeyValuePair <int, DateTime> Info in prepaidTestCateList)
                {
                    Dictionary <string, object> TempDic = new Dictionary <string, object>();
                    ProductInfo product = ProductBLL.ReadProduct(Info.Key);
                    if (product != null)
                    {
                        TempDic.Add("Title", product.Name);
                        if (!string.IsNullOrEmpty(product.ProductNumber))
                        {
                            TempDic.Add("IsVideo", true);
                        }
                        if (!string.IsNullOrEmpty(product.Accessory))
                        {
                            TempDic.Add("IsTest", true);
                        }
                    }
                    else
                    {
                        TempDic.Add("Title", "已删除课程");
                    }
                    TempDic.Add("ClassID", Info.Key);
                    TempDic.Add("PayDate", Info.Value);
                    TempDic.Add("RemainderDays", 30 - (DateTime.Now - Info.Value).Days);
                    TestPaperInfo testPaperModel             = TestPaperBLL.ReadPaper(base.UserID, Info.Key);
                    Dictionary <string, object> testPaperDic = new Dictionary <string, object>();
                    if (testPaperModel != null)
                    {
                        if (testPaperModel.IsPass == 1)
                        {
                            TempDic.Add("IsPass", true);
                        }
                        else
                        {
                            TempDic.Add("IsPass", false);
                            testPaperDic.Add("TestTime", Math.Round(36 - (DateTime.Now - testPaperModel.TestDate).TotalHours, 1));
                        }
                        testPaperDic.Add("Scorse", testPaperModel.Scorse);
                        TempDic.Add("TestCount", 1);
                    }
                    TempDic.Add("TestPaperInfo", testPaperDic);
                    ReturnResult.Add(TempDic);
                }
            }
            return(ReturnResult);
        }
        // GET: TestPaperInfoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestPaperInfo testPaperInfo = db.TestPaperInfoes.Find(id);

            if (testPaperInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(testPaperInfo));
        }
Ejemplo n.º 18
0
        protected override void PageLoad()
        {
            base.PageLoad();
            TestPaperInfo testPaper = new TestPaperInfo();

            if (action != "All")
            {
                testPaper.TestMinDate = DateTime.Parse(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-1");
            }
            testPaper.UserId = base.UserID;
            base.PageSize    = 15;
            testPaperList    = TestPaperBLL.ReadList(testPaper, base.CurrentPage, base.PageSize, ref base.Count);
            base.BindPageControl(ref base.CommonPager);
        }
Ejemplo n.º 19
0
        public List <TestPaperInfo> ReadList(TestPaperInfo Model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select count(*) as TestNum,sum(point) as scorse");
            if (Model.GroupCondition != "")
            {
                sql.Append("," + Model.GroupCondition);
            }
            sql.Append(" from [" + ShopMssqlHelper.TablePrefix + "TestPaper] ");
            List <TestPaperInfo> TempList       = new List <TestPaperInfo>();
            MssqlCondition       mssqlCondition = new MssqlCondition();

            this.PrepareCondition(mssqlCondition, Model);

            if (mssqlCondition.ToString() != string.Empty)
            {
                sql.Append("where " + mssqlCondition.ToString());
            }
            if (Model.GroupCondition != "")
            {
                sql.Append(" Group by " + Model.GroupCondition);
            }
            if (Model.GroupCondition == "cateid")
            {
                sql.Append(" Order by Cateid ");
            }
            using (SqlDataReader dr = DbSQLHelper.ExecuteReader(sql.ToString()))
            {
                //this.PrepareModel(reader, TempList);
                while (dr.Read())
                {
                    TestPaperInfo Model1 = new TestPaperInfo();
                    {
                        Model1.TestNum = dr.GetInt32(0);
                        Model1.Point   = Convert.ToDecimal(dr[1].ToString());
                        Model1.UserId  = dr.GetInt32(2);
                        Model1.CateId  = dr.GetInt32(2);
                    }
                    TempList.Add(Model1);
                }
            }

            return(TempList);
        }
        /// <summary>
        /// 返回添加试卷页面
        /// </summary>
        /// <param name="id">试卷序号</param>
        /// <param name="testType">跳转前的试卷类型</param>
        /// <param name="subject">跳转前的试题科目</param>
        /// <param name="section">跳转前的试题章节</param>
        /// <param name="diffcult">跳转前的试题难易程度</param>
        /// <returns></returns>
        public ActionResult AddQuestions(int?id, string testType, string subject, string section, string diffcult)
        {
            ViewData["testType"] = testType;
            ViewData["subject"]  = subject;
            ViewData["section"]  = section;
            ViewData["diffcult"] = diffcult;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestPaperInfo testPaperInfo = db.TestPaperInfoes.Find(id);

            if (testPaperInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(testPaperInfo));
        }
Ejemplo n.º 21
0
        protected override void PageLoad()
        {
            base.PageLoad();
            base.Title = "最小学习量达成分析表";
            base.CheckUserPower("ReadEMSReport", PowerCheckType.Single);

            TestPaperInfo testPaperSearch = new TestPaperInfo();

            testPaperSearch.TestMinDate = startDate;
            testPaperSearch.TestMaxDate = ShopCommon.SearchEndDate(endDate);
            testPaperSearch.Scorse      = score;
            testPaperSearch.IsPass      = isPass;
            testPaperSearch.PaperName   = courseName;
            if (companyID < 0)
            {
                testPaperSearch.CompanyIdCondition = base.ExistsSonCompany ? base.SonCompanyID : base.UserCompanyID.ToString();
            }
            else
            {
                testPaperSearch.CompanyIdCondition = companyID.ToString();
            }

            if (!string.IsNullOrEmpty(realName) || !string.IsNullOrEmpty(userName))
            {
                UserSearchInfo user = new UserSearchInfo();
                user.RealName    = realName;
                user.UserName    = userName;
                user.InCompanyID = testPaperSearch.CompanyIdCondition;
                testPaperSearch.UserIdCondition = UserBLL.ReadUserIdStr(UserBLL.SearchUserList(user));
                if (string.IsNullOrEmpty(testPaperSearch.UserIdCondition))
                {
                    testPaperSearch.UserIdCondition = "0";
                }
            }

            //if (!string.IsNullOrEmpty(courseName))
            //{
            //    testPaperSearch.Condition = "[CateID] in (select ID from [_Product] where [Name] like '%" + courseName + "%')";
            //}
            testPaperList = TestPaperBLL.ReadList(testPaperSearch, base.CurrentPage, base.PageSize, ref this.Count);
            base.BindPageControl(ref base.CommonPager);
        }
Ejemplo n.º 22
0
        public List <TestPaperInfo> ReadList(TestPaperInfo Model, int currentPage, int pageSize, ref int count)
        {
            List <TestPaperInfo> TempList = new List <TestPaperInfo>();
            ShopMssqlPagerClass  class2   = new ShopMssqlPagerClass();

            class2.TableName   = "[" + ShopMssqlHelper.TablePrefix + "TestPaper]";
            class2.Fields      = "*";
            class2.CurrentPage = currentPage;
            class2.PageSize    = pageSize;
            class2.OrderField  = "[TestPaperId]";
            class2.OrderType   = OrderType.Desc;
            this.PrepareCondition(class2.MssqlCondition, Model);
            class2.Count = count;
            count        = class2.Count;
            using (SqlDataReader reader = class2.ExecuteReader())
            {
                this.PrepareModel(reader, TempList);
            }
            return(TempList);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 返回数据
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public TestPaperInfo GetModel(SqlDataReader dr)
        {
            TestPaperInfo Model = new TestPaperInfo();

            if (dr.Read())
            {
                Model.TestPaperId   = dr.GetInt32(0);
                Model.PaperName     = dr[1].ToString();
                Model.CateId        = dr.GetInt32(2);
                Model.QuestionStyle = dr[3].ToString();;
                Model.QuestionId    = dr[4].ToString();
                Model.Answer        = dr[5].ToString();
                Model.Locked        = dr.GetInt32(6);
                Model.CompanyId     = dr.GetInt32(7);
                Model.UserId        = dr.GetInt32(8);
                Model.Scorse        = dr.GetDecimal(9);
                Model.TestDate      = dr.GetDateTime(10);
                Model.Point         = dr.GetDecimal(11);
                Model.IsPass        = int.Parse(dr["IsPass"].ToString());
            }
            return(Model);
        }
Ejemplo n.º 24
0
 public ActionResult AutoCreate(string Subject, string diffcult, string questionNum)
 {
     try
     {
         int           num           = Convert.ToInt32(questionNum);
         TestPaperInfo testpaperinfo = new TestPaperInfo()
         {
             Name = "自动生成试卷" + DateTime.Now.ToString(),
             CalculateQuestions = db.CalculateQuestion.Where(u => u.Subject == Subject && u.Difficulty == diffcult).OrderBy(u => Guid.NewGuid()).Take(num).ToList(),
             CheckQuestions     = db.CheckQuestions.Where(u => u.Subject == Subject && u.Difficulty == diffcult).OrderBy(u => Guid.NewGuid()).Take(num).ToList(),
             ChoiceQuestions    = db.ChoiceQuestions.Where(u => u.Subject == Subject && u.Difficulty == diffcult).OrderBy(u => Guid.NewGuid()).Take(num).ToList(),
             FillQuestions      = db.FillQuestions.Where(u => u.Subject == Subject && u.Difficulty == diffcult).OrderBy(u => Guid.NewGuid()).Take(num).ToList(),
         };
         db.TestPaperInfoes.Add(testpaperinfo);
         db.SaveChanges();
         return(RedirectToAction("Index", "TestPaperInfoes"));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View("Error"));
     }
 }
Ejemplo n.º 25
0
 public void PrepareCondition(MssqlCondition mssqlCondition, TestPaperInfo Model)
 {
     mssqlCondition.Add("[PaperName]", Model.PaperName, ConditionType.Like);
     mssqlCondition.Add("[Locked]", Model.Locked, ConditionType.Equal);
     mssqlCondition.Add("[TestDate]", Model.TestMinDate, ConditionType.MoreOrEqual);
     mssqlCondition.Add("[TestDate]", Model.TestMaxDate, ConditionType.LessOrEqual);
     mssqlCondition.Add("[UserId]", Model.UserId, ConditionType.Equal);
     mssqlCondition.Add("[UserId]", Model.UserIdCondition, ConditionType.In);
     mssqlCondition.Add("[CateId]", Model.CateIdCondition, ConditionType.In);
     mssqlCondition.Add("[CompanyId]", Model.CompanyIdCondition, ConditionType.In);
     mssqlCondition.Add("[Scorse]", Model.Scorse, ConditionType.MoreOrEqual);
     mssqlCondition.Add("[Scorse]", Model.MaxScorse, ConditionType.Less);
     mssqlCondition.Add("[Del]", Model.Del, ConditionType.Equal);
     mssqlCondition.Add("[IsPass]", Model.IsPass, ConditionType.Equal);
     //if (Model.Field != string.Empty)
     //{
     //    mssqlCondition.Add("[" + Model.Field + "]", Model.Condition, ConditionType.In);
     //}
     if (!string.IsNullOrEmpty(Model.Condition))
     {
         mssqlCondition.Add(Model.Condition);
     }
 }
Ejemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //设置默认值
                if (string.IsNullOrEmpty(action))
                {
                    groupID = "36";
                    state   = ((int)UserState.Normal).ToString();
                }

                if (!string.IsNullOrEmpty(action) && companyID > 0)
                {
                    ShowArea.Style.Add("display", "");
                    company              = CompanyBLL.ReadCompany(companyID);
                    companyName          = company.CompanyName;
                    startDate            = Convert.ToDateTime(RequestHelper.GetQueryString <string>("SearchStartDate"));
                    endDate              = Convert.ToDateTime(RequestHelper.GetQueryString <string>("SearchEndDate"));
                    SearchStartDate.Text = startDate.ToString("d");
                    SearchEndDate.Text   = endDate.ToString("d");
                    endDate              = ShopCommon.SearchEndDate(endDate);

                    //计算周数
                    WeekNum = (endDate - startDate).Days / 7;
                    if ((endDate - startDate).Days % 7 > 0)
                    {
                        WeekNum = WeekNum + 1;
                    }


                    if (base.IsGroupCompany(company.GroupId))
                    {
                        StringBuilder TotalTable = new StringBuilder();
                        //调取所有用户列表
                        UserSearchInfo userSearch = new UserSearchInfo();
                        userSearch.InCompanyID = CompanyBLL.ReadCompanyIdList(companyID.ToString());
                        userSearch.Condition   = "Order by [CompanyID] Desc";
                        List <UserInfo> userAllList = UserBLL.SearchUserList(userSearch);

                        //调取所有考试记录
                        TestPaperInfo testPaperSearch = new TestPaperInfo();
                        testPaperSearch.CompanyIdCondition = userSearch.InCompanyID;
                        testPaperSearch.Condition          = "[UserID] in (select [ID] from [_User] where [CompanyID] in (" + userSearch.InCompanyID + "))";
                        List <TestPaperInfo> TestPaperAllList = TestPaperBLL.NewReadList(testPaperSearch);

                        PostPassInfo postPassSearch = new PostPassInfo();
                        postPassSearch.CreateDate  = endDate;
                        postPassSearch.InCompanyID = userSearch.InCompanyID;
                        List <PostPassInfo> postPassList = PostPassBLL.ReadPostPassList(postPassSearch);

                        TotalTable.Append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
                        TotalTable.Append("<thead>");
                        TotalTable.Append("<tr class=\"listTableHead\">");
                        TotalTable.Append("<th>单店</th>");
                        TotalTable.Append("<th>总人数</th>");
                        TotalTable.Append("<th>应学习人数</th>");
                        TotalTable.Append("<th>学习总人数</th>");
                        TotalTable.Append("<th>通过本岗位总人数</th>");
                        TotalTable.Append("<th>通过本岗位在职人数</th>");
                        TotalTable.Append("<th>正在学习他岗位人数</th>");
                        TotalTable.Append("<th>已通过认证人数</th>");
                        TotalTable.Append("<th>完成多岗位认证的人数</th>");
                        TotalTable.Append("<th>项目启动时间</th>");
                        TotalTable.Append("</tr>\r\n");
                        List <CompanyInfo> companyList = CompanyBLL.ReadCompanyListByParentID(companyID.ToString());
                        foreach (CompanyInfo companyItem in companyList)
                        {
                            Dictionary <int, int> userDic = new Dictionary <int, int>();
                            List <UserInfo>       currentCompanyUserList = userAllList.FindAll(delegate(UserInfo tempUser) { return(tempUser.CompanyID == companyItem.CompanyId); });

                            int manyPostNum = 0;
                            Dictionary <int, int> studyUserDic                    = new Dictionary <int, int>(); //有学习的人
                            Dictionary <int, int> passPostUserDic                 = new Dictionary <int, int>(); //通过认证的人
                            Dictionary <int, int> passSelfPostUserDic             = new Dictionary <int, int>(); //通过本职岗位的人
                            Dictionary <int, int> passSelfPostAndInCompanyUserDic = new Dictionary <int, int>(); //通过本职岗位还在职的人
                            Dictionary <int, int> passOtherPostUserDic            = new Dictionary <int, int>(); //通过其他岗位的人

                            foreach (UserInfo userItem in currentCompanyUserList)
                            {
                                foreach (TestPaperInfo testpaper in TestPaperAllList)
                                {
                                    if (userItem.ID == testpaper.UserId && !studyUserDic.ContainsKey(userItem.ID))
                                    {
                                        studyUserDic[userItem.ID] = userItem.ID;
                                        break;
                                    }
                                }

                                foreach (PostPassInfo postpass in postPassList)
                                {
                                    if (postpass.UserId == userItem.ID)
                                    {
                                        if (passPostUserDic.ContainsKey(userItem.ID))
                                        {
                                            passPostUserDic[userItem.ID] = passPostUserDic[userItem.ID] + 1;
                                        }
                                        else
                                        {
                                            passPostUserDic[userItem.ID] = 1;
                                        }
                                        if (postpass.PostId == userItem.WorkingPostID)
                                        {
                                            passSelfPostUserDic[userItem.ID] = userItem.ID;
                                            if (userItem.Status != (int)UserState.Del)
                                            {
                                                passSelfPostAndInCompanyUserDic[userItem.ID] = userItem.ID;
                                            }
                                        }
                                        if (postpass.PostId != userItem.WorkingPostID)
                                        {
                                            passOtherPostUserDic[userItem.ID] = userItem.ID;
                                        }
                                    }
                                }
                            }

                            foreach (int item in passPostUserDic.Values)
                            {
                                if (item > 1)
                                {
                                    manyPostNum++;
                                }
                            }
                            TotalTable.Append("<tr class=\"listTableMain\">");
                            TotalTable.Append("<td>" + companyItem.CompanySimpleName + "</td>");
                            TotalTable.Append("<td>" + currentCompanyUserList.Count + "</td>");
                            TotalTable.Append("<td>" + currentCompanyUserList.FindAll(delegate(UserInfo tempUser) { return(tempUser.Status != (int)UserState.Del); }).Count + "</td>");
                            TotalTable.Append("<td>" + studyUserDic.Count + "</td>");
                            TotalTable.Append("<td>" + passSelfPostUserDic.Count + "</td>");
                            TotalTable.Append("<td>" + passSelfPostAndInCompanyUserDic.Count + "</td>");
                            TotalTable.Append("<td>" + passOtherPostUserDic.Count + "</td>");
                            TotalTable.Append("<td>" + passPostUserDic.Count + "</td>");
                            TotalTable.Append("<td>" + manyPostNum + "</td>");
                            TotalTable.Append("<td>" + (!string.IsNullOrEmpty(companyItem.PostStartDate.ToString()) ? Convert.ToDateTime(companyItem.PostStartDate).ToString("d") : "") + "</td>");
                            TotalTable.Append("</tr>\r\n");
                        }
                        TotalTable.Append("</table>\r\n");



                        groupResult.Add(company.CompanySimpleName + "合计");
                        groupResult.Add(0);
                        groupResult.Add(0);
                        groupResult.Add(0);
                        groupResult.Add("");
                        groupResult.Add("");
                        groupResult.Add("");
                        groupResult.Add(0);
                        string dataHtml = GetTheadHtml(company);
                        TotalTable.Append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
                        TotalTable.Append("<tr class=\"listTableHead\">");
                        TotalTable.Append("<td colspan=\"7\">" + company.CompanySimpleName + " [" + startDate.ToString("d") + "—" + endDate.AddDays(-1).ToString("d") + "]");
                        TotalTable.Append("</td></tr>\r\n");
                        TotalTable.Append("<tr class=\"listTableHead\">\r\n");
                        TotalTable.Append("<td>公司名</td>");
                        TotalTable.Append("<td>参加岗位考试人数</td>");
                        TotalTable.Append("<td>最小学习量<br />学习达标人数</td>");
                        TotalTable.Append("<td>最小学习量<br />学习未达标人数</td>");
                        TotalTable.Append("<td>最小学习量<br />学习达成率</td>");
                        TotalTable.Append("<td>学霸</td>");
                        TotalTable.Append("<td>学习数量</td>");
                        TotalTable.Append("</tr>\r\n");

                        CompanyInfo companySearch = new CompanyInfo();
                        companySearch.Field            = "CompanyId";
                        companySearch.Condition        = CompanyBLL.ReadCompanyIdList(companyID.ToString());
                        companySearch.State            = 0;
                        companySearch.GroupIdCondition = "0,3";
                        List <CompanyInfo> sonCompanyList = CompanyBLL.ReadCompanyList(companySearch);
                        //List<CompanyInfo> sonCompanyList = CompanyBLL.ReadCompanyListByCompanyId(CompanyBLL.ReadCompanyIdList(companyID.ToString()));
                        foreach (CompanyInfo info in sonCompanyList)
                        {
                            if (info.CompanyId != companyID && !string.IsNullOrEmpty(info.PostStartDate.ToString()) && Convert.ToDateTime(info.PostStartDate) < endDate)
                            {
                                dataHtml += HtmlOut1(info, ref TotalTable);
                            }
                        }
                        TotalTable.Append("<tr class=\"listTableFoot\">\r\n");
                        TotalTable.Append("<td>" + groupResult[0] + "</td>");
                        TotalTable.Append("<td>" + groupResult[1] + "</td>");
                        TotalTable.Append("<td>" + groupResult[2] + "</td>");
                        TotalTable.Append("<td>" + groupResult[3] + "</td>");
                        TotalTable.Append("<td>" + (double.Parse(groupResult[2].ToString()) / double.Parse(groupResult[1].ToString())).ToString("P") + "</td>");
                        TotalTable.Append("<td>" + groupResult[6] + "</td>");
                        TotalTable.Append("<td>" + groupResult[7] + "</td>");
                        TotalTable.Append("</tr>\r\n");
                        TotalTable.Append("</table>\r\n");
                        TotalTable.Append("<div style=\"line-height:25px; text-align:left; font-size:14px; margin-bottom:50px;\"><p style=\"text-align:left;  font-size:14px; line-heigh:30px; margin-top:20px;\">4S店每人每周完成1-2小时的基础学习,将带动公司提升“百年老店”运营,建议高标为100%,低标为70%。");
                        if (!string.IsNullOrEmpty(groupResult[4].ToString()))
                        {
                            TotalTable.Append("<br /><br />目前:<span style=\"color:#00b050;\">" + groupResult[4] + "</span> 达至 <span style=\"color:#00b050;\">100%</span> ,表现良好,予以肯定。");
                        }
                        if (!string.IsNullOrEmpty(groupResult[5].ToString()))
                        {
                            TotalTable.Append("<br /><br /><span style=\"color:#FF0000;\">" + groupResult[5] + "</span> 达成率尚不足 <span style=\"color:#FF0000;\">70%</span> ,请相关部门领导关注下属自主学习时间的妥善安排。");
                        }
                        TotalTable.Append("</p></div>\r\n");
                        this.ReportList.InnerHtml = TotalTable.ToString() + dataHtml + GetTfootHtml();
                    }
                    else
                    {
                        StringBuilder TotalTable = null;
                        this.ReportList.InnerHtml = GetTheadHtml(company) + HtmlOut1(company, ref TotalTable) + GetTfootHtml();
                    }
                }
            }
        }
Ejemplo n.º 27
0
        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>&nbsp;</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>&nbsp;</td>");
                        TextOut.Append("<td>&nbsp;</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>&nbsp;</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());
        }
Ejemplo n.º 28
0
        protected string HtmlOut1(CompanyInfo company, string Type)
        {
            int       WeekNum = 0, ColNum = 10, PeoperNum = 0;
            string    logPath = ServerHelper.MapPath(@"\Log\");
            TxtLog    log     = new TxtLog(logPath);
            Stopwatch time1   = new Stopwatch();

            time1.Start();
            StringBuilder TextOut           = new StringBuilder();
            string        CompanyBrandId    = company.BrandId;
            DateTime      PostPlanStartDate = DateTime.MinValue;

            if (string.IsNullOrEmpty(company.PostStartDate.ToString()))
            {
                PostPlanStartDate = Convert.ToDateTime("2013-7-1");
            }
            else
            {
                PostPlanStartDate = Convert.ToDateTime(company.PostStartDate.ToString());
            }

            string rowspan = string.Empty;

            TextOut.Append("<table class=\"evaluation_sheet\">");
            TextOut.Append("<tr>");
            if (StartDate != DateTime.MinValue)
            {
                WeekNum = (EndDate - StartDate).Days / 7;
                if ((EndDate - StartDate).Days % 7 > 0)
                {
                    WeekNum = WeekNum + 1;
                }
                TextOut.Append("<th colspan=\"" + (ColNum + WeekNum * 3) + "\">" + company.CompanySimpleName + " [" + StartDate.ToString("d") + "—" + EndDate.AddDays(-1).ToString("d") + "]");
                rowspan = " rowspan=\"3\"";
            }
            else
            {
                TextOut.Append("<th colspan=\"" + ColNum + "\">" + company.CompanySimpleName + " [ 截止到:" + EndDate.AddDays(-1).ToString("d") + " ]");
                rowspan = " rowspan=\"3\"";
            }
            TextOut.Append("</th></tr>\r\n");
            TextOut.Append("<tr>\r\n");
            TextOut.Append("<th" + rowspan + " class=\"id\">序号</th>");
            //if (base.IsGroupCompany(company.GroupId)) TextOut.Append("<th" + rowspan + ">公司名</th>");
            TextOut.Append("<th" + rowspan + " class=\"name\">姓名</th>");
            TextOut.Append("<th" + rowspan + " class=\"post\">工作岗位</th>");
            TextOut.Append("<th" + rowspan + " class=\"post\">学习岗位</th>");
            TextOut.Append("<th colspan=\"" + (WeekNum * 3).ToString() + "\">学习已通过</th>");
            TextOut.Append("<th colspan=\"3\">合计<br />(");
            if (StartDate != DateTime.MinValue)
            {
                TextOut.Append(StartDate.ToString("d") + "—" + EndDate.AddDays(-1).ToString("d"));
            }
            else
            {
                TextOut.Append("截止到:" + EndDate.AddDays(-1).ToString("d"));
                StartDate = PostPlanStartDate;
            }
            TextOut.Append(")</th>");
            TextOut.Append("<th colspan=\"3\">从项目启动开始</th>");
            TextOut.Append("</tr>\r\n");
            TextOut.Append("<tr>\r\n");
            for (int j = 1; j <= WeekNum; j++)
            {
                TextOut.Append("<th colspan=\"3\">第" + j.ToString() + "周<br>" + StartDate.AddDays(7 * (j - 1)).ToString("M-d") + "—");
                if (j == WeekNum)
                {
                    TextOut.Append(EndDate.AddDays(-1).ToString("M-d") + "</th>");
                }
                else
                {
                    TextOut.Append(StartDate.AddDays((7 * j) - 1).ToString("M-d") + "</th>");
                }
            }
            TextOut.Append("<th rowspan=\"2\" class=\"total\">累计学习<br />考试次数</th>");
            TextOut.Append("<th rowspan=\"2\" class=\"total\">考试通过<br />课程数量</th>");
            TextOut.Append("<th rowspan=\"2\" class=\"total\">课程考试<br />通过率</th>");
            TextOut.Append("<th rowspan=\"2\" class=\"total\">累计<br>完成总数</th>");
            TextOut.Append("<th rowspan=\"2\" class=\"total\">目标<br>完成总数<br>(实际数)</th>");
            TextOut.Append("<th rowspan=\"2\" class=\"total\">学习进度<br>达成分析<br>(超前/落后)</th>");
            TextOut.Append("</tr>\r\n");
            TextOut.Append("<tr class=\"listTableHead\">\r\n");
            for (int j = 1; j <= WeekNum; j++)
            {
                TextOut.Append("<th class=\"total\">累计学习<br />考试次数</th>");
                TextOut.Append("<th class=\"total\">考试通过<br />课程数量</th>");
                TextOut.Append("<th class=\"total\">课程考试<br />通过率</th>");
            }
            TextOut.Append("</tr>\r\n");

            //统计目标课程数
            int TargetNum = 0, CompanyDelayNum = 0;
            //统计通过课程数量第一的数据信息
            string PassCourseFirstUser = string.Empty, GoodStudent = string.Empty; int FirstPassCourseNum = 0;
            //单个岗位的岗位计划开始时间
            DateTime PostStartDate = DateTime.MinValue;
            int      PostSign = 0;      //是否重新计算岗位总数的标记
            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.Condition          = "[UserID] in (select [ID] from [_User] where [companyID]=" + company.CompanyId.ToString() + " and [status]=" + (int)UserState.Normal;
            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 + ")";
            }
            TestPaperModel.Condition += ")";
            List <TestPaperInfo> TestPaperList = TestPaperBLL.NewReadList(TestPaperModel);

            UserSearchInfo userSearch = new UserSearchInfo();

            userSearch.Status          = (int)UserState.Normal;
            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);
            //记录岗位课程ID串
            Dictionary <int, string[]> postCourseDic = new Dictionary <int, string[]>();

            time1.Stop();
            log.Write("执行到会员开始循环的时间为:" + time1.Elapsed.TotalSeconds);
            time1.Reset();
            foreach (UserInfo Info in userList)
            {
                time1.Reset();
                time1.Start();
                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;
                    TextOut.Append("<tr>\r\n");
                    TextOut.Append("<td>" + PeoperNum + "</td>");
                    //if (base.IsGroupCompany(company.GroupId)) TextOut.Append("<td>" + CompanyBLL.ReadCompany(Info.CompanyID).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>");
                    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;
                time1.Stop();
                log.Write(Info.RealName + "执行时间为:" + time1.Elapsed.Milliseconds);
            }
            TestPaperList = null;
            if (FirstPassCourseNum > 0)
            {
                TextOut.Append("<tr><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><th colspan=\"" + (ColNum + WeekNum * 3) + "\">月度考试数量超过30门的为好学生,此次好学生为: <font color=red>" + GoodStudent + "</font> 。</th></tr>");
            }
            TextOut.Append("<tr><th colspan=\"" + (ColNum + WeekNum * 3) + "\">未达标人数:" + RedNum.ToString() + " 刚好达标人数:" + YellowNum.ToString() + " 超越目标人数:" + GreenNum.ToString() + "</th></tr>");
            TextOut.Append("<tr><th colspan=\"" + (ColNum + WeekNum * 3) + "\">未达标人数:" + RedNum.ToString() + " 达标人数:" + (YellowNum + GreenNum).ToString() + " 达成率:" + ((double)(YellowNum + GreenNum) / (double)PeoperNum).ToString("P") + "</th></tr>");
            TextOut.Append("</table>");
            if (string.IsNullOrEmpty(Type))
            {
                return(TextOut.ToString());
            }
            else
            {
                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);
                return("<tr><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></tr>");
            }
        }
Ejemplo n.º 29
0
        protected override void PageLoad()
        {
            int    companyID = base.UserCompanyID;
            int    userID    = base.UserID;
            string filePath  = TestPaperBLL.ReadTestPaperPath(userID, productID);

            base.PageLoad();
            base.ClearCache();
            base.Title = "考试中心";
            if (productID == int.MinValue)
            {
                ScriptHelper.Alert("请在“课程列表”中选择课程后,进行考试!");
            }
            TestSettingInfo testSetting = TestSettingBLL.ReadTestSetting(companyID, productID);
            ProductInfo     product     = ProductBLL.ReadProduct(productID);

            //if (!CompanyBLL.IsTest)
            //{
            //    Response.Write("<script>alert('该公司不允许考试,请联系管理员!');var DG = frameElement.lhgDG;DG.cancel();</script>");
            //    Response.End();
            //}
            RenZhengCateInfo renZhengProduct = RenZhengCateBLL.ReadTestCateByID(product.ID);

            if (renZhengProduct != null)
            {
                PostApprover postApprover = new PostApprover(PostPassBLL.ReadPostPassList(new PostPassInfo()
                {
                    UserId = userID, IsRZ = 1
                }));
                if (!postApprover.IsTest(renZhengProduct.PostId))
                {
                    Response.Write("<script>alert('请先完成 " + PostBLL.ReadPost(postApprover.NextPostID).PostName + " 的岗位综合认证!');window.close();</script>");
                    Response.End();
                }
            }
            if (testSetting.TestStartTime.HasValue && testSetting.TestEndTime.HasValue)
            {
                //if (product.ClassID != 4387)
                //{
                //    if (Convert.ToDateTime(testSetting.TestStartTime) > DateTime.Now || Convert.ToDateTime(testSetting.TestEndTime) < DateTime.Now)
                //    {
                //        Response.Write("<script>alert('不在 该门课程 设定的考试时间内!');var DG = frameElement.lhgDG;DG.cancel();</script>");
                //        Response.End();
                //    }
                //}
                //else
                //{
                if (testSetting.TestStartTime > DateTime.Now || testSetting.TestEndTime < DateTime.Now) //&& Convert.ToDateTime(testSetting.TestStartTime).Minute <= DateTime.Now.Minute && Convert.ToDateTime(testSetting.TestEndTime).Minute >= DateTime.Now.Minute
                {
                    Response.Write("<script>alert('不在 该门课程 设定的考试时间内!');window.close();</script>");
                    Response.End();
                }
                //}
            }

            TestPaperInfo PaperModel = new TestPaperInfo();

            PaperModel.CateIdCondition = productID.ToString();
            PaperModel.UserIdCondition = userID.ToString();
            List <TestPaperInfo> PaperList = TestPaperBLL.NewReadList(PaperModel);

            if (PaperList.Count > 0)
            {
                foreach (TestPaperInfo Item in PaperList)
                {
                    if (Item.IsPass == 1)// && Item.CateId != 5368孟特销售工具应用与说明 需要多次考试
                    {
                        Response.Write("<script>alert('您已通过,请选择其它课程!');</script>");
                        Response.End();
                    }
                    if ((DateTime.Now - Item.TestDate).TotalHours < testSetting.TestInterval)
                    {
                        if (testSetting.TestStartTime.HasValue || testSetting.TestEndTime.HasValue)
                        {
                            Response.Write("<script>alert('您已经参加过考试,暂不能重考!');window.close();</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('考完" + testSetting.TestInterval + "小时后才能重考,请选择其它课程!');window.close();</script>");
                        }
                        Response.End();
                    }
                }
            }

            if ((File.Exists(filePath) && (DateTime.Now - File.GetLastWriteTime(filePath)).TotalHours < testSetting.TestInterval))//TempPaperInfo != null && (DateTime.Now - TempPaperInfo.TestDate).TotalHours < 72
            {
                bool      HaveTest = false;
                XmlHelper XmlDoc1  = new XmlHelper(filePath);
                for (int StyleId = 1; StyleId <= 3; StyleId++)
                {
                    string NodeName = "TestPaper";
                    if (StyleId == 1)
                    {
                        NodeName = NodeName + "/Single";
                    }
                    else if (StyleId == 2)
                    {
                        NodeName = NodeName + "/Multi";
                    }
                    else if (StyleId == 3)
                    {
                        NodeName = NodeName + "/PanDuan";
                    }
                    //判断题型库里是否有考题
                    XmlNode Node = XmlDoc1.ReadNode(NodeName);
                    if (Node != null && Node.HasChildNodes)
                    {
                        XmlNodeList NodeList = XmlDoc1.ReadChildNodes(NodeName);
                        //遍历节点
                        foreach (XmlNode node in NodeList)
                        {
                            if (!string.IsNullOrEmpty(node.ChildNodes[6].InnerText))
                            {
                                HaveTest = true;
                            }
                        }
                    }
                }
                if (HaveTest)
                {
                    AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("TestPaperRecord"), ShopLanguage.ReadLanguage("TestPaper"), productID);
                    TestPaperInfo testpaper = TestPaperBLL.CalcTestResult(companyID, userID, productID);
                    if (testpaper.IsPass == 1)
                    {
                        PostPassBLL.CheckPostPass(UserID, productID);

                        //孟特销售工具应用与说明 课程处理
                        //if (productID == 5368)
                        //    TestSettingBLL.SpecialTestHandle(userID, int.Parse(CookiesHelper.ReadCookieValue("UserStudyPostId")));
                    }
                    ResponseHelper.Write("<script>alert('您上次未完成交卷,此时系统自动为您补交!得分:" + testpaper.Scorse + "分。');window.close();</script>");
                    Response.End();
                }
            }

            //开启防止多次开启同一课程考试
            //TestSettingBLL.TestBegin(userID, productID);

            paperName = product.Name;
            testTime  = (testSetting.TestTimeLength * 60).ToString();

            QuestionBLL.ReadQuestionXmlList(productID, product.Accessory, companyID, userID);
            XmlHelper XmlDoc = new XmlHelper(filePath);


            paperInfoHtml.AppendLine("<p>考试时长:" + testSetting.TestTimeLength.ToString() + " 分钟</p>");
            paperInfoHtml.AppendLine("<p>试卷总分:" + testSetting.PaperScore.ToString() + " 分</p>");
            paperInfoHtml.AppendLine("<p>试题数量:共 " + XmlDoc.ReadAttribute("TestPaper", "QuestionNum") + " 道。其中 ");
            string TempNum = XmlDoc.ReadAttribute("TestPaper", "SingleNum");

            if (int.Parse(TempNum) > 0)
            {
                paperInfoHtml.Append("单项选择题:" + TempNum + " 道;");
            }
            TempNum = XmlDoc.ReadAttribute("TestPaper", "MultiNum");
            if (int.Parse(TempNum) > 0)
            {
                paperInfoHtml.Append("多项选择题:" + TempNum + " 道;");
            }
            TempNum = XmlDoc.ReadAttribute("TestPaper", "PanDunNum");
            if (int.Parse(TempNum) > 0)
            {
                paperInfoHtml.Append("判断题:" + TempNum + " 道;");
            }
            paperInfoHtml.Append("</p>");

            int NoteCount = XmlDoc.ReadChildNodes("TestPaper/Single").Count;

            if (NoteCount > 0)
            {
                questionStyleHtml.AppendLine("<li data-id=\"1\"><a href=\"javascript:void(0);\">" + EnumHelper.ReadEnumChineseName <QuestionType>(1) + "</a></li>");
                questionIndexHtml.AppendLine("<ul data-style=\"1\" class=\"clearfix\" id=\"radio\">");
                for (int i = 1; i <= NoteCount; i++)
                {
                    questionIndexHtml.AppendLine("<li><a href=\"javascript:void(0);\">" + (i) + "</a></li>");
                }
                questionIndexHtml.AppendLine("</ul>");
            }

            NoteCount = XmlDoc.ReadChildNodes("TestPaper/Multi").Count;
            if (NoteCount > 0)
            {
                questionStyleHtml.AppendLine("<li data-id=\"2\"><a href=\"javascript:void(0);\">" + EnumHelper.ReadEnumChineseName <QuestionType>(2) + "</a></li>");
                questionIndexHtml.AppendLine("<ul data-style=\"2\" class=\"clearfix\" id=\"checkbox\">");
                for (int i = 1; i <= NoteCount; i++)
                {
                    questionIndexHtml.AppendLine("<li><a href=\"javascript:void(0);\">" + (i) + "</a></li>");
                }
                questionIndexHtml.AppendLine("</ul>");
            }

            NoteCount = XmlDoc.ReadChildNodes("TestPaper/PanDuan").Count;
            if (NoteCount > 0)
            {
                questionStyleHtml.AppendLine("<li data-id=\"3\"><a href=\"javascript:void(0);\">" + EnumHelper.ReadEnumChineseName <QuestionType>(3) + "</a></li>");
                questionIndexHtml.AppendLine("<ul data-style=\"3\" class=\"clearfix\" id=\"judge\">");
                for (int i = 1; i <= NoteCount; i++)
                {
                    questionIndexHtml.AppendLine("<li><a href=\"javascript:void(0);\">" + (i) + "</a></li>");
                }
                questionIndexHtml.AppendLine("</ul>");
            }

            UserLogBLL.AddUserLog(ShopLanguage.ReadLanguage("StartTest"), ShopLanguage.ReadLanguage("TestPaper"), paperName);
            UserLogBLL.AddUserLog(Request.Browser.Browser + "|" + Request.Browser.Version, productID);
        }
Ejemplo n.º 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            base.ClearCache();

            int companyID = base.UserCompanyID;
            int userID    = base.UserID;

            filePath = TestPaperBLL.ReadTestPaperPath(userID, productID);

            if (!IsPostBack)
            {
                if (productID < 0)
                {
                    ScriptHelper.Alert("选择课程后,进行考试!");
                    Response.End();
                }
                TestSettingInfo testSetting = TestSettingBLL.ReadTestSetting(companyID, productID);
                ProductInfo     product     = ProductBLL.ReadProduct(productID);

                RenZhengCateInfo renZhengProduct = RenZhengCateBLL.ReadTestCateByID(product.ID);
                if (renZhengProduct != null)
                {
                    PostApprover postApprover = new PostApprover(PostPassBLL.ReadPostPassList(new PostPassInfo()
                    {
                        UserId = userID, IsRZ = 1
                    }));
                    if (!postApprover.IsTest(renZhengProduct.PostId))
                    {
                        Response.Write("<script>alert('请先完成 " + PostBLL.ReadPost(postApprover.NextPostID).PostName + " 的岗位综合认证!');history.go(-1);</script>");
                        Response.End();
                    }
                }

                if (testSetting.TestStartTime != null && testSetting.TestEndTime != null)
                {
                    if (testSetting.TestStartTime > DateTime.Now || testSetting.TestEndTime < DateTime.Now)
                    {
                        Response.Write("<script>alert('不在 该门课程 设定的考试时间内!');history.go(-1);</script>");
                        Response.End();
                    }
                }
                TestPaperInfo PaperModel = new TestPaperInfo();
                PaperModel.CateIdCondition = productID.ToString();
                PaperModel.UserIdCondition = userID.ToString();
                List <TestPaperInfo> PaperList = TestPaperBLL.NewReadList(PaperModel);
                if (PaperList.Count > 0)
                {
                    foreach (TestPaperInfo Item in PaperList)
                    {
                        if (Item.IsPass == 1)// && Item.CateId != 5368//孟特销售工具应用与说明 需要多次考试
                        {
                            Response.Write("<script>alert('您已通过,请选择其它课程!');</script>");
                            Response.End();
                        }
                        if ((DateTime.Now - Item.TestDate).TotalHours < testSetting.TestInterval)
                        {
                            if (testSetting.TestStartTime != null || testSetting.TestEndTime != null)
                            {
                                Response.Write("<script>alert('您已经参加过考试,暂不能重考!');window.close();</script>");
                            }
                            else
                            {
                                Response.Write("<script>alert('考完" + testSetting.TestInterval + "小时后才能重考,请选择其它课程!');history.go(-1);</script>");
                            }
                            Response.End();
                        }
                    }
                }

                if ((File.Exists(filePath) && (DateTime.Now - File.GetLastWriteTime(filePath)).TotalHours < testSetting.TestInterval))//TempPaperInfo != null && (DateTime.Now - TempPaperInfo.TestDate).TotalHours < 72
                {
                    bool      HaveTest = false;
                    XmlHelper XmlDoc1  = new XmlHelper(filePath);
                    for (int StyleId = 1; StyleId <= 3; StyleId++)
                    {
                        string NodeName = "TestPaper";
                        if (StyleId == 1)
                        {
                            NodeName = NodeName + "/Single";
                        }
                        else if (StyleId == 2)
                        {
                            NodeName = NodeName + "/Multi";
                        }
                        else if (StyleId == 3)
                        {
                            NodeName = NodeName + "/PanDuan";
                        }
                        //判断题型库里是否有考题
                        XmlNode Node = XmlDoc1.ReadNode(NodeName);
                        if (Node != null && Node.HasChildNodes)
                        {
                            XmlNodeList NodeList = XmlDoc1.ReadChildNodes(NodeName);
                            //遍历节点
                            foreach (XmlNode node in NodeList)
                            {
                                if (!string.IsNullOrEmpty(node.ChildNodes[6].InnerText))
                                {
                                    HaveTest = true;
                                }
                            }
                        }
                    }
                    if (HaveTest)
                    {
                        AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("TestPaperRecord"), ShopLanguage.ReadLanguage("TestPaper"), productID);
                        TestPaperInfo testpaper = TestPaperBLL.CalcTestResult(companyID, userID, productID);
                        if (testpaper.IsPass == 1)
                        {
                            PostPassBLL.CheckPostPass(UserID, productID);

                            //孟特销售工具应用与说明 课程处理
                            //if (productID == 5368)
                            //    TestSettingBLL.SpecialTestHandle(userID, int.Parse(CookiesHelper.ReadCookieValue("UserStudyPostId")));
                        }
                        ResponseHelper.Write("<script>alert('您上次未完成交卷,此时系统自动为您补交!得分:" + testpaper.Scorse + "分。');window.location.href='CourseCenter.aspx';</script>");
                        Response.End();
                    }
                }


                TestName.Text = product.Name;
                endTimer      = testSetting.TestTimeLength * 60;

                QuestionBLL.ReadQuestionXmlList(productID, product.Accessory, companyID, userID);

                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("StartTest"), ShopLanguage.ReadLanguage("TestCate"), productID);
                AdminLogBLL.AddAdminLog(Request.Browser.Browser + "|" + Request.Browser.Version, productID);
            }
        }