gpt4 book ai didi

c# - 我如何找出计划属于哪个选项卡/位置?

转载 作者:行者123 更新时间:2023-11-30 22:56:22 25 4
gpt4 key购买 nike

我正在尝试使用 Microsoft Graph 创建 Microsoft 团队网站的完整克隆,方法是对团队网站进行基本克隆,然后使用 API 复制和配置所有内容。

我的第一个任务是复制 Planner。我已经足够复制所有可用的计划、桶和任务了。

我的问题是我想不通:

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 网站,而我太笨了,找不到,请告诉我

对于给我的问题足够时间阅读到目前为止的任何人,非常感谢您的帮助,此时任何建议都将不胜感激。

最佳答案

查找标签位置

您可以通过解析 /v1.0/teams/{group-id}/channels/{channel-id}/tabs 返回的结果来检测 channel 标签的位置。结果 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 结果中。您的代码应该假定您的 Tab 键顺序实际上从 UI 中的第 3 个 Tab 键位置开始。

设置 Tab 位置

为了复制固定标签的顺序,您需要 add the tabs按照你想要的顺序。如果您需要重新排序现有选项卡,您需要先 remove them并按照您想要的顺序重新创建它们。

关于c# - 我如何找出计划属于哪个选项卡/位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54510392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com