using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Reflection; using System.ComponentModel; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.StudentManage.OnlineChecking; using EMIS.ViewModel.StudentManage.StudentProfile; using EMIS.DataLogic.StudentManage.OnlineChecking; namespace EMIS.CommonLogic.StudentManage.OnlineChecking { public class CheckingControlServices : BaseServices , ICheckingControlServices { public Lazy CheckingControlDAL { get; set; } /// /// 查询对应的学生校对控制信息CheckingControlView /// /// /// /// /// /// public IGridResultSet GetStudentEditControlViewGrid(ConfiguretView configuretView, int? checkingTypeID, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (checkingTypeID.HasValue) { exp = exp.And(x => x.CheckingTypeID == checkingTypeID); } var query = CheckingControlDAL.Value.GetStudentEditControlQueryable(exp); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = query.OrderBy(x => x.OrderNo).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => { var property = typeof(StudentView).GetProperty(x.ColumnName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); if (property == null) { return; } var displayNameAttribute = (DisplayNameAttribute)property.GetCustomAttributes(typeof(DisplayNameAttribute), false).FirstOrDefault(); if (displayNameAttribute != null) { x.DisplayColumnName = displayNameAttribute.DisplayName; } }); result.rows = result.rows.Where(x => x.DisplayColumnName != null).ToList(); result.total = result.rows.Count; return result; } /// /// 查询对应的学生校对控制信息List /// /// /// /// public IList GetStudentEditControlViewList(ConfiguretView configuretView, int? checkingTypeID) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (checkingTypeID.HasValue) { exp = exp.And(x => x.CheckingTypeID == checkingTypeID); } var query = CheckingControlDAL.Value.GetStudentEditControlQueryable(exp); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = query.OrderBy(x => x.OrderNo).ToList(); result.ForEach(x => { var property = typeof(StudentView).GetProperty(x.ColumnName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); if (property == null) { return; } var displayNameAttribute = (DisplayNameAttribute)property.GetCustomAttributes(typeof(DisplayNameAttribute), false).FirstOrDefault(); if (displayNameAttribute != null) { x.DisplayColumnName = displayNameAttribute.DisplayName; } }); result = result.Where(x => x.DisplayColumnName != null).ToList(); return result; } /// /// 学生信息校对控制设置 /// /// /// public void StudentEditControlSet(IList columnNames, IList checkingTypeIDs) { List studentEditControlUpList = new List(); for (int i = 0; i < columnNames.Count(); i++) { var columnName = columnNames[i]; Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.ColumnName == columnName); var studentEditControl = CheckingControlDAL.Value.StudentEditControlRepository.GetList(exp).SingleOrDefault(); if (studentEditControl != null) { studentEditControl.CheckingTypeID = checkingTypeIDs[i]; this.SetModifyStatus(studentEditControl); studentEditControlUpList.Add(studentEditControl); } } if (studentEditControlUpList != null && studentEditControlUpList.Count() > 0) { UnitOfWork.BatchUpdate(studentEditControlUpList); } } } }