コード例 #1
0
ファイル: AdminController.cs プロジェクト: maziweis/ExamJKY
        public HttpResponseMessage SignSchool([FromBody] User m)
        {
            var sc = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == m.ID);

            if (sc != null)
            {
                return(ResultHelper.Failed("该用户已存在"));
            }
            U_Info s = new U_Info()
            {
                _id  = m.ID,
                em   = m.Email,
                ph   = m.Tel,
                pnm  = m.PersonName,
                pwd  = SecurityHelper.EncryptString("666666"),
                qq   = m.QQ,
                sfnm = m.SchoolFullName,
                snm  = m.SchoolName,
                tp   = 1,
                area = m.AreaID
            };

            MongoDbHelper.Insert(s, DbName.U_Info);
            var exam = MongoDbHelper.QueryOne <E_Info>(DbName.E_Info, w => w.btstate == 0 && w.IsDel == 0);

            if (exam != null)
            {
                Sch_Sc sc1 = new Sch_Sc();
                sc1.eid   = exam._id;
                sc1.sid   = s._id;
                sc1.state = 0;
                sc1.snm   = s.snm;
                sc1.area  = s.area;
                MongoDbHelper.Insert(sc1, DbName.Sch_Sc);
            }
            return(ResultHelper.OK());
        }
コード例 #2
0
        public HttpResponseMessage AddExam([FromBody] ExamInfo m)
        {
            var hisExam = MongoDbHelper.QueryOne <E_Info>(DbName.E_Info, w => w.btstate == 0 && w.IsDel == 0);

            if (hisExam != null)
            {
                return(ResultHelper.Failed("已存在进行中的考试"));
            }
            if (m == null)
            {
                return(ResultHelper.Failed("类容不能为空"));
            }
            E_Info eInfo = new E_Info()
            {
                _id     = ObjectId.GenerateNewId(),
                ppid    = m.PublishID,
                pt      = Function.ConvertDateI(DateTime.Now),
                enm     = m.ExamName,
                sst     = m.StuStartTime,
                set     = m.StuEndTime,
                tst     = m.TchStartTime,
                tet     = m.TchEndTime,
                stcfm   = 0,
                tchcfm  = 0,
                btstate = 0,
                IsDel   = 0
            };

            foreach (var item in m.subNames)
            {
                Sb sb = new Sb();
                sb._id   = item.Key;
                sb.sbnm  = item.Value;
                sb.stct  = 0;
                sb.tchct = 0;
                eInfo.sbs.Add(sb);
            }
            string[] stuType = m.stuTypes.Split(',');
            foreach (var item in stuType)
            {
                Stp sTp = new Stp()
                {
                    _id = ObjectId.GenerateNewId(), tp = item
                };
                eInfo.stps.Add(sTp);
            }
            MongoDbHelper.Insert(eInfo, DbName.E_Info);
            var           allsch = MongoDbHelper.QueryBy <U_Info>(DbName.U_Info, w => w.tp == 1);
            List <Sch_Sc> ls     = new List <Sch_Sc>();

            for (int i = 0; i < allsch.Count; i++)
            {
                Sch_Sc sc = new Sch_Sc();
                sc.eid   = eInfo._id;
                sc.sid   = allsch[i]._id;
                sc.state = 0;
                sc.snm   = allsch[i].snm;
                sc.area  = allsch[i].area;
                ls.Add(sc);
            }
            MongoDbHelper.Insert(ls, DbName.Sch_Sc);
            return(ResultHelper.OK());
        }