コード例 #1
0
        private MailMessage FormatDispatch(NotificationDispatch notification)
        {
            var distributor = _costCentreRepository.GetById(notification.DistributorId);
            var salesman = _costCentreRepository.GetById(notification.SalemanId);
            var outlet = _costCentreRepository.GetById(notification.OutletId);
            if (outlet == null || distributor == null || salesman == null)
                throw new Exception("Invalid distributor , salesman or outlet");
            var msg = new MailMessage();
            GetAddresses(distributor.Id).ForEach(msg.To.Add);
            GetAddresses(salesman.Id).ForEach(msg.To.Add);
            GetAddresses(outlet.Id).ForEach(msg.To.Add);
            // msg.To.Add("*****@*****.**");


            if (msg.To.Count == 0) return null;
            msg.Subject = string.Format("Dispatch {0} Notification", notification.DocumentRef);
            msg.IsBodyHtml = true;
           
            string html = "";
            foreach (var item in notification.Items)
            {
                html += string.Format("<tr><td>{0}</td><td>{1}</td></tr>", item.ItemName, item.Quantity);
            }
            string body = string.Empty;
          
            using (StreamReader reader = new StreamReader("service/resources/DispatchEmailTemplate.htm"))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Distributor}", distributor.Name);
            body = body.Replace("{Salesman}", salesman.Name);
            body = body.Replace("{Outlet}", outlet.Name);
          
            body = body.Replace("{OrderRef}", notification.OrderRef);
            body = body.Replace("{DocumentRef}", notification.DocumentRef);


            body = body.Replace("{Items}", html);

            msg.Body = body;
            return msg;
        }
コード例 #2
0
 private NotificationSMS FormatDispatchSms(NotificationDispatch noti)
 {
     var sms = new NotificationSMS();
     sms.HubId = noti.DistributorId;
     sms.Recipitents = GetPhoneNumber(new List<Guid> { noti.DistributorId, noti.SalemanId, noti.OutletId });// new List<string> { "254722557538" };
     sms.SmsBody = "DIspatch " + noti.DocumentRef + ",\n"
         + "OrderRef =" + noti.OrderRef + "\nStatus= Dispatched ";
     return sms;
 }