protected static OrganizationService CreateOrganizationService(string portalName = null, bool allowDefaultFallback = false, string serviceName = null) { var portalContextElement = PortalCrmConfigurationManager.GetPortalContextElement(portalName, allowDefaultFallback); var contextName = !string.IsNullOrWhiteSpace(portalContextElement.ContextName) ? portalContextElement.ContextName : portalContextElement.Name; var connection = new CrmConnection(CrmConfigurationManager.GetConnectionStringNameFromContext(contextName)); return(CrmConfigurationManager.CreateService(connection, serviceName) as OrganizationService); }
private static string GetContextName(NameValueCollection config) { var str = config["contextName"]; if (!string.IsNullOrWhiteSpace(str)) { return(str); } var portalContextElement = PortalCrmConfigurationManager.GetPortalContextElement(config["portalName"], true); return(!string.IsNullOrWhiteSpace(portalContextElement.ContextName) ? portalContextElement.ContextName : portalContextElement.Name); }
protected override string GetSiteMapChildrenDataServiceUri(IEditableCrmEntityControl control, SiteMapNode startingNode) { var serviceBaseUri = string.IsNullOrEmpty(control.CmsServiceBaseUri) ? PortalCrmConfigurationManager.GetPortalContextElement(PortalName).CmsServiceBaseUri : control.CmsServiceBaseUri; var serviceUri = "{0}/GetSiteMapChildren?siteMapProvider='{1}'&startingNodeUrl='{2}'".FormatWith( serviceBaseUri.TrimEnd('/'), UrlEncode(startingNode.Provider.Name), UrlEncode(startingNode.Url)); return(AddWebsitePathToQuerystring(serviceUri)); }
/// <summary> /// Initializes custom settings. /// </summary> /// <param name="name"></param> /// <param name="config"></param> public virtual void Initialize(string name, NameValueCollection config) { var portalElement = PortalCrmConfigurationManager.GetPortalContextElement(name); _websiteSelector = portalElement.WebsiteSelector.CreateWebsiteSelector(portalElement.Name); var mergeOptionText = config["mergeOption"]; if (!string.IsNullOrWhiteSpace(mergeOptionText)) { ServiceContext.MergeOption = mergeOptionText.ToEnum <MergeOption>(); } AttributeMapUsername = config["attributeMapUsername"]; MemberEntityName = config["memberEntityName"]; }
/// <summary> /// Initializes custom settings. /// </summary> /// <param name="name"></param> /// <param name="config"></param> public virtual void Initialize(string name, NameValueCollection config) { ConfiguredWebsiteName = config["websiteName"] ?? ConfigurationManager.AppSettings["crm-site"] ?? name; if (string.IsNullOrEmpty(ConfiguredWebsiteName)) { // try get the name from the portal configuration element var portal = PortalCrmConfigurationManager.GetPortalContextElement(PortalName); ConfiguredWebsiteName = portal == null ? null : portal.Parameters["websiteName"] ?? portal.Name; } if (string.IsNullOrEmpty(ConfiguredWebsiteName)) { throw new ConfigurationErrorsException(@"Unable to get configured website name. An appSetting key ""crm-site"" must be specified with a valid website name."); } }
private Entity GetUser(OrganizationServiceContext context) { // retrieve the username attribute from the portal configuration var config = PortalCrmConfigurationManager.GetPortalContextElement(PortalName); var attributeMapUsername = config.Parameters["attributeMapUsername"] ?? "adx_identity_username"; var username = GetCurrentIdentity(); var findContact = context.RetrieveSingle("contact", new[] { "contactid" }, new[] { new Condition("statecode", ConditionOperator.Equal, 0), new Condition(attributeMapUsername, ConditionOperator.Equal, username) }); return(findContact); }
private static string GetContextName(string name, NameValueCollection config) { var contextName = config["contextName"]; if (!string.IsNullOrWhiteSpace(contextName)) { return(contextName); } var portalName = config["portalName"]; var portalContextElement = PortalCrmConfigurationManager.GetPortalContextElement(portalName, true); var configName = !string.IsNullOrWhiteSpace(portalContextElement.ContextName) ? portalContextElement.ContextName : portalContextElement.Name; return(configName ?? name); }
private static string GetWebsiteName() { var portal = PortalCrmConfigurationManager.GetPortalContextElement("Xrm"); return(portal == null ? null : portal.Parameters["websiteName"]); }
private static string GetCmsServiceBaseUri(string portalName = null) { var element = PortalCrmConfigurationManager.GetPortalContextElement(portalName); return(element.CmsServiceBaseUri); }