Exemplo n.º 1
0
        public ActionResult GetData(ViewData e)
        {
            Log log = new Log();
            Student a = new Student(null, null, null);
            DataTable dt = new DataTable();//scoreDataTable(成绩的DataTable)
            DataTable dtCreditA = new DataTable();//CreditATableDataTable(学分A的DataTable)
            DataTable dtCreditB = new DataTable();//CreditBTableDataTable(学分B的DataTable)
            DataTable dtNotPassedCourse = new DataTable();//NotPassedCourseTableDataTable(未通过课程的DataTable)
            string jidian = null;//接收绩点返回值的变量
            Icebreaker.Models.IcebreakerEntities1 db = new IcebreakerEntities1();
            string str = null;
            //Session["name"] = "Session of Secound ";//创建Session

            log.Time = DateTime.Now;
            log.Message = "开始查询成绩";
            log.User = a.ID;
            log.Pwd = a.PWD;
            log.Server = "";
            log.Type = "Info";
            db.Logs.Add(log);
            db.SaveChanges();

            if (Session["VaildateCode"].ToString() != e.Code)
            {
                return View("Index");
            }
            else
            {
                if (e.Check == "remember-me")//数据库备份账号密码,并输出该账号密码的成绩
                {
                    str = e.server;
                    string score = null;
                    GetScore Gs = new GetScore();
                    Icebreaker.Models.Student stu = new Student();
                    Icebreaker.Models.IcebreakerEntities1 d_b = new IcebreakerEntities1();
                    PsaEncyrpt En = new PsaEncyrpt();

                    stu.ID = e.User;
                    stu.PWD = En.Encrypt(e.Pwd);//加密后存入数据库
                    stu.LASTMODIFIED = DateTime.Now;
                    d_b.Students.Add(stu);
                    d_b.SaveChanges();

                    try
                    {
                        Icebreaker.Models.IcebreakerEntities1 dAb = new IcebreakerEntities1();
                        // string EnPwd = dAb.Students.Where(p => p.ID == stu.ID).ToString();

                        List<Icebreaker.Models.Student> list1 = dAb.Students.Where(p => p.ID == stu.ID && p.C_ID > 10).ToList();
                        // string EnPwd = dAb.Students.Where(p => p.ID == stu.ID).ToString();
                        string EnPwd = null;
                        foreach (var aaa in list1)
                        {
                            EnPwd = En.Decrypt(aaa.PWD);//解密输出
                        }

                        string Pwd = EnPwd;

                        score = Gs.GetScoreInfoString(stu.ID, Pwd, str);
                        dt = Gs.GetScoreTable(score);
                        stu.SCORE = score;
                        dAb.Students.Add(stu);
                        dAb.SaveChanges();

                    }
                    catch (Exception Ex)
                    {
                        Log OnLog = new Log();
                        Icebreaker.Models.IcebreakerEntities1 OnDB = new IcebreakerEntities1();

                        OnLog.Time = DateTime.Now;
                        OnLog.Type = "Error";
                        OnLog.Message = Ex.Message + " 堆栈内容:\n" + Ex.StackTrace;
                        OnLog.User = stu.ID;
                        OnLog.Pwd = stu.PWD;
                        OnLog.Server = str;
                        OnDB.Logs.Add(OnLog);
                        OnDB.SaveChanges();

                        string s = Ex.Message;
                        ViewData["ErrorData"] = s;

                    }
                    return View("Error");
                }
                else//请求教务处服务器获得成绩数据并输出
                {
                    str = e.server;
                    a.ID = e.User;
                    a.PWD = e.Pwd;

                    //      GetTableDbset gt = new GetTableDbset();
                    //      ViewScoreTable vs = new ViewScoreTable();
                    PsaEncyrpt pas = new PsaEncyrpt();

                    GetScore gs = new GetScore();
                    try
                    {
                        //dt = gs.GetScoreTable(gs.GetScoreInfoString(a.ID, a.PWD, str)); // todo:catch异常
                        string ScoreData = gs.GetScoreInfoString(a.ID, a.PWD, str);
                        dt = gs.GetScoreTable(ScoreData);                                 //各科成绩
                        dtCreditA = gs.GetCharacterTable(ScoreData);                      //学分A:课程性质不同
                        dtCreditB = gs.GetBelongTable(ScoreData);                         //学分B:课程归属不同
                        dtNotPassedCourse = gs.GetFailTable(ScoreData);                   //未通过的课程
                        jidian = gs.GetCensusInfo(ScoreData);                             //绩点

                        try
                        {
                            ScoreView GetText = new ScoreView();                          //创建成绩视图对象
                            Icebreaker.Models.IcebreakerEntities1 dbScoreView = new IcebreakerEntities1();
                            Random ran = new Random();                                 //生成随机数
                            long Singal = ran.Next(10000000, 99999999);
                            ViewBag.Singal = Singal.ToString();

                            GetText.Time = DateTime.Now;                                  //数据库写入数据
                            GetText.User = a.ID;
                            GetText.Text = ScoreData;
                            GetText.Singal = Singal;

                            dbScoreView.ScoreViews.Add(GetText);
                            dbScoreView.SaveChanges();
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    catch (Exception ex)
                    {
                        Log loog = new Log();
                        Icebreaker.Models.IcebreakerEntities1 db2 = new IcebreakerEntities1();

                        loog.Time = DateTime.Now;
                        loog.Type = "Error";
                        loog.Message = ex.Message + "堆栈内容: \n" + ex.StackTrace;
                        loog.User = a.ID;
                        loog.Pwd = pas.Encrypt(a.PWD);
                        loog.Server = str;
                        db2.Logs.Add(loog);
                        db2.SaveChanges();

                        string s = ex.Message;
                        ViewData["ErrorData"] = s;
                        return View("Error");
                    }
                }

                //DataTable列名更改
                //各科成绩
                dt.Columns[0].ColumnName = "Year";
                dt.Columns[1].ColumnName = "Semester";
                dt.Columns[2].ColumnName = "Course";
                dt.Columns[3].ColumnName = "Obligatory";
                dt.Columns[4].ColumnName = "ObligatoryClass";
                dt.Columns[5].ColumnName = "Credit";
                dt.Columns[6].ColumnName = "GreadPoint";
                dt.Columns[7].ColumnName = "Score";
                dt.Columns[8].ColumnName = "LastScore";
                dt.Columns[9].ColumnName = "CollageName";

                //学分A
                dtCreditA.Columns[0].ColumnName = "CourseNature";
                dtCreditA.Columns[1].ColumnName = "CreditRequirements";
                dtCreditA.Columns[2].ColumnName = "GotCredit";
                dtCreditA.Columns[3].ColumnName = "NotPassdeCredit";
                dtCreditA.Columns[4].ColumnName = "NeedCredit";

                //学分B
                dtCreditB.Columns[0].ColumnName = "CourseOwnership";
                dtCreditB.Columns[1].ColumnName = "CreditRequirements";
                dtCreditB.Columns[2].ColumnName = "GotCredit";
                dtCreditB.Columns[3].ColumnName = "NotPassdeCredit";
                dtCreditB.Columns[4].ColumnName = "NeedCredit";

                //未通过的课程
                dtNotPassedCourse.Columns[0].ColumnName = "CourseNumber";
                dtNotPassedCourse.Columns[1].ColumnName = "Course";
                dtNotPassedCourse.Columns[2].ColumnName = "Credit";
                dtNotPassedCourse.Columns[3].ColumnName = "CourseNature";
                dtNotPassedCourse.Columns[4].ColumnName = "HighestGrade";

                Icebreaker.Models.ViewModelList vd = new ViewModelList();
                List<ViewModels.ViewScoreTable> list = vd.TableToEntity<ViewModels.ViewScoreTable>(dt);

                Icebreaker.Models.ViewModelList vb2 = new ViewModelList();
                List<ViewModels.ViewCreditATable> listCreditA = vb2.TableToEntity<ViewModels.ViewCreditATable>(dtCreditA);

                Icebreaker.Models.ViewModelList vb3 = new ViewModelList();
                List<ViewModels.ViewCreditBTable> listCreditB = vb3.TableToEntity<ViewModels.ViewCreditBTable>(dtCreditB);

                Icebreaker.Models.ViewModelList vb4 = new ViewModelList();
                List<ViewModels.ViewNotPassedCourseTable> listNoPassClass = vb4.TableToEntity<ViewModels.ViewNotPassedCourseTable>(dtNotPassedCourse);

                PsaEncyrpt psaa = new PsaEncyrpt();

                //           List<Student> list = db.Student.ToList();
                ViewData["TableData"] = list;
                ViewData["CreditA"] = listCreditA;
                ViewData["CreditB"] = listCreditB;
                ViewData["NoPassClass"] = listNoPassClass;
                ViewData["JiDian"] = jidian;

                Log looog = new Log();
                Icebreaker.Models.IcebreakerEntities1 db3 = new IcebreakerEntities1();
                looog.Time = DateTime.Now;
                looog.Type = "Info";
                looog.User = a.ID;
                looog.Pwd = psaa.Encrypt(a.PWD);
                looog.Server = str;
                looog.Message = "查询成绩成功,返回" + list.Count + "条数据";
                db3.Logs.Add(looog);
                db3.SaveChanges();

                ViewBag.User = a.ID;//前台输出学号
                //var aaaaa = from c in db3.Logs
                //          where c.ID == 1
                //          select c;
                return View("Score");

            }
        }
        public ActionResult PublishLostPropertyData(PublishLostPropertyViewData e, HttpPostedFileBase upImg)
        {
            LostProperty LostData = new LostProperty();//实例化失物信息类
            Icebreaker.Models.Publisher PublisherData = new Models.Publisher();//实例化发布者信息
            GetScore GS = new GetScore();//实例化验证对象
            JsonResult JsonStr = new JsonResult();//图片上传返回字符串

            bool StudentCondition = new bool();//是否为学生
            StudentCondition = GS.CheckLogin(e.PublisherStuNum, e.Passward, "172.17.1.41");//使用学号密码,通过教务系统实现对学生的验证

            //根据返回结果判断是否为学生
            if (StudentCondition == true)
            {
                Icebreaker.Models.IcebreakerEntities1 db_Publisher = new IcebreakerEntities1();
                Icebreaker.Models.IcebreakerEntities1 db_LostData = new IcebreakerEntities1();

                ///接收数据/////////////////////////////////////////////////////////////////////

                JsonStr = Upload(upImg);//调用图片上传方法

                PublisherData.PublisherStuNum = e.PublisherStuNum;//学号
                PublisherData.PublisherPhone = e.PublisherPhone;//联系方式
                PublisherData.PublisherE_mail = e.PublisherE_mail;//邮件地址

                LostData.Name = e.Name;//失物名称
                LostData.PublishDate = DateTime.Now;
                //LostData.PhotoUrl = null;//图片链接
                if (PhotoUrlSignal == true)
                {
                    LostData.PhotoUrl = PhotoUrl;
                }
                else
                {
                    LostData.PhotoUrl = null;//图片链接
                }

                LostData.PublisherNum = e.PublisherStuNum;//发布者编号(学号)
                LostData.Describtion = e.Describtion;//失物信息描述
                LostData.Condition = 0;//失物状态

                //数据写入数据库

                db_LostData.LostProperties.Add(LostData);//失物信息写入数据库
                db_LostData.SaveChanges();

                List<Models.Publisher> Publisher = db_Publisher.Publishers.Where(p => p.PublisherStuNum == PublisherData.PublisherStuNum).ToList();//从数据库取出该编号的记录
                if (Publisher.Count == 0)
                {
                    db_Publisher.Publishers.Add(PublisherData);
                    db_Publisher.SaveChanges();
                }
                return View("Index");
            }
            else
            {
                return View("Error");
            }
        }
Exemplo n.º 3
0
        public ActionResult GetChooseClassData(ChooseClassViewData e)
        {
            Log log = new Log();
            Student a = new Student(null, null, null);
            DataTable dtChoseCourse = new DataTable();//ChoseCourseTableDataTable(选课信息的DataTable)
            Icebreaker.Models.IcebreakerEntities1 db = new IcebreakerEntities1();
            string str = null;
            string SchoolYear = null;
            string SchoolTerm = null;

            log.Time = DateTime.Now;
            log.Message = "开始查询成绩";
            log.User = a.ID;
            log.Pwd = a.PWD;
            log.Server = "";
            log.Type = "Info";
            db.Logs.Add(log);
            db.SaveChanges();

            if (Session["VaildateCode"].ToString() != e.Code)
            {
                return View("Index");//修改
            }
            else
            {
                    str = e.server;
                    a.ID = e.User;
                    a.PWD = e.Pwd;
                    SchoolTerm = e.SchoolTerm;
                    switch (e.SchoolYear)
                    {
                        case "1": SchoolYear = "2015-2016"; break;
                        case "2": SchoolYear = "2014-2015"; break;
                        case "3": SchoolYear = "2013-2014"; break;
                        case "4": SchoolYear = "2012-2013"; break;
                    }

                    //      GetTableDbset gt = new GetTableDbset();
                    //      ViewScoreTable vs = new ViewScoreTable();
                    PsaEncyrpt pas = new PsaEncyrpt();

                    GetScore gs = new GetScore();
                    try
                    {
                        //dt = gs.GetScoreTable(gs.GetScoreInfoString(a.ID, a.PWD, str)); // todo:catch异常
                        string ScoreData = gs.GetScoreInfoString(a.ID, a.PWD, str);
                        string ChoseClassData = gs.GetElectiveInfoString(a.ID, a.PWD, str,SchoolYear,SchoolTerm);
                        dtChoseCourse = gs.GetElectiveTable(ChoseClassData);              //选课情况
                    }
                    catch (Exception ex)
                    {
                        Log loog = new Log();
                        Icebreaker.Models.IcebreakerEntities1 db2 = new IcebreakerEntities1();

                        loog.Time = DateTime.Now;
                        loog.Type = "Error";
                        loog.Message = ex.Message + "堆栈内容: \n" + ex.StackTrace;
                        loog.User = a.ID;
                        loog.Pwd = pas.Encrypt(a.PWD);
                        loog.Server = str;
                        db2.Logs.Add(loog);
                        db2.SaveChanges();

                        string s = ex.Message;
                        ViewData["ErrorData"] = s;
                        return View("Error");
                    }
                }

                //DataTable列名更改
                //选课情况
                dtChoseCourse.Columns[0].ColumnName = "CourseNumber";
                dtChoseCourse.Columns[1].ColumnName = "CourseName";
                dtChoseCourse.Columns[2].ColumnName = "Teacher";
                dtChoseCourse.Columns[3].ColumnName = "Credit";
                dtChoseCourse.Columns[4].ColumnName = "WeekPeriod";
                dtChoseCourse.Columns[5].ColumnName = "ClassRoom";
                dtChoseCourse.Columns[6].ColumnName = "SchoolTime";

                Icebreaker.Models.ViewModelList vb5 = new ViewModelList();
                List<ViewModels.ViewChoseCourseTable> listChoseClass = vb5.TableToEntity<ViewModels.ViewChoseCourseTable>(dtChoseCourse);

                PsaEncyrpt psaa = new PsaEncyrpt();

                //List<Student> list = db.Student.ToList();
                ViewData["ChoseClass"] = listChoseClass;

                Log looog = new Log();
                Icebreaker.Models.IcebreakerEntities1 db3 = new IcebreakerEntities1();
                looog.Time = DateTime.Now;
                looog.Type = "Info";
                looog.User = a.ID;
                looog.Pwd = psaa.Encrypt(a.PWD);
                looog.Server = str;
                looog.Message = "查询成绩成功,返回" + listChoseClass.Count + "条数据";
                db3.Logs.Add(looog);
                db3.SaveChanges();

            return View("Score");
        }
        public ActionResult ReceiverData(ReceiverViewData e,DisplayLostPropertyDataViewData a)
        {
            Icebreaker.Models.Receiver ReceiverData = new Models.Receiver();//实例化领取人信息类
            //Icebreaker.ViewModels.Receiver ReceiverPWD = new ViewModels.Receiver();//实例化领取人密码类
            ReceiveLog Log = new ReceiveLog();//实例化领取人日志类
            //GetScore GS = new GetScore();//实例化验证类

            //bool StudentCondition = new bool();
            //StudentCondition = GS.CheckLogin(e.ReceiverStuNum, e.Passward, "172.17.1.41");

            //if (StudentCondition == true)
            //{
            //    Icebreaker.Models.IcebreakerEntities1 db_Receiver = new IcebreakerEntities1();
            //    Icebreaker.Models.IcebreakerEntities1 db_Log = new IcebreakerEntities1();

            //    ReceiverData.ReceiverStuNum = e.ReceiverStuNum;
            //    ReceiverData.ReceiverPhone = e.ReceiverPhone;

            //    Log.LostPropertyNum = 0;
            //    Log.ReceiverNum = ReceiverData.ReceiverStuNum;
            //    Log.ReceiverDate = DateTime.Now;
            //    Log.Condition = 0;//领取物品状态改变为0,即审核状态

            //    //db_Receiver.Receivers.Add(ReceiverData);
            //    //db_Receiver.SaveChanges();

            //    //db_Log.ReceiveLogs.Add(Log);
            //    //db_Log.SaveChanges();

            //    return View();
            //}
            //else
            //{
            //    return View("Error");
            //}
            Icebreaker.Models.IcebreakerEntities1 db_Receiver = new IcebreakerEntities1();
            Icebreaker.Models.IcebreakerEntities1 db_Log = new IcebreakerEntities1();

            ReceiverData.ReceiverStuNum = e.ReceiverStuNum;//学号
            ReceiverData.ReceiverPhone = e.ReceiverPhone;//联系方式

            Log.LostPropertyNum = Convert.ToInt32(a.DisplayNumber);//货物编号
            Log.ReceiverNum = ReceiverData.ReceiverStuNum;//认领人编号(学号)
            Log.ReceiverDate = DateTime.Now;
            Log.Condition = 0;//领取物品状态改变为0,即审核状态

            List<Models.Receiver> Receiver = db_Receiver.Receivers.Where(p=>p.ReceiverStuNum == ReceiverData.ReceiverStuNum).ToList();//从数据库取出该编号的记录
            if (Receiver.Count == 0)
            {
                db_Receiver.Receivers.Add(ReceiverData);
                db_Receiver.SaveChanges();
            }

            db_Log.ReceiveLogs.Add(Log);
            db_Log.SaveChanges();

            return View("Index");
        }