开发者

MPXJ Set 24 Hours Calendar on Resource

I am working with MPXJ framework to generate an XML file with i import into project 2007. I开发者_如何学Go have run in to allot of problems but i can't seem to find an answer to the following.

I have a fixed Work and duration on a task, but when i add a resource and import it in project i get an error message:

"The resource is assigned outside the original dates for task 2 in project. The duration of this fixed-duration task will change to accommodate the resource assignment".

Project then changes the work and or duration value. that is not what i want. i want the resource to use the 24 hours calendar but i can't seem to attach the project 2007 standard calendar, so i thought lets make my own 24 hours calendar and attach that to resource. now i can't seem to set the 0:00:00 to 0:00:00 time in a work day.

ProjectCalendar calendar = projectFile.addResourceCalendar();
calendar.setName("24 Hours");
calendar.setUniqueID(Count);
calendar.setWorkingDay(Day.MONDAY, true);
calendar.setWorkingDay(Day.TUESDAY, true);
calendar.setWorkingDay(Day.WEDNESDAY, true);
calendar.setWorkingDay(Day.TUESDAY, true);
calendar.setWorkingDay(Day.FRIDAY, true);

Resource resource = projectFile.addResource();
resource.setUniqueID(Count);
resource.setName("Painters");
resource.setResourceCalendar(calendar);

Any one know of a solution to one get the default 24 hour calendar set to the resource of make my own.


The code below illustrates how to create a 24 hour calendar. My apologies for the long-winded way each day is set up, I need to improve the way the Day class works so that it is easier to iterate.

The key point to note is that the DateRange instance is set up to start at 00:00 hours on one date, and finish at 00:00 hours on the following day. The actual date used is irrelevant, the calendar is only using the time element of the date.

Hope that makes sense!

  //
  // Use this date formatter to make it simple to specific the range
  // start and wne dates
  //
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");

  //
  // This is an immutable date range, so we can share it without
  // worrying about it being changed
  //
  DateRange range = new DateRange(format.parse("2000-01-01 00:00"), format.parse("2000-01-02 00:00"));

  //
  // Add the calendar and name it
  //
  ProjectCalendar test = file.addBaseCalendar();
  test.setName("Test 24 Hours");

  //
  // Mark each day as working
  //
  test.setWorkingDay(Day.SUNDAY, true);
  test.setWorkingDay(Day.MONDAY, true);
  test.setWorkingDay(Day.TUESDAY, true);
  test.setWorkingDay(Day.WEDNESDAY, true);
  test.setWorkingDay(Day.THURSDAY, true);
  test.setWorkingDay(Day.FRIDAY, true);
  test.setWorkingDay(Day.SATURDAY, true);

  //
  // Add a working hours range to each day
  //
  ProjectCalendarHours hours;
  hours = test.addCalendarHours(Day.SUNDAY);
  hours.addRange(range);
  hours = test.addCalendarHours(Day.MONDAY);
  hours.addRange(range);
  hours = test.addCalendarHours(Day.TUESDAY);
  hours.addRange(range);
  hours = test.addCalendarHours(Day.WEDNESDAY);
  hours.addRange(range);
  hours = test.addCalendarHours(Day.THURSDAY);
  hours.addRange(range);
  hours = test.addCalendarHours(Day.FRIDAY);
  hours.addRange(range);
  hours = test.addCalendarHours(Day.SATURDAY);
  hours.addRange(range);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜