CRM2011-某些用户的性能不佳

本文关键字:性能 用户 CRM2011- | 更新日期: 2023-09-27 18:26:20

我遇到CRM2011:的问题

当代码尝试使用IOOrganizationService通过linq查询从数据库中检索数据时,在Active Directory中创建的所有新用户的性能都不好。新用户与旧用户具有相同的权限。

这里有一些代码可以更好地理解。活动是一个ActivityPointer,我尝试将所有附件链接到它:(慢的部分是当我尝试使用ActivityAttachments属性的一个项目时)

foreach (var attachment in activity.ActivityAttachments)
                        {
                             //Do stuff
                        }

ActivityAttachments是使用数据上下文的linq查询的结果

        public IEnumerable<ActivityMimeAttachment> ActivityAttachments
    {
        get { return Datacontext.ActivityMimeAttachmentSet.Where(a => a.ObjectId != null && a.ObjectId.Id == Id).Select(a => new ActivityMimeAttachment(a)); }
    }

数据上下文是我的数据模型——为每个用户创建并存储为我的crmservice,即我的组织服务的实例

private static readonly ConcurrentDictionary<string, LeDataModel> _dataModels = new ConcurrentDictionary<string, LeDataModel>();
        protected LeDataModel Datacontext
        {
            get
            {
                LeDataModel _model;
                if (HttpContext.Current != null)
                {
                    var currentUser = HttpContext.Current.User.Identity.Name;
                    if (!_dataModels.TryGetValue(currentUser, out _model))
                    {
                        _model = new LeDataModel(CrmService) { MergeOption = MergeOption.NoTracking };
                        _dataModels.TryAdd(currentUser, _model);
                    }
                }
                else
                {
                    _model = AdminDataContext;
                }
                return _model;
            }
        }
protected OrganizationService CrmService
        {
        get
        {
            OrganizationService _service;
            if (HttpContext.Current != null)
            {
                var currentUser = HttpContext.Current.User.Identity.Name;
                if (!_services.TryGetValue(currentUser, out _service))
                {
                    _service = new OrganizationService("Crm");
                    _services.TryAdd(currentUser, _service);
                }
            }
            else
            {
                _service = AdminCrmService;
            }
            return _service;
        }
    }

我认为,问题不在于代码,因为它对一些用户来说运行良好,而对新用户来说运行缓慢。我比较了CRM和AD中的新/老用户,一切似乎都是一样的。有人知道CRM是如何进行身份验证的吗?你还有别的想法吗?

CRM2011-某些用户的性能不佳

从您关于新用户与老用户遭遇相同异常的评论中,我认为这是新用户性能问题的原因。

找出异常的原因并加以修复,您的性能就会得到改善。

阅读此http://blogs.msdn.com/b/ricom/archive/2006/09/25/771142.aspx

和这个

C#中的异常有多贵?