Resource calendar in MS Project

D

dotnet-force

Hi all,

I'm writing a MS Project 2002 Add-In in C#

My first question is :
Is there a way to know if a resource calendar is the project calendar ?
(i.e. is the resource has non working days different from the project ones).

Second question :
Is there a way to get specific non-working days (hours) for a resource ?
I want to be able to have the difference between the project calendar
and the resource calendar.

When a project is saved in XML format, such information is available.
Here is the information in the XML file.

<Calendar><UID>14</UID><Name>res5</Name><IsBaseCalendar>0</IsBaseCalendar><BaseCalendarUID>1</BaseCalendarUID>
<WeekDays>
<WeekDay>
<DayType>0</DayType>
<DayWorking>0</DayWorking>
<TimePeriod>
<FromDate>2003-12-03T00:00:00</FromDate>
<ToDate>2003-12-04T23:59:00</ToDate>
</TimePeriod>
</WeekDay>
</WeekDays>
</Calendar>

I saw nothing in the API of the
Microsoft.Office.Interop.MSProject.Calendar class but perhaps I missed
something.

Thanks for the help.

Pascal Lenormand
ILOG
 
W

Wei-Dong Xu [MSFT]

Hi Pascal,

Thanks for posting in the community!

From my understanding to this issue, you'd like to know how to ensure
whether one resource Calendar is one project Calendar. And, you'd also like
to know how to obtain the working days of one specified resource. Please
correct me if my understanding is not correct.

For the first question, the resource calendar is related to the resource
object and project calendar belongs to one task. The difference for the two
calendars is which object they belong to. So far as I know, there is no
property of Calendar object to specify whether one resource calendar
belongs to one project calendar.

For the second question, you will need to sum the working day with looping
the working days of one specific resource. I write one sample code for you.
'Code start ----------------------------------------------------
Dim R As Resource
Dim D As Integer, iMonth As Integer, WorkingDays As Integer
...
With R.Calendar.Years(2004)
WorkingDays = 0
For D = 1 To .Months(iMonth).Days.Count
If .Months(iMonth).Days(D).Working = True Then
WorkingDays = WorkingDays + 1
End If
Next D
End With
'Code end ----------------------------------------------------

Thank you for using Microsoft Newsgroup! Enjoy a good weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

dotnet-force

Hi Wei,

First thank you for you quick answer.

Wei-Dong Xu said:
Hi Pascal,

Thanks for posting in the community!

From my understanding to this issue, you'd like to know how to ensure
whether one resource Calendar is one project Calendar. And, you'd
also > like to know how to obtain the working days of one specified
resource.
Please correct me if my understanding is not correct.
For the first question, the resource calendar is related to the
resource object and project calendar belongs to one task. The
difference for the two calendars is which object they belong to. So
far as I know, there is no property of Calendar object to specify
whether one resource calendar belongs to one project calendar.
Ok.

For the second question, you will need to sum the working day with
looping the working days of one specific resource. I write one sample
code for you.
'Code start ----------------------------------------------------
Dim R As Resource
Dim D As Integer, iMonth As Integer, WorkingDays As Integer
..
With R.Calendar.Years(2004)
WorkingDays = 0
For D = 1 To .Months(iMonth).Days.Count
If .Months(iMonth).Days(D).Working = True Then
WorkingDays = WorkingDays + 1
End If
Next D
End With
'Code end ----------------------------------------------------

Thank you.
I was already using Years, Months, and Days properties and then I'm
using the Shiftn object property to know the working / non-working hours.
Tell me if I'm wrong.

I'm coming back on my second question.
Is there a way to know if a calendar is the same that an other one ?
Calendar c1 = ....;
Calendar c2 = ....;
If (c1.Equals(c2)) Then
....
Could you tell me if there is such API or some code to do this test ?

And could you tell me how the XML format for resource calendar is
produced ? Because when I have a look in this file, I exactly find what
I need, so perhaps you could help me. In the following XML part, we see
that the period from 2003-12-03T00:00:00 to 2003-12-04T23:59:00 is a
non-working period (<DayWorking>0</DayWorking>). And it's the period
that I set to non working for the resource.

<Calendar><UID>14</UID><Name>res5</Name><IsBaseCalendar>0</IsBaseCalendar><BaseCalendarUID>1</BaseCalendarUID>
<WeekDays>
<WeekDay>
<DayType>0</DayType>
<DayWorking>0</DayWorking>
<TimePeriod>
<FromDate>2003-12-03T00:00:00</FromDate>
<ToDate>2003-12-04T23:59:00</ToDate>
</TimePeriod>
</WeekDay>
</WeekDays>
</Calendar>

Thank you for using Microsoft Newsgroup! Enjoy a good weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Thanks for your help.

Pascal Lenormand
ILOG
 
W

Wei-Dong Xu [MSFT]

Hi Pascal,

Thank you for replying!

For your convenience on each question, I put the order number for each
section.
1) For the calculation of working days, I don't think there is any mistake
you have made.

2) For the comparison of Calendar object, it will be appreicated you tell
me the reason why you want to perform this comparison. From my view, if you
want to compare the Calendar object, you will need to define one function
to compare several specific properties of the Calendar according to your
scenario, for example comparing the "calendar.Years(2004).Months.Count"
property for two Calendar objects. I will also touch this question in the
analysis below.

3) For the third question on the project XML format file, I try to explain
this for you.
Calendars in Project determine how resources assigned to tasks are
scheduled and how tasks themselves are scheduled. The "Base calendars" are
sets of working and nonworking times and days that the three other types of
calendars use.
a)Project calendar
b)Resource calendar
c)Task calendar
By default, three base calendars are provided with Project:
i)Standard (8:00 A.M. to 5:00 P.M. weekdays, with an hour off for
lunch)
ii)24-Hours
iii)Night Shift

Generally speaking, we will define several more Calendars for different
scenarioes for the project, we can see each Basic Calendar as "calendar
template"(to be easy to explain this, I will call one Basic Calendar as
"template"). Then we can specify one template to the project, Resource or
Task(we can specify one template to different resource and Task). In this
way, if there is any modification on one template, we will only need to
modify the template and then all project, resource and task which uses the
templte will obtain the new template, this way, we avoid to change each
Calendar manually. This will be very simple for the Project Administrator.

Furthermore, if one resource is created with one Basic Calendar at first,
then we modify the resource Calendar from the "resource information"
window. After the modification, one new Basic Calendar will be created. The
new Basic Calendar will create his own xml section in the project xml
format file, as you have mentioned in the post. From this angle, you can
image, if we modify each resource, a lot of resources will be created and
it will be a nightmare for the project Administrator to manage the Basic
Calendar.

So it is suggested you can pre-define several Basic Calendars corresponding
to the project planning and then only specify them into the project, task
and resource respectively. It will be easy for the planning and maintenance
of the project. The server edition Project only permits the system
Administrator to create the Basic Calendar. The client can only specify the
existing Basic Calendar to the project, resource and task. Even if we
connect to the server edition Project from one professional Edition
Project, the modification to resource Calendar and other will be disabled
at client. This design will be very helpful for the project maintenance.

In addition, for the second question above, I think there is no need for us
to compare the Calendar object. We can only check the Calendar Index
property which will tell us which Basic Calendar is used. The
basicCalendars collection will help you to locate the used basic Calendar.

Please feel free to let me know if you have any further questions. I am
standing by to be of service!

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top