Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) RecurrenceException and RecurrenceException (Read 7240 times)
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
RecurrenceException and RecurrenceException
Sep 24th, 2013 at 5:24am
Print Post  
Hi, I am saving data to a database but am not using the SaveTo method. I have no isssues with this except when creating recurrence exceptions. I guess all i really need to know is what data is stored in the RecurrenceException "Item", "IsDeleted" and "Index" Fields and in the RecurrenceExceptions "Recurrence", "Exception"Fields.

I assume as follows,
"Item" would be the Item Key?
"IsDeleted" would be true once item is deleted?
"Index" No idea?? Refference to specific recurrence date???
and
"Recurrence" would be the Recurrence Key??
"Exception" would be the RecurrenceException Key??

Please advise if this makes sence and if this is correct.

Also the "Index" is the one I have no idea of.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: RecurrenceException and RecurrenceException
Reply #1 - Sep 24th, 2013 at 6:15am
Print Post  
Hi,

The fields in the RecurrenceException table have the following meaning:

Item - This is indeed a key of an item in the Items table. This item contains the property values of the exception.
IsDeleted - Deleting an occurrence in the recurrence is considered an exception as well. This field is true for such exceptions. This is the value of the RecurrenceException.IsDeleted property.
Index - This is the value of Item.OccurrenceIndex, or the 0-based index of the exception within the recurrence sequence. For example, if a recurrence repeats weekly, starting at week 1, the occurrence in week 1 will have index 0, the occurrence in week 2 will have index 1, and so on.

Regarding the RecurrenceExceptions table, it is simply a many-to-many table connecting Recurrence and RecurrenceException. That is, the Recurrence field is a key of a recurrence in the Recurrence table and Exception is the key of the related exception in the RecurrenceException table, as you suggested.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: RecurrenceException and RecurrenceException
Reply #2 - Sep 24th, 2013 at 10:02am
Print Post  
Thanks so much Meppy. That is exactly what I was looking for.
  

Regards,
TRB
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: RecurrenceException and RecurrenceException
Reply #3 - Sep 29th, 2013 at 12:17pm
Print Post  
Hi Meppy,
I have added code to the RecurringItemDeleting event to create an exception as mentioned above. I have looked over this a number of times but am getting an error. The only thing I can think of is that i am using an SQL Server database not the standard MSaccess one. The stack trace is as follows: System.NullReferenceException was caught
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=MindFusion.Scheduling
  StackTrace:
       at MindFusion.Scheduling.DataBinding.x8db18c2080b4ae64.xdf653366cdb56b9d(Object x337e217cb3ba0627, Object xaeebf6cdac58d859, IValueConverter x5fbb2bb8f302374f)
       at MindFusion.Scheduling.DataBinding.x8db18c2080b4ae64.x9641f931b2968145(Object x1563b91fcacc4108, IValueConverter x5fbb2bb8f302374f)
       at MindFusion.Scheduling.DataBinding.x8db18c2080b4ae64.x0d510b9a14a54e2f(IValueConv
erter x5fbb2bb8f302374f)
       at MindFusion.Scheduling.DataBinding.xa7e178e5abda1bf4.xc278b192d73221db(IValueConv
erter x5fbb2bb8f302374f)
       at MindFusion.Scheduling.WinForms.Calendar.LoadFromDataSource(IValueConverter converter)
       at MindFusion.Scheduling.WinForms.Calendar.LoadFromDataSource()
       at WindowsApplication1.Module3.LoadSchedule() in C:\Users\*\Documents\Visual Studio 2012\Projects\*\*\*.vb:line 66
  InnerException:

Any Ideas??
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: RecurrenceException and RecurrenceException
Reply #4 - Sep 30th, 2013 at 5:57am
Print Post  
Hi,

What code did you add to the RecurringItemDeleting event handler?

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: RecurrenceException and RecurrenceException
Reply #5 - Oct 2nd, 2013 at 4:07am
Print Post  
Meppy, I have the following code (I have also used the Mark Exception with no luck)

Code
Select All
                    If con.State = ConnectionState.Closed Then con.Open()

                    My_SQL_Sub("Insert Into Item([Task],[StartTime],[EndTime],[AllDayEvent],[HeaderText],_
[DescriptionText],[ImageIndex],[Id],[Locked],[Reminder],[Recurrence],[RecurrenceState],[OccurrenceIndex],[Priority],[Style],[SelectedStyle],[Visible],[Tag],_
[PointedStyle],[PointedSelectedStyle],[AllowChangeStart],[AllowChangeEnd],[AllowMove], [PlannedDuration], [Area], _[Team], [Crew]) Select [Task],CONVERT(datetime,'" & Format(e.Item.StartTime, "yyyy-MM-ddTHH:mm:ss") & "'),_
CONVERT(datetime,'" & Format(e.Item.EndTime, "yyyy-MM-ddTHH:mm:ss") & "'),[AllDayEvent],[HeaderText],[DescriptionText],_
[ImageIndex],[Id],[Locked],[Reminder],[Recurrence],'2', '" & e.Item.OccurrenceIndex & "' ,[Priority],[Style],[SelectedStyle],[Visible],[Tag],[PointedStyle],[PointedSelectedStyle],[AllowChangeStart],_
[AllowChangeEnd],[AllowMove], [PlannedDuration], [Area],_
 [Team], [Crew] From Item Where [Key] = (Select [Key] From Item Where ID = '" & e.Item.Id & "' AND  [RecurrenceState] = 3) Declare @MasterKey int Set @MasterKey = (Select scope_identity()) Insert Into [RecurrenceException] ([Item], [IsDeleted], [Index], _
[Team]) Values (@MasterKey, 'True','" & e.Item.OccurrenceIndex & "', '" & pTeam & "') Declare @NewKey int Set @NewKey = (Select scope_identity()) Insert Into [RecurrenceExceptions] ([Recurrence], _
[Exception], [Team]) (Select [Key], @NewKey, '" & pTeam & "' From Recurrence Where [Master] = (Select [Key] From Item Where ID = '" & e.Item.Id & "' AND  [RecurrenceState] = 3))", , , True)

                    If con.State = ConnectionState.Open Then con.Close() 



All this code does is insert new rows into the "Item", "RecurrenceException" and "RecurrenceExceptions" Tables. I have confirmed this enters the correct data into the database.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: RecurrenceException and RecurrenceException
Reply #6 - Oct 2nd, 2013 at 7:16am
Print Post  
Hi,

Unfortunately I am not able to tell what might be wrong by looking at the obfuscated stack trace.

However, do note that the Planner.NET databinding engine expect that a field-to-property mapping is defined for each field in the database. The mappings for various calendar classes are contained in the respective Calendar.*DataPropertyMap collection. For example, the mappings for the Item class are specified through the Calendar.ItemDataPropertyMap collection. These collections are initialized with mappings for the built-in properties. However, I noticed that you are writing some custom values in the database (Team?). If this is the case, you have to make sure that there is a mapping between these custom properties and their corresponding database fields.

If this doesn't help, is it possible to send me a small sample project along with the SQL database (and the My_SQL_Sub routine), which reproduces the problem?

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: RecurrenceException and RecurrenceException
Reply #7 - Oct 2nd, 2013 at 1:14pm
Print Post  
I have Removed All additional fields from the database and dataset yet the problem is still there. I will work on a sample project as you requested.

Just to confirm, I ran databiding sample that comes with planner.Net and saved a recurring appointment. I then deleted one instance of this appointment. I reviwed the tables in the planner.mdb and my code creates records exactly the same in the following tables "Item", "RecurrenceException" and "RecurrenceExceptions". Should this be all that is needed to create an exception??

As far as I can tell this should be all and seems pretty straight foward?? Am i missing somthing??
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: RecurrenceException and RecurrenceException
Reply #8 - Oct 2nd, 2013 at 2:08pm
Print Post  
Actually, after a second revision I noticed that the Item table also refers to the Style table through the Style, SelectedStyle, PointedStyle, and PointedSelectedStyle fields. This will lead to problems if the Style table is empty. You could try disabling this relationship during load by setting Calendar.StylesDataMember to an empty string.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: RecurrenceException and RecurrenceException
Reply #9 - Oct 3rd, 2013 at 8:12am
Print Post  
You wont believe what i had done! After writing my own code in the Item.drawing event to catch the "deleted" occurances to prevent them being drawn (which actually works) I went back to basics.....I had the RecurrenceExceptionsDataMember set to RecurrenceExceptions in place of RecurrenceException...I am so sorry to waste your time!!

One Issue I still have with it is that the in  RecurrenceExceptionsDataPropertyMap when the drop down to show fields to bind to is opened I only get a list of the Recurrences Table fields and not the RecurrenceException Fields. I found this as after swapping the DataMember to RecurrenceException I had an error "Delete does not exist". I have therfore removed "Delete"-"IsDeleted" from the property map. Please advise what issues this may cause if any?
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: RecurrenceException and RecurrenceException
Reply #10 - Oct 3rd, 2013 at 10:22am
Print Post  
This appears to be a bug in the drop-down list. A fix can be downloaded from the link below:

https://mindfusion.eu/_temp/MindFusion.Scheduling.trial5.zip

However, removing the "Deleted" <-> "IsDeleted" binding from the map may not be wise because this way you may prevent the Deleted property of Recurrence exceptions from being saved/loaded to/from the database.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint