캘린더 예외 추가 및 제거

Contents
[ Hide Show ]

달력 예외 작업

C ++ API의 Tasks는 캘린더 예외를 관리하는 데 도움이됩니다. 예외 Calendarexception 객체의 목록을 나타내는 달력 클래스에 노출 된 속성은 캘린더 예외를 추가하거나 제거하는 데 사용됩니다.

다음 코드 예제는 예외를 추가, 제거 및 표시하는 방법을 보여줍니다.

 1System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 2    
 3{
 4    System::SharedPtr<System::IO::FileStream> fs = System::MakeObject<System::IO::FileStream>(dataDir + u"project_test.mpp", System::IO::FileMode::Open);
 5    // Clearing resources under 'using' statement
 6    System::Details::DisposeGuard<1> __dispose_guard_0({ fs});
 7    // ------------------------------------------
 8    
 9    try
10    {
11        // Create project instance
12        System::SharedPtr<Project> prj = System::MakeObject<Project>(fs);
13        
14        // Remove an exception
15        System::SharedPtr<Aspose::Tasks::Calendar> cal = prj->get_Calendars()->ToList()->idx_get(0);
16        if (cal->get_Exceptions()->get_Count() > 1)
17        {
18            System::SharedPtr<CalendarException> exc = cal->get_Exceptions()->ToList()->idx_get(0);
19            cal->get_Exceptions()->Remove(exc);
20        }
21        
22        // Add an exception
23        System::SharedPtr<CalendarException> calExc = System::MakeObject<CalendarException>();
24        calExc->set_FromDate(System::DateTime(2009, 1, 1));
25        calExc->set_ToDate(System::DateTime(2009, 1, 3));
26        cal->get_Exceptions()->Add(calExc);
27        
28        // Display exceptions
29        
30        {
31            auto calExc1_enumerator = (cal->get_Exceptions())->GetEnumerator();
32            decltype(calExc1_enumerator->get_Current()) calExc1;
33            while (calExc1_enumerator->MoveNext() && (calExc1 = calExc1_enumerator->get_Current(), true))
34            {
35                System::Console::WriteLine(System::String(u"From") + calExc1->get_FromDate().ToShortDateString());
36                System::Console::WriteLine(System::String(u"To") + calExc1->get_ToDate().ToShortDateString());
37            }
38        }
39    }
40    catch(...)
41    {
42        __dispose_guard_0.SetCurrentException(std::current_exception());
43    }
44}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.