sharepoint操作库和栏

chu715322834 2011-04-17 10:46:13
一个库有 日期 正文 创建者 修改者 签出对象 5个栏
private static string _webUrl = "";
private static string _domain = "";
private static string _listName = "市局文件、通知栏";
[WebBrowsable(true), Personalizable(false), WebDescription("网站集URL"), WebDisplayName("网站集URL")]
public string SiteUrl
{
get
{ return SPContext.Current.Site.Url; }
}
[WebBrowsable(true), Personalizable(false), WebDescription("网站URL"), WebDisplayName("网站URL")]
public string WebUrl
{
get { return _webUrl; }
set { _webUrl = value; }
}
[WebBrowsable(true), Personalizable(false), WebDescription("域名"), WebDisplayName("域名")]
public string Domain
{
get { return _domain; }
set { _domain = value; }
}



protected void Page_Load(object sender, EventArgs e)
{

}

public static void ShowMessage(Page page, string message, string target)
{
page.ClientScript.RegisterStartupScript(
page.GetType(),
Guid.NewGuid().ToString(),
string.Format(@"<script language=javascript>alert(""{0}"");window.location.href=""{1}"";</script>",
message.Replace(@"""", "'").Replace("\r\n", @"\n").Replace("\n", @"\n").Replace("\\",
"\\\\").
Replace(@"\\n", @"\n"), target));
}

/// <summary>
/// 保存公告
/// </summary>
/// <returns></returns>
private int SaveNotice()
{

try
{
Guid siteID = SPContext.Current.Site.ID;
SPUser curUser = SPContext.Current.Web.CurrentUser;
using (SPSite site = new SPSite(siteID))
{
using (SPWeb web = site.RootWeb)
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists[_listName];
SPListItem item = null;

item = list.Items.Add();

if (string.IsNullOrEmpty(this.txtTitle.Text.Trim()))
{
ShowMessage(this.Page, "请输入标题信息","");
return -1;
}
item["日期"] = this.dtTime.SelectedDate;
item["正文"] = this.txtTestRecord.Html;
item["创建者"] = curUser.LoginName;
item["修改者"] = curUser.LoginName;
item["签出对象"] = curUser.LoginName;
Response.Write(_listName.ToString());
Response.Write(curUser.LoginName.ToString());
item.Update();

}
}
}


catch (Exception ex)
{
Response.Write(ex.ToString());
}
return 1;
}

protected void Button1_Click(object sender, EventArgs e)
{
int id = SaveNotice();
if (id > 0)
{
this.Response.Redirect("11/Forms/AllPages.aspx");
}
}

老报错为 SHAREPOINT\systemMicrosoft.SharePoint.SPException: 若要将项目添加到文档库,请使用 SPFileCollection.Add() 在 Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, SPWeb web, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames, Object& objAttachmentContents, Int32& parentFolderId) 在 Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) 在 Microsoft.SharePoint.SPListItem.Update() 在 sjgg.sjggAdd.SaveNotice()


还有不管ID>0或者小于0都跳转页面
...全文
150 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Justin-Liu 2011-04-17
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yun_liang1028 的回复:]
SPSite oSiteCollection = SPContext.Current.Site;
SPWeb oWebsiteSrc = oSiteCollection.AllWebs["Source_Site_Name"];
SPWebCollection collWebsites =
oSiteCollection.AllWebs["Destination_Site_Name"].……
[/Quote]
bingo
chu715322834 2011-04-17
  • 打赏
  • 举报
回复
对文档库 操作 要怎么写
Oo云 2011-04-17
  • 打赏
  • 举报
回复
SPSite oSiteCollection = SPContext.Current.Site;
SPWeb oWebsiteSrc = oSiteCollection.AllWebs["Source_Site_Name"];
SPWebCollection collWebsites =
oSiteCollection.AllWebs["Destination_Site_Name"].Webs;

SPFile oFile = oWebsiteSrc.GetFile("Source_Folder_Name/Source_File");
string strFilename = oFile.Name;
byte[] binFile = oFile.OpenBinary();

foreach (SPWeb oWebsite in collWebsites)
{
if (oWebsite.GetFolder("Shared Documents").Exists)
{
SPFolder oFolder = oWebsite.GetFolder("Shared Documents");
oFolder.Files.Add(strFilename, binFile, true);
}
oWebsite.Dispose();
}
oWebsiteSrc.Dispose();
内容概要:本文介绍了COSO企业风险管理框架,阐述了企业风险管理的定义、目标、构成要素及其与内部控制的关系。文章指出,企业风险管理是一个由董事会、管理层及其他人员实施的,应用于战略制定并贯穿于企业之中的过程,旨在识别可能影响主体的潜在事项,管理风险以使其在该主体的风险容量之内,并为主体目标的实现提供合理保证。该框架强调了企业风险管理的八大构成要素:内部环境、目标设定、事项识别、风险评估、风险应对、控制活动、信息与沟通、监控。此外,文章还讨论了企业风险管理的局限性,如人为判断失误、成本与效益的权衡、管理层凌驾等。 适合人群:具备一定管理学基础知识,对风险管理有兴趣的学者、企业管理人员、内部审计师及外部审计师。 使用场景及目标:①帮助组织理解并应用企业风险管理框架,以提高组织的风险管理水平;②指导企业如何通过有效的风险管理来实现其战略、经营、报告和合规目标;③为企业提供一套标准化的风险管理语言,促进内外部沟通与合作。 阅读建议:读者应结合实际案例,深入理解每个构成要素的具体应用,同时关注企业风险管理的局限性,以全面把握企业风险管理的本质。此外,建议定期回顾和更新风险管理策略,以适应不断变化的内外部环境。

3,245

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨 - LinyuLoveTJ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧