你好, 我需要创建一个插件来立即更新新用户时区 创建后,但我不知道如何更新连接的用户设置中的时区 - 我必须更改哪些属性(如 TimeZoneCode) 如果我总是想更改为我的国家巴黎的时区? , 以及如何更新? **我的步骤:
- 我在系统用户实体上创建一个操作后插件 - 创建
- 获取新系统用户的id//systemUser.systemuserid;
- 根据系统用户id检索其连接的userSettings
ColumnSet 属性 = new ColumnSet(new string[] { "timezonecode"}); var 用户设置结果 = _service.Retrieve(userSettings.LogicalName, newSystemUserId, 属性);
**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?
}
}
}
非常感谢:) 李
最佳答案
获取TimeZoneIndex值并更新用户设置 TimeZoneCode与相应的值。
var userSettings = new UserSettings()
{
Id = userSettingsId,
TimeZoneCode = 105 //(GMT+01:00) Brussels, Copenhagen, Madrid, Paris
};
organizationService.Update(userSettings);
关于c# - Dynamics crm 2013 c# 插件更新/更改其用户设置中的系统用户时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39752141/