⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irowsetnotifysourceimpl.h

📁 The ATL OLE DB Provider templates only seem to support read-only rowsets and making them support upd
💻 H
字号:
#ifndef __I_ROWSET_NOTIFY_SOURCE_IMPL__INCLUDED__
#define __I_ROWSET_NOTIFY_SOURCE_IMPL__INCLUDED__

#include <atlcom.h>
#include <atldb.h>

///////////////////////////////////////////////////////////////////////////
// class IRowsetNotifySourceImpl 

template <class T>
class ATL_NO_VTABLE IRowsetNotifySourceImpl : public IConnectionPointImpl<T, &IID_IRowsetNotify>
{
public:

   typedef IConnectionPointImpl<T ,&IID_IRowsetNotify,ATL::CComDynamicUnkArray> RowsetNotifyConnections;

   STDMETHOD(Fire_OnFieldChange)(
      HROW           hRow,                // handle to the row that's changing
      ULONG          cColumns,            // count of columns in the rgColumns array
      ULONG          rgColumns[],         // array of columns in the row that have changed
      DBREASON       eReason,             // the reason
      DBEVENTPHASE   ePhase,              // the phase we're in
      BOOL           fCantDeny)           // true if consumers can't veto the change
   {
      HRESULT hr = S_OK;

      IRowset *pRowset = (T*)this;

      IUnknown **ppUnknown = RowsetNotifyConnections::m_vec.begin();

      while (ppUnknown < RowsetNotifyConnections::m_vec.end())
	   {
         if (*ppUnknown != NULL)
         {
            IRowsetNotify *pNotify = (IRowsetNotify*)*ppUnknown;
      
            ATLTRACE2(atlTraceDBProvider, 0, "IRowsetNotifySourceImpl::Fire_OnFieldChange() - %p\n", pNotify);
            
            hr = pNotify->OnFieldChange(pRowset, hRow, cColumns, rgColumns, eReason, ePhase, fCantDeny);           
            
            if (hr == S_FALSE && fCantDeny == FALSE)
            {
               break;
            }
         }
		   ppUnknown++;
	   }

      if (hr == S_FALSE)
      {
         hr = E_FAIL;
      }

      ATLTRACE2(atlTraceDBProvider, 0, "IRowsetNotifySourceImpl::Fire_OnFieldChange() - %s\n", ((hr == S_OK) ? "OK" : "Not OK"));

      return hr;
   }

   STDMETHOD(Fire_OnRowChange)(
      ULONG          cRows,
      const HROW     rghRows[],
      DBREASON       eReason,
      DBEVENTPHASE   ePhase,
      BOOL           fCantDeny)
   {
      HRESULT hr = S_OK;

      IRowset *pRowset = (T*)this;

      IUnknown **ppUnknown = RowsetNotifyConnections::m_vec.begin();

      while (ppUnknown < RowsetNotifyConnections::m_vec.end())
	   {
         if (*ppUnknown != NULL)
         {
            IRowsetNotify *pNotify = (IRowsetNotify*)*ppUnknown;
      
            ATLTRACE2(atlTraceDBProvider, 0, "IRowsetNotifySourceImpl::Fire_OnFieldChange() - %p\n", pNotify);
            
            hr = pNotify->OnRowChange(pRowset, cRows, rghRows, eReason, ePhase, fCantDeny);
            
            if (hr == S_FALSE && fCantDeny == FALSE)
            {
               break;
            }
         }
		   ppUnknown++;
	   }

      if (hr == S_FALSE)
      {
         hr = E_FAIL;
      }

      return hr;
   }

   STDMETHOD(Fire_OnRowsetChange)(
      DBREASON       eReason,
//      DBEVENTPHASE   ePhase,
      BOOL           fCantDeny)
   {
      HRESULT hr = S_OK;

      IRowset *pRowset = (T*)this;

      IUnknown **ppUnknown = RowsetNotifyConnections::m_vec.begin();

      while (ppUnknown < RowsetNotifyConnections::m_vec.end())
	   {
         if (*ppUnknown != NULL)
         {
            IRowsetNotify *pNotify = (IRowsetNotify*)*ppUnknown;
      
            ATLTRACE2(atlTraceDBProvider, 0, "IRowsetNotifySourceImpl::Fire_OnFieldChange() - %p\n", pNotify);
            
            hr = pNotify->OnRowsetChange(pRowset, eReason, DBEVENTPHASE_DIDEVENT /*ePhase*/, fCantDeny);
            
            if (hr == S_FALSE && fCantDeny == FALSE)
            {
               break;
            }
         }
		   ppUnknown++;
	   }

      if (hr == S_FALSE)
      {
         hr = E_FAIL;
      }
   
      return hr;
   }
};

#endif // __I_ROWSET_NOTIFY_SOURCE_IMPL__INCLUDED__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -