Exemplo n.º 1
0
    /// <summary>
    /// 保存任务完成邮件模板关系
    /// </summary>
    /// <param name="iLoanTaskId"></param>
    public void SaveCompletetionEmails(int iLoanTaskId)
    {
        var tmp = hdnCompletionEmail.Value;

        if (string.IsNullOrEmpty(tmp))
        {
            return;
        }
        var tmpList = tmp.Split('|').ToList();

        LPWeb.BLL.LoanTask_CompletionEmails blltaskMail = new LoanTask_CompletionEmails();
        var tmpidList = new List <int> {
        };

        foreach (var item in tmpList)
        {
            var list = item.Split(',').ToList();
            if (list.Count == 3 && !string.IsNullOrEmpty(list[1]) && !string.IsNullOrEmpty(list[2]) &&
                Convert.ToInt32(list[1]) != 0)
            {
                int templEmailId = Convert.ToInt32(list[1]);
                if (tmpidList.Contains(templEmailId))
                {
                    continue;
                }
                LPWeb.Model.LoanTask_CompletionEmails modMail = new LPWeb.Model.LoanTask_CompletionEmails();


                modMail.LoanTaskid   = iLoanTaskId;
                modMail.TemplEmailId = Convert.ToInt32(list[1]);
                modMail.Enabled      = list[2] == "1" ? true : false;

                blltaskMail.Add(modMail);
                tmpidList.Add(templEmailId);
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 保存任务完成邮件模板关系
    /// </summary>
    /// <param name="iLoanTaskId"></param>
    public void SaveCompletetionEmails(int iLoanTaskId)
    {
        var tmp = hdnCompletionEmail.Value;


        LPWeb.BLL.LoanTask_CompletionEmails blltaskMail = new LoanTask_CompletionEmails();

        var        ds          = blltaskMail.GetList("LoanTaskid=" + iTaskID); //数据库中原有数据
        List <int> IdList      = ds.Tables[0].AsEnumerable().Select(c => c.Field <int>("TaskCompletionEmailId")).ToList();
        List <int> tmpIdList   = ds.Tables[0].AsEnumerable().Select(c => c.Field <int>("TemplEmailId")).ToList();
        var        oldDataList = ds.Tables[0].AsEnumerable().Select(c => new { Id = c.Field <int>("TaskCompletionEmailId"), tmpId = c.Field <int>("TemplEmailId") }).ToList();

        if (string.IsNullOrEmpty(tmp) && IdList.Count == 0)
        {
            return;
        }


        if (!string.IsNullOrEmpty(tmp))
        {
            var tmpList = tmp.Split('|').ToList();
            foreach (var item in tmpList)
            {
                var list = item.Split(',').ToList();

                if (list.Count == 3 && !string.IsNullOrEmpty(list[1]) && !string.IsNullOrEmpty(list[2]) &&
                    Convert.ToInt32(list[1]) != 0)
                {
                    int  Id           = Convert.ToInt32(list[0]);
                    int  templEmailId = Convert.ToInt32(list[1]);
                    bool enabled      = list[2] == "1" ? true : false;

                    var oldData = oldDataList.Where(c => c.tmpId == templEmailId).FirstOrDefault();
                    if (tmpIdList.Contains(templEmailId) && oldData != null & oldData.Id != Id)
                    {
                        continue;
                    }
                    else if (Id == 0)
                    {
                        LPWeb.Model.LoanTask_CompletionEmails modMail = new LPWeb.Model.LoanTask_CompletionEmails();

                        modMail.LoanTaskid   = iLoanTaskId;
                        modMail.TemplEmailId = templEmailId;
                        modMail.Enabled      = enabled;

                        blltaskMail.Add(modMail);
                        tmpIdList.Add(templEmailId);
                    }
                    else if (IdList.Where(c => c == Id).Count() > 0)
                    {
                        LPWeb.Model.LoanTask_CompletionEmails modMail = new LPWeb.Model.LoanTask_CompletionEmails();

                        modMail.TaskCompletionEmailId = Id;
                        modMail.LoanTaskid            = iLoanTaskId;
                        modMail.TemplEmailId          = templEmailId;
                        modMail.Enabled = enabled;

                        blltaskMail.Update(modMail);

                        IdList.Remove(Id);
                    }
                }
            }
        }

        //删除
        if (IdList.Count > 0)
        {
            var allDelId = string.Empty;
            foreach (var Id in IdList)
            {
                allDelId += "," + Id;
            }
            if (!string.IsNullOrEmpty(allDelId))
            {
                allDelId = allDelId.Remove(0, 1);
            }
            blltaskMail.DeleteList(allDelId);
        }
    }