Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Item has already been added: Key in dictionary (Read 2797 times)
rfeuer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Jan 16th, 2006
Item has already been added: Key in dictionary
Jun 23rd, 2006 at 2:14pm
Print Post  
Hi,

I may have discovered a bug with your control. Here is the scenario:

I am loading my appointment and recurrence data from a database. For recurring items, I use the generateItems, loop through the item collection and assign my properties, .id, starttime, etc manually then add the occurrence to the schedule (instead of adding the master item). I have discovered that if I add more than 2 occurrences from the same series, both having the same exact start time, I get "Item has already been added: Key in dictionary". I had double checked to make sure each item had a unique id and the occurrence was unique and both were. I also, checked the schedules item collection to make sure it only contained what I added. You can reproduce this problem by running the code below. Change the numOfOccurrences to 2 and it will work fine. 


       Dim start As Date = Now
       Dim dtend As Date = start.AddMinutes(30)
       Dim app As Appointment
       Dim appOcc As Appointment
       Dim appColl As MindFusion.Scheduling.ItemCollection
       Dim Recurrence As Recurrence = New Recurrence
       Recurrence.Pattern = RecurrencePattern.Daily
       Recurrence.DailyRecurrence = DailyRecurrence.ByDayInterval
       Recurrence.Days = 1
       Recurrence.RecurrenceEnd = RecurrenceEnd.NumOccurrences
       Recurrence.NumOccurrences = 3
       Recurrence.StartDate = start
       Recurrence.StartHour = start.Hour
       Recurrence.StartMinute = start.Minute

       app = New Appointment
       app.HeaderText = "Recurring event"
       app.StartTime = start
       app.EndTime = dtend
       app.Recurrence = Recurrence

       appColl = app.Recurrence.GenerateItems(app.Recurrence.StartDate, app.Recurrence.GetEndDate)

       Dim i As Integer = 1 'this would be my unique id from the db

       For Each appOcc In appColl
           appOcc.Id = i
           appOcc.StartTime = start
           appOcc.EndTime = dtend
           _calendar.Schedule.Items.Add(appOcc)
           i += 1
       Next
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint