c# - Dynamics crm 2013 c# 插件更新/更改其用户设置中的系统用户时区

标签 c# .net plugins dynamics-crm dynamics-crm-2013

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

  1. 我在系统用户实体上创建一个操作后插件 - 创建
  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值并更新用户设置 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/

相关文章:

c# - 为什么\r\n 添加到我的字符串中?

c# - Dapper:映射层次结构和单一不同的属性

c# - P/调用 const char 指针和 int 引用

c# - 临时数据包装器

javascript - Tinymce fontsizeselect 未使用 "theme_advanced_font_sizes"或 "font_size_style_values"值

javascript - jQuery 插件来处理翻译?

java - 监听 Nexus 插件 API 中的下载事件

c# - == 运算符如何与 System.Type 一起使用

c# - 使用StreamReader复制图像时损坏

c# - ASP.NET Web API 2 -> Windows 身份验证 -> 在 Azure 上模拟 Windows 用户