/// <summary> /// /// </summary> /// <param name="service"></param> /// <param name="store"></param> /// <param name="students"></param> public BatchUploadWaitWindow(ICoreService service, LocalStudentWorkStore store, LocalStudents students) : base(service) { this.store = store; this.students = students; InitializeComponent(); }
/// <summary> /// 构造函数。 /// </summary> /// <param name="service"></param> /// <param name="store"></param> /// <param name="students"></param> /// <param name="studentID"></param> public ModifyWorkDetailsWindow(ICoreService service, LocalStudentWorkStore store, string studentID) : base(service) { this.pluginService = new LoadingPluginService(service, this); //及时加载作业索引文件,同步修改信息。 this.store = LocalStudentWorkStore.DeSerializer(store.FileSavePath()); this.localStudentCollection = this.store.HasWorks(); if (this.localStudentCollection != null && this.localStudentCollection.Count > 0 && !string.IsNullOrEmpty(studentID)) { this.index = this.localStudentCollection.FindIndex(studentID); } this.InitializeComponent(); }
/// <summary> /// /// </summary> /// <param name="store"></param> /// <param name="students"></param> /// <param name="dir"></param> /// <param name="zipFile"></param> /// <param name="handler"></param> private void ImportWorkFiles(LocalStudentWorkStore store, LocalStudents students, string dir, ZipFile zipFile, RaiseChangedHandler handler) { if (store != null && students != null && students.Count > 0 && zipFile != null) { foreach (LocalStudent ls in students) { if (ls.HasWork()) { LocalStudentWork lsw = ls.Work; if (lsw.WorkFiles != null && lsw.WorkFiles.Count > 0) { string zipDir = string.Format("{0}{1}{2}{1}", dir, Path.DirectorySeparatorChar, ls.StudentID); this.RaiseChanged(handler, string.Format("导入[{0},{1}]作品数据...", ls.StudentName, ls.StudentCode)); foreach (LocalStudentWorkFile lswf in lsw.WorkFiles) { string sPath = string.Format("{0}{1}{2}", zipDir, lswf.FileID, lswf.FileExt); try { using (Stream stream = ZipUtils.ZipFileData(zipFile, sPath)) { if (stream != null) { this.RaiseChanged(handler, string.Format("导入作品{0}{1}...", lswf.FileName, lswf.FileExt)); using (FileStream fs = new FileStream(lsw.StudentWorkFilePath(store, ls, lswf), FileMode.Create, FileAccess.Write)) { byte[] buf = new byte[512]; int len = 0; while ((len = stream.Read(buf, 0, buf.Length)) > 0) { fs.Write(buf, 0, len); } } } } } catch (Exception x) { Exception t = new Exception(string.Format("[{0},{1}]{2}{3}:{4}", ls.StudentName, ls.StudentCode, lswf.FileName, lswf.FileExt, sPath), x); UtilTools.OnExceptionRecord(t, typeof(ImportWorkUtils)); } } } } } } }
private void uploadWorks(LocalStudentWorkStore store, LocalStudents students, out int success,out int failure, out List<string> listFailure) { success = 0; failure = 0; listFailure = new List<string>(); ///TODO:老师上传作业。 //if (store != null && store.Students != null && store.Students.Count > 0 && students != null && students.Count > 0) //{ // string storeFielPath = store.FileSavePath(); // using (TeaClientServicePoxyFactory factory = TeaClientServicePoxyFactory.Instance(this.CoreService, new RaiseChangedHandler(delegate(string content) // { // this.OnChanged(content); // }))) // { // bool complete = false; // for (int i = 0; i < students.Count; i++) // { // LocalStudent ls = this.students[i]; // #region 处理作品。 // ls = this.store.Students[ls.StudentID]; // if (ls != null && ls.Works != null && ls.Works.Count > 0) // { // if (((ls.Works[0].Status & EnumWorkStatus.Review) == EnumWorkStatus.Review)) // { // if ((ls.Works[0].Status & EnumWorkStatus.Upload) != EnumWorkStatus.Upload) // { // this.OnChanged(string.Format("开始上传:[{0},{1}]作品[{2}]...", ls.StudentName, ls.StudentCode, ls.Works[0].WorkName)); // string content = null; // if (complete = factory.UploadStudentWorks(ref this.store, ref ls, out content)) // { // success++; // ls.Works[0].Status |= EnumWorkStatus.Upload; // WorkStoreHelper.UpdateWorkStatusToQueueStore(new WorkStoreHelper.WorkReviewQueueEntity(ls.StudentID, ls.Works[0].WorkID, ls.Works[0].Status, null, storeFielPath)); // } // else // { // failure++; // listFailure.Add(string.Format("[{0},{1}] {2} {3}", ls.StudentName, ls.StudentCode, ls.Works[0].WorkName, content)); // } // this.OnChanged(string.Format("上传:[{0},{1}]作品[{2}] {3}", ls.StudentName, ls.StudentCode, ls.Works[0].WorkName, complete ? "成功" : "失败")); // } // else // { // this.OnChanged(string.Format("已上传:[{0},{1}]作品[{2}]", ls.StudentName, ls.StudentCode, ls.Works[0].WorkName)); // } // } // else // { // failure++; // listFailure.Add(string.Format("[{0},{1}] {2} {3}", ls.StudentName, ls.StudentCode, ls.Works[0].WorkName, "未批阅")); // this.OnChanged(string.Format("不能上传:[{0},{1}]作品[{2}],{3}", ls.StudentName, ls.StudentCode, ls.Works[0].WorkName, "未批阅!")); // } // } // #endregion // } // } //} }
/// <summary> /// 创建学生作业缩略图集合。 /// </summary> /// <param name="store"></param> /// <param name="localStudents"></param> /// <param name="container"></param> /// <param name="w"></param> /// <param name="h"></param> /// <returns></returns> public static ImageList ThumbnailImageList(LocalStudentWorkStore store, LocalStudents students, IContainer container, int w, int h) { if (store == null || students == null || students.Count == 0) return null; ImageList imgList = container == null ? new ImageList() : new ImageList(container); imgList.ImageSize = new Size(w, h); imgList.TransparentColor = Color.Transparent; foreach (LocalStudent ls in students) { Image img = CreateThumbnailFrist(store, ls.StudentID, w, h); if (img != null) { imgList.Images.Add(ls.StudentID, img); } } return imgList; }
/// <summary> /// 查询数据。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { string catalogID = null, classID = null; TreeNode node = this.treeView.SelectedNode; if (node == null || string.IsNullOrEmpty(classID = this.LeftTreeNodeValue(node, "ClassID"))) { return; } catalogID = this.LeftTreeNodeValue(node.Parent, "CatalogID"); this.store = LocalStudentWorkStore.DeSerializer(this.userInfo.UserID, catalogID, classID); #region 查询数据。 if (this.store != null && this.store.Students != null) { string workName = this.txtWorkName.Text.Trim(); string studentName = this.txtStudentName.Text.Trim(); EnumWorkStatus status = EnumWorkStatus.None; if (this.chkReview.Checked) { status |= EnumWorkStatus.Review; } if (this.chkUpload.Checked) { status |= EnumWorkStatus.Upload; } if (this.chkRelease.Checked) { status |= EnumWorkStatus.Release; } if (status != EnumWorkStatus.None) { status &= ~EnumWorkStatus.None; } this.students = this.store.HasWorks(); if (!string.IsNullOrEmpty(studentName)) { this.students = this.students.FindStudents(studentName); } if (!string.IsNullOrEmpty(workName) || (status != EnumWorkStatus.None)) { this.students = this.students.FindStudents(workName, status); } #region 未批阅。 if (this.chkNoReview.Checked && this.students != null && this.students.Count > 0) {//未批阅。 List<LocalStudent> list = new List<LocalStudent>(); for (int i = 0; i < this.students.Count; i++) { LocalStudent ls = this.students[i]; if (ls.HasWork() && ((ls.Work.Status & EnumWorkStatus.Review) == EnumWorkStatus.Review)) { list.Add(ls); } } if (list.Count > 0) { this.students.Remove(list.ToArray()); } } #endregion #region 未上传。 if (this.chkNoUpload.Checked && this.students != null && this.students.Count > 0) {//未上传。 List<LocalStudent> list = new List<LocalStudent>(); for (int i = 0; i < this.students.Count; i++) { LocalStudent ls = this.students[i]; if (ls.HasWork() && ((ls.Work.Status & EnumWorkStatus.Upload) == EnumWorkStatus.Upload)) { list.Add(ls); } } if (list.Count > 0) { this.students.Remove(list.ToArray()); } } #endregion } #endregion; #region 绘制数据。 this.listView.BeginUpdate(); this.listView.Items.Clear(); if (this.store != null && this.students != null && this.students.Count > 0) { ImageList images = ThumbnailsHelpers.ThumbnailImageList(this.store, this.students, this.components, 100, 75); this.listView.LargeImageList = images; this.listView.SmallImageList = images; List<ListViewItem> items = new List<ListViewItem>(); for (int i = 0; i < this.students.Count; i++) { LocalStudent ls = this.students[i]; if (ls.Work != null) { ListViewItem item = new ListViewItem(ls.StudentName, ls.StudentID); item.Tag = ls.StudentID; item.ToolTipText = ls.Work.Description; item.SubItems.Add(ls.Work.WorkName); item.SubItems.Add(EnumWorkStatusOperaTools.GetStatusName(ls.Work.Status)); item.SubItems.Add(string.Format("{0:yyyy-MM-dd HH:mm:ss}", ls.Work.Time)); if (ls.Work.Review != null) { item.SubItems.Add(string.Format("评阅:{0}", ls.Work.Review.ReviewValue)); } item.SubItems.Add(ls.Work.Description); items.Add(item); } } this.listView.Items.AddRange(items.ToArray()); } this.listView.EndUpdate(); #endregion }
/// <summary> /// 获取有作业数据的学生集合。 /// </summary> /// <returns></returns> public LocalStudents HasWorks() { if (this.Students != null && this.Students.Count > 0) { LocalStudents stus = new LocalStudents(); for (int i = 0; i < this.Students.Count; i++) { LocalStudent ls = this.Students[i]; if (ls != null && ls.HasWork()) { stus.Add(ls); } } stus.Sort(); return stus; } return null; }