コード例 #1
0
 public object GetSchoolInfo(GetSchool obj)
 {
     //var data = db.TblSchools.Where(r => r.UserName == obj.UserName && r.Password == obj.Password).FirstOrDefault();
     //if(data==null)
     //{
     //    return new Error() { IsError = true, Message = "Please Check UserName or Password" };
     //}
     try
     {
         var schoolid = db.TblSchools.Where(r => r.SchoolId == obj.SchoolId).FirstOrDefault();
         if (schoolid == null)
         {
             return(new Error()
             {
                 IsError = true, Message = "School  Not Found"
             });
         }
         else
         {
             return(new Result()
             {
                 IsSucess = true, ResultData = schoolid
             });
         }
     }
     catch (Exception ex)
     {
         return(new Error {
             IsError = true, Message = ex.Message
         });
     }
 }
コード例 #2
0
 public object GetSingleSchool(GetSchool obj)
 {
     try
     {
         SchoolBusiness getinfo = new SchoolBusiness();
         var            result  = getinfo.GetSchoolInfo(obj);
         return(result);
     }
     catch (Exception e)
     {
         return(new Error()
         {
             IsError = true, Message = e.Message
         });
     }
 }
コード例 #3
0
        public HttpResponseMessage GetAllSchool([FromBody] GetSchool m)
        {
            List <U_Info> schs   = new List <U_Info>();
            int           Count  = 0;
            var           filter = new BsonDocument();

            filter.Add("tp", 1);
            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);
                }
            }
            Count = MongoDbHelper.GetCount <U_Info>(DbName.U_Info, filter);
            schs  = MongoDbHelper.GetPagedList1 <U_Info, string>(DbName.U_Info, m.Skip, m.Limit, filter, w => w._id);
            List <User> lu = new List <Models.User>();

            lu = schs.Select(u => new Models.User
            {
                ID             = u._id,
                Email          = u.em,
                PersonName     = u.pnm,
                QQ             = u.qq,
                SchoolFullName = u.sfnm,
                SchoolName     = u.snm,
                Tel            = u.ph,
                AreaID         = u.area,
                Area           = Dict.Area.GetVal(u.area)
            }).ToList();
            return(ResultHelper.OK(new { Data = lu, Count = Count }));
        }
コード例 #4
0
        public HttpResponseMessage GetSchool([FromBody] GetSchool m)
        {
            List <U_Info> schs = new List <U_Info>(); int Count = 0;
            var           filter   = new BsonDocument();
            List <User>   lu       = new List <Models.User>();
            ObjectId      objectid = new ObjectId();

            ObjectId.TryParse(m.ExamID, out objectid);
            List <Sch_Sc> schsc1 = null;

            if (m.IsSend == 1)
            {
                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);
                    }
                }
                filter.Add("eid", objectid);
                filter.Add("state", 1);
                Count = MongoDbHelper.GetCount <Sch_Sc>(DbName.Sch_Sc, filter);
                if (Count == 0)
                {
                    return(ResultHelper.OK(new List <string>()));
                }
                schsc1 = MongoDbHelper.GetPagedList1 <Sch_Sc, string>(DbName.Sch_Sc, m.Skip, m.Limit, filter, w => w._id).ToList();
                var schsc = schsc1.Select(s => s.sid).ToList();
                schs = MongoDbHelper.GetPagedList <U_Info, string>(DbName.U_Info, 0, m.Limit, w => schsc.Contains(w._id), o => o._id);
            }
            if (m.IsSend == 2)
            {
                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);
                    }
                }
                filter.Add("eid", objectid);
                filter.Add("state", 0);
                Count = MongoDbHelper.GetCount <Sch_Sc>(DbName.Sch_Sc, filter);
                if (Count == 0)
                {
                    return(ResultHelper.OK(new List <string>()));
                }
                schsc1 = MongoDbHelper.GetPagedList1 <Sch_Sc, string>(DbName.Sch_Sc, m.Skip, m.Limit, filter, w => w._id).ToList();
                var schsc = schsc1.Select(s => s.sid).ToList();
                schs = MongoDbHelper.GetPagedList <U_Info, string>(DbName.U_Info, 0, m.Limit, w => schsc.Contains(w._id), o => o._id);
            }
            if (m.IsSend == 0)
            {
                schsc1 = MongoDbHelper.QueryBy <Sch_Sc>(DbName.Sch_Sc, w => w.eid == objectid);
                filter.Add("tp", 1);
                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);
                }
                Count = MongoDbHelper.GetCount <U_Info>(DbName.U_Info, filter);
                if (Count == 0)
                {
                    return(ResultHelper.OK(new List <string>()));
                }
                schs = MongoDbHelper.GetPagedList1 <U_Info, string>(DbName.U_Info, m.Skip, m.Limit, filter, w => w._id);
            }
            lu = schs.Join(schsc1, u => u._id, o => o.sid, (u, o) => new Models.User
            {
                ID             = u._id,
                Email          = u.em,
                PersonName     = u.pnm,
                QQ             = u.qq,
                SchoolFullName = u.sfnm,
                SchoolName     = u.snm,
                Tel            = u.ph,
                AreaID         = u.area,
                Area           = Dict.Area.GetVal(u.area),
                Type           = o.state
            }).ToList();
            //for (int i = 0; i < schs.Count; i++)
            //{
            //    Models.User su = new Models.User()
            //    {
            //        ID = schs[i]._id,
            //        Email = schs[i].em,
            //        PersonName = schs[i].pnm,
            //        QQ = schs[i].qq,
            //        SchoolFullName = schs[i].sfnm,
            //        SchoolName = schs[i].snm,
            //        Tel = schs[i].ph,
            //        Area = Dict.Area.GetVal(schs[i].area),
            //         Type= m.IsSend
            //    };
            //    lu.Add(su);
            //}
            return(ResultHelper.OK(new { Data = lu, Count = Count }));
        }
コード例 #5
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));
        }