博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sharepoint 增删改查
阅读量:4925 次
发布时间:2019-06-11

本文共 5075 字,大约阅读时间需要 16 分钟。

前端提交

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MeetingOneWeekNotifyList.aspx.cs" Inherits="MeetingOneWeekNotifyList" %><%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Assembly Name="CodeArt.SharePoint.CamlQuery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=43536cfde91ea799" %><%@ Assembly Name="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" %>
<%--
--%>
一周会议通知
+新增会议申请
序列号 会议室名称 会议名称 申请时间 操作
1 会议室(918) 共同探讨党的18大会议精神1 2014-03-12 10:20-11:20
1 会议室(918) 共同探讨党的18大会议精神1 2014-03-12 10:20-11:20
共有3个会议
<
1
>

一般处理程序  

<%@ WebHandler Language="C#" Class="HandlerMeetReq" %><%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Assembly Name="CodeArt.SharePoint.CamlQuery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=43536cfde91ea799" %><%@ Assembly Name="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" %>using System;using System.Web;using Microsoft.SharePoint;using CodeArt.SharePoint.CamlQuery;using EntityLib;public class HandlerMeetReq : IHttpHandler {    public void ProcessRequest(HttpContext context)    {        context.Response.ContentType = "text/plain";        MeetEntity meetingEntity = new MeetEntity();                try        {            string strReq = context.Request["req"];            string strMethod = context.Request["method"];            MeetEntity entity = Newtonsoft.Json.JsonConvert.DeserializeObject
(strReq); SPContext.Current.Web.AllowUnsafeUpdates = true; SPList list = SPContext.Current.Web.Lists["会议申请"]; SPListItem item = null; if (strMethod == "Add") { item = list.AddItem(); } else { item = list.GetItemById(int.Parse(entity.MeetId)); } if (strMethod == "Add" || strMethod == "Update") { item["标题"] = entity.MeetTitle; item.Update(); } else if (strMethod == "Del") { item.Delete(); } context.Response.Write("OK"); } catch (Exception ex) { context.Response.Write(ex.Message); } } public bool IsReusable { get { return false; } }}//public class MeetEntity//{// public MeetEntity()// {// }// public string MeetId;// public string MeetTitle;// public string MeetRoomId;// public string MeetRoomTitle;// public string MeetContent;//}

  查看数据页面 :http://tuvaudit:41182/Lists/List/AllItems.aspx

 

<%@ WebHandler Language="C#" Class="HandlerMeetList" %><%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Assembly Name="CodeArt.SharePoint.CamlQuery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=43536cfde91ea799" %><%@ Assembly Name="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" %><%@ Assembly Name="EntityLib, Version=1.0.0.0, Culture=neutral" %>using System;using System.Web;using System.Collections.Generic;using Microsoft.SharePoint;using CodeArt.SharePoint.CamlQuery;using EntityLib;public class HandlerMeetList : IHttpHandler{    public void ProcessRequest(HttpContext context)    {        context.Response.ContentType = "text/plain";        SPList list = SPContext.Current.Web.Lists["会议申请"];        QueryField qfId = new QueryField("ID");        SPListItemCollection items = ListQuery.From(list).Where(qfId > 0).GetItems();        List
lstEntities = new List
(); foreach (SPListItem item in items) { MeetEntity entity = new MeetEntity(); entity.MeetId = item.ID.ToString(); entity.MeetTitle = ConvertObj(item["序列号"]); entity.MeetRoomId = ConvertObj(item["会议室名称"]); entity.MeetRoomTitle = ConvertObj(item["会议名称"]); entity.MeetContent = ConvertObj(item["申请时间"]); lstEntities.Add(entity); } //context.Response.Write("Hello World"); context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(lstEntities)); } public bool IsReusable { get { return false; } } private string ConvertObj(object obj) { return obj == null ? "" : obj.ToString(); }}//public class MeetEntity//{// public MeetEntity()// {// }// public string MeetId;// public string MeetTitle;// public string MeetRoomId;// public string MeetRoomTitle;// public string MeetContent;//}

 

 

转载于:https://www.cnblogs.com/laopo/p/6061264.html

你可能感兴趣的文章
C语言位运算
查看>>
OSI七层协议模型、TCP/IP四层模型学习笔记
查看>>
windown vs2012 编译ffplay
查看>>
RTMP协议规范(转载)
查看>>
盘点那些大牌互联网公司内部使用的JavaScript库
查看>>
CentOS 7.0下使用yum安装MySQL
查看>>
vue初级学习--路由router的编写(resolve的使用)
查看>>
批处理学习01
查看>>
java 继承练习题5
查看>>
英媒:滴滴和优步每年烧钱64亿
查看>>
HTMLParser-简单HTML和XHTML解析
查看>>
Java_基础_关键字_volatile
查看>>
American Heritage usaco
查看>>
BZOJ 3689 异或之
查看>>
sublime运行错误
查看>>
vue中渲染页面,动态设置颜色
查看>>
理清cordova插件的调用流程
查看>>
【20170926】【软工】第一次个人项目——数独
查看>>
【poj1741 Tree】
查看>>
如何控制oracle RAC 进行并行运算
查看>>