// ExecPkgEvents.h #define STRICT #define WIN32_LEAN_AND_MEAN #define INC_OLE2 #define UNICODE #define _UNICODE #include #include #include #include #include // COM Compiler support for _bstr_t #include // connection points #include "C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\DevTools\\include\\dtspkg.h" #define BAD_COOKIE 99999 void DisplayError(_com_error& pCE); void DisplayStepResults(IDTSPackage2* pDTSPackage2); class CDTSPackageEvents : public IDTSPackageEvents { public: CDTSPackageEvents() { m_uiRefCount = 0; } ~CDTSPackageEvents() { } // IUnknown STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppvObj) { if (riid == IID_IUnknown || riid == IID_IDispatch || riid == IID_IDTSPackageEvents) { AddRef(); *ppvObj = this; return NOERROR; } *ppvObj = NULL; return E_NOINTERFACE; } STDMETHOD_(ULONG, AddRef)(void) { return InterlockedIncrement((LPLONG)&m_uiRefCount); } STDMETHOD_(ULONG, Release)(void) { if (InterlockedDecrement((LPLONG)&m_uiRefCount) == 0) { delete this; return 0; } return m_uiRefCount; } // IDispatch not implemented, and not required by Package. STDMETHOD(GetTypeInfoCount)(UINT FAR* pcTypeInfo) { *pcTypeInfo = 0; return E_NOTIMPL; } STDMETHOD(GetTypeInfo)(UINT iTypeInfo, LCID lcid, ITypeInfo FAR* FAR* ppTypeInfo) { *ppTypeInfo = NULL; return E_NOTIMPL; } STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR FAR* rgszNames, UINT cNames, LCID lcid, DISPID FAR* rgdispid) { return E_NOTIMPL; } STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pdispparams, LPVARIANT pVarResult, LPEXCEPINFO pexcepinfo, UINT FAR* puArgErr) { return E_NOTIMPL; } // EventSink methods. // STDMETHOD(OnStart)(THIS_ DTS_IN BSTR EventSource) { _tprintf(_T("OnStart(%s)\n"), (LPTSTR) EventSource); return NOERROR; } STDMETHOD(OnFinish)(THIS_ DTS_IN BSTR EventSource) { _tprintf(_T("OnFinish(%s)\n"), (LPTSTR) EventSource); return NOERROR; } STDMETHOD(OnError)(THIS_ DTS_IN BSTR EventSource, DTS_IN long ErrorCode, DTS_IN BSTR Source, DTS_IN BSTR Description, DTS_IN BSTR HelpFile, DTS_IN long HelpContext, DTS_IN BSTR IDofInterfaceWithError, DTS_OUT VARIANT_BOOL *pbCancel) { _tprintf(_T("OnError(%s, %d, %s, %s, %s)\n"), (LPTSTR) EventSource, ErrorCode, (LPTSTR) Source, (LPTSTR) HelpFile, (LPTSTR) HelpContext); // We don't want to cancel in this utility. // if (pbCancel) { *pbCancel = VARIANT_FALSE; } return NOERROR; } STDMETHOD(OnProgress)(THIS_ DTS_IN BSTR EventSource, DTS_IN BSTR ProgressDescription, DTS_IN long PercentComplete, DTS_IN long ProgressCountLow, DTS_IN long ProgressCountHigh) { _tprintf(_T("OnProgress(%s, %s, %d, %d, %d)\n"), (LPTSTR) EventSource, (LPTSTR) ProgressDescription, PercentComplete, ProgressCountLow, ProgressCountHigh); LARGE_INTEGER liProgressCount; liProgressCount.LowPart = ProgressCountLow; liProgressCount.HighPart = ProgressCountHigh; return NOERROR; } STDMETHOD(OnQueryCancel)(THIS_ DTS_IN BSTR EventSource, DTS_OUT VARIANT_BOOL *pbCancel) { _tprintf(_T("OnQueryCancel(%s)\n"), (LPTSTR) EventSource); // This is asking us if we want to cancel.. just say no. // if (pbCancel) { *pbCancel = VARIANT_FALSE; } return NOERROR; } private: UINT m_uiRefCount; };