Aspose.Tasks for C++
Calendar.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="Calendar.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2025 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/string.h>
9 #include <system/nullable.h>
10 #include <system/iequatable.h>
11 #include <system/guid.h>
12 #include <system/date_time.h>
13 #include <cstdint>
14 
15 #include "aspose.tasks.cpp/NullableBool.h"
16 #include "aspose.tasks.cpp/ICalendar.h"
17 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
18 
19 namespace Aspose
20 {
21 namespace Tasks
22 {
23 class AssignmentBaseline;
24 class AutoRecalculationState;
25 class BaselineTimephasedDataMaker;
26 namespace Calculations
27 {
28 class RescheduleIncompleteWorkCalculator;
29 class ResourceAssignmentCalculator;
30 class ResourceAssignmentPeakCalculator;
31 class ResourceCalculator;
32 class ResourceOverAllocationCalculator;
33 class TaskStatusCalculator;
34 class TimephasedDataCalculator;
35 class TimeScaledCalculator;
36 } // namespace Calculations
37 class CalendarCollection;
38 class CalendarDatesCalculator;
39 class CalendarException;
40 class CalendarExceptionCollection;
41 class CalendarExceptionCollectionWithCache;
42 namespace Connectivity
43 {
44 class MpdCalendarMapper;
45 class MspCalendarMapper;
46 class MspDbUtils;
47 class PmCalendarMapper;
48 class PrimaveraDbReader;
49 } // namespace Connectivity
50 class DailyCalendarRepetition;
51 class DailyWorkRepetition;
52 class DatesCalculator;
53 enum class DayType;
54 class Duration;
55 class EVCalculator;
56 namespace Filters
57 {
58 class CalendarRootFilter;
59 } // namespace Filters
60 template <typename, typename> class IKeyValueCache;
61 class IntersectedCalendar;
62 namespace IO
63 {
64 namespace Html
65 {
66 class HtmlCalendarTableReader;
67 } // namespace Html
68 namespace Mpx
69 {
70 class MpxReader;
71 } // namespace Mpx
72 namespace MSProject
73 {
74 class Mpp12CalendarReader;
75 class Mpp12CalendarWriter;
76 class MPP12Reader;
77 class Mpp14CalendarReader;
78 class Mpp14CalendarWriter;
79 class MPP14Reader;
80 class MPP14ResourceWriter;
81 class Mpp15CalendarReader;
82 class Mpp15CalendarWriter;
83 class Mpp9CalendarReader;
84 class Mpp9CalendarWriter;
85 class MPP9Reader;
86 class MppCalendarReader;
87 class MPPProjectPropsReader;
88 class MPPProjectPropsWriter;
89 class MPPReader;
90 class MPPResourceReader;
91 class MPPTaskWriter;
92 class MPPTimephasedDataReader;
93 class MppTimephasedDataWriter;
94 class MppWeekDayReader;
95 } // namespace MSProject
96 namespace PrimaveraXml
97 {
98 class P6XmlUtils;
99 class PrimaveraCalendarNodeReader;
100 class PrimaveraReader;
101 class PrimaveraResourceNodeReader;
102 } // namespace PrimaveraXml
103 namespace Pwa
104 {
105 namespace InternalApi
106 {
107 class InternalApiProjectSerializer;
108 namespace Mapping
109 {
110 class CalendarToRawValuesMapper;
111 class ProjectCalendarsMapper;
112 class ProjectRootMapper;
113 } // namespace Mapping
114 } // namespace InternalApi
115 } // namespace Pwa
116 namespace Xer
117 {
118 class XerAssignmentReader;
119 class XerCalendarReader;
120 class XerPrimaveraReader;
121 class XerProjectNormalizer;
122 } // namespace Xer
123 namespace Xml
124 {
125 class CalendarFactory;
126 class CalendarNodeReader;
127 class CalendarNodeWriter;
128 class ResourceNodeReader;
129 class TaskNodeReader;
130 class TimephasedDataNodeReader;
131 class WeekDayNodeReader;
132 class XmlReader;
133 class XmlWriter;
134 } // namespace Xml
135 } // namespace IO
136 class IReadOnlyWorkingTimeCollection;
137 class ManualState;
138 class MonthlyRepetitionBase;
139 class NullableBool;
140 class PercentCompleteCalculator;
141 class Project;
142 class ProjectIntegrityValidator;
143 class ProjectState;
144 class ProjectWorkUpdater;
145 namespace Recalculation
146 {
147 class TaskSplitCalculator;
148 } // namespace Recalculation
149 namespace Recurring
150 {
151 namespace Calculators
152 {
153 class CalendarDayRecurrenceDateCalculator;
154 class DefaultRecurrenceDateCalculator;
155 class RecurrenceDateCalculatorBase;
156 } // namespace Calculators
157 } // namespace Recurring
158 class Resource;
159 class ResourceAssignment;
160 namespace Saving
161 {
162 class HtmlCalendarTable;
163 class MpxWriter;
164 class PrimaveraCalendarNodeWriter;
165 class XerCalendarTable;
166 } // namespace Saving
167 namespace Scheduling
168 {
169 class ConstraintSolver;
170 class FromStartScheduler;
171 class TopsortCriticalPath;
172 } // namespace Scheduling
173 class SplitsCalculator;
174 class Task;
175 class TaskBaseline;
176 class TaskPlanner;
177 class TaskPlannerAssignmentManager;
178 class TaskWarningCalculator;
179 namespace Timephased
180 {
181 class TimephasedDataByScaledEnumerator;
182 class TimeScaledWorkContourBuilder;
183 } // namespace Timephased
184 class TimephasedDataByScaledMaker;
185 class TimephasedDataCalculationUtil;
186 class TimephasedDataMaker;
187 class TimephasedWorkCostSelector;
188 class TimeScaledExceptions;
189 template <typename> class TimeScaledParentUnit;
190 namespace Util
191 {
192 class CalendarHelper;
193 } // namespace Util
194 namespace Validators
195 {
196 class RecurringTaskParametersValidator;
197 } // namespace Validators
198 class WeekDay;
199 class WeekDayCollection;
200 class WeeklyRepetitionBase;
201 class WorkingTimeCollection;
202 class WorkUnit;
203 class WorkWeekCollection;
204 class YearlyRepetitionBase;
205 } // namespace Tasks
206 } // namespace Aspose
207 namespace System
208 {
209 class TimeSpan;
210 } // namespace System
211 
212 namespace Aspose {
213 
214 namespace Tasks {
215 
216 /// <summary>
217 /// Represents a calendar used in a project.
218 /// </summary>
219 /// <example>
220 /// How to create simple calendar from scratch.
221 /// <code>
222 /// [C#]
223 /// // create empty calendar
224 /// Calendar calendar = new Calendar("New calendar");
225 /// // adds default working days (8 working hours from 9:00 to 17:00)
226 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
227 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
228 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
229 /// // create new new working day
230 /// WeekDay myWeekDay = new WeekDay(DayType.Thursday);
231 /// // Sets working time. Only time part of DateTime is important
232 /// WorkingTime wt1 = new WorkingTime();
233 /// wt1.FromTime = new DateTime(1, 1, 1, 6, 0, 0, 0);
234 /// wt1.ToTime = new DateTime(1, 1, 1, 12, 0, 0, 0);
235 /// WorkingTime wt2 = new WorkingTime();
236 /// wt2.FromTime = new DateTime(1, 1, 1, 14, 0, 0, 0);
237 /// wt2.ToTime = new DateTime(1, 1, 1, 18, 0, 0, 0);
238 /// myWeekDay.WorkingTimes.Add(wt1);
239 /// myWeekDay.WorkingTimes.Add(wt2);
240 /// myWeekDay.DayWorking = true;
241 /// calendar.Days.Add(myWeekDay);
242 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday));
243 /// // adds weekend
244 /// calendar.Days.Add(new WeekDay(DayType.Saturday));
245 /// calendar.Days.Add(new WeekDay(DayType.Sunday));
246 /// </code>
247 /// <code>
248 /// [VB]
249 /// ' create empty calendar
250 /// Dim calendar As Calendar = New Calendar("New calendar")
251 /// ' adds default working days (8 working hours from 9:00 to 17:00)
252 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday))
253 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday))
254 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday))
255 /// ' create new new working day
256 /// Dim myWeekDay As WeekDay = New WeekDay(DayType.Thursday)
257 /// ' Sets working time. Only time part of DateTime is important
258 /// Dim wt1 As WorkingTime = New WorkingTime()
259 /// wt1.FromTime = New DateTime(1, 1, 1, 6, 0, 0, 0)
260 /// wt1.ToTime = New DateTime(1, 1, 1, 12, 0, 0, 0)
261 /// Dim wt2 As WorkingTime = New WorkingTime()
262 /// wt2.FromTime = New DateTime(1, 1, 1, 14, 0, 0, 0)
263 /// wt2.ToTime = New DateTime(1, 1, 1, 18, 0, 0, 0)
264 /// myWeekDay.WorkingTimes.Add(wt1)
265 /// myWeekDay.WorkingTimes.Add(wt2)
266 /// myWeekDay.DayWorking = True
267 /// calendar.Days.Add(myWeekDay)
268 /// calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday))
269 /// ' adds weekend
270 /// calendar.Days.Add(New WeekDay(DayType.Saturday))
271 /// calendar.Days.Add(New WeekDay(DayType.Sunday))
272 /// </code>
273 /// </example>
274 /// <remarks>
275 /// Calendars are used to define standard working and non-working times.
276 /// Projects must have one base calendar. Tasks and resources can have
277 /// their own non-base calendars that are based on a base calendar.
278 /// </remarks>
279 class ASPOSE_TASKS_SHARED_CLASS Calendar : public Aspose::Tasks::ICalendar
280 {
281  typedef Calendar ThisType;
283 
284  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
285  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
286 
287 protected:
288 
289  class CalendarCacheKey;
290 
291 private:
293  friend class Aspose::Tasks::Calculations::RescheduleIncompleteWorkCalculator;
294  friend class Aspose::Tasks::Calculations::ResourceOverAllocationCalculator;
295  friend class Aspose::Tasks::Calculations::TimeScaledCalculator;
296  friend class Aspose::Tasks::Calculations::ResourceAssignmentCalculator;
297  friend class Aspose::Tasks::Calculations::ResourceAssignmentPeakCalculator;
298  friend class Aspose::Tasks::Calculations::ResourceCalculator;
299  friend class Aspose::Tasks::Calculations::TaskStatusCalculator;
300  friend class Aspose::Tasks::Calculations::TimephasedDataCalculator;
301  friend class Aspose::Tasks::IntersectedCalendar;
303  friend class Aspose::Tasks::IO::PrimaveraXml::P6XmlUtils;
304  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraCalendarNodeReader;
305  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraReader;
306  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraResourceNodeReader;
307  friend class Aspose::Tasks::Project;
309  friend class Aspose::Tasks::Task;
310  friend class Aspose::Tasks::BaselineTimephasedDataMaker;
311  friend class Aspose::Tasks::TimephasedDataByScaledMaker;
312  friend class Aspose::Tasks::Timephased::TimeScaledWorkContourBuilder;
313  friend class Aspose::Tasks::Timephased::TimephasedDataByScaledEnumerator;
314  friend class Aspose::Tasks::TimephasedDataCalculationUtil;
315  template<typename FT0> friend class Aspose::Tasks::TimeScaledParentUnit;
316  friend class Aspose::Tasks::Filters::CalendarRootFilter;
317  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::CalendarToRawValuesMapper;
318  friend class Aspose::Tasks::IO::Pwa::InternalApi::InternalApiProjectSerializer;
319  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ProjectRootMapper;
320  friend class Aspose::Tasks::IO::Xml::CalendarFactory;
321  friend class Aspose::Tasks::EVCalculator;
322  friend class Aspose::Tasks::Connectivity::MpdCalendarMapper;
323  friend class Aspose::Tasks::Connectivity::MspCalendarMapper;
324  friend class Aspose::Tasks::Connectivity::MspDbUtils;
325  friend class Aspose::Tasks::Connectivity::PmCalendarMapper;
326  friend class Aspose::Tasks::Connectivity::PrimaveraDbReader;
327  friend class Aspose::Tasks::IO::Html::HtmlCalendarTableReader;
328  friend class Aspose::Tasks::IO::MSProject::Mpp12CalendarReader;
329  friend class Aspose::Tasks::IO::MSProject::MppCalendarReader;
330  friend class Aspose::Tasks::IO::MSProject::MPP12Reader;
331  friend class Aspose::Tasks::IO::MSProject::MPPReader;
332  friend class Aspose::Tasks::IO::MSProject::MPPResourceReader;
333  friend class Aspose::Tasks::IO::MSProject::MppWeekDayReader;
334  friend class Aspose::Tasks::IO::MSProject::Mpp14CalendarReader;
335  friend class Aspose::Tasks::IO::MSProject::MPP14Reader;
336  friend class Aspose::Tasks::IO::MSProject::Mpp15CalendarReader;
337  friend class Aspose::Tasks::IO::MSProject::Mpp15CalendarWriter;
338  friend class Aspose::Tasks::IO::MSProject::Mpp14CalendarWriter;
339  friend class Aspose::Tasks::IO::MSProject::MPP14ResourceWriter;
340  friend class Aspose::Tasks::IO::MSProject::Mpp9CalendarReader;
341  friend class Aspose::Tasks::IO::MSProject::MPP9Reader;
342  friend class Aspose::Tasks::IO::MSProject::MPPProjectPropsReader;
343  friend class Aspose::Tasks::IO::MSProject::MPPTimephasedDataReader;
344  friend class Aspose::Tasks::IO::MSProject::Mpp12CalendarWriter;
345  friend class Aspose::Tasks::IO::MSProject::MPPTaskWriter;
346  friend class Aspose::Tasks::IO::MSProject::Mpp9CalendarWriter;
347  friend class Aspose::Tasks::IO::MSProject::MPPProjectPropsWriter;
348  friend class Aspose::Tasks::IO::MSProject::MppTimephasedDataWriter;
349  friend class Aspose::Tasks::IO::Mpx::MpxReader;
350  friend class Aspose::Tasks::IO::Xer::XerPrimaveraReader;
351  friend class Aspose::Tasks::IO::Xer::XerAssignmentReader;
352  friend class Aspose::Tasks::IO::Xer::XerCalendarReader;
353  friend class Aspose::Tasks::IO::Xer::XerProjectNormalizer;
354  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ProjectCalendarsMapper;
355  friend class Aspose::Tasks::IO::Xml::CalendarNodeReader;
356  friend class Aspose::Tasks::IO::Xml::CalendarNodeWriter;
357  friend class Aspose::Tasks::IO::Xml::ResourceNodeReader;
358  friend class Aspose::Tasks::IO::Xml::TaskNodeReader;
359  friend class Aspose::Tasks::IO::Xml::TimephasedDataNodeReader;
360  friend class Aspose::Tasks::IO::Xml::WeekDayNodeReader;
361  friend class Aspose::Tasks::IO::Xml::XmlReader;
362  friend class Aspose::Tasks::IO::Xml::XmlWriter;
363  friend class Aspose::Tasks::ProjectIntegrityValidator;
364  friend class Aspose::Tasks::AutoRecalculationState;
365  friend class Aspose::Tasks::ProjectState;
366  friend class Aspose::Tasks::CalendarDatesCalculator;
367  friend class Aspose::Tasks::DatesCalculator;
368  friend class Aspose::Tasks::TaskPlannerAssignmentManager;
369  friend class Aspose::Tasks::TaskPlanner;
370  friend class Aspose::Tasks::ManualState;
371  friend class Aspose::Tasks::PercentCompleteCalculator;
372  friend class Aspose::Tasks::ProjectWorkUpdater;
373  friend class Aspose::Tasks::SplitsCalculator;
374  friend class Aspose::Tasks::Recalculation::TaskSplitCalculator;
375  friend class Aspose::Tasks::TaskWarningCalculator;
376  friend class Aspose::Tasks::Recurring::Calculators::CalendarDayRecurrenceDateCalculator;
377  friend class Aspose::Tasks::Recurring::Calculators::RecurrenceDateCalculatorBase;
380  friend class Aspose::Tasks::Recurring::Calculators::DefaultRecurrenceDateCalculator;
384  friend class Aspose::Tasks::Saving::HtmlCalendarTable;
385  friend class Aspose::Tasks::Saving::MpxWriter;
386  friend class Aspose::Tasks::Saving::XerCalendarTable;
387  friend class Aspose::Tasks::Saving::PrimaveraCalendarNodeWriter;
388  friend class Aspose::Tasks::Scheduling::ConstraintSolver;
389  friend class Aspose::Tasks::Scheduling::TopsortCriticalPath;
390  friend class Aspose::Tasks::Scheduling::FromStartScheduler;
391  friend class Aspose::Tasks::TaskBaseline;
392  friend class Aspose::Tasks::TimephasedDataMaker;
393  friend class Aspose::Tasks::TimephasedWorkCostSelector;
394  friend class Aspose::Tasks::TimeScaledExceptions;
395  friend class Aspose::Tasks::Util::CalendarHelper;
396  friend class Aspose::Tasks::Validators::RecurringTaskParametersValidator;
397  friend ASPOSE_TASKS_SHARED_API bool operator ==(Calendar::CalendarCacheKey left, Calendar::CalendarCacheKey right);
398  friend ASPOSE_TASKS_SHARED_API bool operator !=(Calendar::CalendarCacheKey left, Calendar::CalendarCacheKey right);
399 
400 protected:
401 
402  class ASPOSE_TASKS_SHARED_CLASS CalendarCacheKey : public System::IEquatable<Aspose::Tasks::Calendar::CalendarCacheKey>, public System::Details::BoxableObjectBase
403  {
404  typedef CalendarCacheKey ThisType;
405  typedef System::IEquatable<Aspose::Tasks::Calendar::CalendarCacheKey> BaseType;
406 
407  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
408  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
409 
410  friend ASPOSE_TASKS_SHARED_API bool operator ==(Calendar::CalendarCacheKey left, Calendar::CalendarCacheKey right);
411  friend ASPOSE_TASKS_SHARED_API bool operator !=(Calendar::CalendarCacheKey left, Calendar::CalendarCacheKey right);
412 
413  public:
414 
415  ASPOSE_TASKS_SHARED_API CalendarCacheKey(int32_t calUid, System::DateTime start, System::DateTime finish, double units);
416 
417  /// <inheritdoc ></inheritdoc>
418  ASPOSE_TASKS_SHARED_API bool Equals(Calendar::CalendarCacheKey other) override;
419  /// <inheritdoc ></inheritdoc>
420  ASPOSE_TASKS_SHARED_API bool Equals(System::SharedPtr<System::Object> obj) override;
421  /// <inheritdoc ></inheritdoc>
422  ASPOSE_TASKS_SHARED_API int32_t GetHashCode() const override;
423 
424  ASPOSE_TASKS_SHARED_API CalendarCacheKey();
425 
426  protected:
427 
428  #ifdef ASPOSE_GET_SHARED_MEMBERS
429  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
430  #endif
431 
432 
433  private:
434 
435  double units;
436  int32_t calUid;
437  System::DateTime start;
438  System::DateTime finish;
439  int32_t cachedHashCode;
440 
441  };
442 
443 
444 public:
445 
446  /// <summary>
447  /// Gets the name of the calendar.
448  /// </summary>
449  ASPOSE_TASKS_SHARED_API System::String get_Name() const;
450  /// <summary>
451  /// Sets the name of the calendar.
452  /// </summary>
453  ASPOSE_TASKS_SHARED_API void set_Name(const System::String& value);
454  /// <summary>
455  /// Gets the unique identifier of the calendar.
456  /// </summary>
457  ASPOSE_TASKS_SHARED_API int32_t get_Uid() const;
458  /// <summary>
459  /// Sets the unique identifier of the calendar.
460  /// </summary>
461  ASPOSE_TASKS_SHARED_API void set_Uid(int32_t value);
462  /// <summary>
463  /// Gets WeekDaysCollection for this calendar.
464  /// The collection of weekdays that defines the calendar.
465  /// </summary>
466  ASPOSE_TASKS_SHARED_API const System::SharedPtr<WeekDayCollection>& get_WeekDays() const;
467  /// <summary>
468  /// Gets CalendarExceptionCollection object.
469  /// The collection of exceptions that is associated with the calendar.
470  /// </summary>
471  ASPOSE_TASKS_SHARED_API System::SharedPtr<CalendarExceptionCollection> get_Exceptions() const;
472  /// <summary>
473  /// Gets WorkWeekCollections object.
474  /// The collection of work weeks that is associated with the calendar.
475  /// </summary>
476  ASPOSE_TASKS_SHARED_API const System::SharedPtr<WorkWeekCollection>& get_WorkWeeks() const;
477  /// <summary>
478  /// Gets a value indicating whether the calendar is a base calendar.
479  /// </summary>
480  ASPOSE_TASKS_SHARED_API bool get_IsBaseCalendar();
481  /// <summary>
482  /// Gets the base calendar on which this calendar depends.
483  /// Only applicable if the calendar is not a base calendar.
484  /// </summary>
485  ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> get_BaseCalendar() const;
486  /// <summary>
487  /// Sets the base calendar on which this calendar depends.
488  /// Only applicable if the calendar is not a base calendar.
489  /// </summary>
490  ASPOSE_TASKS_SHARED_API void set_BaseCalendar(const System::SharedPtr<Calendar>& value);
491  /// <summary>
492  /// Gets a value indicating whether the calendar is a baseline calendar.
493  /// </summary>
494  ASPOSE_TASKS_SHARED_API bool get_IsBaselineCalendar();
495  /// <summary>
496  /// Sets a value indicating whether the calendar is a baseline calendar.
497  /// </summary>
498  ASPOSE_TASKS_SHARED_API void set_IsBaselineCalendar(bool value);
499  /// <summary>
500  /// Gets calendar's Guid.
501  /// </summary>
502  ASPOSE_TASKS_SHARED_API System::String get_Guid() const;
503 
504  /// <summary>
505  /// Gets <see cref="ICalendar"></see> instance which can be used to perform calculations on the intersection of work schedules of 2 calendars.
506  /// </summary>
507  /// <param name="calendar1">First calendar.</param>
508  /// <param name="calendar2">Second calendar.</param>
509  /// <returns>Implementation of ICalendar interface.</returns>
510  /// <exception cref="ArgumentNullException">When any of the arguments is null.</exception>
511  static ASPOSE_TASKS_SHARED_API System::SharedPtr<ICalendar> GetIntersectionCalendar(const System::SharedPtr<Calendar>& calendar1, const System::SharedPtr<Calendar>& calendar2);
512  /// <summary>
513  /// Creates default standard calendar.
514  /// </summary>
515  /// <param name="calendar">Calendar to make standard calendar from.</param>
516  /// <returns>Calendar with 5 working days (Monday-Friday) with working times 8-12 and 13-17.</returns>
517  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> MakeStandardCalendar(const System::SharedPtr<Calendar>& calendar);
518  /// <summary>
519  /// Makes a given Calendar to be a 24Hour Calendar.
520  /// 24Hours Calendar is a Calendar in which every day of week is working with Round-the-clock working hours.
521  /// </summary>
522  /// <param name="calendar">Calendar to make 24 Hours Calendar from.</param>
523  /// <returns>24Hour Calendar.</returns>
524  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> Make24HourCalendar(const System::SharedPtr<Calendar>& calendar);
525  /// <summary>
526  /// Makes a given Calendar as Night Shift Calendar.
527  /// </summary>
528  /// <param name="calendar">Calendar to make Night Shift Calendar.</param>
529  /// <returns>Night Shift Calendar.</returns>
530  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> MakeNightShiftCalendar(const System::SharedPtr<Calendar>& calendar);
531  /// <summary>
532  /// Returns a value indicating whether this instance is equal to a specified object.
533  /// </summary>
534  /// <param name="obj">The object to compare with this instance.</param>
535  /// <returns><b>True</b> if o is a Calendar that has the same Uid value as this instance; otherwise, <b>false</b>.</returns>
536  ASPOSE_TASKS_SHARED_API bool Equals(System::SharedPtr<System::Object> obj) override;
537  /// <summary>
538  /// Returns a hash code for the instance of the class.
539  /// </summary>
540  /// <returns>a hash code for this object.</returns>
541  ASPOSE_TASKS_SHARED_API int32_t GetHashCode() const override;
542  /// <summary>
543  /// Removes calendar from project.
544  /// </summary>
545  ASPOSE_TASKS_SHARED_API void Delete();
546  /// <summary>
547  /// Returns start date based on the specified finish date and duration.
548  /// </summary>
549  /// <param name="finish">The specified finish date.</param>
550  /// <param name="duration">The specified duration.</param>
551  /// <returns>Calculated start date.</returns>
552  ASPOSE_TASKS_SHARED_API System::DateTime GetStartDateFromFinishAndDuration(System::DateTime finish, Duration duration) override;
553  /// <summary>
554  /// Returns start date based on specified finish date and duration.
555  /// </summary>
556  /// <param name="finish">The specified finish date.</param>
557  /// <param name="duration">The specified duration.</param>
558  /// <returns>Calculated start date.</returns>
559  ASPOSE_TASKS_SHARED_API System::DateTime GetStartDateFromFinishAndDuration(System::DateTime finish, System::TimeSpan duration) override;
560  /// <summary>
561  /// Determines whether the specified day is a working day according to the calendar.
562  /// </summary>
563  /// <param name="dt">The date to check whether the day is working.</param>
564  /// <returns>True if the day is a working day.</returns>
565  ASPOSE_TASKS_SHARED_API bool IsDayWorking(System::DateTime dt) override;
566  /// <summary>
567  /// Return WorkUnit - Start, Finish and Duration of working hours for the specified date time interval.
568  /// </summary>
569  /// <param name="start">Start date of the interval.</param>
570  /// <param name="finish">Finish date of the interval.</param>
571  /// <returns>Instance of <see cref="WorkUnit"></see> class containing Start, Finish and Duration of working hours.</returns>
572  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkUnit> GetWorkingHours(System::DateTime start, System::DateTime finish) override;
573  /// <summary>
574  /// Returns the amount of working hours at the specified date.
575  /// </summary>
576  /// <param name="dt">The date to get working hours for.</param>
577  /// <returns>Working hours at the specified date.</returns>
578  ASPOSE_TASKS_SHARED_API System::TimeSpan GetWorkingHours(System::DateTime dt) override;
579  /// <summary>
580  /// Returns amount of working hours between the specified dates.
581  /// </summary>
582  /// <param name="start">Start date of the interval.</param>
583  /// <param name="finish">Finish date of the interval.</param>
584  /// <returns>Amount of working hours according to the calendar instance.</returns>
585  ASPOSE_TASKS_SHARED_API System::TimeSpan GetWorkingHoursTimeSpan(System::DateTime start, System::DateTime finish) override;
586  /// <summary>
587  /// Calculates the date when the specified amount of work time will pass according to the calendar.
588  /// </summary>
589  /// <param name="start">Start date.</param>
590  /// <param name="work">Work duration.</param>
591  /// <returns>Finish date.</returns>
592  ASPOSE_TASKS_SHARED_API System::DateTime GetFinishDateByStartAndWork(System::DateTime start, Duration work) override;
593  /// <summary>
594  /// Calculates the date when the specified amount of work time will pass according to the calendar.
595  /// </summary>
596  /// <param name="start">Start date.</param>
597  /// <param name="work">Work duration.</param>
598  /// <returns>Finish date.</returns>
599  ASPOSE_TASKS_SHARED_API System::DateTime GetFinishDateByStartAndWork(System::DateTime start, System::TimeSpan work) override;
600  /// <summary>
601  /// Calculates the task finish date and time from its start date, split parts and the work duration.
602  /// </summary>
603  /// <param name="task">The task to calculate finish date for.</param>
604  /// <param name="duration">The duration to calculate.</param>
605  /// <returns>Task's finish date for the given start date and duration.</returns>
606  /// <remarks>Returns DateTime.MinValue if task is summary, null or its start date is not set.</remarks>
607  ASPOSE_TASKS_SHARED_API System::DateTime GetTaskFinishDateFromDuration(System::SharedPtr<Task> task, System::TimeSpan duration) override;
608  /// <summary>
609  /// Returns <see cref="WorkingTimeCollection"></see> of working times for the specified date.
610  /// </summary>
611  /// <param name="dt">The date to get working times for.</param>
612  /// <returns>Collection of <see cref="WorkingTime"></see> instances.</returns>
613  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> GetWorkingTimes(System::DateTime dt) override;
614  /// <summary>
615  /// Calculates the end of the previous working date from the specified date.
616  /// </summary>
617  /// <param name="date">the date to calculate the previous working day end.</param>
618  /// <returns>The end of the previous working day end</returns>
619  ASPOSE_TASKS_SHARED_API System::DateTime GetPreviousWorkingDayEnd(System::DateTime date) override;
620  /// <summary>
621  /// Calculates next working day start for the specified date.
622  /// </summary>
623  /// <param name="date">The date to get next working day start for.</param>
624  /// <returns>Next working day start <see cref="System::DateTime"></see>.</returns>
625  ASPOSE_TASKS_SHARED_API System::DateTime GetNextWorkingDayStart(System::DateTime date) override;
626  /// <summary>
627  /// Calculates next working time start beginning from the specified date and time.
628  /// </summary>
629  /// <param name="date">The date and time.</param>
630  /// <returns>The nearest working time start.</returns>
631  ASPOSE_TASKS_SHARED_API System::DateTime GetWorkStart(System::DateTime date) override;
632  /// <summary>
633  /// Returns whether the calendar doesn't have working hours defined.
634  /// </summary>
635  ASPOSE_TASKS_SHARED_API bool IsEmpty() override;
636 
637 protected:
638 
639  /// <summary>
640  /// Gets WeekDaysCollection for this calendar.
641  /// The collection of weekdays that defines the calendar.
642  /// </summary>
643  ASPOSE_TASKS_SHARED_API void set_WeekDays(const System::SharedPtr<WeekDayCollection>& value);
644  /// <summary>
645  /// Gets calendar's Guid.
646  /// </summary>
647  ASPOSE_TASKS_SHARED_API void set_Guid(const System::String& value);
648  ASPOSE_TASKS_SHARED_API const System::SharedPtr<Project>& get_ParentProject() const;
649  ASPOSE_TASKS_SHARED_API void set_ParentProject(const System::SharedPtr<Project>& value);
650  ASPOSE_TASKS_SHARED_API NullableBool get_NullableIsBaselineCalendar() const;
651  ASPOSE_TASKS_SHARED_API void set_NullableIsBaselineCalendar(NullableBool value);
652  ASPOSE_TASKS_SHARED_API int32_t get_ResourceUid() const;
653  ASPOSE_TASKS_SHARED_API void set_ResourceUid(int32_t value);
654  ASPOSE_TASKS_SHARED_API bool get_IsNull() const;
655  ASPOSE_TASKS_SHARED_API void set_IsNull(bool value);
656  ASPOSE_TASKS_SHARED_API bool get_IsZeroResourceCalendar();
657  ASPOSE_TASKS_SHARED_API System::Guid get_UnknownGuid() const;
658  ASPOSE_TASKS_SHARED_API void set_UnknownGuid(System::Guid value);
659  ASPOSE_TASKS_SHARED_API System::SharedPtr<Aspose::Tasks::Resource> get_Resource() const;
660  ASPOSE_TASKS_SHARED_API void set_Resource(const System::SharedPtr<Aspose::Tasks::Resource>& value);
661  ASPOSE_TASKS_SHARED_API bool get_Is24HourCalendar();
662  ASPOSE_TASKS_SHARED_API bool get_IsCacheEnabled();
663  ASPOSE_TASKS_SHARED_API void set_IsCacheEnabled(bool value);
664  /// <summary>
665  /// Gets a value indicating whether the calendar is 'uniform' (work times are the same for days with the same DayOfWeek).
666  /// </summary>
667  virtual ASPOSE_TASKS_SHARED_API bool get_IsUniform();
668  /// <summary>
669  /// Gets a value indicating whether the calendar is 'uniform' (work times are the same for days with the same DayOfWeek).
670  /// </summary>
671  virtual ASPOSE_TASKS_SHARED_API bool get_CanSkipWeeks();
672 
673  /// <summary>
674  /// Initializes a new instance of the <see cref="Calendar"></see> class.
675  /// </summary>
676  ASPOSE_TASKS_SHARED_API Calendar();
677 
678  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(Calendar, CODEPORTING_ARGS());
679 
680  /// <summary>
681  /// Initializes a new instance of the <see cref="Calendar"></see> class and sets Id value.
682  /// </summary>
683  /// <param name="uid">Unique identifier.</param>
684  ASPOSE_TASKS_SHARED_API Calendar(int32_t uid);
685 
686  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(Calendar, CODEPORTING_ARGS(int32_t uid));
687  ASPOSE_TASKS_SHARED_API bool IsDayOff(System::DateTime date);
688  ASPOSE_TASKS_SHARED_API System::DateTime GetFinishDateByStartAndDuration(System::DateTime start, Duration duration, bool isLast, bool daysOff);
689  ASPOSE_TASKS_SHARED_API System::DateTime GetFinishDateByStartAndDuration(System::DateTime start, System::TimeSpan duration, bool isLast, bool daysOff);
690  ASPOSE_TASKS_SHARED_API System::DateTime GetTaskFinishDateFromDuration(const System::SharedPtr<Task>& task, Duration duration);
691  ASPOSE_TASKS_SHARED_API System::DateTime GetFinishDateFromStartAndDuration(const System::SharedPtr<Task>& task, System::DateTime start, Duration duration);
692  ASPOSE_TASKS_SHARED_API System::DateTime GetStartDateFromFinishAndDuration(const System::SharedPtr<Task>& task, System::DateTime finishDate, Duration duration);
693  /// <summary>
694  /// Calculates task finish date, splits included.
695  /// </summary>
696  /// <param name="task">Task to calculate finish for.</param>
697  /// <param name="start">Start date to calculate finish from.</param>
698  /// <param name="duration">Duration</param>
699  /// <returns>Calculated task finish date.</returns>
700  ASPOSE_TASKS_SHARED_API System::DateTime GetFinishDateFromStartAndDuration(const System::SharedPtr<Task>& task, System::DateTime start, System::TimeSpan duration);
701  /// <summary>
702  /// Calculates task start date, splits included.
703  /// </summary>
704  /// <param name="task">Task to calculate start date for.</param>
705  /// <param name="finishDate">Finish date to calculate start from.</param>
706  /// <param name="duration">Duration</param>
707  /// <returns>Calculated task start date.</returns>
708  ASPOSE_TASKS_SHARED_API System::DateTime GetStartDateFromFinishAndDuration(const System::SharedPtr<Task>& task, System::DateTime finishDate, System::TimeSpan duration);
709  ASPOSE_TASKS_SHARED_API System::DateTime GetWorkStartOrDefault(System::DateTime date);
710  ASPOSE_TASKS_SHARED_API System::DateTime GetPrevWorkingTimeEnd(System::DateTime date);
711  ASPOSE_TASKS_SHARED_API bool IsWorkDayEnd(System::DateTime date);
712  ASPOSE_TASKS_SHARED_API bool IsWorkingTimeEnd(System::DateTime date);
713  ASPOSE_TASKS_SHARED_API bool IsWorkDayStart(System::DateTime date);
714  ASPOSE_TASKS_SHARED_API bool IsNonworkingTime(System::DateTime date);
715  ASPOSE_TASKS_SHARED_API bool IsWorkingTimeStart(System::DateTime date);
716  ASPOSE_TASKS_SHARED_API System::DateTime GetNextDayStart(System::DateTime date);
717  ASPOSE_TASKS_SHARED_API System::DateTime GetNextDayStart(System::DateTime date, System::TimeSpan nonWorkingDayStart);
718  ASPOSE_TASKS_SHARED_API System::DateTime GetDayStart(System::DateTime date);
719  ASPOSE_TASKS_SHARED_API int32_t GetWorkingDaysCount(System::DateTime start, System::DateTime end);
720  /// <summary>
721  /// Gets working times at the specified date "intersected" with the date's TimeOfDay.
722  /// </summary>
723  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> GetWorkingTimesAtDate(System::DateTime date);
724  ASPOSE_TASKS_SHARED_API void StartExceptionsCaching();
725  ASPOSE_TASKS_SHARED_API void StopExceptionsCaching();
726  /// <summary>
727  /// Creates default standard calendar.
728  /// </summary>
729  /// <returns>Created calendar.</returns>
730  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> MakeStandardCalendarNoWeekend();
731  ASPOSE_TASKS_SHARED_API void SetWorkingExceptions(const System::SharedPtr<TimeScaledExceptions>& exceptionCollection);
732  /// <summary>
733  /// Creates default standard calendar.
734  /// </summary>
735  /// <returns>Created calendar.</returns>
736  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> Get24HoursCalendarInternal();
737  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> WrapCalendar(const System::SharedPtr<Calendar>& calendar, const System::SharedPtr<TimeScaledExceptions>& workingExceptions);
738  /// <summary>
739  /// Creates default standard calendar.
740  /// </summary>
741  /// <returns>Created calendar.</returns>
742  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Calendar> MakeStandardCalendarInternal();
743  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> GetWorkingTimesIgnoreTimescaledExceptions(System::DateTime dt, DayType dayType);
744  virtual ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> GetWorkingTimesIgnoreExceptions(DayType dayType);
745  ASPOSE_TASKS_SHARED_API System::SharedPtr<CalendarException> CheckException(System::DateTime dt, bool checkImplicit = true);
746  ASPOSE_TASKS_SHARED_API System::SharedPtr<IReadOnlyWorkingTimeCollection> GetScheduleForImplicitException();
747  virtual ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> CalculateWorkingTimes(System::DateTime dt);
748 
749  virtual ASPOSE_TASKS_SHARED_API ~Calendar();
750 
751  #ifdef ASPOSE_GET_SHARED_MEMBERS
752  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
753  #endif
754 
755 
756 private:
757 
758  System::SharedPtr<CalendarDatesCalculator> calculator;
759  System::SharedPtr<CalendarExceptionCollectionWithCache> exceptions;
760  System::SharedPtr<TimeScaledExceptions> workingExceptions;
761  NullableBool isBaselineCalendar;
762  System::WeakPtr<Aspose::Tasks::Resource> resource;
763  System::Nullable<bool> is24HourCal;
764  System::SharedPtr<Calendar> baseCalendar;
765  System::String guid;
766  int32_t isCacheEnabledNesting;
767  System::SharedPtr<IKeyValueCache<System::DateTime, System::SharedPtr<WorkingTimeCollection>>> calculationsCache;
768 
769  static System::SharedPtr<Calendar>& calendar24Hours();
770 
771  System::String pr_Name;
772  int32_t pr_Uid;
773  System::SharedPtr<WeekDayCollection> pr_WeekDays;
774  System::SharedPtr<WorkWeekCollection> pr_WorkWeeks;
775 
776  /// <summary>
777  /// Gets WorkWeekCollections object.
778  /// The collection of work weeks that is associated with the calendar.
779  /// </summary>
780  ASPOSE_TASKS_SHARED_API void set_WorkWeeks(const System::SharedPtr<WorkWeekCollection>& value);
781 
782  System::WeakPtr<Project> pr_ParentProject;
783  int32_t pr_ResourceUid;
784  bool pr_IsNull;
785  System::Guid pr_UnknownGuid;
786 
787  System::String get_DebuggerDisplay();
788 
789  void TryToSkipByWeek(System::DateTime& enumeratorStartDate, int64_t& totalSpan, System::DateTime finish);
790  System::TimeSpan GetWorkingHoursInDay(System::DateTime start, System::DateTime finish);
791  System::SharedPtr<Calendar> ShallowClone();
792  void InitScheduleForTimescaledException(const System::SharedPtr<CalendarException>& exception, System::DateTime dt);
793  static void Make24HourWeek(const System::SharedPtr<Calendar>& calendar);
794  System::TimeSpan GetWeekTotalWork();
795  bool CheckWeekHasNoExceptions(System::DateTime start, System::DateTime finish);
796  static void MakeNightShiftWeek(const System::SharedPtr<Calendar>& calendar);
797  System::SharedPtr<WorkingTimeCollection> GetWorkingTimesForCalendarException(const System::SharedPtr<CalendarException>& calendarException, System::DateTime dt);
798  System::SharedPtr<WeekDay> GetWeekDay(System::DateTime dt);
799  System::SharedPtr<WeekDay> CheckWeekDay(DayType dayType);
800  System::SharedPtr<WeekDay> CheckDateInWorkWeeks(System::DateTime dt);
801 
802 };
803 
804 ASPOSE_TASKS_SHARED_API bool operator ==(Calendar::CalendarCacheKey left, Calendar::CalendarCacheKey right);
805 ASPOSE_TASKS_SHARED_API bool operator !=(Calendar::CalendarCacheKey left, Calendar::CalendarCacheKey right);
806 
807 } // namespace Tasks
808 } // namespace Aspose
809 
810 
Represents a task in a project.
Definition: Task.h:387
A class for boolean values with possibility to check whether the value was defined or not.
Definition: NullableBool.h:21
Represents Baseline of a Task.
Definition: TaskBaseline.h:52
Definition: Asn.h:12
Represents a collection of Calendar objects.
Definition: CalendarCollection.h:97
Represents a base class for repetitions in weekly recurrence pattern.
Definition: WeeklyRepetitionBase.h:39
Represents duration in a project.
Definition: Duration.h:161
Represents a project.
Definition: Project.h:550
Represents a calendar used in a project.
Definition: Calendar.h:279
Represents a class for repetitions in daily recurrence pattern based on calendar days.
Definition: DailyCalendarRepetition.h:35
Represents a resource assignment in a project.
Definition: ResourceAssignment.h:225
Represents a class for repetitions in daily recurrence pattern based on work days.
Definition: DailyWorkRepetition.h:35
Represents a base pattern for yearly day position.
Definition: YearlyRepetitionBase.h:37
Represents a calendar abstraction which can be used for various calculations of dates and durations.
Definition: ICalendar.h:35
Represents a base pattern for monthly day position.
Definition: MonthlyRepetitionBase.h:39
Represents Baseline of a resource assignment.
Definition: AssignmentBaseline.h:83