Sharepoint中EventHander的例子

public class ListEvenClass : SPListEventReceiver
    {

        public override void FieldAdded(SPListEventProperties properties)
        {
            LogEvent(properties, "添加");
        }

        public override void FieldDeleted(SPListEventProperties properties)
        {
            LogEvent(properties, "删除");
        }

        private void LogEvent(SPListEventProperties properties, string eventName)
        {
            StreamWriter sw = File.AppendText(@"C:\listeventlog.txt");
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("[{0}] {1} Event Occurred:\n", DateTime.Now.ToString(), eventName);
            sb.AppendFormat("\tList : {0}", properties.ListTitle);
            sb.AppendFormat("\t{0} - Field {1}", properties.EventType.ToString(), properties.FieldName);
            sw.WriteLine(sb.ToString());
            sw.Close();
        }
    }

posted @ 2008-10-14 17:03  昕友软件开发  阅读(349)  评论(0编辑  收藏  举报
欢迎访问我的开源项目:xyIM企业即时通讯