/// <summary> /// 初始化修改界面 /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult Update(int Id) { AttendanceDto entity = _attendanceContract.Edit(Id); Administrator admin = _administratorContract.View(entity.AdminId); ViewBag.RealName = admin.Member.RealName; return(PartialView(entity)); }
public ActionResult View(int id) { var model = _administratorContract.View(id); var adminProfile = _entryContract.Entrys.FirstOrDefault(e => e.MemberId == model.MemberId.Value); if (adminProfile == null) { adminProfile = new Entry() { MemberId = model.MemberId.Value }; } ViewBag.Profile = adminProfile; return(PartialView(model)); }
/// <summary> /// 签到 /// </summary> /// <returns></returns> public JsonResult LoginIn(string userNamer) { OperationResult oper = new OperationResult(OperationResultType.Error, "打卡异常"); try { int adminId = _administratorContract.Administrators.Where(x => x.Member.MemberName == userNamer && x.DepartmentId == 7).Select(x => x.Id).FirstOrDefault(); if (adminId == 4147 || adminId == 2119 || adminId == 2114 || adminId == 3122) { Department department = _departmentContract.Departments.Where(x => x.IsDeleted == false && x.IsEnabled == true && !string.IsNullOrEmpty(x.MacAddress) && x.MacAddress == "D4EE074E6AF2").FirstOrDefault(); oper = _attendanceContract.LoginIn(adminId, department); Administrator admin = _administratorContract.View(adminId); admin.UpdatedTime = DateTime.Now; admin.LoginTime = DateTime.Now; _administratorContract.Update(admin); return(Json(oper, JsonRequestBehavior.AllowGet)); } else { return(Json(oper, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new OperationResult(OperationResultType.Error, "没有权限"), JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(int Id) { var rest = _restContract.Edit(Id); var admin = _administratorContract.View(rest.AdminId); rest.RealName = admin.Member.RealName; return(View(rest)); }
public ActionResult Create(WorkOrderDto dto) { if (dto == null) { return(Json(new OperationResult(OperationResultType.Error, "请填写工单申请"))); } var admin = _administratorContract.View(AuthorityHelper.OperatorId ?? 0); if (admin == null) { return(Json(new OperationResult(OperationResultType.Error, "请重新登陆"))); } if (dto.WorkOrderTitle.Trim() == "") { return(Json(new OperationResult(OperationResultType.Error, "请填写工单标题"))); } dto.DepartmentId = admin.DepartmentId; if (_workOrderContract.Entities.Count(w => w.DepartmentId == dto.DepartmentId && w.Status != -1 && w.Status != 3) > 0) { return(Json(new OperationResult(OperationResultType.Error, "该部门还有已申请工单未被处理,暂无法申请新的工单"), JsonRequestBehavior.AllowGet)); } if (dto.WorkOrderCategoryId <= 0) { return(Json(new OperationResult(OperationResultType.Error, "请选择类型"))); } if (dto.Content.Trim() == "") { return(Json(new OperationResult(OperationResultType.Error, "请填写工单内容"))); } if (dto.ImgAddress != null && dto.ImgAddress.Trim().Length > 0 && !FileHelper.FileIsExist(dto.ImgAddress)) { return(Json(new OperationResult(OperationResultType.Error, "图片不存在"))); } dto.ApplicantId = AuthorityHelper.OperatorId ?? 0; var result = _workOrderContract.Insert(dto); return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult Exit() { OperationResult operResult = new OperationResult(OperationResultType.Success); try { var authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null)// && Request.IsAuthenticated { FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); string userdata = authTicket.UserData; if (!string.IsNullOrEmpty(userdata)) { var dyuserdata = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(userdata, new { Id = string.Empty, JPushRegistrationID = string.Empty }); var strUid = dyuserdata.Id; if (!strUid.IsNullOrEmpty()) { Administrator modadmin = _administratorContract.View(strUid.CastTo <int>()); modadmin.JPushRegistrationID = null; operResult = _administratorContract.Update(modadmin); if (operResult.ResultType == OperationResultType.Success) { if (!dyuserdata.JPushRegistrationID.IsNullOrEmpty()) { JPushClient jclient = new JPushClient(JpushApi.app_key, JpushApi.master_secret); //var dresult = jclient.deleteDeviceTags(dyuserdata.JPushRegistrationID, new HashSet<string>() { dyuserdata.TagDepartment, "yuangong" }); var dresult = jclient.updateDeviceTagAlias(dyuserdata.JPushRegistrationID, "", null, null, new HashSet <string>() { "yuangong" }); //operResult.Other = dresult; } } } } if (operResult.ResultType == OperationResultType.Success) { #region 清除Cookie和Session Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddDays(-1); System.Web.Security.FormsAuthentication.SignOut(); Session.Abandon(); #endregion } } } catch (Exception ex) { operResult.Message = "服务器忙,请稍后重试"; _Logger.Error <string>(ex.ToString()); } return(Json(operResult)); }
public JsonResult Assign(int AdminIds, WorkOrderDto dto) { if (AdminIds == 0) { return(Json(new OperationResult(OperationResultType.Error, "请选择员工"))); } Administrator admin = _administratorContract.View(AdminIds); if (admin == null) { return(Json(new OperationResult(OperationResultType.Error, "您选择的员工不存在"))); } OperationResult opera = _workOrderContract.Assign(dto.Id, AdminIds); EntityContract._notificationContract.SendNotice(AdminIds, "指派工单", "您有新的被指派工单哦~~", sendNotificationAction); string msg = "您申请的工单已被指派给" + (admin.Member != null ? admin.Member.RealName : ""); int applicantId = _workOrderContract.View(dto.Id).ApplicantId; EntityContract._notificationContract.SendNotice(applicantId, "工单状态更新提醒", msg, sendNotificationAction); return(Json(opera, JsonRequestBehavior.AllowGet)); }
public JsonResult ScanComplete(string uuid, int?adminId) { OperationResult oResult = new OperationResult(OperationResultType.Success); oResult.Message = "扫码成功"; var adminImg = string.Empty; if (adminId.HasValue) { adminImg = _administratorContract.View(adminId.Value).Member.UserPhoto; } QrLoginHub.scanComplete(uuid, adminImg); return(Json(oResult)); }
public JsonResult CheckIsPersonTime() { int adminId = AuthorityHelper.OperatorId ?? 0; var admin = _administratorContract.View(adminId); if (admin == null) { return(Json(new OperationResult(OperationResultType.Error, "用户未登录"))); } if (!admin.IsPersonalTime) { return(Json(new OperationResult(OperationResultType.Error, "职位时间无法申请调班"))); } return(Json(new OperationResult(OperationResultType.Success))); }
/// <summary> /// 获取管理的部门 /// </summary> /// <param name="opera"></param> /// <returns></returns> private List <SelectListItem> GetDepartments(bool IsAll = false) { int adminId = AuthorityHelper.OperatorId ?? 0; Administrator admin = _administratorContract.View(adminId); List <SelectListItem> select = new List <SelectListItem>(); select.Add(new SelectListItem() { Value = "", Text = "请选择" }); if (admin == null) { return(select); } List <int> listId = new List <int>(); List <Department> listDepart = new List <Department>(); if (admin.JobPosition != null && admin.JobPosition.IsLeader == true) { listId.Add(admin.DepartmentId ?? 0); listDepart.Add(admin.Department); } if (!IsAll) { Department depart = _departmentContract.Departments.FirstOrDefault(x => !x.IsDeleted && x.IsEnabled && x.SubordinateId == adminId); if (depart != null) { listDepart.AddRange(depart.Children.ToList()); } } else { listDepart = _departmentContract.Departments.Where(x => !x.IsDeleted && x.IsEnabled).ToList(); } if (listDepart != null) { select.AddRange(listDepart.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.DepartmentName, }).ToList()); } return(select); }
public ActionResult CheckValid(string content) { string strResult = ""; var modPro = _productOrigNumberContract.OrigNumbs.FirstOrDefault(); var modAdmin = _administratorContract.View(AuthorityHelper.OperatorId.Value); if (modPro.IsNotNull()) { var dic = new Dictionary <string, object>(); dic.Add("PONInfo", modPro); dic.Add("AdminInfo", modAdmin); strResult = NVelocityHelper.Generate(content, dic, "checkValid"); #region 弃用 //StringTemplate strTemplate = new StringTemplate(content); //strTemplate.SetAttribute("PONInfo", modPro); //strResult = strTemplate.ToString(); #endregion } strResult = strResult.IsNullOrEmpty() ? "内容建设中..." : strResult; return(Json(strResult)); }
/// <summary> /// 根据时期获取考勤数据 /// </summary> /// <returns></returns> public JsonResult GetAttenByDate(int AdminId, DateTime Date) { OperationResult oper = new OperationResult(OperationResultType.Error, "服务器忙,请稍候访问"); try { Administrator admin = _administratorContract.View(AdminId); //获取工作时间 var WToper = GetWorkTime(admin); WorkTime workTime = new WorkTime(); if (WToper.ResultType != OperationResultType.Success) { WToper.Data = null; return(Json(WToper, JsonRequestBehavior.AllowGet)); } workTime = WToper.Data as WorkTime; List <Attendance> listAtten = _attendanceContract.Attendances.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.AdminId == AdminId && x.AttendanceTime.Year == Date.Year && x.AttendanceTime.Month == Date.Month).ToList(); AppAttenStatistics appAtten = new AppAttenStatistics(); double num = 0; appAtten.NormalCount = listAtten.Count(); var leaveinfos = _leaveInfoContract.LeaveInfos.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.AdminId == AdminId && x.StartTime.Year == Date.Year && x.StartTime.Month == Date.Month); appAtten.LeaveTimes = leaveinfos == null || leaveinfos.Count() == 0 ? num : leaveinfos.ToList().Sum(x => x.LeaveDays); var overtimes = _overtimeContract.Overtimes.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.AdminId == AdminId && x.StartTime.Year == Date.Year && x.StartTime.Month == Date.Month); appAtten.OvertimeTimes = overtimes == null || overtimes.Count() == 0 ? num : overtimes.ToList().Sum(x => x.OvertimeDays); var fields = _fieldContract.Fields.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.AdminId == AdminId && x.StartTime.Year == Date.Year && x.StartTime.Month == Date.Month); appAtten.FieldTimes = fields == null || fields.Count() == 0 ? num : fields.ToList().Sum(x => x.FieldDays); appAtten.RepairCount = listAtten.Where(w => w.AttendanceRepairs != null).SelectMany(s => s.AttendanceRepairs).Where(w => w.VerifyType == (int)VerifyFlag.Pass).Count(); if (listAtten != null) { appAtten.ArrivalEarlyCount = listAtten.Where(x => x.ArrivalEarlyMinutes > 0).Count(); appAtten.LateCount = listAtten.Where(x => x.IsLate == -1).Count(); appAtten.IsLateConfirmRepair = listAtten.Count(x => x.IsLate == -1 && x.AttendanceRepairs != null && x.AttendanceRepairs.Count(r => r.VerifyType == 3 && r.ApiAttenFlag == (int)ApiAttenFlag.Late && !r.IsDeleted && r.IsEnabled) > 0) > 0; appAtten.LeaveEarlyCount = listAtten.Where(x => x.IsLeaveEarly == -1).Count(); appAtten.IsLeaveEarlyConfirmRepair = listAtten.Count(x => x.IsLeaveEarly == -1 && x.AttendanceRepairs != null && x.AttendanceRepairs.Count(r => r.VerifyType == 3 && r.ApiAttenFlag == (int)ApiAttenFlag.LeaveEarly && !r.IsDeleted && r.IsEnabled) > 0) > 0; appAtten.NoSignOutCount = listAtten.Where(x => x.IsNoSignOut == -1 && (!x.AttendanceTime.ToShortDateString().Equals(DateTime.Now.ToShortDateString()) || (x.AttendanceTime.ToShortDateString().Equals(DateTime.Now.ToShortDateString()) && DateTime.Now > Convert.ToDateTime(DateTime.Now.ToShortDateString() + " " + workTime.PmEndTime)))).Count(); appAtten.IsNoSignOutConfirmRepair = listAtten.Count(x => x.IsNoSignOut == -1 && (!x.AttendanceTime.ToShortDateString().Equals(DateTime.Now.ToShortDateString()) || (x.AttendanceTime.ToShortDateString().Equals(DateTime.Now.ToShortDateString()) && DateTime.Now > Convert.ToDateTime(DateTime.Now.ToShortDateString() + " " + workTime.PmEndTime))) && x.AttendanceRepairs != null && x.AttendanceRepairs.Count(r => r.VerifyType == 3 && r.ApiAttenFlag == (int)ApiAttenFlag.NoSignOut && !r.IsDeleted && r.IsEnabled) > 0) > 0; appAtten.LeaveLateCount = listAtten.Where(x => x.LeaveLateMinutes > 0).Count(); } int absenceCount = 0;// listAtten.Where(x => x.IsAbsence == true && x.AbsenceType == (int)AttendanceFlag.DayOfAbsence).Count(); var _oper = _attendanceContract.GetNoLoginCount(admin.Id); if (_oper.ResultType == OperationResultType.Success) { absenceCount = (_oper.Data as List <AttendanceInfo>).Count(); } appAtten.AbsenceCount = absenceCount; DateTime endtime = Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 18:00"); if (admin.WorkTime != null && !string.IsNullOrEmpty(admin.WorkTime.PmEndTime)) { endtime = Convert.ToDateTime(DateTime.Now.ToShortDateString() + " " + admin.WorkTime.PmEndTime); } //appAtten.NoSignOutCount = listAtten.Where(x => string.IsNullOrEmpty(x.PmEndTime) && endtime < DateTime.Now).Count(); AttendanceStatistics attSta = _attStatisticsContract.AttendanceStatisticses.FirstOrDefault(x => x.AdminId == AdminId && x.CreatedTime.Year == Date.Year); Rest rest = _restContract.Rests.FirstOrDefault(x => x.AdminId == AdminId); if (rest != null) { appAtten.AnnualLeave = rest.AnnualLeaveDays; appAtten.PaidVacation = rest.PaidLeaveDays; } if (attSta != null) { appAtten.WorkDays = attSta.AbsenceDays; //appAtten.RestDays = attSta.RestDays; } oper.Message = string.Empty; oper.Data = appAtten; oper.ResultType = OperationResultType.Success; return(Json(oper, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { _Logger.Error <string>(ex.ToString()); return(Json(oper, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 获取数据列表 /// </summary> /// <returns></returns> public async Task<ActionResult> List(int? FilePath) { GridRequest request = new GridRequest(Request); FilterRule rule = request.FilterGroup.Rules.FirstOrDefault(x => x.Field == "RealName"); string strRealName = string.Empty; if (rule != null) { strRealName = rule.Value.ToString(); request.FilterGroup.Rules.Remove(rule); } FilterRule rule_file = request.FilterGroup.Rules.FirstOrDefault(x => x.Field == "FilePath"); if (rule_file != null) { request.FilterGroup.Rules.Remove(rule_file); } Expression<Func<WorkLog, bool>> predicate = FilterHelper.GetExpression<WorkLog>(request.FilterGroup); //只有是部门领导才可以查看部门下的工作 int adminId = AuthorityHelper.OperatorId ?? 0; Administrator admin = _adminContract.View(adminId); List<int> listId = new List<int>() { adminId }; if (admin != null && admin.JobPosition.IsLeader == true) { ICollection<Administrator> listAdmins = admin.Department.Administrators; if (!string.IsNullOrEmpty(strRealName)) { listAdmins = listAdmins.Where(x => x.Member.RealName.Contains(strRealName)).ToList(); } listId = listAdmins.Select(x => x.Id).ToList(); } if (FilePath.HasValue) { if (FilePath.Value == 1) { predicate = predicate.And(p => !string.IsNullOrEmpty(p.FilePath)); } else { predicate = predicate.And(p => string.IsNullOrEmpty(p.FilePath)); } } var data = await Task.Run(() => { int count; IQueryable<WorkLog> listWorkLog = _workLogContract.WorkLogs; if (listId != null && listId.Count() > 0) { listWorkLog = listWorkLog.Where(x => listId.Contains(x.StaffId ?? 0)); } var list = listWorkLog.Where<WorkLog, int>(predicate, request.PageCondition, out count).Select(m => new { m.WorkLogName, m.Id, m.IsDeleted, m.IsEnabled, m.Sequence, m.UpdatedTime, m.Operator.Member.MemberName, WorkLogAttributeName = m.WorkLogAttribute.WorkLogAttributeName, m.FilePath, RealName = m.StaffId == null ? string.Empty : m.Staff.Member.RealName, m.Keys, m.Notes }).ToList(); return new GridData<object>(list, count, request.RequestInfo); }); return Json(data, JsonRequestBehavior.AllowGet); }
/// <summary> /// 签到 /// </summary> /// <returns></returns> public JsonResult LoginIn(string AdminId, string MacAddress) { OperationResult oper = new OperationResult(OperationResultType.Error, "请重新登陆"); int adminId = 0; string strAdminId = AdminId; if (string.IsNullOrEmpty(strAdminId)) { return(Json(oper)); } adminId = int.Parse(strAdminId); if (ExistUnreadMsg(adminId)) { oper.Message = "请先阅读通知"; return(Json(oper)); } var examRecords = _examRecordContract.Entities.Count(r => r.AdminId == adminId && !r.IsDeleted && r.IsEnabled && r.EntryTrainStatus == 0); if (examRecords > 0) { oper.Message = "您的入职培训试题未完成,无法签到"; return(Json(oper)); } if (_workOrderDealtWithContract.Entities.Count(d => d.HandlerID == adminId && d.Status == 0) > 0) { oper.Message = "您有未处理的配单信息"; return(Json(oper)); } var dic = _attendanceContract.DoubleScoreReminderBySign(adminId); if (dic["DeductionDoubleScore"]) { oper.Message = "扣除双倍积分"; oper.Other = -2; return(Json(oper)); } Administrator admin = _administratorContract.View(adminId); var checkmac = admin?.JobPosition.CheckMac != false; if (checkmac) { string strMac = MacAddress; oper = this.CheckMac(strMac); if (oper.ResultType != OperationResultType.Success) { return(Json(oper, JsonRequestBehavior.AllowGet)); } } Department department = oper.Data as Department; oper = _attendanceContract.LoginIn(adminId, department, !checkmac); if (dic["IsReminder"]) { oper.Other = -1; } else { oper.Other = 0; } admin.UpdatedTime = DateTime.Now; admin.LoginTime = DateTime.Now; _administratorContract.Update(admin); var res = _statContract.SetStoreOpenWhenFirstSignIn(adminId); if (res.ResultType != OperationResultType.Success) { _Logger.Error(res.Message); } if (oper.ResultType == OperationResultType.Success) { _administratorContract.SendAdminBirthdayNoti(adminId); } return(Json(oper, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 签到 /// </summary> /// <returns></returns> public JsonResult LoginIn() { OperationResult oper = new OperationResult(OperationResultType.Error, "请重新登陆"); int adminId = AuthorityHelper.OperatorId ?? 0; Administrator admin = _administratorContract.View(adminId); var examRecords = _examRecordContract.Entities.Count(r => r.AdminId == adminId && !r.IsDeleted && r.IsEnabled && r.EntryTrainStatus == 0); if (examRecords > 0) { oper.Message = "您的入职培训试题未完成,无法签到"; return(Json(oper, JsonRequestBehavior.AllowGet)); } if (_workOrderDealtWithContract.Entities.Count(d => d.HandlerID == adminId && d.Status == 0) > 0) { oper.Message = "您有未处理的配单信息"; return(Json(oper, JsonRequestBehavior.AllowGet)); } var dic = _attendanceContract.DoubleScoreReminderBySign(adminId); if (dic["DeductionDoubleScore"]) { oper.Message = "上个月有未处理的补卡,处理后方可正常签到"; oper.Other = -2; return(Json(oper, JsonRequestBehavior.AllowGet)); } string strMac = Request["Mac"]; var checkmac = admin?.JobPosition.CheckMac != false; if (checkmac) { oper = this.CheckMac(strMac); if (oper.ResultType != OperationResultType.Success) { return(Json(oper, JsonRequestBehavior.AllowGet)); } } Department department = oper.Data as Department; oper = _attendanceContract.LoginIn(adminId, department); if (dic["IsReminder"]) { oper.Other = -1; oper.Message = "补卡未处理的从下个月进行补卡会扣双倍积分"; } else { oper.Other = 0; } admin.UpdatedTime = DateTime.Now; admin.LoginTime = DateTime.Now; _administratorContract.Update(admin); var res = _statContract.SetStoreOpenWhenFirstSignIn(adminId); if (oper.ResultType == OperationResultType.Success) { _administratorContract.SendAdminBirthdayNoti(adminId); } return(Json(oper, JsonRequestBehavior.AllowGet)); }