dynamics crm 2013 c# 插件 update/change 用户设置中的系统用户时区

dynamics crm 2013 c# plugin update/change system user timezone in it's usersettings

您好, 我需要创建一个插件来立即更新新用户时区 创建后,但我不知道如何更新连接的用户设置中的时区 - 我必须更改哪些属性(如 TimeZoneCode) 如果我总是想将时区更改为我的国家 - 巴黎? , 以及如何更新? **我的步数:

  1. 我在系统用户实体上创建了一个 post 操作插件 - 创建
  2. 获取新系统用户的id // systemUser.systemuserid;
  3. 根据系统用户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 value and update the user settings TimeZoneCode

var userSettings = new UserSettings()
{
    Id = userSettingsId,
    TimeZoneCode = 105 //(GMT+01:00) Brussels, Copenhagen, Madrid, Paris
}; 
organizationService.Update(userSettings);