using System;
using System.IO;
using System.Data;
using System.Collections;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebControls;
using Smart.XSystem;
using Smart.XData;
using System.DirectoryServices;
//using BankPro.COM.ADFunc;
namespace XEvent
{
/// <summary>
/// 文件库的event handler
/// </summary>
/// <remarks>
/// </remarks>
public class XEventSink : IListEventSink
{
XConfig Config = new XConfig(XConfig.DSNType.SharePoint, "SPS");
string DateTimeFormat = "yyyy/MM/dd HH:mm:ss";
public XEventSink()
{
//
// TODO: Add constructor logic here
//
}
void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent pEvent)
{
this.HandleEvent(pEvent);
}
public void HandleEvent(Microsoft.SharePoint.SPListEvent pEvent)
{
try
{
SPWeb web = pEvent.Site.OpenWeb();
SPFile file;
string ActionType = "";
Hashtable lTable = new Hashtable();
switch (pEvent.Type)
{
//新增
case SPListEventType.Insert:
file = web.GetFile(pEvent.UrlAfter);
ActionType = "I";
break;
//修改
case SPListEventType.Update:
file = web.GetFile(pEvent.UrlAfter);
ActionType = "U";
break;
//删除
case SPListEventType.Delete:
file = web.GetFile(pEvent.UrlBefore);
ActionType = "D";
break;
default:
return;
}
this.WriteToDB(pEvent, file, ActionType);
}
catch (Exception Ex)
{
string Msg = Ex.Message;
}
}
public void WriteToDB(SPListEvent pEvent, SPFile pFile, string ActionType)
{
try
{
XOleDb.BeginTran(Config.DSN);
XDataAccess.ExecuteNonQueryCommand(lSQL);
XOleDb.CommitTran();
}
catch (Exception Ex)
{
string Msg = Ex.Message;
XOleDb.Rollback();
}
}
}
}
浙公网安备 33010602011771号