Example #1
0
        /// <summary>
        /// 绘制学生控件。
        /// </summary>
        /// <param name="students"></param>
        protected void DrawStudents(StudentsEx students)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object sender)
            {
                int len = 0;
                StudentControls controls = new StudentControls();
                if (students != null && (len = students.Count) > 0)
                {
                    for (int i = 0; i < len; i++)
                    {
                        if (students[i] != null)
                        {
                            StudentControl sc = new StudentControl();
                            sc.ColorSettings = this.settings;
                            sc.MachineName = students[i].MachineName;
                            sc.UserIP = students[i].IP;
                            sc.UserInfo = new UserInfo();
                            sc.UserInfo.UserID = students[i].StudentID;
                            sc.UserInfo.UserCode = students[i].StudentCode;
                            sc.UserInfo.UserName = students[i].StudentName;
                            sc.PropertyChanged += this.StudentControlPropertyChanged;
                            sc.DoubleClick += this.StudentControlDoubleClick;
                            sc.State = students[i].Status;
                            sc.DragDropData += this.IssueResourceData;
                            sc.ContextHandler += this.SCContextMenu;
                            controls.Add(sc);
                        }
                    }
                }
                //绘制界面。
                this.ThreadSafeMethod(this.panelWork, new MethodInvoker(delegate()
                {
                    controls.DrawToPanel(this.panelWork, 4, 5);
                }));

            }));
        }
        /// <summary>
        /// 启动侦听。
        /// </summary>
        /// <param name="students"></param>
        public void StartListen(StudentsEx students)
        {
            if (students == null)
            {
                throw new ArgumentNullException("students", "学生未准备就绪");
            }
            students.SetOfflineStatus();
            #region 初始化学生作品存储。
            if (this.userInfo != null && this.sci != null)
            {
                lock (this)
                {
                    this.classId = this.sci.ClassInfo.ClassID;
                    LocalStudentWorkStore store = LocalStudentWorkStore.DeSerializer(this.userInfo.UserID, this.sci.CatalogInfo.CatalogID, this.sci.ClassInfo.ClassID);
                    #region 初始化。
                    if (store == null)
                    {
                        store = new LocalStudentWorkStore();
                        store.TeacherID = this.userInfo.UserID;
                        store.GradeID = this.sci.GradeID;
                        store.CatalogID = this.sci.CatalogInfo.CatalogID;
                        store.ClassID = this.sci.ClassInfo.ClassID;
                        store.Evaluate = this.sci.Evaluate;
                    }
                    #endregion

                    #region 更新。
                    store.TeacherName = this.userInfo.UserName;
                    store.GradeName = this.sci.GradeName;
                    store.CatalogName = this.sci.CatalogInfo.CatalogName;
                    store.ClassName = this.sci.ClassInfo.ClassName;
                    store.Evaluate = this.sci.Evaluate;
                    #endregion

                    #region 更新学生信息。
                    if (students != null && students.Count > 0)
                    {
                        if (store.Students == null) store.Students = new LocalStudents();
                        string sId = null;
                        for (int i = 0; i < students.Count; i++)
                        {
                            sId = students[i].StudentID;
                            if (!string.IsNullOrEmpty(sId))
                            {
                                LocalStudent ls = store.Students[sId];
                                if (ls == null)
                                {
                                    ls = new LocalStudent(students[i]);
                                    store.Students.Add(ls);
                                }
                                //恢复关联。
                                Tools.RecoveryWorkAssociation(ref store, ls.StudentID);
                                if (ls.HasWork())
                                {
                                    students[i].Status |= StudentControl.EnumStudentState.Upload;
                                    if ((ls.Work.Status & EnumWorkStatus.Review) == EnumWorkStatus.Review)
                                    {
                                        students[i].Status |= StudentControl.EnumStudentState.Review;
                                    }
                                }

                            }
                        }
                    }
                    #endregion

                    //序列化数据。
                    if (!WorkStoreHelper.Serializer(ref store))
                    {
                        throw new Exception("生成索引文件失败(索引文件被占用),请稍后重试!");
                    }
                    //设置当前班级学生。
                    Program.STUDENTS = students;
                }
            }
            #endregion

            this.RaiseChanged("开启端口监听...");
            this.udpSocket.Start();

            this.RaiseChanged("打开文件上传端口侦听...");
            this.workUpTcpService.StartListen();
        }
Example #3
0
 /// <summary>
 /// 加载数据。
 /// </summary>
 /// <param name="students"></param>
 public void Start(StudentsEx students)
 {
     lock (this)
     {
         this.settings = this.CoreService["monitoruicolorsettings"] as MonitorUIColorSettings;
         if (this.settings == null) this.settings = new MonitorUIColorSettings();
         this.DrawStudents(students);
     }
 }