Search website

How to send a notification

The following code sample will show how to send a notification to the Notification system in AutoCount Accounting.

Code Snippet
  1. // 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.
  2. BCE.Data.DBSetting dbSetting = new BCE.Data.DBSetting(BCE.Data.DBServerType.SQL2000, @”(local)\A2006″, “sa”, BCE.AutoCount.Const.AppConst.DefaultPassword, “AED_MOBILE”);
  3. BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(dbSetting);
  4. if (BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).Login(“ADMIN”, “ADMIN”))
  5. {
  6.     string poNo = “PO-000001″;
  7.     SendNotificationWithViewPOHyperlink(dbSetting, poNo);
  8. }

The following is the supplementary code to work with the above sample:

Code Snippet
  1. private static void SendNotificationWithoutHyperlink(BCE.Data.DBSetting dbSetting, string poNo)
  2. {
  3.     string htmlTemplate = “<html><body><font size=\”-1\”><span style=\”font-family: Verdana;\”>#msg0#</font></body></html>”;
  4.     string htmlDetail = htmlTemplate.Replace(“#msg0#”, System.Web.HttpUtility.HtmlEncode(string.Format(“You have unapproved P/O {0}.”, poNo)));
  5.     BCE.AutoCount.Notification.NotifHelper.AddNewNotif(dbSetting, “You have unapproved P/O”, htmlDetail, new string[] { “ADMIN” });
  6. }
  7. private static void SendNotificationWithViewPOHyperlink(BCE.Data.DBSetting dbSetting, string poNo)
  8. {
  9.     string htmlTemplate = “<html><body><font size=\”-1\”><span style=\”font-family: Verdana;\”>#msg0#</font></body></html>”;
  10.     string hyperlink = BCE.AutoCount.Notification.NotifHelper.BuildHyperlink(poNo, typeof(BCE.AutoCount.Invoicing.Purchase.PurchaseOrder.FormPurchaseOrderCmd), “ViewDocument”, new object[] { dbSetting, poNo });
  11.     string htmlDetail = htmlTemplate.Replace(“#msg0#”, string.Format(“You have unapproved P/O {0}.”, hyperlink));
  12.     BCE.AutoCount.Notification.NotifHelper.AddNewNotif(dbSetting, “You have unapproved P/O”, htmlDetail, new string[] { “ADMIN” });
  13. }