我有以下 .cs 文件;
using System;
using System.Collections.Generic;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Events;
using Sitecore.SecurityModel;
namespace LocationItemEventHandler
{
public class ItemEventHandler
{
private static readonly SynchronizedCollection<ID> MProcess = new SynchronizedCollection<ID>();
/// <summary>
/// This custom event auto-populates latitude/longitude co-ordinate when a location item is saved
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
protected void OnItemSaved(object sender, EventArgs args)
{
var item = Event.ExtractParameter(args, 0) as Item;
if (item != null && !MProcess.Contains(item.ID))
{
if (item.TemplateID.Equals("{E490971E-758E-4A75-9C8D-67EC2C6321CA}"))
{
string errMessage = "";
string responseCode = "";
string address = item.Fields["Address"].Value;
if (1=1)
{
string latitude = "100";
string longitude = "200";
MProcess.Add(item.ID);
try
{
var latlngField = item.Fields["Google LatLng"];
using (new SecurityDisabler())
{
item.Editing.BeginEdit();
latlngField.SetValue(latitude + " - " + longitude, true);
Sitecore.Context.ClientPage.ClientResponse.Alert(
string.Format(
"Fields updated automatically\r\nLatitude: {0}\r\nLongitude: {1}",
latitude, longitude));
item.Editing.EndEdit();
}
}
catch (Exception exception)
{
Log.Error(exception.Message, this);
}
finally
{
MProcess.Remove(item.ID);
}
}
}
}
}
}
}
这是在一个代码文件LocationItemEventHandler.cs
中App_Code
。这是在 web.config
<event name="item:saved">
<handler type="LocationItemEventHandler.ItemEventHandler, LocationItemEventHandler" method="OnItemSaved"/>
</event>
当我尝试保存项目时,我得到“无法解析类型名称”。
我错过了什么?