Bitzsoft.Integrations.ProjectManagement.Asana 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bitzsoft.Integrations.ProjectManagement.Asana --version 1.0.3
                    
NuGet\Install-Package Bitzsoft.Integrations.ProjectManagement.Asana -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.ProjectManagement.Asana" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.ProjectManagement.Asana" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.ProjectManagement.Asana" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.ProjectManagement.Asana --version 1.0.3
                    
#r "nuget: Bitzsoft.Integrations.ProjectManagement.Asana, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.ProjectManagement.Asana@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.ProjectManagement.Asana&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.ProjectManagement.Asana&version=1.0.3
                    
Install as a Cake Tool

Bitzsoft.Integrations.ProjectManagement.Asana

Asana REST API v1.0 项目与任务协同连接器实现。遵循项目管理通用抽象规范,实现通用 IProjectManagementService 接口。

功能特性

  • 通用契约对齐:完整实现 IProjectManagementService 抽象规范,支持项目创建与列表查询、任务创建、详情获取、属性更新、任务完成与条件检索。
  • PAT 访问令牌鉴权:采用 Asana 官方推荐的 Personal Access Token 进行 Bearer 认证,静态凭据无需动态握手刷新。
  • 工作空间与项目映射:将 Asana 工作空间(Workspaces)与项目(Projects)同构映射至标准项目模型(PmProject)。
  • 任务状态与优先级映射:原生支持任务的流转完成(completed = true)以及截止日期、指派人、优先级等元数据读写。
  • 工业级弹性韧性:内置 Polly 标准韧性管道(429 Too Many Requests / 503 Service Unavailable 指数退避重试与熔断保护)及出站审计日志(RequestLogging)。

安装

dotnet add package Bitzsoft.Integrations.ProjectManagement.Asana
<PackageReference Include="Bitzsoft.Integrations.ProjectManagement.Asana" Version="1.0.0" />

配置

appsettings.json 中配置 Asana 连接器参数:

{
  "ProjectManagement": {
    "Asana": {
      "PersonalAccessToken": "your-personal-access-token",
      "BaseUrl": "https://app.asana.com/api/1.0"
    }
  }
}

配置项说明

配置键 类型 默认值 说明
PersonalAccessToken string "" Asana 个人访问令牌(PAT),在 Asana 开发者控制台中生成。
BaseUrl string https://app.asana.com/api/1.0 Asana REST API 基地址。
HttpClientName string "ProjectManagementAsana" 底层业务 HttpClient 命名(支持高级 HttpClient 生命周期管理)。

注册服务

支持通过配置源绑定或委托方式进行依赖注入注册:

using Microsoft.Extensions.DependencyInjection;

// 方式 1:通过 IConfiguration 绑定注册(推荐,默认读取 ProjectManagement:Asana)
services.AddAsanaProjectManagement(configuration);

// 自定义配置节路径:
// services.AddAsanaProjectManagement(configuration, "Integrations:Asana");

// 方式 2:通过委托手动配置注册
services.AddAsanaProjectManagement(options =>
{
    options.PersonalAccessToken = "your-personal-access-token";
    options.BaseUrl = "https://app.asana.com/api/1.0";
});

使用示例(通用 IProjectManagementService)

以下代码演示如何在业务类中通过依赖注入使用通用的 IProjectManagementService 契约操作 Asana 敏捷任务:

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Bitzsoft.Integrations.ProjectManagement;
using Bitzsoft.Integrations.ProjectManagement.Dtos;
using TaskStatus = Bitzsoft.Integrations.ProjectManagement.Dtos.TaskStatus;

namespace YourNamespace;

public class AsanaTaskAppService
{
    private readonly IProjectManagementService _pmService;

    public AsanaTaskAppService(IProjectManagementService pmService)
    {
        _pmService = pmService;
    }

    public async Task<List<PmProject>> GetProjectsAsync(
        CancellationToken cancellationToken = default)
    {
        return await _pmService.ListProjectsAsync(cancellationToken);
    }

    public async Task<PmTask> CreateTaskAsync(
        string projectId,
        string taskName,
        string description,
        string? assigneeId = null,
        DateTimeOffset? dueDate = null,
        CancellationToken cancellationToken = default)
    {
        var request = new CreateTaskRequest
        {
            ProjectId = projectId,
            Name = taskName,
            Description = description,
            AssigneeId = assigneeId,
            DueDate = dueDate,
            Priority = TaskPriority.High
        };

        return await _pmService.CreateTaskAsync(request, cancellationToken);
    }

    public async Task<PmTask> GetTaskDetailAsync(
        string taskId,
        CancellationToken cancellationToken = default)
    {
        return await _pmService.GetTaskAsync(taskId, cancellationToken);
    }

    public async Task<PmTask> UpdateTaskAsync(
        string taskId,
        string newName,
        string? newDescription = null,
        CancellationToken cancellationToken = default)
    {
        var request = new UpdateTaskRequest
        {
            Name = newName,
            Description = newDescription
        };

        return await _pmService.UpdateTaskAsync(taskId, request, cancellationToken);
    }

    public async Task<PmResult> MarkTaskCompletedAsync(
        string taskId,
        CancellationToken cancellationToken = default)
    {
        return await _pmService.CompleteTaskAsync(taskId, cancellationToken);
    }

    public async Task<List<PmTask>> ListTasksAsync(
        string projectId,
        TaskStatus? status = null,
        CancellationToken cancellationToken = default)
    {
        var query = new TaskQuery
        {
            ProjectId = projectId,
            Status = status
        };

        return await _pmService.ListTasksAsync(query, cancellationToken);
    }
}

架构与鉴权原理

Asana 连接器内部委托 AsanaHttpClient 执行实际 HTTP 请求:

  • 认证注入:在每次 HTTP 请求发出前,通过 Authorization: Bearer {PersonalAccessToken} 标头传递身份凭证。
  • 对象模型转换:Asana REST API 返回的嵌套对象结构(形如 {"data": { "gid": "...", "name": "..." }})通过 AsanaModelMapper 统一转换为强类型的 PmProjectPmTask 契约模型。

异常处理与弹性策略

连接器集成了基于 Polly 的指数退避重试与熔断机制:

  • 限流防护:当触发 Asana API 频率限制(HTTP 429)或服务端瞬时故障(HTTP 503)时,系统自动按照指数递增等待时间进行重试。
  • 语义化异常:当请求参数不合法或资源不存在时,统一抛出清晰的业务异常或返回包含失败说明的 PmResult

依赖

说明
Bitzsoft.Integrations.ProjectManagement 项目管理服务统一抽象层
Bitzsoft.Integrations.Core 公共基座与供应商解析机制
Bitzsoft.Integrations.Compatibility 多目标框架兼容性工具集
Bitzsoft.Integrations.RequestLogging 出站请求审计与耗时追踪日志

相关包

供应商 / 组件 包名 说明
统一抽象 Bitzsoft.Integrations.ProjectManagement 统一接口定义、基础模型与结果包装
Asana Bitzsoft.Integrations.ProjectManagement.Asana Asana 任务与项目协作连接器
Azure DevOps Bitzsoft.Integrations.ProjectManagement.AzureDevOps 微软 Azure DevOps Boards 敏捷工单与 WIQL 检索
GitHub Bitzsoft.Integrations.ProjectManagement.GitHub GitHub Issues / PR / 里程碑与协同
GitLab Bitzsoft.Integrations.ProjectManagement.GitLab GitLab Issues / Notes / MR 敏捷协同
Gitee Bitzsoft.Integrations.ProjectManagement.Gitee 码云 Gitee Issues / 状态流转与工单协同
Jira Cloud Bitzsoft.Integrations.ProjectManagement.JiraCloud Atlassian Jira Cloud 任务生命周期与工作流流转
Jira Data Center Bitzsoft.Integrations.ProjectManagement.JiraDataCenter Jira Server / Data Center 私有部署与 JQL/Transitions
Monday Bitzsoft.Integrations.ProjectManagement.Monday monday.com 工作流与任务管理
ONES Bitzsoft.Integrations.ProjectManagement.Ones ONES 企业级敏捷研发管理
PingCode Bitzsoft.Integrations.ProjectManagement.PingCode PingCode 研发项目与工单协作
TAPD Bitzsoft.Integrations.ProjectManagement.Tapd 腾讯敏捷协作平台(需求/缺陷/任务三态工作流)
Teambition Bitzsoft.Integrations.ProjectManagement.Teambition 阿里巴巴 Teambition 协同连接器
Trello Bitzsoft.Integrations.ProjectManagement.Trello Trello 看板与卡片协同
阿里云效 Bitzsoft.Integrations.ProjectManagement.Yunxiao 阿里云效 Projex 空间协作与工作项/合并请求
聚合包 Bitzsoft.Integrations.ProjectManagement.All 一键聚合注册全部 14 家项目管理供应商
基础工具库 Bitzsoft.Integrations.Core 核心基座与供应商解析器 (IIntegrationProviderResolver<T>)
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.ProjectManagement.Asana:

Package Downloads
Bitzsoft.Integrations.ProjectManagement.All

项目管理服务聚合包 — 包含全部供应商实现(Asana / Teambition / Monday / Trello / ONES / PingCode / Yunxiao / GitHub / GitLab / Gitee / JiraCloud / JiraDataCenter / AzureDevOps / Tapd)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 0 9/23/2026
1.0.3 36 9/22/2026
1.0.2 131 8/29/2026
1.0.1 163 8/3/2026
1.0.0 147 8/2/2026