Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The GIST contains .NET Examples of Aspose.Tasks Cloud APIs.
The GIST contains .NET Examples of Aspose.Tasks Cloud APIs.
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.PostAssignment(new PostAssignmentRequest
{
ResourceUid = 1,
Units = 0.5D,
TaskUid = 0,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.AssignmentItem);
var assignmentUid = response.AssignmentItem.Uid;
var getResponse = TasksApi.GetAssignment(new GetAssignmentRequest
{
AssignmentUid = assignmentUid,
Name = remoteName,
Folder = this.DataFolder
});
var getTaskResponse = TasksApi.GetTask(new GetTaskRequest
{
TaskUid = 0,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.Assignment);
Assert.AreEqual(0, getResponse.Assignment.TaskUid);
Assert.AreEqual(1, getResponse.Assignment.ResourceUid);
Assert.AreEqual(getTaskResponse.Task.Start, getResponse.Assignment.Start);
Assert.AreEqual(getTaskResponse.Task.Finish, getResponse.Assignment.Finish);
Assert.AreEqual(getTaskResponse.Task.Work, getResponse.Assignment.Work);
Assert.AreEqual(getTaskResponse.Task.Cost, getResponse.Assignment.Cost);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("New project 2013.mpp");
var calendarException = new CalendarException
{
Name = "Non-working day exception",
DayWorking = false,
FromDate = new DateTime(2014, 10, 28),
ToDate = new DateTime(2015, 08, 5),
Occurrences = 10,
Type = CalendarExceptionType.MonthlyByDay,
EnteredByOccurrences = true,
MonthDay = 5,
Period = 1
};
var response = TasksApi.PostCalendarException(new PostCalendarExceptionRequest
{
CalendarUid = 1,
CalendarException = calendarException,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.Created.ToString(), response.Status);
var getResponse = TasksApi.GetCalendarExceptions(new GetCalendarExceptionsRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.CalendarExceptions);
Assert.AreEqual(1, getResponse.CalendarExceptions.Count);
AssertCalendarExceptionsAreEqual(calendarException, getResponse.CalendarExceptions[0]);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var exception = Assert.Throws<ApiException>
(() =>
{
TasksApi.PostCalendar(new PostCalendarRequest
{
Name = remoteName,
Folder = this.DataFolder,
Calendar = new Calendar
{
Name = "My new calendar",
Days = new List<WeekDay>
{
new WeekDay { DayType = DayType.Sunday, DayWorking = false },
new WeekDay
{
DayType = DayType.Monday,
DayWorking = true,
FromDate = DateTime.MinValue.Add(TimeSpan.FromHours(8)),
ToDate = DateTime.MinValue.Add(TimeSpan.FromHours(17)),
WorkingTimes = new List<WorkingTime> {}
}
},
IsBaseCalendar = false,
IsBaselineCalendar = false
}
});
});
Assert.AreEqual(400, exception.ErrorCode);
Assert.AreEqual("InvalidParameters", exception.ReasonCode);
Assert.AreEqual("Calendar should have at least one working time defined", exception.Message);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.PostCalendar(new PostCalendarRequest
{
Name = remoteName,
Folder = this.DataFolder,
Calendar = new Calendar
{
Name = "My new calendar",
Days = new List<WeekDay>
{
new WeekDay { DayType = DayType.Sunday, DayWorking = false },
new WeekDay { DayType = DayType.Monday, DayWorking = true, FromDate = DateTime.MinValue.Add(TimeSpan.FromHours(8)), ToDate = DateTime.MinValue.Add(TimeSpan.FromHours(17)),
WorkingTimes = new List<WorkingTime>
{
new WorkingTime { FromTime = DateTime.MinValue.Add(TimeSpan.FromHours(8)), ToTime = DateTime.MinValue.Add(TimeSpan.FromHours(13))},
new WorkingTime { FromTime = DateTime.MinValue.Add(TimeSpan.FromHours(14)), ToTime = DateTime.MinValue.Add(TimeSpan.FromHours(17))}
}
}
},
IsBaseCalendar = false,
IsBaselineCalendar = false
}
});
Assert.AreEqual(HttpStatusCode.Created.ToString(), response.Status);
var createdCalendarUid = response.CalendarItem.Uid;
var getResponse = TasksApi.GetCalendar(new GetCalendarRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = createdCalendarUid
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.Calendar);
Assert.AreEqual("My new calendar", getResponse.Calendar.Name);
Assert.AreEqual(7, getResponse.Calendar.Days.Count);
var monday = getResponse.Calendar.Days.FirstOrDefault(d => d.DayType == DayType.Monday);
Assert.IsNotNull(monday);
Assert.AreEqual(2, monday.WorkingTimes.Count);
Assert.AreEqual(TimeSpan.FromHours(8), monday.WorkingTimes[0].FromTime.Value.TimeOfDay);
Assert.AreEqual(TimeSpan.FromHours(13), monday.WorkingTimes[0].ToTime.Value.TimeOfDay);
Assert.AreEqual(TimeSpan.FromHours(14), monday.WorkingTimes[1].FromTime.Value.TimeOfDay);
Assert.AreEqual(TimeSpan.FromHours(17), monday.WorkingTimes[1].ToTime.Value.TimeOfDay);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Project2016.mpp");
var postResponse = TasksApi.PostTask(new PostTaskRequest
{
BeforeTaskId = 4,
TaskName = "New task name",
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
FileName = remoteName
});
Assert.AreEqual("Created", postResponse.Status);
Assert.IsNotNull(postResponse.TaskItem);
var newTaskUid = postResponse.TaskItem.Uid;
var tasksResponse = TasksApi.GetTask(new GetTaskRequest
{
TaskUid = newTaskUid,
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), tasksResponse.Status);
Assert.IsNotNull(tasksResponse.Task);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
// initialize and object of TasksApi
Aspose.Tasks.Cloud.Sdk.TasksApi tasksApi = new Aspose.Tasks.Cloud.Sdk.TasksApi(clientSecret, clientID);
// call method to perform conversion
var resultantOutput = tasksApi.GetTaskDocumentWithFormat(new Aspose.Tasks.Cloud.Sdk.Model.Requests.GetTaskDocumentWithFormatRequest
{
Format = Aspose.Tasks.Cloud.Sdk.Model.ProjectFileFormat.Png,
Name = "Home move plan.mpp",
});
// call method to save resultant file
saveToDisk(resultantOutput, "Converted.png");
public static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0,SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.DeleteAssignment(new DeleteAssignmentRequest
{
AssignmentUid = 63,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
var getResponse = TasksApi.GetAssignments(new GetAssignmentsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNull(getResponse.Assignments.AssignmentItem.FirstOrDefault(a => a.TaskUid == 34 && a.ResourceUid == 1));
Assert.IsNull(getResponse.Assignments.AssignmentItem.FirstOrDefault(a => a.Uid == 63));
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.DeleteCalendar(new DeleteCalendarRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 2
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
var getResponse = TasksApi.GetCalendars(new GetCalendarsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.AreEqual(1, getResponse.Calendars.List.Count);
Assert.AreEqual("Standard", getResponse.Calendars.List[0].Name);
Assert.AreEqual(1L, getResponse.Calendars.List[0].Uid);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Calenar with exception.mpp");
var response = TasksApi.DeleteCalendarException(new DeleteCalendarExceptionRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1,
Index = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
var getResponse = TasksApi.GetCalendarExceptions(new GetCalendarExceptionsRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.CalendarExceptions);
Assert.AreEqual(0, getResponse.CalendarExceptions.Count);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Project2016.mpp");
var deleteResponse = TasksApi.DeleteTask(new DeleteTaskRequest
{
TaskUid = 4,
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
FileName = remoteName
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), deleteResponse.Status);
var tasksResponse = TasksApi.GetTasks(new GetTasksRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), tasksResponse.Status);
Assert.IsNotNull(tasksResponse.Tasks);
Assert.AreEqual(5, tasksResponse.Tasks.TaskItem.Count);
var firstTask = tasksResponse.Tasks.TaskItem.FirstOrDefault(i => i.Uid == 4);
Assert.IsNull(firstTask);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetAssignment(new GetAssignmentRequest
{
AssignmentUid = 63,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Assignment);
response.Assignment.TaskUid = 0;
var putResponse = TasksApi.PutAssignment(new PutAssignmentRequest
{
Mode = CalculationMode.Automatic,
Recalculate = true,
AssignmentUid = 63,
Assignment = response.Assignment,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), putResponse.Status);
var getResponse = TasksApi.GetAssignments(new GetAssignmentsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsFalse(getResponse.Assignments.AssignmentItem.Any(a => a.TaskUid == 34 && a.ResourceUid == 1));
Assert.IsTrue(getResponse.Assignments.AssignmentItem.Any(a => a.TaskUid == 0 && a.ResourceUid == 1 && a.Uid == 63));
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var putResponse = TasksApi.PostDocumentProperty(new PostDocumentPropertyRequest
{
Name = remoteName,
Folder = this.DataFolder,
PropertyName = "Title",
Property = new DocumentProperty
{
Name = "Title",
Value = "New title value"
}
});
var response = TasksApi.GetDocumentProperties(new GetDocumentPropertiesRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.AreEqual(48, response.Properties.List.Count);
Assert.AreEqual("Title", response.Properties.List[0].Name);
Assert.AreEqual("New title value", response.Properties.List[0].Value);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Project2016.mpp");
var getResponse = TasksApi.GetTask(new GetTaskRequest
{
TaskUid = 4,
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
});
var task = getResponse.Task;
task.Name = "Modified task name";
task.IsManual = true;
task.ManualStart = new DateTime(2015, 10, 1, 9, 15, 0);
task.ManualFinish = new DateTime(2015, 10, 1, 17, 15, 0);
var putResponse = TasksApi.PutTask(new PutTaskRequest
{
TaskUid = 4,
Task = task,
FileName = remoteName,
Name = remoteName,
Folder = this.DataFolder,
Storage = "Tasks",
Mode = CalculationMode.None,
Recalculate = false
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), putResponse.Status);
var tasksResponse = TasksApi.GetTask(new GetTaskRequest
{
TaskUid = 4,
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), tasksResponse.Status);
Assert.IsNotNull(tasksResponse.Task);
Assert.AreEqual("Modified task name", tasksResponse.Task.Name);
Assert.IsTrue(tasksResponse.Task.IsManual);
Assert.AreEqual(new DateTime(2015, 10, 1, 9, 15, 0), tasksResponse.Task.ManualStart);
Assert.AreEqual(new DateTime(2015, 10, 1, 17, 15, 0), tasksResponse.Task.ManualFinish);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetAssignment(new GetAssignmentRequest
{
AssignmentUid = 63,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Assignment);
Assert.AreEqual(TimeSpan.FromHours(8), response.Assignment.RegularWork);
Assert.AreEqual(TimeSpan.FromHours(8), response.Assignment.RemainingWork);
Assert.AreEqual(new DateTime(2012, 7, 9, 8, 0, 0), response.Assignment.Start.Value);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetAssignments(new GetAssignmentsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Assignments);
Assert.AreEqual(6, response.Assignments.AssignmentItem.Count);
Assert.AreEqual(34, response.Assignments.AssignmentItem[0].TaskUid);
Assert.AreEqual(63, response.Assignments.AssignmentItem[0].Uid);
Assert.AreEqual("/63", response.Assignments.AssignmentItem[0].Link.Href);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.GetCalendar(new GetCalendarRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Calendar);
Assert.AreEqual("Standard", response.Calendar.Name);
Assert.AreEqual(1, response.Calendar.Uid);
Assert.AreEqual(true, response.Calendar.IsBaseCalendar);
Assert.AreEqual(false, response.Calendar.IsBaselineCalendar);
Assert.AreEqual(7, response.Calendar.Days.Count);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Calenar with exception.mpp");
var getResponse = TasksApi.GetCalendarExceptions(new GetCalendarExceptionsRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.CalendarExceptions);
Assert.AreEqual(1, getResponse.CalendarExceptions.Count);
var calendarException = getResponse.CalendarExceptions[0];
Assert.AreEqual(true, calendarException.DayWorking);
CollectionAssert.AreEqual(new[] { DayType.Monday }, calendarException.DaysOfWeek);
Assert.AreEqual(new DateTime(2018, 02, 13), calendarException.FromDate);
Assert.AreEqual(new DateTime(2018, 04, 9), calendarException.ToDate.Value.Date);
Assert.AreEqual(Month.Undefined, calendarException.Month);
Assert.AreEqual(MonthItemType.Undefined, calendarException.MonthItem);
Assert.AreEqual(MonthPosition.Undefined, calendarException.MonthPosition);
Assert.AreEqual(CalendarExceptionType.Weekly, calendarException.Type);
Assert.AreEqual(8, calendarException.Occurrences);
Assert.AreEqual(1, calendarException.Period);
Assert.AreEqual(2, calendarException.WorkingTimes.Count);
Assert.AreEqual(TimeSpan.FromHours(9), calendarException.WorkingTimes[0].FromTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(12, 34, 0), calendarException.WorkingTimes[0].ToTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(15, 11, 0), calendarException.WorkingTimes[1].FromTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(17, 30, 0), calendarException.WorkingTimes[1].ToTime.Value.TimeOfDay);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.GetCalendars(new GetCalendarsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.AreEqual(2, response.Calendars.List.Count);
Assert.AreEqual("Standard", response.Calendars.List[0].Name);
Assert.AreEqual(1L, response.Calendars.List[0].Uid);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("CalendarWorkWeeks.mpp");
var calendarsReponse = TasksApi.GetCalendars(new GetCalendarsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), calendarsReponse.Status);
Assert.IsNotNull(calendarsReponse.Calendars);
var calendarUid = calendarsReponse.Calendars.List.Where(c => c.Name == "Test work weeks").
Select(c => c.Uid)
.FirstOrDefault();
var getResponse = TasksApi.GetCalendarWorkWeeks(new GetCalendarWorkWeeksRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = calendarUid
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.CalendarWorkWeeks);
Assert.AreEqual(1, getResponse.CalendarWorkWeeks.Count);
var workWeek = getResponse.CalendarWorkWeeks[0];
Assert.AreEqual("Work week 1", workWeek.Name);
Assert.AreEqual(new DateTime(2018, 1, 1), workWeek.FromDate.Value.Date);
Assert.AreEqual(new DateTime(2018, 1, 7), workWeek.ToDate.Value.Date);
Assert.AreEqual(4, workWeek.WeekDays.Count);
Assert.AreEqual(true, workWeek.WeekDays[0].DayWorking);
Assert.AreEqual(DayType.Monday, workWeek.WeekDays[0].DayType);
Assert.AreEqual(1, workWeek.WeekDays[0].WorkingTimes.Count);
Assert.AreEqual(new TimeSpan(11, 30, 0), workWeek.WeekDays[0].WorkingTimes[0].FromTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(12, 30, 0), workWeek.WeekDays[0].WorkingTimes[0].ToTime.Value.TimeOfDay);
Assert.AreEqual(false, workWeek.WeekDays[1].DayWorking);
Assert.AreEqual(DayType.Tuesday, workWeek.WeekDays[1].DayType);
Assert.AreEqual(0, workWeek.WeekDays[1].WorkingTimes.Count);
Assert.AreEqual(true, workWeek.WeekDays[2].DayWorking);
Assert.AreEqual(DayType.Wednesday, workWeek.WeekDays[2].DayType);
Assert.AreEqual(2, workWeek.WeekDays[2].WorkingTimes.Count);
Assert.AreEqual(new TimeSpan(9, 30, 0), workWeek.WeekDays[2].WorkingTimes[0].FromTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(13, 23, 0), workWeek.WeekDays[2].WorkingTimes[0].ToTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(14, 45, 0), workWeek.WeekDays[2].WorkingTimes[1].FromTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(18, 45, 0), workWeek.WeekDays[2].WorkingTimes[1].ToTime.Value.TimeOfDay);
Assert.AreEqual(true, workWeek.WeekDays[3].DayWorking);
Assert.AreEqual(DayType.Saturday, workWeek.WeekDays[3].DayType);
Assert.AreEqual(1, workWeek.WeekDays[3].WorkingTimes.Count);
Assert.AreEqual(new TimeSpan(9, 0, 0), workWeek.WeekDays[3].WorkingTimes[0].FromTime.Value.TimeOfDay);
Assert.AreEqual(new TimeSpan(10, 0, 0), workWeek.WeekDays[3].WorkingTimes[0].ToTime.Value.TimeOfDay);
// For complete examples and code files, please visit https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
const string clientID = "xxxx-xxxx-xxxx-xxxxx";
const string clientSecret = "xxxxxxxxx";
// initialize and object of TasksApi
Aspose.Tasks.Cloud.Sdk.TasksApi tasksApi = new Aspose.Tasks.Cloud.Sdk.TasksApi(clientSecret, clientID);
// retrieve properties associated with project document
var retrievedProperties = tasksApi.GetDocumentPropertiesAsync(new GetDocumentPropertiesRequest
{
Name = "sample.mpp",
});
// iterate through list of properties retrieved against document and print their value
for(int counter= 0; counter< retrievedProperties.Result.Properties.List.Count; counter++)
{
Console.WriteLine("Property name at index " + counter + " = "+retrievedProperties.Result.Properties.List[counter].Name);
Console.WriteLine("Property value at index " + counter + " = "+retrievedProperties.Result.Properties.List[counter].Value);
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.GetDocumentProperty(new GetDocumentPropertyRequest
{
Name = remoteName,
Folder = this.DataFolder,
PropertyName = "Title"
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Property);
Assert.AreEqual("Title", response.Property.Name);
Assert.AreEqual("Home Move", response.Property.Value);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.GetPageCount(new GetPageCountRequest
{
PresentationFormat = PresentationFormat.TaskUsage,
Timescale = Timescale.Months,
Name = remoteName,
Folder = this.DataFolder,
StartDate = new DateTime(2004, 1, 1),
EndDate = new DateTime(2004, 2, 28)
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.AreEqual(6, response.PageCount);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("p6_multiproject.xml");
var response = TasksApi.GetProjectIds(new GetProjectIdsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetResourceAssignments(new GetResourceAssignmentsRequest
{
ResourceUid = 1,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Assignments);
Assert.AreEqual(6, response.Assignments.List.Count);
Assert.IsTrue(response.Assignments.List.All(a => a.ResourceUid == 1));
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetAssignmentTimephasedData(new GetAssignmentTimephasedDataRequest()
{
AssignmentUid = 66,
Name = remoteName,
Folder = this.DataFolder,
Type = TimephasedDataType.AssignmentWork
});
Assert.AreEqual("OK", response.Status);
Assert.IsNotNull(response.Items);
var timephasedDataItems = response.Items;
Assert.IsNotNull(timephasedDataItems);
Assert.IsTrue(timephasedDataItems.Count > 0);
for (int i = 0; i < timephasedDataItems.Count; i++)
{
Assert.AreEqual(TimephasedDataType.AssignmentWork, timephasedDataItems[i].TimephasedDataType);
Assert.AreEqual(66, timephasedDataItems[i].Uid);
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetResourceTimephasedData(new GetResourceTimephasedDataRequest()
{
ResourceUid = 1,
Name = remoteName,
Folder = this.DataFolder,
Type = TimephasedDataType.ResourceWork,
});
Assert.AreEqual("OK", response.Status);
Assert.IsNotNull(response.Items);
var timephasedDataItems = response.Items;
Assert.IsNotNull(timephasedDataItems);
Assert.IsTrue(timephasedDataItems.Count > 0);
for (int i = 0; i < timephasedDataItems.Count; i++)
{
Assert.AreEqual(TimephasedDataType.ResourceWork, timephasedDataItems[i].TimephasedDataType);
Assert.AreEqual(1, timephasedDataItems[i].Uid);
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.GetTaskAssignments(new GetTaskAssignmentsRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
TaskUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Assignments);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Project2016.mpp");
var tasksResponse = TasksApi.GetTask(new GetTaskRequest
{
TaskUid = 5,
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), tasksResponse.Status);
Assert.IsNotNull(tasksResponse.Task);
Assert.AreEqual(5, tasksResponse.Task.Uid);
CollectionAssert.AreEquivalent(new[] { 1, 2, 3, 4}, tasksResponse.Task.SubtasksUids);
Assert.AreEqual(new DateTime(2015, 8, 3, 8, 0, 0), tasksResponse.Task.Start);
Assert.AreEqual(new DateTime(2015, 8, 6, 17, 0, 0), tasksResponse.Task.Finish);
Assert.AreEqual(new TimeSpan(1, 8, 0, 0, 0), tasksResponse.Task.RemainingWork);
Assert.AreEqual(1920, tasksResponse.Task.WorkVariance);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.GetTaskDocumentWithFormat(new GetTaskDocumentWithFormatRequest
{
Format = ProjectFileFormat.Csv,
Name = remoteName,
Folder = this.DataFolder,
});
Assert.IsNotNull(response);
Assert.IsTrue(response.Length > 0);
response.Seek(0, SeekOrigin.Begin);
using (var sr = new StreamReader(response))
{
var headersLine = sr.ReadLine();
var line1 = sr.ReadLine();
Assert.AreEqual("ID;Task_Name;Outline_Level;Duration;Start_Date;Finish_Date;Percent_Comp;Cost;Work", headersLine);
Assert.AreEqual("1;Five to Eight Weeks Before Moving;1;16 days;Thu 01.01.04 08:00;Thu 22.01.04 17:00;0%;$0;0 hrs", line1);
}
var remoteName = UploadFileToStorage("sample.mpp");
var response = TasksApi.GetTaskRecurringInfo(new GetTaskRecurringInfoRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
TaskUid = 6
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.RecurringInfo);
var entity = response.RecurringInfo;
Assert.AreEqual(2, (int)entity.Occurrences);
Assert.AreEqual(RecurrencePattern.Monthly, entity.RecurrencePattern);
Assert.AreEqual(true, entity.UseEndDate);
Assert.AreEqual(false, entity.MonthlyUseOrdinalDay);
Assert.AreEqual(1, entity.MonthlyDay);
Assert.AreEqual(WeekDayType.None, entity.WeeklyDays);
Assert.AreEqual(OrdinalNumber.Second, entity.YearlyOrdinalNumber);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Project2016.mpp");
var tasksResponse = TasksApi.GetTasks(new GetTasksRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), tasksResponse.Status);
Assert.IsNotNull(tasksResponse.Tasks);
Assert.AreEqual(6, tasksResponse.Tasks.TaskItem.Count);
var firstTask = tasksResponse.Tasks.TaskItem.FirstOrDefault(i => i.Uid == 5);
Assert.IsNotNull(firstTask);
Assert.AreEqual("Summary Task 1", firstTask.Name);
Assert.AreEqual(new DateTime(2015, 8, 3, 8, 0, 0), firstTask.Start);
Assert.AreEqual(new DateTime(2015, 8, 6, 17, 0, 0), firstTask.Finish);
Assert.AreEqual("/5", firstTask.Link.Href);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.GetTaskTimephasedData(new GetTaskTimephasedDataRequest()
{
TaskUid = 27,
Name = remoteName,
Folder = this.DataFolder,
Type = TimephasedDataType.TaskWork
});
Assert.AreEqual("OK", response.Status);
Assert.IsNotNull(response.Items);
var timephasedDataItems = response.Items;
Assert.IsNotNull(timephasedDataItems);
Assert.IsTrue(timephasedDataItems.Count > 0);
for (int i = 0; i < timephasedDataItems.Count; i++)
{
Assert.AreEqual(TimephasedDataType.TaskWork, timephasedDataItems[i].TimephasedDataType);
Assert.AreEqual(27, timephasedDataItems[i].Uid);
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("VbaProject3.mpp");
var vbaResponse = TasksApi.GetVbaProject(new GetVbaProjectRequest()
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual("OK", vbaResponse.Status);
Assert.IsNotNull(vbaResponse.VbaProject);
Assert.IsNotNull(vbaResponse.VbaProject.Modules);
Assert.AreEqual(7, vbaResponse.VbaProject.Modules.Count);
Assert.AreEqual("Module1", vbaResponse.VbaProject.Modules[0].Name);
Assert.IsTrue(vbaResponse.VbaProject.Modules[0].SourceCode.StartsWith("Type MEMORYSTATUS"));
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("sample.mpp");
var getResponse = TasksApi.GetTask(new GetTaskRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
TaskUid = 6
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
CollectionAssert.DoesNotContain(getResponse.Task.SubtasksUids, 10);
var response = TasksApi.PutMoveTask(new PutMoveTaskRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
ParentTaskUid = 6,
TaskUid = 10
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
getResponse = TasksApi.GetTask(new GetTaskRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
TaskUid = 6
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
CollectionAssert.Contains(getResponse.Task.SubtasksUids, 10);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var response = TasksApi.PutMoveTaskToSibling(new PutMoveTaskToSiblingRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
TaskUid = 41,
BeforeTaskUid = 40
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
var getResponse = TasksApi.GetTask(new GetTaskRequest
{
Name = remoteName,
Storage = "Tasks",
Folder = this.DataFolder,
TaskUid = 38
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
CollectionAssert.AreEqual(new int[] { 39, 41, 40 }, getResponse.Task.SubtasksUids);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
// SaveOptions parameters is a json-serialized representation of
// Aspose.Tasks's SaveOptions class or its format-specific inheritors (Like CsvOptions, etc):
// See Aspose.Tasks reference: https://apireference.aspose.com/net/tasks/aspose.tasks.saving/saveoptions
var saveOptionsSerialized = "{ \"TextDelimiter\":\"Comma\", \"IncludeHeaders\":false,\"NonExistingTestProperty\":false," +
"\"View\":{ \"Columns\":[{Type:\"GanttChartColumn\",\"Name\":\"TestColumn1\",\"Property\":\"Name\",\"Width\":120}," +
"{Type:\"GanttChartColumn\",\"Name\":\"TestColumn2\",\"Property\":\"Duration\",\"Width\":120}]}}";
var saveOptions = JObject.Parse(saveOptionsSerialized);
var response = TasksApi.PostTaskDocumentWithFormat(new PostTaskDocumentWithFormatRequest
{
Format = ProjectFileFormat.Csv,
Name = remoteName,
Folder = this.DataFolder,
SaveOptions = saveOptions
});
Assert.IsNotNull(response);
Assert.IsTrue(response.Length > 0);
response.Seek(0, SeekOrigin.Begin);
using (var sr = new StreamReader(response))
{
var line1 = sr.ReadLine();
Assert.AreEqual("Five to Eight Weeks Before Moving,16 days", line1);
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var response = TasksApi.PutCalendar(new PutCalendarRequest
{
CalendarUid = 1,
Name = remoteName,
Folder = this.DataFolder,
Calendar = new Calendar
{
Uid = 1,
Name = "Modified calendar",
Days = new List<WeekDay>
{
new WeekDay { DayType = DayType.Sunday, DayWorking = false },
new WeekDay { DayType = DayType.Monday, DayWorking = true, FromDate = DateTime.MinValue.Add(TimeSpan.FromHours(8)), ToDate = DateTime.MinValue.Add(TimeSpan.FromHours(17)),
WorkingTimes = new List<WorkingTime>
{
new WorkingTime { FromTime = DateTime.MinValue.Add(TimeSpan.FromHours(8)), ToTime = DateTime.MinValue.Add(TimeSpan.FromHours(13))},
new WorkingTime { FromTime = DateTime.MinValue.Add(TimeSpan.FromHours(14)), ToTime = DateTime.MinValue.Add(TimeSpan.FromHours(17))}
}
}
},
IsBaseCalendar = false,
IsBaselineCalendar = false
}
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
var getResponse = TasksApi.GetCalendar(new GetCalendarRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.Calendar);
Assert.AreEqual("Modified calendar", getResponse.Calendar.Name);
Assert.AreEqual(7, getResponse.Calendar.Days.Count);
var monday = getResponse.Calendar.Days.FirstOrDefault(d => d.DayType == DayType.Monday);
Assert.IsNotNull(monday);
Assert.AreEqual(2, monday.WorkingTimes.Count);
Assert.AreEqual(TimeSpan.FromHours(8), monday.WorkingTimes[0].FromTime.Value.TimeOfDay);
Assert.AreEqual(TimeSpan.FromHours(13), monday.WorkingTimes[0].ToTime.Value.TimeOfDay);
Assert.AreEqual(TimeSpan.FromHours(14), monday.WorkingTimes[1].FromTime.Value.TimeOfDay);
Assert.AreEqual(TimeSpan.FromHours(17), monday.WorkingTimes[1].ToTime.Value.TimeOfDay);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Calenar with exception.mpp");
var getResponse = TasksApi.GetCalendarExceptions(new GetCalendarExceptionsRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
var calendarException = getResponse.CalendarExceptions[0];
calendarException.DaysOfWeek = new List<DayType> { DayType.Thursday, DayType.Friday };
calendarException.WorkingTimes = new List<WorkingTime> { new WorkingTime() { FromTime = DateTime.MinValue + TimeSpan.FromHours(9), ToTime = DateTime.MinValue + TimeSpan.FromHours(17) } };
calendarException.Occurrences = 10;
calendarException.EnteredByOccurrences = true;
calendarException.Period = 1;
calendarException.Name = "Non-working day exception";
calendarException.DayWorking = true;
calendarException.FromDate = new DateTime(2014, 10, 28);
calendarException.ToDate = new DateTime(2015, 08, 5);
var response = TasksApi.PutCalendarException(new PutCalendarExceptionRequest
{
CalendarUid = 1,
Index = calendarException.Index,
CalendarException = calendarException,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
getResponse = TasksApi.GetCalendarExceptions(new GetCalendarExceptionsRequest
{
Name = remoteName,
Folder = this.DataFolder,
CalendarUid = 1
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.CalendarExceptions);
Assert.AreEqual(1, getResponse.CalendarExceptions.Count);
AssertCalendarExceptionsAreEqual(calendarException, getResponse.CalendarExceptions[0]);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("Home move plan.mpp");
var putResponse = TasksApi.PutDocumentProperty(new PutDocumentPropertyRequest
{
Name = remoteName,
Folder = this.DataFolder,
PropertyName = "Title",
Property = new DocumentProperty
{
Name = "Title",
Value = "New title value"
}
});
var response = TasksApi.GetDocumentProperties(new GetDocumentPropertiesRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.AreEqual(48, response.Properties.List.Count);
Assert.AreEqual("Title", response.Properties.List[0].Name);
Assert.AreEqual("New title value", response.Properties.List[0].Value);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("NewProductDev.mpp");
var newExtendedAttribute = new ExtendedAttributeDefinition
{
CalculationType = CalculationType.Lookup,
CfType = CustomFieldType.Text,
FieldName = "Text3",
ElementType = ElementType.Task,
Alias = "New Field",
ValueList = new List<Value>
{
new Value { Description = "descr1", Val = "Internal", Id = 111 },
new Value { Description = "descr2", Val = "External", Id = 112 }
}
};
var response = TasksApi.PutExtendedAttribute(new PutExtendedAttributeRequest
{
ExtendedAttribute = newExtendedAttribute,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.ExtendedAttribute);
Assert.AreEqual("Text3", response.ExtendedAttribute.FieldName);
Assert.AreEqual("New Field", response.ExtendedAttribute.Alias);
Assert.AreEqual("188743737", response.ExtendedAttribute.FieldId);
var addedAttributeIndex = response.ExtendedAttribute.Index;
var getResponse = TasksApi.GetExtendedAttributeByIndex(new GetExtendedAttributeByIndexRequest
{
Index = addedAttributeIndex,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), getResponse.Status);
Assert.IsNotNull(getResponse.ExtendedAttribute);
var extendedAttribute = getResponse.ExtendedAttribute;
Assert.AreEqual("188743737", extendedAttribute.FieldId);
Assert.AreEqual("Text3", extendedAttribute.FieldName);
Assert.AreEqual(CustomFieldType.Text, extendedAttribute.CfType);
Assert.AreEqual("New Field", extendedAttribute.Alias);
var valueList = extendedAttribute.ValueList;
Assert.AreEqual(2, valueList.Count);
Assert.AreEqual(111, valueList[0].Id);
Assert.AreEqual("Internal", valueList[0].Val);
Assert.AreEqual("descr1", valueList[0].Description);
Assert.AreEqual(112, valueList[1].Id);
Assert.AreEqual("External", valueList[1].Val);
Assert.AreEqual("descr2", valueList[1].Description);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var response = TasksApi.PutImportProjectFromDb(new PutImportProjectFromDbRequest
{
ConnectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=ProjectServer_Published;Persist Security Info=True;User ID=sa;Password=pwd;",
DatabaseType = ProjectDatabaseType.Msp,
Folder = this.DataFolder,
Filename = "imported_from_db.xml",
ProjectUid = "E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
DatabaseSchema = "dbo",
Format = ProjectFileFormat.P6xml
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
var getProjectIdsResponse = TasksApi.GetProjectIds(new GetProjectIdsRequest
{
Name = "imported_from_mdp.xml",
Folder = this.DataFolder
});
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remote = UploadFileToStorage("p6_multiproject.xml");
var response = TasksApi.PutImportProjectFromFile(new PutImportProjectFromFileRequest
{
Name = remote,
Folder = this.DataFolder,
Filename = "imported_from_primavera.xml",
ProjectUid = "111",
FileType = ImportedProjectType.PrimaveraXml,
OutputFileFormat = ProjectFileFormat.P6xml
});
var getTasksResponse = TasksApi.GetTasks(new GetTasksRequest
{
Name = "imported_from_primavera.xml",
Folder = this.DataFolder
});
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var configuration = new Configuration { ApiBaseUrl = BaseProductUri, AppKey = this.keys.AppKey, AppSid = this.keys.AppSid };
this.TasksApi = new TasksApi(configuration);
// Get App Key and App SID from https://dashboard.aspose.cloud/
this.StorageApi = new StorageApi(this.keys.AppKey, this.keys.AppSid, BaseProductUri + "/v1.1");
var remoteName = UploadFileToStorage("sample.mpp");
var responseAfterAdd = TasksApi.PostTask(new PostTaskRequest
{
Name = remoteName,
Folder = this.DataFolder,
TaskName = "NewTaskName"
});
Assert.AreEqual(HttpStatusCode.Created.ToString(), responseAfterAdd.Status);
int taskUid = responseAfterAdd.TaskItem.Uid.Value;
var response = TasksApi.GetTask(new GetTaskRequest
{
Name = remoteName,
Folder = this.DataFolder,
TaskUid = taskUid
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), response.Status);
Assert.IsNotNull(response.Task);
var t = response.Task;
t.Name = "New task Name";
t.ActualStart = new DateTime(2000, 10, 20);
t.ActualFinish = new DateTime(2000, 10, 09);
t.Cost = 100;
var responseAfterUpdate = TasksApi.PutTask(new PutTaskRequest
{
Task = t,
TaskUid = taskUid,
Name = remoteName,
Folder = this.DataFolder,
Recalculate = false,
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), responseAfterUpdate.Status);
var recalculationResponse = TasksApi.PutRecalculateProject(new PutRecalculateProjectRequest()
{
FileName = remoteName,
Folder = this.DataFolder,
Name = remoteName,
Mode = CalculationMode.None,
Validate = true
});
Assert.AreEqual(HttpStatusCode.OK.ToString(), recalculationResponse.Status);
var validationResult = recalculationResponse.Result;
Assert.AreEqual(ProjectValidationState.HasErrors, validationResult.ValidationState);
Assert.AreEqual("Actual start date of task is greater than actual finish date. Task name: New task Name; Actual start date: 10/20/2000 00:00:00; Actual finish date: 10/09/2000 00:00:00", validationResult.ValidationErrorMessage);
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet
String MyClientID = "c235e685-1aab-4cda-a95b-54afd63eb87f";
String MyClientSecret = "b8da4ee37494f2ef8da3c727f3a0acb9";
TasksApi tasksApi = new TasksApi(MyClientSecret, MyClientID);
var response2 = tasksApi.GetTaskDocumentWithFormat(new GetTaskDocumentWithFormatRequest
{
Format = ProjectFileFormat.Pdf,
Name = "Home move plan.mpp",
});
saveToDisk(response2, "Converted.pdf");
public static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0,SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet
String MyClientID = "c235e685-1aab-4cda-a95b-54afd63eb87f";
String MyClientSecret = "b8da4ee37494f2ef8da3c727f3a0acb9";
TasksApi tasksApi = new TasksApi(MyClientSecret, MyClientID);
var response2 = tasksApi.GetTaskDocumentWithFormat(new GetTaskDocumentWithFormatRequest
{
Format = ProjectFileFormat.Xlsx,
Name = "Home move plan.mpp",
});
saveToDisk(response2, "MyResultant.xlsx");
public static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0,SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment