zoukankan      html  css  js  c++  java
  • 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();
                }
            }
     }
    }

  • 相关阅读:
    CENTOS7下安装REDIS
    金融量化之tushare模块的使用
    fiddler抓包出现错误 creation of the root certificate was not successful
    matplotlib学习
    Android-消息处理学习总结(Handler,Looper)
    Android-View的绘制源码学习总结
    数据库练习
    编译原理实验一
    图形学
    资源分配(分组背包)
  • 原文地址:https://www.cnblogs.com/willpower/p/1247189.html
Copyright © 2011-2022 走看看