lio*_*ori 2 .net c# plugins dynamics-crm dynamics-crm-2013
你好,我需要创建一个插件来在创建后立即更新新用户 - 时区,但我不知道如何在连接的用户设置中更新时区 - 如果我总是想要,我必须更改哪些属性(如 TimeZoneCode)将时区更改为我的国家-巴黎?,以及如何更新?**我的步骤:
ColumnSet 属性 = 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?
                    }
                }
            }
Run Code Online (Sandbox Code Playgroud)
非常感谢 :) li
获取TimeZoneIndex值并使用相应的值更新用户设置 TimeZoneCode。
var userSettings = new UserSettings()
{
    Id = userSettingsId,
    TimeZoneCode = 105 //(GMT+01:00) Brussels, Copenhagen, Madrid, Paris
}; 
organizationService.Update(userSettings);
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           1413 次  |  
        
|   最近记录:  |