C# 为什么自定义SharePoint计时器作业只能处理列表中一半的项目?
我们有一个计时器作业,用于检查SharePoint用户配置文件服务中的用户位置和标题,然后使用关联的管理员更新办公室页面库的元数据。我们最近更新了逻辑,在QA环境中发布并运行了它,有些页面确实得到了更新,有些没有。尽管在用户配置文件服务中有经理,但大约有一半没有变化。为什么同样的代码会在一半的页面上失败 列表中有Office、Manager等列。代码循环遍历每个配置文件,如果用户的配置文件中有标题“Manager”和Office“Seattle”,则会搜索库并将该用户设置为管理员并发布页面。所有页面都基于一个公共内容类型 尝试清除所有页面上的所有管理器字段&其中一半已更新。失败的用户确实有用户配置文件,我可以手动设置管理器。什么会导致它只在某些页面上失败 这是密码。在getOfficeManager方法中,我对它们进行了两次循环,一次是设置培训中的经理,然后用完整的经理(如果存在的话)覆盖它们(有些经理只有培训中的经理)。这是我对代码所做的更改C# 为什么自定义SharePoint计时器作业只能处理列表中一半的项目?,c#,sharepoint,timer-jobs,C#,Sharepoint,Timer Jobs,我们有一个计时器作业,用于检查SharePoint用户配置文件服务中的用户位置和标题,然后使用关联的管理员更新办公室页面库的元数据。我们最近更新了逻辑,在QA环境中发布并运行了它,有些页面确实得到了更新,有些没有。尽管在用户配置文件服务中有经理,但大约有一半没有变化。为什么同样的代码会在一半的页面上失败 列表中有Office、Manager等列。代码循环遍历每个配置文件,如果用户的配置文件中有标题“Manager”和Office“Seattle”,则会搜索库并将该用户设置为管理员并发布页面。所有
//using statements snipped for brevity
namespace RC.SharePoint.Portal.TimerJobs
{
public class SyncOfficeLocationService: SPJobDefinition
{
#region CONSTANTS
public const string JOB_NAME = "World Office Location Synchronization Service";
public const string TIMER_JOB_META_DATA = "TimerJobMetaData";
private const string PAGES_LIBRARY = "Pages";
private const string USER_PROFILE_FIELD_OFFICE = "Office";
private const string USER_PROFILE_FIELD_TITLE = "Title";
private const string USER_PROFILE_FIELD_DEPT = "Department";
private const string USER_PROFILE_DEPT_REST_OP = "Office Operations";
private const string Office_PROFILE_CONTENT_TYPE = "Office Profile";
private const string Office_SITE_NAME = "rest";
private struct Designations
{
public const string General_Manager = "General Manager";
public const string General_Manager_In_Training = "General Manager in Training";
public const string ManagingPartner = "Managing Partner";
public const string ManagingPartner_In_Training = "Managing Partner in Training";
public const string OperationsManager = "Operations Manager";
public const string OperationsManager_In_Training = "Operations Manager in Training";
public const string ShiftManager = "Shift Manager";
public const string ShiftManager_In_Training = "Shift Manager in Training";
}
private struct Pages
{
public const string Title = "Title";
public const string ContentType = "ContentType";
public const string Name = "Name";
public const string NameInt = "FileLeafRef";
public const string GeneralManager = "General Manager";
public const string GeneralManagerInt = "RC_RestProfile_GeneralManager";
public const string ManagingPartner = "Managing Partner";
public const string ManagingPartnerInt = "RC_RestProfile_ManagingPartner";
public const string OperationsManager = "Operations Manager";
public const string OperationsManagerInt = "RC_RestProfile_OperationsManager";
public const string ShiftManager1 = "Shift Manager 1";
public const string ShiftManager1Int = "RC_RestProfile_ShiftManager1";
public const string ShiftManager2 = "Shift Manager 2";
public const string ShiftManager2Int = "RC_RestProfile_ShiftManager2";
//snipped for space
}
#endregion
#region CONSTRUCTORS
public SyncOfficeLocationService()
: base()
{
}
public SyncOfficeLocationService(string jobName, SPService service, SPServer server, SPJobLockType targetType)
: base(jobName, service, server, targetType)
{
}
public SyncOfficeLocationService(string jobName, SPWebApplication webApplication)
: base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
{
this.Title = jobName;
}
#endregion
#region METHODS
protected override bool HasAdditionalUpdateAccess()
{
return true;
}
public override void Execute(Guid targetInstanceId)
{
try
{
//Read settings from Hierarchical object store
TimerJobMetaData settings = this.WebApplication.GetChild<TimerJobMetaData>(TIMER_JOB_META_DATA);
using (SPSite site = new SPSite(settings.SiteUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Medium, EventSeverity.Information), TraceSeverity.Medium, string.Format("Timer Service started for SharePoint portal: {0}", web.Url), "");
List<OfficeLocation> Offices = GetOfficeManagers(site);
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Medium, EventSeverity.Information), TraceSeverity.Medium, "User profile service parsed successfully. " + Offices.Count.ToString() + " Offices found.", "");
SyncOfficeManagers(web.Webs[Office_SITE_NAME], Offices);
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Medium, EventSeverity.Information), TraceSeverity.Medium, string.Format("Timer Service finished for SharePoint portal: {0}", web.Url), "");
}
}
}
catch (Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
}
}
private Dictionary<string, string> GetUserProfiles(SPSite site)
{
Dictionary<string, string> users = new Dictionary<string, string>();
try
{
SPServiceContext serverContext = SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(serverContext);
IEnumerator userProfiles = profileManager.GetEnumerator();
while (userProfiles.MoveNext())
{
UserProfile userProfile = (UserProfile)userProfiles.Current;
if (userProfile[USER_PROFILE_FIELD_TITLE] != null && userProfile[USER_PROFILE_FIELD_TITLE].Value != null && userProfile[USER_PROFILE_FIELD_TITLE].Value.ToString().Equals(Designations.General_Manager))
{
if (userProfile[USER_PROFILE_FIELD_OFFICE] != null && userProfile[USER_PROFILE_FIELD_OFFICE].Value != null)
{
string key = string.Format("{0}.aspx", userProfile[USER_PROFILE_FIELD_OFFICE].Value.ToString().Replace("RC ", "C"));
if (!users.ContainsKey(key))
users.Add(key, userProfile.AccountName);
}
}
}
}
catch(Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
}
return users;
}
private void SyncOffices(SPWeb web, Dictionary<string, string> users)
{
try
{
SPDocumentLibrary pagesLib = web.Lists[PAGES_LIBRARY] as SPDocumentLibrary;
SPClaimProviderManager cpm = SPClaimProviderManager.Local;
SPWeb rootWeb = web.Site.RootWeb;
var query = new SPQuery();
query.Query = string.Format(@"<Where><Eq><FieldRef Name=""{0}"" /><Value Type=""Text"">{1}</Value></Eq></Where>", Pages.ContentType, Office_PROFILE_CONTENT_TYPE);
query.ViewFields = string.Format(@"<FieldRef Name=""{0}"" /><FieldRef Name=""{1}"" /><FieldRef Name=""{2}"" /><FieldRef Name=""{3}"" />", Pages.ContentType, Pages.Title, Pages.NameInt, Pages.GeneralManagerInt);
query.ViewAttributes = @"Scope=""Recursive""";
query.RowLimit = 0;
SPListItemCollection items = pagesLib.GetItems(query);
foreach (SPListItem item in items)
{
string fileName = item[Pages.Name].ToString();
if (users.ContainsKey(fileName))
{
string mgr = string.Empty;
if (item[Pages.GeneralManager] != null)
{
mgr = new SPFieldUserValue(web, item[Pages.GeneralManager].ToString()).User.LoginName;
}
if (!mgr.EndsWith(users[fileName]))
{
SPFile file = item.File;
if (file.CheckOutType == SPFile.SPCheckOutType.None)
file.CheckOut();
SPClaim userClaim = cpm.ConvertIdentifierToClaim(users[fileName], SPIdentifierTypes.WindowsSamAccountName);
SPUser newMgr = rootWeb.EnsureUser(userClaim.ToEncodedString());
item[Pages.GeneralManager] = new SPFieldUserValue(web, newMgr.ID, newMgr.Name);
item.Update();
file.CheckIn("Automatically checked-in by SharePoint Synchronization Timer Job");
file.Publish("Automatically published by SharePoint Synchronization Timer Job");
}
}
}
}
catch (Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
}
}
private List<OfficeLocation> GetOfficeManagers(SPSite site)
{
List<OfficeLocation> Offices = new List<OfficeLocation>();
try
{
SPServiceContext serverContext = SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(serverContext);
IEnumerator userProfiles = profileManager.GetEnumerator();
while (userProfiles.MoveNext())
{
UserProfile userProfile = (UserProfile)userProfiles.Current;
//Check for department name, it must be "Office Operations"
if (userProfile[USER_PROFILE_FIELD_DEPT] != null && userProfile[USER_PROFILE_FIELD_DEPT].Value != null && userProfile[USER_PROFILE_FIELD_DEPT].Value.ToString().Equals(USER_PROFILE_DEPT_REST_OP))
{
//Check for Office location, it must not be null or empty
if (userProfile[USER_PROFILE_FIELD_OFFICE] != null && userProfile[USER_PROFILE_FIELD_OFFICE].Value != null)
{
string location = userProfile[USER_PROFILE_FIELD_OFFICE].Value.ToString();
OfficeLocation Office = FindOffice(Offices, location);
if (Office == null)
{
Office = new OfficeLocation();
Office.Location = location;
Office.PageName = string.Format("{0}.aspx", location.Replace("RC ", "C"));
Offices.Add(Office);
}
if (userProfile[USER_PROFILE_FIELD_TITLE] != null && userProfile[USER_PROFILE_FIELD_TITLE].Value != null)
{
string designation = userProfile[USER_PROFILE_FIELD_TITLE].Value.ToString();
switch(designation)
{
case Designations.General_Manager_In_Training:
Office.GeneralManager = userProfile.AccountName.ToLower();
break;
case Designations.ManagingPartner_In_Training:
Office.ManagingPartner = userProfile.AccountName.ToLower();
break;
case Designations.OperationsManager_In_Training:
Office.OperationsManager = userProfile.AccountName.ToLower();
break;
case Designations.ShiftManager:
Office.ShiftManagers.Add(userProfile.AccountName.ToLower());
break;
}
}
}
}
}
IEnumerator userProfiles2 = profileManager.GetEnumerator();
while (userProfiles2.MoveNext())
{
UserProfile userProfile = (UserProfile)userProfiles2.Current;
//Check for department name, it must be "Office Operations"
if (userProfile[USER_PROFILE_FIELD_DEPT] != null && userProfile[USER_PROFILE_FIELD_DEPT].Value != null && userProfile[USER_PROFILE_FIELD_DEPT].Value.ToString().Equals(USER_PROFILE_DEPT_REST_OP))
{
//Check for Office location, it must not be null or empty
if (userProfile[USER_PROFILE_FIELD_OFFICE] != null && userProfile[USER_PROFILE_FIELD_OFFICE].Value != null)
{
string location = userProfile[USER_PROFILE_FIELD_OFFICE].Value.ToString();
OfficeLocation Office = FindOffice(Offices, location);
if (Office == null)
{
Office = new OfficeLocation();
Office.Location = location;
Office.PageName = string.Format("{0}.aspx", location.Replace("RC ", "C"));
Offices.Add(Office);
}
if (userProfile[USER_PROFILE_FIELD_TITLE] != null && userProfile[USER_PROFILE_FIELD_TITLE].Value != null)
{
string designation = userProfile[USER_PROFILE_FIELD_TITLE].Value.ToString();
switch (designation)
{
case Designations.General_Manager:
Office.GeneralManager = userProfile.AccountName.ToLower();
break;
case Designations.ManagingPartner:
Office.ManagingPartner = userProfile.AccountName.ToLower();
break;
case Designations.OperationsManager:
Office.OperationsManager = userProfile.AccountName.ToLower();
break;
case Designations.ShiftManager_In_Training:
Office.ShiftManagers.Add(userProfile.AccountName.ToLower());
break;
}
}
}
}
}
}
catch (Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
}
return Offices;
}
private void SyncOfficeManagers(SPWeb web, List<OfficeLocation> Offices)
{
try
{
SPDocumentLibrary pagesLib = web.Lists[PAGES_LIBRARY] as SPDocumentLibrary;
SPClaimProviderManager cpm = SPClaimProviderManager.Local;
SPWeb rootWeb = web.Site.RootWeb;
SPClaim userClaim = null;
SPUser newMgr = null;
var query = new SPQuery();
query.Query = string.Format(@"<Where><Eq><FieldRef Name=""{0}"" /><Value Type=""Text"">{1}</Value></Eq></Where>", Pages.ContentType, Office_PROFILE_CONTENT_TYPE);
//query.ViewFields = string.Format(@"<FieldRef Name=""{0}"" /><FieldRef Name=""{1}"" /><FieldRef Name=""{2}"" /><FieldRef Name=""{3}"" />", Pages.ContentType, Pages.Title, Pages.NameInt, Pages.GeneralManagerInt);
query.ViewAttributes = @"Scope=""Recursive""";
query.RowLimit = 0;
SPListItemCollection items = pagesLib.GetItems(query);
foreach (SPListItem item in items)
{
string pageName = item[Pages.Name].ToString();
OfficeLocation Office = FindOfficeByPageName(Offices, pageName);
if (Office != null)
{
bool updateItem = false;
string mgr = string.Empty;
#region General Manager
if (item[Pages.GeneralManager] != null)
{
mgr = new SPFieldUserValue(web, item[Pages.GeneralManager].ToString()).User.LoginName;
}
if (string.IsNullOrEmpty(Office.GeneralManager) && !string.IsNullOrEmpty(mgr))
{
item[Pages.GeneralManager] = null;
updateItem = true;
}
else if (!mgr.ToLower().EndsWith(Office.GeneralManager))
{
userClaim = cpm.ConvertIdentifierToClaim(Office.GeneralManager, SPIdentifierTypes.WindowsSamAccountName);
newMgr = rootWeb.EnsureUser(userClaim.ToEncodedString());
item[Pages.GeneralManager] = new SPFieldUserValue(web, newMgr.ID, newMgr.Name);
updateItem = true;
}
#endregion
#region Managing Partner
mgr = string.Empty;
if (item[Pages.ManagingPartner] != null)
{
mgr = new SPFieldUserValue(web, item[Pages.ManagingPartner].ToString()).User.LoginName;
}
if (string.IsNullOrEmpty(Office.ManagingPartner) && !string.IsNullOrEmpty(mgr))
{
item[Pages.ManagingPartner] = null;
updateItem = true;
}
else if (!mgr.ToLower().EndsWith(Office.ManagingPartner))
{
userClaim = cpm.ConvertIdentifierToClaim(Office.ManagingPartner, SPIdentifierTypes.WindowsSamAccountName);
newMgr = rootWeb.EnsureUser(userClaim.ToEncodedString());
item[Pages.ManagingPartner] = new SPFieldUserValue(web, newMgr.ID, newMgr.Name);
updateItem = true;
}
#endregion
#region Operations Manager
mgr = string.Empty;
if (item[Pages.OperationsManager] != null)
{
mgr = new SPFieldUserValue(web, item[Pages.OperationsManager].ToString()).User.LoginName;
}
if (string.IsNullOrEmpty(Office.OperationsManager) && !string.IsNullOrEmpty(mgr))
{
item[Pages.OperationsManager] = null;
updateItem = true;
}
else if (!mgr.ToLower().EndsWith(Office.OperationsManager))
{
userClaim = cpm.ConvertIdentifierToClaim(Office.OperationsManager, SPIdentifierTypes.WindowsSamAccountName);
newMgr = rootWeb.EnsureUser(userClaim.ToEncodedString());
item[Pages.OperationsManager] = new SPFieldUserValue(web, newMgr.ID, newMgr.Name);
updateItem = true;
}
#endregion
#region Shift Managers
for (int count = 0; count < 6; count++)
{
string shiftMgr = string.Empty;
if (Office.ShiftManagers.Count > count)
shiftMgr = Office.ShiftManagers[count];
string shiftMgrFieldName = GetShiftManagerFieldName(count + 1);
if (!string.IsNullOrEmpty(shiftMgrFieldName))
{
mgr = string.Empty;
if (item[shiftMgrFieldName] != null)
{
mgr = new SPFieldUserValue(web, item[shiftMgrFieldName].ToString()).User.LoginName;
}
if (string.IsNullOrEmpty(shiftMgr) && !string.IsNullOrEmpty(mgr))
{
item[shiftMgrFieldName] = null;
updateItem = true;
}
else if (!mgr.ToLower().EndsWith(shiftMgr))
{
userClaim = cpm.ConvertIdentifierToClaim(shiftMgr, SPIdentifierTypes.WindowsSamAccountName);
newMgr = rootWeb.EnsureUser(userClaim.ToEncodedString());
item[shiftMgrFieldName] = new SPFieldUserValue(web, newMgr.ID, newMgr.Name);
updateItem = true;
}
}
}
#endregion
if (updateItem)
{
SPFile file = item.File;
if (file.CheckOutType == SPFile.SPCheckOutType.None)
file.CheckOut();
item.Update();
file.CheckIn("Automatically checked-in by SharePoint Synchronization Timer Job");
file.Publish("Automatically published by SharePoint Synchronization Timer Job");
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Medium, EventSeverity.Information), TraceSeverity.Medium, string.Format("Page {0} updated.", pageName), "");
}
}
}
}
catch (Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(1, new SPDiagnosticsCategory("SharePoint Synchronization Timer Job", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
}
}
private string GetShiftManagerFieldName(int count)
{
switch(count)
{
case 1:
return Pages.ShiftManager1;
case 2:
return Pages.ShiftManager2;
//snipped for brevity - goes to 6
}
return string.Empty;
}
private static OfficeLocation FindOffice(List<OfficeLocation> Offices, string location)
{
OfficeLocation Office = Offices.Find(
delegate(OfficeLocation r)
{
return r.Location.Equals(location);
}
);
return Office;
}
private static OfficeLocation FindOfficeByPageName(List<OfficeLocation> Offices, string pageName)
{
OfficeLocation Office = Offices.Find(
delegate(OfficeLocation r)
{
return r.PageName.Equals(pageName);
}
);
//Handle pages with name "C01.aspx"
if (Office == null)
{
if (pageName.IndexOf("0") != 1)
{
pageName = pageName.Insert(1, "0");
Office = Offices.Find(
delegate(OfficeLocation r)
{
return r.PageName.Equals(pageName);
}
);
}
}
//Handle pages with name "C1.aspx"
if (Office == null)
{
if (pageName.IndexOf("0") != 2)
{
pageName = pageName.Insert(1, "0");
Office = Offices.Find(
delegate(OfficeLocation r)
{
return r.PageName.Equals(pageName);
}
);
}
}
return Office;
}
#endregion
}
public class OfficeLocation
{
public OfficeLocation()
{
Location = string.Empty;
PageName = string.Empty;
GeneralManager = string.Empty;
ManagingPartner = string.Empty;
OperationsManager = string.Empty;
ShiftManagers = new StringCollection();
}
public string Location { get; set; }
public string PageName { get; set; }
public string GeneralManager { get; set; }
public string ManagingPartner { get; set; }
public string OperationsManager { get; set; }
public StringCollection ShiftManagers { get; set; }
}
public class TimerJobMetaData : SPPersistedObject
{
[Persisted]
public string SiteUrl;
public TimerJobMetaData() { }
public TimerJobMetaData(string name, SPPersistedObject parent, Guid Id)
: base(name, parent, Id)
{ }
}
}
//使用为简洁而剪裁的语句
命名空间RC.SharePoint.Portal.TimerJobs
{
公共类SyncOfficeLocationService:SPJobDefinition
{
#区域常数
public const string JOB_NAME=“世界办公室位置同步服务”;
public const string TIMER\u JOB\u META\u DATA=“TimerJobMetaData”;
private const string PAGES\u LIBRARY=“PAGES”;
private const string USER\u PROFILE\u FIELD\u OFFICE=“OFFICE”;
私有常量字符串用户\u配置文件\u字段\u TITLE=“TITLE”;
private const string USER\u PROFILE\u FIELD\u DEPT=“Department”;
private const string USER\u PROFILE\u DEPT\u REST\u OP=“Office Operations”;
私有常量字符串办公室\u配置文件\u内容\u TYPE=“办公室配置文件”;
私人建筑字符串办公室\u站点\u NAME=“rest”;
私有结构指定
{
公共const字符串General\u Manager=“General Manager”;
公共建筑字符串总经理培训=“总经理培训”;
public const string managengpartner=“管理合伙人”;
public const string management Partner_In_Training=“management Partner In Training”;
public const string operationmanager=“Operations Manager”;
public const string operationmanager_In_Training=“operation Manager In Training”;
public const string ShiftManager=“Shift Manager”;
public const string ShiftManager_In_Training=“Shift Manager In Training”;
}
私有结构页
{
public const string Title=“Title”;
public const string ContentType=“ContentType”;
public const string Name=“Name”;
public const string NameInt=“FileLeafRef”;
public const string GeneralManager=“GeneralManager”;
public const string GeneralManagerInt=“RC\u RestProfile\u GeneralManager”;
public const string managengpartner=“管理合伙人”;
public const string managengpartnerint=“RC\u RestProfile\u managengpartner”;
public const string operationmanager=“Operations Manager”;
public const string operationmanagerint=“RC\u RestProfile\u operationmanager”;
public const string ShiftManager1=“班次管理器1”;
public const string ShiftManager1Int=“RC\u RestProfile\u ShiftManager1”;
public const string ShiftManager2=“班次管理器2”;
public const string ShiftManager2Int=“RC\u RestProfile\u ShiftManager2”;
//为空间而剪断
}
#端区
#区域构造函数
public SyncOfficeLocationService()
:base()
{
}
public SyncOfficeLocationService(字符串jobName、SPSService服务、SPSServer服务器、SPJobLockType targetType)
:base(作业名、服务、服务器、目标类型)
{
}
public SyncOfficeLocationService(字符串jobName,SPWebApplication webApplication)
:base(jobName、webApplication、null、SPJobLockType.ContentDatabase)
{
this.Title=jobName;
}
#端区
#区域方法
受保护的覆盖bool HasAdditionalUpdateAccess()
{
返回true;
}
公共覆盖无效执行(Guid targetInstanceId)
{
尝试
{
//从分层对象存储中读取设置
TimerJobMetaData设置=this.WebApplication.GetChild(计时器\作业\元数据);
使用(SPSite站点=新SPSite(settings.SiteUrl))
{
使用(SPWeb=site.OpenWeb())
{
SPDiagnosticsService.Local.WriteTrace(1,新的SPDiagnosticsCategory(“SharePoint同步计时器作业”,traceVerity.Medium,EventSeverity.Information),traceVerity.Medium,string.Format(“为SharePoint门户启动的计时器服务:{0}”,web.Url),”);
列表办公室=GetOfficeManager(现场);
SPDiagnosticsService.Local.WriteTrace(1,新的SPDiagnosticsCategory(“SharePoint同步计时器作业”、TraceServirity.Medium、EventSeverity.Information)、TraceServirity.Medium,“用户配置文件服务已成功解析”。+Offices.Count.ToString()+“已找到办公室”。,“”);
SyncOfficeManager(web.Webs[Office\u SITE\u NAME],Offices);
SPDiagnosticsService.Local.WriteTrace(1,新的SPDiagnosticsCategory(“SharePoint同步计时器作业”,traceVerity.Medium,EventSeverity.Information),traceVerity.Medium,string.Format(“SharePoint门户的计时器服务完成:{0}”,web.Url),”);
}
}
}
捕获(例外情况除外)
{
SPDiagnosticsService.Local.WriteTrace(1,新的SPDiagnosticsCategory(“SharePoint同步计时器作业”,traceVerity.Unexpected,EventSeverity.Error),traceVerity.Unexpected,ex.Message,ex.StackTrace);