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();
                }
            }
     }
    }

  • 相关阅读:
    Airflow 使用 Celery 时,如何添加 Celery 配置
    什么是唯品会JIT业务
    Linux 性能优化排查工具
    HttpClient 报错 Invalid cookie header, Invalid 'expires' attribute: Thu, 01 Jan 1970 00:00:00 GMT
    如何使用 Enterprise Architect 画 UML
    通过maven profile 打包指定环境配置
    Git 使用总结
    Git 分支模型
    本地Windows环境Dubbo搭建测试
    makefile
  • 原文地址:https://www.cnblogs.com/willpower/p/1247189.html
Copyright © 2011-2022 走看看