private static void SendMail(List <TaobaoProduct> ThirdPartMappingNotExists) { SendMailBiz biz = new SendMailBiz(); int PageSize = Config.MailContentPageSize; int page = 1; int PageCount = 1; int records = ThirdPartMappingNotExists == null ? 0 : ThirdPartMappingNotExists.Count; List <MailEntity> mailList = new List <MailEntity>(); string template = biz.GetMailTemplate(MailType.ThirdPartMappingNotExists); if (records > 0) { PageCount = records <= PageSize ? 1 : (records % PageSize == 0 ? records / PageSize : records / PageSize + 1); for (; page <= PageCount; page++) { var list = ThirdPartMappingNotExists.Skip((page - 1) * PageSize).Take(PageSize).ToList(); string ThirdPartMappingNotExists_Body = biz.CreateBody(list); string templateResult = template.Replace("$ThirdPartMappingNotExists$", ThirdPartMappingNotExists_Body); templateResult = templateResult.Replace("$ThirdPartMappingNotExists_Count$", list.Count.ToString()); MailEntity entity = new MailEntity { Body = templateResult, CC = Config.MailCCAddress, From = Config.MailFrom, Subject = Config.MailSubject, To = Config.MailAddress }; entity.Subject += "_淘宝存在的商品,本地Mapping无映射"; if (PageCount > 1) { entity.Subject += string.Format("_数据总量({0})_第{1}页({2})", records, page, list.Count); } //biz.SendMail(entity); mailList.Add(entity); } } else { string templateResult = template.Replace("$ThirdPartMappingNotExists$", ""); templateResult = templateResult.Replace("$ThirdPartMappingNotExists_Count$", "0"); MailEntity entity = new MailEntity { Body = templateResult, CC = Config.MailCCAddress, From = Config.MailFrom, Subject = Config.MailSubject, To = Config.MailAddress }; entity.Subject += "_淘宝存在的商品,本地Mapping无映射"; mailList.Add(entity); } SendMail(mailList); }
private static void SendMail(Dictionary <ThirdPartInventoryEntity, TaobaoProduct> InventoryQtyNotEquels) { SendMailBiz biz = new SendMailBiz(); int PageSize = Config.MailContentPageSize; int page = 1; int PageCount = 1; int records = InventoryQtyNotEquels == null ? 0 : InventoryQtyNotEquels.Count; List <MailEntity> mailList = new List <MailEntity>(); string template = biz.GetMailTemplate(MailType.InventoryQtyNotEquels); if (records > 0) { PageCount = records <= PageSize ? 1 : (records % PageSize == 0 ? records / PageSize : records / PageSize + 1); for (; page <= PageCount; page++) { var list = InventoryQtyNotEquels.Skip((page - 1) * PageSize).Take(PageSize).ToDictionary(item => item.Key, elem => elem.Value); string InventoryQtyNotEquels_Body = biz.CreateBody(list); string templateResult = template.Replace("$InventoryQtyNotEquels$", InventoryQtyNotEquels_Body); templateResult = templateResult.Replace("$InventoryQtyNotEquels_Count$", list.Count.ToString()); MailEntity entity = new MailEntity { Body = templateResult, CC = Config.MailCCAddress, From = Config.MailFrom, Subject = Config.MailSubject, To = Config.MailAddress }; entity.Subject += "_本地库存和淘宝库存不同步"; if (PageCount > 1) { entity.Subject += string.Format("_数据总量({0})_第{1}页({2})", records, page, list.Count); } //biz.SendMail(entity); mailList.Add(entity); } } else { string templateResult = template.Replace("$InventoryQtyNotEquels$", string.Empty); templateResult = templateResult.Replace("$InventoryQtyNotEquels_Count$", "0"); mailList.Add( new MailEntity { Body = templateResult, CC = Config.MailCCAddress, From = Config.MailFrom, Subject = Config.MailSubject + "_本地库存和淘宝库存不同步", To = Config.MailAddress } ); } SendMail(mailList); }