//分页查询 public ActionResult Find(int start, int limit) { IQueryable<DocNo> list = from r in ctx.DocNos orderby r.OrderNo descending select r; CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }
//分页查询(会议室查询不分权限,按申请时间降序) public ActionResult Find(int start, int limit, string idStr) { IQueryable<MeetingRoomDTO> list = from r in ctx.ReqMeetingRooms join s in ctx.SignFlows on new { r.FormNo, IsCurrent = 1 } equals new { s.FormNo, s.IsCurrent } into t from x in t.DefaultIfEmpty() orderby r.PreStartTime descending select new MeetingRoomDTO { FormNo = r.FormNo, EmpId = r.EmpId, EmpName = r.Employee.Name, PreStartTime = r.PreStartTime, PreEndTime = r.PreEndTime, RoomName = r.RoomName, IsNeedProjector = r.IsNeedProjector, Cause = r.Cause, StatusId = r.StatusId, CheckEmpId = x.CheckEmpId }; //IQueryable<ReqVehicleMains> list = from r in ctx.ReqVehicleMains select r; CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }
//分页查询 public ActionResult Find(int start, int limit, string idStr) { IQueryable<ExamQuestion> list = from r in ctx.ExamQuestions select r; CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }
//分页查询 public ActionResult Find(int start, int limit, string idStr, DateTime? startDate, DateTime? endDate) { int empId; IList<int> deptIdList = getAuthedDeptIds("Week", idStr, out empId); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; IQueryable<WeeklyDTO> list = from r in ctx.Weeklies join s in ctx.SignFlows on new {r.FormNo,IsCurrent=1} equals new {s.FormNo,s.IsCurrent} into t from x in t.DefaultIfEmpty() where r.StatusId != 0 || r.EmpId == ebi.Id orderby r.FormNo descending select new WeeklyDTO { FormNo = r.FormNo, EmpId = r.EmpId, EmpName = r.Employee.Name, CreatDate=r.CreatDate, BeginDate=r.BeginDate, EndDate=r.EndDate, Summary = r.Summary, TxtPlan = r.TxtPlan, Suggestion = r.Suggestion, Inspiration = r.Inspiration, Improve = r.Improve, StatusId = r.StatusId, CheckEmpId = x.CheckEmpId }; if (empId != 0) { list = list.Where(r => r.EmpId == empId); } else { list = list.Where(r => (from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.EmpId)); } if(startDate!=null) { list = list.Where(r => r.BeginDate >= startDate); } if(endDate!=null) { list = list.Where(r => r.EndDate <= endDate); } CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }
//分页查询 public ActionResult Find(int start, int limit,string corpName,string className,string title) { IQueryable<InfoMarketDTO> list = from r in ctx.InfoMarkets orderby r.InsertDate descending select new InfoMarketDTO { Id = r.Id, CorpName = r.CorpName, ClassName = r.ClassName, Title = r.Title, InfoFrom = r.InfoFrom,EmpId=r.EmpId, Name = r.Employee.Name, InsertDate = r.InsertDate, IsPass=r.IsPass }; EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; if(ebi.EmpDepPos.Where(r=>r.PosId>=4).Count()>0)//总监(含)以上级别只显示审核通过的 和 自己添加的 { list = list.Where(r=>r.IsPass==1 || r.EmpId==ebi.Id); } if(corpName!=null) { list = list.Where(r => r.CorpName.Contains(corpName)); } if(className!=null) { list = list.Where(r => r.ClassName.Contains(className)); } if(title!=null) { list = list.Where(r => r.Title.Contains(title)); } CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }
//按登录用户查找授权文档 public ActionResult GetAuthDoc(int start, int limit, int? fileId) { EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; IQueryable<FileAuthed> v; if(fileId==null) { v = from f in ctx.Files join af in ctx.FileAuths on f.Id equals af.FileId where af.ToId == ebi.Id orderby af.AuthDate descending select new FileAuthed { Id = f.Id, Pid = f.Pid, Name = f.Name, Type = f.Type, RealName = f.RealName, Size = f.Size, CreatTime = af.AuthDate, OwnerId = f.OwnerId, LastUpdaterId = f.LastUpdaterId, StatusId = f.StatusId, FromId = af.FromId, FromName = af.Employee.Name, ToId = af.ToId, AuthType = af.AuthType, AuthLevel = af.AuthLevel }; } else { var pFile = ctx.FileAuths.Single(r => r.FileId == fileId && r.ToId ==ebi.Id);//前期只考虑父子目录授权,祖孙授权暂不考虑 v = from r in ctx.Files where r.Pid == fileId select new FileAuthed { Id = r.Id, Pid = r.Pid, Name = r.Name, Type = r.Type, RealName = r.RealName, Size = r.Size, CreatTime=r.CreatTime, OwnerId = r.OwnerId, LastUpdaterId = r.LastUpdaterId, StatusId = r.StatusId, FromId = pFile.FromId, ToId = pFile.ToId, AuthType = pFile.AuthType, AuthLevel = pFile.AuthLevel }; } string json; CJson CJson = new CJson(); json = CJson.ToJsonString("totalCount:" + v.Count() + ",data", v.OrderByDescending(r=>r.CreatTime).Skip(start).Take(limit).ToList()); return Content(json); }
//分目录查找个人文档,共享文档,通知公告 public ActionResult Find(int start, int limit, int fileClass, int? pid) { EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; IQueryable<File> list; if (pid != null)//子目录 { list = from r in ctx.Files where r.Pid == pid select r; } else if(fileClass==0)//个人文件 { list = from r in ctx.Files where r.FileClass == 0 && r.Pid == null && r.OwnerId ==ebi.Id select r; } else if (fileClass == 1)//共享文件 { list = from r in ctx.Files where r.FileClass == 1 && r.Pid==null select r; } else//通知公告 { list = from r in ctx.Files where r.FileClass == 2 && (r.StatusId == 1 || r.OwnerId ==ebi.Id) select r; } //return Json(list); CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.OrderByDescending(r=>r.CreatTime).Skip(start).Take(limit).ToList()); return Content(json); }
//分页查询 public ActionResult Find(int start, int limit, string idStr,string name) { int empId; IList<int> deptIdList = getAuthedDeptIds("Vacation", idStr, out empId); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; IQueryable<VacationDTO> q = from r in ctx.ReqVacationMains join s in ctx.SignFlows on new { r.FormNo, IsCurrent = 1 } equals new { s.FormNo, s.IsCurrent } into t from x in t.DefaultIfEmpty() where r.StatusId != 0 || r.EmpId == ebi.Id orderby r.FormNo descending select new VacationDTO { FormNo = r.FormNo, EmpId = r.EmpId, EmpName = r.Employee.Name, VacationType = r.VacationType, DaysCnt=r.DaysCnt, Cause = r.Cause, StatusId = r.StatusId, CheckEmpId = x.CheckEmpId }; if (empId != 0) { q = q.Where(r => r.EmpId == empId); } else { q = q.Where(r => (from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.EmpId)); } if (!string.IsNullOrWhiteSpace(name)) { q = q.Where(r => r.EmpName.Contains(name)); } int totalCnt = q.Count(); IList<VacationDTO> list = q.Skip(start).Take(limit).ToList(); foreach (var dto in list) { var subList = from r in ctx.ReqVacationSubs where r.FormNo == dto.FormNo select r; DateTime dtStart = DateTime.MaxValue; DateTime dtEnd = DateTime.MinValue; foreach (var v in subList) { if (dtStart > v.PreStartTime) { dtStart = v.PreStartTime; } if (dtEnd < v.PreEndTime) { dtEnd = v.PreEndTime; } } dto.PreStartTime = dtStart; dto.PreEndTime = dtEnd; } //IQueryable<ReqVehicleMains> list = from r in ctx.ReqVehicleMains select r; CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + totalCnt + ",data", list); return Content(json); }
//分页查询 public ActionResult Find(int start, int limit, string idStr,string name) { int empId; IList<int> deptIdList = getAuthedDeptIds("Perchase", idStr, out empId); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; IQueryable<PerchaseDTO> q = from r in ctx.ReqPerchaseMains join s in ctx.SignFlows on new { r.FormNo, IsCurrent = 1 } equals new { s.FormNo, s.IsCurrent } into t from x in t.DefaultIfEmpty() where r.StatusId != 0 || r.EmpId == ebi.Id orderby r.FormNo descending select new PerchaseDTO { FormNo = r.FormNo, EmpId = r.EmpId, EmpName = r.Employee.Name, Cost = r.Cost, Cause = r.Cause, StatusId = r.StatusId, CheckEmpId = x.CheckEmpId }; if (empId != 0) { q = q.Where(r => r.EmpId == empId); } else { q = q.Where(r => (from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.EmpId)); } if (!string.IsNullOrWhiteSpace(name)) { q = q.Where(r => r.EmpName.Contains(name)); } int totalCnt = q.Count(); IList<PerchaseDTO> list = q.Skip(start).Take(limit).ToList(); foreach (var dto in list) { var subList = from r in ctx.ReqPerchaseSubs where r.FormNo == dto.FormNo select r; string goodsName = null; foreach (var v in subList) { goodsName += v.GoodsName; } dto.GoodsNames = goodsName; } //IQueryable<ReqVehicleMains> list = from r in ctx.ReqVehicleMains select r; CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + totalCnt + ",data", list); return Content(json); }
//分页查询 public ActionResult Find(int start, int limit, string idStr) { int empId; IList<int> deptIdList = getAuthedDeptIds("Overtime", idStr, out empId); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; IQueryable<InviteDTO> list = from r in ctx.ReqInvites join s in ctx.SignFlows on new { r.FormNo, IsCurrent = 1 } equals new { s.FormNo, s.IsCurrent } into t from x in t.DefaultIfEmpty() where r.StatusId != 0 || r.EmpId == ebi.Id orderby r.FormNo descending select new InviteDTO { FormNo = r.FormNo, EmpId = r.EmpId, EmpName = r.Employee.Name, DeptName = r.Depts.Text, Position = r.Position, ReqNum = r.ReqNum, OnDutyDate = r.OnDutyDate, StatusId = r.StatusId, CheckEmpId = x.CheckEmpId }; if (empId != 0) { list = list.Where(r => r.EmpId == empId); } else { list = list.Where(r => (from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.EmpId)); } //IQueryable<ReqVehicleMains> list = from r in ctx.ReqVehicleMains select r; CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }
//公共通讯薄 public ActionResult GetContactInfo(int? deptId) { IQueryable<EmpProfileWithDep> list; if (deptId != null) { var d = new DeptController(); IList<int> deptIdList = d.GetChildDeptIdList((int)deptId); list = from r in ctx.Employees where r.LeaveDate == null && Nullable.Equals(r.LeaveDate,null) && (from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) orderby r.Name select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name,Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, ShortNo = r.ShortNo, IdAddress = r.IdAddress }; } else { list = from r in ctx.Employees where r.LeaveDate == null && Nullable.Equals(r.LeaveDate, null) orderby r.Name select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name,Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, ShortNo = r.ShortNo, IdAddress = r.IdAddress }; } IList<EmpProfileWithDep> epd = list.ToList(); EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo; if(ebi.EmpDepPos.Where(r=>r.PosId<=4).Count()==0)//不是总监(含)级别,则隐藏其他部门员工手机号 { foreach (var v in epd) { if(ebi.EmpDepPos.Where(r=>r.DeptId==v.DeptId).Count()==0) { v.Mobile = null; } } } CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + epd.Count() + ",data", epd); return Content(json); }
//分页查询员工记录 public ActionResult Find(int start, int limit, int? deptId,string name, int? statusId) { string idStr = deptId == null ? null : deptId.ToString(); int empId; IList<int> deptIdList = getAuthedDeptIds("EmpProfile", idStr, out empId); if(name==null) { name = ""; } IQueryable<EmpProfileWithDep> list; if (statusId != null && statusId>0) { switch(statusId) { case 1://在职 list = from r in ctx.Employees where r.Name.Contains(name) && r.LeaveDate == null && ((from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) || r.EmpDepPositions.Count == 0) orderby r.JobNo descending select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name, Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, IdAddress = r.IdAddress }; break; case 2://离职 list = from r in ctx.Employees where r.Name.Contains(name) && r.LeaveDate != null && ((from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) || r.EmpDepPositions.Count == 0) orderby r.JobNo descending select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name, Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, IdAddress = r.IdAddress }; break; case 3://试用 list = from r in ctx.Employees where r.Name.Contains(name) && r.LeaveDate == null && r.TrialDate <= DateTime.Today && r.DueDate > DateTime.Today && ((from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) || r.EmpDepPositions.Count == 0) orderby r.JobNo descending select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name, Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, IdAddress = r.IdAddress }; break; case 4://实习 list = from r in ctx.Employees where r.Name.Contains(name) && r.LeaveDate == null && r.PacticeDate <= DateTime.Today && r.TrialDate > DateTime.Today && ((from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) || r.EmpDepPositions.Count == 0) orderby r.JobNo descending select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name, Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, IdAddress = r.IdAddress }; break; default: list = from r in ctx.Employees where r.Name.Contains(name) && r.LeaveDate == null && ((from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) || r.EmpDepPositions.Count == 0) orderby r.JobNo descending select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name, Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, IdAddress = r.IdAddress }; break; } } else { list = from r in ctx.Employees where r.Name.Contains(name) && r.LeaveDate == null && ((from r1 in ctx.EmpDepPositions where deptIdList.ToArray().Contains(r1.DeptId) select r1.EmpId).Contains(r.Id) || r.EmpDepPositions.Count == 0) orderby r.JobNo descending select new EmpProfileWithDep { Id = r.Id, JobNo = r.JobNo, Name = r.Name, Dep = r.EmpDepPositions.FirstOrDefault().Depts.Text, TelExt = r.TelExt, Mobile = r.Mobile, IdAddress = r.IdAddress }; } CJson CJson = new CJson(); string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList()); return Content(json); }