WorkWeek Class

Represent WorkWeek class
Inheritance Hierarchy
SystemObject
  Aspose.TasksWorkWeek

Namespace:  Aspose.Tasks
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.10
Syntax
public class WorkWeek

The WorkWeek type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleWorkWeek
Initializes a new instance of the WorkWeek class.
Public methodWorkWeek(Calendar) Obsolete.
Initializes a new instance of the WorkWeek class.
Properties
  NameDescription
Public propertyCode exampleFromDate
Gets or sets start DateTime of work week
Public propertyCode exampleName
Gets or sets Name of work week
Public propertyCode exampleToDate
Gets or sets Finish DateTime of work week
Public propertyCode exampleWeekDays
Gets week days.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to read work week information from the project.
var project = new Project();
var calendar = project.Calendars.Add("Standard");
Calendar.MakeStandardCalendar(calendar);

var item = new WorkWeek();
item.Name = "My Work Week";
item.FromDate = new DateTime(2020, 4, 13, 8, 0, 0);
item.ToDate = new DateTime(2020, 4, 17, 17, 0, 0);
item.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
item.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
item.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
item.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday));
item.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday));
item.WeekDays.Add(new WeekDay(DayType.Saturday));
item.WeekDays.Add(new WeekDay(DayType.Sunday));
calendar.WorkWeeks.Add(item);

Console.WriteLine("Work Week Number: " + calendar.WeekDays.Count);
foreach (var workWeek in calendar.WorkWeeks)
{
    // Display work week name, parent calendar name, from, and to dates
    Console.WriteLine("Name: " + workWeek.Name);
    Console.WriteLine("Parent calendar name: " + calendar.Name);
    Console.WriteLine("From Date: " + workWeek.FromDate);
    Console.WriteLine("To Date: " + workWeek.ToDate);
    Console.WriteLine();

    // This data is all about "Details." button you can set special working times for special WeekDay or even make it nonworking
    List<WeekDay> weekDays = workWeek.WeekDays.ToList();
    foreach (var day in weekDays)
    {
        Console.WriteLine(day.DayType.ToString());

        // You can further traverse through working times and display these
        foreach (var workingTime in day.WorkingTimes)
        {
            Console.WriteLine(workingTime.FromTime);
            Console.WriteLine(workingTime.ToTime);
        }
    }

    Console.WriteLine();
}
See Also