コード例 #1
0
        protected override void ExcuteSelf()
        {
            try
            {
                DalInstance.WorkTaskDalInstance.Add(_WorkTask);

                if (_IfEmail)
                {
                    string        subject    = _WorkTask.Account.Name + "新增了一个工作计划";
                    List <string> to         = new List <string>();
                    AccountBll    accountBll = new AccountBll();
                    Account       account    = accountBll.GetLeaderByAccountId(_WorkTask.Account.Id);
                    account = DalInstance.AccountDalInstance.GetAccountById(account.Id);
                    if (account != null && account.Id > 0)
                    {
                        to.Add(account.Email1);
                        if (!string.IsNullOrEmpty(account.Email2))
                        {
                            to.Add(account.Email2);
                        }
                    }

                    for (int i = 0; i < _WorkTask.Responsibles.Count; i++)
                    {
                        Account responsible =
                            DalInstance.AccountDalInstance.GetAccountById(_WorkTask.Responsibles[i].Id);
                        if (responsible != null && responsible.Id > 0)
                        {
                            to.Add(responsible.Email1);
                            if (!string.IsNullOrEmpty(responsible.Email2))
                            {
                                to.Add(responsible.Email2);
                            }
                        }
                    }
                    new WorkTaskEmail(subject, WorkTaskEmail.BuildWorkTaskMailBody(_WorkTask).ToString(), to).SendMail();
                }
            }
            catch
            {
                throw MessageKeys.AppException(MessageKeys._DbError);
            }
        }