Skip to content

Commit

Permalink
[TASKSCLOUD-445] - Deployed new 20.11 version.
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanAndreychikov committed Nov 4, 2020
1 parent dcac52b commit 39138dc
Show file tree
Hide file tree
Showing 14 changed files with 314 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Aspose.Tasks.Cloud.Sdk.Tests/Assignment/TestAssignments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public async Task TestEditAssignmentWithTimephasedDataAndBaselines()
Assert.AreEqual("PT4H0M0S", td.Value.ToString());
Assert.AreEqual(assignment.TimephasedData[0].TimephasedDataType, td.TimephasedDataType);

Assert.AreEqual(assignment.Cost, assignmentAfterUpdate.Cost);
Assert.AreNotEqual(assignment.Cost, assignmentAfterUpdate.Cost, "Calculated fields must be overwritten");
Assert.AreEqual(assignment.Start, assignmentAfterUpdate.Start);
Assert.AreEqual(assignment.Finish, assignmentAfterUpdate.Finish);
Assert.AreEqual(assignment.Work, assignmentAfterUpdate.Work);
Expand Down
4 changes: 3 additions & 1 deletion Aspose.Tasks.Cloud.Sdk.Tests/Base/BaseTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected BaseTestContext()
throw new FileNotFoundException("servercreds.json doesn't contain AppKey and AppSid");
}

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

public string AppKey { get; set; }

public string AuthUrl { get; set; }
}
}
}
58 changes: 49 additions & 9 deletions Aspose.Tasks.Cloud.Sdk.Tests/Tasks/TestTasks.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Aspose" file="TestTasks.cs">
// Copyright (c) 2018 Aspose.Tasks for Cloud
// </copyright>
Expand Down Expand Up @@ -29,6 +28,7 @@
using Aspose.Tasks.Cloud.Sdk.Tests.Base;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Task = System.Threading.Tasks.Task;
Expand Down Expand Up @@ -141,6 +141,46 @@ public async Task TestAddTask()
Assert.IsNotNull(tasksResponse.Task);
}

[Test]
public async Task TestAddTasks()
{
var remoteName = await UploadFileToStorageAsync("Home move plan.mpp");
var firstTask = new TaskCreationRequest
{
TaskName = "SomeFirstTaskName"
};
var secondTask = new TaskCreationRequest
{
TaskName = "SomeSecondTaskNameWithParent",
ParentTaskUid = 2
};
var request = new PostTasksRequest
{
Name = remoteName,
Folder = this.DataFolder,
Requests = new List<TaskCreationRequest> { firstTask, secondTask }
};
var postResponse = await TasksApi.PostTasksAsync(request);

Assert.AreEqual((int)HttpStatusCode.Created, postResponse.Code);
Assert.IsNotNull(postResponse.Tasks);
Assert.AreEqual(request.Requests.Count, postResponse.Tasks.TaskItem.Count);

var newSubtaskUid = postResponse.Tasks.TaskItem
.Single(t => t.Name == secondTask.TaskName)
.Uid;
var parentTaskResponse = await TasksApi.GetTaskAsync(new GetTaskRequest
{
TaskUid = secondTask.ParentTaskUid,
Name = remoteName,
Folder = this.DataFolder
});

Assert.AreEqual((int)HttpStatusCode.OK, parentTaskResponse.Code);
Assert.IsNotNull(parentTaskResponse.Task);
Assert.Contains(newSubtaskUid, parentTaskResponse.Task.SubtasksUids);
}

[Test]
public async Task TestEditTask()
{
Expand Down Expand Up @@ -272,14 +312,14 @@ public async Task TestMoveTaskToSiblingNull()
var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp");

var response = await TasksApi.PutMoveTaskToSiblingAsync(new PutMoveTaskToSiblingRequest
{
Name = remoteName,
Folder = this.DataFolder,
TaskUid = 99999,
BeforeTaskUid = -1
});
{
Name = remoteName,
Folder = this.DataFolder,
TaskUid = 99999,
BeforeTaskUid = -1
});

Assert.IsNull(response);
}
}
}
}
6 changes: 6 additions & 0 deletions Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public string ApiBaseUrl
}
}


/// <summary>
/// Aspose Cloud Auth URL.
/// </summary>
public string AuthUrl { get; set; }

/// <summary>
/// Gets or sets the app key.
/// </summary>
Expand Down
54 changes: 54 additions & 0 deletions Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,60 @@ public TaskItemResponse PostTask(PostTaskRequest request)
}
}

/// <summary>
/// Add a new tasks to a project.
/// </summary>
/// <param name="request">Request. <see cref="PostTasksRequest" /></param>
/// <returns><see cref="TaskItemsResponse"/></returns>
public TaskItemsResponse PostTasks(PostTasksRequest request)
{
// verify the required parameter 'name' is set
if (request.Name == null)
{
throw new ApiException("Missing required parameter 'name' when calling PostTasks",
StatusCodes.ErrorInvalidInputData);
}
// verify the required parameter 'requests' is set
if (request.Requests == null)
{
throw new ApiException("Missing required parameter 'requests' when calling PostTasks",
StatusCodes.ErrorInvalidInputData);
}

// create path and map variables
var resourcePath = UnescapePath(this.configuration.GetApiRootUrl() + "/tasks/{name}/tasks/batch");
resourcePath = UrlHelper.AddPathParameter(resourcePath, "name", request.Name);
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "fileName", request.FileName);
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.Storage);
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "folder", request.Folder);
var postBody = SerializationHelper.Serialize(request.Requests); // http body (model) parameter

try
{
var response = this.apiInvoker.InvokeApi(
resourcePath,
"POST",
postBody,
null,
null);
if (response != null)
{
return (TaskItemsResponse)SerializationHelper.Deserialize(response, typeof(TaskItemsResponse));
}

return null;
}
catch (ApiException ex)
{
if (ex.HttpStatusCode == HttpStatusCode.NotFound)
{
return null;
}

throw;
}
}

/// <summary>
/// Get a project document in the specified format and with the specified save options.
/// </summary>
Expand Down
54 changes: 54 additions & 0 deletions Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,60 @@ public async Task<TaskItemResponse> PostTaskAsync(PostTaskRequest request)
}
}

/// <summary>
/// Add a new tasks to a project.
/// </summary>
/// <param name="request">Request. <see cref="PostTasksRequest" /></param>
/// <returns><see cref="TaskItemsResponse"/></returns>
public async Task<TaskItemsResponse> PostTasksAsync(PostTasksRequest request)
{
// verify the required parameter 'name' is set
if (request.Name == null)
{
throw new ApiException("Missing required parameter 'name' when calling PostTasks",
StatusCodes.ErrorInvalidInputData);
}
// verify the required parameter 'requests' is set
if (request.Requests == null)
{
throw new ApiException("Missing required parameter 'requests' when calling PostTasks",
StatusCodes.ErrorInvalidInputData);
}

// create path and map variables
var resourcePath = UnescapePath(this.configuration.GetApiRootUrl() + "/tasks/{name}/tasks/batch");
resourcePath = UrlHelper.AddPathParameter(resourcePath, "name", request.Name);
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "fileName", request.FileName);
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.Storage);
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "folder", request.Folder);
var postBody = SerializationHelper.Serialize(request.Requests); // http body (model) parameter

try
{
var response = await this.apiInvoker.InvokeApiAsync(
resourcePath,
"POST",
postBody,
null,
null);
if (response != null)
{
return (TaskItemsResponse)SerializationHelper.Deserialize(response, typeof(TaskItemsResponse));
}

return null;
}
catch (ApiException ex)
{
if (ex.HttpStatusCode == HttpStatusCode.NotFound)
{
return null;
}

throw;
}
}

/// <summary>
/// Get a project document in the specified format and with the specified save options.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
<Compile Include="Model\Requests\PostTaskLinkRequest.cs" />
<Compile Include="Model\Requests\PostTaskRecurringInfoRequest.cs" />
<Compile Include="Model\Requests\PostTaskRequest.cs" />
<Compile Include="Model\Requests\PostTasksRequest.cs" />
<Compile Include="Model\Requests\PutAssignmentRequest.cs" />
<Compile Include="Model\Requests\PutCalendarExceptionRequest.cs" />
<Compile Include="Model\Requests\PutCalendarRequest.cs" />
Expand Down Expand Up @@ -264,6 +265,7 @@
<Compile Include="Model\RollupType.cs" />
<Compile Include="Model\Task.cs" />
<Compile Include="Model\TaskBaseline.cs" />
<Compile Include="Model\TaskCreationRequest.cs" />
<Compile Include="Model\TaskItem.cs" />
<Compile Include="Model\TaskItemResponse.cs" />
<Compile Include="Model\TaskItems.cs" />
Expand Down
7 changes: 3 additions & 4 deletions Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Aspose.Tasks-Cloud</id>
<version>20.8</version>
<version>20.11</version>
<title>Aspose.Tasks Cloud SDK for .NET</title>
<summary>Aspose.Tasks Cloud SDK allows developer to manipulate or convert Microsoft Project documents hosted on a cloud platform from .NET applications</summary>
<authors>Aspose</authors>
Expand All @@ -14,10 +14,9 @@
<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.
</description>
<releaseNotes>
* Add an ability to specify the non-default path for Project Server's PWA URL.
* Add an ability to modify timephasedData collection in assignments.
* Add an ability to create multiple tasks in single api call.

The complete list of changes can be found at https://docs.aspose.cloud/display/taskscloud/Aspose.Tasks+Cloud+20.8+Release+Notes
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
</releaseNotes>
<copyright>Aspose 2002-2020. All Rights Reserved.</copyright>
<tags>MPP Primavera Microsoft Project Server Online P6XML PrimaveraXML XER MPX</tags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async Task ProcessResponseAsync(HttpWebResponse response, Stream resultSt

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

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

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

var postData = "grant_type=client_credentials";
postData += "&client_id=" + this.configuration.AppSid;
Expand Down
71 changes: 71 additions & 0 deletions Aspose.Tasks.Cloud.Sdk/Model/Requests/PostTasksRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Aspose" file="PostTasksRequest.cs">
// Copyright (c) 2020 Aspose.Tasks Cloud
// </copyright>
// <summary>
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.Collections.Generic;

namespace Aspose.Tasks.Cloud.Sdk.Model.Requests
{

/// <summary>
/// Request model for <see cref="TasksApi.PostTasks" /> operation.
/// </summary>
public class PostTasksRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="PostTasksRequest"/> class.
/// </summary>
public PostTasksRequest()
{
}


/// <summary>
/// The name of the file.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Requests to create tasks.
/// </summary>
/// <returns></returns>
public List<TaskCreationRequest> Requests { get; set; }

/// <summary>
/// The name of the project document to save changes to.
/// If this parameter is omitted then the changes will be saved to the source project document.
/// </summary>
public string FileName { get; set; }

/// <summary>
/// The document storage.
/// </summary>
public string Storage { get; set; }

/// <summary>
/// The document folder.
/// </summary>
public string Folder { get; set; }
}
}
Loading

0 comments on commit 39138dc

Please sign in to comment.