你好, 我需要创建一个插件来立即更新新用户-timezone 它创建后,但我不知道如何更新连接的用户设置中的时区 - 哪些属性(如TimeZoneCode)我必须更改 如果我一直想换到我的国家的时区 - 巴黎? , 以及如何更新? **我的步骤:
ColumnSet attributes = new ColumnSet(new string [] {“timezonecode”}); var userSettingsResult = _service.Retrieve(userSettings.LogicalName,newSystemUserId,attributes);
** 4。但我不知道我需要在用户设备中更新哪些属性以更改实际时区
例如:从伦敦到我的国家巴黎(我总是换到巴黎)
我只需要更改TimeZoneCode,还是需要更改TimeZoneBias等更多属性? 如果是这样,哪些属性以及如何?**
我的代码
public void updateNewUserTimeZone(MOHServiceContext myContext, Entity entity, ITracingService trc, IOrganizationService service, IPluginExecutionContext executionContext)
{
if (entity != null)
{
// post operation - the new system user
var systemUser = entity.ToEntity<systemuser>();
var newSystemUserId=systemUser.systemuserid; //get the id of the new systemuser
if (newSystemUserId)
{
//find the userSettingObject that has the same id as the system user now created
--var userSettingsResult = (from userSettingObject in myContext.userSettingsSet
--where userSettingObject.systemuserid == newSystemUserId
--select userSettingObject).FirstOrDefault();
// second way to retrive user setting
//the fields we wandt to retrive from usersettings
ColumnSet attributes = new ColumnSet(new string[] { "timezonecode" });
// Retrieve the usersettings and its timezonecode attribute.
var userSettingsResult = _service.Retrieve(userSettings.LogicalName, newSystemUserId, attributes);
//if we find serSettingObject that has the same id as the system user now created
if (userSettingsResult != null)
{
//how to update the time zone in userSettingsResult we found to paris?
}
}
}
非常感谢:) 利
答案 0 :(得分:4)
获取TimeZoneIndex值并使用相应的值更新用户设置TimeZoneCode。
var userSettings = new UserSettings()
{
Id = userSettingsId,
TimeZoneCode = 105 //(GMT+01:00) Brussels, Copenhagen, Madrid, Paris
};
organizationService.Update(userSettings);