Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1082
How to merge all resources and Activities in unique WebSchedule?
posted

Hi Infragistics,

 How to merge all resources and activities in unique WebSchedule?

 Best regards

Parents Reply Children
  • 160
    posted in reply to Lello

    Hi jurisquick,

    I can't provide a complete example, because it's client work. But, I've included some detailed VB.Net snippets below, which I hope will help.

    If you need translations to C#, I suggest you use http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

    Here are the snippets:

     On the page where you use webscheduleinfo, in page load, add handlers for the activity added, updated and deleted event, like this:

            'Add a handler for the customer activity added event
            AddHandler WebScheduleInfo1.ActivityAdded, AddressOf Me.AddCustomerActivity
            'Add a handler for the customer activity deleted event
            AddHandler WebScheduleInfo1.ActivityDeleted, AddressOf Me.DeleteCustomerActivity
            'Add a handler for the customer activity updated event
            AddHandler WebScheduleInfo1.ActivityUpdated, AddressOf Me.UpdateCustomerActivity

    Then in each handler, add some additional logic to add/update/delete the mirror appointment, for example:

     Private Sub AddCustomerActivity(ByVal s As Object, ByVal e As Infragistics.WebUI.WebSchedule.ActivityEventArgs)

            'Capture the newly added activity 
            Try


                Dim cusappointment As Infragistics.WebUI.WebSchedule.Appointment
                cusappointment = e.Activity

         Dim eventid as integer = e.datakey


                Dim cusScheduleInfo As Infragistics.WebUI.WebSchedule.WebScheduleInfo
                cusScheduleInfo = cusappointment.ScheduleInfo
                cusScheduleInfo.DataBind()

                AddMirrorActivity(WebScheduleInfoAgg, WebScheduleInfo1, SqlDataSourceAgg, WebScheduleSqlClientProviderAgg, eventid, ....)

               .....

            Catch etc.
            End Try

        End Sub

     


     Private Sub AddMirrorActivity(ByVal WebScheduleInfoAggregate As WebScheduleInfo, ByVal WebScheduleInfoReal As WebScheduleInfo, ByVal SqlDataSourceAggregate As SqlDataSource, ByVal WebScheduleSqlClientProviderAggregate As WebScheduleSqlClientProvider, ByVal AppointmentID As Integer ...)

            Try

                WebScheduleInfoAggregate.ActiveResourceName = "Aggregate"

                SqlDataSourceAggregate.DataBind()
                WebScheduleInfoAggregate.DataBind(

                Dim realappt As Appointment
                realappt = FindAppointment(AppointmentID, WebScheduleInfoReal)

                If Not IsNothing(realappt) Then


                    'Now create a new mirror appointment for the Aggregate resource
                    WebScheduleInfoAggregate.DataBind()
                    Dim appt As New Appointment(WebScheduleInfoAggregate)


                    appt.EndDateTime = realappt.EndDateTime
                    appt.Duration = realappt.Duration
                    appt.AllDayEvent = realappt.AllDayEvent
                    appt.Status = realappt.Status
                    appt.Subject = realappt.Subject
                    appt.StartDateTime = realappt.StartDateTime
                    appt.Description = realappt.Description
                    appt.ShowTimeAs = realappt.ShowTimeAs
                    appt.ResourceKey = WebScheduleInfoAggregate.ActiveResource.DataKey

                    WebScheduleInfoAggregate.Activities.Add(appt)
                    WebScheduleSqlClientProviderAggregate.AddActivity(appt, WebScheduleInfoAggregate.ActiveResource)
                    SqlDataSourceAggregate.DataBind()
                    WebScheduleInfoAggregate.DataBind()


                    Dim NewApptKey As Integer = appt.DataKey
                 AddAppointmenttLink(Appointmentid, NewApptKey ...)

          .....

            Catch etc..
            End Try

        End Sub


    Now replicate this approach for the update and delete handlers .....

    In your page which displays the aggregate resource, bind the dayview to the aggregate resource, which will then contain only the "mirror" appointments.


    Regards.

     

    Mike