Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        private static void SendMail(List <MailEntity> mailList)
        {
            SendMailBiz biz = new SendMailBiz();
            List <SendMailDelegate <MailEntity> > delegateList = new List <SendMailDelegate <MailEntity> >();
            List <IAsyncResult> resultList = new List <IAsyncResult>();

            for (int i = 0; i < mailList.Count; i++)
            {
                MailEntity entity = mailList[i];
                SendMailDelegate <MailEntity> sendMail = new SendMailDelegate <MailEntity>(biz.SendMail);
                delegateList.Add(sendMail);
                resultList.Add(sendMail.BeginInvoke(entity, null, null));
            }
            for (int i = 0; i < delegateList.Count; i++)
            {
                SendMailDelegate <MailEntity> mailDelegate = delegateList[i];
                mailDelegate.EndInvoke(resultList[i]);
            }
        }