예제 #1
0
        /// <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));
            }
        }
예제 #2
0
        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));
        }
예제 #3
0
        public ActionResult Update(Administrator dto)
        {
            OperationResult result    = new OperationResult(OperationResultType.Error);
            int             countName = _administratorContract.Administrators.Where(x => x.Id != dto.Id && x.Member.MemberName == dto.Member.MemberName).Count();

            if (countName > 0)
            {
                result.Message = "员工昵称已经存在";
                return(Json(result));
            }
            Administrator admin = _administratorContract.Administrators.Where(c => c.Id == dto.Id).FirstOrDefault();

            admin.Member.MemberName = dto.Member.MemberName;
            if (!dto.Member.MemberPass.IsNullOrEmpty())
            {
                admin.Member.MemberPass = dto.Member.MemberPass.MD5Hash();
            }
            admin.Member.Email       = dto.Member.Email;
            admin.Member.MobilePhone = dto.Member.MobilePhone;
            admin.Member.RealName    = dto.Member.RealName;
            admin.Member.Gender      = dto.Member.Gender;
            admin.Member.UpdatedTime = DateTime.Now;
            admin.MacAddress         = dto.MacAddress;
            //admin.AdministratorTypeId = 3;//设计师
            admin.Notes = dto.Notes;

            admin.IsEnabled = true;

            #region 角色
            var rolestr = Request["role"];
            if (!string.IsNullOrEmpty(rolestr))
            {
                var        rol     = Request["role"].Split(',');
                List <int> roleIds = new List <int>();
                foreach (var item in rol)
                {
                    roleIds.Add(Convert.ToInt32(item));
                }
                List <int> allRoleId = new List <int>();
                if (admin.Roles != null)
                {
                    allRoleId = admin.Roles.Where(c => c.IsDeleted == false && c.IsEnabled == true).Select(c => c.Id).ToList();
                }

                List <int> newAddRoleIds = roleIds.Where(c => !allRoleId.Contains(c)).ToList();
                List <int> removRoleIds  = allRoleId.Where(c => !roleIds.Contains(c)).ToList();

                foreach (var item in newAddRoleIds)
                {
                    var addRole = _roleContract.Roles.Where(c => c.Id == item).FirstOrDefault();
                    if (admin.Roles == null)
                    {
                        admin.Roles = new List <Role>()
                        {
                            addRole
                        }
                    }
                    ;
                    else
                    {
                        admin.Roles.Add(addRole);
                    }
                }
                foreach (var item in removRoleIds)
                {
                    var removRole = admin.Roles.Where(c => c.Id == item).FirstOrDefault();
                    if (admin.Roles != null)
                    {
                        admin.Roles.Remove(removRole);
                    }
                }
            }
            else
            {
                admin.Roles.Clear();
            }

            #endregion

            result = _administratorContract.Update(admin);
            return(Json(result));
        }
예제 #4
0
        public JsonResult ToExamineHander(int ToExamineStatues, int Id)
        {
            var oper = _classApplicationContract.ToExamine(ToExamineStatues, Id);

            if (ToExamineStatues != 1 || oper.ResultType == OperationResultType.Error)
            {
                return(Json(oper));
            }
            var class_Applcation = _classApplicationContract.ClassApplications.FirstOrDefault(x => x.Id == Id);
            var admin            = class_Applcation.Admin;

            if (admin.WorkTime == null)
            {
                return(Json(new OperationResult(OperationResultType.Error, "暂无工作时间")));
            }
            var work_time    = _workTimeContract.WorkTimes.FirstOrDefault(x => x.Id == class_Applcation.Admin.WorkTime.Id);
            var workTimrId   = class_Applcation.Admin.WorkTime.Id;
            int currentYear  = DateTime.Now.Year;
            int currentMonth = DateTime.Now.Month;
            var monthList    = _workTimeDetaileContract.WorkTimeDetailes.Where(x => x.WorkTimeId == workTimrId).GroupBy(x => x.Month).Select(x => x.Key).ToList();

            if (monthList.Count == 2)
            {
                int minMonth = monthList.Min();
                int minYear  = _workTimeDetaileContract.WorkTimeDetailes.FirstOrDefault(x => x.WorkTimeId == workTimrId && x.Month == minMonth).Year;
                int maxMonth = monthList.Max();
                int maxYear  = _workTimeDetaileContract.WorkTimeDetailes.FirstOrDefault(x => x.WorkTimeId == workTimrId && x.Month == maxMonth).Year;

                if (!(minMonth == currentMonth && minYear == currentYear) && !(maxMonth == currentMonth && maxYear == currentYear))
                {
                    if (minYear > maxYear)
                    {//如果最小月的年份儿大于最大月的年份儿,那么最大月与最小月反过来(即最大月为最小月,最小月为最大月)
                        currentYear  = maxYear;
                        currentMonth = maxMonth;
                    }
                    else
                    {
                        currentYear  = minYear;
                        currentMonth = minMonth;
                    }
                }

                //if (monthList.Contains(currentMonth))
                //{
                //if ((minMonth == currentMonth && minYear == currentYear) || (maxMonth == currentMonth && maxYear == currentYear))
                //{
                //    //if (monthList.Contains(12) && monthList.Contains(1))
                //    //{
                //    //}
                //    if (minYear > maxYear)
                //    {//如果最小月的年份儿大于最大月的年份儿,那么最大月与最小月反过来(即最大月为最小月,最小月为最大月)
                //        if (maxMonth == currentMonth)
                //        {//若当月为12月,则下月为一月份
                //            currentMonth = minMonth;
                //            currentYear = minYear;
                //        }
                //        else
                //        {//若当月为1月,且未进行下个月的排班,则下月用最小月(此处即maxMonth)排班
                //            currentMonth = maxMonth;
                //            currentYear = maxYear;
                //        }
                //    }
                //    else
                //    {
                //        if (minYear > maxYear)
                //        {//如果最小月的年份儿大于最大月的年份儿,那么最大月与最小月反过来(即最大月为最小月,最小月为最大月)
                //            currentMonth = maxMonth;
                //            currentYear = maxYear;
                //        }
                //        else
                //        {
                //            currentMonth = minMonth;
                //            currentYear = minYear;
                //        }
                //    }
                //}
                //else
                //{
                //    currentMonth = minMonth;
                //}
            }
            oper = _administratorContract.Update(admin);
            var dayId = _workTimeDetaileContract.WorkTimeDetailes.FirstOrDefault(x => x.WorkTimeId == admin.WorkTime.Id && x.WorkDay == class_Applcation.Day &&
                                                                                 x.Year == currentYear && x.Month == currentMonth);
            var offdayId = _workTimeDetaileContract.WorkTimeDetailes.FirstOrDefault(x => x.WorkTimeId == admin.WorkTime.Id && x.WorkDay == class_Applcation.OffDay &&
                                                                                    x.Year == currentYear && x.Month == currentMonth);

            if (oper.ResultType == OperationResultType.Error)
            {
                return(Json(oper));
            }

            WorkTimeDetaileDto daydetail = _workTimeDetaileContract.Edit(dayId.Id);

            daydetail.AmStartTime  = offdayId.AmStartTime;
            daydetail.AmEndTime    = offdayId.AmEndTime;
            daydetail.PmStartTime  = offdayId.PmStartTime;
            daydetail.PmEndTime    = offdayId.PmEndTime;
            daydetail.WorkHour     = offdayId.WorkHour;
            daydetail.WorkTimeType = offdayId.WorkTimeType;

            //oper = _workTimeDetaileContract.UpdateWorkType(2, class_Applcation.OffDay, dayId == null ? 0 : dayId.Id);
            if (oper.ResultType == OperationResultType.Error)
            {
                return(Json(oper));
            }
            WorkTimeDetaileDto offdaydetail = _workTimeDetaileContract.Edit(offdayId.Id);

            offdaydetail.AmStartTime  = dayId.AmStartTime;
            offdaydetail.AmEndTime    = dayId.AmEndTime;
            offdaydetail.PmStartTime  = dayId.PmStartTime;
            offdaydetail.PmEndTime    = dayId.PmEndTime;
            offdaydetail.WorkHour     = dayId.WorkHour;
            offdaydetail.WorkTimeType = dayId.WorkTimeType;

            oper = _workTimeDetaileContract.Update(daydetail);
            oper = _workTimeDetaileContract.Update(offdaydetail);
            //oper = _workTimeDetaileContract.UpdateWorkType(0, class_Applcation.Day, offdayId == null ? 0 : offdayId.Id);

            return(Json(oper));
        }
예제 #5
0
        /// <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));
        }
예제 #6
0
        public ActionResult Update(ProfileUpdateEntry dto, Administrator dtoAdmin)
        {
            var model        = _administratorContract.View(dto.AdminId);
            var adminProfile = _entryContract.Entrys.FirstOrDefault(e => e.MemberId == model.MemberId.Value);
            var action       = "update";

            if (adminProfile == null)
            {
                action = "insert";

                // 补档操作
                adminProfile = new Entry()
                {
                    MemberId         = model.MemberId.Value,
                    UpdatedTime      = DateTime.Now,
                    EntryTime        = model.CreatedTime,                                        // 入职时间
                    DepartmentId     = model.DepartmentId,                                       // 部门
                    JobPositionId    = model.JobPositionId,                                      // 职位
                    RoleJurisdiction = string.Join(",", model.Roles.Select(r => r.Id).ToList()), //角色ids
                    operationId      = AuthorityHelper.OperatorId,
                    ToExamineResult  = 3
                };
            }

            model.Member.Email       = dtoAdmin.Member.Email;
            model.Member.MobilePhone = dtoAdmin.Member.MobilePhone;
            model.Member.RealName    = dtoAdmin.Member.RealName;
            model.Member.Gender      = dtoAdmin.Member.Gender;
            model.Member.DateofBirth = dtoAdmin.Member.DateofBirth;
            model.Notes     = dtoAdmin.Notes;
            model.EntryTime = dtoAdmin.EntryTime;


            if (!string.IsNullOrEmpty(dto.BankcardImgPath) && dto.BankcardImgPath.Length > 0 && dto.BankcardImgPath.IndexOf("base64") > 0)
            {
                adminProfile.BankcardImgPath = SaveImg(dto.BankcardImgPath);
            }

            if (!string.IsNullOrEmpty(dto.IdCardImgPath) && dto.IdCardImgPath.Length > 0 && dto.IdCardImgPath.IndexOf("base64") > 0)
            {
                adminProfile.IdCardImgPath = SaveImg(dto.IdCardImgPath);
            }

            if (!string.IsNullOrEmpty(dto.HealthCertificateImgPath) && dto.HealthCertificateImgPath.Length > 0 && dto.HealthCertificateImgPath.IndexOf("base64") > 0)
            {
                adminProfile.HealthCertificateImgPath = SaveImg(dto.HealthCertificateImgPath);
            }


            if (!string.IsNullOrEmpty(dto.PhotoImgPath) && dto.PhotoImgPath.Length > 0 && dto.PhotoImgPath.IndexOf("base64") > 0)
            {
                adminProfile.PhotoImgPath = SaveImg(dto.PhotoImgPath);
            }

            if (!string.IsNullOrEmpty(dto.RegistFormPath) && dto.RegistFormPath.Length > 0 && dto.RegistFormPath.IndexOf("base64") > 0)
            {
                adminProfile.RegistFormPath = SaveImg(dto.RegistFormPath);
            }

            if (!string.IsNullOrEmpty(dto.LaborContractImgPath) && dto.LaborContractImgPath.Length > 0 && dto.LaborContractImgPath.IndexOf("base64") > 0)
            {
                adminProfile.LaborContractImgPath = SaveImg(dto.LaborContractImgPath);
            }

            if (!string.IsNullOrEmpty(dto.ResumeImgPath) && dto.ResumeImgPath.Length > 0 && dto.ResumeImgPath.IndexOf("base64") > 0)
            {
                adminProfile.ResumeImgPath = SaveImg(dto.ResumeImgPath);
            }

            var oper = _administratorContract.Update(model);

            if (oper.ResultType == OperationResultType.Success)
            {
                if (action == "update")
                {
                    var res = _entryContract.Update(adminProfile);
                    return(Json(res));
                }
                else
                {
                    var res = _entryContract.Insert(adminProfile);
                    return(Json(res));
                }
            }
            return(Json(oper));
        }
        /// <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));
        }