#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);
        }
Beispiel #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();
        }
Beispiel #3
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);
        }
Beispiel #4
0
 // Connect to ActiveX event source
 void Connect()
 {
     if (ConnectionPoint == null)
     {
         ConnectionCount = 0;
         Guid g = new Guid("4EF6100A-AF88-11D0-9846-00C04FC29993");
         ConnectionPointContainer.FindConnectionPoint(ref g, out ConnectionPoint);
         EventSinkHelper = new FontEvents_SinkHelper();
         ConnectionPoint.Advise(EventSinkHelper, out EventSinkHelper.Cookie);
     }
 }
Beispiel #5
0
 // Connect to ActiveX event source
 void Connect()
 {
     if (ConnectionPoint == null)
     {
         ConnectionCount = 0;
         Guid g = new Guid("614E1495-1014-44F8-B350-5344C0770C1E");
         ConnectionPointContainer.FindConnectionPoint(ref g, out ConnectionPoint);
         EventSinkHelper = new _IQTControlEvents_SinkHelper();
         ConnectionPoint.Advise(EventSinkHelper, out EventSinkHelper.Cookie);
     }
 }
        /// <summary>
        /// Connects this event sink to a COM object.
        /// </summary>
        /// <param name="connectionPoint">
        /// The connection point to connect to.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="connectionPoint"/> is <see langword="null"/>.
        /// </exception>
        internal void Connect(UCOMIConnectionPoint connectionPoint)
        {
            if (null == connectionPoint)
            {
                throw new ArgumentNullException("connectionPoint");
            }

            if (0 == _connectionCookie)
            {
                int connectionCookie;
                connectionPoint.Advise(this, out connectionCookie);
                _connectionCookie = connectionCookie;
                _connectionPoint  = connectionPoint;
            }
        }
Beispiel #7
0
        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);
        }
Beispiel #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);
            }
        }
Beispiel #9
0
        // Method called when the connection is put back into the pool while it is manually
        // enlisted in a distributed transaction.  We must create an outcome event and let the
        // connection wait until the distributed transaction has finished.  Once it does, we then
        // put it back into the general population of the pool.
        private void PutConnectionManualEnlisted(SqlInternalConnection con)
        {
            ITransaction transaction = con.ManualEnlistedTransaction;

            con.ResetCachedTransaction(); // Null out con internal transaction reference
            con.InPool = true;            // Mark as in pool so it will not be reclaimed by CheckForDeadConnections

            // Create IConnectionPoint object - from ITransaction
            UCOMIConnectionPoint point = (UCOMIConnectionPoint)transaction;

            // Create outcome event - passing pool, connection, and the IConnectionPoint object
            TransactionOutcomeEvents outcomeEvent = new TransactionOutcomeEvents(this, con, point);

            Int32 cookie = 0;

            point.Advise(outcomeEvent, out cookie); // Register for callbacks, obtain cookie

            outcomeEvent.SetCookie(cookie);         // Set the cookie on the event
        }
Beispiel #10
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();
        }
Beispiel #11
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);
        }
Beispiel #12
0
        public void PutObject(DBPooledObject obj, object owningObject)
        {
            if (obj == null)
            {
                throw ADP.ArgumentNull("obj");
            }

            obj.PrePush(owningObject);

            if (_state != State.ShuttingDown)
            {
                bool isInTransaction = obj.Deactivate();

                if (obj.CanBePooled())
                {
#if USEORAMTS
                    ITransaction transaction = obj.ManualEnlistedTransaction;

                    if (null != transaction)
                    {
                        // When the object is put back into the pool while it is manually
                        // enlisted in a distributed transaction, we must create an outcome
                        // event and let the object wait until the distributed transaction
                        // has finished.  Once it does, the TransactionOutcomeEvents class
                        // can put it back into the general population of the pool.

                        UCOMIConnectionPoint point = (UCOMIConnectionPoint)transaction;

                        TransactionOutcomeEvents outcomeEvent = new TransactionOutcomeEvents(this, obj, point);

                        Int32 cookie = 0;
                        point.Advise(outcomeEvent, out cookie); // Register for callbacks, obtain cookie
                        outcomeEvent.SetCookie(cookie);         // Set the cookie on the event

#if ALLOWTRACING
                        ADP.TraceObjectPoolActivity("WaitForOutcomeEvnt", obj);
#endif //ALLOWTRACING
                        return;
                    }
#endif //USEORAMTS
                    // Try shoving it in the tx context first.  If that succeeds,
                    // we're done.
                    if (isInTransaction && TryPutResourceInContext(obj))
                    {
                        return;
                    }

                    // If the above failed, we just shove it into our current collection
                    PutNewObject(obj);
                }
                else
                {
                    DestroyObject(obj);
                    // Make sure we're at quota by posting a callback to the threadpool.
                    ThreadPool.QueueUserWorkItem(new WaitCallback(PoolCreateRequest));
                }
            }
            else
            {
                // If we're shutting down, we destroy the object.
                DestroyObject(obj);
            }
        }
Beispiel #13
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);
        }
Beispiel #14
0
		/// <summary>
		/// Connects this event sink to a COM object.
		/// </summary>
		/// <param name="connectionPoint">
		/// The connection point to connect to.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="connectionPoint"/> is <see langword="null"/>.
		/// </exception>
		internal void Connect(UCOMIConnectionPoint connectionPoint)
		{
			if (null == connectionPoint) throw new ArgumentNullException("connectionPoint");
			
			if (0 == _connectionCookie)
			{
				int connectionCookie;
				connectionPoint.Advise(this, out connectionCookie);
				_connectionCookie = connectionCookie;
				_connectionPoint = connectionPoint;
			}
		}