private NotificationSMS FormatPurchaseSms(NotificationPurchase noti) { var sms = new NotificationSMS(); var farmer = _costCentreRepository.GetById(noti.FarmerId); if (farmer == null) throw new Exception("Invalid farmer"); sms.HubId = noti.HubId; sms.Recipitents = GetPhoneNumber(new List<Guid> { noti.HubId, noti.PurchaseClerkId, noti.FarmerId }); string body = ""; body = "PurchaseID= " + noti.DocumentRef + "\n" + "Farmer=" + farmer.Name + ",\n" + "CUM.Weight=" + noti.CummulativeWeightDetail + ",\n" + "and Center=" + noti.CenterName + "\n"; foreach (var item in noti.Items) { body +="Commodity=" + item.ItemName + ",\n" + "Grade=" + item.Grade + ",\n" + "NT.Weight=" + item.Quantity; } body += "\nStatus= Purchased"; sms.SmsBody = body; return sms; }
private async void SendSms(NotificationSMS mail, NotificationProcessingAudit audit) { _log.Info(" sending sms "); var info = new NotificationProcessingAuditInfo { Id = audit.Id.ToString() + "_SMS", DateInserted = DateTime.Now, NotificationId = audit.Id, Type = "SMS", Contact = string.Join(",", mail.Recipitents.ToArray()) }; try { var smsuri = _settingsRepository.GetByKey(SettingsKeys.SmsUri); string smsurivalue = ""; if (smsuri != null) smsurivalue = smsuri.Value; var client = new HttpClient(); client.Timeout = TimeSpan.FromMinutes(1); client.BaseAddress = new Uri(smsurivalue); string urlSuffix = "api/gateway/sms/postnotification"; _log.InfoFormat("Sending sms to {0} {1}",smsuri,urlSuffix); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.PostAsJsonAsync(urlSuffix, mail ); response.EnsureSuccessStatusCode(); string r = await response.Content.ReadAsStringAsync(); info.Info = r; _processingAuditRepository.Add(info); } catch (Exception ex) { info.Info = ex.Message; if (ex.InnerException != null) info.Info += " --> " + ex.InnerException.Message; _processingAuditRepository.Add(info); } }
private NotificationSMS FormatInvoiceSms(NotificationInvoice 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 = "Invoice " + noti.DocumentRef + "\n" + "of Vat AMT=" + noti.TotalVat + ",\n" + "Discount AMT=" + noti.SalevalueDiscount + ",\n" + "Gross AMT=" + noti.TotalGross + ",\n" + "and Net AMT=" + noti.TotalNet + "\nStatus= Approved "; return sms; }
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; }
private NotificationSMS FormatReceiptSms(NotificationReceipt 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 = "Receipt " + noti.DocumentRef + ",\n" + "OrderRef" + noti.OrderRef + ",\n" + "InvoiceRef=" + noti.InvoiceRef + ",\n" + "and Amount Paid=" + noti.TotalAmount.ToString("N2") + "\nStatus= Received "; return sms; }