Ejemplo n.º 1
0
 private void SendMailToAssignee(string subject,
    string receipantName, string receipantMailbox,
    string content)
 {
     FapMail mail = CreateMail(subject, new string[] { receipantName }, new string[] { receipantMailbox }, content);
     _dataAccessor.Insert(mail);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 发送邮件给业务处理人
 /// </summary>
 /// <param name="senderName"></param>
 /// <param name="senderMailbox"></param>
 /// <param name="receipantNames"></param>
 /// <param name="receipantMailboxes"></param>
 /// <param name="content"></param>
 private void SendMailToAssignee(string subject,
     List<string> receipantNames, List<string> receipantMailboxes,
     string content)
 {
     FapMail mail = CreateMail(subject, receipantNames.ToArray(), receipantMailboxes.ToArray(), content);
     _dataAccessor.Insert<FapMail>(mail);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建邮件对象
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="senderMail"></param>
        /// <param name="recipients"></param>
        /// <param name="recipientMails"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        private FapMail CreateMail(
            string Subject,
            string[] recipients,
            string[] recipientMails,
            string content)
        {
            FapMail mail = new FapMail();
            mail.Subject = Subject;
            //mail.Sender = sender;
            //mail.SenderEmailAddress = senderMail;
            mail.MailContent = content;
            mail.IsSeparate = 1;
            mail.Recipient =string.Join(';', recipients);
            mail.RecipientEmailAddress =string.Join(';', recipientMails);

            return mail;
        }
Ejemplo n.º 4
0
        public void PayrollOffNotice(string caseUid)
        {
            PayCase pc = _dbContext.Get <PayCase>(caseUid);

            if (pc.PayFlag == 0)
            {
                throw new FapException("薪资还未发放,还不能发送通知");
            }
            string sql     = $"select {pc.TableName}.EmpUid,Employee.Mailbox,Employee.EmpName from {pc.TableName} left join Employee on {pc.TableName}.EmpUid=Employee.Fid";
            var    empList = _dbContext.Query(sql);

            if (empList.Any())
            {
                string            mailContent = pc.PayYM + "份薪资已发放,请登录HCM系统查看。员工自助--》我的薪资";
                string            msgContent  = pc.PayYM + "份薪资已发放。";
                string            sendTime    = DateTimeUtils.CurrentDateTimeStr;
                List <string>     lmail       = new List <string>();
                List <FapMessage> lmsg        = new List <FapMessage>();
                foreach (var emp in empList)
                {
                    FapMessage message = new FapMessage {
                        HasRead = 0, MsgCategory = "Notice", MsgContent = msgContent, REmpUid = emp.EmpUid, SendTime = sendTime, Title = "薪资发放通知"
                    };
                    lmsg.Add(message);
                    string mailBox = emp.Mailbox;
                    if (mailBox.IsPresent())
                    {
                        lmail.Add($"{emp.EmpName}<{emp.Mailbox}>");
                    }
                }
                _dbContext.InsertBatchSql <FapMessage>(lmsg);
                if (lmail.Any())
                {
                    FapMail fmail = new FapMail();
                    fmail.IsSeparate            = 1;
                    fmail.Recipient             = "薪资套人员";
                    fmail.Subject               = "薪资发放通知";
                    fmail.MailContent           = mailContent;
                    fmail.RecipientEmailAddress = string.Join(";", lmail);
                    fmail.SendStatus            = 0;
                    _dbContext.Insert <FapMail>(fmail);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 发送邮件
 /// </summary>
 /// <param name="mailModel"></param>
 public void SendMail(FapMail mail)
 {
     _dataAccessor.Insert(mail);
 }
Ejemplo n.º 6
0
        public void ExceptionNotice(string[] options)
        {
            var    currPeriod = GetCurrentPeriod();
            string startDate  = currPeriod.StartDate;
            string endDate    = currPeriod.EndDate;
            //此时间段日结果
            var dayResults = _dbContext.QueryWhere <TmDayResult>($"{nameof(TmDayResult.CurrDate)}>=@StartDate and {nameof(TmDayResult.CurrDate)}<=@EndDate and {nameof(TmDayResult.CalResult)} like '{DayResultEnum.Absence.Description()}%'",
                                                                 new DynamicParameters(new { StartDate = startDate, EndDate = endDate }));

            if (!dayResults.Any())
            {
                return;
            }
            IList <FapMail> mailList = new List <FapMail>();

            if (options.Contains("emp", new FapStringEqualityComparer()))
            {
                var employees = _dbContext.QueryWhere <Employee>("Fid in @EmpUids", new DynamicParameters(new { EmpUids = dayResults.Select(d => d.EmpUid).Distinct() }));
                foreach (var empResult in dayResults.GroupBy(d => d.EmpUid))
                {
                    var employee = employees.FirstOrDefault(e => e.Fid == empResult.Key);
                    if (employee == null || employee.Mailbox.IsMissing())
                    {
                        continue;
                    }
                    FapMail mail = new FapMail();
                    mail.Recipient             = employee.EmpName;
                    mail.RecipientEmailAddress = $"{employee.EmpName}<{employee.Mailbox}>";
                    mail.Subject      = "考勤异常通知";
                    mail.MailContent  = $"您有{empResult.Count()}条考勤异常未处理,请抓紧补签。";
                    mail.SendCount    = 0;
                    mail.MailCategory = "考勤异常";
                    mailList.Add(mail);
                }
            }
            if (options.Contains("mgr", new FapStringEqualityComparer()))
            {
                var deptList = _dbContext.QueryWhere <OrgDept>("Fid in @DeptUids", new DynamicParameters(new { DeptUids = dayResults.Select(d => d.DeptUid).Distinct() }));
                if (deptList.Any())
                {
                    var employees = _dbContext.QueryWhere <Employee>("Fid in @EmpUids", new DynamicParameters(new { EmpUids = deptList.Select(d => d.DeptManager).Union(deptList.Select(d => d.Director)).Distinct() }));
                    foreach (var deptResult in dayResults.GroupBy(d => d.DeptUid))
                    {
                        var dept = deptList.FirstOrDefault(d => d.Fid == deptResult.Key);
                        if (dept != null && (dept.DeptManager.IsPresent() || dept.Director.IsPresent()))
                        {
                            if (dept.DeptManager.EqualsWithIgnoreCase(dept.Director))
                            {
                                var employee = employees.FirstOrDefault(e => e.Fid == dept.DeptManager);
                                if (employee == null)
                                {
                                    continue;
                                }
                                SendDeptMail(employee, deptResult.Count());
                            }
                            if (dept.DeptManager.IsPresent() && dept.Director.IsPresent() && !dept.DeptManager.EqualsWithIgnoreCase(dept.Director))
                            {
                                string[] empUids = new string[] { dept.DeptManager, dept.Director };
                                foreach (var employee in employees.Where(e => empUids.Contains(e.Fid)))
                                {
                                    SendDeptMail(employee, deptResult.Count());
                                }
                            }
                        }
                    }
                }
            }
            if (mailList.Count > 0)
            {
                _dbContext.InsertBatchSql(mailList);
            }
            void SendDeptMail(Employee employee, int count)
            {
                if (employee.Mailbox.IsMissing())
                {
                    return;
                }
                FapMail mail = new FapMail();

                mail.Recipient             = employee.EmpName;
                mail.RecipientEmailAddress = $"{employee.EmpName}<{employee.Mailbox}>";
                mail.Subject      = "部门考勤异常通知";
                mail.MailContent  = $"您部门还有{count}条考勤异常未处理,请抓紧催促补签。";
                mail.SendCount    = 0;
                mail.MailCategory = "考勤异常";
                mailList.Add(mail);
            }
        }