internal override IEnumerable <XObject> ToBody(HttpContext context, ProductInfo product) { var assemblies = ToSection("Assemblies", new[] { "Name", "Version", "Location" }, () => product.Assemblies.Select(ToAssembly)); var iis = ToSection("IIS", new[] { "Name", "Value" }, () => ToIis(context)); var identity = ToSection("Identity", new[] { "Name", "Value" }, () => ToIdentity(context)); var claims = ToSection("Claims", new[] { "Type", "Value", "Value Type", "Issuer", "Original Issuer" }, () => ToClaims(context)); var errors = ToSection("Errors", new[] { "Timestamp", "Dropped", "Message" }, ToErrors); var connectionStringName = context.Request["connectionStringName"] ?? CrmConfigurationManager.GetConnectionStringNameFromContext(null, true) ?? "Xrm"; if (!string.IsNullOrWhiteSpace(connectionStringName)) { var connection = new CrmConnection(connectionStringName); using (var service = new OrganizationService(connection)) { var connectionSection = ToSection("Connection", new[] { "Name", "Value" }, () => ToConnection(connectionStringName, service)); var organization = ToSection("Organization", new[] { "Name", "Value" }, () => ToOrganization(service)); var solutions = ToSection("Solutions", new[] { "UniqueName", "Name", "Version", "Publisher" }, () => ToSolutions(service)); var portal = ToSection("Portal", new[] { "Name", "Value" }, ToPortal); return(assemblies.Concat(connectionSection).Concat(organization).Concat(solutions).Concat(portal).Concat(iis).Concat(identity).Concat(claims).Concat(errors)); } } var connectionStringNameSection = ToSection("Connection", new[] { "Name", "Value" }, () => new[] { ToRow("ConnectionStringName", connectionStringName) }); return(assemblies.Concat(connectionStringNameSection).Concat(iis).Concat(identity).Concat(claims).Concat(errors)); }
protected virtual string GetConnectionStringName(string name, NameValueCollection config) { var contextName = GetContextName(name, config); var connectionStringName = CrmConfigurationManager.GetConnectionStringNameFromContext(contextName); return(connectionStringName); }
private static string GetConnectionId(NameValueCollection config) { var contextName = GetContextName(config); var connectionStringName = CrmConfigurationManager.GetConnectionStringNameFromContext(contextName, true); var connection = new CrmConnection(connectionStringName); return(connection.GetConnectionId()); }
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 GetConnectionId(NameValueCollection config) { return(new CrmConnection(CrmConfigurationManager.GetConnectionStringNameFromContext(GetContextName(config), true)).GetConnectionId()); }
/// <summary> /// Initializes the provider with the property values specified in the ASP.NET application's configuration file. /// </summary> public override void Initialize(string name, NameValueCollection config) { if (_initialized) { return; } config.ThrowOnNull("config"); if (string.IsNullOrEmpty(name)) { name = GetType().FullName; } if (string.IsNullOrEmpty(config["description"])) { config["description"] = "Windows Live Id Membership Provider"; } base.Initialize(name, config); ApplicationName = config["applicationName"] ?? Utility.GetDefaultApplicationName(); var connectionStringName = config["connectionStringName"]; var contextName = config["contextName"]; if (!string.IsNullOrWhiteSpace(connectionStringName)) { ConnectionStringName = connectionStringName; } else if (!string.IsNullOrWhiteSpace(contextName)) { ConnectionStringName = CrmConfigurationManager.GetConnectionStringNameFromContext(contextName); } else if (CrmConfigurationManager.CreateConnectionStringSettings(connectionStringName) != null) { ConnectionStringName = name; } else { ConnectionStringName = CrmConfigurationManager.GetConnectionStringNameFromContext(name, true); } if (string.IsNullOrEmpty(ConnectionStringName)) { throw new ConfigurationErrorsException("One of 'connectionStringName' or 'contextName' must be specified on the '{0}' named '{1}'.".FormatWith(this, name)); } LiveIdConnectionStringName = config["liveIdConnectionStringName"]; if (string.IsNullOrEmpty(LiveIdConnectionStringName)) { throw new ConfigurationErrorsException("The 'liveIdConnectionStringName' must be specified on the '{0}' named '{1}'.".FormatWith(this, name)); } var parameters = LiveIdConnectionStringName.ToDictionaryFromConnectionStringName(); AppId = parameters.FirstNotNullOrEmpty("AppId", "Application Id", "ApplicationId"); // Remove all of the known configuration values. If there are any left over, they are unrecognized. config.Remove("name"); config.Remove("applicationName"); config.Remove("contextName"); config.Remove("connectionStringName"); config.Remove("liveIdConnectionStringName"); if (config.Count > 0) { string unrecognizedAttribute = config.GetKey(0); if (!string.IsNullOrEmpty(unrecognizedAttribute)) { throw new ConfigurationErrorsException("The '{0}' named '{1}' does not currently recognize or support the attribute '{2}'.".FormatWith(this, name, unrecognizedAttribute)); } } _initialized = true; }