Пример #1
0
        protected virtual void MoveItemDown(object parameter)
        {
            var temp = ViewModelList.GetSelectedElement();

            this.ViewModelList.MoveSelectedElement(1);

            temp.ForEach(v => v.IsSelected = true);
        }
Пример #2
0
        /// <summary>
        /// Revieves a message stating which vm should be viewed
        /// </summary>
        /// <param name="message"></param>
        void ReceiveViewModelControlMessage(ViewModelControlMessage <ViewModelList> message)
        {
            ViewModelList vm = new ViewModelList();

            vm = message.ActivateViewModel;
            switch (vm)
            {
            case ViewModelList.Login:
                //CurrentViewModel = MainViewModel.loginViewModel;
                CurrentViewModel = MainViewModel.loginStaffViewModel;
                break;

            case ViewModelList.Table:
                CurrentViewModel = MainViewModel.tableViewModel;
                break;

            case ViewModelList.Configuration:
                CurrentViewModel = MainViewModel.configurationViewModel;
                break;

            case ViewModelList.Keyboard:
                CurrentViewModel = MainViewModel.keyboardViewModel;
                break;

            case ViewModelList.KeyPad:
                CurrentViewModel = MainViewModel.keyPadViewModel;
                break;

            case ViewModelList.NumPad:
                CurrentViewModel = MainViewModel.numPadViewModel;
                break;

            case ViewModelList.ConfigKeyboard:
                CurrentViewModel = MainViewModel.configUsersKeyboardViewModel;
                break;

            case ViewModelList.ConfigNumPad:
                CurrentViewModel = MainViewModel.configUsersNumpadViewModel;
                break;

            case ViewModelList.PasswordReset:
                CurrentViewModel = MainViewModel.passwordResetViewModel;
                break;

            case ViewModelList.ClockIn:
                CurrentViewModel = MainViewModel.clockInViewModel;
                break;

            default:
                break;
            }
        }
Пример #3
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");

            }
        }
Пример #4
0
 public EditarCommand(ViewModelList vm)
 {
     _vm = vm;
 }
Пример #5
0
 public AdicionarCommand(ViewModelList vm)
 {
     _vm = vm;
 }
Пример #6
0
 public DeletarCommand(ViewModelList vm)
 {
     _vm = vm;
 }
Пример #7
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");
        }
Пример #8
0
 public ViewModelControlMessage(ViewModelList activateViewModel)
 {
     this.ActivateViewModel = activateViewModel;
 }
Пример #9
0
 public GoBackCommand(ViewModelList viewModel)
 {
     Viewmodel = viewModel;
 }
Пример #10
0
 public ViewList()
 {
     InitializeComponent();
     BindingContext = new ViewModelList();
 }
Пример #11
0
        /// <summary>
        /// RegisterViewModels
        /// </summary>
        /// <param name="register"></param>
        public static void RegisterViewModel(ViewModelList register)
        {
            switch (register)
            {
            case ViewModelList.Login:
                //if (SimpleIoc.Default.IsRegistered<LoginViewModel>() == false)
                //{
                //    SimpleIoc.Default.Register<LoginViewModel>();
                //}
                if (SimpleIoc.Default.IsRegistered <LoginStaffViewModel>() == false)
                {
                    SimpleIoc.Default.Register <LoginStaffViewModel>();
                }
                break;

            case ViewModelList.Table:
                if (SimpleIoc.Default.IsRegistered <TableViewModel>() == false)
                {
                    SimpleIoc.Default.Register <TableViewModel>();
                }
                break;

            case ViewModelList.Configuration:
                if (SimpleIoc.Default.IsRegistered <ConfigurationViewModel>() == false)
                {
                    SimpleIoc.Default.Register <ConfigurationViewModel>();
                }
                break;

            case ViewModelList.Keyboard:
                if (SimpleIoc.Default.IsRegistered <KeyboardBase>() == false)
                {
                    SimpleIoc.Default.Register <KeyboardBase>();
                }
                break;

            case ViewModelList.KeyPad:
                if (SimpleIoc.Default.IsRegistered <KeyPadViewModel>() == false)
                {
                    SimpleIoc.Default.Register <KeyPadViewModel>();
                }
                break;

            case ViewModelList.NumPad:
                if (SimpleIoc.Default.IsRegistered <NumPadViewModel>() == false)
                {
                    SimpleIoc.Default.Register <NumPadViewModel>();
                }
                break;

            case ViewModelList.ConfigKeyboard:
                if (SimpleIoc.Default.IsRegistered <ConfigUsersKeyboardViewModel>() == false)
                {
                    SimpleIoc.Default.Register <ConfigUsersKeyboardViewModel>();
                }
                break;

            case ViewModelList.ConfigNumPad:
                if (SimpleIoc.Default.IsRegistered <ConfigUsersNumpadViewModel>() == false)
                {
                    SimpleIoc.Default.Register <ConfigUsersNumpadViewModel>();
                }
                break;

            case ViewModelList.PasswordReset:
                if (SimpleIoc.Default.IsRegistered <PasswordResetViewModel>() == false)
                {
                    SimpleIoc.Default.Register <PasswordResetViewModel>();
                }
                break;

            case ViewModelList.ClockIn:
                if (SimpleIoc.Default.IsRegistered <ClockInViewModel>() == false)
                {
                    SimpleIoc.Default.Register <ClockInViewModel>();
                }
                break;

            default:
                break;
            }
        }
Пример #12
0
        /// <summary>
        /// Dispose ViewModels
        /// </summary>
        /// <param name="dispose"></param>
        public static void Cleanup(ViewModelList dispose)
        {
            // TODO Clear the ViewModels
            switch (dispose)
            {
            case ViewModelList.Login:
                //if (SimpleIoc.Default.IsRegistered<LoginViewModel>())
                //{
                //    SimpleIoc.Default.Unregister<LoginViewModel>();
                //}
                if (SimpleIoc.Default.IsRegistered <LoginStaffViewModel>())
                {
                    SimpleIoc.Default.Unregister <LoginStaffViewModel>();
                }
                break;

            case ViewModelList.Table:
                if (SimpleIoc.Default.IsRegistered <TableViewModel>())
                {
                    SimpleIoc.Default.Unregister <TableViewModel>();
                }
                break;

            case ViewModelList.Configuration:
                if (SimpleIoc.Default.IsRegistered <ConfigurationViewModel>())
                {
                    SimpleIoc.Default.Unregister <ConfigurationViewModel>();
                }
                break;

            case ViewModelList.Keyboard:
                if (SimpleIoc.Default.IsRegistered <KeyboardBase>())
                {
                    SimpleIoc.Default.Unregister <KeyboardBase>();
                }
                break;

            case ViewModelList.KeyPad:
                if (SimpleIoc.Default.IsRegistered <KeyPadViewModel>())
                {
                    SimpleIoc.Default.Unregister <KeyPadViewModel>();
                }
                break;

            case ViewModelList.NumPad:
                if (SimpleIoc.Default.IsRegistered <NumPadViewModel>())
                {
                    SimpleIoc.Default.Unregister <NumPadViewModel>();
                }
                break;

            case ViewModelList.ConfigKeyboard:
                if (SimpleIoc.Default.IsRegistered <ConfigUsersKeyboardViewModel>())
                {
                    SimpleIoc.Default.Unregister <ConfigUsersKeyboardViewModel>();
                }
                break;

            case ViewModelList.ConfigNumPad:
                if (SimpleIoc.Default.IsRegistered <ConfigUsersNumpadViewModel>())
                {
                    SimpleIoc.Default.Unregister <ConfigUsersNumpadViewModel>();
                }
                break;

            case ViewModelList.PasswordReset:
                //if (SimpleIoc.Default.IsRegistered<PasswordResetNumPadViewModel>())
                //{
                //    SimpleIoc.Default.Unregister<PasswordResetNumPadViewModel>();
                //}
                break;

            case ViewModelList.ClockIn:
                if (SimpleIoc.Default.IsRegistered <ClockInViewModel>())
                {
                    SimpleIoc.Default.Unregister <ClockInViewModel>();
                }
                break;

            default:
                break;
            }
        }