Announcements
private static readonly Dictionary _crmClientCache = new Dictionary(); private static readonly Object _orgServiceLock = new Object(); private static readonly string _authType = "OAuth"; private static readonly string _requireNewInstance = "true"; private static readonly string _appId = "51f81489-12ee-4a9e-aaae-a2591f45987d"; private static readonly string _reDirectURI = "app://58145B91-0C36-4500-8554-080854F2AC97"; public static CrmServiceClient GetCrmClient(string userName, string password, string url) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string ConnectionString = string.Format("AuthType={0};Username={1};Password={2};Url={3};AppId={4};RedirectUri={5};RequireNewInstance={6};", _authType, userName, password, url, _appId, _reDirectURI, _requireNewInstance); CrmServiceClient crmClient; lock (_orgServiceLock) { if (!_crmClientCache.ContainsKey(ConnectionString)) { crmClient = new CrmServiceClient(ConnectionString); _crmClientCache.Add(ConnectionString, crmClient); } } crmClient = _crmClientCache[ConnectionString]; if (crmClient.IsReady) { return crmClient; } throw new Exception(crmClient.LastCrmError); }
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156