Hi, I have a trouble in creating a task. I want create task without start and end date.
var license = new License();
Stream licenseStream =
Assembly.GetExecutingAssembly().GetManifestResourceStream(
"Aspose_test_Solution.Aspose.Tasks.lic");
license.SetLicense(licenseStream);
var project = new Project();
var task = project.RootTask.Children.Add("Task without dates");
// we need have empty task without start date , end date and duration, just empty task
task.Set(Tsk.DurationText, string.Empty); // don't clean duration Why and how do it?
task.Set(Tsk.FinishText, string.Empty);
task.Set(Tsk.ActualFinish, DateTime.MinValue);
task.Set(Tsk.ActualStart, DateTime.MinValue);
task.Set(Tsk.StartText, string.Empty);
project.Save("a2.XML", SaveFileFormat.XML);
But I get Task with duration 1 and not empty start and end date
@LogicSoft,
I have observed your requirements and request you to please visit this documentation link to serve the purpose on your end.
Hello @LogicSoft
You can add empty task as follows
var license = new License();
Stream licenseStream =
Assembly.GetExecutingAssembly().GetManifestResourceStream(
"Aspose_test_Solution.Aspose.Tasks.lic");
license.SetLicense(licenseStream);
var project = new Project{CalculationMode = CalculationMode.Manual};
project.Set(Prj.StartDate, new DateTime(2019, 7, 30, 8, 0, 0));
project.Set(Prj.NewTasksAreManual, true);
var task = project.RootTask.Children.Add("Task without dates");
task.Set(Tsk.IsManual, true);
task.Set(Tsk.DurationFormat, TimeUnitType.Null);
task.Set(Tsk.ManualStart, DateTime.MinValue);
task.Set(Tsk.ManualFinish, DateTime.MinValue);
task.Set(Tsk.Duration, project.GetDuration(0));
task.Set(Tsk.ManualDuration, project.GetDuration(0));
task.Set(Tsk.RemainingDuration, project.GetDuration(8, TimeUnitType.Hour));
task.Set(Tsk.StartText, "");
task.Set(Tsk.FinishText, "");
task.Set(Tsk.DurationText, "");
project.Save("out.xml", SaveFileFormat.XML);
Unfortunately, there is no abilito to set task duration to the empty, only to 0 day. But we will handle with it in future releases
Unfortunately, we don’t want use manual data management for setting dates. I have 2 exported files with old code and new + your advises how to set empty dates, and have different result. I expect to get same result like before.Sample Project - 1st Training Rollout_201907311045.zip (52.1 KB)
@LogicSoft,
We are working on this and will share feedback soon.
BTW, what of the files you sent is correct? Please attach yout MPP file and your C# code sample and we will try to help you.
File Sample Project - 1st Training Rollout_201907311045.xml is correct was created by Aspose.Tasks 2009 for .NET 6.2.0.0
Second was created by Published by Aspose.Tasks for .NET 19.7 the same code + advices
Thank you! Can you share the code sample you are using to create the files?
Hi, Can u also share Code sample for JAVA
@parthpithadia
Can you please share which sample code you are referring to for Java.
@parthpithadia
Please use the following Java implementation for required sample code.
public static void TestTaskWithoutDate() throws Exception
{
License license = new License();
license.setLicense("Aspose_test_Solution.Aspose.Tasks.lic");
Project project = new Project();
//Setting Calculation mode
project.setCalculationMode(CalculationMode.Manual);
java.util.Calendar calTimeStart = java.util.Calendar.getInstance();
calTimeStart.set(2019, 7, 30, 8, 0, 0);
//Setting Minimum date
java.util.Calendar calTimeMin = java.util.Calendar.getInstance();
calTimeMin.setTime(new Date(0L));
project.set(Prj.START_DATE, calTimeStart.getTime());
project.set(Prj.NEW_TASKS_ARE_MANUAL, new NullableBool(true));
Task task = project.getRootTask().getChildren().add("Task without dates");
task.set(Tsk.IS_MANUAL, new NullableBool(true));
task.set(Tsk.DURATION_FORMAT, TimeUnitType.Null);
task.set(Tsk.MANUAL_START, calTimeMin.getTime());
task.set(Tsk.MANUAL_FINISH, calTimeMin.getTime());
task.set(Tsk.DURATION, project.getDuration(0));
task.set(Tsk.MANUAL_DURATION, project.getDuration(0));
task.set(Tsk.REMAINING_DURATION, project.getDuration(8, TimeUnitType.Hour));
task.set(Tsk.START_TEXT, "");
task.set(Tsk.FINISH_TEXT, "");
task.set(Tsk.DURATION_TEXT, "");
project.save("out.xml", SaveFileFormat.XML);
}