This is a migrated thread and some comments may be shown as answers.

Looking for a RadScheduler example binded to Exchange server

8 Answers 245 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 22 Jun 2010, 10:57 PM
Hey telerik team,

I was looking for an example of how to bind a RadScheduler to an Exchange server calendar for retrieving and creating appointments. It seems I can't find anything satisfying on the web, nether within the Telerik demos web page.

Please help, I'm using the RadControls for ASP.NET AJAX Q1 2010 library. also using ASP.Net 4.0 and Exchange Server 2007 if that helps.

Thanks.

Nick

8 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 23 Jun 2010, 03:55 PM
Hello Nicolas,

We have a sample provider implementation for RadScheduler. Please take a look at this help topic.

I hope this helps.

Regards,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Stewart
Top achievements
Rank 1
answered on 07 Dec 2010, 12:19 AM
Do you have examples that use EWS Managed API to populate RadScheduler control with appointments?  It seems like there should be documentation.  I really only want to view the appointments using the RadScheduler at this point. 

Thanks,
Ishmael
0
Peter
Telerik team
answered on 10 Dec 2010, 11:12 AM
Hello Ishamal,

Thank you for this excellent question. Currently, we don't have any examples with EWS Managed API, but it would be nice to create one. I have logged your suggestion and we will consider it. 

In the meantime, you can review the following demos which might help you get started with this task:
Binding to Generic ListWeb Service, WCF Web Service.

Your Telerik points have been updated!


Best wishes,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Stewart
Top achievements
Rank 1
answered on 10 Dec 2010, 08:07 PM
Thank you. 

Also, it seems like the process of populating data should be more straight forward.  If Exchange Web Services is the source of data, populating the scheduler should be a straight forward process.

I have looked up the Generic List sample that you provided. It seems to get me closer to my goal.  I do have a problem with the sample however.

This sample uses an updated AppointmentInfo.vb class compared to the sample provided by the initial installation.  However, there is no cooresponding AppointmentList.vb class. http://demos.telerik.com/aspnet-ajax/scheduler/examples/bindtolist/defaultvb.aspx

Can you provide an updated AppointmentList.vb class?  Thanks.
0
Nikolay Tsenkov
Telerik team
answered on 15 Dec 2010, 02:25 PM
Hi Ishamal Amin,

Well, if the demo previously made some use of AppointmentList type which currently is not present, this only means the demo is updated. I am not sure what exactly do you need this type for?
Could you, please, further clarify that?


Regards,
Nikolay Tsenkov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Stewart
Top achievements
Rank 1
answered on 15 Dec 2010, 05:29 PM
I was able to resolve my issue with populating data into RadScheduler using Exchange Webservice API.  I had to make further modifications to AppointmentInfo.vb.  Thanks for your help.

Ishmael
0
James
Top achievements
Rank 2
answered on 19 Jan 2011, 12:49 PM
Hey Ishamal, 

I don't suppose you could share how you manage to do this exactly with the API.

It would be good if you could post some code here.

Thanks

James
0
Stewart
Top achievements
Rank 1
answered on 21 Jan 2011, 06:02 PM

I have included the major files that are necessary to make this work.  I can try to answer quetions that you may have.  I went a little further in my
design by allowing the event IDs provided by the Exchange Server to be passed to the scheduler.  This allows me to retrieve the details of events to be displayed on a different page.  Let me know if you have questions.


'file name: radSch.aspx
'=======================================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="radSch.aspx.vb" Inherits="radSch" %>
<%
@ Register src="radSchUC.ascx" tagname="radSchUC" tagprefix="uc1" %>

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

 

 

 

<html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">

 

 

 

 

<title></title>
</head>

<
body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server" />
<uc1:radSchUC ID="radSchUC1" runat="server" DetailURL="defaultDetail.aspx" Mailbox=user@domain.com /> <!-- insert user email used to manage calendar events-->
</div>
</form>
</
body>
</
html>
'====================================================================
'File name: radSchUC.ascx
'===========================================

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="radSchUC.ascx.vb" Inherits="radSchUC" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

       
        <telerik:RadScheduler ID="RadScheduler1" runat="server" Height=""
            ReadOnly="True" DataEndField="End" DataKeyField="ID"
            DataStartField="Start"
            DataSubjectField="Subject" SelectedView="MonthView">
            <TimelineView ReadOnly="True" />
            <WeekView ReadOnly="True" />
            <DayView ReadOnly="True" />
            <MultiDayView ReadOnly="True" />
            <MonthView ReadOnly="True"  />
        </telerik:RadScheduler>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
            DeleteMethod="DeleteAppointment" InsertMethod="InsertAppointment"
            SelectMethod="AllData" TypeName="AppointmentList"
            UpdateMethod="UpdateAppointment">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Start" Type="DateTime" />
                <asp:Parameter Name="End" Type="DateTime" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="RecurrenceParentID" Type="Object" />
                <asp:Parameter Name="RecurrenceState" Type="Object" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="ID" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Start" Type="DateTime" />
                <asp:Parameter Name="End" Type="DateTime" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="RecurrenceParentID" Type="Object" />
                <asp:Parameter Name="RecurrenceState" Type="Object" />
            </UpdateParameters>
        </asp:ObjectDataSource>

'==============================================================
'File name: RadSchUC.ascx.vb
'Comments:

Imports System
Imports System.IO
Imports System.Xml
Imports Microsoft.Exchange.WebServices.Data
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Web.UI
Imports Telerik.Web.UI

Partial Class radSchUC
    Inherits System.Web.UI.UserControl

        Dim writer As StreamWriter

#Region "Properties"

        Private m_height As String = "200"
        Private m_width As String = "200"
        Private m_mailbox As String
        Private m_days As Integer = 8
        Private m_showDateRange As Boolean = False
        Private m_detailURL As String = "detail.aspx"

    Public Property Height() As String
        Get
            Return m_height
        End Get
        Set(ByVal value As String)
            m_height = value
        End Set
    End Property

    Public Property Width() As String
        Get
            Return m_width
        End Get
        Set(ByVal value As String)
            m_width = value
        End Set
    End Property

    Public Property Mailbox() As String
        Get
            Return m_mailbox
        End Get
        Set(ByVal value As String)
            m_mailbox = value
        End Set
    End Property

    Public Property Days() As String
        Get
            Return m_days
        End Get
        Set(ByVal value As String)
            m_days = value
        End Set
    End Property

    <DefaultValue("False")> _
    Public Property ShowDateRange() As String
        Get
            Return m_showDateRange
        End Get
        Set(ByVal value As String)
            m_showDateRange = value
        End Set
    End Property

    Public Property DetailURL() As String
        Get
            Return m_detailURL
        End Get
        Set(ByVal value As String)
            m_detailURL = value
        End Set
    End Property

    Private m_CallID As String = String.Empty
    Public Property CallID() As String
        Get
            Return m_CallID
        End Get
        Set(ByVal value As String)
            m_CallID = value
        End Set
    End Property
#End Region

    Private Const AppointmentsKey As String = "BindToList"

    Private ReadOnly Property Appointments() As List(Of AppointmentInfo)
        Get
            Dim sessApts As List(Of AppointmentInfo) = TryCast(Session(AppointmentsKey), List(Of AppointmentInfo))
            If sessApts Is Nothing Then
                sessApts = New List(Of AppointmentInfo)()
                Session(AppointmentsKey) = sessApts
            End If

            Return sessApts
        End Get
    End Property
    Sub RadScheduler1_AppointmentClick(ByVal sender As Object, ByVal e As SchedulerEventArgs) Handles RadScheduler1.AppointmentClick
        Dim ai As AppointmentInfo = FindById(e.Appointment.ID)
        Response.Redirect(m_detailURL & "?CalID=" + HttpUtility.UrlEncode(ai.ID.ToString()))
    End Sub

    Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs)
        Appointments.Add(New AppointmentInfo(e.Appointment))
    End Sub

    Protected Sub RadScheduler1_AppointmentUpdate(ByVal sender As Object, ByVal e As AppointmentUpdateEventArgs)
        Dim ai As AppointmentInfo = FindById(e.ModifiedAppointment.ID)
        ai.CopyInfo(e.ModifiedAppointment)
    End Sub

    Protected Sub RadScheduler1_AppointmentDelete(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs)
        Appointments.Remove(FindById(e.Appointment.ID))
    End Sub

    Private Sub InitializeResources()

    End Sub

    Private Sub InitializeAppointments()
       
    End Sub

    Private Function FindById(ByVal ID As Object) As AppointmentInfo
        For Each ai As AppointmentInfo In Appointments
            If ai.ID.Equals(ID) Then
                Return ai
            End If
        Next

        Return Nothing
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim service As New ExchangeService(ExchangeVersion.Exchange2007_SP1)
        Dim serviceCred As New WebCredentials(Net.CredentialCache.DefaultCredentials)
        Dim serviceURI As New Uri("https://domain.com/ews/Exchange.asmx") <!-- insert path to Exchange.asmx -->
        Dim calAppt As Microsoft.Exchange.WebServices.Data.Appointment
        Dim calStringB As New StringBuilder
        Dim dateStart As Date = Date.Today
        Dim dateEnd As Date = DateAdd(DateInterval.Second, -1, DateAdd(DateInterval.Day, m_days + 1, dateStart))

        service.Credentials = serviceCred
        service.Url = serviceURI

        Dim findResults As FindItemsResults(Of Microsoft.Exchange.WebServices.Data.Appointment)

       findResults = service.FindAppointments(New FolderId(WellKnownFolderName.Calendar, _
                                                New Mailbox(m_mailbox)), _
                                                New CalendarView(dateStart, dateEnd))

        'setup new objects

        '///////////////////////////////////////////////
        If Not IsPostBack Then
            Session.Remove(AppointmentsKey)

            'InitializeResources()
            Dim resType As New ResourceType("User")
            resType.ForeignKeyField = "UserID"

            RadScheduler1.ResourceTypes.Add(resType)
            RadScheduler1.Resources.Add(New Resource("user", 1, "Name")) '<!-- update user, id, and name of calendar -->
          
     'POPULATE RADSCHEDULER

            Dim j As Integer = 0

            For Each calAppt In findResults          
                Appointments.Add(New AppointmentInfo(calAppt.Subject.ToString().ToString, calAppt.Start, calAppt.End, String.Empty, Nothing, j, calAppt.Id.ToString()))

                j += 1
            Next

            RadScheduler1.DataSource = Appointments
        End If
    End Sub
End Class
'==================================================================
'File name: AppointmentInfo.vb:
'Comments: I added an override for the New() Sub Procedure that allows a parameter to be passed from the Web Exchange Server.

Imports System
Imports System.Collections.Generic
Imports System.Web
Imports Telerik.Web.UI

''' <summary>
''' Summary description for AppointmentInfo
''' </summary>
Public Class AppointmentInfo

    Private _id As String
    Private _subject As String
    Private _start As DateTime
    Private _end As DateTime
    Private _recurrenceRule As String
    Private _recurrenceParentId As String
    Private _userID As System.Nullable(Of Integer)
    Private _recurrenceState As Telerik.Web.UI.RecurrenceState
    Private _calID As String

    Public ReadOnly Property ID() As String
        Get
            Return _id
        End Get
    End Property

    Public Property Subject() As String
        Get
            Return _subject
        End Get
        Set(ByVal value As String)
            _subject = value
        End Set
    End Property

    Public Property Start() As DateTime
        Get
            Return _start
        End Get
        Set(ByVal value As DateTime)
            _start = value
        End Set
    End Property

    Public Property [End]() As DateTime
        Get
            Return _end
        End Get
        Set(ByVal value As DateTime)
            _end = value
        End Set
    End Property

    Public Property RecurrenceRule() As String
        Get
            Return _recurrenceRule
        End Get
        Set(ByVal value As String)
            _recurrenceRule = value
        End Set
    End Property

    Public Property RecurrenceParentID() As String
        Get
            Return _recurrenceParentId
        End Get
        Set(ByVal value As String)
            _recurrenceParentId = value
        End Set
    End Property

    '_recurrenceState As Telerik.Web.UI.RecurrenceState
    Public Property RecurrenceState() As Telerik.Web.UI.RecurrenceState
        Get
            Return _recurrenceState
        End Get
        Set(ByVal value As Telerik.Web.UI.RecurrenceState)
            _recurrenceState = value
        End Set
    End Property

    Public Property UserID() As System.Nullable(Of Integer)
        Get
            Return _userID
        End Get
        Set(ByVal value As System.Nullable(Of Integer))
            _userID = value
        End Set
    End Property

    Private Sub New()
        Me._id = Guid.NewGuid().ToString()
    End Sub

    Public Sub New(ByVal subject As String, ByVal start As DateTime, ByVal [end] As DateTime)
        Me.New()
        Me._subject = subject
        Me._start = start
        Me._end = [end]
    End Sub

    Public Sub New(ByVal subject As String, ByVal start As DateTime, ByVal [end] As DateTime, ByVal recurrenceRule As String, ByVal recurrenceParentID As String, ByVal userID As System.Nullable(Of Integer))
        Me.New()
        Me._subject = subject
        Me._start = start
        Me._end = [end]
        Me._recurrenceRule = recurrenceRule
        Me._recurrenceParentId = recurrenceParentID
        Me._userID = userID
    End Sub

'Added the following override in order to pass the calendar id passed by the Exchange Server:
    Public Sub New(ByVal subject As String, ByVal start As DateTime, ByVal [end] As DateTime, ByVal recurrenceRule As String, ByVal recurrenceParentID As String, ByVal userID As System.Nullable(Of Integer), ByVal calID As String)
        'Me.New()
        Me._id = calID
        Me._subject = subject
        Me._start = start
        Me._end = [end]
        Me._recurrenceRule = recurrenceRule
        Me._recurrenceParentId = recurrenceParentID
        Me._userID = userID

    End Sub

    Public Sub New(ByVal source As Appointment)
        Me.New()
        CopyInfo(source)
    End Sub

    Public Sub CopyInfo(ByVal source As Appointment)
        Subject = source.Subject
        Start = source.Start
        [End] = source.[End]

        RecurrenceRule = source.RecurrenceRule
        If source.RecurrenceParentID IsNot Nothing Then
            RecurrenceParentID = source.RecurrenceParentID.ToString()
        End If

        Dim user As Resource = source.Resources.GetResourceByType("User")
        If user IsNot Nothing Then
            UserID = DirectCast(user.Key, System.Nullable(Of Integer))
        Else
            UserID = Nothing
        End If

    End Sub

End Class

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================

'File name: AppointmentList.vb
'Comments: No changes to this file

Imports System
Imports System.Collections.Generic
Imports System.Web
Imports Telerik.Web.UI

''' <summary>
''' Summary description for AppointmentList
''' </summary>
Public Class AppointmentList
    Const AppointmentsKey As String = "Scheduler.GettingStarted_Apts"
    Public Shared Function AllData() As List(Of AppointmentInfo)
        Dim sessApts As List(Of AppointmentInfo) = TryCast(HttpContext.Current.Session(AppointmentsKey), List(Of AppointmentInfo))
        If sessApts Is Nothing Then
            sessApts = New List(Of AppointmentInfo)()
            HttpContext.Current.Session(AppointmentsKey) = sessApts
        End If
        Return sessApts
    End Function
    Public Shared Sub InsertAppointment(ByVal Subject As String, ByVal Start As DateTime, ByVal [End] As DateTime, ByVal RecurrenceRule As String, ByVal RecurrenceParentID As [Object], ByVal RecurrenceState As Telerik.Web.UI.RecurrenceState)
        Dim sessApts As List(Of AppointmentInfo) = AllData()
        Dim ai As New AppointmentInfo(Subject, Start, [End])
        ai.RecurrenceRule = RecurrenceRule
        ai.RecurrenceParentID = RecurrenceParentID
        ai.RecurrenceState = RecurrenceState
        sessApts.Add(ai)
    End Sub
    Public Shared Sub DeleteAppointment(ByVal ID As String)
        Dim sessApts As List(Of AppointmentInfo) = AllData()
        sessApts.Remove(FindById(ID, sessApts))
    End Sub
    Public Shared Sub UpdateAppointment(ByVal ID As String, ByVal Subject As String, ByVal Start As DateTime, ByVal [End] As DateTime, ByVal RecurrenceRule As String, ByVal RecurrenceParentID As [Object], _
     ByVal RecurrenceState As Telerik.Web.UI.RecurrenceState)
        Dim sessApts As List(Of AppointmentInfo) = AllData()
        Dim ai As AppointmentInfo = FindById(ID, sessApts)
        ai.Subject = Subject
        ai.Start = Start
        ai.[End] = [End]
        ai.RecurrenceRule = RecurrenceRule
        ai.RecurrenceParentID = RecurrenceParentID
        ai.RecurrenceState = RecurrenceState
    End Sub
    Public Shared Function FindById(ByVal ID As String, ByVal sessApts As List(Of AppointmentInfo)) As AppointmentInfo
        For Each ai As AppointmentInfo In sessApts
            If ai.ID = ID Then
                Return ai
            End If
        Next
        Return Nothing
    End Function
End Class

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================

'=============================================================

Tags
Scheduler
Asked by
Nicolas
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Stewart
Top achievements
Rank 1
Peter
Telerik team
Nikolay Tsenkov
Telerik team
James
Top achievements
Rank 2
Share this question
or