Click here to Skip to main content
15,898,036 members
Articles / Programming Languages / C#

Using the Web Services and COM+ Event System in the .Net Application.

Rate me:
Please Sign up or sign in to vote.
4.86/5 (7 votes)
11 Oct 2001CPOL7 min read 123.1K   1K   44  
This article describes how to subscribe the Web Service into the COM+ Event System using the C# language.
using System;
using System.Diagnostics;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Security.Permissions;
using System.Threading;
//
using COMPlusEventSystem;
	
	[assembly: ApplicationName("EventClassLogMsg")]
	[assembly: ApplicationActivation(ActivationOption.Server)]
	[assembly: ApplicationAccessControl(Value = false, Authentication  = AuthenticationOption.None)]

#region COM+ Event System Interfaces
namespace COMPlusEventSystem
{
	//--------------------------< EventSystem  >--------------------------------------------------
	//
	[ComImport, Guid("4E14FBA2-2E22-11D1-9964-00C04FBBB345")]
	public class EventSystem {}
	[InterfaceType(ComInterfaceType.InterfaceIsIDispatch),Guid("4E14FB9F-2E22-11D1-9964-00C04FBBB345")]
	public interface IEventSystem
	{
		[PreserveSig]
		object Query([In, MarshalAs(UnmanagedType.BStr)] string progId, 
			[In, MarshalAs(UnmanagedType.BStr)] string queryCriteria, 
			[Out] out Int32 errorIndex);
		[PreserveSig]
		void Store([In, MarshalAs(UnmanagedType.BStr)] string progId, 
			[In, MarshalAs(UnmanagedType.Interface)] object pInterface);
		[PreserveSig]
		void Remove([In, MarshalAs(UnmanagedType.BStr)] string progId, 
			[In, MarshalAs(UnmanagedType.BStr)] string queryCriteria, 
			[Out] out Int32 errorIndex);
		[PreserveSig]
		string get_EventObjectChangeEventClassID();  
		[PreserveSig]
		object QueryS([In, MarshalAs(UnmanagedType.BStr)] string progId, 
			[Out] out Int32 errorIndex);
		[PreserveSig]
		void RemoveS([In, MarshalAs(UnmanagedType.BStr)] string progId, 
			[Out] out Int32 errorIndex);
	}
	//
	
	[ComImport, Guid("7542E960-79C7-11D1-88F9-0080C7D771BF")]
	public class EventSubcription {}
	[InterfaceType(ComInterfaceType.InterfaceIsIDispatch),Guid("4A6B0E15-2E38-11D1-9965-00C04FBBB345")]
	public interface IEventSubcription
	{
		string SubscriptionID { get; set; }
		string SubscriptionName { get; set; }
		string PublisherID { get; set; }
		string EventClassID { get; set; }
		string MethodName { get; set; }
		string SubscriberCLSID { get; set; }
		object SubscriberInterface { get; set; }
		bool   PerUser { get; set; }
		string OwnerSID { get; set; }
		bool   Enabled { get; set; }
		string Description { get; set; }
		string MachineName { get; set; }
		
		[PreserveSig]
		object GetPublisherProperty([In, MarshalAs(UnmanagedType.BStr)] string PropertyName);
		[PreserveSig]
		void   PutPublisherProperty([In, MarshalAs(UnmanagedType.BStr)] string PropertyName, ref object propertyValue);
		[PreserveSig]
		void   RemovePublisherProperty([In, MarshalAs(UnmanagedType.BStr)] string PropertyName);
		[PreserveSig]
		object GetPublisherPropertyCollection();
		[PreserveSig]
		object GetSubscriberProperty([In, MarshalAs(UnmanagedType.BStr)] string PropertyName);
		[PreserveSig]
		void   PutSubscriberProperty([In, MarshalAs(UnmanagedType.BStr)] string PropertyName, ref object propertyValue);
		[PreserveSig]
		void   RemoveSubscriberProperty([In, MarshalAs(UnmanagedType.BStr)] string PropertyName);
		[PreserveSig]
		object GetSubscriberPropertyCollection();
		string InterfaceID { get; set; }
	}

	[InterfaceType(ComInterfaceType.InterfaceIsIDispatch),Guid("4A6B0E16-2E38-11D1-9965-00C04FBBB345")]
	public interface IEventSubcription2 : IEventSubcription							
	{
		string FilterCriteria { get; set; }
		string SubscriberMoniker { get; set; }
	}

}	
#endregion

namespace EventClassLogMsg
{
	[Guid("32F5CB45-F0CB-41e2-919E-54D884905F13")]
	public interface ILogMsg
	{
		void WriteLogMsg(string ticket, string msg);
	}

	// meta class
	[Guid("5AA8C91D-EA0F-405a-8840-95344038AF5A")]
	[EventClass]
	[Transaction(TransactionOption.Disabled)]
	[ObjectPooling(Enabled=true, MinPoolSize=10, MaxPoolSize=60)]
	[EventTrackingEnabled]
	public class EventClassLogMsg : ServicedComponent, ILogMsg
	{
		public void WriteLogMsg(string ticket, string msg){}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions