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

Sending extra info to the web service

25 Answers 645 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
broctune
Top achievements
Rank 1
broctune asked on 31 Mar 2009, 04:40 PM
I'm using The Q1 2009 Scheduler control with a Web Service data source.  I would like to pass some extra information to the GetAppointments web method that will determine which types of appointments are returned.  The only parameter of this method is of type SchedulerInfo and that object only has 2 properties: ViewStart and ViewEnd.  Is there a way to pass any additional information?  I would like to use the OnClientAppointmentsPopulating event to add more data to the Scheduler Info object.

Any ideas?

Thanks,
Dave

25 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 03 Apr 2009, 04:22 PM
Hello,

Thank you for the excellent question. You're on the right track - the populating event is exactly what you need. You can add your custom fields like this:

function aptsPopulating(sender, eventArgs)
{
    var info = eventArgs.get_schedulerInfo();
    info.MyCustomInfo = "Test";
}


In order to read this on the server you need to inherit the SchedulerInfo class:

public class MySchedulerInfo : SchedulerInfo
{
    private string _myCustomInfo;

    public string MyCustomInfo
    {
        get
        {
            return _myCustomInfo;
        }

        set
        {
            _myCustomInfo = value;
        }
    }
}

[WebMethod]
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
    string info = schedulerInfo.MyCustomInfo;
    // ...
}

Serialization shouldn't be an issue with most types. Dates are a bit trickier as you need to compensate for the client browser time zone offset, as they are serialized as ticks. We do this in RadScheduler, but for simplicity I recommend you to pass them as strings in a well known format.

Regards,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Raj Nemani
Top achievements
Rank 1
answered on 21 Apr 2009, 01:45 PM
Hi,

As a follow up, I was wondering if you can answer this question

I have the following WebserviceappointmentController classs, shown partially here

 

public class SchedulerService : ISchedulerService

 

{

 

private WebServiceAppointmentController _controller;

 

 

private WebServiceAppointmentController Controller

 

{

 

get

 

{

 

if (_controller == null)

 

{

_controller =

 

new WebServiceAppointmentController(new SchedulerServiceProvider());

 

}

 

return _controller;

 

}

}

 

public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)

 

{

 

return Controller.GetAppointments(schedulerInfo);

 

}

.....
.....

When GetAppointment is called, the call to Controller.GetAppointments correctly takes me to the GetAppointments method of ScheduleServiceProvider which inherits SchedulerProviderBase class.  But with in the GetAppointments method of this ScheudleService provider,I cannot see a way to get  bavck to MySchedulerInfo and the my custom data in there.  If I cannot get to it then I cannot do much becasue all the backend stuff to get appointment data happens in ScehduleService provider based on the MySchedulerInfo data. 

I hope you will be able to throw some light on this. 

Thanks
Raj

 

0
T. Tsonev
Telerik team
answered on 24 Apr 2009, 12:40 PM
Hi,

Thank you for the excellent question. It's true that the existing SchedulerProvider interface limits us in our options to pass information to the provider. We are considering improving it, but for the moment there are two options:

1. Use the session to pass parameters:
[WebMethod(EnableSession = true)]
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
    Session["Data"] = schedulerInfo.Data;
    return Controller.GetAppointments(schedulerInfo);
}

// Provider code:
int Data = (int) HttpContext.Current.Session["Data"];

2. Instantiate the provider per request and use its public properties to pass parameters.

I hope this helps.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paige Cook
Top achievements
Rank 2
answered on 14 Aug 2009, 05:52 PM
Hi,

I wanted to see if there had been any improvements to the SchedulerProvider to allow for sending additional information to the provider. I am looking at implementing the WCF services, if that makes any difference. 

I saw that there is now GetAppointmentsMethod property of the WebServices attribute and wondered if that could be leveraged in this way. if so, could you provide a code sample?

Also, I really like the addition of the SchedulerOperationResult class that can be used to pass extra data back along with the appointments. I think that will be very useful.

Thanks,
Paige


Thanks.
0
T. Tsonev
Telerik team
answered on 19 Aug 2009, 05:19 PM
Hi,

We still haven't implemented the improvements to the SchedulerProvider abstract base class. The Session and directly referencing the provider instance remain the only two options for passing additional information to the provider.

The GetAppointmentsMethod property only specifies the Web Service method name to be used for retrieving appointments and has no other uses.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paige Cook
Top achievements
Rank 2
answered on 20 Aug 2009, 12:21 PM
Hi Tesvetomir,

Thank you for the update, I appreciate it. Do you know if there is a targeted release yet for making improvements to the SchedulerProvider abstract base to accommodate passing additional information?


Thank You,
Paige
0
T. Tsonev
Telerik team
answered on 26 Aug 2009, 08:56 AM
Hi,

I'm not sure if time will allow us to complete these improvements for the Q3 release, as we already have a lot of work in the pipeline. We'll be working on a prototype meanwhile, but for now our primary objective is to get feedback from the community.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Michael
Top achievements
Rank 1
answered on 28 Oct 2009, 06:52 PM
Do you have an example of how to do option 2:

2. Instantiate the provider per request and use its public properties to pass parameters.
0
T. Tsonev
Telerik team
answered on 03 Nov 2009, 09:55 AM
Hi Michael,

This is what I had in mind:

[WebMethod]
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
    MySchedulerProvider provider = new MySchedulerProvider(...);
 
    provider.Property = MySchedulerInfo.Property;
 
    WebServiceAppointmentController controller = new WebServiceAppointmentController(provider);
 
    return controller.GetAppointments(schedulerInfo);
}

You can use your implementation of ISchedulerInfo to pass additional data as described earlier. Then you set a property on the provider to let it know about the additional data.

The drawback is that the provider must be instantiated on each request, while its normally shared between requests.

All the best,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
towpse
Top achievements
Rank 2
answered on 23 Nov 2009, 03:26 PM
All that's been discussed makes sense for the populating method since you can get at a scheduler info
function AppointmentsPopulating(sender, eventArgs) { 
    var info = eventArgs.get_schedulerInfo(); 
    info.ObjectId = "BEE39F67-3737-4A05-9AA3-DD61D9CCEE77"; //TODO get Object ID from UI

What about on Insert, update, delete methods? How do I accomplish this when all I have access to in this case is the appointment object which as far as I can tell right now does not expose a scheduler info? Is that right?
function AppointmentWebServiceInserting(sender, eventArgs) { 
    //get object Id from UI and pass it along to the scheduler info so I can get at the object Id from the web service

I will then need to obtain the object Id in the web service
        [WebMethod] 
        public IEnumerable<AppointmentData> InsertAppointment(OutputControlSchedulerInfo schedulerInfo, AppointmentData appointmentData) 
        { 
            if (!string.IsNullOrEmpty(appointmentData.RecurrenceRule)) 
            { 
                appointmentData.RecurrenceState = RecurrenceState.Master; 
            } 
            MyScheduleProvider provider = new MyScheduleProvider(); 
            provider.ObjectId = schedulerInfo.ObjectId; 
            WebServiceAppointmentController controller = new WebServiceAppointmentController(provider); 
            return controller.InsertAppointment(schedulerInfo, appointmentData); 
        } 

Does this make sense at all?

EDIT What event gets fired on the client-side when the save button is clicked on the Advanced Form?
Where do I handle that event and pass an object ID to the web service so it can pass that Id onto the provider?

EDIT yeah it seems i do have the scheduler info on the web service insert! very nice.

thanks
0
Peter
Telerik team
answered on 24 Nov 2009, 02:32 PM
Hello towps,

Thank you for posting these questions and thus enriching the discussion. It seems you were able to find the answers yourself, but feel free to contact us if you have further questions or concerns.


All the best,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
towpse
Top achievements
Rank 2
answered on 26 Nov 2009, 03:17 PM
What is the purpose of using this web service appointment controller object in the following code?

    MySchedulerProvider provider = new MySchedulerProvider(...);  
   
    provider.Property = MySchedulerInfo.Property;  
   
    WebServiceAppointmentController controller = new WebServiceAppointmentController(provider);  
   
    return controller.GetAppointments(schedulerInfo); 

When in this case I coould just as easily call provider.GetAppointments?
What does this technique buy?
0
T. Tsonev
Telerik team
answered on 01 Dec 2009, 05:22 PM
Hello,

The WebServiceAppointmentController.GetAppointments method takes care of filtering only the visible appointments and for expanding recurring series.

It's meant to be a bridge between the provider and the control instance and to encapsulate the logic that links them together.

I hope this helps.

Greetings,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jimmy Jou
Top achievements
Rank 1
answered on 05 Dec 2009, 04:31 AM
While we are on the subject of passing extra data from Scheduler to web service using custom scheduler provider, I like to ask if there is a way to pass the hosting web site URL to custom scheulder provider? I saw RadScheduler has data member Site, Page, and Parent. But they are all null when reaching web service side.

Is session the only way to pass back the web page URL that hosts the Scheduler? By the way, I am working in SharePoint environment and the hosting site URL is the most popular parameter to hold on.
0
T. Tsonev
Telerik team
answered on 08 Dec 2009, 04:48 PM
Hello Jimmy,

I can confirm that at the moment the two options for passing information to the provider are:

1. Transfer information via the Session
2. Instantiate the provider per request and use its public properties to pass parameters

Those are described in the forum thread and we can provide samples if necessary.

We have plans to improve this by updating the RadScheduler provider interface, but it's unlikely that we'll be able to complete these changes in time for the next release.

All the best,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ryan Eaves
Top achievements
Rank 1
answered on 01 Sep 2010, 07:03 PM
I just wanted to add something to this thread for others who are reading it and can't see how to use your custom fields during Web Services Update/Insert/Delete. Two helpful things that are not documented:

1) The OnClientAppointmentsPopulating event gets fired even when the Scheduler is doing a WebServices Update/Insert/Delete. So if you are using the same values in each operation, then you can just add the values to the SchedulerInfo object in this event and they will be present during all operations.

2) Even though it's not currently listed in the documentation, you can access the SchedulerInfo in the Web Services Update/Insert/Delete client-side events like this: eventArgs.get_schedulerInfo(). So, if you have different values you want to add for each operation, you can do so in the appropriate client-side event.

-Ryan
0
T. Tsonev
Telerik team
answered on 25 Oct 2010, 12:44 PM
Hi,

I'd like to announce that we've made improvements to the provider interface of RadScheduler that make sending extra data much easier. Read more here: http://blogs.telerik.com/tsvetomirtsonev/posts/10-10-25/radscheduler_for_asp_net_ajax_-_improvements_to_provider_interface_in_q3_2010.aspx

Please feel free to try the Q3 2010 Beta and let us know if you have any comments.

Ryan, thanks for sharing the hints - we're updating the documentation right now and we'll try to make these possibilities clear.

Greetings,
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
towpse
Top achievements
Rank 2
answered on 26 Oct 2010, 03:30 PM
Did you folks attack the issue of rendering many appointments on the UI in IE?
When the scheduler needs to render many daily appointments in month view, even though it only displays 2 per day, the total number of appointments can be quite large and unfortunately the scheduler returns and iterates through all though it really needs to only worry about 2 per day.
This causes IE to be unresponsive. Not sure if anyone on your end has started looking at that issue yet.

cheers
0
T. Tsonev
Telerik team
answered on 27 Oct 2010, 03:35 PM
Hi Matt,

Yes, we're working on this problem as well. The official release will be a bit smarter about the extra appointments and will trim them before leaving the web service.

I hope this helps.

Greetings,
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
Matthew
Top achievements
Rank 1
answered on 01 Jun 2011, 02:42 PM
Hi there,

I've been looking at this thread, and this section in the online documentation:

http://www.telerik.com/help/aspnet-ajax/scheduler-sending-additional-information-to-the-web-service.html


But I'm struggling to make my radscheduler populate from my web service at the moment.

I've got the following in my sheduler control
<WebServiceSettings Path="~/Services/Calendar_Service.asmx" />

And have a javascript function being called with the 'OnClientAppointmentsPopulating', which sets my accountid property :
eventArgs.get_schedulerInfo().AccountID

I've my own SchedulerInfo class:

public class MySchedulerInfo : SchedulerInfo
{
    public int AccountID { get; set; }
    public MySchedulerInfo(ISchedulerInfo baseInfo, int accountid)
        : base(baseInfo)
    {
        AccountID = accountid;
    }
}

My web service takes an object of this class as a param:

[WebMethod]
public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
{
    return Controller.GetAppointments(schedulerInfo);
}

And I have my own custom provider that takes an ISchedulerInfo param with it's 'GetAppointments' method.


However, when I run this, I just get a javascript alert with the following error (twice):

"No parameterless constructor defined for type of 'Classes.MySchedulerInfo'"


I've tried to do this as per the instructions, what am I missing?
0
Veronica
Telerik team
answered on 01 Jun 2011, 03:00 PM
Hi Ryan Eaves,

This error is self-descriptive:  you don't have parameterless constructor in the MySchedulerInfo class. Please add the following constructor and everything will work OK:

public class MySchedulerInfo : SchedulerInfo
{
    public int AccountID { get; set; }
    public MySchedulerInfo(ISchedulerInfo baseInfo, int accountid)
        : base(baseInfo)
    {
        AccountID = accountid;
    }
      
    public MySchedulerInfo()
    {
  
    }
}


All the best,
Veronica Milcheva
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
Matthew
Top achievements
Rank 1
answered on 01 Jun 2011, 03:21 PM
That's far too obvious! That worked, thanks for that. It might be worth updating your documentation, as I just copied and pasted the class from there:

http://www.telerik.com/help/aspnet-ajax/scheduler-sending-additional-information-to-the-web-service.html
0
Veronica
Telerik team
answered on 01 Jun 2011, 03:24 PM
Hello Ryan Eaves,

You are definitely right that the documentation needs improvement. Thank you!

Best wishes,
Veronica Milcheva
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
Kuldeep
Top achievements
Rank 1
answered on 20 May 2013, 04:35 PM
How I will access the scheduler info in wcf ??

0
Plamen
Telerik team
answered on 22 May 2013, 05:42 AM
Hi,

 You can refer to this Code Library where are provided all the steps to sent more information to the service. The steps are exactly the same in scenario with WCF service.

Hope this will be helpful.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
broctune
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Raj Nemani
Top achievements
Rank 1
Paige Cook
Top achievements
Rank 2
Michael
Top achievements
Rank 1
towpse
Top achievements
Rank 2
Peter
Telerik team
Jimmy Jou
Top achievements
Rank 1
Ryan Eaves
Top achievements
Rank 1
Matthew
Top achievements
Rank 1
Veronica
Telerik team
Kuldeep
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or