From 39138dc3a629c1b83bfd16f3b03e407a8d698ee1 Mon Sep 17 00:00:00 2001 From: IvanAndreychikov Date: Wed, 4 Nov 2020 12:49:41 +0500 Subject: [PATCH] [TASKSCLOUD-445] - Deployed new 20.11 version. --- .../Assignment/TestAssignments.cs | 2 +- .../Base/BaseTestContext.cs | 4 +- .../Tasks/TestTasks.cs | 58 ++++++++++++--- Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs | 6 ++ Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs | 54 ++++++++++++++ Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs | 54 ++++++++++++++ .../Aspose.Tasks.Cloud.Sdk.csproj | 2 + .../Aspose.Tasks.Cloud.Sdk.nuspec | 7 +- .../RequestHandlers/OAuthRequestHandler.cs | 4 +- .../Model/Requests/PostTasksRequest.cs | 71 +++++++++++++++++++ .../Model/TaskCreationRequest.cs | 64 +++++++++++++++++ .../Properties/AssemblyInfo.cs | 4 +- .../Aspose.Tasks.Cloud.Live.Demos.UI.csproj | 4 +- .../packages.config | 2 +- 14 files changed, 314 insertions(+), 22 deletions(-) create mode 100644 Aspose.Tasks.Cloud.Sdk/Model/Requests/PostTasksRequest.cs create mode 100644 Aspose.Tasks.Cloud.Sdk/Model/TaskCreationRequest.cs diff --git a/Aspose.Tasks.Cloud.Sdk.Tests/Assignment/TestAssignments.cs b/Aspose.Tasks.Cloud.Sdk.Tests/Assignment/TestAssignments.cs index b88704b..55665c4 100644 --- a/Aspose.Tasks.Cloud.Sdk.Tests/Assignment/TestAssignments.cs +++ b/Aspose.Tasks.Cloud.Sdk.Tests/Assignment/TestAssignments.cs @@ -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); diff --git a/Aspose.Tasks.Cloud.Sdk.Tests/Base/BaseTestContext.cs b/Aspose.Tasks.Cloud.Sdk.Tests/Base/BaseTestContext.cs index 9ab3f18..7bd2d34 100644 --- a/Aspose.Tasks.Cloud.Sdk.Tests/Base/BaseTestContext.cs +++ b/Aspose.Tasks.Cloud.Sdk.Tests/Base/BaseTestContext.cs @@ -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(); } @@ -152,6 +152,8 @@ private class Keys public string AppSid { get; set; } public string AppKey { get; set; } + + public string AuthUrl { get; set; } } } } \ No newline at end of file diff --git a/Aspose.Tasks.Cloud.Sdk.Tests/Tasks/TestTasks.cs b/Aspose.Tasks.Cloud.Sdk.Tests/Tasks/TestTasks.cs index d1c68dd..cb6604f 100644 --- a/Aspose.Tasks.Cloud.Sdk.Tests/Tasks/TestTasks.cs +++ b/Aspose.Tasks.Cloud.Sdk.Tests/Tasks/TestTasks.cs @@ -1,5 +1,4 @@ - -// -------------------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2018 Aspose.Tasks for Cloud // @@ -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; @@ -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 { 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() { @@ -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); } } -} +} \ No newline at end of file diff --git a/Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs b/Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs index 1671573..00bbb89 100644 --- a/Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs +++ b/Aspose.Tasks.Cloud.Sdk/Api/Configuration.cs @@ -51,6 +51,12 @@ public string ApiBaseUrl } } + + /// + /// Aspose Cloud Auth URL. + /// + public string AuthUrl { get; set; } + /// /// Gets or sets the app key. /// diff --git a/Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs b/Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs index 7812bb7..dbbee1a 100644 --- a/Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs +++ b/Aspose.Tasks.Cloud.Sdk/Api/TasksApi.cs @@ -2512,6 +2512,60 @@ public TaskItemResponse PostTask(PostTaskRequest request) } } + /// + /// Add a new tasks to a project. + /// + /// Request. + /// + 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; + } + } + /// /// Get a project document in the specified format and with the specified save options. /// diff --git a/Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs b/Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs index 315d21d..0993666 100644 --- a/Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs +++ b/Aspose.Tasks.Cloud.Sdk/Api/TasksApiAsync.cs @@ -2451,6 +2451,60 @@ public async Task PostTaskAsync(PostTaskRequest request) } } + /// + /// Add a new tasks to a project. + /// + /// Request. + /// + public async Task 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; + } + } + /// /// Get a project document in the specified format and with the specified save options. /// diff --git a/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.csproj b/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.csproj index ef152c6..41b3a93 100644 --- a/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.csproj +++ b/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.csproj @@ -231,6 +231,7 @@ + @@ -264,6 +265,7 @@ + diff --git a/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.nuspec b/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.nuspec index 1bf2ba4..d4895f6 100644 --- a/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.nuspec +++ b/Aspose.Tasks.Cloud.Sdk/Aspose.Tasks.Cloud.Sdk.nuspec @@ -2,7 +2,7 @@ Aspose.Tasks-Cloud - 20.8 + 20.11 Aspose.Tasks Cloud SDK for .NET Aspose.Tasks Cloud SDK allows developer to manipulate or convert Microsoft Project documents hosted on a cloud platform from .NET applications Aspose @@ -14,10 +14,9 @@ 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. - * 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 Aspose 2002-2020. All Rights Reserved. MPP Primavera Microsoft Project Server Online P6XML PrimaveraXML XER MPX diff --git a/Aspose.Tasks.Cloud.Sdk/Internal/RequestHandlers/OAuthRequestHandler.cs b/Aspose.Tasks.Cloud.Sdk/Internal/RequestHandlers/OAuthRequestHandler.cs index 3fa107e..f991763 100644 --- a/Aspose.Tasks.Cloud.Sdk/Internal/RequestHandlers/OAuthRequestHandler.cs +++ b/Aspose.Tasks.Cloud.Sdk/Internal/RequestHandlers/OAuthRequestHandler.cs @@ -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; @@ -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; diff --git a/Aspose.Tasks.Cloud.Sdk/Model/Requests/PostTasksRequest.cs b/Aspose.Tasks.Cloud.Sdk/Model/Requests/PostTasksRequest.cs new file mode 100644 index 0000000..2bc023c --- /dev/null +++ b/Aspose.Tasks.Cloud.Sdk/Model/Requests/PostTasksRequest.cs @@ -0,0 +1,71 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2020 Aspose.Tasks Cloud +// +// +// 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. +// +// -------------------------------------------------------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Aspose.Tasks.Cloud.Sdk.Model.Requests +{ + + /// + /// Request model for operation. + /// + public class PostTasksRequest + { + /// + /// Initializes a new instance of the class. + /// + public PostTasksRequest() + { + } + + + /// + /// The name of the file. + /// + public string Name { get; set; } + + /// + /// Requests to create tasks. + /// + /// + public List Requests { get; set; } + + /// + /// 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. + /// + public string FileName { get; set; } + + /// + /// The document storage. + /// + public string Storage { get; set; } + + /// + /// The document folder. + /// + public string Folder { get; set; } + } +} \ No newline at end of file diff --git a/Aspose.Tasks.Cloud.Sdk/Model/TaskCreationRequest.cs b/Aspose.Tasks.Cloud.Sdk/Model/TaskCreationRequest.cs new file mode 100644 index 0000000..d7b8c0b --- /dev/null +++ b/Aspose.Tasks.Cloud.Sdk/Model/TaskCreationRequest.cs @@ -0,0 +1,64 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2020 Aspose.Tasks Cloud +// +// +// 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. +// +// -------------------------------------------------------------------------------------------------------------------- + +using System.Text; + +namespace Aspose.Tasks.Cloud.Sdk.Model +{ + public class TaskCreationRequest + { + + /// + /// The name for the new task. + /// + public string TaskName { get; set; } + + /// + /// Uid for parent task. + /// + public int? ParentTaskUid { get; set; } + + /// + /// Id of task before which new task will be inserted.. + /// + public int? BeforeTaskId { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class TaskCreationRequest {\n"); + sb.Append(" TaskName: ").Append(this.TaskName).Append("\n"); + sb.Append(" ParentTaskUid: ").Append(this.ParentTaskUid).Append("\n"); + sb.Append(" BeforeTaskId: ").Append(this.BeforeTaskId).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/Aspose.Tasks.Cloud.Sdk/Properties/AssemblyInfo.cs b/Aspose.Tasks.Cloud.Sdk/Properties/AssemblyInfo.cs index 6b4eadd..19b2aa0 100644 --- a/Aspose.Tasks.Cloud.Sdk/Properties/AssemblyInfo.cs +++ b/Aspose.Tasks.Cloud.Sdk/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ // Minor Version // Build Number // Revision -[assembly: AssemblyVersion("20.8.0.0")] -[assembly: AssemblyFileVersion("20.8.0.0")] +[assembly: AssemblyVersion("20.11.0.0")] +[assembly: AssemblyFileVersion("20.11.0.0")] diff --git a/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/Aspose.Tasks.Cloud.Live.Demos.UI.csproj b/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/Aspose.Tasks.Cloud.Live.Demos.UI.csproj index 1f2bb61..912f1f1 100644 --- a/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/Aspose.Tasks.Cloud.Live.Demos.UI.csproj +++ b/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/Aspose.Tasks.Cloud.Live.Demos.UI.csproj @@ -78,8 +78,8 @@ ..\..\packages\AspNet.ScriptManager.jQuery.3.3.1\lib\net45\AspNet.ScriptManager.jQuery.dll - - ..\..\packages\Aspose.Tasks-Cloud.20.8.0\lib\net20\Aspose.Tasks.Cloud.Sdk.dll + + ..\..\packages\Aspose.Tasks-Cloud.20.11.0\lib\net20\Aspose.Tasks.Cloud.Sdk.dll ..\..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.6.4\lib\net45\Microsoft.AI.DependencyCollector.dll diff --git a/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/packages.config b/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/packages.config index 6b8537b..6c32a08 100644 --- a/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/packages.config +++ b/Demos/src/Aspose.Tasks.Cloud.Live.Demos.UI/packages.config @@ -4,7 +4,7 @@ - +