Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2010 事件接收器停止工作_Sharepoint 2010_Sharepoint Deployment - Fatal编程技术网

Sharepoint 2010 事件接收器停止工作

Sharepoint 2010 事件接收器停止工作,sharepoint-2010,sharepoint-deployment,Sharepoint 2010,Sharepoint Deployment,由于某种原因,我正在处理一个事件接收器,但它停止了工作。我正在从VisualStudio2010更新和部署它,它以前是工作的,但在我执行查找字段时它停止了。即使我删除刚才添加的部分,它也不再起作用。任何想法。多谢各位 `/// An item was added. /// </summary> public override void ItemAdded(SPItemEventProperties properties) { base.

由于某种原因,我正在处理一个事件接收器,但它停止了工作。我正在从VisualStudio2010更新和部署它,它以前是工作的,但在我执行查找字段时它停止了。即使我删除刚才添加的部分,它也不再起作用。任何想法。多谢各位

    `/// An item was added.
    /// </summary>
    public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);
        string fname = Convert.ToString(properties.AfterProperties["Title"]);
        string Cdate = Convert.ToString(properties.AfterProperties["CDate"]).Substring(2, 2);
        // ---- Lookup fields ----- 
        String lookupZF = "Office";
        String ZF = Convert.ToString(properties.ListItem[lookupZF]);
        SPFieldLookupValue ZFValue = new SPFieldLookupValue(ZF);
        // ------ End of lookup fields ----- 
        string FName = fname + Cdate; // + ZFValue;

        SPSecurity.RunWithElevatedPrivileges(delegate()
                       {
                           using (SPSite site = new SPSite(properties.Web.Site.ID))
                           {
                               using (SPWeb web = site.OpenWeb())
                               {
                                   web.AllowUnsafeUpdates = true;
                                   SPList CurrentList = web.Lists[properties.ListId];
                             SPListItem Litem = CurrentList.GetItemById(properties.ListItemId);

                                   Litem["Description"] = "update working ...!";
                                   Litem["Prop No."] = FName;

                                   Litem.Update();
                                   CurrentList.Update();

                                   web.AllowUnsafeUpdates = false;
                               }
                           }
                       });
    }`
`///添加了一项。
/// 
添加了公共覆盖无效项(SPItemEventProperties属性)
{
基本。添加的项目(属性);
字符串fname=Convert.ToString(properties.AfterProperties[“Title”]);
字符串Cdate=Convert.ToString(properties.AfterProperties[“Cdate”])。子字符串(2,2);
//-----查找字段------
字符串lookupZF=“Office”;
字符串ZF=Convert.ToString(properties.ListItem[lookupZF]);
SPFieldLookupValue ZFValue=新的SPFieldLookupValue(ZF);
//-----查找字段的结束------
字符串FName=FName+Cdate;//+ZFValue;
SPSecurity.runWithLevelatedPrivileges(委托()
{
使用(SPSite site=newspsite(properties.Web.site.ID))
{
使用(SPWeb=site.OpenWeb())
{
web.AllowUnsafeUpdates=true;
SPList CurrentList=web.Lists[properties.ListId];
SPListItem Litem=CurrentList.GetItemById(properties.ListItemId);
Litem[“Description”]=“更新工作…!”;
Litem[“项目编号”]=FName;
Litem.Update();
CurrentList.Update();
web.AllowUnsafeUpdates=false;
}
}
});
}`

我建议在部署解决方案后,检查“管理站点功能”中的功能是否已激活。

我必须使用日期时间,然后才能获取年份。出于某种原因,我得到了空字符串或null字符串,从而停止了代码的执行。以下是有效的方法:

DateTime Cdate = DateTime.Parse(properties.ListItem["Created"].ToString());
string SDate = Cdate.Year.ToString().Substring(2, 2);

我想是日期字段?解析年份(最后2位)的正确/保存方式是什么。谢谢