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(); }
#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); }
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); }
// 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); } }
// 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); } }
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); }
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); } }
/// <summary> /// Initialize the event sink. /// </summary> private void Initialize() { if (null == _connectionPointContainer) { throw new ObjectDisposedException("ComEventProvider"); } UCOMIConnectionPoint connectionPoint; Guid pointGuid = _connectionPointGuid; _connectionPointContainer.FindConnectionPoint(ref pointGuid, out connectionPoint); _connectionPoint = connectionPoint; _eventSink = (ComEventSink)Activator.CreateInstance(_eventSinkType); _eventSink.Connect(_connectionPoint); _eventSink.Owner = _owner; }
/// <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(); }
/// <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); }
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); }