예제 #1
0
        private MailMessage FormatDelivery(NotificationDelivery 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);
           


            if (msg.To.Count == 0) return null;
            msg.Subject = string.Format("Delivery {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/DeliveryEmailTemplate.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 FormatDeliverySms(NotificationDelivery 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 = "Delivery " + noti.DocumentRef + ",\n"
        + "OrderRef =" + noti.OrderRef + "\nStatus= Delivered ";
     return sms;
 }