Re: List Event Handler firing twice
- From: "JD" <yazoo@xxxxxxxxxxxxxxxx>
- Date: Thu, 23 Aug 2007 21:12:16 -0400
As part of my testing, I stripped down the code to the basics, but it still
gets fired twice. The code is below.
Oddly, it does not fire twice on another test machine that I have. Is there
any way it could get "installed" twice? Any way to check for that?
To install the handler, I build a .wsp file and then install it so my
handler appears as feature on my sites. Then I activate the feature on the
appropriate sites.
Should I be calling base.ItemAdded(), base.ItemUpdated, and
base.ItemDeleted()?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Data;
using System.IO;
using Microsoft.SharePoint;
namespace MyHandler
{
public class ItemEventReceiver : SPItemEventReceiver
{
private void writeLog(string s)
{
try
{
StreamWriter writer =
File.AppendText("c:\\temp\\myHandler.txt");
writer.WriteLine(System.DateTime.Now.ToShortDateString() + "
" + System.DateTime.Now.ToShortTimeString() + ": " + s);
writer.Close();
}
catch (Exception)
{
}
}
// List item added
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
myHandler("ItemAdded", properties);
}
// List item udpated
public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties);
myHandler("ItemUpdated", properties);
}
// List item deleted
public override void ItemDeleted(SPItemEventProperties properties)
{
base.ItemDeleted(properties);
myHandler("ItemDeleted", properties);
}
private void myHandler(string eventType, SPItemEventProperties
properties)
{
writeLog("List ID: " + properties.ListId.ToString());
writeLog("Web url: " + properties.WebUrl);
writeLog("Site ID: " + properties.SiteId);
writeLog("User login: " + properties.UserLoginName);
writeLog("User name: " + properties.UserDisplayName);
writeLog("Event type: " + properties.EventType.ToString());
if (eventType != "ItemDeleted")
{
writeLog("List column dump:");
foreach (SPField item in properties.ListItem.Fields)
{
writeLog(" DisplayName:" + item.Title + " Internal:" +
item.InternalName);
}
}
}
}
}
"Wei Lu [MSFT]" <weilu@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:u%23M9WNT5HHA.2340@xxxxxxxxxxxxxxxxxxxxxxxxx
Hello JD,
I would like to get the code you use for further troubleshooting.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
.
- Follow-Ups:
- Re: List Event Handler firing twice
- From: Wei Lu [MSFT]
- Re: List Event Handler firing twice
- References:
- List Event Handler firing twice
- From: JD
- RE: List Event Handler firing twice
- From: Wei Lu [MSFT]
- Re: List Event Handler firing twice
- From: JD
- Re: List Event Handler firing twice
- From: Wei Lu [MSFT]
- List Event Handler firing twice
- Prev by Date: Thanx Note
- Next by Date: RE: Showing Issue ID on Lists
- Previous by thread: Re: List Event Handler firing twice
- Next by thread: Re: List Event Handler firing twice
- Index(es):
Relevant Pages
|