繁体   English   中英

Dynamics CRM 2013 C#插件的用户设置中的更新/更改系统用户时区

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

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

  1. 我在systemuser实体上创建了一个后期操作插件-创建
  2. 获取新的系统用户的ID // systemUser.systemuserid;
  3. 根据系统用户ID检索其连接的userSettings

ColumnSet属性= new ColumnSet(new string [] {“ timezonecode”}); var userSettingsResult = _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?

                    }
                }


            }

非常感谢:) li

获取TimeZoneIndex值,并使用相应的值更新用户设置TimeZoneCode

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM