コード例 #1
0
ファイル: AdminController.cs プロジェクト: maziweis/ExamJKY
        public HttpResponseMessage ExportArea()
        {
            var           sts  = MongoDbHelper.QueryBy <U_Info>(DbName.U_Info, w => w.tp == 2);
            List <string> data = ExcelBLL.GetAreaColumn();
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            for (int i = 0; i < sts.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = sts[i]._id;
                dr[1] = Dict.Area.GetVal(sts[i].area);
                dr[2] = sts[i].pnm;
                dr[3] = sts[i].ph;
                dr[4] = sts[i].em;
                dr[5] = sts[i].qq;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }
コード例 #2
0
        public HttpResponseMessage ExportPaperExcel([FromBody] ExportPaper m)
        {
            var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);

            if (eInfo == null)
            {
                return(ResultHelper.Failed("未查到当前考试"));
            }
            var filter = new BsonDocument();

            filter.Add("eid", eInfo._id);
            if (!string.IsNullOrEmpty(m.School))
            {
                int id = -1;
                if (int.TryParse(m.School, out id))
                {
                    filter.Add("sid", m.School);
                }
                else
                {
                    filter.Add("snm", m.School);
                }
            }
            var           sts  = MongoDbHelper.GetPagedList1 <Pp_Nm, string>(DbName.Pp_Nm, 0, 0, filter, w => w.sid);
            List <string> data = ExcelBLL.GetPaperColumn(eInfo);
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            for (int i = 0; i < sts.Count; i++)
            {
                DataRow dr    = dt.NewRow();
                var     count = 0;
                dr[0] = sts[i].sid;
                dr[1] = sts[i].snm;
                for (int j = 0; j < eInfo.sbs.Count; j++)
                {
                    var pp = sts[i].sbnms.Where(w => w.sbnm == eInfo.sbs[j].sbnm).FirstOrDefault();
                    if (pp != null)
                    {
                        dr[3 + j] = pp.sct;
                        count    += pp.sct;
                    }
                    else
                    {
                        dr[3 + j] = 0;
                    }
                }
                dr[2] = count;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }
コード例 #3
0
        public HttpResponseMessage ExportTchExcel([FromBody] ExportTchInfo m)
        {
            var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);

            if (eInfo == null)
            {
                return(ResultHelper.Failed("未查到当前考试"));
            }
            var filter = new BsonDocument();

            filter.Add("eid", eInfo._id);
            if (!string.IsNullOrEmpty(m.School))
            {
                int id = -1;
                if (int.TryParse(m.School, out id))
                {
                    filter.Add("sid", m.School);
                }
                else
                {
                    filter.Add("snm", m.School);
                }
            }
            if (!string.IsNullOrEmpty(m.Subject))
            {
                filter.Add("sb", m.Subject);
            }
            if (!string.IsNullOrEmpty(m.Name))
            {
                filter.Add("nm", m.Name);
            }
            var           tchs = MongoDbHelper.GetPagedList1 <Tch_Info, string>(DbName.Tch_Info, 0, 0, filter, w => w.nm);
            List <string> data = ExcelBLL.GetTchColumn();
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            for (int i = 0; i < tchs.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = tchs[i].sid;
                dr[1] = tchs[i].snm;
                dr[2] = tchs[i].sb;
                dr[3] = tchs[i].nm;
                dr[4] = tchs[i].sx == 0 ? "女" : "男";
                dr[5] = tchs[i].zc;
                dr[6] = tchs[i].ph;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }
コード例 #4
0
ファイル: StudentController.cs プロジェクト: maziweis/ExamJKY
        public HttpResponseMessage ExportStuExcel([FromBody] ExportStuInfo m)
        {
            var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);

            if (eInfo == null)
            {
                return(ResultHelper.Failed("未查到当前考试"));
            }
            var filter = new BsonDocument();

            filter.Add("eid", eInfo._id);
            if (!string.IsNullOrEmpty(m.School))
            {
                int id = -1;
                if (int.TryParse(m.School, out id))
                {
                    filter.Add("sid", m.School);
                }
                else
                {
                    filter.Add("snm", m.School);
                }
            }
            if (!string.IsNullOrEmpty(m.StudentID))
            {
                filter.Add("stid", m.StudentID);
            }
            if (!string.IsNullOrEmpty(m.StudentName))
            {
                filter.Add("nm", m.StudentName);
            }
            var           sts  = MongoDbHelper.GetPagedList1 <St_Info, string>(DbName.St_Info, 0, 0, filter, w => w.stid);
            List <string> data = ExcelBLL.GetStuColumn(eInfo);
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            for (int i = 0; i < sts.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = sts[i].sid;
                dr[1] = sts[i].snm;
                dr[2] = sts[i].stid;
                dr[3] = sts[i].cls;
                dr[4] = sts[i].nm;
                for (int j = 0; j < eInfo.sbs.Count; j++)
                {
                    var sb = sts[i].subEs.Where(w => w.sbnm == eInfo.sbs[j].sbnm).FirstOrDefault();
                    if (sb != null)
                    {
                        dr[5 + j * 3] = sb.sbrm;
                        dr[6 + j * 3] = sb.sbst;
                        dr[7 + j * 3] = sb.sbtch;
                    }
                    else
                    {
                        dr[5 + j * 3] = null;
                        dr[6 + j * 3] = null;
                        dr[7 + j * 3] = null;
                    }
                }
                dr[5 + eInfo.sbs.Count * 3] = sts[i].idcd;
                dr[6 + eInfo.sbs.Count * 3] = sts[i].tp;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }
コード例 #5
0
        public HttpResponseMessage ExportScore([FromBody] ExportScore m)
        {
            var eInfo = MongoDbHelper.FindOne <E_Info>(m.ExamID, DbName.E_Info);

            if (eInfo == null)
            {
                return(ResultHelper.Failed("未查到当前考试"));
            }
            var filter = new BsonDocument();

            filter.Add("eid", eInfo._id);
            if (!string.IsNullOrEmpty(m.School))
            {
                filter.Add("sid", m.School);
            }
            if (!string.IsNullOrEmpty(m.StudentID))
            {
                filter.Add("stid", m.StudentID);
            }
            if (!string.IsNullOrEmpty(m.Name))
            {
                filter.Add("nm", m.Name);
            }
            var           stSc = MongoDbHelper.GetPagedList1 <St_Sc, string>(DbName.St_Sc, 0, 0, filter, w => w.nm);
            List <string> data = ExcelBLL.GetScoreColumn(eInfo);
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            Type t = typeof(St_Sc);
            List <PropertyInfo> p = t.GetProperties().ToList();
            Dictionary <string, PropertyInfo> dic = new Dictionary <string, PropertyInfo>();
            List <string> sbs = eInfo.sbs.Select(w => "s" + w._id).ToList();

            p.ForEach(w =>
            {
                if (sbs.Contains(w.Name))
                {
                    dic.Add(w.Name, w);
                }
            });
            for (int i = 0; i < stSc.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = stSc[i].stid;
                dr[1] = stSc[i].cls;
                dr[2] = stSc[i].nm;
                dr[3] = stSc[i].idcd;
                for (int j = 0; j < sbs.Count; j++)
                {
                    PropertyInfo pro   = dic[sbs[j]];
                    string       value = pro.GetValue(stSc[i], null).ToString();
                    dr[4 + j] = value == "-1"?"-":value;
                }
                dr[4 + sbs.Count] = stSc[i].sc;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }
コード例 #6
0
ファイル: AdminController.cs プロジェクト: maziweis/ExamJKY
        public HttpResponseMessage ExportSchool([FromBody] GetSchool m)
        {
            List <U_Info> sts      = new List <U_Info>();
            var           filter   = new BsonDocument();
            ObjectId      objectid = new ObjectId();

            if (ObjectId.TryParse(m.ExamID, out objectid))
            {
                filter.Add("eid", objectid);
                if (!string.IsNullOrEmpty(m.School))
                {
                    int id = -1;
                    if (int.TryParse(m.School, out id))
                    {
                        filter.Add("sid", m.School);
                    }
                    else
                    {
                        filter.Add("snm", m.School);
                    }
                }
                if (m.Area != 0)
                {
                    filter.Add("area", m.Area);
                }
                if (m.IsSend != 0)
                {
                    filter.Add("state", m.IsSend);
                }
                var schsc1 = MongoDbHelper.GetPagedList1 <Sch_Sc, string>(DbName.Sch_Sc, 0, 10000, filter, w => w._id).ToList();
                var schsc  = schsc1.Select(s => s.sid).ToList();
                sts = MongoDbHelper.GetPagedList <U_Info, string>(DbName.U_Info, 0, 10000, w => schsc.Contains(w._id), o => o._id);
            }
            else
            {
                if (!string.IsNullOrEmpty(m.School))
                {
                    int id = -1;
                    if (int.TryParse(m.School, out id))
                    {
                        filter.Add("_id", m.School);
                    }
                    else
                    {
                        filter.Add("snm", m.School);
                    }
                }
                if (m.Area != 0)
                {
                    filter.Add("area", m.Area);
                }
                sts = MongoDbHelper.GetPagedList1 <U_Info, string>(DbName.U_Info, 0, 10000, filter, w => w._id).ToList();
            }
            //var sts = MongoDbHelper.QueryBy<U_Info>(DbName.U_Info, w => w.tp == 1);
            List <string> data = ExcelBLL.GetSchColumn();
            DataTable     dt   = new DataTable();

            for (int j = 0; j < data.Count; j++)
            {
                dt.Columns.Add(data[j]);
            }
            for (int i = 0; i < sts.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = sts[i]._id;
                dr[1] = sts[i].snm;
                dr[2] = Dict.Area.GetVal(sts[i].area);
                dr[3] = sts[i].pnm;
                dr[4] = sts[i].ph;
                dr[5] = sts[i].em;
                dr[6] = sts[i].qq;
                dt.Rows.Add(dr);
            }
            string file = ExcelBLL.BuildExcel1(data.ToArray(), dt);
            string url  = RequestContext.Url.Request.RequestUri.Authority + "\\" + file;

            return(ResultHelper.OK(url));
        }