Exemple #1
0
        /// <summary>
        /// Cleans up the COM object references.
        /// </summary>
        /// <param name="disposing">
        /// <see langword="true"/> if this was called from the
        /// <see cref="IDisposable"/> interface.
        /// </param>
        private void Dispose(bool disposing)
        {
            lock (this)
            {
                if (null != _eventSink)
                {
                    _eventSink.Dispose();
                    _eventSink = null;
                }

                if (null != _connectionPoint)
                {
                    while (Marshal.ReleaseComObject(_connectionPoint) > 0)
                    {
                        ;
                    }
                    _connectionPoint = null;
                }

                if (null != _connectionPointContainer)
                {
                    while (Marshal.ReleaseComObject(_connectionPointContainer) > 0)
                    {
                        ;
                    }
                    _connectionPointContainer = null;
                }
            }
        }
Exemple #2
0
        public AGMUI()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            int hr = GetAdminSession(out ias);

            tbEvents.Text += "GetSession = " + hr.ToString() + "\r\n";
            if (hr != 0)
            {
                return;
            }
            iserver = ias.Server;
            btRefreshGames_Click(null, null);

            UCOMIConnectionPointContainer icpc = (UCOMIConnectionPointContainer)ias;
            Guid riid = new Guid("DE3ED156-76A0-4A8E-8CFE-9ED26C3B0A5E");

            icpc.FindConnectionPoint(ref riid, out icp);
            myCookie = 0;
            icp.Advise((IAdminSessionEvents)this, out myCookie);
            ias.ActivateAllEvents();
        }
Exemple #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="target">
        /// The target COM object
        /// </param>
        /// <param name="interceptType">
        /// The intercepted type.
        /// </param>
        /// <param name="owner">
        /// The owner <see cref="COMWrapper"/>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="target"/> is <see langword="null"/></para>
        /// <para>-or-</para>
        /// <para><paramref name="interceptType"/> is <see langword="null"/></para>
        /// </exception>
        /// <exception cref="NotImplementedException">
        /// <paramref name="interceptType"/> does not define the
        /// <see cref="ComEventsAttribute"/> attribute.
        /// </exception>
        public ComEventProvider(object target, Type interceptType, COMWrapper owner)
        {
            if (null == target)
            {
                throw new ArgumentNullException("target");
            }
            if (null == interceptType)
            {
                throw new ArgumentNullException("interceptType");
            }

            ComEventsAttribute value = ComEventsAttribute.GetAttribute(interceptType);

            if (null == value)
            {
                throw new NotImplementedException("Event provider attribute not found.");
            }

            _connectionPointContainer = (UCOMIConnectionPointContainer)target;
            _eventSinkType            = value.EventSinkType;
            _connectionPointGuid      = value.EventsGuid;

            if (null != owner)
            {
                _owner = new WeakReference(owner);
            }
        }
#pragma warning restore 618

        #region Implementation of IObjectWithSite
        int IObjectWithSite.SetSite(object site)
        {
#if DEBUG
            // launch debugger when in Debug build
            Debugger.Launch();
#endif

            if (site != null)
            {
                browser = (IWebBrowser2)site;

                // can't simply subscribe to OnBeforeNavigate2 from .NET - https://support.microsoft.com/en-us/kb/325079?wa=wsignin1.0
#pragma warning disable 618
                UCOMIConnectionPointContainer icpc = (UCOMIConnectionPointContainer)site;
#pragma warning restore 618
                Guid g = typeof(DWebBrowserEvents).GUID;
                icpc.FindConnectionPoint(ref g, out icp);
                icp.Advise(this, out cookie);

                ((DWebBrowserEvents2_Event)browser).DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
                ((DWebBrowserEvents2_Event)browser).DownloadBegin    += new DWebBrowserEvents2_DownloadBeginEventHandler(this.OnDownloadBegin);
                ((DWebBrowserEvents2_Event)browser).DownloadComplete += new DWebBrowserEvents2_DownloadCompleteEventHandler(this.OnDownloadComplete);
            }
            else
            {
                icp.Unadvise(cookie);

                ((DWebBrowserEvents2_Event)browser).DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
                ((DWebBrowserEvents2_Event)browser).DownloadComplete -= new DWebBrowserEvents2_DownloadCompleteEventHandler(this.OnDownloadComplete);

                browser = null;
            }
            return(0);
        }
Exemple #5
0
        public SessionCtrl()
        {
            int m_dwCookie = 0;

            m_Session = new XASession();
            m_icpc    = (UCOMIConnectionPointContainer)m_Session;
            Guid IID_SessionEvents = typeof(_IXASessionEvents).GUID;

            m_icpc.FindConnectionPoint(ref IID_SessionEvents, out m_icp);
            m_icp.Advise(this, out m_dwCookie);
        }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="target">
		/// The target COM object
		/// </param>
		/// <param name="interceptType">
		/// The intercepted type.
		/// </param>
		/// <param name="owner">
		/// The owner <see cref="COMWrapper"/>
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="target"/> is <see langword="null"/></para>
		/// <para>-or-</para>
		/// <para><paramref name="interceptType"/> is <see langword="null"/></para>
		/// </exception>
		/// <exception cref="NotImplementedException">
		/// <paramref name="interceptType"/> does not define the
		/// <see cref="ComEventsAttribute"/> attribute.
		/// </exception>
		public ComEventProvider(object target, Type interceptType, COMWrapper owner)
		{
			if (null == target) throw new ArgumentNullException("target");
			if (null == interceptType) throw new ArgumentNullException("interceptType");
			
			ComEventsAttribute value = ComEventsAttribute.GetAttribute(interceptType);
			if (null == value) throw new NotImplementedException("Event provider attribute not found.");
			
			_connectionPointContainer = (UCOMIConnectionPointContainer)target;
			_eventSinkType = value.EventSinkType;
			_connectionPointGuid = value.EventsGuid;
			
			if (null != owner) _owner = new WeakReference(owner);
		}
        public BrowserEvents2Multicaster(HtmlControl hc)
        {
            // Call QueryInterface for IConnectionPointContainer
            control = hc;
            UCOMIConnectionPointContainer icpc =
                (UCOMIConnectionPointContainer)hc.GetOcx();

            // Find the connection point for the
            // DWebBrowserEvents2 source interface
            Guid g = typeof(IWebBrowserEvents2).GUID;

            icpc.FindConnectionPoint(ref g, out icp);

            // Pass a pointer to the host to the connection point
            icp.Advise(this, out cookie);
        }
Exemple #8
0
        void SetPropertyNotifyEvent()
        {
            if (m_htmldoc != null)
            {
                //get the connection point container
                UCOMIConnectionPointContainer icpc = (UCOMIConnectionPointContainer)m_htmldoc;

                //find the source interface
                //get IPropertyNotifySink interface
                Guid g = new Guid("9BFBBC02-EFF1-101A-84ED-00AA00341D07");

                icpc.FindConnectionPoint(ref g, out icp);

                //pass a pointer to the host to the connection point
                icp.Advise(this, out cookie);
            }
        }
Exemple #9
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        private AllsrvConnector()
        {
            IAdminSession IAS = null;

            // Call into AGCLib to get the AdminSession
            int ErrorCode = GetAdminSession(out IAS);

            if (ErrorCode != 0)
            {
                throw new ApplicationException("Attempt to retrieve Admin Session failed. Error " + ErrorCode.ToString());
            }

            _session = IAS;
            TagTrace.WriteLine(TraceLevel.Verbose, "Admin Session retrieved from Allsrv.");

            // Hook into events
            UCOMIConnectionPointContainer uCOMIConnectionPointContainer = (UCOMIConnectionPointContainer)_session;

            uCOMIConnectionPointContainer.FindConnectionPoint(ref _sessionGuid, out _icp);
            _cookie = 0;
            _icp.Advise(this, out _cookie);
            _session.ActivateAllEvents();
        }
Exemple #10
0
        /// <summary>
        /// Ie_s the document complete.
        /// </summary>
        /// <param name="pDisp">P disp.</param>
        /// <param name="URL">URL.</param>
        private void ie_DocumentComplete(object pDisp, ref object URL)
        {
            if (m_dwCookie != 0)
            {
                pConPt.Unadvise(m_dwCookie);
            }

            //Funky, yes, with a reason: http://support.microsoft.com/?id=811645
            // Help from http://www.eggheadcafe.com/ng/microsoft.public.dotnet.framework.sdk/post21853543.asp
            // We are going to sink the event here by using COM connection point.
            doc = (HTMLDocument)ie.Document;
            // I am going to QueryInterface UCOMConnectionPointContainer of the WebBrowser Control
            UCOMIConnectionPointContainer pConPtCon = (UCOMIConnectionPointContainer)doc;

            // Get access to the IConnectionPoint pointer.
            // UCOMIConnectionPoint pConPt;
            // Get the GUID of the HTMLDocumentEvents2
            Guid guid = typeof(HTMLDocumentEvents2).GUID;

            pConPtCon.FindConnectionPoint(ref guid, out pConPt);
            // define your event handler class IEHTMLDocumentEvents
            d = new IEHTMLDocumentEvents(this);
            pConPt.Advise(d, out m_dwCookie);
        }
Exemple #11
0
 // Aletnative to destructor
 void IDisposable.Dispose()
 {
   Disconnect();
   ConnectionPointContainer = null;
   System.GC.SuppressFinalize(this);
 }
Exemple #12
0
 // Constructor: remember ConnectionPointContainer
 IWMPButtonCtrlEvents_EventProvider(object CPContainer) : base()
 {
   ConnectionPointContainer = (UCOMIConnectionPointContainer)CPContainer;
 }
Exemple #13
0
 // Constructor: remember ConnectionPointContainer
 _WMPOCXEvents_EventProvider(object CPContainer) : base()
 {
   ConnectionPointContainer = (UCOMIConnectionPointContainer)CPContainer;
 }
Exemple #14
0
 // Constructor: remember ConnectionPointContainer
 IWMPCustomSliderCtrlEvents_EventProvider(object CPContainer) : base()
 {
   ConnectionPointContainer = (UCOMIConnectionPointContainer)CPContainer;
 }
Exemple #15
0
        public string ExecuteSqlServerPackage(int iBuyerCompanyID, string strFromDate, string strToDate, string strType)
        {
            string strMessage = "";

            UCOMIConnectionPointContainer CnnctPtCont = null;
            UCOMIConnectionPoint          CnnctPt     = null;
            PackageEventsSink             PES         = null;

            int iCookie = 0;

            try
            {
                package     = new Package2Class();
                CnnctPtCont = (UCOMIConnectionPointContainer)package;
                PES         = new PackageEventsSink();
                Guid guid = new Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5");

                CnnctPtCont.FindConnectionPoint(ref guid, out CnnctPt);
                CnnctPt.Advise(PES, out iCookie);
                object pVarPersistStgOfHost = null;

                package.LoadFromSQLServer(serverName, serverUsername, serverPassword, DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, null,
                                          null, null, packageName, ref pVarPersistStgOfHost);

                foreach (GlobalVariable global in package.GlobalVariables)
                {
                    try
                    {
                        if (global.Name.Equals("BuyerCompanyID"))
                        {
                            package.GlobalVariables.Remove(global.Name);
                        }

                        if (global.Name.Equals("FromDate"))
                        {
                            package.GlobalVariables.Remove(global.Name);
                        }

                        if (global.Name.Equals("ToDate"))
                        {
                            package.GlobalVariables.Remove(global.Name);
                        }
                    }
                    catch (Exception ex) { strMessage = strMessage + ex.Message + Environment.NewLine; }
                }

                //Read all the global variables that are of type string
                package.GlobalVariables.AddGlobalVariable("BuyerCompanyID", iBuyerCompanyID);
                package.GlobalVariables.AddGlobalVariable("FromDate", strFromDate);
                package.GlobalVariables.AddGlobalVariable("ToDate", strToDate);
                package.Execute();
                package.UnInitialize();
                package = null;
                CnnctPt.Unadvise(iCookie); //a connection that is created by IConnectionPoint.Advise must be closed by calling IConnectionPoint.Unadvise to avoid a memory leak

                strMessage = strMessage + "CSV Files generated successfully through DTS package." + Environment.NewLine;
            }
            catch (System.Runtime.InteropServices.COMException ex) { strMessage = strMessage + ex.Message + Environment.NewLine; package.UnInitialize(); package = null; CnnctPt.Unadvise(iCookie); }
            catch (Exception ex) { strMessage = strMessage + ex.Message + Environment.NewLine; package.UnInitialize(); package = null; CnnctPt.Unadvise(iCookie); }

            return(strMessage);
        }
        public void Disconnect()
        {
            if( ! (shutdowncpoint == null) )
            {
            if( shutdowncookie != 0 )
                {
                shutdowncpoint.Unadvise( shutdowncookie );
                shutdowncookie = 0;
                }
            int	rc = Marshal.ReleaseComObject( shutdowncpoint );
            shutdowncpoint = null;
            }

            cpointcontainer = null;
            ifBrowse		= null;
            ifItmProps		= null;
            ifCommon		= null;
            ifServer		= null;
            if( ! (OPCserverObj == null) )
            {
            int rc = Marshal.ReleaseComObject( OPCserverObj );
            OPCserverObj = null;
            }
        }
Exemple #17
0
 // Aletnative to destructor
 void IDisposable.Dispose()
 {
     Disconnect();
     ConnectionPointContainer = null;
     System.GC.SuppressFinalize(this);
 }
Exemple #18
0
 // Constructor: remember ConnectionPointContainer
 FontEvents_EventProvider(object CPContainer) : base()
 {
     ConnectionPointContainer = (UCOMIConnectionPointContainer)CPContainer;
 }
        public void Remove( bool bForce )
        {
            if( ! (callbackcpoint == null) )
            {
            if( callbackcookie != 0 )
                {
                callbackcpoint.Unadvise( callbackcookie );
                callbackcookie = 0;
                }
            int	rc = Marshal.ReleaseComObject( callbackcpoint );
            callbackcpoint = null;
            }

            cpointcontainer	= null;
            ifItems		= null;
            ifSync		= null;
            ifAsync		= null;

            if( ! (ifMgt == null) )
            {
            int	rc = Marshal.ReleaseComObject( ifMgt );
            ifMgt = null;
            }

            if( ! (ifServer == null) )
            {
            if( ! state.Public )
                ifServer.RemoveGroup( state.HandleServer, bForce );
            ifServer	= null;
            }

            state.HandleServer = 0;
        }
        // -------------------------- private ---------------------
        private void getinterfaces()
        {
            ifItems	= (IOPCItemMgt) ifMgt;
            ifSync	= (IOPCSyncIO) ifMgt;
            ifAsync	= (IOPCAsyncIO2) ifMgt;

            cpointcontainer	= (UCOMIConnectionPointContainer)	ifMgt;
        }
 // Constructor: remember ConnectionPointContainer
 _IShockwaveFlashEvents_EventProvider(object CPContainer) : base()
 {
   ConnectionPointContainer = (UCOMIConnectionPointContainer)CPContainer;
 }
		/// <summary>
		/// Cleans up the COM object references.
		/// </summary>
		/// <param name="disposing">
		/// <see langword="true"/> if this was called from the
		/// <see cref="IDisposable"/> interface.
		/// </param>
		private void Dispose(bool disposing)
		{
			lock(this)
			{
				if (null != _eventSink)
				{
					_eventSink.Dispose();
					_eventSink = null;
				}
				
				if (null != _connectionPoint)
				{
					while( Marshal.ReleaseComObject(_connectionPoint) > 0 );
					_connectionPoint = null;
				}
				
				if (null != _connectionPointContainer)
				{
					while( Marshal.ReleaseComObject(_connectionPointContainer) > 0 );
					_connectionPointContainer = null;
				}
			}
		}
        public void Connect( string	clsidOPCserver )
        {
            Disconnect();

            Type	typeofOPCserver = Type.GetTypeFromProgID( clsidOPCserver );
            if( typeofOPCserver == null )
            Marshal.ThrowExceptionForHR( HRESULTS.OPC_E_NOTFOUND );

            OPCserverObj = Activator.CreateInstance( typeofOPCserver );
            ifServer = (IOPCServer) OPCserverObj;
            if( ifServer == null )
            Marshal.ThrowExceptionForHR( HRESULTS.CONNECT_E_NOCONNECTION );

            // connect all interfaces
            ifCommon		= (IOPCCommon)						OPCserverObj;
            ifBrowse		= (IOPCBrowseServerAddressSpace)	ifServer;
            ifItmProps		= (IOPCItemProperties)				ifServer;
            cpointcontainer	= (UCOMIConnectionPointContainer)	OPCserverObj;
            AdviseIOPCShutdown();
        }