Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Proper Way to Add a Resource (Read 3494 times)
Alon.Chanoch
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jun 30th, 2008
Proper Way to Add a Resource
Jun 30th, 2008 at 1:19pm
Print Post  
Hello, I am new to Planner.Net so please bear with me Smiley For some reason ... I can not add a resource (and subsequently view the Resource view) properly. I know it must be a simple misunderstanding ... so if the solution already exists, please point me in the correct direction.

OK ... so this is what I am doing (what is wrong):
1) I have created a custom appointment item, lets say called "Party" and I have added the "planner" resources to the base class by calling base.Resources.Add(plannerResource);
2) I add all my parties to a generic List
3) When I go to display the calendar control ... I loop through all my parties in the List<Parties> generic object and and if there is a resource assigned ... I do a calendar.resources.add() for each planner assigned to the party.

Now .. .when I change the calendar view to resources and set the grouptype to resources ... I have a single entry for each planner for each party. This leads to tens of "planners" in the resource view, with each one only having one party. In actuality, I only have 5 planners and numerous parties that each one works on. If I only add resources to the calendar that have not been added, then I only get the 5 planners, but only the first party they are assigned too.

What am I doing wrong when adding the resources to the calendar? Any suggestions?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Proper Way to Add a Resource
Reply #1 - Jun 30th, 2008 at 2:16pm
Print Post  
Where do you create the resources you are adding to the Resources collection of your items (parties)?

The most common way to work with resources in Planner.NET is to create all possible resources and add them to the Calendar.Schedule.Resources collection. Then, select those resources you would like to group by and add them to the Calendar.Resources collection (It is not really necessary to add the resources to the first collection since they will be automatically added there when you add them to the second collection.). Associate items with resources by adding references to existing resources to the Resources collection  of the items. Finally, set the Calendar.GroupType property to the appropriate value.

Hope that helps.

Meppy
  
Back to top
 
IP Logged
 
Alon.Chanoch
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jun 30th, 2008
Re: Proper Way to Add a Resource
Reply #2 - Jun 30th, 2008 at 2:34pm
Print Post  
Thanks for the quick reply Smiley

I retrieve the list of Parties from a SQL Database, and each Party has a number of planners assigned. So I am adding 1 or more planners to each party (as a resource). I add all the parties into a generic list (only because my data access logic is separate from the form that has the calendar control on it).
When the form with the calendar control on it loads, it reads all the parties from the list and adds each party to the calendar control ... while I am adding each party ... I also add each planner to the calendars resource collection.

Based on your comments ... I should not be adding the resource to both the party (appointment) and the calendar resources collection? I basically need to load the resources once and then have each party select the resource.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Proper Way to Add a Resource
Reply #3 - Jun 30th, 2008 at 3:07pm
Print Post  
Quote:
I should not be adding the resource to both the party (appointment) and the calendar resources collection?


Well, you need to add the resource to both collections: to the item's Resources collection - to indicate that the item is related to this resource and to the Calendar.Resources collection - to indicate that you want to group by this resource.

What I was suspecting is, that you might be creating a new Resource object every time you are associating a resource with an item. This way you will end up with many Resource objects representing the same logical resource. Is that the case?

Meppy
  
Back to top
 
IP Logged
 
Alon.Chanoch
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jun 30th, 2008
Re: Proper Way to Add a Resource
Reply #4 - Jun 30th, 2008 at 3:22pm
Print Post  
Yes ... I think that is the case. I add a new planner resource to each Party ... and then when I load all the parties into the calendar I add each party resource ... however, when I try to only add a resource once to the calendar ... then it is still not correct. So ... is this what I should do ...
1) Create one collection of resources.
2) When creating each party appointment just add the resource that is already in the collection.
3) Add the resource collection (from step 1) to the calendar control.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Proper Way to Add a Resource
Reply #5 - Jun 30th, 2008 at 3:56pm
Print Post  
Yes, that's exactly what you should do. Smiley
  
Back to top
 
IP Logged
 
Alon.Chanoch
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jun 30th, 2008
Re: Proper Way to Add a Resource
Reply #6 - Jul 1st, 2008 at 11:57am
Print Post  
Thanks! That seems to work now. Amazing how things work when you code them properly Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint