using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.SystemView; using EMIS.ViewModel.TeachingMaterial; using EMIS.DataLogic.Common.TeachingMaterial; using EMIS.ViewModel; using Bowin.Common.Linq; using System.Linq.Expressions; using EMIS.ViewModel.WorkflowManage; namespace EMIS.CommonLogic.TeachingMaterial { public class TeachersOrderExamineServices : BaseWorkflowServices, ITeachersOrderExamineServices { public TeachersOrderDAL TeachersOrderDAL { get; set; } public IGridResultSet GetTeachersOrderViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus, int pageIndex, int pageSize) { var statusList = this.GetStatusViewList(); var approveStatusList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); Expression> exp = (x => approveStatusList.Contains(x.ApprovalStatus)); if (schoolyearID.HasValue) exp = exp.And(x => x.SchoolyearID == schoolyearID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); if (coursematerialID.HasValue) exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID)); if (publishID.HasValue) exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID); if (ApprovalStatus.HasValue) exp = exp.And(x => x.ApprovalStatus == ApprovalStatus); var query = TeachersOrderDAL.GetTeachingOrderGridView(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault()); return result; } public List GetTeachersOrderViewList(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus) { throw new NotImplementedException(); } /// /// 提交审核 /// /// /// /// public void SubmitTeachersOrderExamine(List planApplicationIDs, Guid userID, string comment = "") { try { StartUp(planApplicationIDs, userID, comment); } catch (Exception) { throw; } } public List GetAuditingActionView(Guid formID, Guid userID) { return GetActionView(formID, userID); } public IGridResultSet GetWorkflowApproveHistoryView(Guid? planApplicationID) { var query = GetApproveHistoryViewList((Guid)planApplicationID).ToList().OrderBy(x => x.PID); return query.AsQueryable().ToGridResultSet(0, 100); } /// /// 获取征订详细 /// /// /// public TeachersOrderView GetTeachersOrderExamineView(Guid? teachersOrderID) { var statusList = this.GetStatusViewList(); var result = TeachersOrderDAL.GetTeachingOrderGridView(x => x.TeachersOrderID == teachersOrderID).FirstOrDefault(); result.ApproveStatusName = statusList.Where(x => x.ID == result.ApproveStatus).Select(x => x.Name).FirstOrDefault(); return result; } /// /// 审核 /// /// /// /// /// public void ApproveTeachersOrderExamine(List teachersOrderIDs, Guid userID, ActionView actionView, string comment) { try { if (teachersOrderIDs.Count > 1 && string.IsNullOrEmpty(comment)) comment = "同意"; Approve(teachersOrderIDs, userID, actionView.ActionID, comment);//审核 } catch (Exception ex) { throw ex; } } /// /// 查询计划申请详细 /// /// 主键ID /// public Entities.ET_TeachersOrder GetTeachersOrder(Guid? teachersOrderID) { //查询条件 System.Linq.Expressions.Expression> expression = (x => x.ApprovalStatus > (int)SYS_STATUS.UNUSABLE); expression = (x => x.TeachersOrderID == teachersOrderID); return TeachersOrderDAL.TeachersOrderRepository.GetSingle(expression); } public IList GetTeachersOrderExamineViewExcel(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus) { var statusList = this.GetStatusViewList(); var approveStatusList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); Expression> exp = (x => approveStatusList.Contains(x.ApprovalStatus)); if (schoolyearID.HasValue) exp = exp.And(x => x.SchoolyearID == schoolyearID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); if (coursematerialID.HasValue) exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID)); if (publishID.HasValue) exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID); if (ApprovalStatus.HasValue) exp = exp.And(x => x.ApprovalStatus == ApprovalStatus); var query = TeachersOrderDAL.GetTeachingOrderGridView(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime).ToList(); query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CreateTime).ToList(); result.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault()); return result; } } }