Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist repository contains code snippet related to Aspose.Tasks Cloud SDK for Go
Aspose.Tasks-Cloud-SDK-Go
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.CreateNewProjectOpts{
Name: remoteFileName,
SiteUrl: "http://project_server_instance.local/sites/pwa",
UserName: optional.NewString("SomeLogin"),
XSharepointPassword: optional.NewString("SomePassword"),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.CreateNewProject(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.CreateNewProjectOpts{
Name: remoteFileName,
SiteUrl: "http://project_server_instance.local/sites/pwa",
XProjectOnlineToken: optional.NewString("SOMESECRETTOKEN"),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.CreateNewProject(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteResult, _, err := client.TasksApi.DeleteAssignment(ctx, &requests.DeleteAssignmentOpts{
AssignmentUid: 63,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteCalendarOpts := &requests.DeleteCalendarOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
CalendarUid: 3,
}
deleteResult, _, err := client.TasksApi.DeleteCalendar(ctx, deleteCalendarOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteResult, _, err := client.TasksApi.DeleteCalendarException(ctx, &requests.DeleteCalendarExceptionOpts{
CalendarUid: 1,
Index: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteResult, _, err := client.TasksApi.DeleteExtendedAttributeByIndex(ctx, &requests.DeleteExtendedAttributeByIndexOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
Index: 1,
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteOptions := &requests.DeleteOutlineCodeByIndexOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
Index: 1,
}
deleteResult, _, err := client.TasksApi.DeleteOutlineCodeByIndex(ctx, deleteOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteOpts := &requests.DeleteResourceOpts{
ResourceUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
deleteResult, _, err := client.TasksApi.DeleteResource(ctx, deleteOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
deleteOpts := &requests.DeleteTaskOpts{
TaskUid: 4,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
deleteResult, _, err := client.TasksApi.DeleteTask(ctx, deleteOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetAssignmentOpts{
AssignmentUid: 63,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetAssignment(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Assignment)
assert.Equal(t, "08:00:00", *result.Assignment.RegularWork)
assert.Equal(t, "08:00:00", *result.Assignment.RemainingWork)
assert.Equal(t, CreateTime(2012, 7, 9, 8, 0, 0), result.Assignment.Start)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetAssignmentsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetAssignments(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Assignments)
assert.Equal(t, 6, len(result.Assignments.AssignmentItem))
assert.Equal(t, int32(34), result.Assignments.AssignmentItem[0].TaskUid)
assert.Equal(t, int32(63), result.Assignments.AssignmentItem[0].Uid)
assert.Equal(t, "/63", result.Assignments.AssignmentItem[0].Link.Href)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetAssignmentTimephasedDataOpts{
AssignmentUid: 66,
Type_: optional.NewString(string(models.ASSIGNMENT_WORK_TimephasedDataType)),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetAssignmentTimephasedData(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Items)
assert.LessOrEqual(t, 1, len(result.Items))
for _, timephasedData := range result.Items {
assert.Equal(t, models.ASSIGNMENT_WORK_TimephasedDataType, *timephasedData.TimephasedDataType)
assert.Equal(t, int32(66), timephasedData.Uid)
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetCalendarOpts{
CalendarUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetCalendar(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Calendar)
assert.Equal(t, "Standard", result.Calendar.Name)
assert.Equal(t, int32(1), result.Calendar.Uid)
assert.True(t, result.Calendar.IsBaseCalendar)
assert.False(t, result.Calendar.IsBaselineCalendar)
assert.Equal(t, 7, len(result.Calendar.Days))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetCalendarExceptionsOpts{
CalendarUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetCalendarExceptions(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.CalendarExceptions)
assert.Equal(t, 1, len(result.CalendarExceptions))
calendarException := result.CalendarExceptions[0]
assert.True(t, calendarException.DayWorking)
assert.Equal(t, []models.DayType{models.MONDAY_DayType}, calendarException.DaysOfWeek)
assert.Equal(t, CreateTime(2018, 2, 13, 0, 0, 0), calendarException.FromDate)
assert.Equal(t, CreateTime(2018, 4, 9, 23, 59, 0), calendarException.ToDate)
assert.Equal(t, models.UNDEFINED_Month, *calendarException.Month)
assert.Equal(t, models.UNDEFINED_MonthItemType, *calendarException.MonthItem)
assert.Equal(t, models.UNDEFINED_MonthPosition, *calendarException.MonthPosition)
assert.Equal(t, models.WEEKLY_CalendarExceptionType, *calendarException.Type_)
assert.Equal(t, int32(8), calendarException.Occurrences)
assert.Equal(t, int32(1), calendarException.Period)
assert.Equal(t, 2, len(calendarException.WorkingTimes))
assert.Equal(t, "09:00:00", ExtractTimeOnly(calendarException.WorkingTimes[0].FromTime))
assert.Equal(t, "12:34:00", ExtractTimeOnly(calendarException.WorkingTimes[0].ToTime))
assert.Equal(t, "15:11:00", ExtractTimeOnly(calendarException.WorkingTimes[1].FromTime))
assert.Equal(t, "17:30:00", ExtractTimeOnly(calendarException.WorkingTimes[1].ToTime))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetCalendarsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetCalendars(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Calendars.List)
assert.Equal(t, 1, len(result.Calendars.List))
assert.Equal(t, "Standard", result.Calendars.List[0].Name)
assert.Equal(t, int32(1), result.Calendars.List[0].Uid)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getCalendarsResult, _, err := client.TasksApi.GetCalendars(ctx, &requests.GetCalendarsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
var calendarUid int32
for _, calendar := range getCalendarsResult.Calendars.List {
if calendar.Name == "Test work weeks" {
calendarUid = calendar.Uid
break
}
}
getCalendarWorkWeeksResult, _, err := client.TasksApi.GetCalendarWorkWeeks(ctx, &requests.GetCalendarWorkWeeksOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
CalendarUid: calendarUid,
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getCalendarWorkWeeksResult.Code)
assert.Equal(t, 1, len(getCalendarWorkWeeksResult.CalendarWorkWeeks))
workWeek := getCalendarWorkWeeksResult.CalendarWorkWeeks[0]
assert.Equal(t, "Work week 1", workWeek.Name)
assert.Equal(t, "2018-01-01", ExtractDateOnly(workWeek.FromDate))
assert.Equal(t, "2018-01-07", ExtractDateOnly(workWeek.ToDate))
assert.Equal(t, 4, len(workWeek.WeekDays))
assert.True(t, workWeek.WeekDays[0].DayWorking)
assert.Equal(t, models.MONDAY_DayType, *workWeek.WeekDays[0].DayType)
assert.Equal(t, 1, len(workWeek.WeekDays[0].WorkingTimes))
assert.Equal(t, "11:30:00", ExtractTimeOnly(workWeek.WeekDays[0].WorkingTimes[0].FromTime))
assert.Equal(t, "12:30:00", ExtractTimeOnly(workWeek.WeekDays[0].WorkingTimes[0].ToTime))
assert.False(t, workWeek.WeekDays[1].DayWorking)
assert.Equal(t, models.TUESDAY_DayType, *workWeek.WeekDays[1].DayType)
assert.Equal(t, 0, len(workWeek.WeekDays[1].WorkingTimes))
assert.True(t, workWeek.WeekDays[2].DayWorking)
assert.Equal(t, models.WEDNESDAY_DayType, *workWeek.WeekDays[2].DayType)
assert.Equal(t, 2, len(workWeek.WeekDays[2].WorkingTimes))
assert.Equal(t, "09:30:00", ExtractTimeOnly(workWeek.WeekDays[2].WorkingTimes[0].FromTime))
assert.Equal(t, "13:23:00", ExtractTimeOnly(workWeek.WeekDays[2].WorkingTimes[0].ToTime))
assert.Equal(t, "14:45:00", ExtractTimeOnly(workWeek.WeekDays[2].WorkingTimes[1].FromTime))
assert.Equal(t, "18:45:00", ExtractTimeOnly(workWeek.WeekDays[2].WorkingTimes[1].ToTime))
assert.True(t, workWeek.WeekDays[0].DayWorking)
assert.Equal(t, models.SATURDAY_DayType, *workWeek.WeekDays[3].DayType)
assert.Equal(t, 1, len(workWeek.WeekDays[3].WorkingTimes))
assert.Equal(t, "09:00:00", ExtractTimeOnly(workWeek.WeekDays[3].WorkingTimes[0].FromTime))
assert.Equal(t, "10:00:00", ExtractTimeOnly(workWeek.WeekDays[3].WorkingTimes[0].ToTime))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetDocumentPropertiesOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetDocumentProperties(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Properties)
assert.Equal(t, 52, len(result.Properties.List))
assert.Equal(t, "Title", result.Properties.List[0].Name)
assert.Equal(t, "Home Move", result.Properties.List[0].Value)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetDocumentPropertyOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PropertyName: "Title",
}
result, _, err := client.TasksApi.GetDocumentProperty(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Property)
assert.Equal(t, "Title", result.Property.Name)
assert.Equal(t, "Home Move", result.Property.Value)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetExtendedAttributeByIndexOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
Index: 1,
}
result, _, err := client.TasksApi.GetExtendedAttributeByIndex(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.ExtendedAttribute)
assert.Equal(t, "Text1", result.ExtendedAttribute.FieldName)
assert.Equal(t, models.LOOKUP_CalculationType, *result.ExtendedAttribute.CalculationType)
assert.Equal(t, 1, len(result.ExtendedAttribute.ValueList))
assert.Equal(t, "descr", result.ExtendedAttribute.ValueList[0].Description)
assert.Equal(t, int32(1), result.ExtendedAttribute.ValueList[0].Id)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetExtendedAttributesOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetExtendedAttributes(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.ExtendedAttributes)
assert.Equal(t, 2, len(result.ExtendedAttributes.List))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetOutlineCodeByIndexOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
Index: 1,
}
result, _, err := client.TasksApi.GetOutlineCodeByIndex(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.OutlineCode)
assert.Equal(t, "F45D601B-70C5-E311-A5BA-D43D7E937F92", result.OutlineCode.Guid)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetOutlineCodesOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetOutlineCodes(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.OutlineCodes)
assert.Equal(t, 2, len(result.OutlineCodes.List))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetPageCountOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PresentationFormat: optional.NewString(string(models.TASK_USAGE_PresentationFormat)),
Timescale: optional.NewString(string(models.MONTHS_Timescale)),
}
result, _, err := client.TasksApi.GetPageCount(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.Equal(t, int32(4), result.PageCount)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetProjectIdsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetProjectIds(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.Equal(t, []string{"1", "111"}, result.ProjectIds)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := PrepareTest(t, config)
getOptions := &requests.GetProjectListOpts{
SiteUrl: "http://project_server_instance.local/sites/pwa",
UserName: optional.NewString("SomeLogin"),
XSharepointPassword: optional.NewString("SomePassword"),
}
result, _, err := client.TasksApi.GetProjectList(ctx, getOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Projects)
assert.LessOrEqual(t, 1, len(result.Projects.ProjectInfo))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := PrepareTest(t, config)
getOptions := &requests.GetProjectListOpts{
SiteUrl: "http://project_server_instance.local/sites/pwa",
XProjectOnlineToken: optional.NewString("SOMESECRETTOKEN"),
}
result, _, err := client.TasksApi.GetProjectList(ctx, getOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Projects)
assert.LessOrEqual(t, 1, len(result.Projects.ProjectInfo))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetReportPdfOpts{
Type_: string(models.MILESTONES_ReportType),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
file, response, err := client.TasksApi.GetReportPdf(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, 200, response.StatusCode)
assert.Less(t, 1, len(file))
fileAsStrings := ConvertBytesToStrings(file)
assert.Equal(t, "%PDF-1.5", fileAsStrings[0])
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.GetResourceAssignmentsOpts{
ResourceUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetResourceAssignments(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Assignments)
assert.Equal(t, 6, len(result.Assignments.List))
for _, resourceAssignment := range result.Assignments.List {
assert.Equal(t, int32(1), resourceAssignment.ResourceUid)
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetResourcesOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetResources(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Resources)
assert.Equal(t, 2, len(result.Resources.ResourceItem))
assert.Equal(t, "Project manager", result.Resources.ResourceItem[1].Name)
assert.Equal(t, int32(1), result.Resources.ResourceItem[1].Uid)
assert.Equal(t, int32(1), result.Resources.ResourceItem[1].Id)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetResourceTimephasedDataOpts{
ResourceUid: 1,
Type_: optional.NewString(string(models.RESOURCE_WORK_TimephasedDataType)),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetResourceTimephasedData(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Items)
assert.LessOrEqual(t, 1, len(result.Items))
for _, timephasedData := range result.Items {
assert.Equal(t, models.RESOURCE_WORK_TimephasedDataType, *timephasedData.TimephasedDataType)
assert.Equal(t, int32(1), timephasedData.Uid)
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetTaskOpts{
TaskUid: 5,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetTask(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Task)
assert.Equal(t, int32(5), result.Task.Uid)
assert.Equal(t, []int32{1, 2, 3, 4}, result.Task.SubtasksUids)
assert.Equal(t, "Summary Task 1", result.Task.Name)
assert.Equal(t, CreateTime(2015, 8, 3, 8, 0, 0), result.Task.Start)
assert.Equal(t, CreateTime(2015, 8, 6, 17, 0, 0), result.Task.Finish)
assert.Equal(t, "1.08:00:00", *result.Task.RemainingWork)
assert.Equal(t, float64(1920), result.Task.WorkVariance)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetTaskAssignmentsOpts{
TaskUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetTaskAssignments(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Assignments)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetTaskDocumentWithFormatOpts{
Name: remoteFileName,
Format: string(models.CSV_ProjectFileFormat),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
data, response, err := client.TasksApi.GetTaskDocumentWithFormat(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, 200, response.StatusCode)
assert.NotNil(t, data)
assert.Less(t, 1, len(data))
fileAsStrings := ConvertBytesToStrings(data)
assert.Equal(t, "ID;Task_Name;Outline_Level;Duration;Start_Date;Finish_Date;Percent_Comp;Cost;Work", fileAsStrings[0])
assert.Equal(t, "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", fileAsStrings[1])
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
result, _, err := client.TasksApi.GetTaskRecurringInfo(ctx, &requests.GetTaskRecurringInfoOpts{
TaskUid: 6,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.Equal(t, int32(2), result.RecurringInfo.Occurrences)
assert.Equal(t, models.MONTHLY_RecurrencePattern, *result.RecurringInfo.RecurrencePattern)
assert.True(t, result.RecurringInfo.UseEndDate)
assert.False(t, result.RecurringInfo.MonthlyUseOrdinalDay)
assert.Equal(t, int32(1), result.RecurringInfo.MonthlyDay)
assert.Equal(t, models.NONE_WeekDayType, *result.RecurringInfo.WeeklyDays)
assert.Equal(t, models.SECOND_OrdinalNumber, *result.RecurringInfo.YearlyOrdinalNumber)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetTasksOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetTasks(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Tasks)
assert.Equal(t, 6, len(result.Tasks.TaskItem))
var firstTask models.TaskItem
for _, t := range result.Tasks.TaskItem {
if t.Uid == 5 {
firstTask = t
break
}
}
assert.NotNil(t, firstTask)
assert.Equal(t, "Summary Task 1", firstTask.Name)
assert.Equal(t, CreateTime(2015, 8, 3, 8, 0, 0), firstTask.Start)
assert.Equal(t, CreateTime(2015, 8, 6, 17, 0, 0), firstTask.Finish)
assert.Equal(t, "/5", firstTask.Link.Href)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetTaskTimephasedDataOpts{
TaskUid: 27,
Type_: optional.NewString(string(models.TASK_WORK_TimephasedDataType)),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetTaskTimephasedData(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Items)
assert.LessOrEqual(t, 1, len(result.Items))
for _, timephasedData := range result.Items {
assert.Equal(t, models.TASK_WORK_TimephasedDataType, *timephasedData.TimephasedDataType)
assert.Equal(t, int32(27), timephasedData.Uid)
}
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.GetVbaProjectOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetVbaProject(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.VbaProject)
assert.NotNil(t, result.VbaProject.Modules)
assert.Equal(t, 7, len(result.VbaProject.Modules))
assert.Equal(t, "Module1", result.VbaProject.Modules[0].Name)
assert.True(t, strings.HasPrefix(result.VbaProject.Modules[0].SourceCode, "Type MEMORYSTATUS"))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
postAssignmentOpts := &requests.PostAssignmentOpts{
ResourceUid: 1,
Units: optional.NewFloat64(0.5),
TaskUid: 0,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.PostAssignment(ctx, postAssignmentOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.AssignmentItem)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
postAssignmentOpts := &requests.PostAssignmentOpts{
ResourceUid: 1,
Cost: optional.NewFloat32(2),
TaskUid: 0,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.PostAssignment(ctx, postAssignmentOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.AssignmentItem)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
firstDayType := models.SUNDAY_DayType
secondDayType := models.MONDAY_DayType
newFirstWorkingTime := models.WorkingTime{
FromTime: CreateTime(1, 1, 1, 8, 0, 0),
ToTime: CreateTime(1, 1, 1, 13, 0, 0),
}
newSecondWorkingTime := models.WorkingTime{
FromTime: CreateTime(1, 1, 1, 14, 0, 0),
ToTime: CreateTime(1, 1, 1, 17, 0, 0),
}
postCalendarOpts := &requests.PostCalendarOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
Calendar: models.Calendar{
Name: "My new calendar",
IsBaseCalendar: false,
IsBaselineCalendar: false,
Days: []models.WeekDay{
{
DayType: &firstDayType,
DayWorking: false,
},
{
DayType: &secondDayType,
DayWorking: true,
FromDate: CreateTime(1, 1, 1, 8, 0, 0),
ToDate: CreateTime(1, 1, 1, 17, 0, 0),
WorkingTimes: []models.WorkingTime{
newFirstWorkingTime,
newSecondWorkingTime,
},
},
},
},
}
postResult, _, err := client.TasksApi.PostCalendar(ctx, postCalendarOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(201), postResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
newExceptionType := models.MONTHLY_BY_DAY_CalendarExceptionType
newMonthItemType := models.UNDEFINED_MonthItemType
newMonthPosition := models.UNDEFINED_MonthPosition
newMonth := models.UNDEFINED_Month
newException := models.CalendarException{
Name: "Non-working day exception",
DayWorking: false,
FromDate: CreateTime(2014, 10, 27, 0, 0, 0),
ToDate: CreateTime(2015, 8, 5, 23, 59, 0),
Occurrences: 10,
Type_: &newExceptionType,
MonthItem: &newMonthItemType,
MonthPosition: &newMonthPosition,
Month: &newMonth,
EnteredByOccurrences: true,
MonthDay: 5,
Period: 1,
}
postResult, _, err := client.TasksApi.PostCalendarException(ctx, &requests.PostCalendarExceptionOpts{
CalendarUid: 1,
CalendarException: newException,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(201), postResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
postOptions := &requests.PostDocumentPropertyOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PropertyName: "Title",
Property: models.DocumentProperty{
Name: "Title",
Value: "New title value",
},
}
postResult, _, err := client.TasksApi.PostDocumentProperty(ctx, postOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), postResult.Code)
assert.NotNil(t, postResult.Property)
assert.Equal(t, "Title", postResult.Property.Name)
assert.Equal(t, "New title value", postResult.Property.Value)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
postOptions := &requests.PostDocumentPropertyOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PropertyName: "new property",
Property: models.DocumentProperty{
Name: "new property",
Value: "new property value",
},
}
postResult, _, err := client.TasksApi.PostDocumentProperty(ctx, postOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), postResult.Code)
assert.Nil(t, postResult.Property)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
postOpts := &requests.PostResourceOpts{
ResourceName: optional.NewString("new resource"),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
postResult, _, err := client.TasksApi.PostResource(ctx, postOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(201), postResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
postTaskOpts := &requests.PostTaskOpts{
Name: remoteFileName,
TaskName: optional.NewString("New task name"),
BeforeTaskId: optional.NewInt32(4),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
postResult, _, err := client.TasksApi.PostTask(ctx, postTaskOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(201), postResult.Code)
assert.NotNil(t, postResult.TaskItem)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
// SaveOptions parameters is a 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
type (
Column = struct {
Type string
Name string
Property string
Width int
}
View = struct {
Columns []Column
}
saveOptions = struct {
TextDelimiter string
IncludeHeaders bool
NonExistingTestProperty bool
View View
}
)
so := saveOptions{
"Comma",
false,
false,
View{
[]Column{
{"GanttChartColumn", "TestColumn1", "Name", 120},
{"GanttChartColumn", "TestColumn2", "Duration", 120},
},
},
}
opts := &requests.PostTaskDocumentWithFormatOpts{
Name: remoteFileName,
SaveOptions: so,
Format: string(models.CSV_ProjectFileFormat),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
data, response, err := client.TasksApi.PostTaskDocumentWithFormat(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, 200, response.StatusCode)
assert.NotNil(t, data)
assert.Less(t, 1, len(data))
fileAsStrings := ConvertBytesToStrings(data)
assert.Equal(t, "Five to Eight Weeks Before Moving,16 days", fileAsStrings[0])
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getResult, _, err := client.TasksApi.GetAssignment(ctx, &requests.GetAssignmentOpts{
AssignmentUid: 63,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
assert.NotNil(t, getResult.Assignment)
getResult.Assignment.TaskUid = 0
putResponse, _, err := client.TasksApi.PutAssignment(ctx, &requests.PutAssignmentOpts{
Mode: optional.NewString(string(models.AUTOMATIC_CalculationMode)),
Recalculate: optional.NewBool(true),
AssignmentUid: 63,
Assignment: *getResult.Assignment,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
assert.Equal(t, int32(200), putResponse.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getResult, _, err := client.TasksApi.GetAssignment(ctx, &requests.GetAssignmentOpts{
AssignmentUid: 63,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
assert.NotNil(t, getResult.Assignment)
getResult.Assignment.Cost = 100
getResult.Assignment.Start = CreateTime(2001, 9, 10, 0, 0, 0)
getResult.Assignment.Finish = CreateTime(2002, 9, 10, 0, 0, 0)
newBaselineType := models.BASELINE1_BaselineType
newStart := CreateTime(2002, 9, 10, 0, 0, 0)
getResult.Assignment.Baselines = []models.AssignmentBaseline{
{
BaselineNumber: &newBaselineType,
Start: &newStart,
},
}
allocatedActualWork := "10:10:10"
getResult.Assignment.ActualWork = &allocatedActualWork
getResult.Assignment.ActualCost = 100
getResult.Assignment.ActualStart = CreateTime(2001, 9, 10, 0, 0, 0)
getResult.Assignment.ActualFinish = CreateTime(2002, 9, 10, 0, 0, 0)
allocatedOvertimeActualWork := "100:10:10"
getResult.Assignment.ActualOvertimeWork = &allocatedOvertimeActualWork
allocatedWork := "80:10:10"
getResult.Assignment.Work = &allocatedWork
getResult.Assignment.Uid = 63
getResult.Assignment.Vac = 10
newWorkContourType := models.CONTOURED_WorkContourType
getResult.Assignment.WorkContour = &newWorkContourType
newTimeUnitType := models.HOUR_TimeUnitType
newTimephasedDataType := models.ASSIGNMENT_REMAINING_WORK_TimephasedDataType
getResult.Assignment.TimephasedData = []models.TimephasedData{
{
Uid: getResult.Assignment.Uid,
Start: CreateTime(2001, 9, 10, 9, 0, 0),
Finish: CreateTime(2001, 9, 10, 14, 0, 0),
Unit: &newTimeUnitType,
Value: "4:0:0",
TimephasedDataType: &newTimephasedDataType,
},
}
putResponse, _, err := client.TasksApi.PutAssignment(ctx, &requests.PutAssignmentOpts{
Mode: optional.NewString(string(models.NONE_CalculationMode)),
Recalculate: optional.NewBool(false),
AssignmentUid: getResult.Assignment.Uid,
Assignment: *getResult.Assignment,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResponse.Code)
assert.NotNil(t, putResponse.Assignment)
assert.Equal(t, getResult.Assignment.Uid, putResponse.Assignment.Uid)
assert.Equal(t, getResult.Assignment.Vac, putResponse.Assignment.Vac)
assert.NotEqual(t, getResult.Assignment.Cost, putResponse.Assignment.Cost, "Calculated fields must be overwritten")
assert.Equal(t, getResult.Assignment.Start, putResponse.Assignment.Start)
assert.Equal(t, getResult.Assignment.Finish, putResponse.Assignment.Finish)
assert.Equal(t, "80.10:10:00", *putResponse.Assignment.Work)
assert.Equal(t, *getResult.Assignment.ActualWork, *putResponse.Assignment.ActualWork)
assert.Equal(t, getResult.Assignment.ActualStart, putResponse.Assignment.ActualStart)
assert.Equal(t, getResult.Assignment.ActualFinish, putResponse.Assignment.ActualFinish)
assert.Equal(t, "100.10:10:00", *putResponse.Assignment.ActualOvertimeWork)
assert.Equal(t, 1, len(putResponse.Assignment.Baselines))
assert.Equal(t, models.BASELINE1_BaselineType, *putResponse.Assignment.Baselines[0].BaselineNumber)
assert.Equal(t, getResult.Assignment.Baselines[0].Start, putResponse.Assignment.Baselines[0].Start)
assert.Equal(t, 1, len(putResponse.Assignment.TimephasedData))
assert.Equal(t, getResult.Assignment.TimephasedData[0].Uid, putResponse.Assignment.TimephasedData[0].Uid)
assert.Equal(t, "PT4H0M0S", putResponse.Assignment.TimephasedData[0].Value)
assert.Equal(t, getResult.Assignment.TimephasedData[0].Start, putResponse.Assignment.TimephasedData[0].Start)
assert.Equal(t, getResult.Assignment.TimephasedData[0].Finish, putResponse.Assignment.TimephasedData[0].Finish)
assert.Equal(t, getResult.Assignment.TimephasedData[0].TimephasedDataType, putResponse.Assignment.TimephasedData[0].TimephasedDataType)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
firstDayType := models.SUNDAY_DayType
secondDayType := models.MONDAY_DayType
newFirstWorkingTime := models.WorkingTime{
FromTime: CreateTime(1, 1, 1, 8, 0, 0),
ToTime: CreateTime(1, 1, 1, 13, 0, 0),
}
newSecondWorkingTime := models.WorkingTime{
FromTime: CreateTime(1, 1, 1, 14, 0, 0),
ToTime: CreateTime(1, 1, 1, 17, 0, 0),
}
putCalendarOpts := &requests.PutCalendarOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
CalendarUid: 1,
Calendar: models.Calendar{
Uid: 1,
Name: "Modified calendar",
IsBaseCalendar: false,
IsBaselineCalendar: false,
Days: []models.WeekDay{
{
DayType: &firstDayType,
DayWorking: false,
},
{
DayType: &secondDayType,
DayWorking: true,
FromDate: CreateTime(1, 1, 1, 8, 0, 0),
ToDate: CreateTime(1, 1, 1, 17, 0, 0),
WorkingTimes: []models.WorkingTime{
newFirstWorkingTime,
newSecondWorkingTime,
},
},
},
},
}
putResult, _, err := client.TasksApi.PutCalendar(ctx, putCalendarOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getResult, _, err := client.TasksApi.GetCalendarExceptions(ctx, &requests.GetCalendarExceptionsOpts{
CalendarUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
exception := &getResult.CalendarExceptions[0]
exception.WorkingTimes = []models.WorkingTime{
{
FromTime: CreateTime(1, 1, 1, 9, 0, 0),
ToTime: CreateTime(1, 1, 1, 17, 0, 0),
},
}
exception.DaysOfWeek = []models.DayType{models.THURSDAY_DayType, models.FRIDAY_DayType}
exception.Occurrences = 10
exception.EnteredByOccurrences = true
exception.Period = 1
exception.Name = "Non-working day exception"
exception.DayWorking = true
exception.FromDate = CreateTime(2014, 10, 27, 0, 0, 0)
exception.ToDate = CreateTime(2015, 8, 5, 23, 59, 0)
putResult, _, err := client.TasksApi.PutCalendarException(ctx, &requests.PutCalendarExceptionOpts{
CalendarUid: 1,
Index: exception.Index,
CalendarException: *exception,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
putOptions := &requests.PutDocumentPropertyOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PropertyName: "Title",
Property: models.DocumentProperty{
Name: "Title",
Value: "New title value",
},
}
putResult, _, err := client.TasksApi.PutDocumentProperty(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
assert.NotNil(t, putResult.Property)
assert.Equal(t, "Title", putResult.Property.Name)
assert.Equal(t, "New title value", putResult.Property.Value)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
firstValue := models.Value{
Description: "descr1",
Val: "Internal",
Id: 111,
}
secondValue := models.Value{
Description: "descr2",
Val: "External",
Id: 112,
}
newCalculationType := models.LOOKUP_CalculationType
newCfType := models.TEXT_CustomFieldType
newElementType := models.TASK_ElementType
newRollupType := models.NULL_RollupType
newExtendedAttribute := models.ExtendedAttributeDefinition{
CalculationType: &newCalculationType,
CfType: &newCfType,
ElementType: &newElementType,
RollupType: &newRollupType,
FieldName: "Text3",
Alias: "New Field",
ValueList: []models.Value{firstValue, secondValue},
}
putResult, _, err := client.TasksApi.PutExtendedAttribute(ctx, &requests.PutExtendedAttributeOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
ExtendedAttribute: newExtendedAttribute,
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
assert.NotNil(t, putResult.ExtendedAttribute)
assert.Equal(t, newExtendedAttribute.FieldName, putResult.ExtendedAttribute.FieldName)
assert.Equal(t, newExtendedAttribute.Alias, putResult.ExtendedAttribute.Alias)
assert.Equal(t, "188743737", putResult.ExtendedAttribute.FieldId)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := PrepareTest(t, config)
putOptions := &requests.PutImportProjectFromDbOpts{
ConnectionString: "Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;",
DatabaseType: string(models.MSP_ProjectDatabaseType),
Filename: "imported_from_db.xml",
Folder: optional.NewString(remoteBaseTestDataFolder),
ProjectUid: "E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
DatabaseSchema: optional.NewString("dbo"),
Format: optional.NewString(string(models.P6XML_ProjectFileFormat)),
}
putProjectResult, _, err := client.TasksApi.PutImportProjectFromDb(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putProjectResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
putOptions := &requests.PutImportProjectFromFileOpts{
Name: remoteFileName,
ProjectUid: "111",
Filename: "imported_from_primavera.xml",
Folder: optional.NewString(remoteBaseTestDataFolder),
FileType: optional.NewString(string(models.PRIMAVERA_XML_ImportedProjectType)),
OutputFileFormat: optional.NewString(string(models.P6XML_ProjectFileFormat)),
}
putProjectResult, _, err := client.TasksApi.PutImportProjectFromFile(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putProjectResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := PrepareTest(t, config)
putOptions := &requests.PutImportProjectFromProjectOnlineOpts{
Name: "NewProductDev.mpp",
Guid: "E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
SiteUrl: "http://project_server_instance.local/sites/pwa",
XProjectOnlineToken: optional.NewString("SOMESECRETTOKEN"),
Format: optional.NewString(string(models.P6XML_ProjectFileFormat)),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putProjectResult, _, err := client.TasksApi.PutImportProjectFromProjectOnline(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putProjectResult.Code)
file, response, err := client.TasksApi.DownloadFile(ctx, &requests.DownloadFileOpts{
Path: putOptions.Folder.Value() + "/" + putOptions.Name,
})
if err != nil {
t.Error(err)
}
assert.Equal(t, 200, response.StatusCode)
assert.Less(t, 1, len(file))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := PrepareTest(t, config)
putOptions := &requests.PutImportProjectFromProjectOnlineOpts{
Name: "NewProductDev.mpp",
Guid: "E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
SiteUrl: "http://project_server_instance.local/sites/pwa",
UserName: optional.NewString("SomeLogin"),
XSharepointPassword: optional.NewString("SomePassword"),
Format: optional.NewString(string(models.P6XML_ProjectFileFormat)),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putProjectResult, _, err := client.TasksApi.PutImportProjectFromProjectOnline(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putProjectResult.Code)
file, response, err := client.TasksApi.DownloadFile(ctx, &requests.DownloadFileOpts{
Path: putOptions.Folder.Value() + "/" + putOptions.Name,
})
if err != nil {
t.Error(err)
}
assert.Equal(t, 200, response.StatusCode)
assert.Less(t, 1, len(file))
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getOpts := &requests.GetTaskOpts{
TaskUid: 6,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
getResult, _, err := client.TasksApi.GetTask(ctx, getOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
assert.NotNil(t, getResult.Task)
for _, uid := range getResult.Task.SubtasksUids {
assert.NotEqual(t, int32(10), uid)
}
putMoveOpts := &requests.PutMoveTaskOpts{
TaskUid: 10,
ParentTaskUid: getOpts.TaskUid,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putMoveResult, _, err := client.TasksApi.PutMoveTask(ctx, putMoveOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putMoveResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
putMoveToSiblingOpts := &requests.PutMoveTaskToSiblingOpts{
TaskUid: 40,
BeforeTaskUid: 41,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putMoveToSiblingResult, _, err := client.TasksApi.PutMoveTaskToSibling(ctx, putMoveToSiblingOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putMoveToSiblingResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
putRecalculateOpts := &requests.PutRecalculateProjectOpts{
Name: remoteFileName,
Mode: optional.NewString(string(models.NONE_CalculationMode)),
Validate: optional.NewBool(true),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putRecalculateResult, _, err := client.TasksApi.PutRecalculateProject(ctx, putRecalculateOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putRecalculateResult.Code)
assert.Equal(t, models.VALID_ProjectValidationState, *putRecalculateResult.Result.ValidationState)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.PutRecalculateProjectResourceFieldsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.PutRecalculateProjectResourceFields(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.PutRecalculateProjectUncompleteWorkToStartAfterOpts{
After: CreateTime(2010, 10, 10, 0, 0, 0),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.PutRecalculateProjectUncompleteWorkToStartAfter(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
opts := &requests.PutRecalculateProjectWorkAsCompleteOpts{
CompleteThrough: CreateTime(2010, 10, 10, 0, 0, 0),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.PutRecalculateProjectWorkAsComplete(ctx, opts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getOpts := &requests.GetResourceOpts{
ResourceUid: 1,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
getResult, _, err := client.TasksApi.GetResource(ctx, getOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
assert.NotNil(t, getResult.Resource)
newBaselineNumber := models.BASELINE1_BaselineType
newBaseline := models.Baseline{
BaselineNumber: &newBaselineNumber,
Cost: 44,
}
getResult.Resource.Name = "Modified Resource1"
getResult.Resource.Cost = 200
getResult.Resource.Start = CreateTime(2000, 10, 10, 0, 0, 0)
newWork := "4.04:10:00"
getResult.Resource.Work = &newWork
newOvertimeWork := "4.04:00:00"
getResult.Resource.OvertimeWork = &newOvertimeWork
newWorkgroup := models.NONE_WorkGroupType
getResult.Resource.Workgroup = &newWorkgroup
getResult.Resource.StandardRate = 101
getResult.Resource.Finish = CreateTime(2000, 10, 10, 0, 0, 0)
getResult.Resource.Baselines = []models.Baseline{newBaseline}
putOpts := &requests.PutResourceOpts{
ResourceUid: 1,
Resource: *getResult.Resource,
Recalculate: optional.NewBool(false),
Mode: optional.NewString(string(models.NONE_CalculationMode)),
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putResult, _, err := client.TasksApi.PutResource(ctx, putOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
assert.Equal(t, 1, len(putResult.Resource.Baselines))
assert.Equal(t, *newBaseline.BaselineNumber, *putResult.Resource.Baselines[0].BaselineNumber)
assert.Equal(t, newBaseline.Cost, putResult.Resource.Baselines[0].Cost)
assert.Equal(t, getResult.Resource.StandardRate, putResult.Resource.StandardRate)
assert.Equal(t, getResult.Resource.Start, putResult.Resource.Start)
assert.Equal(t, getResult.Resource.Finish, putResult.Resource.Finish)
assert.Equal(t, *getResult.Resource.Work, *putResult.Resource.Work)
assert.Equal(t, *getResult.Resource.Workgroup, *putResult.Resource.Workgroup)
assert.Equal(t, *getResult.Resource.OvertimeWork, *putResult.Resource.OvertimeWork)
assert.Equal(t, getResult.Resource.Cost, putResult.Resource.Cost)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
getTaskOpts := &requests.GetTaskOpts{
TaskUid: 4,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
getResult, _, err := client.TasksApi.GetTask(ctx, getTaskOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
assert.NotNil(t, getResult.Task)
taskToModify := getResult.Task
taskToModify.Name = "Modified task name"
taskToModify.IsManual = true
taskToModify.ManualStart = CreateTime(2015, 10, 1, 9, 15, 0)
taskToModify.ManualFinish = CreateTime(2015, 10, 1, 17, 15, 0)
putTaskOpts := &requests.PutTaskOpts{
TaskUid: getTaskOpts.TaskUid,
Recalculate: optional.NewBool(false),
Mode: optional.NewString(string(models.NONE_CalculationMode)),
Task: *taskToModify,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putResult, _, err := client.TasksApi.PutTask(ctx, putTaskOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.UpdateProjectOpts{
Name: remoteFileName,
SiteUrl: "http://project_server_instance.local/sites/pwa",
UserName: optional.NewString("SomeLogin"),
XSharepointPassword: optional.NewString("SomePassword"),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.UpdateProject(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
options := &requests.UpdateProjectOpts{
Name: remoteFileName,
SiteUrl: "http://project_server_instance.local/sites/pwa",
XProjectOnlineToken: optional.NewString("SOMESECRETTOKEN"),
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.UpdateProject(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment