How to send a notification
Posted on July 1, 2016 | By Mohd Imran
The following code sample will show how to send a notification to the Notification system in AutoCount Accounting.
Code Snippet
- // The following code direct access to a local AutoCount database called AED_MOBILE, there is no login window to prompt out to allow users to select a database.
- BCE.Data.DBSetting dbSetting = new BCE.Data.DBSetting(BCE.Data.DBServerType.SQL2000, @”(local)\A2006″, “sa”, BCE.AutoCount.Const.AppConst.DefaultPassword, “AED_MOBILE”);
- BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(dbSetting);
- if (BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).Login(“ADMIN”, “ADMIN”))
- {
- string poNo = “PO-000001″;
- SendNotificationWithViewPOHyperlink(dbSetting, poNo);
- }
The following is the supplementary code to work with the above sample:
Code Snippet
- private static void SendNotificationWithoutHyperlink(BCE.Data.DBSetting dbSetting, string poNo)
- {
- string htmlTemplate = “<html><body><font size=\”-1\”><span style=\”font-family: Verdana;\”>#msg0#</font></body></html>”;
- string htmlDetail = htmlTemplate.Replace(“#msg0#”, System.Web.HttpUtility.HtmlEncode(string.Format(“You have unapproved P/O {0}.”, poNo)));
- BCE.AutoCount.Notification.NotifHelper.AddNewNotif(dbSetting, “You have unapproved P/O”, htmlDetail, new string[] { “ADMIN” });
- }
- private static void SendNotificationWithViewPOHyperlink(BCE.Data.DBSetting dbSetting, string poNo)
- {
- string htmlTemplate = “<html><body><font size=\”-1\”><span style=\”font-family: Verdana;\”>#msg0#</font></body></html>”;
- string hyperlink = BCE.AutoCount.Notification.NotifHelper.BuildHyperlink(poNo, typeof(BCE.AutoCount.Invoicing.Purchase.PurchaseOrder.FormPurchaseOrderCmd), “ViewDocument”, new object[] { dbSetting, poNo });
- string htmlDetail = htmlTemplate.Replace(“#msg0#”, string.Format(“You have unapproved P/O {0}.”, hyperlink));
- BCE.AutoCount.Notification.NotifHelper.AddNewNotif(dbSetting, “You have unapproved P/O”, htmlDetail, new string[] { “ADMIN” });
- }