我试图通过对团队站点进行基本克隆,然后使用API复制和配置所有内容,来使用Microsoft Graph创建Microsoft团队站点的完整克隆。
我的首要任务是复制计划程序。我已经足够复制所有可用的计划,存储桶和任务。
我的问题是我不知道:
1)计划属于旧团队中的哪个选项卡/位置
2)如何将新计划放入新团队的上述标签/位置
public async Task<IEnumerable<Channel>> GetChannels(string accessToken, string teamId) {
string endpoint = $"{GraphRootUri}/teams/{teamId}/channels";
HttpResponseMessage response =
await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken); //old functionality of stolen method - ignore these two lines
string destinationTeamID = "Teamid";
//find all plans
endpoint = $"{GraphRootUri}/groups/{teamId}/planner/plans";
HttpResponseMessage responsePlans = await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken);
var plansIn = await ParseList<Planner>(responsePlans);
//the following two sections are just me seeing if I can find references to the plans
endpoint = $"{GraphRootUri}/teams/{teamId}/channels";
HttpResponseMessage responseChannels = await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken);
var inChannels = await responseChannels.Content.ReadAsStringAsync();
endpoint = $"{GraphRootUri}/teams/{teamId}/channels/mychannellocation/tabs";
HttpResponseMessage responseTabs = await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken);
var inTabs = await responseTabs.Content.ReadAsStringAsync();
//the following code copies the plans, buckets and tasks
foreach (Planner plan in plansIn) {
//first we get everything from the previous team plan
//grab tasks from the previous plan
endpoint = $"{GraphRootUri}/planner/plans/{plan.id}/tasks";
HttpResponseMessage responseTasks = await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken);
var inTasks = await ParseList<plannerTask>(responseTasks);
//get all buckets
endpoint = $"{GraphRootUri}/planner/plans/{plan.id}/buckets";
HttpResponseMessage responseBuckets = await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken);
var inBuckets = await ParseList<plannerBucket>(responseBuckets);
endpoint = $"{GraphRootUri}/planner/tasks";
//HttpResponseMessage responseTasks = await ServiceHelper.SendRequest(HttpMethod.Get, endpoint, accessToken);
// .content .Deserialize<plannerPlan>(); ;
//then we start to create everything in the new team
//create the plan in the new team
endpoint = $"{GraphRootUri}/planner/plans";
var sendPlanResponse =
await ServiceHelper.SendRequest(HttpMethod.Post, endpoint, accessToken, new plannerStub(plan, destinationTeamID));
var newPlanString = await sendPlanResponse.Content.ReadAsStringAsync();
//get the created plan
var newPlan = JsonConvert.DeserializeObject<Planner>(newPlanString);
//create buckets in the new team
Dictionary<string, string> bucketIdMap = new Dictionary<string, string>();
foreach (plannerBucket bucket in inBuckets) {
endpoint = $"{GraphRootUri}/planner/buckets";
var outBucket = new plannerBucketStub(bucket, newPlan.id);
var sendBucketResponse =
await ServiceHelper.SendRequest(HttpMethod.Post, endpoint, accessToken, new plannerStub(plan, destinationTeamID));
//get the created Bucket
var newBucket = JsonConvert.DeserializeObject<plannerBucket>(await sendPlanResponse.Content.ReadAsStringAsync());
bucketIdMap[bucket.id] = newBucket.id; //so we can send the tasks to our new bucket
}
//create tasks in the new team
foreach (plannerTask task in inTasks) {
endpoint = $"{GraphRootUri}/planner/tasks";
task.bucketId = bucketIdMap[task.bucketId];
task.planId = newPlan.id;
var sendBucketResponse = await ServiceHelper.SendRequest(HttpMethod.Post, endpoint, accessToken, task);
}
//put planner in appropriate tab - stuck at this point
endpoint = $"{GraphRootUri}/teams/{newPlan.id}/channels/";
}
}
到目前为止,我已经有了以前的代码,有谁知道我如何找出旧计划者的住处以及如何将新计划者放在新团队的同一位置?
目标团队现在是第一团队的副本。
我最好的猜测是使用计划程序的“上下文”,但是我找不到关于此的任何文档。有谁知道如何解决这个问题?编辑。我尝试使用上下文没有任何效果,我正式迷路了。
顺便说一句,如果有人找到了一个代码仓库,可以完全复制我无法找到的Microsoft Teams网站,请告诉我
对于任何给我提问有足够时间阅读本文的人,非常感谢您的帮助,在此,我们将不胜感激。
答案 0 :(得分:1)
在“团队和计划者”集成中,由团队维护到计划的链接,因此最好的选择是在那里查看是否可以在某个地方找到计划ID。不幸的是,我对那些API并不熟悉。
在Planner上,有两个可选属性可帮助导航回团队。首先是Plan上的上下文,其中包含“ displayNameSegments”属性。这应该与团队/渠道名称结构匹配。第二个是PlanDetails上的contextDetails,其中包含团队的URL。这些属性仅在beta中可用。不能保证一定要填写,并且可能不准确。
答案 1 :(得分:1)
查找标签位置
您可以通过分析/v1.0/teams/{group-id}/channels/{channel-id}/tabs
返回的结果来检测“频道”标签的位置。生成的teamsTab
array将包含相反顺序的标签(第一个标签为最后):
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('{{id}}')/channels('{id}')/tabs",
"value": [
{
"id": "{id}",
"displayName": "Tab #2",
"webUrl": "{url}",
"configuration": {
"entityId": null,
"contentUrl": null,
"removeUrl": null,
"websiteUrl": null,
"wikiTabId": 1,
"wikiDefaultTab": true,
"hasContent": false
}
},
{
"id": "{id}",
"displayName": "Tab #1",
"webUrl": "{url}",
"configuration": {
"entityId": "{plan-id}",
"contentUrl": "{url}",
"removeUrl": "{url}",
"websiteUrl": "{url}",
"dateAdded": "2019-02-04T17:38:11.079Z"
}
}
]
}
请记住,“对话”和“文件”实际上不是选项卡,并且其位置是固定的。因此,两者都不会出现在/tabs
结果中。您的代码应假定您的标签顺序实际上始于UI中的第3个标签位置。
设置标签页位置
要复制固定标签的顺序,您需要按照add the tabs的顺序进行操作。如果需要对现有选项卡进行重新排序,则需要首先remove them并按所需顺序重新创建它们。