Example #1
0
        protected override void ExcuteSelf()
        {
            DateTime endMonthDate = new HrmisUtility().EndMonthByYearMonth(_CurrDate);

            if (DateTime.Compare(_CurrDate.Date, endMonthDate.Date) == 0)
            {
                string          employeeNameFailEmail = "";
                List <Employee> employees             = _GetEmployee.GetAllEmployeeBasicInfo();
                foreach (Employee employee in employees)
                {
                    if (employee.EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
                    {
                        continue;
                    }
                    if (employee.EmployeeType == EmployeeTypeEnum.DimissionEmployee)
                    {
                        employee.EmployeeDetails =
                            _GetEmployee.GetEmployeeByAccountID(employee.Account.Id).EmployeeDetails;
                        if (
                            DateTime.Compare(employee.EmployeeDetails.Work.DimissionInfo.DimissionDate,
                                             _CurrDate.AddDays(1 - _CurrDate.Date.Day)) < 0)
                        {
                            continue;
                        }
                    }
                    //没有排版表的人不需要提醒
                    List <PlanDutyDetail> planDutyDetailList =
                        _IPlanDutyDal.GetPlanDutyDetailByAccount(employee.Account.Id, _CurrDate.AddDays(1).AddMonths(-1),
                                                                 _CurrDate);
                    if (planDutyDetailList.Count == 0)
                    {
                        continue;
                    }
                    try
                    {
                        SendEmailToEmployee(employee);
                    }
                    catch
                    {
                        if (string.IsNullOrEmpty(employeeNameFailEmail))
                        {
                            employeeNameFailEmail = employee.Account.Name;
                        }
                        else
                        {
                            employeeNameFailEmail += "," + employee.Account.Name;
                        }
                    }
                    employee.EmployeeDetails = null;
                }
                if (!string.IsNullOrEmpty(employeeNameFailEmail))
                {
                    throw new Exception("发送邮件失败。以下" + employeeNameFailEmail.Split(',').Length + "位员工没有获得系统提醒:" +
                                        employeeNameFailEmail);
                }
            }
        }
        ///<summary>
        ///</summary>
        ///<exception cref="Exception"></exception>
        public void Excute()
        {
            string employeeNameFailEmail = "";

            foreach (DateTime date in _DateList)
            {
                if (date.Month == _CurrDate.Month && date.Day == _CurrDate.Day)
                {
                    List <Employee> allEmployeeList = _GetEmployee.GetAllEmployeeBasicInfo();
                    foreach (Employee employee in allEmployeeList)
                    {
                        if (employee.EmployeeType == EmployeeTypeEnum.DimissionEmployee ||
                            employee.EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
                        {
                            continue;
                        }
                        Vacation vacation = _Dal.GetNearVacationByAccountIDAndTime(employee.Account.Id, _CurrDate);

                        if (vacation == null || vacation.SurplusDayNum == 0)
                        {
                            continue;
                        }
                        try
                        {
                            vacation.Employee.Account = employee.Account;
                            SendEmailToEmployee(vacation);
                        }
                        catch
                        {
                            //拼接邮件发送失败人员姓名
                            if (string.IsNullOrEmpty(employeeNameFailEmail))
                            {
                                employeeNameFailEmail = vacation.Employee.Account.Name;
                            }
                            else
                            {
                                employeeNameFailEmail += "," + vacation.Employee.Account.Name;
                            }
                        }
                        employee.EmployeeDetails = null;
                    }
                    break;
                }
            }

            string throwmessage = "";

            if (!string.IsNullOrEmpty(employeeNameFailEmail))
            {
                throwmessage += "发送邮件失败。以下" + employeeNameFailEmail.Split(',').Length + "位员工没有获得系统提醒:" +
                                employeeNameFailEmail;
            }
            if (!string.IsNullOrEmpty(throwmessage))
            {
                throw new Exception(throwmessage);
            }
        }
Example #3
0
        protected override void ExcuteSelf()
        {
            string employeeNameFailEmail = "";
            string hrFailEmail           = "";

            _MailBodyListToHR = new List <MailBody>();
            List <Employee> allEmployees = _GetEmployee.GetAllEmployeeBasicInfo();

            if (allEmployees != null)
            {
                foreach (Employee employee in allEmployees)
                {
                    if (employee.EmployeeType == EmployeeTypeEnum.DimissionEmployee ||
                        employee.EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
                    {
                        continue;
                    }
                    employee.EmployeeDetails =
                        _GetEmployee.GetEmployeeByAccountID(employee.Account.Id).EmployeeDetails;
                    if (employee.EmployeeDetails.ResidencePermits != null)
                    {
                        if (DateTime.Compare(employee.EmployeeDetails.ResidencePermits.DueDate, _CurrDate.AddDays(_Days)) == 0)
                        {
                            //到期前2个月提醒个人
                            try
                            {
                                SendEmailToEmployee(employee);
                            }
                            catch
                            {
                                if (string.IsNullOrEmpty(employeeNameFailEmail))
                                {
                                    employeeNameFailEmail = employee.Account.Name;
                                }
                                else
                                {
                                    employeeNameFailEmail += "," + employee.Account.Name;
                                }
                            }
                            //年假到期2个月提醒人事
                            new AutoRemindServerUtility(_GetDiyProcess).CreateHREmail(employee.Account.Id, _MailBodyListToHR,
                                                                                      employee.Account.Name, ",");
                        }
                    }
                    employee.EmployeeDetails = null;
                }
            }
            if (_MailBodyListToHR.Count > 0)
            {
                try
                {
                    //发给人事邮件
                    SendEmailToHR(_MailBodyListToHR);
                }
                catch
                {
                    hrFailEmail = "人力资源部邮件提醒发送失败;";
                }
            }
            string throwmessage = "";

            if (!string.IsNullOrEmpty(hrFailEmail))
            {
                throwmessage += hrFailEmail;
            }
            if (!string.IsNullOrEmpty(employeeNameFailEmail))
            {
                throwmessage += "发送邮件失败。以下" + employeeNameFailEmail.Split(',').Length + "位员工没有获得系统提醒:" +
                                employeeNameFailEmail;
            }
            if (!string.IsNullOrEmpty(throwmessage))
            {
                throw new Exception(throwmessage);
            }
        }