Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

Salesforce(适配器)

Bitzsoft.Integrations.Crm.Salesforce 适配器参考——包装 ISalesforceClient 只读能力,适配 ICrmService。

Last updated

Salesforce 是适配器——它包装单体连接器 Bitzsoft.Integrations.Salesforce 暴露的 ISalesforceClient,把 SOQL / Account / Contact 读取能力适配到统一的 ICrmService 抽象。

包信息

NuGet 包Bitzsoft.Integrations.Crm.Salesforce
实现接口ICrmService
Provider IDsalesforce(复用单体连接器已注册的 providerId)
鉴权方式由单体连接器 Bitzsoft.Integrations.Salesforce 负责(OAuth 2.0 JWT Bearer for External Client App)
区域Global

配置字段

本适配器不重复注册鉴权与 endpoint,配置仅承载构造请求上下文所需的默认值:

字段类型必填默认值说明
DefaultTenantIdstringdefault缺少 IIntegrationContextAccessor 作用域时使用的默认租户
DefaultCredentialNamestring?指向单体 IIntegrationCredentialResolver 中的凭据条目
DefaultRegionstring?默认 region
DefaultEnvironmentstring?默认 environment(缺省由单体决定)
DefaultProfileIdstring?默认 profileId
QueryBatchSizeint单体默认值SOQL 查询默认批量大小(200–2000,单体约束)

配置 JSON 示例

{
"Crm": {
"Salesforce": {
"DefaultTenantId": "default",
"DefaultCredentialName": "salesforce-prod",
"QueryBatchSize": 500
}
}
}

DI 注册

// 1. 先注册 Salesforce 单体连接器(提供 ISalesforceClient、transport 与凭据)
services.AddBitzsoftSalesforce(/* ... */);
// 2. 再注册 CRM 适配器(从配置节,默认节名 Crm:Salesforce)
services.AddSalesforceCrm(configuration);
// 或用回调配置
services.AddSalesforceCrm(options =>
{
options.DefaultTenantId = "default";
options.DefaultCredentialName = "salesforce-prod";
options.QueryBatchSize = 500;
});

使用示例

// 读取能力可用
var contacts = await _crm.ListContactsAsync(new ListContactsRequest { Keyword = "acme.com" });
var contact = await _crm.GetContactAsync("003...");
// 以下方法会抛出 CrmException(只读边界):
// await _crm.CreateContactAsync(...)
// await _crm.UpdateContactAsync(...)
// await _crm.DeleteContactAsync(...)
// await _crm.CreateOpportunityAsync(...)
// await _crm.ListOpportunitiesAsync(...)
// await _crm.UpdateOpportunityStageAsync(...)

依赖

说明
Bitzsoft.Integrations.Crm客户关系管理服务抽象层
Bitzsoft.Integrations.SalesforceSalesforce 单体连接器(提供 ISalesforceClient

已知限制

  • 只读:Contact 写入(Create / Update / Delete)与全部 Opportunity(商机)方法抛出 CrmException
  • 鉴权、endpoint profile、token 刷新均由单体连接器管理,本适配器不参与。
  • ICrmService.PageSize 会被钳制到 SOQL 批量大小区间(200–2000)。

100%

滚轮或按钮缩放 · 放大后拖动画面 · 双击切换 100% / 200%