Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Show new event
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Show new event

 Post Reply Post Reply
Author
Message
IDBG View Drop Down
Groupie
Groupie


Joined: 16 May 2006
Location: United States
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote IDBG Quote  Post ReplyReply Direct Link To This Post Topic: Show new event
    Posted: 16 May 2006 at 1:11pm

Hi!  We're in the process of evaluating your software for our company.  Everything works great, except for one issue.

When we tried setting the Calendar Control to an SQL database, we had a serious performance issue, so we are now manually creating all events.  The code is pretty simple (VB6) ...

<Setup calendar/resources/schedules>
<open recordset>
<Loop>
  <calendarcontrol.dataprovider.CreateEventEx(rst("ID"))> ;
  <set recurring properties>
<end loop>
<CalendarControl.Populate()>

The issue I have is as follows:
- When I create a new event and try to add it the current view, it won't show up.  I've tried the following two methods:

Method 1:
<create new event in database table>
<CalendarControl.GetAllEventsRaw()>
<Append new event to this collection>
<CalendarControl.Populate()>

Method 2:
<Create new event in database table>
<CalendarControl.DataProvider.CreateNewEventEx(rst("ID")) >
<CalendarControl.DataProvider.AddEvent>
<CalendarControl.Populate()>

In both cases, the new event won't show up until I do the following

<CalendarControl.dataprovider.RemoveAllEvents>
<Remove all resources>
<Remove all schedules>
<Rebuild entire calendar from database table>

Please help!  I'm probably missing something.  One quick note that might help...I couldn't get the calendar to show any events until I added the following:

If CalendarResourcesManager.AddDataProvider("", 0) = False Then
    Exit Sub
End If

Could this be the problem?

Please help! We are  in the water until we resolve this issue!

Thanks!!!
Mir

 

 

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2006 at 1:09pm
Hi,

Method 1 is not a method for adding an event.
GetAllEventsRaw() is used to export all events or some similar purposes.

The correct order of action would be:
1) Open data provider(s)
2) Configure resources/schedules (if you need them)
3) Add events to data provider(s). You can use following methods:
   CalendarControl.DataProvider.AddEvent
   CalendarResource.DataProvider.AddEvent
4) When finished adding events, call CalendarControl.Populate()

When you add a single events, verify that some important properties are set correctly: StartTime, EndTime, ScheduleID, recurrence options if applicable.

I'd also suggest you to look deeper at our sample applications. See VB CalendarSample for following topics:
 * Simple DataProviders.
    Open/close a data provider; connection strings for different data provider types: memory, XML/binary, DataBase, MAPI.
 * Resources/schedules.
    Simple usage; extended - using resource manager (see corresponding menu items in the sample)
 * Using "custom" data provider to work with custom DB.
   See SQL Server example.

Also this forum contain a lot of information on those subjects.

--
WBR,
Serge
Back to Top
IDBG View Drop Down
Groupie
Groupie


Joined: 16 May 2006
Location: United States
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote IDBG Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2006 at 1:49pm

Hi!  Thanks for the response!

I know Method 1 isn't for this purpose, but I was trying that to see if maybe it'll work that way.

My app loads the Calendar in the following way:

- Load list of users
- Load list of resources
- User checks off users and resources he/she wants to see
- Open recordset from db
- Populate calendar

All this works perfectly.

This screen is still open when the user click "New Appointment"

On the "New Appointment" screen I save the new entry in the db
- Create new CalendarEvent
- Append this to the currently loaded calendar with
    CalendarControl.DataProvider.AddEvent CEvent
    CalendarControl.Populate()

Nothing happens.  I've debugged and scheduleID's match, start and end times are accuarate and all other information is accurate.

Is there an issue if the calendar is "manually" populated first and if you are trying to add a new event manually again?

I've gone through the entire demo project line-by-line and I think I understand it well.  I'm probably missing some small step somewhere..or at least I hope it's small .

2006-05-17_134906_ScrShot1.zip

Thanks again!

Mir

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2006 at 2:48pm
Hi,

It would be nice if you send a piece of code which initializes calendar resources in your application, catches database events, and adds a new single event. It would allow me to analyze your steps in more details.

CalendarResourcesManager.AddDataProvider("", 0)
How do you manage a date provider?

Some more notes about data providers.
For resources you have to call one of following methods:
CalendarResource.SetDataProvider(DataProvider)
CalendarResource.SetDataProvider2(ConnectionString)

Normally, 1 data provider object is enough, and for a first resource you call SetDataProvider2 to create it and for others call like:
objRCxxx.SetDataProvider(objRC0.DataProvider)

Also you can use CalendarResourcesManager like:
CalendarResourcesManager.AddDataProvider("", xtpCalendarDPF_CloseOnDestroy)
objRCxxx.SetDataProvider( CalendarResourcesManager. DataProvider(0) )

CalendarControl.DataProvider property works like:  CalendarControl.MultipleResources(0).DataProvider

Ensure that you have only one data provider for all resources.

--
WBR,
Serge
Back to Top
IDBG View Drop Down
Groupie
Groupie


Joined: 16 May 2006
Location: United States
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote IDBG Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2006 at 1:09am

Hi Serge,

Here's the routine.

Public RMan As New CalendarResourcesManager
Dim pData As CalendarDataProvider
Dim pSchedules As CalendarSchedules
Dim pRCDesc As CalendarResourceDescription

If RMan.AddDataProvider("", 32) = False Then
    Exit Sub
End If
   

Set pData = RMan.DataProvider(0)
Set pSchedules = pData.Schedules
Set Rscs = Me.CalendarControl.MultipleResources
       
Dim strName As String
Dim i As Integer, j As Integer
       
j = pSchedules.Count
While j > 0
    pSchedules.RemoveSchedule (j)
    j = j - 1
Wend

j = RMan.ResourcesCount
While j > 0
    RMan.RemoveResource (j - 1)
    j = j - 1
Wend
       
pData.Save
RMan.SaveCfg App.Path & "\MCal.xtpCal"
Set Rscs = Me.CalendarControl.MultipleResources
       
i = 0
j = 0
       
'First process all users
For i = 0 To 19
    If arCals(i) <> "" Then
        strName = frmPaneCalendar.trvCalendar.Nodes(arCals(i)).Text
        pSchedules.A ddNewSchedule strName
        pData.Save
        RMan.AddReso urce strName, True
        Set pRCDesc = RMan.Resource(j)
        pRCDesc.Reso urce.SetDataProvider pData, False
        pRCDesc.Reso urce.ScheduleIDs.Add pSchedules(j).ID
        pRCDesc.Gene rateName = True
        j = j + 1
    End If
Next
        
i = 0
     
RMan.ApplyToCalendar Me.CalendarControl
        
Me.CalendarControl.DataProvider.RemoveAllEvents

<Open Recordset from database>

<do while not rst.eof>
    Set cEvent = Me.CalendarControl.DataProvider.CreateEventEx(rst!ApptID)
    <set all event properties and recurring properties>
    <cevent.ScheduleID=x> 'To show for appropriate user
    Me.CalendarControl.DataProvider.AddEvent cEvent
<loop>

Me.CalendarControl.Populate()

Hope this helps.  Thanks a bunch for your help!

If you'd like me to email you the VB module, please send me an e-mail address, and I'll be happy to do so.

Thanks!!
Mir

Back to Top
IDBG View Drop Down
Groupie
Groupie


Joined: 16 May 2006
Location: United States
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote IDBG Quote  Post ReplyReply Direct Link To This Post Posted: 21 May 2006 at 3:13am

Serge,

This is very embarassing!!!!

It works fine!!  My issue was I had the wrong instance of the form

It works absolutely great!!!

Thanks!
Mir

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.