码迷,mamicode.com
首页 > 其他好文 > 详细

sharepoint 客户端对象模型之日历操作

时间:2016-05-09 15:43:37      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

sharepoint 客户端对象模型对日历的添加和删除操作,完整代码

1 //实例化网站,获取上下文关系
2 ClientContext c = new ClientContext("http://spweb");
1 //身份验证
2 c.Credentials = new System.Net.NetworkCredential("用户名", "密码", "");
1 //获取操作对象
2 Web web = c.Web;

string renyuan = “zhangshan,lisi”;

string[] rilirenyuan = new string[] { };

rilirenyuan = renyuan.Split(‘,‘);

//对日历的添加操作
            ListCreationInformation listInfo = null;

            foreach (var item in rilirenyuan)
            {
                listInfo = new ListCreationInformation();
                listInfo.Title = item;
                listInfo.TemplateType = (int)ListTemplateType.Events;
                listInfo.QuickLaunchOption = QuickLaunchOptions.Off;
                web.Lists.Add(listInfo);
                c.ExecuteQuery();
                string msg = "http://spweb/_layouts/15/start.aspx#/Lists/" + item + "/calendar.aspx \r\n";
                byte[] myByte = System.Text.Encoding.UTF8.GetBytes(msg);
//输出日志记录
                using (FileStream fsWrite = new FileStream(@"D:\1.txt", FileMode.Append))
                {
                    fsWrite.Write(myByte, 0, myByte.Length);
                };


                Console.WriteLine(item);
            }
//对日历的删除操作
            foreach (var item in rilirenyuan)
            {
                List oList = web.Lists.GetByTitle(item);
                oList.DeleteObject();
                c.ExecuteQuery();
                Console.WriteLine(item + "delete");
            }

 

sharepoint 客户端对象模型之日历操作

标签:

原文地址:http://www.cnblogs.com/CHANGZG/p/5474045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!