Skip to content

Commit 39138dc

Browse files
[TASKSCLOUD-445] - Deployed new 20.11 version.
1 parent dcac52b commit 39138dc

File tree

14 files changed

+314
-22
lines changed

14 files changed

+314
-22
lines changed

Aspose.Tasks.Cloud.Sdk.Tests/Assignment/TestAssignments.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public async Task TestEditAssignmentWithTimephasedDataAndBaselines()
281281
Assert.AreEqual("PT4H0M0S", td.Value.ToString());
282282
Assert.AreEqual(assignment.TimephasedData[0].TimephasedDataType, td.TimephasedDataType);
283283

284-
Assert.AreEqual(assignment.Cost, assignmentAfterUpdate.Cost);
284+
Assert.AreNotEqual(assignment.Cost, assignmentAfterUpdate.Cost, "Calculated fields must be overwritten");
285285
Assert.AreEqual(assignment.Start, assignmentAfterUpdate.Start);
286286
Assert.AreEqual(assignment.Finish, assignmentAfterUpdate.Finish);
287287
Assert.AreEqual(assignment.Work, assignmentAfterUpdate.Work);

Aspose.Tasks.Cloud.Sdk.Tests/Base/BaseTestContext.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected BaseTestContext()
5858
throw new FileNotFoundException("servercreds.json doesn't contain AppKey and AppSid");
5959
}
6060

61-
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
61+
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid, AuthUrl = this.keys.AuthUrl };
6262
this.TasksApi = new TasksApi(configuration);
6363
clearingRequests = new List<DeleteRequest>();
6464
}
@@ -152,6 +152,8 @@ private class Keys
152152
public string AppSid { get; set; }
153153

154154
public string AppKey { get; set; }
155+
156+
public string AuthUrl { get; set; }
155157
}
156158
}
157159
}

Aspose.Tasks.Cloud.Sdk.Tests/Tasks/TestTasks.cs

+49-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
// --------------------------------------------------------------------------------------------------------------------
1+
// --------------------------------------------------------------------------------------------------------------------
32
// <copyright company="Aspose" file="TestTasks.cs">
43
// Copyright (c) 2018 Aspose.Tasks for Cloud
54
// </copyright>
@@ -29,6 +28,7 @@
2928
using Aspose.Tasks.Cloud.Sdk.Tests.Base;
3029
using NUnit.Framework;
3130
using System;
31+
using System.Collections.Generic;
3232
using System.Linq;
3333
using System.Net;
3434
using Task = System.Threading.Tasks.Task;
@@ -141,6 +141,46 @@ public async Task TestAddTask()
141141
Assert.IsNotNull(tasksResponse.Task);
142142
}
143143

144+
[Test]
145+
public async Task TestAddTasks()
146+
{
147+
var remoteName = await UploadFileToStorageAsync("Home move plan.mpp");
148+
var firstTask = new TaskCreationRequest
149+
{
150+
TaskName = "SomeFirstTaskName"
151+
};
152+
var secondTask = new TaskCreationRequest
153+
{
154+
TaskName = "SomeSecondTaskNameWithParent",
155+
ParentTaskUid = 2
156+
};
157+
var request = new PostTasksRequest
158+
{
159+
Name = remoteName,
160+
Folder = this.DataFolder,
161+
Requests = new List<TaskCreationRequest> { firstTask, secondTask }
162+
};
163+
var postResponse = await TasksApi.PostTasksAsync(request);
164+
165+
Assert.AreEqual((int)HttpStatusCode.Created, postResponse.Code);
166+
Assert.IsNotNull(postResponse.Tasks);
167+
Assert.AreEqual(request.Requests.Count, postResponse.Tasks.TaskItem.Count);
168+
169+
var newSubtaskUid = postResponse.Tasks.TaskItem
170+
.Single(t => t.Name == secondTask.TaskName)
171+
.Uid;
172+
var parentTaskResponse = await TasksApi.GetTaskAsync(new GetTaskRequest
173+
{
174+
TaskUid = secondTask.ParentTaskUid,
175+
Name = remoteName,
176+
Folder = this.DataFolder
177+
});
178+
179+
Assert.AreEqual((int)HttpStatusCode.OK, parentTaskResponse.Code);
180+
Assert.IsNotNull(parentTaskResponse.Task);
181+
Assert.Contains(newSubtaskUid, parentTaskResponse.Task.SubtasksUids);
182+
}
183+
144184
[Test]
145185
public async Task TestEditTask()
146186
{
@@ -272,14 +312,14 @@ public async Task TestMoveTaskToSiblingNull()
272312
var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp");
273313

274314
var response = await TasksApi.PutMoveTaskToSiblingAsync(new PutMoveTaskToSiblingRequest
275-
{
276-
Name = remoteName,
277-
Folder = this.DataFolder,
278-
TaskUid = 99999,
279-
BeforeTaskUid = -1
280-
});
315+
{
316+
Name = remoteName,
317+
Folder = this.DataFolder,
318+
TaskUid = 99999,
319+
BeforeTaskUid = -1
320+
});
281321

282322
Assert.IsNull(response);
283323
}
284324
}
285-
}
325+
}

Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public string ApiBaseUrl
5151
}
5252
}
5353

54+
55+
/// <summary>
56+
/// Aspose Cloud Auth URL.
57+
/// </summary>
58+
public string AuthUrl { get; set; }
59+
5460
/// <summary>
5561
/// Gets or sets the app key.
5662
/// </summary>

Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs

+54
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,60 @@ public TaskItemResponse PostTask(PostTaskRequest request)
25122512
}
25132513
}
25142514

2515+
/// <summary>
2516+
/// Add a new tasks to a project.
2517+
/// </summary>
2518+
/// <param name="request">Request. <see cref="PostTasksRequest" /></param>
2519+
/// <returns><see cref="TaskItemsResponse"/></returns>
2520+
public TaskItemsResponse PostTasks(PostTasksRequest request)
2521+
{
2522+
// verify the required parameter 'name' is set
2523+
if (request.Name == null)
2524+
{
2525+
throw new ApiException("Missing required parameter 'name' when calling PostTasks",
2526+
StatusCodes.ErrorInvalidInputData);
2527+
}
2528+
// verify the required parameter 'requests' is set
2529+
if (request.Requests == null)
2530+
{
2531+
throw new ApiException("Missing required parameter 'requests' when calling PostTasks",
2532+
StatusCodes.ErrorInvalidInputData);
2533+
}
2534+
2535+
// create path and map variables
2536+
var resourcePath = UnescapePath(this.configuration.GetApiRootUrl() + "/tasks/{name}/tasks/batch");
2537+
resourcePath = UrlHelper.AddPathParameter(resourcePath, "name", request.Name);
2538+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "fileName", request.FileName);
2539+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.Storage);
2540+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "folder", request.Folder);
2541+
var postBody = SerializationHelper.Serialize(request.Requests); // http body (model) parameter
2542+
2543+
try
2544+
{
2545+
var response = this.apiInvoker.InvokeApi(
2546+
resourcePath,
2547+
"POST",
2548+
postBody,
2549+
null,
2550+
null);
2551+
if (response != null)
2552+
{
2553+
return (TaskItemsResponse)SerializationHelper.Deserialize(response, typeof(TaskItemsResponse));
2554+
}
2555+
2556+
return null;
2557+
}
2558+
catch (ApiException ex)
2559+
{
2560+
if (ex.HttpStatusCode == HttpStatusCode.NotFound)
2561+
{
2562+
return null;
2563+
}
2564+
2565+
throw;
2566+
}
2567+
}
2568+
25152569
/// <summary>
25162570
/// Get a project document in the specified format and with the specified save options.
25172571
/// </summary>

Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs

+54
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,60 @@ public async Task<TaskItemResponse> PostTaskAsync(PostTaskRequest request)
24512451
}
24522452
}
24532453

2454+
/// <summary>
2455+
/// Add a new tasks to a project.
2456+
/// </summary>
2457+
/// <param name="request">Request. <see cref="PostTasksRequest" /></param>
2458+
/// <returns><see cref="TaskItemsResponse"/></returns>
2459+
public async Task<TaskItemsResponse> PostTasksAsync(PostTasksRequest request)
2460+
{
2461+
// verify the required parameter 'name' is set
2462+
if (request.Name == null)
2463+
{
2464+
throw new ApiException("Missing required parameter 'name' when calling PostTasks",
2465+
StatusCodes.ErrorInvalidInputData);
2466+
}
2467+
// verify the required parameter 'requests' is set
2468+
if (request.Requests == null)
2469+
{
2470+
throw new ApiException("Missing required parameter 'requests' when calling PostTasks",
2471+
StatusCodes.ErrorInvalidInputData);
2472+
}
2473+
2474+
// create path and map variables
2475+
var resourcePath = UnescapePath(this.configuration.GetApiRootUrl() + "/tasks/{name}/tasks/batch");
2476+
resourcePath = UrlHelper.AddPathParameter(resourcePath, "name", request.Name);
2477+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "fileName", request.FileName);
2478+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.Storage);
2479+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "folder", request.Folder);
2480+
var postBody = SerializationHelper.Serialize(request.Requests); // http body (model) parameter
2481+
2482+
try
2483+
{
2484+
var response = await this.apiInvoker.InvokeApiAsync(
2485+
resourcePath,
2486+
"POST",
2487+
postBody,
2488+
null,
2489+
null);
2490+
if (response != null)
2491+
{
2492+
return (TaskItemsResponse)SerializationHelper.Deserialize(response, typeof(TaskItemsResponse));
2493+
}
2494+
2495+
return null;
2496+
}
2497+
catch (ApiException ex)
2498+
{
2499+
if (ex.HttpStatusCode == HttpStatusCode.NotFound)
2500+
{
2501+
return null;
2502+
}
2503+
2504+
throw;
2505+
}
2506+
}
2507+
24542508
/// <summary>
24552509
/// Get a project document in the specified format and with the specified save options.
24562510
/// </summary>

Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
<Compile Include="Model\Requests\PostTaskLinkRequest.cs" />
232232
<Compile Include="Model\Requests\PostTaskRecurringInfoRequest.cs" />
233233
<Compile Include="Model\Requests\PostTaskRequest.cs" />
234+
<Compile Include="Model\Requests\PostTasksRequest.cs" />
234235
<Compile Include="Model\Requests\PutAssignmentRequest.cs" />
235236
<Compile Include="Model\Requests\PutCalendarExceptionRequest.cs" />
236237
<Compile Include="Model\Requests\PutCalendarRequest.cs" />
@@ -264,6 +265,7 @@
264265
<Compile Include="Model\RollupType.cs" />
265266
<Compile Include="Model\Task.cs" />
266267
<Compile Include="Model\TaskBaseline.cs" />
268+
<Compile Include="Model\TaskCreationRequest.cs" />
267269
<Compile Include="Model\TaskItem.cs" />
268270
<Compile Include="Model\TaskItemResponse.cs" />
269271
<Compile Include="Model\TaskItems.cs" />

Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.nuspec

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>Aspose.Tasks-Cloud</id>
5-
<version>20.8</version>
5+
<version>20.11</version>
66
<title>Aspose.Tasks Cloud SDK for .NET</title>
77
<summary>Aspose.Tasks Cloud SDK allows developer to manipulate or convert Microsoft Project documents hosted on a cloud platform from .NET applications</summary>
88
<authors>Aspose</authors>
@@ -14,10 +14,9 @@
1414
<description>New generation of Aspose Cloud SDK that allows to manipulate or convert Microsoft Project documents hosted on a cloud platform from .NET applications. It allows you to work with all aspects of a Project document including conversion. The API offers a wide range of Microsoft Project export options. The Aspose.Tasks Cloud API allows developers to convert Project documents to various formats including XML, HTML, BMP, PNG, PDF, and XSLX.
1515
</description>
1616
<releaseNotes>
17-
* Add an ability to specify the non-default path for Project Server's PWA URL.
18-
* Add an ability to modify timephasedData collection in assignments.
17+
* Add an ability to create multiple tasks in single api call.
1918

20-
The complete list of changes can be found at https://docs.aspose.cloud/display/taskscloud/Aspose.Tasks+Cloud+20.8+Release+Notes
19+
The complete list of changes can be found at https://github.com/aspose-tasks/Aspose.Tasks-Documentation/blob/master/cloud/release-notes/release-notes-2020/aspose-tasks-cloud-20-11-release-notes/_index.md
2120
</releaseNotes>
2221
<copyright>Aspose 2002-2020. All Rights Reserved.</copyright>
2322
<tags>MPP Primavera Microsoft Project Server Online P6XML PrimaveraXML XER MPX</tags>

Aspose.Tasks.Cloud.Sdk/Internal/RequestHandlers/OAuthRequestHandler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public async Task ProcessResponseAsync(HttpWebResponse response, Stream resultSt
123123

124124
private void RequestToken()
125125
{
126-
var requestUrl = this.configuration.ApiBaseUrl + "/connect/token";
126+
var requestUrl = this.configuration.AuthUrl ?? (this.configuration.ApiBaseUrl + "/connect/token");
127127

128128
var postData = "grant_type=client_credentials";
129129
postData += "&client_id=" + this.configuration.AppSid;
@@ -143,7 +143,7 @@ private void RequestToken()
143143

144144
private async Task RequestTokenAsync()
145145
{
146-
var requestUrl = this.configuration.ApiBaseUrl + "/connect/token";
146+
var requestUrl = this.configuration.AuthUrl ?? (this.configuration.ApiBaseUrl + "/connect/token");
147147

148148
var postData = "grant_type=client_credentials";
149149
postData += "&client_id=" + this.configuration.AppSid;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose" file="PostTasksRequest.cs">
3+
// Copyright (c) 2020 Aspose.Tasks Cloud
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
using System.Collections.Generic;
27+
28+
namespace Aspose.Tasks.Cloud.Sdk.Model.Requests
29+
{
30+
31+
/// <summary>
32+
/// Request model for <see cref="TasksApi.PostTasks" /> operation.
33+
/// </summary>
34+
public class PostTasksRequest
35+
{
36+
/// <summary>
37+
/// Initializes a new instance of the <see cref="PostTasksRequest"/> class.
38+
/// </summary>
39+
public PostTasksRequest()
40+
{
41+
}
42+
43+
44+
/// <summary>
45+
/// The name of the file.
46+
/// </summary>
47+
public string Name { get; set; }
48+
49+
/// <summary>
50+
/// Requests to create tasks.
51+
/// </summary>
52+
/// <returns></returns>
53+
public List<TaskCreationRequest> Requests { get; set; }
54+
55+
/// <summary>
56+
/// The name of the project document to save changes to.
57+
/// If this parameter is omitted then the changes will be saved to the source project document.
58+
/// </summary>
59+
public string FileName { get; set; }
60+
61+
/// <summary>
62+
/// The document storage.
63+
/// </summary>
64+
public string Storage { get; set; }
65+
66+
/// <summary>
67+
/// The document folder.
68+
/// </summary>
69+
public string Folder { get; set; }
70+
}
71+
}

0 commit comments

Comments
 (0)