• MOSS 2007 文档库事件处理


    using System;
    using System.Text;
    using Microsoft.SharePoint;
    using System.Data.SqlClient;
    namespace EventHandle
    {
        public class listEventHandle : IListEventSink
     {
            public void OnEvent(SPListEvent listEvent)
            {

                try
                {
                    if (listEvent.Type == SPListEventType.Insert)
                    {
                        SPWeb web = listEvent.Site.OpenWeb();
                        SPFile SharePointEventItem = web.GetFile(listEvent.UrlAfter);
                        SPListItem item = SharePointEventItem.Item;

                        string itemid = item.ID.ToString();
                        string name = item["姓名"].ToString();
                        string destAdd = item["目的"].ToString();
                        string appDate = item["申请日期"].ToString();
                        string memo = item["备注"].ToString();
                        string email = item["Email"].ToString();
                        string cfd = item["出发地"].ToString();
                        string mdd = item["目的地"].ToString();
                        SqlConnection conn = new SqlConnection("Data Source=moss;Initial Catalog=test;integrated security=SSPI");
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("insert into t_cs(listitem_id,Name,destAdd,appDate,memo,email,cfd,mdd) values('" + itemid + "','" + name + "','" + destAdd + "','" + appDate + "','" + memo + "','" + email + "','" + cfd + "','" + mdd + "')", conn);
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
                catch (Exception e)
                {
                    System.IO.StreamWriter log = new System.IO.StreamWriter(@"d:\log.txt", true);
                    log.Write("StackTrace:" + e.StackTrace);
                    log.Write("Message:" + e.Message);
                    log.Flush();
                    log.Close();
                }
            }
     }
    }

  • 相关阅读:
    C#学习第四弹之封装、继承和多态
    C#学习第三弹之给常量赋值可能引发的问题
    C#学习第二弹之C#与.NET框架
    hdu 5199 map或二分或哈希
    hdu 5195 线段树
    hdu 2545 并查集
    ACM数论模板
    C#学习第一弹之Hello World
    对字符串进行频繁拼接的话,使用StringBuffer或者StringBuilder
    String中根据,(逗号)进行分割
  • 原文地址:https://www.cnblogs.com/willpower/p/1247189.html
Copyright © 2020-2023  润新知