Dynamicweb.Notifications Namespace : eCommerce.Stock Class |
'Declaration
Public NotInheritable Class eCommerce.Stock
public sealed class eCommerce.Stock
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Dynamicweb.Examples.CSharp.Notifications.eCommerce { /// <summary> /// Subscribing on StatusChanged event /// </summary> [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Stock.StatusChanged)] public class EcomStatusChangedObserver : Dynamicweb.Extensibility.NotificationSubscriber { /// <summary> /// Occurs after the stock status has been changed. /// </summary> /// <param name="notification"></param> /// <param name="args"></param> public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args) { if (args == null || args is Dynamicweb.Notifications.eCommerce.Stock.StatusChangedArgs) return; var TmpArgs = (Dynamicweb.Notifications.eCommerce.Stock.StatusChangedArgs)args; Dynamicweb.eCommerce.Products.Product product = TmpArgs.Product; Dynamicweb.eCommerce.Stocks.StockStatus oldStockStatus = TmpArgs.OldStockStatus; Dynamicweb.eCommerce.Stocks.StockStatus newStockStatus = TmpArgs.NewStockStatus; //send e-mail string emailBody = string.Format("ProductID:{0}<br/>Old stock status:{1}<br/>New stock status:{2}", product.ID, oldStockStatus.Text, newStockStatus.Text); Dynamicweb.Modules.Common.Email.SendMail("user name", "username@somedomain.dk", "EcomStatusChangedObserver", "admin", "noreply@dynamicweb.dk", emailBody, "UTF-8"); } } }
Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Namespace Dynamicweb.Examples.CSharp.Notifications.eCommerce ''' <summary> ''' Subscribing on StatusChanged event ''' </summary> <Global.Dynamicweb.Extensibility.Subscribe(Global.Dynamicweb.Notifications.eCommerce.Stock.StatusChanged)> _ Public Class EcomStatusChangedObserver Inherits Global.Dynamicweb.Extensibility.NotificationSubscriber ''' <summary> ''' Occurs after the stock status has been changed. ''' </summary> ''' <param name="notification"></param> ''' <param name="args"></param> Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Global.Dynamicweb.Extensibility.NotificationArgs) If args Is Nothing OrElse TypeOf args Is Global.Dynamicweb.Notifications.eCommerce.Stock.StatusChangedArgs Then Return End If Dim TmpArgs = DirectCast(args, Global.Dynamicweb.Notifications.eCommerce.Stock.StatusChangedArgs) Dim product As Global.Dynamicweb.eCommerce.Products.Product = TmpArgs.Product Dim oldStockStatus As Global.Dynamicweb.eCommerce.Stocks.StockStatus = TmpArgs.OldStockStatus Dim newStockStatus As Global.Dynamicweb.eCommerce.Stocks.StockStatus = TmpArgs.NewStockStatus 'send e-mail Dim emailBody As String = String.Format("ProductID:{0}<br/>Old stock status:{1}<br/>New stock status:{2}", product.ID, oldStockStatus.Text, newStockStatus.Text) Global.Dynamicweb.Modules.Common.Email.SendMail("user name", "username@somedomain.dk", "EcomStatusChangedObserver", "admin", "noreply@dynamicweb.dk", emailBody, _ "UTF-8") End Sub End Class End Namespace
System.Object
Dynamicweb.Notifications.eCommerce.Stock
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2