Cant' create task without start and end date and empty duration


#1

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


#2

@LogicSoft,

I have observed your requirements and request you to please visit this documentation link to serve the purpose on your end.


#3

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


#4

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)


#5

@LogicSoft,

We are working on this and will share feedback soon.


#6

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.


#7

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


#8

Thank you! Can you share the code sample you are using to create the files?